@univerjs/sheets-hyper-link-ui 0.2.4-alpha.0 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
- import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { Injector } from '@wendellhu/redi';
2
+ import { Plugin, UniverInstanceType } from '@univerjs/core';
2
3
  import { IRenderManagerService } from '@univerjs/engine-render';
3
4
  import { IUniverSheetsHyperLinkUIConfig } from './controllers/ui.controller';
4
5
 
@@ -1,7 +1,8 @@
1
1
  import { ISheetLocationBase } from '@univerjs/sheets';
2
2
  import { HyperLinkModel } from '@univerjs/sheets-hyper-link';
3
3
  import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
4
- import { IDisposable, Disposable } from '@univerjs/core';
4
+ import { IDisposable } from '@wendellhu/redi';
5
+ import { Disposable } from '@univerjs/core';
5
6
 
6
7
  export interface IHyperLinkPopup {
7
8
  unitId: string;
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(l,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("clsx"),require("@univerjs/design"),require("@univerjs/ui"),require("@univerjs/engine-formula"),require("@univerjs/docs-hyper-link"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/engine-render","rxjs","react","clsx","@univerjs/design","@univerjs/ui","@univerjs/engine-formula","@univerjs/docs-hyper-link","@univerjs/docs"],a):(l=typeof globalThis<"u"?globalThis:l||self,a(l.UniverSheetsHyperLinkUi={},l.UniverCore,l.UniverSheets,l.UniverSheetsHyperLink,l.UniverSheetsUi,l.UniverEngineRender,l.rxjs,l.React,l.clsx,l.UniverDesign,l.UniverUi,l.UniverEngineFormula,l.UniverDocsHyperLink,l.UniverDocs))})(this,function(l,a,h,v,f,ue,pe,C,ke,I,O,D,De,Ae){"use strict";var Gn=Object.defineProperty;var Xn=(l,a,h)=>a in l?Gn(l,a,{enumerable:!0,configurable:!0,writable:!0,value:h}):l[a]=h;var $=(l,a,h)=>Xn(l,typeof a!="symbol"?a+"":a,h);var Ve=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,xe=(i,e,t,n)=>{for(var r=n>1?void 0:n?Be(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ve(e,t,r),r},he=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkRemoveSheetController=class extends a.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._hyperLinkModel=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var t;if(e.id===h.RemoveSheetCommand.id){const n=e.params,r=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return{redos:[],undos:[]};const o=r.getUnitId(),s=n.subUnitId||((t=r.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const c=this._hyperLinkModel.getSubUnit(o,s),d=c.map(S=>({id:v.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:s,id:S.id}})),p=c.map(S=>({id:v.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:s,link:S}}));return{redos:d,undos:p}}return{redos:[],undos:[]}}}))}},l.SheetsHyperLinkRemoveSheetController=xe([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkRemoveSheetController),he(0,a.Inject(h.SheetInterceptorService)),he(1,a.IUniverInstanceService),he(2,a.Inject(v.HyperLinkModel))],l.SheetsHyperLinkRemoveSheetController);var We=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Ie=(i,e,t,n)=>{for(var r=n>1?void 0:n?Fe(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&We(e,t,r),r},Y=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkRenderController=class extends a.Disposable{constructor(e,t,n,r){super(),this._context=e,this._hyperLinkModel=t,this._sheetSkeletonManagerService=n,this._renderManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var c;const t=this._context.unit,n=t.getUnitId(),r=(c=t.getActiveSheet())==null?void 0:c.getSheetId();if(!r){console.warn("No active sheet found");return}const o=this._sheetSkeletonManagerService.getOrCreateSkeleton({sheetId:r}),s=this._renderManagerService.getRenderById(n);o==null||o.makeDirty(!0),o==null||o.calculate(),s&&s.mainComponent.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(()=>{e()}))}},l.SheetsHyperLinkRenderController=Ie([Y(1,a.Inject(v.HyperLinkModel)),Y(2,a.Inject(f.SheetSkeletonManagerService)),Y(3,ue.IRenderManagerService)],l.SheetsHyperLinkRenderController),l.SheetsHyperLinkRenderManagerController=class extends a.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._themeService=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(h.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(e,t,n)=>{const{row:r,col:o,unitId:s,subUnitId:c}=t,d=this._hyperLinkModel.getHyperLinkByLocation(s,c,r,o),p=this._themeService.getCurrentTheme();return n(d?{...e,interceptorStyle:{ul:{s:a.BooleanNumber.TRUE},cl:{rgb:p.blue500}}}:e)},priority:100}))}},l.SheetsHyperLinkRenderManagerController=Ie([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkRenderManagerController),Y(0,a.Inject(h.SheetInterceptorService)),Y(1,a.Inject(v.HyperLinkModel)),Y(2,a.Inject(a.ThemeService))],l.SheetsHyperLinkRenderManagerController);var Re={exports:{}},ne={};/**
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/docs-hyper-link"),require("@univerjs/docs")):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/docs-hyper-link","@univerjs/docs"],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.UniverDocsHyperLink,l.UniverDocs))})(this,function(l,a,h,y,v,_,me,re,L,U,Re,R,w,V,Ve,xe){"use strict";var Jn=Object.defineProperty;var Qn=(l,a,h)=>a in l?Jn(l,a,{enumerable:!0,configurable:!0,writable:!0,value:h}):l[a]=h;var K=(l,a,h)=>Qn(l,typeof a!="symbol"?a+"":a,h);var We=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Fe=(i,e,t,n)=>{for(var r=n>1?void 0:n?Be(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&We(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===h.RemoveSheetCommand.id){const n=e.params,r=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return{redos:[],undos:[]};const o=r.getUnitId(),s=n.subUnitId||((t=r.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const c=this._hyperLinkModel.getSubUnit(o,s),d=c.map(S=>({id:v.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:s,id:S.id}})),p=c.map(S=>({id:v.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:s,link:S}}));return{redos:d,undos:p}}return{redos:[],undos:[]}}}))}},l.SheetsHyperLinkRemoveSheetController=Fe([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkRemoveSheetController),ve(0,y.Inject(h.SheetInterceptorService)),ve(1,a.IUniverInstanceService),ve(2,y.Inject(v.HyperLinkModel))],l.SheetsHyperLinkRemoveSheetController);var $e=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Pe=(i,e,t,n)=>{for(var r=n>1?void 0:n?Ye(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&&$e(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$.pipe(re.debounceTime(16)).subscribe(()=>{e()}))}},l.SheetsHyperLinkRenderController=Pe([z(1,y.Inject(v.HyperLinkModel)),z(2,y.Inject(_.SheetSkeletonManagerService)),z(3,me.IRenderManagerService)],l.SheetsHyperLinkRenderController),l.SheetsHyperLinkRenderManagerController=class extends a.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._themeService=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(h.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(e,t,n)=>{const{row:r,col:o,unitId:s,subUnitId:c}=t,d=this._hyperLinkModel.getHyperLinkByLocation(s,c,r,o),p=this._themeService.getCurrentTheme();return n(d?{...e,interceptorStyle:{ul:{s:a.BooleanNumber.TRUE},cl:{rgb:p.blue500}}}:e)},priority:100}))}},l.SheetsHyperLinkRenderManagerController=Pe([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkRenderManagerController),z(0,y.Inject(h.SheetInterceptorService)),z(1,y.Inject(v.HyperLinkModel)),z(2,y.Inject(a.ThemeService))],l.SheetsHyperLinkRenderManagerController);var be={exports:{}},ie={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var $e=C,Ye=Symbol.for("react.element"),Ke=Symbol.for("react.fragment"),ze=Object.prototype.hasOwnProperty,Ze=$e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ge={key:!0,ref:!0,__self:!0,__source:!0};function Pe(i,e,t){var n,r={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)ze.call(e,n)&&!Ge.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:Ye,type:i,key:o,ref:s,props:r,_owner:Ze.current}}ne.Fragment=Ke,ne.jsx=Pe,ne.jsxs=Pe,Re.exports=ne;var m=Re.exports,T=function(){return T=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},T.apply(this,arguments)},Xe=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},F=C.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,s=Xe(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),d=C.useRef("_".concat(qe()));return Ee(t,"".concat(n),{defIds:t.defIds,idSuffix:d.current},T({ref:e,className:c},s),o)});function Ee(i,e,t,n,r){return C.createElement(i.tag,T(T({key:e},Je(i,t,r)),n),(Qe(i,t).children||[]).map(function(o,s){return Ee(o,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,r)}))}function Je(i,e,t){var n=T({},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)?T(T({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?T(T({},r),{attrs:T(T({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function qe(){return Math.random().toString(36).substring(2,8)}F.displayName="UniverIcon";var en={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},te=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"all-border-single",ref:e,icon:en}))});te.displayName="AllBorderSingle";var nn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.02547 12.4251C5.15328 13.7417 6.26305 14.7708 7.61318 14.7708H12.6132C14.0491 14.7708 15.2132 13.6067 15.2132 12.1708V6.1708C15.2132 4.78586 14.1303 3.65383 12.7651 3.57517C12.6373 2.25858 11.5275 1.22949 10.1774 1.22949H5.17739C3.74145 1.22949 2.57739 2.39355 2.57739 3.82949V9.82949C2.57739 11.2144 3.66024 12.3465 5.02547 12.4251ZM11.5535 3.5708H7.61318C6.17724 3.5708 5.01318 4.73486 5.01318 6.1708V11.22C4.31736 11.1387 3.77739 10.5471 3.77739 9.82949V3.82949C3.77739 3.05629 4.40419 2.42949 5.17739 2.42949H10.1774C10.8622 2.42949 11.4322 2.92119 11.5535 3.5708ZM14.0132 6.1708C14.0132 5.3976 13.3864 4.7708 12.6132 4.7708H7.61318C6.83998 4.7708 6.21318 5.3976 6.21318 6.1708V12.1708C6.21318 12.944 6.83998 13.5708 7.61318 13.5708H12.6132C13.3864 13.5708 14.0132 12.944 14.0132 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},be=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"copy-single",ref:e,icon:nn}))});be.displayName="CopySingle";var tn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},re=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"link-single",ref:e,icon:tn}))});re.displayName="LinkSingle";var rn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},Oe=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"unlink-single",ref:e,icon:rn}))});Oe.displayName="UnlinkSingle";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},Me=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"write-single",ref:e,icon:on}))});Me.displayName="WriteSingle";var sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.36396 1.12549C2.61066 1.12549 2 1.73615 2 2.48945V13.5104C2 14.2637 2.61066 14.8744 3.36396 14.8744H12.457C13.2103 14.8744 13.821 14.2637 13.821 13.5104V5.0992L9.91954 1.12549H3.36396Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M9.91797 1.12549L13.8209 5.09842H10.5846C10.2164 5.09842 9.91797 4.79994 9.91797 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.71926 10.2949L6.28687 12.403C6.17306 12.5705 5.94501 12.614 5.77751 12.5002C5.61002 12.3864 5.56649 12.1584 5.6803 11.9909L7.27596 9.64252L5.85088 7.54519C5.73707 7.37769 5.78059 7.14964 5.94809 7.03583C6.11558 6.92202 6.34363 6.96555 6.45744 7.13304L7.71926 8.9901L8.98108 7.13304C9.09489 6.96555 9.32294 6.92202 9.49044 7.03583C9.65793 7.14964 9.70146 7.37769 9.58765 7.54519L8.16256 9.64252L9.75822 11.9909C9.87203 12.1584 9.82851 12.3864 9.66101 12.5002C9.49351 12.614 9.26547 12.5705 9.15166 12.403L7.71926 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},me=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"xlsx",ref:e,icon:sn}))});me.displayName="Xlsx";var an=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,cn=(i,e,t,n)=>{for(var r=n>1?void 0:n?ln(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&an(e,t,r),r},G=(i,e)=>(t,n)=>e(t,n,i);function dn(i,e){const t=e.getMergeData(),n=e.getMaxColumns()-1,r=e.getMaxRows()-1;if(n<i.endColumn&&(i.endColumn=n),r<i.endRow&&(i.endRow=r),i.rangeType===a.RANGE_TYPE.COLUMN||a.RANGE_TYPE.ROW)return i;const o=[];return t.forEach(s=>{a.Rectangle.intersects(i,s)&&o.push(s)}),a.Rectangle.realUnion(i,...o)}l.SheetsHyperLinkResolverService=class{constructor(e,t,n,r,o){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=o}_getURLName(e){var d;const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const s=t?o.getSheetBySheetId(t):o.getActiveSheet(),c=(d=s==null?void 0:s.getName())!=null?d:"";if(n){const p=D.deserializeRangeWithSheet(n).range;return a.isValidRange(p)&&n!==v.ERROR_RANGE?{type:"range",name:D.serializeRangeWithSheet(c,p)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const p=this._definedNamesService.getValueById(o.getUnitId(),r);return p?{type:"defineName",name:p.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(t){const p=o.getSheetBySheetId(t);return p?{type:"sheet",name:p.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(e){const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=o.getUnitId();if(r&&this.navigateToDefineName(s,r),!!t){if(n){const c=D.deserializeRangeWithSheet(n);a.isValidRange(c.range)&&n!==v.ERROR_RANGE&&this.navigateToRange(s,t,c.range);return}this.navigateToSheetById(s,t)}}parseHyperLink(e){var t,n,r;if(e!=null&&e.startsWith("#")){const o=new URLSearchParams(e.slice(1)),s={gid:(t=o.get("gid"))!=null?t:"",range:(n=o.get("range"))!=null?n:"",rangeid:(r=o.get("rangeid"))!=null?r:""},c=this._getURLName(s);return{type:(c==null?void 0:c.type)||"link",name:(c==null?void 0:c.name)||e,url:e,searchObj:s,handler:()=>{this.navigateTo(s)}}}else return{type:"outer",name:e,url:e,handler:()=>{this.navigateToOtherWebsite(e)}}}async navigateToRange(e,t,n){const r=await this.navigateToSheetById(e,t);if(r){const o=dn(n,r);await this._commandService.executeCommand(h.SetSelectionsOperation.id,{unitId:e,subUnitId:t,selections:[{range:o}]}),await this._commandService.executeCommand(f.ScrollToRangeOperation.id,{range:o})}}async navigateToSheet(e,t){const n=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if((r==null?void 0:r.getName())===t)return!0;const o=n.getSheetBySheetName(t);if(!o){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error});return}const s=o.getSheetId();return n.getHiddenWorksheets().indexOf(s)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),await this._commandService.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:s})}async navigateToSheetById(e,t){const n=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const o=n.getSheetBySheetId(t);return o?n.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),!1):await this._commandService.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error}),!1)}async navigateToDefineName(e,t){return this._definedNamesService.focusRange(e,t),!0}async navigateToOtherWebsite(e){window.open(e,"_blank","noopener noreferrer")}},l.SheetsHyperLinkResolverService=cn([G(0,a.IUniverInstanceService),G(1,a.ICommandService),G(2,D.IDefinedNamesService),G(3,O.IMessageService),G(4,a.Inject(a.LocaleService))],l.SheetsHyperLinkResolverService);function X(i){return a.Tools.isLegalUrl(i)}function un(i){return/^[a-zA-Z]+:\/\//.test(i)}function pn(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function ve(i){if(X(i)){const e=un(i)?i:pn(i)?`mailto://${i}`:`http://${i}`,t=new URL(e);return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:e}return i}function hn(i){if(i===null)return"";if(i!=null&&i.p){const e=i==null?void 0:i.p.body;if(e==null)return"";const t=e.dataStream;return t.substring(t.length-2,t.length)===a.DEFAULT_EMPTY_DOCUMENT_VALUE?t.substring(0,t.length-2):t}return i==null?void 0:i.v}const mn={cellLinkEditButtons:"univer-cell-link-edit-buttons"},ie=()=>{var ee;const[i,e]=C.useState(""),[t,n]=C.useState(""),[r,o]=C.useState("link"),[s,c]=C.useState(""),d=a.useDependency(a.LocaleService),p=a.useDependency(D.IDefinedNamesService),S=a.useDependency(a.IUniverInstanceService),_=a.useDependency(l.SheetsHyperLinkPopupService),u=O.useObservable(_.currentEditing$),k=a.useDependency(v.HyperLinkModel),y=a.useDependency(l.SheetsHyperLinkResolverService),L=a.useDependency(a.ICommandService),[R,H]=C.useState(!1),b=C.useRef(!1);C.useEffect(()=>{var g,P,w;if((u==null?void 0:u.row)!==void 0&&u.column!==void 0){const E=k.getHyperLinkByLocationSync(u.unitId,u.subUnitId,u.row,u.column);if(E){const de=y.parseHyperLink(E.payload);if(e(E.id),n(E.display),de.type==="outer"){o("link"),c(de.url),de.url===E.display&&(b.current=!0);return}else{const V=de.searchObj;if(V.rangeid){o("rangeid"),c(V.rangeid);return}if(V.range){const Zn=V.gid&&(w=(P=(g=S.getUnit(u.unitId))==null?void 0:g.getSheetBySheetId(V.gid))==null?void 0:P.getName())!=null?w:"";if(o("range"),V.range===v.ERROR_RANGE)c("");else{const Ne=D.serializeRangeWithSheet(Zn,D.deserializeRangeWithSheet(V.range).range);c(Ne),Ne===E.display&&(b.current=!0)}return}if(V.gid){o("gid"),c(V.gid);return}}}const j=S.getUnit(u.unitId),N=j==null?void 0:j.getSheetBySheetId(u.subUnitId),zn=N==null?void 0:N.getCellRaw(u.row,u.column),Le=hn(zn);o("link"),c(""),n((Le!=null?Le:"").toString()),e("");return}o("link"),c(""),n(""),e("")},[u,k,y,S]);const U=C.useMemo(()=>s,[r]),B=[{label:d.t("hyperLink.form.link"),value:"link"},{label:d.t("hyperLink.form.range"),value:"range"},{label:d.t("hyperLink.form.worksheet"),value:"gid"},{label:d.t("hyperLink.form.definedName"),value:"rangeid"}],M=S.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!M)return;const Z=M.getHiddenWorksheets(),x=M.getSheets().map(g=>({label:g.getName(),value:g.getSheetId()})).filter(g=>Z.indexOf(g.value)===-1),W=Object.values((ee=p.getDefinedNameMap(M.getUnitId()))!=null?ee:{}).map(g=>({label:g.name,value:g.id})),q=(g,P)=>{if(g==="link")return ve(P);if(g==="range"){const w=D.deserializeRangeWithSheet(P),E=M.getSheetBySheetName(w.sheetName);if(E)return`#gid=${E.getSheetId()}&range=${D.serializeRange(w.range)}`}return`#${g}=${P}`},_e=O.useEvent(g=>{var E;const P=g[0];if(!P||!a.isValidRange(P.range))return;P.sheetName||(P.sheetName=((E=M.getActiveSheet())==null?void 0:E.getName())||"");const w=D.serializeRangeToRefString(P);c(w),w&&(b.current||!t)&&(n(w),b.current=!0)}),Ce=async()=>{if(u&&(i?await L.executeCommand(v.UpdateHyperLinkCommand.id,{unitId:u.unitId,subUnitId:u.subUnitId,id:i,payload:{display:t,payload:q(r,s)}}):await L.executeCommand(v.AddHyperLinkCommand.id,{unitId:u.unitId,subUnitId:u.subUnitId,link:{id:a.Tools.generateRandomId(),row:u.row,column:u.column,payload:q(r,s),display:t}})),u){await L.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:u.unitId,subUnitId:u.subUnitId});const g=1;await L.executeCommand(f.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-g,0),endRow:u.row+g,startColumn:Math.max(u.column-g,0),endColumn:u.column+g}})}L.executeCommand(J.id)};return m.jsxs("div",{children:[m.jsx(I.FormLayout,{label:d.t("hyperLink.form.label"),error:R&&!t?d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:t,onChange:g=>{n(g),b.current=!1},placeholder:d.t("hyperLink.form.labelPlaceholder")})}),m.jsx(I.FormLayout,{label:d.t("hyperLink.form.type"),children:m.jsx(I.Select,{options:B,value:r,onChange:g=>{o(g),c("")}})}),r==="link"&&m.jsx(I.FormLayout,{error:R?s?X(s)?"":d.t("hyperLink.form.linkError"):d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:s,onChange:g=>{c(g),g&&(b.current||!t||t===s)&&(n(g),b.current=!0)},placeholder:d.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&m.jsx(I.FormLayout,{error:R&&!s?d.t("hyperLink.form.inputError"):"",children:m.jsx(O.RangeSelector,{openForSheetUnitId:M.getUnitId(),id:a.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:U,onChange:_e})}),r==="gid"&&m.jsx(I.FormLayout,{error:R&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:x,value:s,onChange:g=>{var E,j;c(g);const P=(E=x.find(N=>N.value===g))==null?void 0:E.label,w=(j=x.find(N=>N.value===s))==null?void 0:j.label;P&&(b.current||!t||t===w)&&(n(P),b.current=!0)}})}),r==="rangeid"&&m.jsx(I.FormLayout,{error:R&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:W,value:s,onChange:g=>{var E,j;c(g);const P=(E=W.find(N=>N.value===g))==null?void 0:E.label,w=(j=W.find(N=>N.value===s))==null?void 0:j.label;P&&(b.current||!t||t===w)&&(n(P),b.current=!0)}})}),m.jsxs("div",{className:mn.cellLinkEditButtons,children:[m.jsx(I.Button,{onClick:()=>{u&&L.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:u.unitId,subUnitId:u.subUnitId}),L.executeCommand(J.id)},children:d.t("hyperLink.form.cancel")}),m.jsx(I.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!t||!s||r==="link"&&!X(s)){H(!0);return}Ce()},children:d.t("hyperLink.form.ok")})]})]})};ie.componentKey="univer.sheet.cell-link-edit";const oe={type:a.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(i,e){if(!e)return!1;const{unitId:t,subUnitId:n,row:r,column:o}=e,s=i.get(v.HyperLinkModel),c=i.get(O.ISidebarService),d=i.get(l.SheetsHyperLinkPopupService),p=s.getHyperLinkByLocation(t,n,r,o);return d.startEditing(e),c.open({header:{title:p?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:ie.componentKey}}),!0}},J={type:a.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const e=i.get(O.ISidebarService),t=i.get(l.SheetsHyperLinkPopupService);return e.close(),t.endEditing(),!0}},se={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(a.IUniverInstanceService),t=h.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(a.ICommandService),o=i.get(h.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const s=o.primary.startRow,c=o.primary.startColumn;return n.executeCommand(oe.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:s,column:c})}},ge={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const e=i.get(a.ICommandService);return i.get(l.SheetsHyperLinkPopupService).currentEditing?e.executeCommand(J.id):e.executeCommand(se.id)}},A={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},vn={outer:m.jsx(re,{}),link:m.jsx(re,{}),sheet:m.jsx(me,{}),range:m.jsx(te,{}),defineName:m.jsx(te,{}),"range-error":m.jsx(te,{}),"sheet-error":m.jsx(me,{})},ae=()=>{const i=a.useDependency(l.SheetsHyperLinkPopupService),e=a.useDependency(v.HyperLinkModel),t=a.useDependency(a.ICommandService),n=a.useDependency(O.IMessageService),r=a.useDependency(a.LocaleService),[o,s]=C.useState(null),c=a.useDependency(l.SheetsHyperLinkResolverService);if(C.useEffect(()=>{s(i.currentPopup);const y=i.currentPopup$.subscribe(L=>{s(L)});return()=>{y.unsubscribe()}},[i.currentPopup,i.currentPopup$]),!o)return null;const{unitId:d,subUnitId:p,id:S}=o,_=e.getHyperLink(d,p,S);if(!_)return null;const u=c.parseHyperLink(_.payload),k=u.type.indexOf("error")>-1;return m.jsxs("div",{className:A.cellLink,onClick:()=>i.hideCurrentPopup(),children:[m.jsxs("div",{className:ke(A.cellLinkContent,{[A.cellLinkContentError]:k}),onClick:u.handler,children:[m.jsx("div",{className:A.cellLinkType,children:vn[u.type]}),m.jsx(I.Tooltip,{showIfEllipsis:!0,title:u.name,children:m.jsx("span",{className:A.cellLinkUrl,children:u.name})})]}),m.jsxs("div",{className:A.cellLinkOperations,children:[o.copyPermission&&m.jsx("div",{className:ke(A.cellLinkOperation,{[A.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(u.type!=="outer"){const y=new URL(window.location.href);y.hash=u.url.slice(1),navigator.clipboard.writeText(y.href)}else navigator.clipboard.writeText(u.url);n.show({content:r.t("hyperLink.message.coped"),type:I.MessageType.Info})}},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:m.jsx(be,{})})}),o.editPermission&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:A.cellLinkOperation,onClick:()=>{t.executeCommand(oe.id,{unitId:d,subUnitId:p,row:_.row,column:_.column})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:m.jsx(Me,{})})}),m.jsx("div",{className:A.cellLinkOperation,onClick:()=>{t.executeCommand(v.CancelHyperLinkCommand.id,{unitId:d,subUnitId:p,id:_.id})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:m.jsx(Oe,{})})})]})]})]})};ae.componentKey="univer.sheet.cell-link-popup";var gn=Object.defineProperty,Sn=Object.getOwnPropertyDescriptor,yn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Sn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&gn(e,t,r),r},we=(i,e)=>(t,n)=>e(t,n,i);const fn=(i,e)=>i.unitId===e.unitId&&i.subUnitId===e.subUnitId&&i.row===e.row&&i.col===e.col;l.SheetsHyperLinkPopupService=class extends a.Disposable{constructor(t,n){super();$(this,"_currentPopup",null);$(this,"_currentPopup$",new pe.Subject);$(this,"currentPopup$",this._currentPopup$.asObservable());$(this,"_currentEditing$",new pe.BehaviorSubject(null));$(this,"currentEditing$",this._currentEditing$.asObservable());this._hyperLinkModel=t,this._sheetCanvasPopManagerService=n,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}showPopup(t){if(this._currentPopup&&fn(t,this._currentPopup))return;this.hideCurrentPopup();const{unitId:n,subUnitId:r,row:o,col:s}=t,c=this._hyperLinkModel.getHyperLinkByLocation(n,r,o,s);if(!c)return;const d=this._sheetCanvasPopManagerService.attachPopupToCell(o,s,{componentKey:ae.componentKey,direction:"bottom",closeOnSelfTarget:!0,onClickOutside:()=>{this.hideCurrentPopup()}});d&&(this._currentPopup={unitId:n,subUnitId:r,id:c.id,disposable:d,row:o,col:s,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(){var t;this._currentPopup&&((t=this._currentPopup.disposable)==null||t.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}startEditing(t){this._currentEditing$.next(t)}endEditing(){this._currentEditing$.next(null)}},l.SheetsHyperLinkPopupService=yn([we(0,a.Inject(v.HyperLinkModel)),we(1,a.Inject(f.SheetCanvasPopManagerService))],l.SheetsHyperLinkPopupService);var _n=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,Ln=(i,e,t,n)=>{for(var r=n>1?void 0:n?Cn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&_n(e,t,r),r},K=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkSetRangeController=class extends a.Disposable{constructor(e,t,n,r,o,s){super(),this._sheetInterceptorService=e,this._injector=t,this._hyperLinkModel=n,this._selectionManagerService=r,this._univerInstanceService=o,this._editorBridgeService=s,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor(),this._initRichTextEditorInterceptor()}_getCurrentCell(e,t,n,r){var o,s;return(s=(o=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetId(t))==null?void 0:s.getCell(n,r)}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var t;if(e.id===v.AddHyperLinkCommand.id){const n=e.params,{unitId:r,subUnitId:o,link:s}=n,c=this._getCurrentCell(r,o,s.row,s.column),d={unitId:r,subUnitId:o,cellValue:{[s.row]:{[s.column]:{v:s.display,p:null,t:(t=c==null?void 0:c.t)!=null?t:void 0}}}};return{redos:[{id:h.SetRangeValuesMutation.id,params:d}],undos:[{id:h.SetRangeValuesMutation.id,params:h.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}return{redos:[],undos:[]}}}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===v.UpdateHyperLinkCommand.id){const t=e.params,{unitId:n,subUnitId:r,id:o,payload:s}=t,c=this._hyperLinkModel.getHyperLink(n,r,o);if(c&&c.display!==s.display){const d={unitId:n,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:s.display,t:a.CellValueType.STRING,p:null}}}};return{redos:[{id:h.SetRangeValuesMutation.id,params:d}],undos:[{id:h.SetRangeValuesMutation.id,params:h.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===h.SetRangeValuesCommand.id){const t=e.params,{unitId:n,subUnitId:r}=t,o=[],s=[];return t.cellValue&&new a.ObjectMatrix(t.cellValue).forValue((c,d,p)=>{var k,y,L,R,H,b,U;const S=(L=p==null?void 0:p.v)!=null?L:(y=(k=p==null?void 0:p.p)==null?void 0:k.body)==null?void 0:y.dataStream.slice(0,-2),_=(S!=null?S:"").toString(),u=this._hyperLinkModel.getHyperLinkByLocation(n,r,c,d);if(!u){if(X(_)||(R=p==null?void 0:p.custom)!=null&&R.__link_url){const B=(b=(H=p==null?void 0:p.custom)==null?void 0:H.__link_url)!=null?b:_,M=a.Tools.generateRandomId();s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:M}}),o.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:{id:M,row:c,column:d,display:_,payload:ve(B)}}})}return}(S===""||((U=p==null?void 0:p.custom)==null?void 0:U.__link_url)==="")&&(o.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:u.id}}),s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:u}}))}),{undos:s,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===h.ClearSelectionContentCommand.id||e.id===h.ClearSelectionAllCommand.id||e.id===h.ClearSelectionFormatCommand.id){const t=[],n=[],r=this._selectionManagerService.getCurrentLastSelection(),o=h.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:s,subUnitId:c}=o;a.Range.foreach(r.range,(d,p)=>{const S=this._hyperLinkModel.getHyperLinkByLocation(s,c,d,p);S&&(t.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:S.id}}),n.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:S}}))})}return{redos:t,undos:n}}return{redos:[],undos:[]}}}))}_initRichTextEditorInterceptor(){this.disposeWithMe(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(e,t,n)=>{var r,o,s,c,d,p;if(e!=null&&e.p){const S=(o=(r=e.p.body)==null?void 0:r.customRanges)==null?void 0:o.find(u=>u.rangeType===a.CustomRangeType.HYPERLINK),_=(s=e.p.resources)==null?void 0:s.find(u=>u.name===De.DOC_HYPER_LINK_PLUGIN);if(S&&_){const u=S.rangeId,k=(p=(d=(c=JSON.parse(_.data))==null?void 0:c.links)==null?void 0:d.find(y=>y.id===u))==null?void 0:p.payload;return n({...e,p:null,v:Ae.getPlainTextFormDocument(e.p),t:a.CellValueType.STRING,custom:{__link_url:k}})}}return n(e)}}))}},l.SheetHyperLinkSetRangeController=Ln([a.OnLifecycle(a.LifecycleStages.Starting,l.SheetHyperLinkSetRangeController),K(0,a.Inject(h.SheetInterceptorService)),K(1,a.Inject(a.Injector)),K(2,a.Inject(v.HyperLinkModel)),K(3,a.Inject(h.SheetsSelectionsService)),K(4,a.IUniverInstanceService),K(5,f.IEditorBridgeService)],l.SheetHyperLinkSetRangeController);var kn=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Rn=(i,e,t,n)=>{for(var r=n>1?void 0:n?In(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&kn(e,t,r),r},Q=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkPopupController=class extends a.Disposable{constructor(e,t,n,r,o){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._permissionService=r,this._sheetPermissionInterceptorBaseController=o,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(pe.debounceTime(100)).subscribe(e=>{var u,k;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const t=(k=(u=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:u.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(e.location.subUnitId))==null?void 0:k.skeleton,n=e.location.col,r=e.location.row;let o=r,s=n;if(t&&t.overflowCache.forValue((y,L,R)=>{a.Rectangle.contains(R,{startColumn:n,endColumn:n,startRow:r,endRow:r})&&(o=y,s=L)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[h.WorkbookViewPermission],worksheetTypes:[h.WorksheetViewPermission],rangeTypes:[h.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const d=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}]),p=e.location.unitId,S=e.location.subUnitId,_=this._permissionService.composePermission([new h.WorkbookCopyPermission(p).id,new h.WorksheetCopyPermission(p,S).id]).every(y=>y.value);this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:s,editPermission:d,copyPermission:_})}))}},l.SheetsHyperLinkPopupController=Rn([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetsHyperLinkPopupController),Q(0,a.Inject(f.HoverManagerService)),Q(1,a.Inject(l.SheetsHyperLinkPopupService)),Q(2,a.Inject(ue.IRenderManagerService)),Q(3,a.Inject(a.IPermissionService)),Q(4,a.Inject(f.SheetPermissionInterceptorBaseController))],l.SheetsHyperLinkPopupController);const Pn=i=>({id:se.id,type:O.MenuItemType.BUTTON,positions:[O.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:O.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:f.getCurrentRangeDisable$(i,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),En=i=>({tooltip:"hyperLink.form.addTitle",positions:O.MenuPosition.TOOLBAR_START,group:O.MenuGroup.TOOLBAR_OTHERS,id:ge.id,type:O.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:O.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:f.getCurrentRangeDisable$(i,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),Se={id:ge.id,binding:O.KeyCode.K|O.MetaKeys.CTRL_COMMAND,preconditions:f.whenSheetEditorFocused};var bn=Object.defineProperty,On=Object.getOwnPropertyDescriptor,Mn=(i,e,t,n)=>{for(var r=n>1?void 0:n?On(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&bn(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(){[[ae,ae.componentKey],[ie,ie.componentKey],[re,"LinkSingle"]].forEach(([e,t])=>{this._componentManager.register(t,e)})}_initCommands(){[oe,J,se,ge].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){var e,t,n,r;this._menuService.addMenuItem(Pn(this._injector),(t=(e=this._config)==null?void 0:e.menu)!=null?t:{}),this._menuService.addMenuItem(En(this._injector),(r=(n=this._config)==null?void 0:n.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(Se)}},l.SheetsHyperLinkUIController=Mn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkUIController),z(1,a.Inject(O.ComponentManager)),z(2,a.ICommandService),z(3,a.Inject(a.LocaleService)),z(4,O.IMenuService),z(5,a.Inject(a.Injector)),z(6,a.Inject(O.IShortcutService))],l.SheetsHyperLinkUIController);const ye="SHEET_HYPER_LINK_UI_PLUGIN";var wn=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,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&&wn(e,t,r),r},He=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkAutoFillController=class extends a.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,o)=>{const{source:s,target:c,unitId:d,subUnitId:p}=r,S=f.virtualizeDiscreteRanges([s,c]),[_,u]=S.ranges,{mapFunc:k}=S,y={row:_.startRow,col:_.startColumn},L=f.getAutoFillRepeatRange(_,u),R=[],H=[];return L.forEach(b=>{const U=b.repeatStartCell,B=b.relativeRange,M={startRow:y.row,startColumn:y.col,endColumn:y.col,endRow:y.row},Z={startRow:U.row,startColumn:U.col,endColumn:U.col,endRow:U.row};a.Range.foreach(B,(x,W)=>{const q=a.Rectangle.getPositionRange({startRow:x,startColumn:W,endColumn:W,endRow:x},M),{row:_e,col:Ce}=k(q.startRow,q.startColumn),ee=this._hyperLinkModel.getHyperLinkByLocation(d,p,_e,Ce);if(ee){const g=a.Rectangle.getPositionRange({startRow:x,startColumn:W,endColumn:W,endRow:x},Z),{row:P,col:w}=k(g.startRow,g.startColumn),E=a.Tools.generateRandomId(),j=this._hyperLinkModel.getHyperLinkByLocation(d,p,P,w);j&&R.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:p,id:j.id}}),(f.APPLY_TYPE.COPY===o||f.APPLY_TYPE.SERIES===o)&&(R.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:p,link:{...ee,id:E,row:P,column:w}}}),H.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:p,id:E}})),j&&H.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:p,link:j}})}})}),{undos:H,redos:R}},n={id:ye,onFillData:(r,o,s)=>s===f.APPLY_TYPE.COPY||s===f.APPLY_TYPE.ONLY_FORMAT||s===f.APPLY_TYPE.SERIES?t(r,s):e()};this.disposeWithMe(this._autoFillService.addHook(n))}},l.SheetsHyperLinkAutoFillController=jn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkAutoFillController),He(0,f.IAutoFillService),He(1,a.Inject(v.HyperLinkModel))],l.SheetsHyperLinkAutoFillController);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},le=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkCopyPasteController=class extends a.Disposable{constructor(t,n,r,o){super();$(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=n,this._injector=r,this._resolverService=o,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:ye,onBeforeCopy:(t,n,r)=>this._collect(t,n,r),onPasteCells:(t,n,r,o)=>{const{copyType:s=f.COPY_TYPE.COPY,pasteType:c}=o,{range:d}=t||{},{range:p,unitId:S,subUnitId:_}=n;return this._generateMutations(p,{copyType:s,pasteType:c,copyRange:d,unitId:S,subUnitId:_})},onPastePlainText:(t,n)=>{if(X(n)){const r=ve(n),{range:o,unitId:s,subUnitId:c}=t,{ranges:[d],mapFunc:p}=f.virtualizeDiscreteRanges([o]),S=[],_=[];return a.Range.foreach(d,(u,k)=>{const{row:y,col:L}=p(u,k),R=this._hyperLinkModel.getHyperLinkByLocation(s,c,y,L);R&&S.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:R.id}});const H=a.Tools.generateRandomId();S.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{id:H,row:y,column:L,payload:r}}}),_.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:H}}),R&&_.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:R}})}),{redos:S,undos:_}}return{undos:[],redos:[]}}})}_collect(t,n,r){const o=new a.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:o};const s={get:this._injector.get.bind(this._injector)},c=f.rangeToDiscreteRange(r,s,t,n);if(!c)return;const{rows:d,cols:p}=c;d.forEach((S,_)=>{p.forEach((u,k)=>{var L;const y=this._hyperLinkModel.getHyperLinkByLocation(t,n,S,u);o.setValue(_,k,(L=y==null?void 0:y.id)!=null?L:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,s=[],c=[],{ranges:[d,p],mapFunc:S}=f.virtualizeDiscreteRanges([n.copyRange,t]);return f.getRepeatRange(d,p,!0).forEach(({startRange:u})=>{var k;(k=this._copyInfo)==null||k.matrix.forValue((y,L,R)=>{const H=a.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:L,endColumn:L},u),b=this._hyperLinkModel.getHyperLink(r,o,R),{row:U,col:B}=S(H.startRow,H.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,U,B),Z=a.Tools.generateRandomId();M&&s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),b&&(s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...b,id:Z,row:U,column:B}}}),c.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:Z}})),M&&c.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:s,undos:c}}},l.SheetsHyperLinkCopyPasteController=Nn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkCopyPasteController),le(0,f.ISheetClipboardService),le(1,a.Inject(v.HyperLinkModel)),le(2,a.Inject(a.Injector)),le(3,a.Inject(l.SheetsHyperLinkResolverService))],l.SheetsHyperLinkCopyPasteController);var Dn=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(i,e,t,n)=>{for(var r=n>1?void 0:n?An(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Dn(e,t,r),r},Bn=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkUrlController=class extends a.Disposable{constructor(e){super(),this._resolverService=e,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;e&&this._resolverService.parseHyperLink(e).handler()}},l.SheetHyperLinkUrlController=Vn([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetHyperLinkUrlController),Bn(0,a.Inject(l.SheetsHyperLinkResolverService))],l.SheetHyperLinkUrlController);var xn=Object.defineProperty,Wn=Object.getOwnPropertyDescriptor,Fn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&xn(e,t,r),r},fe=(i,e)=>(t,n)=>e(t,n,i);let ce=class extends a.Disposable{constructor(i,e,t){super(),this._localeService=i,this._commandService=e,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{i.id===Se.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[h.WorkbookEditablePermission],rangeTypes:[h.RangeProtectionPermissionEditPoint],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};ce=Fn([a.OnLifecycle(a.LifecycleStages.Rendered,ce),fe(0,a.Inject(a.LocaleService)),fe(1,a.ICommandService),fe(2,a.Inject(f.SheetPermissionInterceptorBaseController))],ce);var je=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Yn=(i,e,t)=>e in i?je(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Kn=(i,e,t,n)=>{for(var r=n>1?void 0:n?$n(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&je(e,t,r),r},Te=(i,e)=>(t,n)=>e(t,n,i),Ue=(i,e,t)=>Yn(i,typeof e!="symbol"?e+"":e,t);l.UniverSheetsHyperLinkUIPlugin=class extends a.Plugin{constructor(e,t,n){super(),this._config=e,this._injector=t,this._renderManagerService=n}onStarting(e){[[l.SheetsHyperLinkResolverService],[l.SheetsHyperLinkPopupService],[l.SheetsHyperLinkRemoveSheetController],[l.SheetsHyperLinkRenderManagerController],[l.SheetHyperLinkSetRangeController],[l.SheetsHyperLinkPopupController],[l.SheetsHyperLinkUIController,{useFactory:()=>this._injector.createInstance(l.SheetsHyperLinkUIController,this._config)}],[l.SheetsHyperLinkAutoFillController],[l.SheetsHyperLinkCopyPasteController],[ce],[l.SheetHyperLinkUrlController]].forEach(n=>e.add(n))}onReady(){[[l.SheetsHyperLinkRenderController]].forEach(t=>this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,t))}},Ue(l.UniverSheetsHyperLinkUIPlugin,"pluginName",ye),Ue(l.UniverSheetsHyperLinkUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),l.UniverSheetsHyperLinkUIPlugin=Kn([a.DependentOn(v.UniverSheetsHyperLinkPlugin),Te(1,a.Inject(a.Injector)),Te(2,ue.IRenderManagerService)],l.UniverSheetsHyperLinkUIPlugin),l.CloseHyperLinkSidebarOperation=J,l.InsertHyperLinkOperation=se,l.InsertLinkShortcut=Se,l.OpenHyperLinkSidebarOperation=oe,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
9
+ */var Ke=L,ze=Symbol.for("react.element"),Ze=Symbol.for("react.fragment"),Ge=Object.prototype.hasOwnProperty,Xe=Ke.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Je={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)Ge.call(e,n)&&!Je.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:Xe.current}}ie.Fragment=Ze,ie.jsx=Ee,ie.jsxs=Ee,be.exports=ie;var m=be.exports,N=function(){return N=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},N.apply(this,arguments)},Qe=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},Y=L.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,s=Qe(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),d=L.useRef("_".concat(nn()));return Oe(t,"".concat(n),{defIds:t.defIds,idSuffix:d.current},N({ref:e,className:c},s),o)});function Oe(i,e,t,n,r){return L.createElement(i.tag,N(N({key:e},qe(i,t,r)),n),(en(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=N({},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 en(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)?N(N({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?N(N({},r),{attrs:N(N({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function nn(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";var tn={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"}}]},oe=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"all-border-single",ref:e,icon:tn}))});oe.displayName="AllBorderSingle";var rn={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=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"copy-single",ref:e,icon:rn}))});we.displayName="CopySingle";var on={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"}}]},se=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"link-single",ref:e,icon:on}))});se.displayName="LinkSingle";var sn={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=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"unlink-single",ref:e,icon:sn}))});Me.displayName="UnlinkSingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},He=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"write-single",ref:e,icon:an}))});He.displayName="WriteSingle";var ln={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=L.forwardRef(function(i,e){return L.createElement(Y,Object.assign({},i,{id:"xlsx",ref:e,icon:ln}))});ge.displayName="Xlsx";var cn=Object.defineProperty,dn=Object.getOwnPropertyDescriptor,un=(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&&cn(e,t,r),r},J=(i,e)=>(t,n)=>e(t,n,i);function pn(i,e){const t=e.getMergeData(),n=e.getMaxColumns()-1,r=e.getMaxRows()-1;if(n<i.endColumn&&(i.endColumn=n),r<i.endRow&&(i.endRow=r),i.rangeType===a.RANGE_TYPE.COLUMN||a.RANGE_TYPE.ROW)return i;const o=[];return t.forEach(s=>{a.Rectangle.intersects(i,s)&&o.push(s)}),a.Rectangle.realUnion(i,...o)}l.SheetsHyperLinkResolverService=class{constructor(e,t,n,r,o){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=o}_getURLName(e){var d;const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const s=t?o.getSheetBySheetId(t):o.getActiveSheet(),c=(d=s==null?void 0:s.getName())!=null?d:"";if(n){const p=V.deserializeRangeWithSheet(n).range;return a.isValidRange(p)&&n!==v.ERROR_RANGE?{type:"range",name:V.serializeRangeWithSheet(c,p)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const p=this._definedNamesService.getValueById(o.getUnitId(),r);return p?{type:"defineName",name:p.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(t){const p=o.getSheetBySheetId(t);return p?{type:"sheet",name:p.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(e){const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=o.getUnitId();if(r&&this.navigateToDefineName(s,r),!!t){if(n){const c=V.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=pn(n,r);await this._commandService.executeCommand(h.SetSelectionsOperation.id,{unitId:e,subUnitId:t,selections:[{range:o}]}),await this._commandService.executeCommand(_.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:R.MessageType.Error});return}const s=o.getSheetId();return n.getHiddenWorksheets().indexOf(s)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:R.MessageType.Error}),await this._commandService.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:s})}async navigateToSheetById(e,t){const n=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const o=n.getSheetBySheetId(t);return o?n.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:R.MessageType.Error}),!1):await this._commandService.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:R.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=un([J(0,a.IUniverInstanceService),J(1,a.ICommandService),J(2,V.IDefinedNamesService),J(3,w.IMessageService),J(4,y.Inject(a.LocaleService))],l.SheetsHyperLinkResolverService);function Q(i){return a.Tools.isLegalUrl(i)}function hn(i){return/^[a-zA-Z]+:\/\//.test(i)}function mn(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function Se(i){if(Q(i)){const e=hn(i)?i:mn(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 vn(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 gn={cellLinkEditButtons:"univer-cell-link-edit-buttons"},ae=()=>{var te;const[i,e]=L.useState(""),[t,n]=L.useState(""),[r,o]=L.useState("link"),[s,c]=L.useState(""),d=U.useDependency(a.LocaleService),p=U.useDependency(V.IDefinedNamesService),S=U.useDependency(a.IUniverInstanceService),C=U.useDependency(l.SheetsHyperLinkPopupService),u=w.useObservable(C.currentEditing$),I=U.useDependency(v.HyperLinkModel),f=U.useDependency(l.SheetsHyperLinkResolverService),k=U.useDependency(a.ICommandService),[P,T]=L.useState(!1),O=L.useRef(!1);L.useEffect(()=>{var g,b,H;if((u==null?void 0:u.row)!==void 0&&u.column!==void 0){const E=I.getHyperLinkByLocationSync(u.unitId,u.subUnitId,u.row,u.column);if(E){const he=f.parseHyperLink(E.payload);if(e(E.id),n(E.display),he.type==="outer"){o("link"),c(he.url),he.url===E.display&&(O.current=!0);return}else{const W=he.searchObj;if(W.rangeid){o("rangeid"),c(W.rangeid);return}if(W.range){const Xn=W.gid&&(H=(b=(g=S.getUnit(u.unitId))==null?void 0:g.getSheetBySheetId(W.gid))==null?void 0:b.getName())!=null?H:"";if(o("range"),W.range===v.ERROR_RANGE)c("");else{const Ae=V.serializeRangeWithSheet(Xn,V.deserializeRangeWithSheet(W.range).range);c(Ae),Ae===E.display&&(O.current=!0)}return}if(W.gid){o("gid"),c(W.gid);return}}}const j=S.getUnit(u.unitId),A=j==null?void 0:j.getSheetBySheetId(u.subUnitId),Gn=A==null?void 0:A.getCellRaw(u.row,u.column),Ie=vn(Gn);o("link"),c(""),n((Ie!=null?Ie:"").toString()),e("");return}o("link"),c(""),n(""),e("")},[u,I,f,S]);const D=L.useMemo(()=>s,[r]),B=[{label:d.t("hyperLink.form.link"),value:"link"},{label:d.t("hyperLink.form.range"),value:"range"},{label:d.t("hyperLink.form.worksheet"),value:"gid"},{label:d.t("hyperLink.form.definedName"),value:"rangeid"}],M=S.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!M)return;const X=M.getHiddenWorksheets(),F=M.getSheets().map(g=>({label:g.getName(),value:g.getSheetId()})).filter(g=>X.indexOf(g.value)===-1),$=Object.values((te=p.getDefinedNameMap(M.getUnitId()))!=null?te:{}).map(g=>({label:g.name,value:g.id})),ne=(g,b)=>{if(g==="link")return Se(b);if(g==="range"){const H=V.deserializeRangeWithSheet(b),E=M.getSheetBySheetName(H.sheetName);if(E)return`#gid=${E.getSheetId()}&range=${V.serializeRange(H.range)}`}return`#${g}=${b}`},Le=w.useEvent(g=>{var E;const b=g[0];if(!b||!a.isValidRange(b.range))return;b.sheetName||(b.sheetName=((E=M.getActiveSheet())==null?void 0:E.getName())||"");const H=V.serializeRangeToRefString(b);c(H),H&&(O.current||!t)&&(n(H),O.current=!0)}),ke=async()=>{if(u&&(i?await k.executeCommand(v.UpdateHyperLinkCommand.id,{unitId:u.unitId,subUnitId:u.subUnitId,id:i,payload:{display:t,payload:ne(r,s)}}):await k.executeCommand(v.AddHyperLinkCommand.id,{unitId:u.unitId,subUnitId:u.subUnitId,link:{id:a.Tools.generateRandomId(),row:u.row,column:u.column,payload:ne(r,s),display:t}})),u){await k.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:u.unitId,subUnitId:u.subUnitId});const g=1;await k.executeCommand(_.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-g,0),endRow:u.row+g,startColumn:Math.max(u.column-g,0),endColumn:u.column+g}})}k.executeCommand(q.id)};return m.jsxs("div",{children:[m.jsx(R.FormLayout,{label:d.t("hyperLink.form.label"),error:P&&!t?d.t("hyperLink.form.inputError"):"",children:m.jsx(R.Input,{value:t,onChange:g=>{n(g),O.current=!1},placeholder:d.t("hyperLink.form.labelPlaceholder")})}),m.jsx(R.FormLayout,{label:d.t("hyperLink.form.type"),children:m.jsx(R.Select,{options:B,value:r,onChange:g=>{o(g),c("")}})}),r==="link"&&m.jsx(R.FormLayout,{error:P?s?Q(s)?"":d.t("hyperLink.form.linkError"):d.t("hyperLink.form.inputError"):"",children:m.jsx(R.Input,{value:s,onChange:g=>{c(g),g&&(O.current||!t||t===s)&&(n(g),O.current=!0)},placeholder:d.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&m.jsx(R.FormLayout,{error:P&&!s?d.t("hyperLink.form.inputError"):"",children:m.jsx(w.RangeSelector,{openForSheetUnitId:M.getUnitId(),id:a.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:D,onChange:Le})}),r==="gid"&&m.jsx(R.FormLayout,{error:P&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(R.Select,{options:F,value:s,onChange:g=>{var E,j;c(g);const b=(E=F.find(A=>A.value===g))==null?void 0:E.label,H=(j=F.find(A=>A.value===s))==null?void 0:j.label;b&&(O.current||!t||t===H)&&(n(b),O.current=!0)}})}),r==="rangeid"&&m.jsx(R.FormLayout,{error:P&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(R.Select,{options:$,value:s,onChange:g=>{var E,j;c(g);const b=(E=$.find(A=>A.value===g))==null?void 0:E.label,H=(j=$.find(A=>A.value===s))==null?void 0:j.label;b&&(O.current||!t||t===H)&&(n(b),O.current=!0)}})}),m.jsxs("div",{className:gn.cellLinkEditButtons,children:[m.jsx(R.Button,{onClick:()=>{u&&k.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:u.unitId,subUnitId:u.subUnitId}),k.executeCommand(q.id)},children:d.t("hyperLink.form.cancel")}),m.jsx(R.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!t||!s||r==="link"&&!Q(s)){T(!0);return}ke()},children:d.t("hyperLink.form.ok")})]})]})};ae.componentKey="univer.sheet.cell-link-edit";const le={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(w.ISidebarService),d=i.get(l.SheetsHyperLinkPopupService),p=s.getHyperLinkByLocation(t,n,r,o);return d.startEditing(e),c.open({header:{title:p?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:ae.componentKey}}),!0}},q={type:a.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const e=i.get(w.ISidebarService),t=i.get(l.SheetsHyperLinkPopupService);return e.close(),t.endEditing(),!0}},ce={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(a.IUniverInstanceService),t=h.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(a.ICommandService),o=i.get(h.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const s=o.primary.startRow,c=o.primary.startColumn;return n.executeCommand(le.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:s,column:c})}},ye={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(ce.id)}},x={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"},Sn={outer:m.jsx(se,{}),link:m.jsx(se,{}),sheet:m.jsx(ge,{}),range:m.jsx(oe,{}),defineName:m.jsx(oe,{}),"range-error":m.jsx(oe,{}),"sheet-error":m.jsx(ge,{})},de=()=>{const i=U.useDependency(l.SheetsHyperLinkPopupService),e=U.useDependency(v.HyperLinkModel),t=U.useDependency(a.ICommandService),n=U.useDependency(w.IMessageService),r=U.useDependency(a.LocaleService),[o,s]=L.useState(null),c=U.useDependency(l.SheetsHyperLinkResolverService);if(L.useEffect(()=>{s(i.currentPopup);const f=i.currentPopup$.subscribe(k=>{s(k)});return()=>{f.unsubscribe()}},[i.currentPopup,i.currentPopup$]),!o)return null;const{unitId:d,subUnitId:p,id:S}=o,C=e.getHyperLink(d,p,S);if(!C)return null;const u=c.parseHyperLink(C.payload),I=u.type.indexOf("error")>-1;return m.jsxs("div",{className:x.cellLink,onClick:()=>i.hideCurrentPopup(),children:[m.jsxs("div",{className:Re(x.cellLinkContent,{[x.cellLinkContentError]:I}),onClick:u.handler,children:[m.jsx("div",{className:x.cellLinkType,children:Sn[u.type]}),m.jsx(R.Tooltip,{showIfEllipsis:!0,title:u.name,children:m.jsx("span",{className:x.cellLinkUrl,children:u.name})})]}),m.jsxs("div",{className:x.cellLinkOperations,children:[o.copyPermission&&m.jsx("div",{className:Re(x.cellLinkOperation,{[x.cellLinkOperationError]:I}),onClick:()=>{if(!I){if(u.type!=="outer"){const f=new URL(window.location.href);f.hash=u.url.slice(1),navigator.clipboard.writeText(f.href)}else navigator.clipboard.writeText(u.url);n.show({content:r.t("hyperLink.message.coped"),type:R.MessageType.Info})}},children:m.jsx(R.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:m.jsx(we,{})})}),o.editPermission&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:x.cellLinkOperation,onClick:()=>{t.executeCommand(le.id,{unitId:d,subUnitId:p,row:C.row,column:C.column})},children:m.jsx(R.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:m.jsx(He,{})})}),m.jsx("div",{className:x.cellLinkOperation,onClick:()=>{t.executeCommand(v.CancelHyperLinkCommand.id,{unitId:d,subUnitId:p,id:C.id})},children:m.jsx(R.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:m.jsx(Me,{})})})]})]})]})};de.componentKey="univer.sheet.cell-link-popup";var yn=Object.defineProperty,fn=Object.getOwnPropertyDescriptor,_n=(i,e,t,n)=>{for(var r=n>1?void 0:n?fn(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},Te=(i,e)=>(t,n)=>e(t,n,i);const Cn=(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();K(this,"_currentPopup",null);K(this,"_currentPopup$",new re.Subject);K(this,"currentPopup$",this._currentPopup$.asObservable());K(this,"_currentEditing$",new re.BehaviorSubject(null));K(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&&Cn(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:de.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=_n([Te(0,y.Inject(v.HyperLinkModel)),Te(1,y.Inject(_.SheetCanvasPopManagerService))],l.SheetsHyperLinkPopupService);var Ln=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,In=(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&&Ln(e,t,r),r},Z=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkSetRangeController=class extends a.Disposable{constructor(e,t,n,r,o,s){super(),this._sheetInterceptorService=e,this._injector=t,this._hyperLinkModel=n,this._selectionManagerService=r,this._univerInstanceService=o,this._editorBridgeService=s,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor(),this._initRichTextEditorInterceptor()}_getCurrentCell(e,t,n,r){var o,s;return(s=(o=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetId(t))==null?void 0:s.getCell(n,r)}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var t;if(e.id===v.AddHyperLinkCommand.id){const n=e.params,{unitId:r,subUnitId:o,link:s}=n,c=this._getCurrentCell(r,o,s.row,s.column),d={unitId:r,subUnitId:o,cellValue:{[s.row]:{[s.column]:{v:s.display,p:null,t:(t=c==null?void 0:c.t)!=null?t:void 0}}}};return{redos:[{id:h.SetRangeValuesMutation.id,params:d}],undos:[{id:h.SetRangeValuesMutation.id,params:h.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}return{redos:[],undos:[]}}}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===v.UpdateHyperLinkCommand.id){const t=e.params,{unitId:n,subUnitId:r,id:o,payload:s}=t,c=this._hyperLinkModel.getHyperLink(n,r,o);if(c&&c.display!==s.display){const d={unitId:n,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:s.display,t:a.CellValueType.STRING,p:null}}}};return{redos:[{id:h.SetRangeValuesMutation.id,params:d}],undos:[{id:h.SetRangeValuesMutation.id,params:h.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===h.SetRangeValuesCommand.id){const t=e.params,{unitId:n,subUnitId:r}=t,o=[],s=[];return t.cellValue&&new a.ObjectMatrix(t.cellValue).forValue((c,d,p)=>{var I,f,k,P,T,O,D;const S=(k=p==null?void 0:p.v)!=null?k:(f=(I=p==null?void 0:p.p)==null?void 0:I.body)==null?void 0:f.dataStream.slice(0,-2),C=(S!=null?S:"").toString(),u=this._hyperLinkModel.getHyperLinkByLocation(n,r,c,d);if(!u){if(Q(C)||(P=p==null?void 0:p.custom)!=null&&P.__link_url){const B=(O=(T=p==null?void 0:p.custom)==null?void 0:T.__link_url)!=null?O:C,M=a.Tools.generateRandomId();s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:M}}),o.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:{id:M,row:c,column:d,display:C,payload:Se(B)}}})}return}(S===""||((D=p==null?void 0:p.custom)==null?void 0:D.__link_url)==="")&&(o.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:u.id}}),s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:u}}))}),{undos:s,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===h.ClearSelectionContentCommand.id||e.id===h.ClearSelectionAllCommand.id||e.id===h.ClearSelectionFormatCommand.id){const t=[],n=[],r=this._selectionManagerService.getCurrentLastSelection(),o=h.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:s,subUnitId:c}=o;a.Range.foreach(r.range,(d,p)=>{const S=this._hyperLinkModel.getHyperLinkByLocation(s,c,d,p);S&&(t.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:S.id}}),n.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:S}}))})}return{redos:t,undos:n}}return{redos:[],undos:[]}}}))}_initRichTextEditorInterceptor(){this.disposeWithMe(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(e,t,n)=>{var r,o,s,c,d,p;if(e!=null&&e.p){const S=(o=(r=e.p.body)==null?void 0:r.customRanges)==null?void 0:o.find(u=>u.rangeType===a.CustomRangeType.HYPERLINK),C=(s=e.p.resources)==null?void 0:s.find(u=>u.name===Ve.DOC_HYPER_LINK_PLUGIN);if(S&&C){const u=S.rangeId,I=(p=(d=(c=JSON.parse(C.data))==null?void 0:c.links)==null?void 0:d.find(f=>f.id===u))==null?void 0:p.payload;return n({...e,p:null,v:xe.getPlainTextFormDocument(e.p),t:a.CellValueType.STRING,custom:{__link_url:I}})}}return n(e)}}))}},l.SheetHyperLinkSetRangeController=In([a.OnLifecycle(a.LifecycleStages.Starting,l.SheetHyperLinkSetRangeController),Z(0,y.Inject(h.SheetInterceptorService)),Z(1,y.Inject(y.Injector)),Z(2,y.Inject(v.HyperLinkModel)),Z(3,y.Inject(h.SheetsSelectionsService)),Z(4,a.IUniverInstanceService),Z(5,_.IEditorBridgeService)],l.SheetHyperLinkSetRangeController);var Rn=Object.defineProperty,Pn=Object.getOwnPropertyDescriptor,bn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Pn(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&&Rn(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(re.debounceTime(100)).subscribe(e=>{var u,I;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const t=(I=(u=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:u.with(_.SheetSkeletonManagerService).getWorksheetSkeleton(e.location.subUnitId))==null?void 0:I.skeleton,n=e.location.col,r=e.location.row;let o=r,s=n;if(t&&t.overflowCache.forValue((f,k,P)=>{a.Rectangle.contains(P,{startColumn:n,endColumn:n,startRow:r,endRow:r})&&(o=f,s=k)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[h.WorkbookViewPermission],worksheetTypes:[h.WorksheetViewPermission],rangeTypes:[h.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const d=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}]),p=e.location.unitId,S=e.location.subUnitId,C=this._permissionService.composePermission([new h.WorkbookCopyPermission(p).id,new h.WorksheetCopyPermission(p,S).id]).every(f=>f.value);this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:s,editPermission:d,copyPermission:C})}))}},l.SheetsHyperLinkPopupController=bn([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetsHyperLinkPopupController),ee(0,y.Inject(_.HoverManagerService)),ee(1,y.Inject(l.SheetsHyperLinkPopupService)),ee(2,y.Inject(me.IRenderManagerService)),ee(3,y.Inject(a.IPermissionService)),ee(4,y.Inject(_.SheetPermissionInterceptorBaseController))],l.SheetsHyperLinkPopupController);const En=i=>({id:ce.id,type:w.MenuItemType.BUTTON,positions:[w.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:w.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:_.getCurrentRangeDisable$(i,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),On=i=>({tooltip:"hyperLink.form.addTitle",positions:w.MenuPosition.TOOLBAR_START,group:w.MenuGroup.TOOLBAR_OTHERS,id:ye.id,type:w.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:w.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentRangeDisable$(i,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),fe={id:ye.id,binding:w.KeyCode.K|w.MetaKeys.CTRL_COMMAND,preconditions:_.whenSheetEditorFocused};var wn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,Hn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Mn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&wn(e,t,r),r},G=(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(){[[de,de.componentKey],[ae,ae.componentKey],[se,"LinkSingle"]].forEach(([e,t])=>{this._componentManager.register(t,e)})}_initCommands(){[le,q,ce,ye].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){var e,t,n,r;this._menuService.addMenuItem(En(this._injector),(t=(e=this._config)==null?void 0:e.menu)!=null?t:{}),this._menuService.addMenuItem(On(this._injector),(r=(n=this._config)==null?void 0:n.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(fe)}},l.SheetsHyperLinkUIController=Hn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkUIController),G(1,y.Inject(w.ComponentManager)),G(2,a.ICommandService),G(3,y.Inject(a.LocaleService)),G(4,w.IMenuService),G(5,y.Inject(y.Injector)),G(6,y.Inject(w.IShortcutService))],l.SheetsHyperLinkUIController);const _e="SHEET_HYPER_LINK_UI_PLUGIN";var Tn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Un=(i,e,t,n)=>{for(var r=n>1?void 0:n?jn(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},je=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkAutoFillController=class extends a.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,o)=>{const{source:s,target:c,unitId:d,subUnitId:p}=r,S=_.virtualizeDiscreteRanges([s,c]),[C,u]=S.ranges,{mapFunc:I}=S,f={row:C.startRow,col:C.startColumn},k=_.getAutoFillRepeatRange(C,u),P=[],T=[];return k.forEach(O=>{const D=O.repeatStartCell,B=O.relativeRange,M={startRow:f.row,startColumn:f.col,endColumn:f.col,endRow:f.row},X={startRow:D.row,startColumn:D.col,endColumn:D.col,endRow:D.row};a.Range.foreach(B,(F,$)=>{const ne=a.Rectangle.getPositionRange({startRow:F,startColumn:$,endColumn:$,endRow:F},M),{row:Le,col:ke}=I(ne.startRow,ne.startColumn),te=this._hyperLinkModel.getHyperLinkByLocation(d,p,Le,ke);if(te){const g=a.Rectangle.getPositionRange({startRow:F,startColumn:$,endColumn:$,endRow:F},X),{row:b,col:H}=I(g.startRow,g.startColumn),E=a.Tools.generateRandomId(),j=this._hyperLinkModel.getHyperLinkByLocation(d,p,b,H);j&&P.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:p,id:j.id}}),(_.APPLY_TYPE.COPY===o||_.APPLY_TYPE.SERIES===o)&&(P.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:p,link:{...te,id:E,row:b,column:H}}}),T.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:p,id:E}})),j&&T.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:p,link:j}})}})}),{undos:T,redos:P}},n={id:_e,onFillData:(r,o,s)=>s===_.APPLY_TYPE.COPY||s===_.APPLY_TYPE.ONLY_FORMAT||s===_.APPLY_TYPE.SERIES?t(r,s):e()};this.disposeWithMe(this._autoFillService.addHook(n))}},l.SheetsHyperLinkAutoFillController=Un([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkAutoFillController),je(0,_.IAutoFillService),je(1,y.Inject(v.HyperLinkModel))],l.SheetsHyperLinkAutoFillController);var Nn=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,An=(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&&Nn(e,t,r),r},ue=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkCopyPasteController=class extends a.Disposable{constructor(t,n,r,o){super();K(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=_.COPY_TYPE.COPY,pasteType:c}=o,{range:d}=t||{},{range:p,unitId:S,subUnitId:C}=n;return this._generateMutations(p,{copyType:s,pasteType:c,copyRange:d,unitId:S,subUnitId:C})},onPastePlainText:(t,n)=>{if(Q(n)){const r=Se(n),{range:o,unitId:s,subUnitId:c}=t,{ranges:[d],mapFunc:p}=_.virtualizeDiscreteRanges([o]),S=[],C=[];return a.Range.foreach(d,(u,I)=>{const{row:f,col:k}=p(u,I),P=this._hyperLinkModel.getHyperLinkByLocation(s,c,f,k);P&&S.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:P.id}});const T=a.Tools.generateRandomId();S.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{id:T,row:f,column:k,payload:r}}}),C.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:T}}),P&&C.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:P}})}),{redos:S,undos:C}}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=_.rangeToDiscreteRange(r,s,t,n);if(!c)return;const{rows:d,cols:p}=c;d.forEach((S,C)=>{p.forEach((u,I)=>{var k;const f=this._hyperLinkModel.getHyperLinkByLocation(t,n,S,u);o.setValue(C,I,(k=f==null?void 0:f.id)!=null?k:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([_.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,_.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,_.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,_.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,s=[],c=[],{ranges:[d,p],mapFunc:S}=_.virtualizeDiscreteRanges([n.copyRange,t]);return _.getRepeatRange(d,p,!0).forEach(({startRange:u})=>{var I;(I=this._copyInfo)==null||I.matrix.forValue((f,k,P)=>{const T=a.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:k,endColumn:k},u),O=this._hyperLinkModel.getHyperLink(r,o,P),{row:D,col:B}=S(T.startRow,T.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,D,B),X=a.Tools.generateRandomId();M&&s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),O&&(s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...O,id:X,row:D,column:B}}}),c.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:X}})),M&&c.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:s,undos:c}}},l.SheetsHyperLinkCopyPasteController=An([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkCopyPasteController),ue(0,_.ISheetClipboardService),ue(1,y.Inject(v.HyperLinkModel)),ue(2,y.Inject(y.Injector)),ue(3,y.Inject(l.SheetsHyperLinkResolverService))],l.SheetsHyperLinkCopyPasteController);var Vn=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Wn=(i,e,t,n)=>{for(var r=n>1?void 0:n?xn(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&&Vn(e,t,r),r},Bn=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkUrlController=class extends a.Disposable{constructor(e){super(),this._resolverService=e,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;e&&this._resolverService.parseHyperLink(e).handler()}},l.SheetHyperLinkUrlController=Wn([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetHyperLinkUrlController),Bn(0,y.Inject(l.SheetsHyperLinkResolverService))],l.SheetHyperLinkUrlController);var Fn=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Yn=(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&&Fn(e,t,r),r},Ce=(i,e)=>(t,n)=>e(t,n,i);let pe=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===fe.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[h.WorkbookEditablePermission],rangeTypes:[h.RangeProtectionPermissionEditPoint],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};pe=Yn([a.OnLifecycle(a.LifecycleStages.Rendered,pe),Ce(0,y.Inject(a.LocaleService)),Ce(1,a.ICommandService),Ce(2,y.Inject(_.SheetPermissionInterceptorBaseController))],pe);var Ue=Object.defineProperty,Kn=Object.getOwnPropertyDescriptor,zn=(i,e,t)=>e in i?Ue(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Zn=(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&&Ue(e,t,r),r},Ne=(i,e)=>(t,n)=>e(t,n,i),De=(i,e,t)=>zn(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],[pe],[l.SheetHyperLinkUrlController]].forEach(n=>e.add(n))}onReady(){[[l.SheetsHyperLinkRenderController]].forEach(t=>this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,t))}},De(l.UniverSheetsHyperLinkUIPlugin,"pluginName",_e),De(l.UniverSheetsHyperLinkUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),l.UniverSheetsHyperLinkUIPlugin=Zn([a.DependentOn(v.UniverSheetsHyperLinkPlugin),Ne(1,y.Inject(y.Injector)),Ne(2,me.IRenderManagerService)],l.UniverSheetsHyperLinkUIPlugin),l.CloseHyperLinkSidebarOperation=q,l.InsertHyperLinkOperation=ce,l.InsertLinkShortcut=fe,l.OpenHyperLinkSidebarOperation=le,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.2.4-alpha.0",
3
+ "version": "0.2.4",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -50,39 +50,41 @@
50
50
  "lib"
51
51
  ],
52
52
  "peerDependencies": {
53
+ "@wendellhu/redi": "0.16.0",
53
54
  "clsx": ">=2.0.0",
54
55
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
55
56
  "rxjs": ">=7.0.0",
56
- "@univerjs/core": "0.2.4-alpha.0",
57
- "@univerjs/docs": "0.2.4-alpha.0",
58
- "@univerjs/docs-hyper-link": "0.2.4-alpha.0",
59
- "@univerjs/design": "0.2.4-alpha.0",
60
- "@univerjs/engine-formula": "0.2.4-alpha.0",
61
- "@univerjs/engine-render": "0.2.4-alpha.0",
62
- "@univerjs/sheets-hyper-link": "0.2.4-alpha.0",
63
- "@univerjs/ui": "0.2.4-alpha.0",
64
- "@univerjs/sheets-ui": "0.2.4-alpha.0",
65
- "@univerjs/sheets": "0.2.4-alpha.0"
57
+ "@univerjs/core": "0.2.4",
58
+ "@univerjs/design": "0.2.4",
59
+ "@univerjs/docs": "0.2.4",
60
+ "@univerjs/docs-hyper-link": "0.2.4",
61
+ "@univerjs/engine-render": "0.2.4",
62
+ "@univerjs/sheets": "0.2.4",
63
+ "@univerjs/sheets-ui": "0.2.4",
64
+ "@univerjs/sheets-hyper-link": "0.2.4",
65
+ "@univerjs/engine-formula": "0.2.4",
66
+ "@univerjs/ui": "0.2.4"
66
67
  },
67
68
  "dependencies": {
68
- "@univerjs/icons": "^0.1.64",
69
- "@univerjs/sheets-hyper-link": "0.2.4-alpha.0"
69
+ "@univerjs/icons": "^0.1.65",
70
+ "@univerjs/sheets-hyper-link": "0.2.4"
70
71
  },
71
72
  "devDependencies": {
73
+ "@wendellhu/redi": "0.16.0",
72
74
  "clsx": "^2.1.1",
73
75
  "rxjs": "^7.8.1",
74
76
  "typescript": "^5.5.3",
75
77
  "vite": "^5.3.4",
76
78
  "vitest": "^2.0.3",
77
- "@univerjs/core": "0.2.4-alpha.0",
78
- "@univerjs/docs-hyper-link": "0.2.4-alpha.0",
79
- "@univerjs/docs": "0.2.4-alpha.0",
80
- "@univerjs/engine-render": "0.2.4-alpha.0",
81
- "@univerjs/engine-formula": "0.2.4-alpha.0",
82
- "@univerjs/shared": "0.2.4-alpha.0",
83
- "@univerjs/sheets": "0.2.4-alpha.0",
84
- "@univerjs/ui": "0.2.4-alpha.0",
85
- "@univerjs/sheets-ui": "0.2.4-alpha.0"
79
+ "@univerjs/core": "0.2.4",
80
+ "@univerjs/docs": "0.2.4",
81
+ "@univerjs/shared": "0.2.4",
82
+ "@univerjs/engine-render": "0.2.4",
83
+ "@univerjs/docs-hyper-link": "0.2.4",
84
+ "@univerjs/engine-formula": "0.2.4",
85
+ "@univerjs/sheets": "0.2.4",
86
+ "@univerjs/ui": "0.2.4",
87
+ "@univerjs/sheets-ui": "0.2.4"
86
88
  },
87
89
  "univerSpace": {
88
90
  ".": {