@univerjs/sheets-hyper-link-ui 0.4.1 → 0.4.2-nightly.202410301606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/es/facade.js +1 -0
- package/lib/es/index.js +104 -560
- package/lib/locale/en-US.js +38 -0
- package/lib/locale/fa-IR.js +38 -0
- package/lib/locale/ru-RU.js +38 -0
- package/lib/locale/vi-VN.js +38 -0
- package/lib/locale/zh-CN.js +38 -0
- package/lib/locale/zh-TW.js +38 -0
- package/lib/types/controllers/menu.d.ts +5 -6
- package/lib/types/controllers/url.controller.d.ts +3 -1
- package/lib/types/facade/f-workbook.d.ts +13 -0
- package/lib/types/{types/interfaces/i-sheet-url-params.d.ts → facade/index.d.ts} +0 -6
- package/lib/types/index.d.ts +0 -4
- package/lib/types/services/resolver.service.d.ts +4 -8
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +2 -2
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +27 -25
- package/LICENSE +0 -176
- package/lib/cjs/index.js +0 -9
- package/lib/locale/en-US.json +0 -35
- package/lib/locale/fa-IR.json +0 -35
- package/lib/locale/ru-RU.json +0 -35
- package/lib/locale/vi-VN.json +0 -35
- package/lib/locale/zh-CN.json +0 -35
- package/lib/locale/zh-TW.json +0 -35
- package/lib/types/commands/commands/add-hyper-link.command.d.ts +0 -19
- package/lib/types/commands/commands/remove-hyper-link.command.d.ts +0 -19
- package/lib/types/commands/commands/update-hyper-link.command.d.ts +0 -17
- package/lib/types/types/interfaces/i-sheet-hyper-link-info.d.ts +0 -10
- package/lib/types/types/interfaces/index.d.ts +0 -17
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/docs-ui"),require("react"),require("@univerjs/engine-render"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs","rxjs","@univerjs/docs-ui","react","@univerjs/engine-render","@univerjs/sheets-formula-ui"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsHyperLinkUi={},global.UniverCore,global.UniverSheetsHyperLink,global.UniverSheetsUi,global.UniverDesign,global.UniverEngineFormula,global.UniverSheets,global.UniverUi,global.UniverDocs,global.rxjs,global.UniverDocsUi,global.React,global.UniverEngineRender,global.UniverSheetsFormulaUi))})(this,function(exports2,core,sheetsHyperLink,sheetsUi,design,engineFormula,sheets,ui,docs,rxjs,docsUi,require$$0,engineRender,sheetsFormulaUi){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m,_n;function isLegalLink(link){return core.Tools.isLegalUrl(link)}__name(isLegalLink,"isLegalLink");function hasProtocol(urlString){return/^[a-zA-Z]+:\/\//.test(urlString)}__name(hasProtocol,"hasProtocol");function isEmail(url){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url)}__name(isEmail,"isEmail");function serializeUrl(urlStr){if(isLegalLink(urlStr)){const transformedUrl=hasProtocol(urlStr)?urlStr:isEmail(urlStr)?`mailto://${urlStr}`:`http://${urlStr}`;let url;try{url=new URL(transformedUrl)}catch{return urlStr}return url.hostname===location.hostname&&url.port===location.port&&url.protocol===location.protocol&&url.pathname===location.pathname&&url.hash&&!url.search?url.hash:transformedUrl}return urlStr}__name(serializeUrl,"serializeUrl");const PLUGIN_CONFIG_KEY="sheets-hyper-link-ui.config",defaultPluginConfig={};var __defProp$c=Object.defineProperty,__getOwnPropDesc$c=Object.getOwnPropertyDescriptor,__decorateClass$c=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$c(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$c(target,key,result),result},"__decorateClass$c"),__decorateParam$c=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$c");function getContainRange(range,worksheet){const mergedCells=worksheet.getMergeData(),maxCol=worksheet.getMaxColumns()-1,maxRow=worksheet.getMaxRows()-1;if(maxCol<range.endColumn&&(range.endColumn=maxCol),maxRow<range.endRow&&(range.endRow=maxRow),range.rangeType===core.RANGE_TYPE.COLUMN||core.RANGE_TYPE.ROW)return range;const relativeCells=[];return mergedCells.forEach(cell=>{core.Rectangle.intersects(range,cell)&&relativeCells.push(cell)}),core.Rectangle.realUnion(range,...relativeCells)}__name(getContainRange,"getContainRange"),exports2.SheetsHyperLinkResolverService=(_a=class{constructor(_univerInstanceService,_commandService,_definedNamesService,_messageService,_localeService,_configService){this._univerInstanceService=_univerInstanceService,this._commandService=_commandService,this._definedNamesService=_definedNamesService,this._messageService=_messageService,this._localeService=_localeService,this._configService=_configService}_getURLName(params){var _a2;const{gid,range,rangeid,unitid}=params,workbook=unitid?this._univerInstanceService.getUnit(unitid,core.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET),invalidLink={type:sheetsHyperLink.SheetHyperLinkType.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!workbook)return invalidLink;const sheet=gid?workbook.getSheetBySheetId(gid):workbook.getActiveSheet(),sheetName=(_a2=sheet==null?void 0:sheet.getName())!=null?_a2:"";if(range){if(!sheet)return invalidLink;const rangeObj=engineFormula.deserializeRangeWithSheet(range).range;return core.isValidRange(rangeObj,sheet)&&range!==sheetsHyperLink.ERROR_RANGE?{type:sheetsHyperLink.SheetHyperLinkType.RANGE,name:engineFormula.serializeRangeWithSheet(sheetName,rangeObj)}:invalidLink}if(rangeid){const range2=this._definedNamesService.getValueById(workbook.getUnitId(),rangeid);return range2?{type:sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME,name:range2.formulaOrRefString}:invalidLink}if(gid){const worksheet=workbook.getSheetBySheetId(gid);return worksheet?{type:sheetsHyperLink.SheetHyperLinkType.SHEET,name:worksheet.getName()}:invalidLink}return invalidLink}navigateTo(params){const{gid,range,rangeid}=params,workbook=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return;const unitId=workbook.getUnitId();if(rangeid){const item=this._definedNamesService.getValueById(unitId,rangeid);if(!item)return;const{formulaOrRefString}=item,worksheet=this._definedNamesService.getWorksheetByRef(unitId,formulaOrRefString);if(!worksheet){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:design.MessageType.Error});return}if(worksheet.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:design.MessageType.Error});return}this.navigateToDefineName(unitId,rangeid)}if(gid){if(range){const rangeInfo=engineFormula.deserializeRangeWithSheet(range);core.isValidRange(rangeInfo.range)&&range!==sheetsHyperLink.ERROR_RANGE&&this.navigateToRange(unitId,gid,rangeInfo.range);return}this.navigateToSheetById(unitId,gid)}}buildHyperLink(unitId,sheetId,range){return`#${sheetsHyperLink.SheetHyperLinkType.SHEET}=${sheetId}${range?`&${typeof range=="string"?sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME:sheetsHyperLink.SheetHyperLinkType.RANGE}=${typeof range=="string"?range:engineFormula.serializeRange(range)}`:""}`}parseHyperLink(urlStr){var _a2,_b2,_c2,_d2;if(urlStr.startsWith("#")){const search=new URLSearchParams(urlStr.slice(1)),searchObj={gid:(_a2=search.get("gid"))!=null?_a2:"",range:(_b2=search.get("range"))!=null?_b2:"",rangeid:(_c2=search.get("rangeid"))!=null?_c2:"",unitid:(_d2=search.get("unitid"))!=null?_d2:""},urlInfo=this._getURLName(searchObj);return{type:urlInfo.type,name:urlInfo.name,url:urlStr,searchObj,handler:__name(()=>{this.navigateTo(searchObj)},"handler")}}else return{type:sheetsHyperLink.SheetHyperLinkType.URL,name:urlStr,url:urlStr,handler:__name(()=>{this.navigateToOtherWebsite(urlStr)},"handler"),searchObj:null}}async navigateToRange(unitId,subUnitId,range){const worksheet=await this.navigateToSheetById(unitId,subUnitId);if(worksheet){const realRange=getContainRange(range,worksheet);await this._commandService.executeCommand(sheets.SetSelectionsOperation.id,{unitId,subUnitId,selections:[{range:realRange}]}),await this._commandService.executeCommand(sheetsUi.ScrollToRangeOperation.id,{range:realRange})}}async navigateToSheet(unitId,sheetName){const workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return!1;const worksheet=workbook.getActiveSheet();if((worksheet==null?void 0:worksheet.getName())===sheetName)return!0;const targetSheet=workbook.getSheetBySheetName(sheetName);if(!targetSheet){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:design.MessageType.Error});return}const sheetId=targetSheet.getSheetId();return workbook.getHiddenWorksheets().indexOf(sheetId)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:design.MessageType.Error}),await this._commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId,subUnitId:sheetId})}async navigateToSheetById(unitId,subUnitId){const workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return!1;const worksheet=workbook.getActiveSheet();if(!worksheet)return!1;if(worksheet.getSheetId()===subUnitId)return worksheet;const targetSheet=workbook.getSheetBySheetId(subUnitId);return targetSheet?workbook.getHiddenWorksheets().indexOf(subUnitId)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:design.MessageType.Error}),!1):await this._commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId,subUnitId})?targetSheet:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:design.MessageType.Error}),!1)}async navigateToDefineName(unitId,rangeid){return this._definedNamesService.focusRange(unitId,rangeid),!0}async navigateToOtherWebsite(url){var _a2;const config=this._configService.getConfig(PLUGIN_CONFIG_KEY);if((_a2=config==null?void 0:config.urlHandler)!=null&&_a2.navigateToOtherWebsite)return config.urlHandler.navigateToOtherWebsite(url);window.open(url,"_blank","noopener noreferrer")}},__name(_a,"SheetsHyperLinkResolverService"),_a),exports2.SheetsHyperLinkResolverService=__decorateClass$c([__decorateParam$c(0,core.IUniverInstanceService),__decorateParam$c(1,core.ICommandService),__decorateParam$c(2,engineFormula.IDefinedNamesService),__decorateParam$c(3,ui.IMessageService),__decorateParam$c(4,core.Inject(core.LocaleService)),__decorateParam$c(5,core.IConfigService)],exports2.SheetsHyperLinkResolverService);const SHEET_HYPER_LINK_UI_PLUGIN="SHEET_HYPER_LINK_UI_PLUGIN";var __defProp$b=Object.defineProperty,__getOwnPropDesc$b=Object.getOwnPropertyDescriptor,__decorateClass$b=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$b(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$b(target,key,result),result},"__decorateClass$b"),__decorateParam$b=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$b");exports2.SheetsHyperLinkCopyPasteController=(_b=class extends core.Disposable{constructor(_sheetClipboardService,_hyperLinkModel,_injector,_resolverService){super();__publicField(this,"_plainTextFilter",new Set);__publicField(this,"_copyInfo");this._sheetClipboardService=_sheetClipboardService,this._hyperLinkModel=_hyperLinkModel,this._injector=_injector,this._resolverService=_resolverService,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(filter){this._plainTextFilter.add(filter)}removePlainTextFilter(filter){this._plainTextFilter.delete(filter)}_filterPlainText(text){return Array.from(this._plainTextFilter).every(filter=>filter(text))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:SHEET_HYPER_LINK_UI_PLUGIN,onBeforeCopy:__name((unitId,subUnitId,range)=>this._collect(unitId,subUnitId,range),"onBeforeCopy"),onPasteCells:__name((pasteFrom,pasteTo,data,payload)=>{const{copyType=sheetsUi.COPY_TYPE.COPY,pasteType}=payload,{range:copyRange}=pasteFrom||{},{range:pastedRange,unitId,subUnitId}=pasteTo;return this._generateMutations(pastedRange,{copyType,pasteType,copyRange,unitId,subUnitId})},"onPasteCells"),onPastePlainText:__name((pasteTo,clipText)=>{const filterResult=this._filterPlainText(clipText);if(isLegalLink(clipText)&&filterResult){const{range,unitId,subUnitId}=pasteTo,{ranges:[pasteToRange],mapFunc}=sheetsUi.virtualizeDiscreteRanges([range]),redos=[],undos=[];return core.Range.foreach(pasteToRange,(originRow,originCol)=>{const{row,col:column}=mapFunc(originRow,originCol),link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,column);link&&redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}}),link&&undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}})}),{redos,undos}}return{undos:[],redos:[]}},"onPastePlainText"),priority:99})}_collect(unitId,subUnitId,range){const matrix=new core.ObjectMatrix;this._copyInfo={unitId,subUnitId,matrix};const discreteRange=this._injector.invoke(accessor=>sheetsUi.rangeToDiscreteRange(range,accessor,unitId,subUnitId));if(!discreteRange)return;const{rows,cols}=discreteRange;rows.forEach((row,rowIndex)=>{cols.forEach((col,colIndex)=>{var _a2;const link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);matrix.setValue(rowIndex,colIndex,(_a2=link==null?void 0:link.id)!=null?_a2:"")})})}_generateMutations(pastedRange,copyInfo){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!copyInfo.copyRange)return{redos:[],undos:[]};if([sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(copyInfo.pasteType))return{redos:[],undos:[]};const{unitId,subUnitId}=this._copyInfo,redos=[],undos=[],{ranges:[vCopyRange,vPastedRange],mapFunc}=sheetsUi.virtualizeDiscreteRanges([copyInfo.copyRange,pastedRange]);return sheetsUi.getRepeatRange(vCopyRange,vPastedRange,!0).forEach(({startRange})=>{var _a2;(_a2=this._copyInfo)==null||_a2.matrix.forValue((row,col,ruleId)=>{const range=core.Rectangle.getPositionRange({startRow:row,endRow:row,startColumn:col,endColumn:col},startRange),oldLink=this._hyperLinkModel.getHyperLink(unitId,subUnitId,ruleId),{row:startRow,col:startColumn}=mapFunc(range.startRow,range.startColumn),currentLink=this._hyperLinkModel.getHyperLinkByLocation(copyInfo.unitId,copyInfo.subUnitId,startRow,startColumn),id=core.Tools.generateRandomId();currentLink&&redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,id:currentLink.id}}),oldLink&&(redos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,link:{...oldLink,id,row:startRow,column:startColumn}}}),undos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,id}})),currentLink&&undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,link:currentLink}})})}),{redos,undos}}},__name(_b,"SheetsHyperLinkCopyPasteController"),_b),exports2.SheetsHyperLinkCopyPasteController=__decorateClass$b([__decorateParam$b(0,sheetsUi.ISheetClipboardService),__decorateParam$b(1,core.Inject(sheetsHyperLink.HyperLinkModel)),__decorateParam$b(2,core.Inject(core.Injector)),__decorateParam$b(3,core.Inject(exports2.SheetsHyperLinkResolverService))],exports2.SheetsHyperLinkCopyPasteController);var HyperLinkEditSourceType=(HyperLinkEditSourceType2=>(HyperLinkEditSourceType2.EDITING="editing",HyperLinkEditSourceType2.VIEWING="viewing",HyperLinkEditSourceType2.ZEN_EDITOR="zen_mode",HyperLinkEditSourceType2))(HyperLinkEditSourceType||{}),jsxRuntime={exports:{}},reactJsxRuntime_production_min={};/**
|
|
1
|
+
(function(S,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react","@univerjs/sheets-formula-ui"],s):(S=typeof globalThis<"u"?globalThis:S||self,s(S.UniverSheetsHyperLinkUi={},S.UniverCore,S.UniverSheetsHyperLink,S.UniverSheetsUi,S.UniverDesign,S.UniverEngineFormula,S.UniverSheets,S.UniverUi,S.UniverDocsUi,S.UniverEngineRender,S.rxjs,S.UniverDocs,S.React,S.UniverSheetsFormulaUi))})(this,function(S,s,g,I,D,F,f,O,J,pe,T,he,R,Bt){"use strict";var ci=Object.defineProperty;var li=(S,s,g)=>s in S?ci(S,s,{enumerable:!0,configurable:!0,writable:!0,value:g}):S[s]=g;var W=(S,s,g)=>li(S,typeof s!="symbol"?s+"":s,g);function ye(t){return s.Tools.isLegalUrl(t)}function Wt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Ft(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function Zt(t){if(ye(t)){const i=Wt(t)?t:Ft(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(i)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:i}return t}const ot="sheets-hyper-link-ui.config",Kt={};var $t=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Gt=(t,i,e,n)=>{for(var r=n>1?void 0:n?Yt(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&$t(i,e,r),r},ce=(t,i)=>(e,n)=>i(e,n,t);function zt(t,i){const e=i.getMergeData(),n=i.getMaxColumns()-1,r=i.getMaxRows()-1;if(n<t.endColumn&&(t.endColumn=n),r<t.endRow&&(t.endRow=r),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const o=[];return e.forEach(a=>{s.Rectangle.intersects(t,a)&&o.push(a)}),s.Rectangle.realUnion(t,...o)}S.SheetsHyperLinkResolverService=class{constructor(i,e,n,r,o,a){this._univerInstanceService=i,this._commandService=e,this._definedNamesService=n,this._messageService=r,this._localeService=o,this._configService=a}navigate(i){switch(i.type){case g.SheetHyperLinkType.URL:this.navigateToOtherWebsite(i.url);break;default:this._navigateToUniver(i.searchObj)}}_navigateToUniver(i){const{gid:e,range:n,rangeid:r}=i,o=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return;const a=o.getUnitId();if(r){const c=this._definedNamesService.getValueById(a,r);if(!c)return;const{formulaOrRefString:l}=c,u=this._definedNamesService.getWorksheetByRef(a,l);if(!u){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:D.MessageType.Error});return}if(u.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:D.MessageType.Error});return}this.navigateToDefineName(a,r)}if(e){if(n){const c=F.deserializeRangeWithSheet(n);s.isValidRange(c.range)&&n!==g.ERROR_RANGE&&this.navigateToRange(a,e,c.range);return}this.navigateToSheetById(a,e)}}async navigateToRange(i,e,n){const r=await this.navigateToSheetById(i,e);if(r){const o=zt(n,r);await this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:i,subUnitId:e,selections:[{range:o}]}),await this._commandService.executeCommand(I.ScrollToRangeOperation.id,{range:o})}}async navigateToSheetById(i,e){const n=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===e)return r;const o=n.getSheetBySheetId(e);return o?n.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:D.MessageType.Error}),!1):await this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:e})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:D.MessageType.Error}),!1)}async navigateToDefineName(i,e){return this._definedNamesService.focusRange(i,e),!0}async navigateToOtherWebsite(i){var n;const e=this._configService.getConfig(ot);if((n=e==null?void 0:e.urlHandler)!=null&&n.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(i);window.open(i,"_blank","noopener noreferrer")}},S.SheetsHyperLinkResolverService=Gt([ce(0,s.IUniverInstanceService),ce(1,s.ICommandService),ce(2,F.IDefinedNamesService),ce(3,O.IMessageService),ce(4,s.Inject(s.LocaleService)),ce(5,s.IConfigService)],S.SheetsHyperLinkResolverService);const We="SHEET_HYPER_LINK_UI_PLUGIN";var Xt=Object.defineProperty,Jt=Object.getOwnPropertyDescriptor,Qt=(t,i,e,n)=>{for(var r=n>1?void 0:n?Jt(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&Xt(i,e,r),r},Ce=(t,i)=>(e,n)=>i(e,n,t);S.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,n,r,o){super();W(this,"_plainTextFilter",new Set);W(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=n,this._injector=r,this._resolverService=o,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(n=>n(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:We,onBeforeCopy:(e,n,r)=>this._collect(e,n,r),onPasteCells:(e,n,r,o)=>{const{copyType:a=I.COPY_TYPE.COPY,pasteType:c}=o,{range:l}=e||{},{range:u,unitId:p,subUnitId:h}=n;return this._generateMutations(u,{copyType:a,pasteType:c,copyRange:l,unitId:p,subUnitId:h})},onPastePlainText:(e,n)=>{const r=this._filterPlainText(n);if(ye(n)&&r){const{range:o,unitId:a,subUnitId:c}=e,{ranges:[l],mapFunc:u}=I.virtualizeDiscreteRanges([o]),p=[],h=[];return s.Range.foreach(l,(v,_)=>{const{row:P,col:E}=u(v,_),k=this._hyperLinkModel.getHyperLinkByLocation(a,c,P,E);k&&p.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:c,id:k.id}}),k&&h.push({id:g.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:c,link:k}})}),{redos:p,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,n,r){const o=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:n,matrix:o};const a=this._injector.invoke(u=>I.rangeToDiscreteRange(r,u,e,n));if(!a)return;const{rows:c,cols:l}=a;c.forEach((u,p)=>{l.forEach((h,v)=>{var P;const _=this._hyperLinkModel.getHyperLinkByLocation(e,n,u,h);o.setValue(p,v,(P=_==null?void 0:_.id)!=null?P:"")})})}_generateMutations(e,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([I.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,I.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,I.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,I.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,a=[],c=[],{ranges:[l,u],mapFunc:p}=I.virtualizeDiscreteRanges([n.copyRange,e]);return I.getRepeatRange(l,u,!0).forEach(({startRange:v})=>{var _;(_=this._copyInfo)==null||_.matrix.forValue((P,E,k)=>{const d=s.Rectangle.getPositionRange({startRow:P,endRow:P,startColumn:E,endColumn:E},v),H=this._hyperLinkModel.getHyperLink(r,o,k),{row:N,col:x}=p(d.startRow,d.startColumn),V=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,N,x),q=s.Tools.generateRandomId();V&&a.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:V.id}}),H&&(a.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...H,id:q,row:N,column:x}}}),c.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:q}})),V&&c.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:V}})})}),{redos:a,undos:c}}},S.SheetsHyperLinkCopyPasteController=Qt([Ce(0,I.ISheetClipboardService),Ce(1,s.Inject(g.HyperLinkModel)),Ce(2,s.Inject(s.Injector)),Ce(3,s.Inject(S.SheetsHyperLinkResolverService))],S.SheetsHyperLinkCopyPasteController);var y=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(y||{}),at={exports:{}},Ee={};/**
|
|
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 f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function q(c,a,g){var b,d={},e=null,h=null;g!==void 0&&(e=""+g),a.key!==void 0&&(e=""+a.key),a.ref!==void 0&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)d[b]===void 0&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__name(q,"q"),reactJsxRuntime_production_min.Fragment=l,reactJsxRuntime_production_min.jsx=q,reactJsxRuntime_production_min.jsxs=q,jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports;const AddHyperLinkCommand={type:core.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(accessor,params){var _a2;if(!params)return!1;const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),renderManagerService=accessor.get(engineRender.IRenderManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),hyperLinkModel=accessor.get(sheetsHyperLink.HyperLinkModel),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),{unitId,subUnitId,link}=params,workbook=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET),currentRender=renderManagerService.getRenderById(unitId);if(!currentRender||!workbook)return!1;const worksheet=workbook==null?void 0:workbook.getSheetBySheetId(subUnitId),skeleton=(_a2=currentRender.with(sheetsUi.SheetSkeletonManagerService).getCurrent())==null?void 0:_a2.skeleton;if(!worksheet||!skeleton)return!1;const{payload,display,row,column,id}=link,cellData=worksheet.getCell(row,column),doc=skeleton.getBlankCellDocumentModel(cellData),snapshot=doc.documentModel.getSnapshot(),body=core.Tools.deepClone(snapshot.body);if(!body)return!1;let textX;if(display?textX=core.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:body.dataStream.length-2,collapsed:!0},body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${display}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{startIndex:0,endIndex:display.length+1,rangeType:core.CustomRangeType.HYPERLINK,rangeId:id,properties:{url:payload}}]},doc:doc.documentModel}):textX=core.BuildTextUtils.customRange.add({body,range:{startOffset:0,endOffset:body.dataStream.length-2,collapsed:!1},rangeId:id,rangeType:core.CustomRangeType.HYPERLINK,properties:{url:payload,refId:id}}),!textX)return!1;const newBody=core.TextX.apply(body,textX.serialize()),newCellData={p:{...snapshot,body:newBody},t:core.CellValueType.STRING},finalCellData=await editorBridgeService.beforeSetRangeValue(workbook,worksheet,row,column,newCellData),redoParams={unitId,subUnitId,cellValue:{[link.row]:{[link.column]:finalCellData}}},redo={id:sheets.SetRangeValuesMutation.id,params:redoParams},undoParams=sheets.SetRangeValuesUndoMutationFactory(accessor,redoParams),undo={id:sheets.SetRangeValuesMutation.id,params:undoParams},redos=[redo],undos=[undo],modelLink=hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,column);return modelLink&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:modelLink.id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:modelLink}})),await core.sequenceExecuteAsync(redos,commandService)?(undoRedoService.pushUndoRedo({redoMutations:redos,undoMutations:undos,unitID:unitId}),!0):!1}},AddRichHyperLinkCommand={id:"sheets.command.add-rich-hyper-link",type:core.CommandType.COMMAND,handler:__name(async(accessor,params)=>{if(!params)return!1;const{documentId,link}=params,commandService=accessor.get(core.ICommandService),textSelectionService=accessor.get(docs.DocSelectionManagerService),newId=core.generateRandomId(),{payload}=link;if(!textSelectionService.getActiveTextRange())return!1;const replaceSelection=docsUi.addCustomRangeBySelectionFactory(accessor,{unitId:documentId,rangeId:newId,rangeType:core.CustomRangeType.HYPERLINK,properties:{url:payload,refId:newId}});return replaceSelection?commandService.syncExecuteCommand(replaceSelection.id,replaceSelection.params):!1},"handler")},UpdateHyperLinkCommand={type:core.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(accessor,params){var _a2,_b2,_c2,_d2;if(!params)return!1;const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),renderManagerService=accessor.get(engineRender.IRenderManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),hyperLinkModel=accessor.get(sheetsHyperLink.HyperLinkModel),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),{unitId,subUnitId,payload:link,row,column,id}=params,workbook=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET),currentRender=renderManagerService.getRenderById(unitId);if(!currentRender||!workbook)return!1;const worksheet=workbook==null?void 0:workbook.getSheetBySheetId(subUnitId),skeleton=(_a2=currentRender.with(sheetsUi.SheetSkeletonManagerService).getCurrent())==null?void 0:_a2.skeleton;if(!worksheet||!skeleton)return!1;const{payload,display=""}=link,cellData=worksheet.getCell(row,column);if(!cellData)return!1;const doc=skeleton.getCellDocumentModelWithFormula(cellData);if(!(doc!=null&&doc.documentModel))return!1;const snapshot=doc.documentModel.getSnapshot(),range=(_c2=(_b2=snapshot.body)==null?void 0:_b2.customRanges)==null?void 0:_c2.find(range2=>range2.rangeId===id);if(!range)return!1;const newId=core.generateRandomId(),textRun=(_d2=core.getBodySlice(doc.documentModel.getBody(),range.startIndex,range.endIndex+1).textRuns)==null?void 0:_d2[0];textRun&&(textRun.ed=display.length+1);const replaceSelection=docsUi.replaceSelectionFactory(accessor,{unitId,body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${display}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{rangeId:newId,rangeType:core.CustomRangeType.HYPERLINK,startIndex:0,endIndex:display.length+1,properties:{url:payload}}],textRuns:textRun?[textRun]:void 0},selection:{startOffset:range.startIndex,endOffset:range.endIndex+1,collapsed:!1},doc:doc.documentModel});if(!replaceSelection)return!1;const newBody=core.TextX.apply(core.Tools.deepClone(snapshot.body),replaceSelection.textX.serialize()),newCellData={p:{...snapshot,body:newBody},t:core.CellValueType.STRING},finalCellData=await editorBridgeService.beforeSetRangeValue(workbook,worksheet,row,column,newCellData),redo={id:sheets.SetRangeValuesMutation.id,params:{unitId,subUnitId,cellValue:{[row]:{[column]:finalCellData}}}},undoParams=sheets.SetRangeValuesUndoMutationFactory(accessor,redo.params),undo={id:sheets.SetRangeValuesMutation.id,params:undoParams},redos=[redo],undos=[undo],modelLink=hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,column);return modelLink&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:modelLink.id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:modelLink}})),await core.sequenceExecuteAsync(redos,commandService)?(undoRedoService.pushUndoRedo({redoMutations:redos,undoMutations:undos,unitID:unitId}),!0):!1}},UpdateRichHyperLinkCommand={type:core.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:__name((accessor,params)=>{var _a2,_b2,_c2,_d2;if(!params)return!1;const{documentId:unitId,payload,id:rangeId}=params,univerInstanceService=accessor.get(core.IUniverInstanceService),commandService=accessor.get(core.ICommandService),doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!doc)return!1;const range=(_b2=(_a2=doc.getBody())==null?void 0:_a2.customRanges)==null?void 0:_b2.find(range2=>range2.rangeId===rangeId);if(!range)return!1;const display=(_c2=params.payload.display)!=null?_c2:"",newId=core.generateRandomId(),textRun=(_d2=core.getBodySlice(doc.getBody(),range.startIndex,range.endIndex+1).textRuns)==null?void 0:_d2[0];textRun&&(textRun.ed=display.length+1);const replaceSelection=docsUi.replaceSelectionFactory(accessor,{unitId,body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${display}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{rangeId:newId,rangeType:core.CustomRangeType.HYPERLINK,startIndex:0,endIndex:display.length+1,properties:{url:payload.payload}}],textRuns:textRun?[textRun]:void 0},selection:{startOffset:range.startIndex,endOffset:range.endIndex+1,collapsed:!1},doc});return replaceSelection?commandService.syncExecuteCommand(replaceSelection.id,replaceSelection.params):!1},"handler")},_SheetsHyperLinkSidePanelService=class _SheetsHyperLinkSidePanelService extends core.Disposable{constructor(){super(...arguments);__publicField(this,"_customHyperLinks",new Map)}isBuiltInLinkType(type){return type!==sheetsHyperLink.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option})=>option)}findCustomHyperLink(link){return Array.from(this._customHyperLinks.values()).find(item=>item.match(link))}registerCustomHyperLink(customHyperLink){this._customHyperLinks.set(customHyperLink.type,customHyperLink)}getCustomHyperLink(type){return this._customHyperLinks.get(type)}removeCustomHyperLink(type){const{_customHyperLinks}=this;_customHyperLinks.delete(type)}dispose(){super.dispose(),this._customHyperLinks.clear()}};__name(_SheetsHyperLinkSidePanelService,"SheetsHyperLinkSidePanelService");let SheetsHyperLinkSidePanelService=_SheetsHyperLinkSidePanelService;const styles$1={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},CellLinkEdit=__name(()=>{var _a2;const[id,setId]=require$$0.useState(""),[hide,setHide]=require$$0.useState(!1),[display,setDisplay]=require$$0.useState(""),[showLabel,setShowLabel]=require$$0.useState(!0),[type,setType]=require$$0.useState(sheetsHyperLink.SheetHyperLinkType.URL),[payload,setPayload]=require$$0.useState(""),localeService=core.useDependency(core.LocaleService),definedNameService=core.useDependency(engineFormula.IDefinedNamesService),editorBridgeService=core.useDependency(sheetsUi.IEditorBridgeService),univerInstanceService=core.useDependency(core.IUniverInstanceService),popupService=core.useDependency(exports2.SheetsHyperLinkPopupService),editing=ui.useObservable(popupService.currentEditing$),resolverService=core.useDependency(exports2.SheetsHyperLinkResolverService),commandService=core.useDependency(core.ICommandService),sidePanelService=core.useDependency(SheetsHyperLinkSidePanelService),sidePanelOptions=require$$0.useMemo(()=>sidePanelService.getOptions(),[sidePanelService]),zenZoneService=core.useDependency(ui.IZenZoneService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),markSelectionService=core.useDependency(sheetsUi.IMarkSelectionService),textSelectionService=core.useDependency(docs.DocSelectionManagerService),contextService=core.useDependency(core.IContextService),themeService=core.useDependency(core.ThemeService),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),rangeSelectorActionsRef=require$$0.useRef({}),customHyperLinkSidePanel=require$$0.useMemo(()=>{if(!sidePanelService.isBuiltInLinkType(type))return sidePanelService.getCustomHyperLink(type)},[sidePanelService,type]),[showError,setShowError]=require$$0.useState(!1),[isFocusRangeSelector,isFocusRangeSelectorSet]=require$$0.useState(!1),setByPayload=require$$0.useRef(!1),workbook=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET),subUnitId=(workbook==null?void 0:workbook.getActiveSheet().getSheetId())||"";require$$0.useEffect(()=>{isFocusRangeSelectorSet(!1)},[subUnitId]),require$$0.useEffect(()=>{var _a3,_b2,_c2,_d2,_e2,_f2,_g2,_h2,_i2,_j2,_k2,_l2,_m2,_n2,_o,_p,_q,_r;if((editing==null?void 0:editing.row)!==void 0&&editing.col!==void 0){const{label,customRange,row,col}=editing;let link;if(customRange)link={id:(_a3=customRange==null?void 0:customRange.rangeId)!=null?_a3:"",display:label!=null?label:"",payload:(_c2=(_b2=customRange==null?void 0:customRange.properties)==null?void 0:_b2.url)!=null?_c2:"",row,column:col};else if(editing.type===HyperLinkEditSourceType.VIEWING){const workbook2=univerInstanceService.getUnit(editing.unitId),worksheet=workbook2==null?void 0:workbook2.getSheetBySheetId(editing.subUnitId),cell=worksheet==null?void 0:worksheet.getCellRaw(editing.row,editing.col),range=(_f2=(_e2=(_d2=cell==null?void 0:cell.p)==null?void 0:_d2.body)==null?void 0:_e2.customRanges)==null?void 0:_f2.find(range2=>{var _a4;return range2.rangeType===core.CustomRangeType.HYPERLINK&&((_a4=range2.properties)==null?void 0:_a4.url)}),cellValue=cell==null?void 0:cell.v;cell&&(!core.BuildTextUtils.transform.isEmptyDocument((_h2=(_g2=cell.p)==null?void 0:_g2.body)==null?void 0:_h2.dataStream)||cellValue)&&setShowLabel(!1),link={id:"",display:"",payload:(_j2=(_i2=range==null?void 0:range.properties)==null?void 0:_i2.url)!=null?_j2:"",row,column:col}}else{const doc=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC),selection=textSelectionService.getActiveTextRange(),customRange2=selection&&((_m2=core.BuildTextUtils.customRange.getCustomRangesInterestsWithRange(selection,(_l2=(_k2=doc==null?void 0:doc.getBody())==null?void 0:_k2.customRanges)!=null?_l2:[]))==null?void 0:_m2[0]);setShowLabel(!1),link={id:"",display:label!=null?label:"",payload:(_o=(_n2=customRange2==null?void 0:customRange2.properties)==null?void 0:_n2.url)!=null?_o:"",row,column:col}}setId(link.id);const customLink=sidePanelService.findCustomHyperLink(link);if(customLink){const customLinkInfo=customLink.convert(link);setType(customLinkInfo.type),setPayload(customLinkInfo.payload),setDisplay(customLinkInfo.display);return}setDisplay(link.display);const linkInfo=resolverService.parseHyperLink(link.payload);switch(setType(linkInfo.type===sheetsHyperLink.SheetHyperLinkType.INVALID?sheetsHyperLink.SheetHyperLinkType.RANGE:linkInfo.type),linkInfo.type){case sheetsHyperLink.SheetHyperLinkType.URL:{setPayload(linkInfo.url),linkInfo.url===link.display&&(setByPayload.current=!0);break}case sheetsHyperLink.SheetHyperLinkType.RANGE:{const params=linkInfo.searchObj,sheetName=params.gid&&(_r=(_q=(_p=univerInstanceService.getUnit(editing.unitId))==null?void 0:_p.getSheetBySheetId(params.gid))==null?void 0:_q.getName())!=null?_r:"",payload2=engineFormula.serializeRangeWithSheet(sheetName,engineFormula.deserializeRangeWithSheet(params.range).range);setPayload(payload2),payload2===link.display&&(setByPayload.current=!0);break}case sheetsHyperLink.SheetHyperLinkType.SHEET:{const params=linkInfo.searchObj;setPayload(params.gid);break}case sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME:{const params=linkInfo.searchObj;setPayload(params.rangeid);break}default:setPayload("");break}}},[editing,resolverService,sidePanelService,textSelectionService,univerInstanceService]),require$$0.useEffect(()=>{let id2=null;if(editing&&!editing.customRangeId&&editing.type===HyperLinkEditSourceType.VIEWING&&core.Tools.isDefine(editing.row)&&core.Tools.isDefine(editing.col)){const workbook2=univerInstanceService.getUnit(editing.unitId,core.UniverInstanceType.UNIVER_SHEET),worksheet=workbook2==null?void 0:workbook2.getSheetBySheetId(editing.subUnitId),mergeInfo=worksheet==null?void 0:worksheet.getMergedCell(editing.row,editing.col),color=new core.ColorKit(themeService.getCurrentTheme().hyacinth500).toRgb();id2=markSelectionService.addShape({range:mergeInfo!=null?mergeInfo:{startColumn:editing.col,endColumn:editing.col,startRow:editing.row,endRow:editing.row},style:{hasAutoFill:!1,fill:`rgb(${color.r}, ${color.g}, ${color.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{id2&&markSelectionService.removeShape(id2)}},[editing,markSelectionService,themeService,univerInstanceService]);const payloadInitial=require$$0.useMemo(()=>payload,[type]);require$$0.useEffect(()=>{const render2=renderManagerService.getRenderById(editorBridgeService.getCurrentEditorId()),disposeCollection=new core.DisposableCollection;if(render2){const selectionRenderService=render2.with(docsUi.DocSelectionRenderService);selectionRenderService.setReserveRangesStatus(!0),disposeCollection.add(()=>{selectionRenderService.setReserveRangesStatus(!1)})}return()=>{editorBridgeService.disableForceKeepVisible(),disposeCollection.dispose()}},[editorBridgeService,renderManagerService]),require$$0.useEffect(()=>(popupService.setIsKeepVisible(type===sheetsHyperLink.SheetHyperLinkType.RANGE),()=>{popupService.setIsKeepVisible(!1)}),[type]),require$$0.useEffect(()=>()=>{zenZoneService.temporaryHidden&&(zenZoneService.show(),contextService.setContextValue(core.FOCUSING_SHEET,!1))},[contextService,zenZoneService]);const linkTypeOptions=[{label:localeService.t("hyperLink.form.link"),value:sheetsHyperLink.SheetHyperLinkType.URL},{label:localeService.t("hyperLink.form.range"),value:sheetsHyperLink.SheetHyperLinkType.RANGE},{label:localeService.t("hyperLink.form.worksheet"),value:sheetsHyperLink.SheetHyperLinkType.SHEET},{label:localeService.t("hyperLink.form.definedName"),value:sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME},...sidePanelOptions];if(!workbook)return;const hiddens=workbook.getHiddenWorksheets(),sheetsOption=workbook.getSheets().map(sheet=>({label:sheet.getName(),value:sheet.getSheetId()})).filter(opt=>hiddens.indexOf(opt.value)===-1),definedNames=Object.values((_a2=definedNameService.getDefinedNameMap(workbook.getUnitId()))!=null?_a2:{}).map(value=>({label:value.name,value:value.id})),formatUrl=__name((type2,payload2)=>{if(type2===sheetsHyperLink.SheetHyperLinkType.URL)return serializeUrl(payload2);if(type2===sheetsHyperLink.SheetHyperLinkType.RANGE){const info=engineFormula.deserializeRangeWithSheet(payload2),worksheet=workbook.getSheetBySheetName(info.sheetName);if(worksheet)return`#gid=${worksheet.getSheetId()}&range=${engineFormula.serializeRange(info.range)}`}return`#${type2}=${payload2}`},"formatUrl"),handleRangeChange=ui.useEvent(rangeText=>{var _a3;const range=rangeText.split(",").map(engineFormula.deserializeRangeWithSheet)[0];if(!range||!core.isValidRange(range.range))return;range.sheetName||(range.sheetName=((_a3=workbook.getActiveSheet())==null?void 0:_a3.getName())||"");const newPayload=engineFormula.serializeRangeToRefString(range);setPayload(newPayload),newPayload&&(setByPayload.current||!display)&&(setDisplay(newPayload),setByPayload.current=!0)}),handleSubmit=__name(async()=>{if(showLabel&&!display||!payload||type===sheetsHyperLink.SheetHyperLinkType.URL&&!isLegalLink(payload)){setShowError(!0);return}if(editing)if(id){const commandId=editing.type===HyperLinkEditSourceType.ZEN_EDITOR||editing.type===HyperLinkEditSourceType.EDITING?UpdateRichHyperLinkCommand.id:UpdateHyperLinkCommand.id;await commandService.executeCommand(commandId,{id,unitId:editing.unitId,subUnitId:editing.subUnitId,payload:{display:showLabel?display:"",payload:formatUrl(type,payload)},row:editing.row,column:editing.col,documentId:editing.type===HyperLinkEditSourceType.ZEN_EDITOR?core.DOCS_ZEN_EDITOR_UNIT_ID_KEY:editorBridgeService.getCurrentEditorId()})}else{const commandId=editing.type===HyperLinkEditSourceType.ZEN_EDITOR||editing.type===HyperLinkEditSourceType.EDITING?AddRichHyperLinkCommand.id:AddHyperLinkCommand.id;await commandService.executeCommand(commandId,{unitId:editing.unitId,subUnitId:editing.subUnitId,link:{id:core.generateRandomId(),row:editing.row,column:editing.col,payload:formatUrl(type,payload),display:showLabel?display:""},documentId:editing.type===HyperLinkEditSourceType.ZEN_EDITOR?core.DOCS_ZEN_EDITOR_UNIT_ID_KEY:editorBridgeService.getCurrentEditorId()})}if((editing==null?void 0:editing.type)===HyperLinkEditSourceType.VIEWING){await commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId:editing.unitId,subUnitId:editing.subUnitId});const GAP=1;await commandService.executeCommand(sheetsUi.ScrollToRangeOperation.id,{range:{startRow:Math.max(editing.row-GAP,0),endRow:editing.row+GAP,startColumn:Math.max(editing.col-GAP,0),endColumn:editing.col+GAP}})}commandService.executeCommand(CloseHyperLinkPopupOperation.id)},"handleSubmit"),handlePanelClick=__name(e=>{var _a3;if(type!==sheetsHyperLink.SheetHyperLinkType.RANGE)return;const handleOutClick=(_a3=rangeSelectorActionsRef.current)==null?void 0:_a3.handleOutClick;handleOutClick&&handleOutClick(e,isFocusRangeSelectorSet)},"handlePanelClick");return editing?jsxRuntimeExports.jsxs("div",{className:styles$1.cellLinkEdit,style:{display:hide?"none":"block"},onClick:handlePanelClick,children:[showLabel?jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("hyperLink.form.label"),error:showError&&!display?localeService.t("hyperLink.form.inputError"):"",children:jsxRuntimeExports.jsx(design.Input,{value:display,onChange:__name(v=>{setDisplay(v),setByPayload.current=!1},"onChange"),placeholder:localeService.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:__name(e=>{e.keyCode===ui.KeyCode.ENTER&&handleSubmit()},"onKeyDown")})}):null,jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("hyperLink.form.type"),contentStyle:{marginBottom:0},children:jsxRuntimeExports.jsx(design.Select,{options:linkTypeOptions,value:type,onChange:__name(newType=>{setType(newType),setPayload("")},"onChange")})}),type===sheetsHyperLink.SheetHyperLinkType.URL&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError?payload?isLegalLink(payload)?"":localeService.t("hyperLink.form.linkError"):localeService.t("hyperLink.form.inputError"):"",children:jsxRuntimeExports.jsx(design.Input,{value:payload,onChange:__name(newLink=>{setPayload(newLink),newLink&&(setByPayload.current||!display||display===payload)&&(setDisplay(newLink),setByPayload.current=!0)},"onChange"),placeholder:localeService.t("hyperLink.form.linkPlaceholder"),autoFocus:!showLabel,onKeyDown:__name(e=>{e.keyCode===ui.KeyCode.ENTER&&handleSubmit()},"onKeyDown")})}),type===sheetsHyperLink.SheetHyperLinkType.RANGE&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError&&!payload?localeService.t("hyperLink.form.inputError"):"",children:jsxRuntimeExports.jsx(sheetsFormulaUi.RangeSelector,{unitId:workbook.getUnitId(),subUnitId,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:payloadInitial,onChange:handleRangeChange,isFocus:isFocusRangeSelector,onBlur:__name(()=>{isFocusRangeSelectorSet(!1)},"onBlur"),actions:rangeSelectorActionsRef.current,onRangeSelectorDialogVisibleChange:__name(async visible=>{var _a3,_b2;if(visible)editing.type===HyperLinkEditSourceType.ZEN_EDITOR&&(zenZoneService.hide(),contextService.setContextValue(core.FOCUSING_SHEET,!0)),editing.type!==HyperLinkEditSourceType.VIEWING&&editorBridgeService.enableForceKeepVisible(),setHide(!0);else{if(await resolverService.navigateToRange(editing.unitId,editing.subUnitId,{startRow:editing.row,endRow:editing.row,startColumn:editing.col,endColumn:editing.col}),editing.type===HyperLinkEditSourceType.ZEN_EDITOR){await commandService.executeCommand(sheets.SetSelectionsOperation.id,{unitId:editing.unitId,subUnitId:editing.subUnitId,selections:[{range:{startRow:editing.row,endRow:editing.row,startColumn:editing.col,endColumn:editing.col}}]}),zenZoneService.show(),contextService.setContextValue(core.FOCUSING_SHEET,!1);const docBackScrollRenderController=(_a3=renderManagerService.getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a3.with(docsUi.DocBackScrollRenderController),range=(_b2=docSelectionManagerService.getTextRanges({unitId:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:_b2[0];docBackScrollRenderController&&range&&setTimeout(()=>{docBackScrollRenderController.scrollToRange(range),docSelectionManagerService.refreshSelection({unitId:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY})},100)}editorBridgeService.disableForceKeepVisible(),setHide(!1)}},"onRangeSelectorDialogVisibleChange")})}),type===sheetsHyperLink.SheetHyperLinkType.SHEET&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError&&!payload?localeService.t("hyperLink.form.selectError"):"",children:jsxRuntimeExports.jsx(design.Select,{options:sheetsOption,value:payload,onChange:__name(newPayload=>{var _a3,_b2;setPayload(newPayload);const label=(_a3=sheetsOption.find(i=>i.value===newPayload))==null?void 0:_a3.label,oldLabel=(_b2=sheetsOption.find(i=>i.value===payload))==null?void 0:_b2.label;label&&(setByPayload.current||!display||display===oldLabel)&&(setDisplay(label),setByPayload.current=!0)},"onChange")})}),type===sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError&&!payload?localeService.t("hyperLink.form.selectError"):"",children:jsxRuntimeExports.jsx(design.Select,{options:definedNames,value:payload,onChange:__name(newValue=>{var _a3,_b2;setPayload(newValue);const label=(_a3=definedNames.find(i=>i.value===newValue))==null?void 0:_a3.label,oldLabel=(_b2=definedNames.find(i=>i.value===payload))==null?void 0:_b2.label;label&&(setByPayload.current||!display||display===oldLabel)&&(setDisplay(label),setByPayload.current=!0)},"onChange")})}),(customHyperLinkSidePanel==null?void 0:customHyperLinkSidePanel.Form)&&jsxRuntimeExports.jsx(customHyperLinkSidePanel.Form,{linkId:id,payload,display,showError,setByPayload,setDisplay:__name(newLink=>{setDisplay(newLink),setByPayload.current=!0},"setDisplay"),setPayload}),jsxRuntimeExports.jsxs("div",{className:styles$1.cellLinkEditButtons,children:[jsxRuntimeExports.jsx(design.Button,{onClick:__name(()=>{editing&&resolverService.navigateToRange(editing.unitId,editing.subUnitId,{startRow:editing.row,endRow:editing.row,startColumn:editing.col,endColumn:editing.col}),commandService.executeCommand(CloseHyperLinkPopupOperation.id)},"onClick"),children:localeService.t("hyperLink.form.cancel")}),jsxRuntimeExports.jsx(design.Button,{type:"primary",style:{marginLeft:8},onClick:__name(async()=>{handleSubmit()},"onClick"),children:localeService.t("hyperLink.form.ok")})]})]}):null},"CellLinkEdit");CellLinkEdit.componentKey="univer.sheet.cell-link-edit";var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n2=arguments.length;i<n2;i++){s=arguments[i];for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&(t[p2]=s[p2])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&e.indexOf(p2)<0&&(t[p2]=s[p2]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p2=Object.getOwnPropertySymbols(s);i<p2.length;i++)e.indexOf(p2[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p2[i])&&(t[p2[i]]=s[p2[i]]);return t},IconBase=require$$0.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=require$$0.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return require$$0.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element$5={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},AllBorderSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"all-border-single",ref,icon:element$5}))});AllBorderSingle.displayName="AllBorderSingle";var element$4={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},CopySingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"copy-single",ref,icon:element$4}))});CopySingle.displayName="CopySingle";var element$3={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},LinkSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"link-single",ref,icon:element$3}))});LinkSingle.displayName="LinkSingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},UnlinkSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"unlink-single",ref,icon:element$2}))});UnlinkSingle.displayName="UnlinkSingle";var element$1={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},WriteSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"write-single",ref,icon:element$1}))});WriteSingle.displayName="WriteSingle";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Xlsx=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"xlsx",ref,icon:element}))});Xlsx.displayName="Xlsx";function r(e){var t,f2,n2="";if(typeof e=="string"||typeof e=="number")n2+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f2=r(e[t]))&&(n2&&(n2+=" "),n2+=f2)}else for(f2 in e)e[f2]&&(n2&&(n2+=" "),n2+=f2);return n2}__name(r,"r");function clsx(){for(var e,t,f2=0,n2="",o=arguments.length;f2<o;f2++)(e=arguments[f2])&&(t=r(e))&&(n2&&(n2+=" "),n2+=t);return n2}__name(clsx,"clsx");const CancelHyperLinkCommand={type:core.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(accessor,params){var _a2,_b2,_c2;if(!params)return!1;const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),renderManagerService=accessor.get(engineRender.IRenderManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),hyperLinkModel=accessor.get(sheetsHyperLink.HyperLinkModel),{unitId,subUnitId,row,column,id}=params,workbook=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET),currentRender=renderManagerService.getRenderById(unitId);if(!currentRender||!workbook)return!1;const worksheet=workbook==null?void 0:workbook.getSheetBySheetId(subUnitId),skeleton=(_a2=currentRender.with(sheetsUi.SheetSkeletonManagerService).getCurrent())==null?void 0:_a2.skeleton;if(!worksheet||!skeleton)return!1;const cellData=worksheet.getCell(row,column);if(!cellData)return!1;const doc=skeleton.getCellDocumentModelWithFormula(cellData);if(!(doc!=null&&doc.documentModel))return!1;const snapshot=core.Tools.deepClone(doc.documentModel.getSnapshot());if(!((_c2=(_b2=snapshot.body)==null?void 0:_b2.customRanges)==null?void 0:_c2.find(range2=>range2.rangeId===id)))return!1;const textX=core.BuildTextUtils.customRange.delete(accessor,{documentDataModel:doc.documentModel,rangeId:id});if(!textX)return!1;const newBody=core.TextX.apply(snapshot.body,textX.serialize()),redos=[],undos=[],setRangeParams={unitId,subUnitId,cellValue:{[row]:{[column]:{p:{...snapshot,body:newBody},t:core.CellValueType.STRING}}}};redos.push({id:sheets.SetRangeValuesMutation.id,params:setRangeParams});const undoParams=sheets.SetRangeValuesUndoMutationFactory(accessor,setRangeParams);undos.push({id:sheets.SetRangeValuesMutation.id,params:undoParams});const link=hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,column);return link&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:{...link}}})),core.sequenceExecute(redos,commandService).result?(undoRedoService.pushUndoRedo({redoMutations:redos,undoMutations:undos,unitID:unitId}),!0):!1}},CancelRichHyperLinkCommand={type:core.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(accessor,params){var _a2,_b2;if(!params)return!1;const{id:linkId,documentId}=params,commandService=accessor.get(core.ICommandService),doc=accessor.get(core.IUniverInstanceService).getUnit(documentId,core.UniverInstanceType.UNIVER_DOC),link=(_b2=(_a2=doc==null?void 0:doc.getBody())==null?void 0:_a2.customRanges)==null?void 0:_b2.find(i=>i.rangeId===linkId);let insert=null;link&&link.endIndex===doc.getBody().dataStream.length-3&&(insert={dataStream:" "});const doMutation=docsUi.deleteCustomRangeFactory(accessor,{unitId:documentId,rangeId:linkId,insert});return doMutation?commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},styles={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},iconsMap={[sheetsHyperLink.SheetHyperLinkType.URL]:jsxRuntimeExports.jsx(LinkSingle,{}),[sheetsHyperLink.SheetHyperLinkType.SHEET]:jsxRuntimeExports.jsx(Xlsx,{}),[sheetsHyperLink.SheetHyperLinkType.RANGE]:jsxRuntimeExports.jsx(AllBorderSingle,{}),[sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME]:jsxRuntimeExports.jsx(AllBorderSingle,{}),[sheetsHyperLink.SheetHyperLinkType.INVALID]:jsxRuntimeExports.jsx(AllBorderSingle,{})},CellLinkPopup=__name(()=>{var _a2,_b2;const popupService=core.useDependency(exports2.SheetsHyperLinkPopupService),commandService=core.useDependency(core.ICommandService),messageService=core.useDependency(ui.IMessageService),localeService=core.useDependency(core.LocaleService),[currentPopup,setCurrentPopup]=require$$0.useState(null),resolverService=core.useDependency(exports2.SheetsHyperLinkResolverService),editorBridgeService=core.useDependency(sheetsUi.IEditorBridgeService),zenZoneService=core.useDependency(ui.IZenZoneService);if(core.useObservable(zenZoneService.visible$),require$$0.useEffect(()=>{setCurrentPopup(popupService.currentPopup);const ob=popupService.currentPopup$.subscribe(popup=>{setCurrentPopup(popup)});return()=>{ob.unsubscribe()}},[popupService.currentPopup,popupService.currentPopup$]),!currentPopup)return null;const{unitId,subUnitId,customRange,row,col}=currentPopup;if(!((_a2=customRange==null?void 0:customRange.properties)!=null&&_a2.url))return null;const linkObj=resolverService.parseHyperLink((_b2=customRange.properties.url)!=null?_b2:""),isError=linkObj.type===sheetsHyperLink.SheetHyperLinkType.INVALID;return jsxRuntimeExports.jsxs("div",{className:styles.cellLink,onClick:__name(()=>popupService.hideCurrentPopup(),"onClick"),children:[jsxRuntimeExports.jsxs("div",{className:clsx(styles.cellLinkContent,{[styles.cellLinkContentError]:isError}),onClick:__name(()=>{zenZoneService.visible||linkObj.handler()},"onClick"),children:[jsxRuntimeExports.jsx("div",{className:styles.cellLinkType,children:iconsMap[linkObj.type]}),jsxRuntimeExports.jsx(design.Tooltip,{showIfEllipsis:!0,title:linkObj.name,children:jsxRuntimeExports.jsx("span",{className:styles.cellLinkUrl,children:linkObj.name})})]}),jsxRuntimeExports.jsxs("div",{className:styles.cellLinkOperations,children:[currentPopup.copyPermission&&jsxRuntimeExports.jsx("div",{className:clsx(styles.cellLinkOperation,{[styles.cellLinkOperationError]:isError}),onClick:__name(()=>{if(!isError){if(linkObj.type!==sheetsHyperLink.SheetHyperLinkType.URL){const url=new URL(window.location.href);url.hash=linkObj.url.slice(1),navigator.clipboard.writeText(url.href)}else navigator.clipboard.writeText(linkObj.url);messageService.show({content:localeService.t("hyperLink.message.coped"),type:design.MessageType.Info})}},"onClick"),children:jsxRuntimeExports.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("hyperLink.popup.copy"),children:jsxRuntimeExports.jsx(CopySingle,{})})}),currentPopup.editPermission&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:styles.cellLinkOperation,onClick:__name(()=>{commandService.executeCommand(OpenHyperLinkEditPanelOperation.id,{unitId,subUnitId,row,col,customRangeId:customRange.rangeId,type:currentPopup.type})},"onClick"),children:jsxRuntimeExports.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("hyperLink.popup.edit"),children:jsxRuntimeExports.jsx(WriteSingle,{})})}),jsxRuntimeExports.jsx("div",{className:styles.cellLinkOperation,onClick:__name(()=>{const commandId=currentPopup.type===HyperLinkEditSourceType.EDITING||currentPopup.type===HyperLinkEditSourceType.ZEN_EDITOR?CancelRichHyperLinkCommand.id:CancelHyperLinkCommand.id;commandService.syncExecuteCommand(commandId,{unitId,subUnitId,id:customRange.rangeId,row,column:col,documentId:currentPopup.type===HyperLinkEditSourceType.ZEN_EDITOR?core.DOCS_ZEN_EDITOR_UNIT_ID_KEY:editorBridgeService.getCurrentEditorId()})&&popupService.hideCurrentPopup(void 0,!0)},"onClick"),children:jsxRuntimeExports.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("hyperLink.popup.cancel"),children:jsxRuntimeExports.jsx(UnlinkSingle,{})})})]})]})]})},"CellLinkPopup");CellLinkPopup.componentKey="univer.sheet.cell-link-popup";var __defProp$a=Object.defineProperty,__getOwnPropDesc$a=Object.getOwnPropertyDescriptor,__decorateClass$a=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$a(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$a(target,key,result),result},"__decorateClass$a"),__decorateParam$a=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$a");const isEqualLink=__name((a,b)=>{var _a2,_b2;return a.unitId===b.unitId&&a.subUnitId===b.subUnitId&&a.row===b.row&&a.col===b.col&&((_a2=a.customRange)==null?void 0:_a2.rangeId)===((_b2=b.customRange)==null?void 0:_b2.rangeId)&&a.type===b.type},"isEqualLink");exports2.SheetsHyperLinkPopupService=(_c=class extends core.Disposable{constructor(_sheetCanvasPopManagerService,_injector,_univerInstanceService,_editorBridgeService,_textSelectionManagerService,_docCanvasPopManagerService,_editorService,_rangeSelectorService,_zenZoneService){super();__publicField(this,"_currentPopup",null);__publicField(this,"_currentPopup$",new rxjs.Subject);__publicField(this,"currentPopup$",this._currentPopup$.asObservable());__publicField(this,"_currentEditingPopup",null);__publicField(this,"_currentEditing$",new rxjs.BehaviorSubject(null));__publicField(this,"currentEditing$",this._currentEditing$.asObservable());__publicField(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=_sheetCanvasPopManagerService,this._injector=_injector,this._univerInstanceService=_univerInstanceService,this._editorBridgeService=_editorBridgeService,this._textSelectionManagerService=_textSelectionManagerService,this._docCanvasPopManagerService=_docCanvasPopManagerService,this._editorService=_editorService,this._rangeSelectorService=_rangeSelectorService,this._zenZoneService=_zenZoneService,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(v){this._isKeepVisible=v}getIsKeepVisible(){return this._isKeepVisible}showPopup(location2){if(this._currentPopup&&isEqualLink(location2,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),location2.type!==HyperLinkEditSourceType.ZEN_EDITOR&&this._zenZoneService.visible))return;const currentEditing=this._currentEditing$.getValue();if(currentEditing&&isEqualLink(location2,currentEditing))return;const{unitId,subUnitId,row,col,customRangeRect,customRange}=location2;if(!customRange)return;let disposable;const popup={componentKey:CellLinkPopup.componentKey,direction:"bottom",onClickOutside:__name(()=>{this.hideCurrentPopup()},"onClickOutside"),onClick:__name(()=>{this.hideCurrentPopup(location2.type,!0)},"onClick")};location2.type===HyperLinkEditSourceType.EDITING?disposable=customRangeRect&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(customRangeRect,popup):location2.type===HyperLinkEditSourceType.ZEN_EDITOR?disposable=this._docCanvasPopManagerService.attachPopupToRange({startOffset:customRange.startIndex,endOffset:customRange.endIndex+1,collapsed:!1},popup,core.DOCS_ZEN_EDITOR_UNIT_ID_KEY):disposable=customRangeRect&&this._sheetCanvasPopManagerService.attachPopupByPosition(customRangeRect,popup),disposable&&(this._currentPopup={unitId,subUnitId,disposable,row,col,editPermission:!!location2.editPermission,copyPermission:!!location2.copyPermission,customRange,type:location2.type},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(type,force){var _a2,_b2;this._currentPopup&&((!type||type===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||force)&&((_b2=(_a2=this._currentPopup)==null?void 0:_a2.disposable)==null||_b2.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var _a2,_b2,_c2;const visible=this._editorBridgeService.isVisible().visible,state=this._editorBridgeService.getEditCellState();if(visible&&state){const textRange=this._textSelectionManagerService.getActiveTextRange(),body=(_a2=state.documentLayoutObject.documentModel)==null?void 0:_a2.getBody();if(!body)return null;if(!textRange||textRange.collapsed)return{startOffset:0,endOffset:body.dataStream.length-2,collapsed:body.dataStream.length-2===0,label:core.BuildTextUtils.transform.getPlainText(body.dataStream)};const links=core.BuildTextUtils.customRange.getCustomRangesInterestsWithRange(textRange,(_c2=(_b2=body.customRanges)==null?void 0:_b2.filter(i=>i.rangeType===core.CustomRangeType.HYPERLINK))!=null?_c2:[]);let start=textRange.startOffset,end=textRange.endOffset;return links.forEach(link=>{start=Math.min(start,link.startIndex),end=Math.max(end,link.endIndex+1)}),{startOffset:start,endOffset:end,collapsed:start===end,label:core.BuildTextUtils.transform.getPlainText(body.dataStream.slice(start,end))}}return null}get _editPopup(){return{componentKey:CellLinkEdit.componentKey,direction:"bottom",onClickOutside:__name(()=>{this.getIsKeepVisible()||this.endEditing()},"onClickOutside"),onContextMenu:__name(()=>{this.getIsKeepVisible()||this.endEditing()},"onContextMenu"),hiddenType:"hide"}}startAddEditing(link){var _a2,_b2,_c2,_d2,_e2;const{unitId,subUnitId,type}=link;if(type===HyperLinkEditSourceType.ZEN_EDITOR){const document=this._univerInstanceService.getUnit(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,core.UniverInstanceType.UNIVER_DOC);if(!document)return;const range=this._textSelectionManagerService.getActiveTextRange();if(!range)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(range,this._editPopup,core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const label=(_a2=document.getBody())==null?void 0:_a2.dataStream.slice(range.startOffset,range.endOffset-1);this._currentEditing$.next({...link,label})}else if(type===HyperLinkEditSourceType.EDITING){const range=this._getEditingRange();range&&this._textSelectionManagerService.replaceTextRanges([{...range}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(link.row,link.col,this._editPopup,unitId,subUnitId),this._currentEditing$.next({...link,label:(_b2=range==null?void 0:range.label)!=null?_b2:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(link.row,link.col,this._editPopup,unitId,subUnitId);const workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET),worksheet=workbook==null?void 0:workbook.getSheetBySheetId(subUnitId),cell=worksheet==null?void 0:worksheet.getCellRaw(link.row,link.col);this._currentEditing$.next({...link,label:cell!=null&&cell.p?core.BuildTextUtils.transform.getPlainText((_d2=(_c2=cell.p.body)==null?void 0:_c2.dataStream)!=null?_d2:""):((_e2=cell==null?void 0:cell.v)!=null?_e2:"").toString()})}}startEditing(link){var _a2,_b2,_c2,_d2,_e2,_f2;(_a2=this._currentEditingPopup)==null||_a2.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId,subUnitId}=link;let customRange,label;if(link.type===HyperLinkEditSourceType.ZEN_EDITOR){const document=this._univerInstanceService.getUnit(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,core.UniverInstanceType.UNIVER_DOC);if(customRange=(_c2=(_b2=document==null?void 0:document.getBody())==null?void 0:_b2.customRanges)==null?void 0:_c2.find(range=>range.rangeId===link.customRangeId),label=customRange?(_d2=document==null?void 0:document.getBody())==null?void 0:_d2.dataStream.slice(customRange.startIndex+1,customRange.endIndex):"",!customRange||!label)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:customRange.startIndex,endOffset:customRange.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:customRange.startIndex,endOffset:customRange.endIndex,collapsed:!1},this._editPopup,core.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(link.type===HyperLinkEditSourceType.EDITING){const customRangeInfo=sheetsUi.getEditingCustomRangePosition(this._injector,link.unitId,link.subUnitId,link.row,link.col,link.customRangeId);if(!customRangeInfo||!((_e2=customRangeInfo.rects)!=null&&_e2.length))return;customRange=customRangeInfo.customRange,label=customRangeInfo.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:customRange.startIndex,endOffset:customRange.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(customRangeInfo.rects.pop(),this._editPopup,unitId,subUnitId)}else{const customRangeInfo=sheetsUi.getCustomRangePosition(this._injector,link.unitId,link.subUnitId,link.row,link.col,link.customRangeId);if(!customRangeInfo||!((_f2=customRangeInfo.rects)!=null&&_f2.length))return;customRange=customRangeInfo.customRange,label=customRangeInfo.label,this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(customRangeInfo.rects.pop(),this._editPopup,unitId,subUnitId)}this._currentEditing$.next({...link,customRange,label})}endEditing(type){var _a2;const current=this._currentEditing$.getValue();current&&(!type||type===current.type)&&((_a2=this._currentEditingPopup)==null||_a2.dispose(),this._currentEditing$.next(null))}},__name(_c,"SheetsHyperLinkPopupService"),_c),exports2.SheetsHyperLinkPopupService=__decorateClass$a([__decorateParam$a(0,core.Inject(sheetsUi.SheetCanvasPopManagerService)),__decorateParam$a(1,core.Inject(core.Injector)),__decorateParam$a(2,core.IUniverInstanceService),__decorateParam$a(3,sheetsUi.IEditorBridgeService),__decorateParam$a(4,core.Inject(docs.DocSelectionManagerService)),__decorateParam$a(5,core.Inject(docsUi.DocCanvasPopManagerService)),__decorateParam$a(6,docsUi.IEditorService),__decorateParam$a(7,docsUi.IRangeSelectorService),__decorateParam$a(8,ui.IZenZoneService)],exports2.SheetsHyperLinkPopupService);const getShouldDisableCellLink=__name((worksheet,row,col)=>{const cell=worksheet.getCell(row,col);if(cell!=null&&cell.f||cell!=null&&cell.si)return!0;const disables=[core.DataValidationType.CHECKBOX,core.DataValidationType.LIST,core.DataValidationType.LIST_MULTIPLE];return!!(cell!=null&&cell.dataValidation&&disables.includes(cell.dataValidation.rule.type))},"getShouldDisableCellLink"),getShouldDisableCurrentCellLink=__name(accessor=>{const unit=accessor.get(core.IUniverInstanceService).getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!unit)return!0;const worksheet=unit.getActiveSheet(),selections=accessor.get(sheets.SheetsSelectionsService).getCurrentSelections();if(!selections.length)return!0;const row=selections[0].range.startRow,col=selections[0].range.startColumn;return getShouldDisableCellLink(worksheet,row,col)},"getShouldDisableCurrentCellLink"),shouldDisableAddLink=__name(accessor=>{var _a2;const textSelectionService=accessor.get(docs.DocSelectionManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),textRanges=textSelectionService.getDocRanges();if(!textRanges.length||textRanges.length>1)return!0;const activeRange=textRanges[0],doc=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC);if(!doc||!activeRange||activeRange.collapsed)return!0;const body=doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody(),paragraphs=body==null?void 0:body.paragraphs;if(!paragraphs)return!0;for(let i=0,len=paragraphs.length;i<len;i++){const p2=paragraphs[i];if(activeRange.startOffset<=p2.startIndex&&activeRange.endOffset>p2.startIndex)return!0;if(p2.startIndex>activeRange.endOffset)break}return!core.BuildTextUtils.customRange.getCustomRangesInterestsWithRange(activeRange,(_a2=body.customRanges)!=null?_a2:[]).every(range=>range.rangeType===core.CustomRangeType.HYPERLINK)},"shouldDisableAddLink"),OpenHyperLinkEditPanelOperation={type:core.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(accessor,params){if(!params)return!1;const popupService=accessor.get(exports2.SheetsHyperLinkPopupService);return params.customRangeId?popupService.startEditing(params):popupService.startAddEditing(params),!0}},CloseHyperLinkPopupOperation={type:core.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(accessor){return accessor.get(exports2.SheetsHyperLinkPopupService).endEditing(),!0}},InsertHyperLinkOperation={type:core.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(accessor){var _a2;const univerInstanceService=accessor.get(core.IUniverInstanceService),target=sheets.getSheetCommandTarget(univerInstanceService),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService);if(!target)return!1;const commandService=accessor.get(core.ICommandService),selection=accessor.get(sheets.SheetsSelectionsService).getCurrentLastSelection();if(!selection)return!1;const row=selection.range.startRow,col=selection.range.startColumn,visible=editorBridgeService.isVisible(),isZenEditor=((_a2=univerInstanceService.getFocusedUnit())==null?void 0:_a2.getUnitId())===core.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return commandService.executeCommand(OpenHyperLinkEditPanelOperation.id,{unitId:target.unitId,subUnitId:target.subUnitId,row,col,type:isZenEditor?HyperLinkEditSourceType.ZEN_EDITOR:visible.visible?HyperLinkEditSourceType.EDITING:HyperLinkEditSourceType.VIEWING})}},InsertHyperLinkToolbarOperation={type:core.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(accessor){if(getShouldDisableCurrentCellLink(accessor))return!1;const commandService=accessor.get(core.ICommandService);return accessor.get(exports2.SheetsHyperLinkPopupService).currentEditing?commandService.executeCommand(CloseHyperLinkPopupOperation.id):commandService.executeCommand(InsertHyperLinkOperation.id)}},getLinkDisable$=__name(accessor=>{const disableRange$=sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetInsertHyperlinkPermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]}),univerInstanceService=accessor.get(core.IUniverInstanceService),sheetSelectionService=accessor.get(sheets.SheetsSelectionsService),disableCell$=univerInstanceService.focused$.pipe(rxjs.map(focused=>focused?univerInstanceService.getUnit(focused,core.UniverInstanceType.UNIVER_SHEET):null),rxjs.mergeMap(unit=>unit?unit.activeSheet$:new rxjs.Observable(sub=>{sub.next(null)})),rxjs.mergeMap(sheet=>sheetSelectionService.selectionMoveEnd$.pipe(rxjs.map(selections=>sheet&&{selections,sheet}))),rxjs.map(sheetWithSelection=>{if(!sheetWithSelection)return!0;const{selections,sheet}=sheetWithSelection;if(!selections.length)return!0;const row=selections[0].range.startRow,col=selections[0].range.startColumn;return getShouldDisableCellLink(sheet,row,col)}));return disableRange$.pipe(rxjs.mergeMap(disableRange=>disableCell$.pipe(rxjs.map(disableCell=>disableRange||disableCell))))},"getLinkDisable$"),getZenLinkDisable$=__name(accessor=>{const univerInstanceService=accessor.get(core.IUniverInstanceService);return univerInstanceService.focused$.pipe(rxjs.mergeMap(focused=>!focused||focused!==core.DOCS_ZEN_EDITOR_UNIT_ID_KEY?new rxjs.Observable(sub=>sub.next(null)):accessor.get(docs.DocSelectionManagerService).textSelection$),rxjs.map(selection=>{if(!selection||selection.unitId!==core.DOCS_ZEN_EDITOR_UNIT_ID_KEY)return!0;const state=accessor.get(sheetsUi.IEditorBridgeService).getEditCellState();if(!state)return!0;const target=sheets.getSheetCommandTarget(univerInstanceService,{unitId:state.unitId,subUnitId:state.sheetId});return!(target!=null&&target.worksheet)||getShouldDisableCellLink(target.worksheet,state.row,state.column)?!0:shouldDisableAddLink(accessor)}))},"getZenLinkDisable$"),linkMenu={commandId:InsertHyperLinkOperation.id,type:ui.MenuItemType.BUTTON,positions:[ui.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",icon:"LinkSingle"},genZenEditorMenuId=__name(id=>`${id}-zen-editor`,"genZenEditorMenuId"),insertLinkMenuFactory=__name(accessor=>({...linkMenu,id:linkMenu.commandId,hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:getLinkDisable$(accessor)}),"insertLinkMenuFactory"),zenEditorInsertLinkMenuFactory=__name(accessor=>({...linkMenu,id:genZenEditorMenuId(linkMenu.commandId),hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC,core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:getZenLinkDisable$(accessor)}),"zenEditorInsertLinkMenuFactory"),linkToolbarMenu={tooltip:"hyperLink.form.addTitle",positions:ui.MenuPosition.TOOLBAR_START,group:ui.MenuGroup.TOOLBAR_OTHERS,commandId:InsertHyperLinkToolbarOperation.id,type:ui.MenuItemType.BUTTON,icon:"LinkSingle"},insertLinkMenuToolbarFactory=__name(accessor=>({...linkToolbarMenu,id:linkToolbarMenu.commandId,hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:getLinkDisable$(accessor)}),"insertLinkMenuToolbarFactory"),zenEditorInsertLinkMenuToolbarFactory=__name(accessor=>({...linkToolbarMenu,id:genZenEditorMenuId(linkToolbarMenu.commandId),hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC,core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:getZenLinkDisable$(accessor)}),"zenEditorInsertLinkMenuToolbarFactory"),InsertLinkShortcut={id:InsertHyperLinkToolbarOperation.id,binding:ui.KeyCode.K|ui.MetaKeys.CTRL_COMMAND,preconditions:sheetsUi.whenSheetEditorFocused};var __defProp$9=Object.defineProperty,__getOwnPropDesc$9=Object.getOwnPropertyDescriptor,__decorateClass$9=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$9(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$9(target,key,result),result},"__decorateClass$9"),__decorateParam$9=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$9");let SheetsHyperLinkAutoFillController=(_d=class extends core.Disposable{constructor(_autoFillService,_hyperLinkModel){super(),this._autoFillService=_autoFillService,this._hyperLinkModel=_hyperLinkModel,this._initAutoFill()}_initAutoFill(){const noopReturnFunc=__name(()=>({redos:[],undos:[]}),"noopReturnFunc"),generalApplyFunc=__name((location2,applyType)=>{const{source:sourceRange,target:targetRange,unitId,subUnitId}=location2,virtualRange=sheetsUi.virtualizeDiscreteRanges([sourceRange,targetRange]),[vSourceRange,vTargetRange]=virtualRange.ranges,{mapFunc}=virtualRange,sourceStartCell={row:vSourceRange.startRow,col:vSourceRange.startColumn},repeats=sheetsUi.getAutoFillRepeatRange(vSourceRange,vTargetRange),redos=[],undos=[];return repeats.forEach(repeat=>{const targetStartCell=repeat.repeatStartCell,relativeRange=repeat.relativeRange,sourceRange2={startRow:sourceStartCell.row,startColumn:sourceStartCell.col,endColumn:sourceStartCell.col,endRow:sourceStartCell.row},targetRange2={startRow:targetStartCell.row,startColumn:targetStartCell.col,endColumn:targetStartCell.col,endRow:targetStartCell.row};core.Range.foreach(relativeRange,(row,col)=>{const sourcePositionRange=core.Rectangle.getPositionRange({startRow:row,startColumn:col,endColumn:col,endRow:row},sourceRange2),{row:sourceRow,col:sourceCol}=mapFunc(sourcePositionRange.startRow,sourcePositionRange.startColumn),link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,sourceRow,sourceCol),targetPositionRange=core.Rectangle.getPositionRange({startRow:row,startColumn:col,endColumn:col,endRow:row},targetRange2),{row:targetRow,col:targetCol}=mapFunc(targetPositionRange.startRow,targetPositionRange.startColumn),id=core.Tools.generateRandomId(),currentLink=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,targetRow,targetCol);currentLink&&redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:currentLink.id}}),(sheetsUi.APPLY_TYPE.COPY===applyType||sheetsUi.APPLY_TYPE.SERIES===applyType)&&link&&(redos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:{...link,id,row:targetRow,column:targetCol}}}),undos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id}})),currentLink&&undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:currentLink}})})}),{undos,redos}},"generalApplyFunc"),hook={id:SHEET_HYPER_LINK_UI_PLUGIN,onFillData:__name((location2,direction,applyType)=>applyType===sheetsUi.APPLY_TYPE.COPY||applyType===sheetsUi.APPLY_TYPE.ONLY_FORMAT||applyType===sheetsUi.APPLY_TYPE.SERIES?generalApplyFunc(location2,applyType):noopReturnFunc(),"onFillData")};this.disposeWithMe(this._autoFillService.addHook(hook))}},__name(_d,"SheetsHyperLinkAutoFillController"),_d);SheetsHyperLinkAutoFillController=__decorateClass$9([__decorateParam$9(0,sheetsUi.IAutoFillService),__decorateParam$9(1,core.Inject(sheetsHyperLink.HyperLinkModel))],SheetsHyperLinkAutoFillController);var __defProp$8=Object.defineProperty,__getOwnPropDesc$8=Object.getOwnPropertyDescriptor,__decorateClass$8=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$8(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$8(target,key,result),result},"__decorateClass$8"),__decorateParam$8=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$8");let SheetsHyperLinkPermissionController=(_e=class extends core.Disposable{constructor(_localeService,_commandService,_sheetPermissionInterceptorBaseController){super(),this._localeService=_localeService,this._commandService=_commandService,this._sheetPermissionInterceptorBaseController=_sheetPermissionInterceptorBaseController,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(command=>{command.id===InsertLinkShortcut.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookEditablePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}},__name(_e,"SheetsHyperLinkPermissionController"),_e);SheetsHyperLinkPermissionController=__decorateClass$8([__decorateParam$8(0,core.Inject(core.LocaleService)),__decorateParam$8(1,core.ICommandService),__decorateParam$8(2,core.Inject(sheetsUi.SheetPermissionInterceptorBaseController))],SheetsHyperLinkPermissionController);var __defProp$7=Object.defineProperty,__getOwnPropDesc$7=Object.getOwnPropertyDescriptor,__decorateClass$7=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$7(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$7(target,key,result),result},"__decorateClass$7"),__decorateParam$7=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$7");let SheetsHyperLinkPopupController=(_f=class extends core.Disposable{constructor(_hoverManagerService,_sheetsHyperLinkPopupService,_renderManagerService,_permissionService,_sheetPermissionInterceptorBaseController,_commandService,_editorBridgeService,_textSelectionManagerService,_univerInstanceService,_zenZoneService){super(),this._hoverManagerService=_hoverManagerService,this._sheetsHyperLinkPopupService=_sheetsHyperLinkPopupService,this._renderManagerService=_renderManagerService,this._permissionService=_permissionService,this._sheetPermissionInterceptorBaseController=_sheetPermissionInterceptorBaseController,this._commandService=_commandService,this._editorBridgeService=_editorBridgeService,this._textSelectionManagerService=_textSelectionManagerService,this._univerInstanceService=_univerInstanceService,this._zenZoneService=_zenZoneService,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(location2){const{unitId,subUnitId,row:currentRow,col:currentCol}=location2,workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET);if(!(workbook==null?void 0:workbook.getSheetBySheetId(subUnitId)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const viewPermission=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookViewPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:currentRow,startColumn:currentCol,endRow:currentRow,endColumn:currentCol}]),editPermission=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetInsertHyperlinkPermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]},[{startRow:currentRow,startColumn:currentCol,endRow:currentRow,endColumn:currentCol}]),copyPermission=this._permissionService.composePermission([new sheets.WorkbookCopyPermission(unitId).id,new sheets.WorksheetCopyPermission(unitId,subUnitId).id]).every(permission=>permission.value);return{viewPermission,editPermission,copyPermission}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(rxjs.debounceTime(200)).subscribe(currentCell=>{var _a2;if(!currentCell){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId,subUnitId,row,col}=currentCell,renderer=this._renderManagerService.getRenderById(unitId);if(!renderer)return;if(!renderer.with(sheetsUi.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING);return}const skeleton=(_a2=renderer==null?void 0:renderer.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId))==null?void 0:_a2.skeleton,currentCol=col,currentRow=row;let targetRow=currentRow,targetCol=currentCol;skeleton&&skeleton.overflowCache.forValue((row2,col2,value)=>{core.Rectangle.contains(value,{startColumn:currentCol,endColumn:currentCol,startRow:currentRow,endRow:currentRow})&&(targetRow=row2,targetCol=col2)});const{viewPermission,editPermission,copyPermission}=this._getLinkPermission(currentCell);if(!viewPermission||!currentCell.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:targetRow,col:targetCol,editPermission,copyPermission,customRange:currentCell.customRange,customRangeRect:currentCell.rect,type:HyperLinkEditSourceType.VIEWING,unitId,subUnitId})}))}_initHoverEditingListener(){let subscribe=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(rxjs.mergeMap(state=>this._editorBridgeService.visible$.pipe(rxjs.map(visible=>({visible,state}))))).subscribe(({visible,state})=>{if(!state||state.editorUnitId!==core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!visible.visible){subscribe==null||subscribe.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.EDITING),this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING);return}const{editorUnitId,unitId,sheetId,row,column}=state,renderer=this._renderManagerService.getRenderById(editorUnitId);if(!renderer)return;const{editPermission,viewPermission,copyPermission}=this._getLinkPermission({unitId,subUnitId:sheetId,row,col:column}),docEventService=renderer.with(docsUi.DocEventManagerService);viewPermission&&(subscribe==null||subscribe.unsubscribe(),subscribe=docEventService.hoverCustomRanges$.pipe(rxjs.debounceTime(200)).subscribe(customRanges=>{var _a2,_b2;const customRange=customRanges.find(customRange2=>customRange2.range.rangeType===core.CustomRangeType.HYPERLINK);if(!customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const rect=customRange.rects[customRange.rects.length-1];if(!((_b2=(_a2=this._renderManagerService.getRenderById(unitId))==null?void 0:_a2.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(sheetId))==null?void 0:_b2.skeleton)||!rect)return;const canvasClientRect=renderer.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId,subUnitId:sheetId,row,col:column,customRange:customRange.range,customRangeRect:{left:rect.left+canvasClientRect.left,top:rect.top+canvasClientRect.top,bottom:rect.bottom+canvasClientRect.top,right:rect.right+canvasClientRect.left},editPermission,copyPermission,type:HyperLinkEditSourceType.EDITING})}))})),this.disposeWithMe(()=>{subscribe==null||subscribe.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(visible=>{visible&&(this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.EDITING),this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(rxjs.mergeMap(id=>{const render2=id===core.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(id):null;return render2?render2.with(docsUi.DocEventManagerService).hoverCustomRanges$.pipe(rxjs.debounceTime(200)):new rxjs.Observable(sub=>{sub.next(null)})})).subscribe(value=>{const range=value==null?void 0:value.find(range2=>range2.range.rangeType===core.CustomRangeType.HYPERLINK),state=this._editorBridgeService.getEditCellState();if(range&&state){const{unitId,sheetId,row,column}=state,{editPermission,viewPermission,copyPermission}=this._getLinkPermission({unitId,subUnitId:sheetId,row,col:column});viewPermission&&this._sheetsHyperLinkPopupService.showPopup({type:HyperLinkEditSourceType.ZEN_EDITOR,unitId,subUnitId:sheetId,row,col:column,customRange:range.range,editPermission,copyPermission})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(selection=>{selection&&selection.unitId===core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING)}))}_initCommandListener(){const HIDE_COMMAND_LIST=[sheets.ClearSelectionContentCommand.id,sheets.ClearSelectionAllCommand.id,sheets.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(command=>{HIDE_COMMAND_LIST.includes(command.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}},__name(_f,"SheetsHyperLinkPopupController"),_f);SheetsHyperLinkPopupController=__decorateClass$7([__decorateParam$7(0,core.Inject(sheetsUi.HoverManagerService)),__decorateParam$7(1,core.Inject(exports2.SheetsHyperLinkPopupService)),__decorateParam$7(2,core.Inject(engineRender.IRenderManagerService)),__decorateParam$7(3,core.Inject(core.IPermissionService)),__decorateParam$7(4,core.Inject(sheetsUi.SheetPermissionInterceptorBaseController)),__decorateParam$7(5,core.ICommandService),__decorateParam$7(6,sheetsUi.IEditorBridgeService),__decorateParam$7(7,core.Inject(docs.DocSelectionManagerService)),__decorateParam$7(8,core.IUniverInstanceService),__decorateParam$7(9,ui.IZenZoneService)],SheetsHyperLinkPopupController);var __defProp$6=Object.defineProperty,__getOwnPropDesc$6=Object.getOwnPropertyDescriptor,__decorateClass$6=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$6(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$6(target,key,result),result},"__decorateClass$6"),__decorateParam$6=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$6");let SheetsHyperLinkRemoveSheetController=(_g=class extends core.Disposable{constructor(_sheetInterceptorService,_univerInstanceService,_hyperLinkModel){super(),this._sheetInterceptorService=_sheetInterceptorService,this._univerInstanceService=_univerInstanceService,this._hyperLinkModel=_hyperLinkModel,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(commandInfo=>{var _a2;if(commandInfo.id===sheets.RemoveSheetCommand.id){const params=commandInfo.params,workbook=params.unitId?this._univerInstanceService.getUnit(params.unitId):this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return{redos:[],undos:[]};const unitId=workbook.getUnitId(),subUnitId=params.subUnitId||((_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId());if(!subUnitId)return{redos:[],undos:[]};const links=this._hyperLinkModel.getSubUnit(unitId,subUnitId),redos=links.map(link=>({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}})),undos=links.map(link=>({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}}));return{redos,undos}}return{redos:[],undos:[]}},"getMutations")}))}},__name(_g,"SheetsHyperLinkRemoveSheetController"),_g);SheetsHyperLinkRemoveSheetController=__decorateClass$6([__decorateParam$6(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$6(1,core.IUniverInstanceService),__decorateParam$6(2,core.Inject(sheetsHyperLink.HyperLinkModel))],SheetsHyperLinkRemoveSheetController);var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");let SheetsHyperLinkRenderController=(_h=class extends core.Disposable{constructor(_context,_hyperLinkModel){super(),this._context=_context,this._hyperLinkModel=_hyperLinkModel,this._initSkeletonChange()}_initSkeletonChange(){const markSkeletonDirty=__name(()=>{var _a2;(_a2=this._context.mainComponent)==null||_a2.makeForceDirty()},"markSkeletonDirty");this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(rxjs.debounceTime(16)).subscribe(()=>{markSkeletonDirty()}))}},__name(_h,"SheetsHyperLinkRenderController"),_h);SheetsHyperLinkRenderController=__decorateClass$5([__decorateParam$5(1,core.Inject(sheetsHyperLink.HyperLinkModel))],SheetsHyperLinkRenderController);let SheetsHyperLinkRenderManagerController=(_i=class extends core.Disposable{constructor(_sheetInterceptorService,_hyperLinkModel){super(),this._sheetInterceptorService=_sheetInterceptorService,this._hyperLinkModel=_hyperLinkModel,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(sheets.INTERCEPTOR_POINT.CELL_CONTENT,{effect:core.InterceptorEffectEnum.Value,priority:100,handler:__name((cell,pos,next)=>{const{row,col,unitId,subUnitId}=pos,link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);return next(link?{...cell,linkUrl:link.payload,linkId:link.id}:cell)},"handler")}))}},__name(_i,"SheetsHyperLinkRenderManagerController"),_i);SheetsHyperLinkRenderManagerController=__decorateClass$5([__decorateParam$5(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$5(1,core.Inject(sheetsHyperLink.HyperLinkModel))],SheetsHyperLinkRenderManagerController);var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");let SheetsHyperLinkRichTextRefRangeController=(_j=class extends core.Disposable{constructor(_commandService,_univerInstanceService,_refRangeService){super();__publicField(this,"_refRangeMap",new Map);this._commandService=_commandService,this._univerInstanceService=_univerInstanceService,this._refRangeService=_refRangeService,this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(unitId,subUnitId){let unitMap=this._refRangeMap.get(unitId);unitMap||(unitMap=new Map,this._refRangeMap.set(unitId,unitMap));let subUnitMap=unitMap.get(subUnitId);return subUnitMap||(subUnitMap=new core.ObjectMatrix,unitMap.set(subUnitId,subUnitMap)),subUnitMap}_isLegalRangeUrl(unitId,payload){var _a2,_b2,_c2;const workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return null;if(payload&&payload.startsWith("#")){const search=new URLSearchParams(payload.slice(1)),searchObj={gid:(_a2=search.get("gid"))!=null?_a2:"",range:(_b2=search.get("range"))!=null?_b2:"",rangeid:(_c2=search.get("rangeid"))!=null?_c2:""};if(searchObj.range&&searchObj.gid){const subUnitId=searchObj.gid,worksheet=workbook.getSheetBySheetId(subUnitId);if(!worksheet)return null;const range=engineFormula.deserializeRangeWithSheet(searchObj.range).range;if(core.isValidRange(range,worksheet)&&searchObj.range!==sheetsHyperLink.ERROR_RANGE)return range}}return null}_registerRange(unitId,subUnitId,row,col,p2){var _a2,_b2,_c2,_d2;const map=this._enusreMap(unitId,subUnitId),data=core.Tools.deepClone(p2),handleRangeChange=__name(commandInfo=>{var _a3,_b3;const dataCopy=core.Tools.deepClone(data);(_b3=(_a3=dataCopy.body)==null?void 0:_a3.customRanges)==null||_b3.forEach(customRange=>{var _a4;if(customRange.rangeType===core.CustomRangeType.HYPERLINK){const payload=(_a4=customRange.properties)==null?void 0:_a4.url,range=this._isLegalRangeUrl(unitId,payload);if(range){const resultRange=sheets.handleDefaultRangeChangeWithEffectRefCommands(range,commandInfo),newPayload=`#gid=${subUnitId}&range=${resultRange?engineFormula.serializeRange(resultRange):sheetsHyperLink.ERROR_RANGE}`;customRange.properties.url=newPayload}}});const position=sheets.handleDefaultRangeChangeWithEffectRefCommands({startRow:row,endRow:row,startColumn:col,endColumn:col},commandInfo);return position?{redos:[{id:sheets.SetRangeValuesMutation.id,params:{unitId,subUnitId,cellValue:{[position.startRow]:{[position.startColumn]:{p:dataCopy}}}}}],undos:[{id:sheets.SetRangeValuesMutation.id,params:{unitId,subUnitId,cellValue:{[row]:{[col]:{p:data}}}}}]}:{redos:[],undos:[]}},"handleRangeChange");if((_b2=(_a2=p2.body)==null?void 0:_a2.customRanges)!=null&&_b2.some(customRange=>{var _a3;return customRange.rangeType===core.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(unitId,(_a3=customRange.properties)==null?void 0:_a3.url)})){const disposableCollection=new core.DisposableCollection;(_d2=(_c2=p2.body)==null?void 0:_c2.customRanges)==null||_d2.forEach(customRange=>{var _a3;if(customRange.rangeType===core.CustomRangeType.HYPERLINK){const payload=(_a3=customRange.properties)==null?void 0:_a3.url,range=this._isLegalRangeUrl(unitId,payload);range&&disposableCollection.add(this._refRangeService.registerRefRange(range,handleRangeChange,unitId,subUnitId))}}),map.setValue(row,col,disposableCollection)}}_initWorkbookLoad(){const handleWorkbook=__name(workbook=>{const unitId=workbook.getUnitId();workbook.getSheets().forEach(sheet=>{const subUnitId=sheet.getSheetId(),map=this._enusreMap(unitId,subUnitId);sheet.getCellMatrix().forValue((row,col,cell)=>{const dispose=map.getValue(row,col);dispose&&dispose.dispose(),cell&&cell.p&&this._registerRange(unitId,subUnitId,row,col,cell.p)})})},"handleWorkbook");this._univerInstanceService.getAllUnitsForType(core.UniverInstanceType.UNIVER_SHEET).forEach(workbook=>{handleWorkbook(workbook)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(unit=>{unit.type===core.UniverInstanceType.UNIVER_SHEET&&handleWorkbook(unit)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(unit=>{if(unit.type===core.UniverInstanceType.UNIVER_SHEET){const workbook=unit,unitId=workbook.getUnitId();workbook.getSheets().forEach(sheet=>{const subUnitId=sheet.getSheetId();this._enusreMap(unitId,subUnitId).forValue((row,col,dispose)=>{dispose&&dispose.dispose()})}),this._refRangeMap.delete(unitId)}})}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{if(commandInfo.id===sheets.SetRangeValuesMutation.id){const params=commandInfo.params,{unitId,subUnitId,cellValue}=params,map=this._enusreMap(unitId,subUnitId);cellValue&&new core.ObjectMatrix(cellValue).forValue((row,col,cell)=>{const dispose=map.getValue(row,col);dispose&&dispose.dispose(),cell&&cell.p&&this._registerRange(unitId,subUnitId,row,col,cell.p)})}}))}},__name(_j,"SheetsHyperLinkRichTextRefRangeController"),_j);SheetsHyperLinkRichTextRefRangeController=__decorateClass$4([__decorateParam$4(0,core.ICommandService),__decorateParam$4(1,core.IUniverInstanceService),__decorateParam$4(2,core.Inject(sheets.RefRangeService))],SheetsHyperLinkRichTextRefRangeController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");let SheetHyperLinkSetRangeController=(_k=class extends core.Disposable{constructor(_sheetInterceptorService,_hyperLinkModel,_selectionManagerService,_univerInstanceService,_editorBridgeService,_renderManagerService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._hyperLinkModel=_hyperLinkModel,this._selectionManagerService=_selectionManagerService,this._univerInstanceService=_univerInstanceService,this._editorBridgeService=_editorBridgeService,this._renderManagerService=_renderManagerService,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(command=>{if(command.id===sheets.SetRangeValuesCommand.id){const params=command.params,{unitId,subUnitId}=params,redos=[],undos=[];return params.cellValue&&new core.ObjectMatrix(params.cellValue).forValue((row,col)=>{const link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);link&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}}))}),{undos,redos}}return{redos:[],undos:[]}},"getMutations")}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(command=>{if(command.id===sheets.ClearSelectionContentCommand.id||command.id===sheets.ClearSelectionAllCommand.id||command.id===sheets.ClearSelectionFormatCommand.id){const redos=[],undos=[],selection=this._selectionManagerService.getCurrentLastSelection(),target=sheets.getSheetCommandTarget(this._univerInstanceService);if(selection&&target){const{unitId,subUnitId}=target;core.Range.foreach(selection.range,(row,col)=>{const link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);link&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}}))})}return{redos,undos}}return{redos:[],undos:[]}},"getMutations")}))}_initAfterEditor(){this.disposeWithMe(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:__name((cell,context,next)=>{if(!cell||cell.p)return next(cell);if(typeof cell.v=="string"&&core.Tools.isLegalUrl(cell.v)&&cell.v[cell.v.length-1]!==" "){const{unitId,subUnitId}=context,renderer=this._renderManagerService.getRenderById(unitId),skeleton=renderer==null?void 0:renderer.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);if(!skeleton)return next(cell);const doc=skeleton.skeleton.getBlankCellDocumentModel(cell);if(!doc.documentModel)return next(cell);const textX=core.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:cell.v.length,collapsed:!1},body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${cell.v}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{startIndex:0,endIndex:cell.v.length+1,rangeId:core.generateRandomId(),rangeType:core.CustomRangeType.HYPERLINK,properties:{url:cell.v}}]},doc:doc.documentModel});if(!textX)return next(cell);const body=doc.documentModel.getBody();return core.TextX.apply(body,textX.serialize()),next({...cell,p:{id:core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return next(cell)},"handler")}))}},__name(_k,"SheetHyperLinkSetRangeController"),_k);SheetHyperLinkSetRangeController=__decorateClass$3([__decorateParam$3(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$3(1,core.Inject(sheetsHyperLink.HyperLinkModel)),__decorateParam$3(2,core.Inject(sheets.SheetsSelectionsService)),__decorateParam$3(3,core.IUniverInstanceService),__decorateParam$3(4,sheetsUi.IEditorBridgeService),__decorateParam$3(5,engineRender.IRenderManagerService)],SheetHyperLinkSetRangeController);const menuSchema={[ui.RibbonStartGroup.OTHERS]:{[InsertHyperLinkToolbarOperation.id]:{order:2,menuItemFactory:insertLinkMenuToolbarFactory},[genZenEditorMenuId(InsertHyperLinkToolbarOperation.id)]:{order:2,menuItemFactory:zenEditorInsertLinkMenuToolbarFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.OTHERS]:{order:1,[InsertHyperLinkToolbarOperation.id]:{order:0,menuItemFactory:insertLinkMenuFactory},[genZenEditorMenuId(InsertHyperLinkToolbarOperation.id)]:{order:0,menuItemFactory:zenEditorInsertLinkMenuFactory}}}};var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let SheetsHyperLinkUIController=(_l=class extends core.Disposable{constructor(_componentManager,_commandService,_menuManagerService,_injector,_shortcutService){super(),this._componentManager=_componentManager,this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._injector=_injector,this._shortcutService=_shortcutService,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[CellLinkPopup,CellLinkPopup.componentKey],[CellLinkEdit,CellLinkEdit.componentKey],[LinkSingle,"LinkSingle"]].forEach(([comp,key])=>{this._componentManager.register(key,comp)})}_initCommands(){[OpenHyperLinkEditPanelOperation,CloseHyperLinkPopupOperation,InsertHyperLinkOperation,InsertHyperLinkToolbarOperation,AddHyperLinkCommand,UpdateHyperLinkCommand,CancelHyperLinkCommand,UpdateRichHyperLinkCommand,CancelRichHyperLinkCommand,AddRichHyperLinkCommand].forEach(command=>{this._commandService.registerCommand(command)})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}_initShortCut(){this._shortcutService.registerShortcut(InsertLinkShortcut)}},__name(_l,"SheetsHyperLinkUIController"),_l);SheetsHyperLinkUIController=__decorateClass$2([__decorateParam$2(0,core.Inject(ui.ComponentManager)),__decorateParam$2(1,core.ICommandService),__decorateParam$2(2,ui.IMenuManagerService),__decorateParam$2(3,core.Inject(core.Injector)),__decorateParam$2(4,core.Inject(ui.IShortcutService))],SheetsHyperLinkUIController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let SheetHyperLinkUrlController=(_m=class extends core.Disposable{constructor(_resolverService){super(),this._resolverService=_resolverService,this._handleInitUrl()}_handleInitUrl(){const hash=location.hash;hash&&this._resolverService.parseHyperLink(hash).handler()}},__name(_m,"SheetHyperLinkUrlController"),_m);SheetHyperLinkUrlController=__decorateClass$1([__decorateParam$1(0,core.Inject(exports2.SheetsHyperLinkResolverService))],SheetHyperLinkUrlController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverSheetsHyperLinkUIPlugin=(_n=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[exports2.SheetsHyperLinkResolverService],[exports2.SheetsHyperLinkPopupService],[SheetsHyperLinkSidePanelService],[SheetsHyperLinkRemoveSheetController],[SheetsHyperLinkRenderManagerController],[SheetHyperLinkSetRangeController],[SheetsHyperLinkPopupController],[SheetsHyperLinkUIController],[SheetsHyperLinkAutoFillController],[exports2.SheetsHyperLinkCopyPasteController],[SheetsHyperLinkPermissionController],[SheetHyperLinkUrlController],[SheetsHyperLinkRichTextRefRangeController]].forEach(dep=>this._injector.add(dep)),this._injector.get(SheetsHyperLinkRenderManagerController),this._injector.get(SheetsHyperLinkRichTextRefRangeController),this._injector.get(SheetHyperLinkSetRangeController)}onReady(){this._injector.get(engineRender.IRenderManagerService).registerRenderModule(core.UniverInstanceType.UNIVER_SHEET,[SheetsHyperLinkRenderController]),this._injector.get(SheetsHyperLinkAutoFillController),this._injector.get(exports2.SheetsHyperLinkCopyPasteController),this._injector.get(SheetsHyperLinkRemoveSheetController),this._injector.get(SheetsHyperLinkUIController)}onRendered(){this._injector.get(SheetsHyperLinkPermissionController),this._injector.get(SheetHyperLinkUrlController),this._injector.get(SheetsHyperLinkPopupController)}},__name(_n,"UniverSheetsHyperLinkUIPlugin"),_n),__publicField2(exports2.UniverSheetsHyperLinkUIPlugin,"pluginName",SHEET_HYPER_LINK_UI_PLUGIN),__publicField2(exports2.UniverSheetsHyperLinkUIPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),exports2.UniverSheetsHyperLinkUIPlugin=__decorateClass([core.DependentOn(sheetsHyperLink.UniverSheetsHyperLinkPlugin,docsUi.UniverDocsUIPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports2.UniverSheetsHyperLinkUIPlugin),exports2.AddHyperLinkCommand=AddHyperLinkCommand,exports2.CancelHyperLinkCommand=CancelHyperLinkCommand,exports2.CloseHyperLinkPopupOperation=CloseHyperLinkPopupOperation,exports2.InsertHyperLinkOperation=InsertHyperLinkOperation,exports2.InsertLinkShortcut=InsertLinkShortcut,exports2.OpenHyperLinkEditPanelOperation=OpenHyperLinkEditPanelOperation,exports2.SheetsHyperLinkSidePanelService=SheetsHyperLinkSidePanelService,exports2.UpdateHyperLinkCommand=UpdateHyperLinkCommand,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var qt=R,en=Symbol.for("react.element"),tn=Symbol.for("react.fragment"),nn=Object.prototype.hasOwnProperty,rn=qt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,sn={key:!0,ref:!0,__self:!0,__source:!0};function ct(t,i,e){var n,r={},o=null,a=null;e!==void 0&&(o=""+e),i.key!==void 0&&(o=""+i.key),i.ref!==void 0&&(a=i.ref);for(n in i)nn.call(i,n)&&!sn.hasOwnProperty(n)&&(r[n]=i[n]);if(t&&t.defaultProps)for(n in i=t.defaultProps,i)r[n]===void 0&&(r[n]=i[n]);return{$$typeof:en,type:t,key:o,ref:a,props:r,_owner:rn.current}}Ee.Fragment=tn,Ee.jsx=ct,Ee.jsxs=ct,at.exports=Ee;var C=at.exports;class Fe extends s.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==g.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:n}=this;n.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const lt={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Re=()=>{var Tt;const[t,i]=R.useState(""),[e,n]=R.useState(!1),[r,o]=R.useState(""),[a,c]=R.useState(!0),[l,u]=R.useState(g.SheetHyperLinkType.URL),[p,h]=R.useState(""),v=s.useDependency(s.LocaleService),_=s.useDependency(F.IDefinedNamesService),P=s.useDependency(I.IEditorBridgeService),E=s.useDependency(s.IUniverInstanceService),k=s.useDependency(S.SheetsHyperLinkPopupService),d=O.useObservable(k.currentEditing$),H=s.useDependency(g.SheetsHyperLinkParserService),N=s.useDependency(S.SheetsHyperLinkResolverService),x=s.useDependency(s.ICommandService),V=s.useDependency(Fe),q=R.useMemo(()=>V.getOptions(),[V]),Y=s.useDependency(O.IZenZoneService),re=s.useDependency(pe.IRenderManagerService),_e=s.useDependency(I.IMarkSelectionService),Be=s.useDependency(he.DocSelectionManagerService),se=s.useDependency(s.IContextService),Se=s.useDependency(s.ThemeService),me=s.useDependency(he.DocSelectionManagerService),fe=R.useRef({}),oe=R.useMemo(()=>{if(!V.isBuiltInLinkType(l))return V.getCustomHyperLink(l)},[V,l]),[Z,ni]=R.useState(!1),[qe,et]=R.useState(!1),A=R.useRef(!1),G=E.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),ii=(G==null?void 0:G.getActiveSheet().getSheetId())||"";R.useEffect(()=>{var m,b,L,w,U,z,Lt,Ot,bt,kt,Dt,wt,Mt,Nt,Ut,Ht,jt;if((d==null?void 0:d.row)!==void 0&&d.col!==void 0){const{label:de,customRange:ae,row:rt,col:st}=d;let X;if(ae)X={id:(m=ae==null?void 0:ae.rangeId)!=null?m:"",display:de!=null?de:"",payload:(L=(b=ae==null?void 0:ae.properties)==null?void 0:b.url)!=null?L:"",row:rt,column:st};else if(d.type===y.VIEWING){const M=E.getUnit(d.unitId),te=M==null?void 0:M.getSheetBySheetId(d.subUnitId),j=te==null?void 0:te.getCellRaw(d.row,d.col),ue=(z=(U=(w=j==null?void 0:j.p)==null?void 0:w.body)==null?void 0:U.customRanges)==null?void 0:z.find(Vt=>{var At;return Vt.rangeType===s.CustomRangeType.HYPERLINK&&((At=Vt.properties)==null?void 0:At.url)}),Ie=j==null?void 0:j.v;j&&(!s.BuildTextUtils.transform.isEmptyDocument((Ot=(Lt=j.p)==null?void 0:Lt.body)==null?void 0:Ot.dataStream)||Ie)&&c(!1),X={id:"",display:"",payload:(kt=(bt=ue==null?void 0:ue.properties)==null?void 0:bt.url)!=null?kt:"",row:rt,column:st}}else{const M=E.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),te=Be.getActiveTextRange(),j=M==null?void 0:M.getBody(),ue=te&&j?s.BuildTextUtils.selection.getInsertSelection(te,j):null,Ie=ue&&((wt=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ue,(Dt=j==null?void 0:j.customRanges)!=null?Dt:[]))==null?void 0:wt[0]);c(!1),X={id:"",display:de!=null?de:"",payload:(Nt=(Mt=Ie==null?void 0:Ie.properties)==null?void 0:Mt.url)!=null?Nt:"",row:rt,column:st}}i(X.id);const xt=V.findCustomHyperLink(X);if(xt){const M=xt.convert(X);u(M.type),h(M.payload),o(M.display);return}o(X.display);const ee=H.parseHyperLink(X.payload);switch(u(ee.type===g.SheetHyperLinkType.INVALID?g.SheetHyperLinkType.RANGE:ee.type),ee.type){case g.SheetHyperLinkType.URL:{h(ee.url),ee.url===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.RANGE:{const M=ee.searchObj,te=M.gid&&(jt=(Ht=(Ut=E.getUnit(d.unitId))==null?void 0:Ut.getSheetBySheetId(M.gid))==null?void 0:Ht.getName())!=null?jt:"",j=F.serializeRangeWithSheet(te,F.deserializeRangeWithSheet(M.range).range);h(j),j===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.SHEET:{const M=ee.searchObj;h(M.gid);break}case g.SheetHyperLinkType.DEFINE_NAME:{const M=ee.searchObj;h(M.rangeid);break}default:h("");break}}},[d,N,V,Be,E]),R.useEffect(()=>{let m=null;if(d&&!d.customRangeId&&d.type===y.VIEWING&&s.Tools.isDefine(d.row)&&s.Tools.isDefine(d.col)){const b=E.getUnit(d.unitId,s.UniverInstanceType.UNIVER_SHEET),L=b==null?void 0:b.getSheetBySheetId(d.subUnitId),w=L==null?void 0:L.getMergedCell(d.row,d.col),U=new s.ColorKit(Se.getCurrentTheme().hyacinth500).toRgb();m=_e.addShape({range:w!=null?w:{startColumn:d.col,endColumn:d.col,startRow:d.row,endRow:d.row},style:{hasAutoFill:!1,fill:`rgb(${U.r}, ${U.g}, ${U.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{m&&_e.removeShape(m)}},[d,_e,Se,E]),R.useEffect(()=>{et(l===g.SheetHyperLinkType.RANGE)},[l]),R.useEffect(()=>{const m=(d==null?void 0:d.type)===y.ZEN_EDITOR?re.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):re.getRenderById(P.getCurrentEditorId()),b=new s.DisposableCollection;if(m){const L=m.with(J.DocSelectionRenderService);L.setReserveRangesStatus(!0),b.add(()=>{L.setReserveRangesStatus(!1)})}return()=>{P.disableForceKeepVisible(),b.dispose()}},[d==null?void 0:d.type,P,re]),R.useEffect(()=>(k.setIsKeepVisible(qe),()=>{k.setIsKeepVisible(!1)}),[qe,k]),R.useEffect(()=>()=>{Y.temporaryHidden&&(Y.show(),se.setContextValue(s.FOCUSING_SHEET,!1))},[se,Y]);const ri=[{label:v.t("hyperLink.form.link"),value:g.SheetHyperLinkType.URL},{label:v.t("hyperLink.form.range"),value:g.SheetHyperLinkType.RANGE},{label:v.t("hyperLink.form.worksheet"),value:g.SheetHyperLinkType.SHEET},{label:v.t("hyperLink.form.definedName"),value:g.SheetHyperLinkType.DEFINE_NAME},...q];if(!G)return;const si=G.getHiddenWorksheets(),tt=G.getSheets().map(m=>({label:m.getName(),value:m.getSheetId()})).filter(m=>si.indexOf(m.value)===-1),nt=Object.values((Tt=_.getDefinedNameMap(G.getUnitId()))!=null?Tt:{}).map(m=>({label:m.name,value:m.id})),Pt=(m,b)=>{if(m===g.SheetHyperLinkType.URL)return Zt(b);if(m===g.SheetHyperLinkType.RANGE){const L=F.deserializeRangeWithSheet(b),w=G.getSheetBySheetName(L.sheetName);if(w)return`#gid=${w.getSheetId()}&range=${F.serializeRange(L.range)}`}return`#${m}=${b}`},oi=O.useEvent(m=>{var U;const L=m.split(",").map(F.deserializeRangeWithSheet)[0];if(!L||!s.isValidRange(L.range))return;L.sheetName||(L.sheetName=((U=G.getActiveSheet())==null?void 0:U.getName())||"");const w=F.serializeRangeToRefString(L);h(w),w&&(A.current||!r)&&(o(w),A.current=!0)}),it=async()=>{if(a&&!r||!p||l===g.SheetHyperLinkType.URL&&!ye(p)){ni(!0);return}if(d)if(t){const m=d.type===y.ZEN_EDITOR||d.type===y.EDITING?g.UpdateRichHyperLinkCommand.id:g.UpdateHyperLinkCommand.id;await x.executeCommand(m,{id:t,unitId:d.unitId,subUnitId:d.subUnitId,payload:{display:a?r:"",payload:Pt(l,p)},row:d.row,column:d.col,documentId:d.type===y.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:P.getCurrentEditorId()})}else{const m=d.type===y.ZEN_EDITOR||d.type===y.EDITING?g.AddRichHyperLinkCommand.id:g.AddHyperLinkCommand.id;await x.executeCommand(m,{unitId:d.unitId,subUnitId:d.subUnitId,link:{id:s.generateRandomId(),row:d.row,column:d.col,payload:Pt(l,p),display:a?r:""},documentId:d.type===y.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:P.getCurrentEditorId()})}if((d==null?void 0:d.type)===y.VIEWING){await x.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:d.unitId,subUnitId:d.subUnitId});const m=1;await x.executeCommand(I.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-m,0),endRow:d.row+m,startColumn:Math.max(d.col-m,0),endColumn:d.col+m}})}x.executeCommand(ge.id)},ai=m=>{var L;if(l!==g.SheetHyperLinkType.RANGE)return;const b=(L=fe.current)==null?void 0:L.handleOutClick;b&&b(m,()=>et(!1))};return d?C.jsxs("div",{className:lt.cellLinkEdit,style:{display:e?"none":"block"},onClick:ai,children:[a?C.jsx(D.FormLayout,{label:v.t("hyperLink.form.label"),error:Z&&!r?v.t("hyperLink.form.inputError"):"",children:C.jsx(D.Input,{value:r,onChange:m=>{o(m),A.current=!1},placeholder:v.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:m=>{m.keyCode===O.KeyCode.ENTER&&it()}})}):null,C.jsx(D.FormLayout,{label:v.t("hyperLink.form.type"),children:C.jsx(D.Select,{options:ri,value:l,onChange:m=>{u(m),h("")}})}),l===g.SheetHyperLinkType.URL&&C.jsx(D.FormLayout,{error:Z?p?ye(p)?"":v.t("hyperLink.form.linkError"):v.t("hyperLink.form.inputError"):"",children:C.jsx(D.Input,{value:p,onChange:m=>{h(m),m&&(A.current||!r||r===p)&&(o(m),A.current=!0)},placeholder:v.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:m=>{m.keyCode===O.KeyCode.ENTER&&it()}})}),l===g.SheetHyperLinkType.RANGE&&C.jsx(D.FormLayout,{error:Z&&!p?v.t("hyperLink.form.inputError"):"",children:C.jsx(Bt.RangeSelector,{unitId:G.getUnitId(),subUnitId:ii,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:p,onChange:oi,isFocus:qe,onFocus:()=>et(!0),actions:fe.current,onRangeSelectorDialogVisibleChange:async m=>{var b,L;if(m)d.type===y.ZEN_EDITOR&&(Y.hide(),se.setContextValue(s.FOCUSING_SHEET,!0)),d.type!==y.VIEWING&&P.enableForceKeepVisible(),n(!0);else{if(await N.navigateToRange(d.unitId,d.subUnitId,{startRow:d.row,endRow:d.row,startColumn:d.col,endColumn:d.col}),d.type===y.ZEN_EDITOR){await x.executeCommand(f.SetSelectionsOperation.id,{unitId:d.unitId,subUnitId:d.subUnitId,selections:[{range:{startRow:d.row,endRow:d.row,startColumn:d.col,endColumn:d.col}}]}),Y.show(),se.setContextValue(s.FOCUSING_SHEET,!1);const w=(b=re.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(J.DocBackScrollRenderController),U=(L=me.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:L[0];w&&U&&(w.scrollToRange(U),me.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}P.disableForceKeepVisible(),n(!1)}}})}),l===g.SheetHyperLinkType.SHEET&&C.jsx(D.FormLayout,{error:Z&&!p?v.t("hyperLink.form.selectError"):"",children:C.jsx(D.Select,{options:tt,value:p,onChange:m=>{var w,U;h(m);const b=(w=tt.find(z=>z.value===m))==null?void 0:w.label,L=(U=tt.find(z=>z.value===p))==null?void 0:U.label;b&&(A.current||!r||r===L)&&(o(b),A.current=!0)}})}),l===g.SheetHyperLinkType.DEFINE_NAME&&C.jsx(D.FormLayout,{error:Z&&!p?v.t("hyperLink.form.selectError"):"",children:C.jsx(D.Select,{options:nt,value:p,onChange:m=>{var w,U;h(m);const b=(w=nt.find(z=>z.value===m))==null?void 0:w.label,L=(U=nt.find(z=>z.value===p))==null?void 0:U.label;b&&(A.current||!r||r===L)&&(o(b),A.current=!0)}})}),(oe==null?void 0:oe.Form)&&C.jsx(oe.Form,{linkId:t,payload:p,display:r,showError:Z,setByPayload:A,setDisplay:m=>{o(m),A.current=!0},setPayload:h}),C.jsxs("div",{className:lt.cellLinkEditButtons,children:[C.jsx(D.Button,{onClick:()=>{d&&N.navigateToRange(d.unitId,d.subUnitId,{startRow:d.row,endRow:d.row,startColumn:d.col,endColumn:d.col}),x.executeCommand(ge.id)},children:v.t("hyperLink.form.cancel")}),C.jsx(D.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{it()},children:v.t("hyperLink.form.ok")})]})]}):null};Re.componentKey="univer.sheet.cell-link-edit";var B=function(){return B=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},B.apply(this,arguments)},on=function(t,i){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(e[n[r]]=t[n[r]]);return e},ne=R.forwardRef(function(t,i){var e=t.icon,n=t.id,r=t.className,o=t.extend,a=on(t,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=R.useRef("_".concat(ln()));return dt(e,"".concat(n),{defIds:e.defIds,idSuffix:l.current},B({ref:i,className:c},a),o)});function dt(t,i,e,n,r){return R.createElement(t.tag,B(B({key:i},an(t,e,r)),n),(cn(t,e).children||[]).map(function(o,a){return dt(o,"".concat(i,"-").concat(t.tag,"-").concat(a),e,void 0,r)}))}function an(t,i,e){var n=B({},t.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=i.defIds;return!r||r.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(n[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function cn(t,i){var e,n=i.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?B(B({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?B(B({},r),{attrs:B(B({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):t}function ln(){return Math.random().toString(36).substring(2,8)}ne.displayName="UniverIcon";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Pe=R.forwardRef(function(t,i){return R.createElement(ne,Object.assign({},t,{id:"all-border-single",ref:i,icon:dn}))});Pe.displayName="AllBorderSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ut=R.forwardRef(function(t,i){return R.createElement(ne,Object.assign({},t,{id:"copy-single",ref:i,icon:un}))});ut.displayName="CopySingle";var pn={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"}}]},Ze=R.forwardRef(function(t,i){return R.createElement(ne,Object.assign({},t,{id:"link-single",ref:i,icon:pn}))});Ze.displayName="LinkSingle";var hn={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"}}]},pt=R.forwardRef(function(t,i){return R.createElement(ne,Object.assign({},t,{id:"unlink-single",ref:i,icon:hn}))});pt.displayName="UnlinkSingle";var gn={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"}}]},ht=R.forwardRef(function(t,i){return R.createElement(ne,Object.assign({},t,{id:"write-single",ref:i,icon:gn}))});ht.displayName="WriteSingle";var vn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},gt=R.forwardRef(function(t,i){return R.createElement(ne,Object.assign({},t,{id:"xlsx",ref:i,icon:vn}))});gt.displayName="Xlsx";function vt(t){var i,e,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(i=0;i<r;i++)t[i]&&(e=vt(t[i]))&&(n&&(n+=" "),n+=e)}else for(e in t)t[e]&&(n&&(n+=" "),n+=e);return n}function _t(){for(var t,i,e=0,n="",r=arguments.length;e<r;e++)(t=arguments[e])&&(i=vt(t))&&(n&&(n+=" "),n+=i);return n}const K={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"},_n={[g.SheetHyperLinkType.URL]:C.jsx(Ze,{}),[g.SheetHyperLinkType.SHEET]:C.jsx(gt,{}),[g.SheetHyperLinkType.RANGE]:C.jsx(Pe,{}),[g.SheetHyperLinkType.DEFINE_NAME]:C.jsx(Pe,{}),[g.SheetHyperLinkType.INVALID]:C.jsx(Pe,{})},Te=()=>{var d,H;const t=s.useDependency(S.SheetsHyperLinkPopupService),i=s.useDependency(s.ICommandService),e=s.useDependency(O.IMessageService),n=s.useDependency(s.LocaleService),[r,o]=R.useState(null),a=s.useDependency(S.SheetsHyperLinkResolverService),c=s.useDependency(I.IEditorBridgeService),l=s.useDependency(g.SheetsHyperLinkParserService),u=s.useDependency(O.IZenZoneService);if(s.useObservable(u.visible$),R.useEffect(()=>{o(t.currentPopup);const N=t.currentPopup$.subscribe(x=>{o(x)});return()=>{N.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!r)return null;const{unitId:p,subUnitId:h,customRange:v,row:_,col:P}=r;if(!((d=v==null?void 0:v.properties)!=null&&d.url))return null;const E=l.parseHyperLink((H=v.properties.url)!=null?H:""),k=E.type===g.SheetHyperLinkType.INVALID;return C.jsxs("div",{className:K.cellLink,onClick:()=>t.hideCurrentPopup(),children:[C.jsxs("div",{className:_t(K.cellLinkContent,{[K.cellLinkContentError]:k}),onClick:()=>{u.visible||a.navigate(E)},children:[C.jsx("div",{className:K.cellLinkType,children:_n[E.type]}),C.jsx(D.Tooltip,{showIfEllipsis:!0,title:E.name,children:C.jsx("span",{className:K.cellLinkUrl,children:E.name})})]}),C.jsxs("div",{className:K.cellLinkOperations,children:[r.copyPermission&&C.jsx("div",{className:_t(K.cellLinkOperation,{[K.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(E.type!==g.SheetHyperLinkType.URL){const N=new URL(window.location.href);N.hash=E.url.slice(1),navigator.clipboard.writeText(N.href)}else navigator.clipboard.writeText(E.url);e.show({content:n.t("hyperLink.message.coped"),type:D.MessageType.Info})}},children:C.jsx(D.Tooltip,{placement:"bottom",title:n.t("hyperLink.popup.copy"),children:C.jsx(ut,{})})}),r.editPermission&&C.jsxs(C.Fragment,{children:[C.jsx("div",{className:K.cellLinkOperation,onClick:()=>{i.executeCommand(Le.id,{unitId:p,subUnitId:h,row:_,col:P,customRangeId:v.rangeId,type:r.type})},children:C.jsx(D.Tooltip,{placement:"bottom",title:n.t("hyperLink.popup.edit"),children:C.jsx(ht,{})})}),C.jsx("div",{className:K.cellLinkOperation,onClick:()=>{const N=r.type===y.EDITING||r.type===y.ZEN_EDITOR?g.CancelRichHyperLinkCommand.id:g.CancelHyperLinkCommand.id;i.syncExecuteCommand(N,{unitId:p,subUnitId:h,id:v.rangeId,row:_,column:P,documentId:r.type===y.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:c.getCurrentEditorId()})&&t.hideCurrentPopup(void 0,!0)},children:C.jsx(D.Tooltip,{placement:"bottom",title:n.t("hyperLink.popup.cancel"),children:C.jsx(pt,{})})})]})]})]})};Te.componentKey="univer.sheet.cell-link-popup";var Sn=Object.defineProperty,mn=Object.getOwnPropertyDescriptor,fn=(t,i,e,n)=>{for(var r=n>1?void 0:n?mn(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&Sn(i,e,r),r},Q=(t,i)=>(e,n)=>i(e,n,t);const St=(t,i)=>{var e,n;return t.unitId===i.unitId&&t.subUnitId===i.subUnitId&&t.row===i.row&&t.col===i.col&&((e=t.customRange)==null?void 0:e.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&t.type===i.type};S.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,n,r,o,a,c,l,u,p){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new T.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new T.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=o,this._textSelectionManagerService=a,this._docCanvasPopManagerService=c,this._editorService=l,this._rangeSelectorService=u,this._zenZoneService=p,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&St(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==y.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&St(e,n))return;const{unitId:r,subUnitId:o,row:a,col:c,customRangeRect:l,customRange:u}=e;if(!u)return;let p;const h={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};e.type===y.EDITING?p=l&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(l,h):e.type===y.ZEN_EDITOR?p=this._docCanvasPopManagerService.attachPopupToRange({startOffset:u.startIndex,endOffset:u.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):p=l&&this._sheetCanvasPopManagerService.attachPopupByPosition(l,h),p&&(this._currentPopup={unitId:r,subUnitId:o,disposable:p,row:a,col:c,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:u,type:e.type},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,n){var r,o;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((o=(r=this._currentPopup)==null?void 0:r.disposable)==null||o.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,o,a;const e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){const c=this._textSelectionManagerService.getActiveTextRange(),l=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!l)return null;if(!c||c.collapsed)return{startOffset:0,endOffset:l.dataStream.length-2,collapsed:l.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(l.dataStream)};const u=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(c,(a=(o=l.customRanges)==null?void 0:o.filter(v=>v.rangeType===s.CustomRangeType.HYPERLINK))!=null?a:[]);let p=c.startOffset,h=c.endOffset;return u.forEach(v=>{p=Math.min(p,v.startIndex),h=Math.max(h,v.endIndex+1)}),{startOffset:p,endOffset:h,collapsed:p===h,label:s.BuildTextUtils.transform.getPlainText(l.dataStream.slice(p,h))}}return null}get _editPopup(){return{componentKey:Re.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var a,c,l,u,p;const{unitId:n,subUnitId:r,type:o}=e;if(o===y.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const v=this._textSelectionManagerService.getActiveTextRange();if(!v)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(v,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const _=(a=h.getBody())==null?void 0:a.dataStream.slice(v.startOffset,v.endOffset-1);this._currentEditing$.next({...e,label:_})}else if(o===y.EDITING){const h=this._getEditingRange();h&&this._textSelectionManagerService.replaceTextRanges([{...h}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r),this._currentEditing$.next({...e,label:(c=h==null?void 0:h.label)!=null?c:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),v=h==null?void 0:h.getSheetBySheetId(r),_=v==null?void 0:v.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:_!=null&&_.p?s.BuildTextUtils.transform.getPlainText((u=(l=_.p.body)==null?void 0:l.dataStream)!=null?u:""):((p=_==null?void 0:_.v)!=null?p:"").toString()})}}startEditing(e){var c,l,u,p,h,v;(c=this._currentEditingPopup)==null||c.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=e;let o,a;if(e.type===y.ZEN_EDITOR){const _=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(o=(u=(l=_==null?void 0:_.getBody())==null?void 0:l.customRanges)==null?void 0:u.find(P=>P.rangeId===e.customRangeId),a=o?(p=_==null?void 0:_.getBody())==null?void 0:p.dataStream.slice(o.startIndex+1,o.endIndex):"",!o||!a)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:o.startIndex,endOffset:o.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===y.EDITING){const _=I.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!_||!((h=_.rects)!=null&&h.length))return;o=_.customRange,a=_.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(_.rects.pop(),this._editPopup,n,r)}else{const _=I.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!_||!((v=_.rects)!=null&&v.length))return;o=_.customRange,a=_.label,this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(_.rects.pop(),this._editPopup,n,r)}this._currentEditing$.next({...e,customRange:o,label:a})}endEditing(e){var r;const n=this._currentEditing$.getValue();n&&(!e||e===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},S.SheetsHyperLinkPopupService=fn([Q(0,s.Inject(I.SheetCanvasPopManagerService)),Q(1,s.Inject(s.Injector)),Q(2,s.IUniverInstanceService),Q(3,I.IEditorBridgeService),Q(4,s.Inject(he.DocSelectionManagerService)),Q(5,s.Inject(J.DocCanvasPopManagerService)),Q(6,J.IEditorService),Q(7,J.IRangeSelectorService),Q(8,O.IZenZoneService)],S.SheetsHyperLinkPopupService);const Ke=(t,i,e)=>{const n=t.getCell(i,e);if(n!=null&&n.f||n!=null&&n.si)return!0;const r=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(n!=null&&n.dataValidation&&r.includes(n.dataValidation.rule.type))},In=t=>{const i=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const e=i.getActiveSheet(),n=t.get(f.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,o=n[0].range.startColumn;return Ke(e,r,o)},yn=t=>{var u,p;const i=t.get(he.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),n=i.getDocRanges();if(!n.length||n.length>1)return!0;const r=n[0],o=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!o||!r||r.collapsed)return!0;const a=o.getSelfOrHeaderFooterModel(r.segmentId).getBody();if(!a)return!0;const c=(u=a==null?void 0:a.paragraphs)!=null?u:[];for(let h=0,v=c.length;h<v;h++){const _=c[h];if(r.startOffset<=_.startIndex&&r.endOffset>_.startIndex)return!0;if(_.startIndex>r.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(r,(p=a.customRanges)!=null?p:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},Le={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,i){if(!i)return!1;const e=t.get(S.SheetsHyperLinkPopupService);return i.customRangeId?e.startEditing(i):e.startAddEditing(i),!0}},ge={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(S.SheetsHyperLinkPopupService).endEditing(),!0}},Oe={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const i=t.get(s.IUniverInstanceService),e=f.getSheetCommandTarget(i),n=t.get(I.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),a=t.get(f.SheetsSelectionsService).getCurrentLastSelection();if(!a)return!1;const c=a.range.startRow,l=a.range.startColumn,u=n.isVisible(),p=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Le.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:c,col:l,type:p?y.ZEN_EDITOR:u.visible?y.EDITING:y.VIEWING})}},ie={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(In(t))return!1;const i=t.get(s.ICommandService);return t.get(S.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(ge.id):i.executeCommand(Oe.id)}},$e=(t,i=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),n=(r=t.get(pe.IRenderManagerService).getRenderById(i))==null?void 0:r.with(J.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(T.map(()=>{const a=t.get(I.IEditorBridgeService).getEditCellState();if(!a)return!0;const c=f.getSheetCommandTarget(e,{unitId:a.unitId,subUnitId:a.sheetId});return!(c!=null&&c.worksheet)||Ke(c.worksheet,a.row,a.column)?!0:yn(t)})):T.of(!0)},mt=t=>{const i=I.getCurrentRangeDisable$(t,{workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),n=t.get(f.SheetsSelectionsService),r=t.has(I.IEditorBridgeService)?t.get(I.IEditorBridgeService):null,o=e.focused$.pipe(T.filter(a=>!!a),T.map(a=>e.getUnit(a,s.UniverInstanceType.UNIVER_SHEET)),T.filter(a=>!!a),T.switchMap(a=>a.activeSheet$),T.switchMap(a=>n.selectionMoveEnd$.pipe(T.map(c=>a&&{selections:c,sheet:a}))),T.map(a=>{if(!a)return!0;const{selections:c,sheet:l}=a;if(!c.length)return!0;const u=c[0].range.startRow,p=c[0].range.startColumn;if(Ke(l,u,p))return!0}),T.switchMap(a=>a?T.of(!0):(r?r.visible$:T.of(null)).pipe(T.map(l=>l!=null&&l.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)).pipe(T.switchMap(l=>l?$e(t,l):T.of(!1)))));return i.pipe(T.distinctUntilChanged(),T.switchMap(a=>o.pipe(T.map(c=>a||c))))},be={commandId:Oe.id,type:O.MenuItemType.BUTTON,positions:[O.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",icon:"LinkSingle"},ke=t=>`${t}-zen-editor`,Cn=t=>({...be,id:be.commandId,hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:mt(t)}),En=t=>({...be,id:ke(be.commandId),hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:$e(t)}),De={tooltip:"hyperLink.form.addTitle",positions:O.MenuPosition.TOOLBAR_START,group:O.MenuGroup.TOOLBAR_OTHERS,commandId:ie.id,type:O.MenuItemType.BUTTON,icon:"LinkSingle"},Rn=t=>({...De,id:De.commandId,hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:mt(t)}),Pn=t=>({...De,id:ke(De.commandId),hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:$e(t)}),Ye={id:ie.id,binding:O.KeyCode.K|O.MetaKeys.CTRL_COMMAND,preconditions:I.whenSheetEditorFocused};var Tn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,On=(t,i,e,n)=>{for(var r=n>1?void 0:n?Ln(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&Tn(i,e,r),r},ft=(t,i)=>(e,n)=>i(e,n,t);let we=class extends s.Disposable{constructor(t,i){super(),this._autoFillService=t,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:o,target:a,unitId:c,subUnitId:l}=n,u=I.virtualizeDiscreteRanges([o,a]),[p,h]=u.ranges,{mapFunc:v}=u,_={row:p.startRow,col:p.startColumn},P=I.getAutoFillRepeatRange(p,h),E=[],k=[];return P.forEach(d=>{const H=d.repeatStartCell,N=d.relativeRange,x={startRow:_.row,startColumn:_.col,endColumn:_.col,endRow:_.row},V={startRow:H.row,startColumn:H.col,endColumn:H.col,endRow:H.row};s.Range.foreach(N,(q,Y)=>{const re=s.Rectangle.getPositionRange({startRow:q,startColumn:Y,endColumn:Y,endRow:q},x),{row:_e,col:Be}=v(re.startRow,re.startColumn),se=this._hyperLinkModel.getHyperLinkByLocation(c,l,_e,Be),Se=s.Rectangle.getPositionRange({startRow:q,startColumn:Y,endColumn:Y,endRow:q},V),{row:me,col:fe}=v(Se.startRow,Se.startColumn),oe=s.Tools.generateRandomId(),Z=this._hyperLinkModel.getHyperLinkByLocation(c,l,me,fe);Z&&E.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:c,subUnitId:l,id:Z.id}}),(I.APPLY_TYPE.COPY===r||I.APPLY_TYPE.SERIES===r)&&se&&(E.push({id:g.AddHyperLinkMutation.id,params:{unitId:c,subUnitId:l,link:{...se,id:oe,row:me,column:fe}}}),k.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:c,subUnitId:l,id:oe}})),Z&&k.push({id:g.AddHyperLinkMutation.id,params:{unitId:c,subUnitId:l,link:Z}})})}),{undos:k,redos:E}},e={id:We,onFillData:(n,r,o)=>o===I.APPLY_TYPE.COPY||o===I.APPLY_TYPE.ONLY_FORMAT||o===I.APPLY_TYPE.SERIES?i(n,o):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};we=On([ft(0,I.IAutoFillService),ft(1,s.Inject(g.HyperLinkModel))],we);var bn=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Dn=(t,i,e,n)=>{for(var r=n>1?void 0:n?kn(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&bn(i,e,r),r},Ge=(t,i)=>(e,n)=>i(e,n,t);let Me=class extends s.Disposable{constructor(t,i,e){super(),this._localeService=t,this._commandService=i,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===Ye.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],rangeTypes:[f.RangeProtectionPermissionEditPoint],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=Dn([Ge(0,s.Inject(s.LocaleService)),Ge(1,s.ICommandService),Ge(2,s.Inject(I.SheetPermissionInterceptorBaseController))],Me);var wn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,Nn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Mn(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&wn(i,e,r),r},$=(t,i)=>(e,n)=>i(e,n,t);let Ne=class extends s.Disposable{constructor(t,i,e,n,r,o,a,c,l,u){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=i,this._renderManagerService=e,this._permissionService=n,this._sheetPermissionInterceptorBaseController=r,this._commandService=o,this._editorBridgeService=a,this._textSelectionManagerService=c,this._univerInstanceService=l,this._zenZoneService=u,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:i,subUnitId:e,row:n,col:r}=t,o=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!(o==null?void 0:o.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const c=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[f.WorkbookViewPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),u=this._permissionService.composePermission([new f.WorkbookCopyPermission(i).id,new f.WorksheetCopyPermission(i,e).id]).every(p=>p.value);return{viewPermission:c,editPermission:l,copyPermission:u}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(T.debounceTime(200)).subscribe(t=>{var E;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:e,row:n,col:r}=t,o=this._renderManagerService.getRenderById(i);if(!o)return;if(!o.with(I.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(y.VIEWING);return}const c=(E=o==null?void 0:o.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:E.skeleton,l=r,u=n;let p=u,h=l;c&&c.overflowCache.forValue((k,d,H)=>{s.Rectangle.contains(H,{startColumn:l,endColumn:l,startRow:u,endRow:u})&&(p=k,h=d)});const{viewPermission:v,editPermission:_,copyPermission:P}=this._getLinkPermission(t);if(!v||!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:p,col:h,editPermission:_,copyPermission:P,customRange:t.customRange,customRangeRect:t.rect,type:y.VIEWING,unitId:i,subUnitId:e})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(T.switchMap(i=>this._editorBridgeService.visible$.pipe(T.map(e=>({visible:e,state:i}))))).subscribe(({visible:i,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(y.EDITING),this._sheetsHyperLinkPopupService.endEditing(y.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:o,row:a,column:c}=e,l=this._renderManagerService.getRenderById(n);if(!l)return;const{editPermission:u,viewPermission:p,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:o,row:a,col:c}),v=l.with(J.DocEventManagerService);p&&(t==null||t.unsubscribe(),t=v.hoverCustomRanges$.pipe(T.debounceTime(200)).subscribe(_=>{var H,N;const P=_.find(x=>x.range.rangeType===s.CustomRangeType.HYPERLINK);if(!P){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const E=P.rects[P.rects.length-1];if(!((N=(H=this._renderManagerService.getRenderById(r))==null?void 0:H.with(I.SheetSkeletonManagerService).getWorksheetSkeleton(o))==null?void 0:N.skeleton)||!E)return;const d=l.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:o,row:a,col:c,customRange:P.range,customRangeRect:{left:E.left+d.left,top:E.top+d.top,bottom:E.bottom+d.top,right:E.right+d.left},editPermission:u,copyPermission:h,type:y.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(y.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(y.EDITING),this._sheetsHyperLinkPopupService.endEditing(y.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(y.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(y.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(y.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(T.switchMap(t=>{const i=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return i?i.with(J.DocEventManagerService).hoverCustomRanges$.pipe(T.debounceTime(200)):new T.Observable(e=>{e.next(null)})})).subscribe(t=>{const i=t==null?void 0:t.find(n=>n.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(i&&e){const{unitId:n,sheetId:r,row:o,column:a}=e,{editPermission:c,viewPermission:l,copyPermission:u}=this._getLinkPermission({unitId:n,subUnitId:r,row:o,col:a});l&&this._sheetsHyperLinkPopupService.showPopup({type:y.ZEN_EDITOR,unitId:n,subUnitId:r,row:o,col:a,customRange:i.range,editPermission:c,copyPermission:u})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(y.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(y.EDITING)}))}_initCommandListener(){const t=[f.ClearSelectionContentCommand.id,f.ClearSelectionAllCommand.id,f.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{t.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ne=Nn([$(0,s.Inject(I.HoverManagerService)),$(1,s.Inject(S.SheetsHyperLinkPopupService)),$(2,s.Inject(pe.IRenderManagerService)),$(3,s.Inject(s.IPermissionService)),$(4,s.Inject(I.SheetPermissionInterceptorBaseController)),$(5,s.ICommandService),$(6,I.IEditorBridgeService),$(7,s.Inject(he.DocSelectionManagerService)),$(8,s.IUniverInstanceService),$(9,O.IZenZoneService)],Ne);var Un=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,jn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Hn(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&Un(i,e,r),r},ze=(t,i)=>(e,n)=>i(e,n,t);let Ue=class extends s.Disposable{constructor(t,i,e){super(),this._sheetInterceptorService=t,this._univerInstanceService=i,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{var i;if(t.id===f.RemoveSheetCommand.id){const e=t.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const r=n.getUnitId(),o=e.subUnitId||((i=n.getActiveSheet())==null?void 0:i.getSheetId());if(!o)return{redos:[],undos:[]};const a=this._hyperLinkModel.getSubUnit(r,o),c=a.map(u=>({id:g.RemoveHyperLinkMutation.id,params:{unitId:r,subUnitId:o,id:u.id}})),l=a.map(u=>({id:g.AddHyperLinkMutation.id,params:{unitId:r,subUnitId:o,link:u}}));return{redos:c,undos:l}}return{redos:[],undos:[]}}}))}};Ue=jn([ze(0,s.Inject(f.SheetInterceptorService)),ze(1,s.IUniverInstanceService),ze(2,s.Inject(g.HyperLinkModel))],Ue);var xn=Object.defineProperty,Vn=Object.getOwnPropertyDescriptor,It=(t,i,e,n)=>{for(var r=n>1?void 0:n?Vn(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&xn(i,e,r),r},Xe=(t,i)=>(e,n)=>i(e,n,t);let Je=class extends s.Disposable{constructor(t,i){super(),this._context=t,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(T.debounceTime(16)).subscribe(()=>{t()}))}};Je=It([Xe(1,s.Inject(g.HyperLinkModel))],Je);let He=class extends s.Disposable{constructor(t,i){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,i,e)=>{const{row:n,col:r,unitId:o,subUnitId:a}=i,c=this._hyperLinkModel.getHyperLinkByLocation(o,a,n,r);return e(c?{...t,linkUrl:c.payload,linkId:c.id}:t)}}))}};He=It([Xe(0,s.Inject(f.SheetInterceptorService)),Xe(1,s.Inject(g.HyperLinkModel))],He);var An=Object.defineProperty,Bn=Object.getOwnPropertyDescriptor,Wn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Bn(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&An(i,e,r),r},Qe=(t,i)=>(e,n)=>i(e,n,t);let je=class extends s.Disposable{constructor(i,e,n){super();W(this,"_refRangeMap",new Map);this._commandService=i,this._univerInstanceService=e,this._refRangeService=n,this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(i,e){let n=this._refRangeMap.get(i);n||(n=new Map,this._refRangeMap.set(i,n));let r=n.get(e);return r||(r=new s.ObjectMatrix,n.set(e,r)),r}_isLegalRangeUrl(i,e){var r,o,a;const n=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!n)return null;if(e&&e.startsWith("#")){const c=new URLSearchParams(e.slice(1)),l={gid:(r=c.get("gid"))!=null?r:"",range:(o=c.get("range"))!=null?o:"",rangeid:(a=c.get("rangeid"))!=null?a:""};if(l.range&&l.gid){const u=l.gid,p=n.getSheetBySheetId(u);if(!p)return null;const h=F.deserializeRangeWithSheet(l.range).range;if(s.isValidRange(h,p)&&l.range!==g.ERROR_RANGE)return h}}return null}_registerRange(i,e,n,r,o){var c,l,u,p;const a=this._enusreMap(i,e);if((l=(c=o.body)==null?void 0:c.customRanges)!=null&&l.some(h=>{var v;return h.rangeType===s.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(i,(v=h.properties)==null?void 0:v.url)})){const h=new s.DisposableCollection;(p=(u=o.body)==null?void 0:u.customRanges)==null||p.forEach(v=>{var _;if(v.rangeType===s.CustomRangeType.HYPERLINK){const P=(_=v.properties)==null?void 0:_.url,E=this._isLegalRangeUrl(i,P);E&&h.add(this._refRangeService.watchRange(i,e,E,(k,d)=>{v.properties.url=`#gid=${e}&range=${d?F.serializeRange(d):g.ERROR_RANGE}`}))}}),a.setValue(n,r,h)}}_initWorkbookLoad(){const i=e=>{const n=e.getUnitId();e.getSheets().forEach(r=>{const o=r.getSheetId(),a=this._enusreMap(n,o);r.getCellMatrix().forValue((c,l,u)=>{const p=a.getValue(c,l);p&&p.dispose(),u&&u.p&&this._registerRange(n,o,c,l,u.p)})})};this._univerInstanceService.getAllUnitsForType(s.UniverInstanceType.UNIVER_SHEET).forEach(e=>{i(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===s.UniverInstanceType.UNIVER_SHEET&&i(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(i=>{if(i.type===s.UniverInstanceType.UNIVER_SHEET){const e=i,n=e.getUnitId();e.getSheets().forEach(r=>{const o=r.getSheetId();this._enusreMap(n,o).forValue((c,l,u)=>{u&&u.dispose()})}),this._refRangeMap.delete(n)}})}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===f.SetRangeValuesMutation.id){const e=i.params,{unitId:n,subUnitId:r,cellValue:o}=e,a=this._enusreMap(n,r);o&&new s.ObjectMatrix(o).forValue((c,l,u)=>{const p=a.getValue(c,l);p&&p.dispose(),u&&u.p&&this._registerRange(n,r,c,l,u.p)})}}))}};je=Wn([Qe(0,s.ICommandService),Qe(1,s.IUniverInstanceService),Qe(2,s.Inject(f.RefRangeService))],je);var Fn=Object.defineProperty,Zn=Object.getOwnPropertyDescriptor,Kn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Zn(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&Fn(i,e,r),r},le=(t,i)=>(e,n)=>i(e,n,t);let xe=class extends s.Disposable{constructor(t,i,e,n,r,o){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._selectionManagerService=e,this._univerInstanceService=n,this._editorBridgeService=r,this._renderManagerService=o,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{if(t.id===f.SetRangeValuesCommand.id){const i=t.params,{unitId:e,subUnitId:n}=i,r=[],o=[];return i.cellValue&&new s.ObjectMatrix(i.cellValue).forValue((a,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,c);l&&(r.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:e,subUnitId:n,id:l.id}}),o.push({id:g.AddHyperLinkMutation.id,params:{unitId:e,subUnitId:n,link:l}}))}),{undos:o,redos:r}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{if(t.id===f.ClearSelectionContentCommand.id||t.id===f.ClearSelectionAllCommand.id||t.id===f.ClearSelectionFormatCommand.id){const i=[],e=[],n=this._selectionManagerService.getCurrentLastSelection(),r=f.getSheetCommandTarget(this._univerInstanceService);if(n&&r){const{unitId:o,subUnitId:a}=r;s.Range.foreach(n.range,(c,l)=>{const u=this._hyperLinkModel.getHyperLinkByLocation(o,a,c,l);u&&(i.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:a,id:u.id}}),e.push({id:g.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:a,link:u}}))})}return{redos:i,undos:e}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(f.AFTER_CELL_EDIT,{handler:(t,i,e)=>{if(!t||t.p)return e(t);if(typeof t.v=="string"&&s.Tools.isLegalUrl(t.v)&&t.v[t.v.length-1]!==" "){const{unitId:n,subUnitId:r}=i,o=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),a=o==null?void 0:o.getSheetBySheetId(r);if(!a)return e(t);const c=a.getBlankCellDocumentModel(t);if(!c.documentModel)return e(t);const l=s.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:t.v.length,collapsed:!1},body:{dataStream:`${s.DataStreamTreeTokenType.CUSTOM_RANGE_START}${t.v}${s.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{startIndex:0,endIndex:t.v.length+1,rangeId:s.generateRandomId(),rangeType:s.CustomRangeType.HYPERLINK,properties:{url:t.v}}]},doc:c.documentModel});if(!l)return e(t);const u=c.documentModel.getBody();return s.TextX.apply(u,l.serialize()),e({...t,p:{id:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:u,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(t)}}))}};xe=Kn([le(0,s.Inject(f.SheetInterceptorService)),le(1,s.Inject(g.HyperLinkModel)),le(2,s.Inject(f.SheetsSelectionsService)),le(3,s.IUniverInstanceService),le(4,I.IEditorBridgeService),le(5,pe.IRenderManagerService)],xe);const $n={[O.RibbonStartGroup.OTHERS]:{[ie.id]:{order:2,menuItemFactory:Rn},[ke(ie.id)]:{order:2,menuItemFactory:Pn}},[O.ContextMenuPosition.MAIN_AREA]:{[O.ContextMenuGroup.OTHERS]:{order:1,[ie.id]:{order:0,menuItemFactory:Cn},[ke(ie.id)]:{order:0,menuItemFactory:En}}}};var Yn=Object.defineProperty,Gn=Object.getOwnPropertyDescriptor,zn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Gn(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&Yn(i,e,r),r},ve=(t,i)=>(e,n)=>i(e,n,t);let Ve=class extends s.Disposable{constructor(t,i,e,n,r){super(),this._componentManager=t,this._commandService=i,this._menuManagerService=e,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Re,Re.componentKey],[Ze,"LinkSingle"]].forEach(([t,i])=>{this._componentManager.register(i,t)})}_initCommands(){[Le,ge,Oe,ie].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu($n)}_initShortCut(){this._shortcutService.registerShortcut(Ye)}};Ve=zn([ve(0,s.Inject(O.ComponentManager)),ve(1,s.ICommandService),ve(2,O.IMenuManagerService),ve(3,s.Inject(s.Injector)),ve(4,s.Inject(O.IShortcutService))],Ve);var Xn=Object.defineProperty,Jn=Object.getOwnPropertyDescriptor,Qn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Jn(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&Xn(i,e,r),r},yt=(t,i)=>(e,n)=>i(e,n,t);let Ae=class extends s.Disposable{constructor(t,i){super(),this._parserService=t,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const i=this._parserService.parseHyperLink(t);this._resolverService.navigate(i)}}};Ae=Qn([yt(0,s.Inject(g.SheetsHyperLinkParserService)),yt(1,s.Inject(S.SheetsHyperLinkResolverService))],Ae);var Ct=Object.defineProperty,qn=Object.getOwnPropertyDescriptor,ei=(t,i,e)=>i in t?Ct(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,ti=(t,i,e,n)=>{for(var r=n>1?void 0:n?qn(i,e):i,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(i,e,r):a(r))||r);return n&&r&&Ct(i,e,r),r},Et=(t,i)=>(e,n)=>i(e,n,t),Rt=(t,i,e)=>ei(t,typeof i!="symbol"?i+"":i,e);S.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(i=Kt,e,n){super(),this._config=i,this._injector=e,this._configService=n;const{menu:r,...o}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(ot,o)}onStarting(){[[S.SheetsHyperLinkResolverService],[S.SheetsHyperLinkPopupService],[Fe],[Ue],[He],[xe],[Ne],[Ve],[we],[S.SheetsHyperLinkCopyPasteController],[Me],[Ae],[je]].forEach(e=>this._injector.add(e)),this._injector.get(He),this._injector.get(je),this._injector.get(xe)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[Je]),this._injector.get(we),this._injector.get(S.SheetsHyperLinkCopyPasteController),this._injector.get(Ue),this._injector.get(Ve)}onRendered(){this._injector.get(Me),this._injector.get(Ae),this._injector.get(Ne)}},Rt(S.UniverSheetsHyperLinkUIPlugin,"pluginName",We),Rt(S.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),S.UniverSheetsHyperLinkUIPlugin=ti([s.DependentOn(g.UniverSheetsHyperLinkPlugin,J.UniverDocsUIPlugin),Et(1,s.Inject(s.Injector)),Et(2,s.IConfigService)],S.UniverSheetsHyperLinkUIPlugin),S.CloseHyperLinkPopupOperation=ge,S.InsertHyperLinkOperation=Oe,S.InsertLinkShortcut=Ye,S.OpenHyperLinkEditPanelOperation=Le,S.SheetsHyperLinkSidePanelService=Fe,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsHyperLinkUiEnUS=n())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"Edit Link",addTitle:"Insert Link",label:"Label",type:"Type",link:"Link",linkPlaceholder:"Enter link",range:"Range",worksheet:"Worksheet",definedName:"Defined Name",ok:"Confirm",cancel:"Cancel",labelPlaceholder:"Enter label",inputError:"Please enter",selectError:"Please select",linkError:"Please enter a legal link"},menu:{add:"Insert Link"},message:{noSheet:"Target sheet has been delete",refError:"Invalid Range",hiddenSheet:"Cannot open the link because the linked sheet is hidden",coped:"Link copied to clipboard"},popup:{copy:"Copy Link",edit:"Edit Link",cancel:"Cancel Link"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsHyperLinkUiFaIR=n())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"ویرایش لینک",addTitle:"درج لینک",label:"برچسب",type:"نوع",link:"لینک",linkPlaceholder:"لینک را وارد کنید",range:"محدوده",worksheet:"برگ کار",definedName:"نام تعریف شده",ok:"تایید",cancel:"انصراف",labelPlaceholder:"برچسب را وارد کنید",inputError:"لطفا وارد کنید",selectError:"لطفا انتخاب کنید",linkError:"لطفا یک لینک معتبر وارد کنید"},menu:{add:"درج لینک"},message:{noSheet:"برگ هدف حذف شده است",refError:"محدوده نامعتبر",hiddenSheet:"نمیتوان لینک را باز کرد زیرا برگ مرتبط پنهان است",coped:"لینک به کلیپ بورد کپی شد"},popup:{copy:"کپی لینک",edit:"ویرایش لینک",cancel:"لینک را لغو کنید"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsHyperLinkUiRuRU=n())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"Редактировать ссылку",addTitle:"Вставить ссылку",label:"Метка",type:"Тип",link:"Ссылка",linkPlaceholder:"Введите ссылку",range:"Диапазон",worksheet:"Лист",definedName:"Определенное имя",ok:"ОК",cancel:"Отмена",labelPlaceholder:"Введите метку",inputError:"Пожалуйста, введите",selectError:"Пожалуйста, выберите",linkError:"Пожалуйста, введите корректную ссылку"},menu:{add:"Вставить ссылку"},message:{noSheet:"Целевой лист был удален",refError:"Недопустимый диапазон",hiddenSheet:"Невозможно открыть ссылку, так как связанный лист скрыт",coped:"Ссылка скопирована в буфер обмена"},popup:{copy:"Копировать ссылку",edit:"Редактировать ссылку",cancel:"Отменить ссылку"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(n,e){typeof exports=="object"&&typeof module<"u"?module.exports=e():typeof define=="function"&&define.amd?define(e):(n=typeof globalThis<"u"?globalThis:n||self,n.UniverSheetsHyperLinkUiViVN=e())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"Chỉnh sửa liên kết",addTitle:"Chèn liên kết",label:"Văn bản",labelPlaceholder:"Nhập văn bản",type:"Loại",link:"Liên kết",linkPlaceholder:"Nhập địa chỉ liên kết",range:"Ô",worksheet:"Bảng tính",definedName:"Tên đã xác định",ok:"Xác nhận",cancel:"Hủy",inputError:"Vui lòng nhập",selectError:"Vui lòng chọn",linkError:"Vui lòng nhập liên kết hợp lệ"},menu:{add:"Thêm liên kết"},message:{noSheet:"Bảng con này đã bị xóa",refError:"Tham chiếu lỗi",hiddenSheet:"Không thể mở bảng con bị ẩn",coped:"Liên kết đã được sao chép vào clipboard"},popup:{copy:"Sao chép",edit:"Chỉnh sửa",cancel:"Hủy liên kết"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsHyperLinkUiZhCN=n())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"编辑链接",addTitle:"插入链接",label:"文本",labelPlaceholder:"输入文本",type:"类型",link:"链接",linkPlaceholder:"输入链接地址",range:"单元格",worksheet:"工作表",definedName:"定义的名称",ok:"确认",cancel:"取消",inputError:"请输入",selectError:"请选择",linkError:"请输入合法的链接"},menu:{add:"添加链接"},message:{noSheet:"该子表已被删除",refError:"错误的引用",hiddenSheet:"无法打开被隐藏的子表",coped:"链接已被复制到剪贴板"},popup:{copy:"复制",edit:"编辑",cancel:"取消链接"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsHyperLinkUiZhTW=n())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"編輯連結",addTitle:"插入連結",label:"文本",labelPlaceholder:"輸入文字",type:"類型",link:"連結",linkPlaceholder:"輸入連結位址",range:"單元格",worksheet:"工作表",definedName:"定義的名稱",ok:"確認",cancel:"取消",inputError:"請輸入",selectError:"請選擇",linkError:"請輸入合法的連結"},menu:{add:"新增連結"},message:{noSheet:"該子表已被刪除",refError:"錯誤的引用",hiddenSheet:"無法開啟被隱藏的子表",coped:"連結已複製到剪貼簿"},popup:{copy:"複製",edit:"編輯",cancel:"取消連結"}}}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-hyper-link-ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2-nightly.202410301606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -23,19 +23,19 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"import": "./lib/es/index.js",
|
|
26
|
-
"require": "./lib/cjs/index.js",
|
|
27
26
|
"types": "./lib/types/index.d.ts"
|
|
28
27
|
},
|
|
29
28
|
"./*": {
|
|
30
29
|
"import": "./lib/es/*",
|
|
31
|
-
"require": "./lib/cjs/*",
|
|
32
30
|
"types": "./lib/types/index.d.ts"
|
|
33
31
|
},
|
|
34
32
|
"./lib/*": "./lib/*",
|
|
35
|
-
"./locale/*":
|
|
33
|
+
"./locale/*": {
|
|
34
|
+
"import": "./lib/locale/*.js",
|
|
35
|
+
"types": "./lib/types/locale/*.d.ts"
|
|
36
|
+
}
|
|
36
37
|
},
|
|
37
|
-
"main": "./lib/
|
|
38
|
-
"module": "./lib/es/index.js",
|
|
38
|
+
"main": "./lib/es/index.js",
|
|
39
39
|
"types": "./lib/types/index.d.ts",
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
@@ -51,40 +51,41 @@
|
|
|
51
51
|
"rxjs": ">=7.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@univerjs/icons": "^0.
|
|
54
|
+
"@univerjs/icons": "^0.2.2",
|
|
55
55
|
"clsx": "^2.1.1",
|
|
56
|
-
"@univerjs/core": "0.4.
|
|
57
|
-
"@univerjs/docs
|
|
58
|
-
"@univerjs/docs": "0.4.
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/sheets": "0.4.
|
|
63
|
-
"@univerjs/sheets
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/ui": "0.4.
|
|
56
|
+
"@univerjs/core": "0.4.2-nightly.202410301606",
|
|
57
|
+
"@univerjs/docs": "0.4.2-nightly.202410301606",
|
|
58
|
+
"@univerjs/docs-hyper-link": "0.4.2-nightly.202410301606",
|
|
59
|
+
"@univerjs/engine-formula": "0.4.2-nightly.202410301606",
|
|
60
|
+
"@univerjs/docs-ui": "0.4.2-nightly.202410301606",
|
|
61
|
+
"@univerjs/sheets-formula-ui": "0.4.2-nightly.202410301606",
|
|
62
|
+
"@univerjs/sheets-hyper-link": "0.4.2-nightly.202410301606",
|
|
63
|
+
"@univerjs/sheets": "0.4.2-nightly.202410301606",
|
|
64
|
+
"@univerjs/engine-render": "0.4.2-nightly.202410301606",
|
|
65
|
+
"@univerjs/ui": "0.4.2-nightly.202410301606",
|
|
66
|
+
"@univerjs/sheets-ui": "0.4.2-nightly.202410301606"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"rxjs": "^7.8.1",
|
|
70
70
|
"typescript": "^5.6.3",
|
|
71
|
-
"vite": "^5.4.
|
|
72
|
-
"vitest": "^2.1.
|
|
73
|
-
"@univerjs-infra/shared": "0.4.
|
|
71
|
+
"vite": "^5.4.10",
|
|
72
|
+
"vitest": "^2.1.4",
|
|
73
|
+
"@univerjs-infra/shared": "0.4.2"
|
|
74
74
|
},
|
|
75
75
|
"univerSpace": {
|
|
76
76
|
".": {
|
|
77
77
|
"import": "./lib/es/index.js",
|
|
78
|
-
"require": "./lib/cjs/index.js",
|
|
79
78
|
"types": "./lib/types/index.d.ts"
|
|
80
79
|
},
|
|
81
80
|
"./*": {
|
|
82
81
|
"import": "./lib/es/*",
|
|
83
|
-
"require": "./lib/cjs/*",
|
|
84
82
|
"types": "./lib/types/index.d.ts"
|
|
85
83
|
},
|
|
86
84
|
"./lib/*": "./lib/*",
|
|
87
|
-
"./locale/*":
|
|
85
|
+
"./locale/*": {
|
|
86
|
+
"import": "./lib/locale/*.js",
|
|
87
|
+
"types": "./lib/types/locale/*.d.ts"
|
|
88
|
+
}
|
|
88
89
|
},
|
|
89
90
|
"scripts": {
|
|
90
91
|
"test": "vitest run",
|
|
@@ -92,5 +93,6 @@
|
|
|
92
93
|
"coverage": "vitest run --coverage",
|
|
93
94
|
"lint:types": "tsc --noEmit",
|
|
94
95
|
"build": "tsc && vite build"
|
|
95
|
-
}
|
|
96
|
+
},
|
|
97
|
+
"module": "./lib/es/index.js"
|
|
96
98
|
}
|