@univerjs/preset-sheets-hyper-link 0.6.10-nightly.202504161609 → 0.6.10-nightly.202504181606

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.
Files changed (2) hide show
  1. package/lib/umd/index.js +1 -1
  2. package/package.json +5 -5
package/lib/umd/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  // @univerjs/sheets-hyper-link-ui/index
10
- (function(g,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react/jsx-runtime"),require("@univerjs/sheets-formula-ui"),require("react"),require("@univerjs/sheets-data-validation")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react/jsx-runtime","@univerjs/sheets-formula-ui","react","@univerjs/sheets-data-validation"],o):(g=typeof globalThis<"u"?globalThis:g||self,o(g.UniverSheetsHyperLinkUi={},g.UniverCore,g.UniverSheets,g.UniverSheetsHyperLink,g.UniverSheetsUi,g.UniverDesign,g.UniverEngineFormula,g.UniverUi,g.UniverDocsUi,g.UniverEngineRender,g.rxjs,g.UniverDocs,g.React,g.UniverSheetsFormulaUi,g.React,g.UniverSheetsDataValidation))})(this,function(g,o,f,_,L,b,q,m,Q,pe,w,he,y,Ht,E,nt){"use strict";var Mn=Object.defineProperty;var Un=(g,o,f)=>o in g?Mn(g,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):g[o]=f;var F=(g,o,f)=>Un(g,typeof o!="symbol"?o+"":o,f);function Ee(e){return o.Tools.isLegalUrl(e)}function At(e){return/^[a-zA-Z]+:\/\//.test(e)}function Bt(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Vt(e){if(Ee(e)){const i=At(e)?e:Bt(e)?`mailto://${e}`:`http://${e}`;let t;try{t=new URL(i)}catch{return e}return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:i}return e}const it="sheets-hyper-link-ui.config",rt={};var $t=Object.getOwnPropertyDescriptor,xt=(e,i,t,n)=>{for(var r=n>1?void 0:n?$t(i,t):i,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ce=(e,i)=>(t,n)=>i(t,n,e);function jt(e,i){const t=i.getMergeData(),n=i.getMaxColumns()-1,r=i.getMaxRows()-1;if(n<e.endColumn&&(e.endColumn=n),r<e.endRow&&(e.endRow=r),e.rangeType===o.RANGE_TYPE.COLUMN||o.RANGE_TYPE.ROW)return e;const s=[];return t.forEach(a=>{o.Rectangle.intersects(e,a)&&s.push(a)}),o.Rectangle.realUnion(e,...s)}g.SheetsHyperLinkResolverService=class{constructor(i,t,n,r,s,a){this._univerInstanceService=i,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=s,this._configService=a}navigate(i){switch(i.type){case _.SheetHyperLinkType.URL:this.navigateToOtherWebsite(i.url);break;default:this._navigateToUniver(i.searchObj)}}_navigateToUniver(i){const{gid:t,range:n,rangeid:r}=i,s=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const a=s.getUnitId();if(r){const l=this._definedNamesService.getValueById(a,r);if(!l)return;const{formulaOrRefString:d}=l,p=this._definedNamesService.getWorksheetByRef(a,d);if(!p){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:b.MessageType.Error});return}if(p.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:b.MessageType.Error});return}this.navigateToDefineName(a,r)}if(t){if(n){const l=q.deserializeRangeWithSheet(n);o.isValidRange(l.range)&&n!==_.ERROR_RANGE&&this.navigateToRange(a,t,l.range);return}this.navigateToSheetById(a,t)}}async navigateToRange(i,t,n,r){const s=await this.navigateToSheetById(i,t);if(s){const a=jt(n,s);await this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:i,subUnitId:t,selections:[{range:a,primary:null}]}),await this._commandService.executeCommand(L.ScrollToRangeOperation.id,{range:a,forceTop:r})}}async navigateToSheetById(i,t){const n=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const s=n.getSheetBySheetId(t);return s?n.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:b.MessageType.Error}),!1):await this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:t})?s:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:b.MessageType.Error}),!1)}async navigateToDefineName(i,t){return this._definedNamesService.focusRange(i,t),!0}async navigateToOtherWebsite(i){var n;const t=this._configService.getConfig(it);if((n=t==null?void 0:t.urlHandler)!=null&&n.navigateToOtherWebsite)return t.urlHandler.navigateToOtherWebsite(i);window.open(i,"_blank","noopener noreferrer")}},g.SheetsHyperLinkResolverService=xt([ce(0,o.IUniverInstanceService),ce(1,o.ICommandService),ce(2,q.IDefinedNamesService),ce(3,m.IMessageService),ce(4,o.Inject(o.LocaleService)),ce(5,o.IConfigService)],g.SheetsHyperLinkResolverService);const je="SHEET_HYPER_LINK_UI_PLUGIN";var Zt=Object.getOwnPropertyDescriptor,Ft=(e,i,t,n)=>{for(var r=n>1?void 0:n?Zt(i,t):i,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Le=(e,i)=>(t,n)=>i(t,n,e);g.SheetsHyperLinkCopyPasteController=class extends o.Disposable{constructor(t,n,r,s){super();F(this,"_plainTextFilter",new Set);F(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=n,this._injector=r,this._resolverService=s,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(t){this._plainTextFilter.add(t)}removePlainTextFilter(t){this._plainTextFilter.delete(t)}_filterPlainText(t){return Array.from(this._plainTextFilter).every(n=>n(t))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:je,onBeforeCopy:(t,n,r)=>this._collect(t,n,r),onPasteCells:(t,n,r,s)=>{const{copyType:a=L.COPY_TYPE.COPY,pasteType:l}=s,{range:d}=t||{},{range:p,unitId:u,subUnitId:h}=n;return this._generateMutations(p,{copyType:a,pasteType:l,copyRange:d,unitId:u,subUnitId:h})},onPastePlainText:(t,n)=>{const r=this._filterPlainText(n);if(Ee(n)&&r){const{range:s,unitId:a,subUnitId:l}=t,{ranges:[d],mapFunc:p}=L.virtualizeDiscreteRanges([s]),u=[],h=[];return o.Range.foreach(d,(I,S)=>{const{row:R,col:T}=p(I,S),P=this._hyperLinkModel.getHyperLinkByLocation(a,l,R,T);P&&u.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:l,id:P.id}}),P&&h.push({id:_.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:l,link:P}})}),{redos:u,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(t,n,r){const s=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:s};const a=this._injector.invoke(p=>f.rangeToDiscreteRange(r,p,t,n));if(!a)return;const{rows:l,cols:d}=a;l.forEach((p,u)=>{d.forEach((h,I)=>{var R;const S=this._hyperLinkModel.getHyperLinkByLocation(t,n,p,h);s.setValue(u,I,(R=S==null?void 0:S.id)!=null?R:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([L.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,L.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,L.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,L.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:s,subUnitId:a}=this._copyInfo,l=[],d=[],{ranges:[p,u],mapFunc:h}=L.virtualizeDiscreteRanges([n.copyRange,t]);return L.getRepeatRange(p,u,!0).forEach(({startRange:S})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((T,P,c)=>{const k=o.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:P,endColumn:P},S),B=this._hyperLinkModel.getHyperLink(s,a,c),{row:M,col:U}=h(k.startRow,k.startColumn),x=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,M,U),$=o.Tools.generateRandomId();x&&l.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:x.id}}),B&&(l.push({id:_.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...B,id:$,row:M,column:U}}}),d.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:$}})),x&&d.push({id:_.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:x}})})}),{redos:l,undos:d}}},g.SheetsHyperLinkCopyPasteController=Ft([Le(0,L.ISheetClipboardService),Le(1,o.Inject(_.HyperLinkModel)),Le(2,o.Inject(o.Injector)),Le(3,o.Inject(g.SheetsHyperLinkResolverService))],g.SheetsHyperLinkCopyPasteController);var C=(e=>(e.EDITING="editing",e.VIEWING="viewing",e.ZEN_EDITOR="zen_mode",e))(C||{});class Ze extends o.Disposable{constructor(){super(...arguments);F(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==_.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(r=>r.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:n}=this;n.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const ot={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Re=()=>{var yt;const[e,i]=E.useState(""),[t,n]=E.useState(!1),[r,s]=E.useState(""),[a,l]=E.useState(!0),[d,p]=E.useState(_.SheetHyperLinkType.URL),[u,h]=E.useState(""),I=m.useDependency(o.LocaleService),S=m.useDependency(q.IDefinedNamesService),R=m.useDependency(L.IEditorBridgeService),T=m.useDependency(o.IUniverInstanceService),P=m.useDependency(g.SheetsHyperLinkPopupService),c=m.useObservable(P.currentEditing$),k=m.useDependency(_.SheetsHyperLinkParserService),B=m.useDependency(g.SheetsHyperLinkResolverService),M=m.useDependency(o.ICommandService),U=m.useDependency(Ze),x=E.useMemo(()=>U.getOptions(),[U]),$=m.useDependency(m.IZenZoneService),X=m.useDependency(pe.IRenderManagerService),_e=m.useDependency(L.IMarkSelectionService),Ve=m.useDependency(he.DocSelectionManagerService),se=m.useDependency(o.IContextService),Ie=m.useDependency(o.ThemeService),me=m.useDependency(he.DocSelectionManagerService),[fe,$e]=E.useState(!1),le=m.useDependency(f.SheetsSelectionsService),kn=E.useMemo(()=>le.getCurrentSelections(),[]),xe=E.useMemo(()=>{if(!U.isBuiltInLinkType(d))return U.getCustomHyperLink(d)},[U,d]),[de,On]=E.useState(!1),[ye,mt]=E.useState(!1),j=E.useRef(!1),Y=T.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),Dn=(Y==null?void 0:Y.getActiveSheet().getSheetId())||"",ee=E.useCallback(v=>{s(v.replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[s]);E.useEffect(()=>{var v,O,D,N,A,G,Ct,Et,Lt,Rt,Pt,Tt,kt,Ot,Dt,bt,wt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:ae,row:et,col:tt}=c;let{label:J}=c;typeof J=="number"&&(J=`${J}`);let z;if(ae)z={id:(v=ae==null?void 0:ae.rangeId)!=null?v:"",display:J!=null?J:"",payload:(D=(O=ae==null?void 0:ae.properties)==null?void 0:O.url)!=null?D:"",row:et,column:tt};else if(c.type===C.VIEWING){const H=T.getUnit(c.unitId),ne=H==null?void 0:H.getSheetBySheetId(c.subUnitId),V=ne==null?void 0:ne.getCellRaw(c.row,c.col),ue=(G=(A=(N=V==null?void 0:V.p)==null?void 0:N.body)==null?void 0:A.customRanges)==null?void 0:G.find(Mt=>{var Ut;return Mt.rangeType===o.CustomRangeType.HYPERLINK&&((Ut=Mt.properties)==null?void 0:Ut.url)}),Ce=V==null?void 0:V.v;V&&(!o.BuildTextUtils.transform.isEmptyDocument((Et=(Ct=V.p)==null?void 0:Ct.body)==null?void 0:Et.dataStream)||o.Tools.isDefine(Ce))&&l(!1),z={id:"",display:"",payload:(Rt=(Lt=ue==null?void 0:ue.properties)==null?void 0:Lt.url)!=null?Rt:"",row:et,column:tt}}else{const H=T.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),ne=Ve.getActiveTextRange(),V=H==null?void 0:H.getBody(),ue=ne&&V?ne:null,Ce=ue&&((Tt=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ue,(Pt=V==null?void 0:V.customRanges)!=null?Pt:[]))==null?void 0:Tt[0]);l(!1),z={id:"",display:J!=null?J:"",payload:(Ot=(kt=Ce==null?void 0:Ce.properties)==null?void 0:kt.url)!=null?Ot:"",row:et,column:tt}}i(z.id);const Nt=U.findCustomHyperLink(z);if(Nt){const H=Nt.convert(z);p(H.type),h(H.payload),ee(H.display);return}ee(z.display);const te=k.parseHyperLink(z.payload);switch(p(te.type===_.SheetHyperLinkType.INVALID?_.SheetHyperLinkType.RANGE:te.type),te.type){case _.SheetHyperLinkType.URL:{h(te.url),te.url===z.display&&(j.current=!0);break}case _.SheetHyperLinkType.RANGE:{const H=te.searchObj,ne=H.gid&&(wt=(bt=(Dt=T.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:bt.getName())!=null?wt:"",V=q.serializeRangeWithSheet(ne,q.deserializeRangeWithSheet(H.range).range);h(V),V===z.display&&(j.current=!0);break}case _.SheetHyperLinkType.SHEET:{const H=te.searchObj;h(H.gid);break}case _.SheetHyperLinkType.DEFINE_NAME:{const H=te.searchObj;h(H.rangeid);break}default:h("");break}}},[c,B,U,Ve,T]),E.useEffect(()=>{let v=null;if(c&&!c.customRangeId&&c.type===C.VIEWING&&o.Tools.isDefine(c.row)&&o.Tools.isDefine(c.col)){const O=T.getUnit(c.unitId,o.UniverInstanceType.UNIVER_SHEET),D=O==null?void 0:O.getSheetBySheetId(c.subUnitId),N=D==null?void 0:D.getMergedCell(c.row,c.col),A=new o.ColorKit(Ie.getCurrentTheme().hyacinth500).toRgb();v=_e.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${A.r}, ${A.g}, ${A.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{v&&_e.removeShape(v)}},[c,_e,Ie,T]),E.useEffect(()=>{mt(d===_.SheetHyperLinkType.RANGE)},[d]),E.useEffect(()=>{const v=(c==null?void 0:c.type)===C.ZEN_EDITOR?X.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY):X.getRenderById(R.getCurrentEditorId()),O=new o.DisposableCollection;if(v){const D=v.with(Q.DocSelectionRenderService);D.setReserveRangesStatus(!0),O.add(()=>{D.setReserveRangesStatus(!1)})}return()=>{R.disableForceKeepVisible(),O.dispose()}},[c==null?void 0:c.type,R,X]),E.useEffect(()=>(ye&&P.setIsKeepVisible(ye),P.setIsKeepVisible(fe),()=>{P.setIsKeepVisible(!1)}),[ye,fe,P]),E.useEffect(()=>()=>{$.temporaryHidden&&($.show(),se.setContextValue(o.FOCUSING_SHEET,!1))},[se,$]),E.useEffect(()=>{if(ye)return R.enableForceKeepVisible(),()=>{R.disableForceKeepVisible()}},[ye,R]);const bn=[{label:I.t("hyperLink.form.link"),value:_.SheetHyperLinkType.URL},{label:I.t("hyperLink.form.range"),value:_.SheetHyperLinkType.RANGE},{label:I.t("hyperLink.form.worksheet"),value:_.SheetHyperLinkType.SHEET},{label:I.t("hyperLink.form.definedName"),value:_.SheetHyperLinkType.DEFINE_NAME},...x];if(!Y)return;const wn=Y.getHiddenWorksheets(),Xe=Y.getSheets().map(v=>({label:v.getName(),value:v.getSheetId()})).filter(v=>wn.indexOf(v.value)===-1),Je=Object.values((yt=S.getDefinedNameMap(Y.getUnitId()))!=null?yt:{}).map(v=>({label:v.name,value:v.id})),ft=(v,O)=>{if(v===_.SheetHyperLinkType.URL)return Vt(O);if(v===_.SheetHyperLinkType.RANGE){const D=q.deserializeRangeWithSheet(O),N=Y.getSheetBySheetName(D.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${q.serializeRange(D.range)}`}return`#${v}=${O}`},Nn=m.useEvent(v=>{var A;const D=v.split(",").map(q.deserializeRangeWithSheet)[0];if(!D||!o.isValidRange(D.range))return;D.sheetName||(D.sheetName=((A=Y.getActiveSheet())==null?void 0:A.getName())||"");const N=q.serializeRangeToRefString(D);h(N),N&&(j.current||!r)&&(ee(N),j.current=!0)}),Qe=async()=>{if(a&&!r||!u||d===_.SheetHyperLinkType.URL&&!Ee(u)){On(!0);return}if(c)if(e){const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?_.UpdateRichHyperLinkCommand.id:_.UpdateHyperLinkCommand.id;await M.executeCommand(v,{id:e,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:a?r:"",payload:ft(d,u)},row:c.row,column:c.col,documentId:c.type===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:R.getCurrentEditorId()})}else{const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?_.AddRichHyperLinkCommand.id:_.AddHyperLinkCommand.id;await M.executeCommand(v,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:o.generateRandomId(),row:c.row,column:c.col,payload:ft(d,u),display:a?r:""},documentId:c.type===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:R.getCurrentEditorId()})}if((c==null?void 0:c.type)===C.VIEWING){await M.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const v=1;await M.executeCommand(L.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-v,0),endRow:c.row+v,startColumn:Math.max(c.col-v,0),endColumn:c.col+v}})}M.executeCommand(ve.id)};return c?y.jsxs("div",{className:ot.cellLinkEdit,style:{display:t?"none":"block"},children:[a?y.jsx(b.FormLayout,{label:I.t("hyperLink.form.label"),error:de&&!r?I.t("hyperLink.form.inputError"):"",children:y.jsx(b.Input,{value:r,onChange:v=>{ee(v),j.current=!1},placeholder:I.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Qe()}})}):null,y.jsx(b.FormLayout,{label:I.t("hyperLink.form.type"),children:y.jsx(b.Select,{options:bn,value:d,onChange:v=>{p(v),h("")}})}),d===_.SheetHyperLinkType.URL&&y.jsx(b.FormLayout,{error:de?u?Ee(u)?"":I.t("hyperLink.form.linkError"):I.t("hyperLink.form.inputError"):"",children:y.jsx(b.Input,{value:u,onChange:v=>{h(v),v&&(j.current||!r||r===u)&&(ee(v),j.current=!0)},placeholder:I.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Qe()}})}),d===_.SheetHyperLinkType.RANGE&&y.jsx(b.FormLayout,{error:de&&!u?I.t("hyperLink.form.inputError"):"",children:y.jsx(Ht.RangeSelector,{unitId:Y.getUnitId(),subUnitId:Dn,maxRangeCount:1,supportAcrossSheet:!0,initialValue:u,resetRange:kn,onChange:(v,O)=>Nn(O),onRangeSelectorDialogVisibleChange:async v=>{var O,D;if($e(v),v)c.type===C.ZEN_EDITOR&&($.hide(),se.setContextValue(o.FOCUSING_SHEET,!0)),c.type!==C.VIEWING&&R.enableForceKeepVisible(),n(!0);else{if(await B.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===C.ZEN_EDITOR){await M.executeCommand(f.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),$.show(),se.setContextValue(o.FOCUSING_SHEET,!1);const N=(O=X.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:O.with(Q.DocBackScrollRenderController),A=(D=me.getTextRanges({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:D[0];N&&A&&(N.scrollToRange(A),me.refreshSelection({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}R.disableForceKeepVisible(),n(!1)}},onFocusChange:v=>mt(v)})}),d===_.SheetHyperLinkType.SHEET&&y.jsx(b.FormLayout,{error:de&&!u?I.t("hyperLink.form.selectError"):"",children:y.jsx(b.Select,{options:Xe,value:u,onChange:v=>{var N,A;h(v);const O=(N=Xe.find(G=>G.value===v))==null?void 0:N.label,D=(A=Xe.find(G=>G.value===u))==null?void 0:A.label;O&&(j.current||!r||r===D)&&(ee(O),j.current=!0)}})}),d===_.SheetHyperLinkType.DEFINE_NAME&&y.jsx(b.FormLayout,{error:de&&!u?I.t("hyperLink.form.selectError"):"",children:y.jsx(b.Select,{options:Je,value:u,onChange:v=>{var N,A;h(v);const O=(N=Je.find(G=>G.value===v))==null?void 0:N.label,D=(A=Je.find(G=>G.value===u))==null?void 0:A.label;O&&(j.current||!r||r===D)&&(ee(O),j.current=!0)}})}),(xe==null?void 0:xe.Form)&&y.jsx(xe.Form,{linkId:e,payload:u,display:r,showError:de,setByPayload:j,setDisplay:v=>{ee(v),j.current=!0},setPayload:h}),y.jsxs("div",{className:ot.cellLinkEditButtons,children:[y.jsx(b.Button,{onClick:()=>{c&&B.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),M.executeCommand(ve.id)},children:I.t("hyperLink.form.cancel")}),y.jsx(b.Button,{variant:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:I.t("hyperLink.form.ok")})]})]}):null};Re.componentKey="univer.sheet.cell-link-edit";var Z=function(){return Z=Object.assign||function(e){for(var i,t=1,n=arguments.length;t<n;t++){i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},Z.apply(this,arguments)},Kt=function(e,i){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&i.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]]);return t},ie=E.forwardRef(function(e,i){var t=e.icon,n=e.id,r=e.className,s=e.extend,a=Kt(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),d=E.useRef("_".concat(Gt()));return st(t,"".concat(n),{defIds:t.defIds,idSuffix:d.current},Z({ref:i,className:l},a),s)});function st(e,i,t,n,r){return E.createElement(e.tag,Z(Z({key:i},Wt(e,t,r)),n),(Yt(e,t).children||[]).map(function(s,a){return st(s,"".concat(i,"-").concat(e.tag,"-").concat(a),t,void 0,r)}))}function Wt(e,i,t){var n=Z({},e.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+i.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];a==="mask"&&typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))});var r=i.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function Yt(e,i){var t,n=i.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?Z(Z({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?Z(Z({},r),{attrs:Z(Z({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):e}function Gt(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var zt={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=E.forwardRef(function(e,i){return E.createElement(ie,Object.assign({},e,{id:"all-border-single",ref:i,icon:zt}))});Pe.displayName="AllBorderSingle";var qt={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"}}]},at=E.forwardRef(function(e,i){return E.createElement(ie,Object.assign({},e,{id:"copy-single",ref:i,icon:qt}))});at.displayName="CopySingle";var Xt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},Fe=E.forwardRef(function(e,i){return E.createElement(ie,Object.assign({},e,{id:"link-single",ref:i,icon:Xt}))});Fe.displayName="LinkSingle";var Jt={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"}}]},ct=E.forwardRef(function(e,i){return E.createElement(ie,Object.assign({},e,{id:"unlink-single",ref:i,icon:Jt}))});ct.displayName="UnlinkSingle";var Qt={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"}}]},lt=E.forwardRef(function(e,i){return E.createElement(ie,Object.assign({},e,{id:"write-single",ref:i,icon:Qt}))});lt.displayName="WriteSingle";var en={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.4538 1.12549C2.70051 1.12549 2.08984 1.73615 2.08984 2.48945V13.5104C2.08984 14.2637 2.70051 14.8744 3.4538 14.8744H12.5468C13.3001 14.8744 13.9108 14.2637 13.9108 13.5104V5.0992L10.0094 1.12549H3.4538Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M10.0078 1.12549L13.9107 5.09842H10.6745C10.3063 5.09842 10.0078 4.79994 10.0078 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.80941 10.2949L6.37701 12.403C6.2632 12.5705 6.03516 12.614 5.86766 12.5002C5.70017 12.3864 5.65664 12.1584 5.77045 11.9909L7.36611 9.64252L5.94103 7.54519C5.82722 7.37769 5.87074 7.14964 6.03824 7.03583C6.20573 6.92202 6.43378 6.96555 6.54759 7.13304L7.80941 8.9901L9.07123 7.13304C9.18504 6.96555 9.41309 6.92202 9.58059 7.03583C9.74808 7.14964 9.7916 7.37769 9.67779 7.54519L8.25271 9.64252L9.84837 11.9909C9.96218 12.1584 9.91866 12.3864 9.75116 12.5002C9.58366 12.614 9.35562 12.5705 9.24181 12.403L7.80941 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},dt=E.forwardRef(function(e,i){return E.createElement(ie,Object.assign({},e,{id:"xlsx",ref:i,icon:en}))});dt.displayName="Xlsx";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"},tn={[_.SheetHyperLinkType.URL]:y.jsx(Fe,{}),[_.SheetHyperLinkType.SHEET]:y.jsx(dt,{}),[_.SheetHyperLinkType.RANGE]:y.jsx(Pe,{}),[_.SheetHyperLinkType.DEFINE_NAME]:y.jsx(Pe,{}),[_.SheetHyperLinkType.INVALID]:y.jsx(Pe,{})},ut=e=>{var B,M;const i=m.useDependency(g.SheetsHyperLinkPopupService),t=m.useDependency(o.ICommandService),n=m.useDependency(m.IMessageService),r=m.useDependency(o.LocaleService),s=m.useDependency(g.SheetsHyperLinkResolverService),a=m.useDependency(L.IEditorBridgeService),l=m.useDependency(_.SheetsHyperLinkParserService),d=m.useDependency(m.IZenZoneService),{customRange:p,row:u,col:h,unitId:I,subUnitId:S,editPermission:R,copyPermission:T,type:P}=e;if(!((B=p==null?void 0:p.properties)!=null&&B.url))return null;const c=l.parseHyperLink((M=p.properties.url)!=null?M:""),k=c.type===_.SheetHyperLinkType.INVALID;return y.jsxs("div",{className:K.cellLink,onClick:()=>i.hideCurrentPopup(),children:[y.jsxs("div",{className:b.clsx(K.cellLinkContent,{[K.cellLinkContentError]:k}),onClick:()=>{d.visible||k||s.navigate(c)},children:[y.jsx("div",{className:K.cellLinkType,children:tn[c.type]}),y.jsx(b.Tooltip,{showIfEllipsis:!0,title:c.name,asChild:!0,children:y.jsx("span",{className:K.cellLinkUrl,children:c.name})})]}),y.jsxs("div",{className:K.cellLinkOperations,children:[T&&y.jsx("div",{className:b.clsx(K.cellLinkOperation,{[K.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==_.SheetHyperLinkType.URL){const U=new URL(window.location.href);U.hash=c.url.slice(1),navigator.clipboard.writeText(U.href)}else navigator.clipboard.writeText(c.url);n.show({content:r.t("hyperLink.message.coped"),type:b.MessageType.Info})}},children:y.jsx(b.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:y.jsx(at,{})})}),R&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:K.cellLinkOperation,onClick:()=>{t.executeCommand(ke.id,{unitId:I,subUnitId:S,row:u,col:h,customRangeId:p.rangeId,type:P})},children:y.jsx(b.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:y.jsx(lt,{})})}),y.jsx("div",{className:K.cellLinkOperation,onClick:()=>{const U=P===C.EDITING||P===C.ZEN_EDITOR?_.CancelRichHyperLinkCommand.id:_.CancelHyperLinkCommand.id;t.syncExecuteCommand(U,{unitId:I,subUnitId:S,id:p.rangeId,row:u,column:h,documentId:P===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:a.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:y.jsx(b.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:y.jsx(ct,{})})})]})]})]})},Te=()=>{var r,s;const e=m.useDependency(g.SheetsHyperLinkPopupService),[i,t]=E.useState(null),n=m.useDependency(o.IUniverInstanceService);if(E.useEffect(()=>{t(e.currentPopup);const a=e.currentPopup$.subscribe(l=>{t(l)});return()=>{a.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!i)return null;if(i.showAll){const a=n.getUnit(i.unitId,o.UniverInstanceType.UNIVER_SHEET),l=a==null?void 0:a.getSheetBySheetId(i.subUnitId),d=l==null?void 0:l.getCell(i.row,i.col),p=(s=(r=d==null?void 0:d.p)==null?void 0:r.body)==null?void 0:s.customRanges;return p!=null&&p.length?y.jsx("div",{children:p.map(u=>y.jsx(ut,{...i,customRange:u},u.rangeId))}):null}return y.jsx(ut,{...i})};Te.componentKey="univer.sheet.cell-link-popup";var nn=Object.getOwnPropertyDescriptor,rn=(e,i,t,n)=>{for(var r=n>1?void 0:n?nn(i,t):i,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},re=(e,i)=>(t,n)=>i(t,n,e);const pt=(e,i)=>{var t,n;return e.unitId===i.unitId&&e.subUnitId===i.subUnitId&&e.row===i.row&&e.col===i.col&&((t=e.customRange)==null?void 0:t.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&e.type===i.type};g.SheetsHyperLinkPopupService=class extends o.Disposable{constructor(t,n,r,s,a,l,d){super();F(this,"_currentPopup",null);F(this,"_currentPopup$",new w.Subject);F(this,"currentPopup$",this._currentPopup$.asObservable());F(this,"_currentEditingPopup",null);F(this,"_currentEditing$",new w.BehaviorSubject(null));F(this,"currentEditing$",this._currentEditing$.asObservable());F(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=s,this._textSelectionManagerService=a,this._docCanvasPopManagerService=l,this._zenZoneService=d,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){if(this._currentPopup&&pt(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==C.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&pt(t,n))return;const{unitId:r,subUnitId:s,row:a,col:l,customRangeRect:d,customRange:p}=t;let u;const h={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===C.EDITING){if(!p)return;u=d&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(d,h)}else if(t.type===C.ZEN_EDITOR){if(!p)return;u=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)u=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,h,r,s);else{if(!p)return;u=d&&this._sheetCanvasPopManagerService.attachPopupByPosition(d,h,t)}u&&(this._currentPopup={unitId:r,subUnitId:s,disposable:u,row:a,col:l,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:p,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,n){var r,s;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((s=(r=this._currentPopup)==null?void 0:r.disposable)==null||s.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,s,a;const t=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(t&&n){const l=this._textSelectionManagerService.getActiveTextRange(),d=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!d)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:d.dataStream.length-2,collapsed:d.dataStream.length-2===0,label:o.BuildTextUtils.transform.getPlainText(d.dataStream)};const p=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(a=(s=d.customRanges)==null?void 0:s.filter(I=>I.rangeType===o.CustomRangeType.HYPERLINK))!=null?a:[]);let u=l.startOffset,h=l.endOffset;return p.forEach(I=>{u=Math.min(u,I.startIndex),h=Math.max(h,I.endIndex+1)}),{startOffset:u,endOffset:h,collapsed:u===h,label:o.BuildTextUtils.transform.getPlainText(d.dataStream.slice(u,h))}}return null}get _editPopup(){return{componentKey:Re.componentKey,direction:"vertical",onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var a,l,d,p,u;const{unitId:n,subUnitId:r,type:s}=t;if(s===C.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(!h)return;const I=this._textSelectionManagerService.getActiveTextRange();if(!I)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(I,this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const S=(a=h.getBody())==null?void 0:a.dataStream.slice(I.startOffset,I.endOffset);this._currentEditing$.next({...t,label:S})}else if(s===C.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const I=this._injector.get(pe.IRenderManagerService).getRenderById(o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!I)return;const S=Q.calcDocRangePositions(h,I);if(!(S!=null&&S.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.pop(),this._editPopup,n,r),this._currentEditing$.next({...t,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),I=h==null?void 0:h.getSheetBySheetId(r),S=I==null?void 0:I.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:S!=null&&S.p?o.BuildTextUtils.transform.getPlainText((p=(d=S.p.body)==null?void 0:d.dataStream)!=null?p:""):((u=S==null?void 0:S.v)!=null?u:"").toString()})}}startEditing(t){var l,d,p,u,h,I;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=t;let s,a;if(t.type===C.ZEN_EDITOR){const S=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(s=(p=(d=S==null?void 0:S.getBody())==null?void 0:d.customRanges)==null?void 0:p.find(R=>R.rangeId===t.customRangeId),a=s?(u=S==null?void 0:S.getBody())==null?void 0:u.dataStream.slice(s.startIndex,s.endIndex+1):"",!s||!a)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:s.startIndex,endOffset:s.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:s.startIndex,endOffset:s.endIndex,collapsed:!1},this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===C.EDITING){const S=L.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!S||!((h=S.rects)!=null&&h.length))return;s=S.customRange,a=S.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:s.startIndex,endOffset:s.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.rects.pop(),this._editPopup,n,r)}else{const S=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),R=S==null?void 0:S.getSheetBySheetId(r),T=R==null?void 0:R.getCellRaw(t.row,t.col),P=S==null?void 0:S.getStyles().getStyleByCell(T),c=P==null?void 0:P.tr,k=L.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!k||!((I=k.rects)!=null&&I.length))return;s=k.customRange,a=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:s,label:a})}endEditing(t){var r;if(this.getIsKeepVisible())return;const n=this._currentEditing$.getValue();n&&(!t||t===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},g.SheetsHyperLinkPopupService=rn([re(0,o.Inject(L.SheetCanvasPopManagerService)),re(1,o.Inject(o.Injector)),re(2,o.IUniverInstanceService),re(3,L.IEditorBridgeService),re(4,o.Inject(he.DocSelectionManagerService)),re(5,o.Inject(Q.DocCanvasPopManagerService)),re(6,m.IZenZoneService)],g.SheetsHyperLinkPopupService);var ge=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(ge||{});const on=new Set([o.DataValidationType.CHECKBOX,o.DataValidationType.LIST,o.DataValidationType.LIST_MULTIPLE]),Ke=(e,i,t,n)=>{var l,d,p,u,h;const r=i.getCell(t,n);if(r!=null&&r.f||r!=null&&r.si||(p=(d=(l=r==null?void 0:r.p)==null?void 0:l.body)==null?void 0:d.customBlocks)!=null&&p.length)return 1;const s=e.has(nt.SheetDataValidationModel)?e.get(nt.SheetDataValidationModel):null,a=s==null?void 0:s.getRuleByLocation(i.getUnitId(),i.getSheetId(),t,n);return a&&on.has(a.type)?!0:(h=(u=r==null?void 0:r.p)==null?void 0:u.drawingsOrder)!=null&&h.length?2:0},sn=e=>{const i=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const t=i.getActiveSheet(),n=e.get(f.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,s=n[0].range.startColumn;return Ke(e,t,r,s)===1},an=e=>{const i=e.get(he.DocSelectionManagerService),t=e.get(o.IUniverInstanceService),n=i.getTextRanges();if(!(n!=null&&n.length))return!0;const r=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);return!!(!r||n.every(a=>a.collapsed)||!r.getSelfOrHeaderFooterModel(n[0].segmentId).getBody())},ke={type:o.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,i){if(!i)return!1;const t=e.get(g.SheetsHyperLinkPopupService);return i.customRangeId?t.startEditing(i):t.startAddEditing(i),!0}},ve={type:o.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(g.SheetsHyperLinkPopupService).endEditing(),!0}},Oe={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var h;const i=e.get(o.IUniverInstanceService),t=f.getSheetCommandTarget(i),n=e.get(L.IEditorBridgeService);if(!t)return!1;const r=e.get(o.ICommandService),a=e.get(f.SheetsSelectionsService).getCurrentLastSelection();if(!a)return!1;const l=a.range.startRow,d=a.range.startColumn,p=n.isVisible(),u=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(ke.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:l,col:d,type:u?C.ZEN_EDITOR:p.visible?C.EDITING:C.VIEWING})}},oe={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(sn(e))return!1;const i=e.get(o.ICommandService);return e.get(g.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(ve.id):i.executeCommand(Oe.id)}},We=(e,i=o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const t=e.get(o.IUniverInstanceService),n=(r=e.get(pe.IRenderManagerService).getRenderById(i))==null?void 0:r.with(Q.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(w.map(()=>{const a=e.get(L.IEditorBridgeService).getEditCellState();if(!a)return!0;const l=f.getSheetCommandTarget(t,{unitId:a.unitId,subUnitId:a.sheetId});return!(l!=null&&l.worksheet)||Ke(e,l.worksheet,a.row,a.column)===1?!0:an(e)})):w.of(!0)},ht=e=>{var s;const i=L.getCurrentRangeDisable$(e,{workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},!0),t=e.get(o.IUniverInstanceService),n=e.has(L.IEditorBridgeService)?e.get(L.IEditorBridgeService):null;return((s=n==null?void 0:n.currentEditCellState$.pipe(w.map(a=>{if(!a)return ge.DISABLED_BY_CELL;const l=f.getSheetCommandTarget(t,{unitId:a.unitId,subUnitId:a.sheetId});return l?Ke(e,l.worksheet,a.row,a.column):ge.DISABLED_BY_CELL}),w.switchMap(a=>{if(a===ge.DISABLED_BY_CELL)return w.of(!0);const l=n?n.visible$:w.of(null);return w.combineLatest([l,t.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC)]).pipe(w.switchMap(([d,p])=>d!=null&&d.visible?(p==null?void 0:p.getUnitId())===o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?w.of(!0):We(e,o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):w.of(a!==ge.ALLOWED)))})))!=null?s:w.of(!0)).pipe(w.switchMap(a=>a?w.of(!0):i))},De={commandId:Oe.id,type:m.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},be=e=>`${e}-zen-editor`,cn=e=>({...De,id:De.commandId,hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:ht(e)}),ln=e=>({...De,id:be(De.commandId),hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:We(e)}),we={tooltip:"hyperLink.form.addTitle",commandId:oe.id,type:m.MenuItemType.BUTTON,icon:"LinkSingle"},dn=e=>({...we,id:we.commandId,hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:ht(e)}),un=e=>({...we,id:be(we.commandId),hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:We(e)}),Ye={id:oe.id,binding:m.KeyCode.K|m.MetaKeys.CTRL_COMMAND,preconditions:L.whenSheetEditorFocused};var pn=Object.getOwnPropertyDescriptor,hn=(e,i,t,n)=>{for(var r=n>1?void 0:n?pn(i,t):i,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},gt=(e,i)=>(t,n)=>i(t,n,e);let Ne=class extends o.Disposable{constructor(e,i){super(),this._autoFillService=e,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:s,target:a,unitId:l,subUnitId:d}=n,p=L.virtualizeDiscreteRanges([s,a]),[u,h]=p.ranges,{mapFunc:I}=p,S={row:u.startRow,col:u.startColumn},R=L.getAutoFillRepeatRange(u,h),T=[],P=[];return R.forEach(c=>{const k=c.repeatStartCell,B=c.relativeRange,M={startRow:S.row,startColumn:S.col,endColumn:S.col,endRow:S.row},U={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};o.Range.foreach(B,(x,$)=>{const X=o.Rectangle.getPositionRange({startRow:x,startColumn:$,endColumn:$,endRow:x},M),{row:_e,col:Ve}=I(X.startRow,X.startColumn),se=this._hyperLinkModel.getHyperLinkByLocation(l,d,_e,Ve),Ie=o.Rectangle.getPositionRange({startRow:x,startColumn:$,endColumn:$,endRow:x},U),{row:me,col:fe}=I(Ie.startRow,Ie.startColumn),$e=o.Tools.generateRandomId(),le=this._hyperLinkModel.getHyperLinkByLocation(l,d,me,fe);le&&T.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:d,id:le.id}}),(L.APPLY_TYPE.COPY===r||L.APPLY_TYPE.SERIES===r)&&se&&(T.push({id:_.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:d,link:{...se,id:$e,row:me,column:fe}}}),P.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:d,id:$e}})),le&&P.push({id:_.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:d,link:le}})})}),{undos:P,redos:T}},t={id:je,onFillData:(n,r,s)=>s===L.APPLY_TYPE.COPY||s===L.APPLY_TYPE.ONLY_FORMAT||s===L.APPLY_TYPE.SERIES?i(n,s):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};Ne=hn([gt(0,L.IAutoFillService),gt(1,o.Inject(_.HyperLinkModel))],Ne);var gn=Object.getOwnPropertyDescriptor,vn=(e,i,t,n)=>{for(var r=n>1?void 0:n?gn(i,t):i,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Ge=(e,i)=>(t,n)=>i(t,n,e);let Me=class extends o.Disposable{constructor(e,i,t){super(),this._localeService=e,this._commandService=i,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===Ye.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],rangeTypes:[f.RangeProtectionPermissionEditPoint],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=vn([Ge(0,o.Inject(o.LocaleService)),Ge(1,o.ICommandService),Ge(2,o.Inject(f.SheetPermissionCheckController))],Me);var Sn=Object.getOwnPropertyDescriptor,_n=(e,i,t,n)=>{for(var r=n>1?void 0:n?Sn(i,t):i,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},W=(e,i)=>(t,n)=>i(t,n,e);let Ue=class extends o.Disposable{constructor(e,i,t,n,r,s,a,l,d,p){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=i,this._renderManagerService=t,this._permissionService=n,this._sheetPermissionCheckController=r,this._commandService=s,this._editorBridgeService=a,this._textSelectionManagerService=l,this._univerInstanceService=d,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:i,subUnitId:t,row:n,col:r}=e,s=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET);if(!(s==null?void 0:s.getSheetBySheetId(t)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookViewPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),d=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),p=this._permissionService.composePermission([new f.WorkbookCopyPermission(i).id,new f.WorksheetCopyPermission(i,t).id]).every(u=>u.value);return{viewPermission:l,editPermission:d,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(w.debounceTime(200)).subscribe(e=>{var M,U;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:t,row:n,col:r}=e,s=this._renderManagerService.getRenderById(i);if(!s)return;const a=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),l=a==null?void 0:a.getSheetBySheetId(t);if(!l)return;if(!s.with(L.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING);return}const p=(M=s==null?void 0:s.with(L.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:M.skeleton,u=r,h=n;let I=h,S=u;p&&p.overflowCache.forValue((x,$,X)=>{o.Rectangle.contains(X,{startColumn:u,endColumn:u,startRow:h,endRow:h})&&(I=x,S=$)});const{viewPermission:R,editPermission:T,copyPermission:P}=this._getLinkPermission(e);if(!R){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(I,S),k=a.getStyles().getStyleByCell(c),B=(U=k==null?void 0:k.tr)==null?void 0:U.a;if(!B&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:I,col:S,editPermission:T,copyPermission:P,customRange:e.customRange,customRangeRect:e.rect,type:C.VIEWING,unitId:i,subUnitId:t,showAll:!!B})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(w.switchMap(i=>this._editorBridgeService.visible$.pipe(w.map(t=>({visible:t,state:i}))))).subscribe(({visible:i,state:t})=>{if(!t||t.editorUnitId!==o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:s,row:a,column:l}=t,d=this._renderManagerService.getRenderById(n);if(!d)return;const{editPermission:p,viewPermission:u,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:s,row:a,col:l}),I=d.with(Q.DocEventManagerService);u&&(e==null||e.unsubscribe(),e=I.hoverCustomRanges$.pipe(w.debounceTime(200)).subscribe(S=>{var k,B;const R=S.find(M=>M.range.rangeType===o.CustomRangeType.HYPERLINK);if(!R){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const T=R.rects[R.rects.length-1];if(!((B=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(L.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton)||!T)return;const c=d.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:s,row:a,col:l,customRange:R.range,customRangeRect:{left:T.left+c.left,top:T.top+c.top,bottom:T.bottom+c.top,right:T.right+c.left},editPermission:p,copyPermission:h,type:C.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(C.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(w.switchMap(e=>{const i=e===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return i?i.with(Q.DocEventManagerService).hoverCustomRanges$.pipe(w.debounceTime(200)):new w.Observable(t=>{t.next(null)})})).subscribe(e=>{const i=e==null?void 0:e.find(n=>n.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(i&&t){const{unitId:n,sheetId:r,row:s,column:a}=t,{editPermission:l,viewPermission:d,copyPermission:p}=this._getLinkPermission({unitId:n,subUnitId:r,row:s,col:a});d&&this._sheetsHyperLinkPopupService.showPopup({type:C.ZEN_EDITOR,unitId:n,subUnitId:r,row:s,col:a,customRange:i.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(C.EDITING)}))}_initCommandListener(){const e=[f.ClearSelectionContentCommand.id,f.ClearSelectionAllCommand.id,f.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{e.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=_n([W(0,o.Inject(L.HoverManagerService)),W(1,o.Inject(g.SheetsHyperLinkPopupService)),W(2,o.Inject(pe.IRenderManagerService)),W(3,o.Inject(o.IPermissionService)),W(4,o.Inject(f.SheetPermissionCheckController)),W(5,o.ICommandService),W(6,L.IEditorBridgeService),W(7,o.Inject(he.DocSelectionManagerService)),W(8,o.IUniverInstanceService),W(9,m.IZenZoneService)],Ue);var In=Object.getOwnPropertyDescriptor,vt=(e,i,t,n)=>{for(var r=n>1?void 0:n?In(i,t):i,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ze=(e,i)=>(t,n)=>i(t,n,e);let qe=class extends o.Disposable{constructor(e,i){super(),this._context=e,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(w.debounceTime(16)).subscribe(()=>{e()}))}};qe=vt([ze(1,o.Inject(_.HyperLinkModel))],qe);let He=class extends o.Disposable{constructor(e,i){super(),this._sheetInterceptorService=e,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Value,priority:100,handler:(e,i,t)=>{const{row:n,col:r,unitId:s,subUnitId:a}=i,l=this._hyperLinkModel.getHyperLinkByLocation(s,a,n,r);return t(l?{...e,linkUrl:l.payload,linkId:l.id}:e)}}))}};He=vt([ze(0,o.Inject(f.SheetInterceptorService)),ze(1,o.Inject(_.HyperLinkModel))],He);const mn={[m.RibbonStartGroup.OTHERS]:{[oe.id]:{order:2,menuItemFactory:dn},[be(oe.id)]:{order:2,menuItemFactory:un}},[m.ContextMenuPosition.MAIN_AREA]:{[m.ContextMenuGroup.OTHERS]:{order:1,[oe.id]:{order:0,menuItemFactory:cn},[be(oe.id)]:{order:0,menuItemFactory:ln}}}};var fn=Object.getOwnPropertyDescriptor,yn=(e,i,t,n)=>{for(var r=n>1?void 0:n?fn(i,t):i,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Se=(e,i)=>(t,n)=>i(t,n,e);let Ae=class extends o.Disposable{constructor(e,i,t,n,r){super(),this._componentManager=e,this._commandService=i,this._menuManagerService=t,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Re,Re.componentKey],[Fe,"LinkSingle"]].forEach(([e,i])=>{this._componentManager.register(i,e)})}_initCommands(){[ke,ve,Oe,oe].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(mn)}_initShortCut(){this._shortcutService.registerShortcut(Ye)}};Ae=yn([Se(0,o.Inject(m.ComponentManager)),Se(1,o.ICommandService),Se(2,m.IMenuManagerService),Se(3,o.Inject(o.Injector)),Se(4,o.Inject(m.IShortcutService))],Ae);var Cn=Object.getOwnPropertyDescriptor,En=(e,i,t,n)=>{for(var r=n>1?void 0:n?Cn(i,t):i,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},St=(e,i)=>(t,n)=>i(t,n,e);let Be=class extends o.Disposable{constructor(e,i){super(),this._parserService=e,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const i=this._parserService.parseHyperLink(e);this._resolverService.navigate(i)}}};Be=En([St(0,o.Inject(_.SheetsHyperLinkParserService)),St(1,o.Inject(g.SheetsHyperLinkResolverService))],Be);var Ln=Object.defineProperty,Rn=Object.getOwnPropertyDescriptor,Pn=(e,i,t)=>i in e?Ln(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t,Tn=(e,i,t,n)=>{for(var r=n>1?void 0:n?Rn(i,t):i,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},_t=(e,i)=>(t,n)=>i(t,n,e),It=(e,i,t)=>Pn(e,typeof i!="symbol"?i+"":i,t);g.UniverSheetsHyperLinkUIPlugin=class extends o.Plugin{constructor(i=rt,t,n){super(),this._config=i,this._injector=t,this._configService=n;const{menu:r,...s}=o.merge({},rt,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(it,s)}onStarting(){[[g.SheetsHyperLinkResolverService],[g.SheetsHyperLinkPopupService],[Ze],[He],[Ue],[Ae],[Ne],[g.SheetsHyperLinkCopyPasteController],[Me],[Be]].forEach(t=>this._injector.add(t)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[qe]),this._injector.get(Ne),this._injector.get(g.SheetsHyperLinkCopyPasteController),this._injector.get(Ae)}onRendered(){this._injector.get(Me),this._injector.get(Be),this._injector.get(Ue)}},It(g.UniverSheetsHyperLinkUIPlugin,"pluginName",je),It(g.UniverSheetsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkUIPlugin=Tn([o.DependentOn(_.UniverSheetsHyperLinkPlugin,Q.UniverDocsUIPlugin),_t(1,o.Inject(o.Injector)),_t(2,o.IConfigService)],g.UniverSheetsHyperLinkUIPlugin),g.CloseHyperLinkPopupOperation=ve,g.InsertHyperLinkOperation=Oe,g.InsertLinkShortcut=Ye,g.OpenHyperLinkEditPanelOperation=ke,g.SheetsHyperLinkSidePanelService=Ze,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
10
+ (function(g,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react/jsx-runtime"),require("@univerjs/sheets-formula-ui"),require("react"),require("@univerjs/sheets-data-validation")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react/jsx-runtime","@univerjs/sheets-formula-ui","react","@univerjs/sheets-data-validation"],o):(g=typeof globalThis<"u"?globalThis:g||self,o(g.UniverSheetsHyperLinkUi={},g.UniverCore,g.UniverSheets,g.UniverSheetsHyperLink,g.UniverSheetsUi,g.UniverDesign,g.UniverEngineFormula,g.UniverUi,g.UniverDocsUi,g.UniverEngineRender,g.rxjs,g.UniverDocs,g.React,g.UniverSheetsFormulaUi,g.React,g.UniverSheetsDataValidation))})(this,function(g,o,f,_,L,b,q,m,Q,pe,w,he,y,Ht,E,nt){"use strict";var Mn=Object.defineProperty;var Un=(g,o,f)=>o in g?Mn(g,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):g[o]=f;var F=(g,o,f)=>Un(g,typeof o!="symbol"?o+"":o,f);function Ee(e){return o.Tools.isLegalUrl(e)}function At(e){return/^[a-zA-Z]+:\/\//.test(e)}function Bt(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Vt(e){if(Ee(e)){const n=At(e)?e:Bt(e)?`mailto://${e}`:`http://${e}`;let t;try{t=new URL(n)}catch{return e}return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:n}return e}const it="sheets-hyper-link-ui.config",rt={};var $t=Object.getOwnPropertyDescriptor,xt=(e,n,t,i)=>{for(var r=i>1?void 0:i?$t(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ce=(e,n)=>(t,i)=>n(t,i,e);function jt(e,n){const t=n.getMergeData(),i=n.getMaxColumns()-1,r=n.getMaxRows()-1;if(i<e.endColumn&&(e.endColumn=i),r<e.endRow&&(e.endRow=r),e.rangeType===o.RANGE_TYPE.COLUMN||o.RANGE_TYPE.ROW)return e;const s=[];return t.forEach(a=>{o.Rectangle.intersects(e,a)&&s.push(a)}),o.Rectangle.realUnion(e,...s)}g.SheetsHyperLinkResolverService=class{constructor(n,t,i,r,s,a){this._univerInstanceService=n,this._commandService=t,this._definedNamesService=i,this._messageService=r,this._localeService=s,this._configService=a}navigate(n){switch(n.type){case _.SheetHyperLinkType.URL:this.navigateToOtherWebsite(n.url);break;default:this._navigateToUniver(n.searchObj)}}_navigateToUniver(n){const{gid:t,range:i,rangeid:r}=n,s=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const a=s.getUnitId();if(r){const l=this._definedNamesService.getValueById(a,r);if(!l)return;const{formulaOrRefString:d}=l,h=this._definedNamesService.getWorksheetByRef(a,d);if(!h){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:b.MessageType.Error});return}if(h.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:b.MessageType.Error});return}this.navigateToDefineName(a,r)}if(t){if(i){const l=q.deserializeRangeWithSheet(i);o.isValidRange(l.range)&&i!==_.ERROR_RANGE&&this.navigateToRange(a,t,l.range);return}this.navigateToSheetById(a,t)}}async navigateToRange(n,t,i,r){const s=await this.navigateToSheetById(n,t);if(s){const a=jt(i,s);await this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:n,subUnitId:t,selections:[{range:a,primary:null}]}),await this._commandService.executeCommand(L.ScrollToRangeOperation.id,{range:a,forceTop:r})}}async navigateToSheetById(n,t){const i=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;const r=i.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const s=i.getSheetBySheetId(t);return s?i.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:b.MessageType.Error}),!1):await this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:t})?s:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:b.MessageType.Error}),!1)}async navigateToDefineName(n,t){return this._definedNamesService.focusRange(n,t),!0}async navigateToOtherWebsite(n){var i;const t=this._configService.getConfig(it);if((i=t==null?void 0:t.urlHandler)!=null&&i.navigateToOtherWebsite)return t.urlHandler.navigateToOtherWebsite(n);window.open(n,"_blank","noopener noreferrer")}},g.SheetsHyperLinkResolverService=xt([ce(0,o.IUniverInstanceService),ce(1,o.ICommandService),ce(2,q.IDefinedNamesService),ce(3,m.IMessageService),ce(4,o.Inject(o.LocaleService)),ce(5,o.IConfigService)],g.SheetsHyperLinkResolverService);const je="SHEET_HYPER_LINK_UI_PLUGIN";var Zt=Object.getOwnPropertyDescriptor,Ft=(e,n,t,i)=>{for(var r=i>1?void 0:i?Zt(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Le=(e,n)=>(t,i)=>n(t,i,e);g.SheetsHyperLinkCopyPasteController=class extends o.Disposable{constructor(t,i,r,s){super();F(this,"_plainTextFilter",new Set);F(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=i,this._injector=r,this._resolverService=s,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(t){this._plainTextFilter.add(t)}removePlainTextFilter(t){this._plainTextFilter.delete(t)}_filterPlainText(t){return Array.from(this._plainTextFilter).every(i=>i(t))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:je,onBeforeCopy:(t,i,r)=>this._collect(t,i,r),onPasteCells:(t,i,r,s)=>{const{copyType:a=L.COPY_TYPE.COPY,pasteType:l}=s,{range:d}=t||{},{range:h,unitId:u,subUnitId:p}=i;return this._generateMutations(h,{copyType:a,pasteType:l,copyRange:d,unitId:u,subUnitId:p})},onPastePlainText:(t,i)=>{const r=this._filterPlainText(i);if(Ee(i)&&r){const{range:s,unitId:a,subUnitId:l}=t,{ranges:[d],mapFunc:h}=L.virtualizeDiscreteRanges([s]),u=[],p=[];return o.Range.foreach(d,(I,S)=>{const{row:R,col:T}=h(I,S),P=this._hyperLinkModel.getHyperLinkByLocation(a,l,R,T);P&&u.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:l,id:P.id}}),P&&p.push({id:_.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:l,link:P}})}),{redos:u,undos:p}}return{undos:[],redos:[]}},priority:99})}_collect(t,i,r){const s=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:i,matrix:s};const a=this._injector.invoke(h=>f.rangeToDiscreteRange(r,h,t,i));if(!a)return;const{rows:l,cols:d}=a;l.forEach((h,u)=>{d.forEach((p,I)=>{var R;const S=this._hyperLinkModel.getHyperLinkByLocation(t,i,h,p);s.setValue(u,I,(R=S==null?void 0:S.id)!=null?R:"")})})}_generateMutations(t,i){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!i.copyRange)return{redos:[],undos:[]};if([L.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,L.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,L.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,L.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(i.pasteType))return{redos:[],undos:[]};const{unitId:s,subUnitId:a}=this._copyInfo,l=[],d=[],{ranges:[h,u],mapFunc:p}=L.virtualizeDiscreteRanges([i.copyRange,t]);return L.getRepeatRange(h,u,!0).forEach(({startRange:S})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((T,P,c)=>{const k=o.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:P,endColumn:P},S),B=this._hyperLinkModel.getHyperLink(s,a,c),{row:M,col:U}=p(k.startRow,k.startColumn),x=this._hyperLinkModel.getHyperLinkByLocation(i.unitId,i.subUnitId,M,U),$=o.Tools.generateRandomId();x&&l.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:x.id}}),B&&(l.push({id:_.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:{...B,id:$,row:M,column:U}}}),d.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:$}})),x&&d.push({id:_.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:x}})})}),{redos:l,undos:d}}},g.SheetsHyperLinkCopyPasteController=Ft([Le(0,L.ISheetClipboardService),Le(1,o.Inject(_.HyperLinkModel)),Le(2,o.Inject(o.Injector)),Le(3,o.Inject(g.SheetsHyperLinkResolverService))],g.SheetsHyperLinkCopyPasteController);var C=(e=>(e.EDITING="editing",e.VIEWING="viewing",e.ZEN_EDITOR="zen_mode",e))(C||{});class Ze extends o.Disposable{constructor(){super(...arguments);F(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==_.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(r=>r.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:i}=this;i.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const ot={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Re=()=>{var yt;const[e,n]=E.useState(""),[t,i]=E.useState(!1),[r,s]=E.useState(""),[a,l]=E.useState(!0),[d,h]=E.useState(_.SheetHyperLinkType.URL),[u,p]=E.useState(""),I=m.useDependency(o.LocaleService),S=m.useDependency(q.IDefinedNamesService),R=m.useDependency(L.IEditorBridgeService),T=m.useDependency(o.IUniverInstanceService),P=m.useDependency(g.SheetsHyperLinkPopupService),c=m.useObservable(P.currentEditing$),k=m.useDependency(_.SheetsHyperLinkParserService),B=m.useDependency(g.SheetsHyperLinkResolverService),M=m.useDependency(o.ICommandService),U=m.useDependency(Ze),x=E.useMemo(()=>U.getOptions(),[U]),$=m.useDependency(m.IZenZoneService),X=m.useDependency(pe.IRenderManagerService),_e=m.useDependency(L.IMarkSelectionService),Ve=m.useDependency(he.DocSelectionManagerService),se=m.useDependency(o.IContextService),Ie=m.useDependency(o.ThemeService),me=m.useDependency(he.DocSelectionManagerService),[fe,$e]=E.useState(!1),le=m.useDependency(f.SheetsSelectionsService),kn=E.useMemo(()=>le.getCurrentSelections(),[]),xe=E.useMemo(()=>{if(!U.isBuiltInLinkType(d))return U.getCustomHyperLink(d)},[U,d]),[de,On]=E.useState(!1),[ye,mt]=E.useState(!1),j=E.useRef(!1),Y=T.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),Dn=(Y==null?void 0:Y.getActiveSheet().getSheetId())||"",ee=E.useCallback(v=>{s(v.replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[s]);E.useEffect(()=>{var v,O,D,N,A,G,Ct,Et,Lt,Rt,Pt,Tt,kt,Ot,Dt,bt,wt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:ae,row:et,col:tt}=c;let{label:J}=c;typeof J=="number"&&(J=`${J}`);let z;if(ae)z={id:(v=ae==null?void 0:ae.rangeId)!=null?v:"",display:J!=null?J:"",payload:(D=(O=ae==null?void 0:ae.properties)==null?void 0:O.url)!=null?D:"",row:et,column:tt};else if(c.type===C.VIEWING){const H=T.getUnit(c.unitId),ne=H==null?void 0:H.getSheetBySheetId(c.subUnitId),V=ne==null?void 0:ne.getCellRaw(c.row,c.col),ue=(G=(A=(N=V==null?void 0:V.p)==null?void 0:N.body)==null?void 0:A.customRanges)==null?void 0:G.find(Mt=>{var Ut;return Mt.rangeType===o.CustomRangeType.HYPERLINK&&((Ut=Mt.properties)==null?void 0:Ut.url)}),Ce=V==null?void 0:V.v;V&&(!o.BuildTextUtils.transform.isEmptyDocument((Et=(Ct=V.p)==null?void 0:Ct.body)==null?void 0:Et.dataStream)||o.Tools.isDefine(Ce))&&l(!1),z={id:"",display:"",payload:(Rt=(Lt=ue==null?void 0:ue.properties)==null?void 0:Lt.url)!=null?Rt:"",row:et,column:tt}}else{const H=T.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),ne=Ve.getActiveTextRange(),V=H==null?void 0:H.getBody(),ue=ne&&V?ne:null,Ce=ue&&((Tt=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ue,(Pt=V==null?void 0:V.customRanges)!=null?Pt:[]))==null?void 0:Tt[0]);l(!1),z={id:"",display:J!=null?J:"",payload:(Ot=(kt=Ce==null?void 0:Ce.properties)==null?void 0:kt.url)!=null?Ot:"",row:et,column:tt}}n(z.id);const Nt=U.findCustomHyperLink(z);if(Nt){const H=Nt.convert(z);h(H.type),p(H.payload),ee(H.display);return}ee(z.display);const te=k.parseHyperLink(z.payload);switch(h(te.type===_.SheetHyperLinkType.INVALID?_.SheetHyperLinkType.RANGE:te.type),te.type){case _.SheetHyperLinkType.URL:{p(te.url),te.url===z.display&&(j.current=!0);break}case _.SheetHyperLinkType.RANGE:{const H=te.searchObj,ne=H.gid&&(wt=(bt=(Dt=T.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:bt.getName())!=null?wt:"",V=q.serializeRangeWithSheet(ne,q.deserializeRangeWithSheet(H.range).range);p(V),V===z.display&&(j.current=!0);break}case _.SheetHyperLinkType.SHEET:{const H=te.searchObj;p(H.gid);break}case _.SheetHyperLinkType.DEFINE_NAME:{const H=te.searchObj;p(H.rangeid);break}default:p("");break}}},[c,B,U,Ve,T]),E.useEffect(()=>{let v=null;if(c&&!c.customRangeId&&c.type===C.VIEWING&&o.Tools.isDefine(c.row)&&o.Tools.isDefine(c.col)){const O=T.getUnit(c.unitId,o.UniverInstanceType.UNIVER_SHEET),D=O==null?void 0:O.getSheetBySheetId(c.subUnitId),N=D==null?void 0:D.getMergedCell(c.row,c.col),A=new o.ColorKit(Ie.getCurrentTheme().hyacinth500).toRgb();v=_e.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${A.r}, ${A.g}, ${A.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{v&&_e.removeShape(v)}},[c,_e,Ie,T]),E.useEffect(()=>{mt(d===_.SheetHyperLinkType.RANGE)},[d]),E.useEffect(()=>{const v=(c==null?void 0:c.type)===C.ZEN_EDITOR?X.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY):X.getRenderById(R.getCurrentEditorId()),O=new o.DisposableCollection;if(v){const D=v.with(Q.DocSelectionRenderService);D.setReserveRangesStatus(!0),O.add(()=>{D.setReserveRangesStatus(!1)})}return()=>{R.disableForceKeepVisible(),O.dispose()}},[c==null?void 0:c.type,R,X]),E.useEffect(()=>(ye&&P.setIsKeepVisible(ye),P.setIsKeepVisible(fe),()=>{P.setIsKeepVisible(!1)}),[ye,fe,P]),E.useEffect(()=>()=>{$.temporaryHidden&&($.show(),se.setContextValue(o.FOCUSING_SHEET,!1))},[se,$]),E.useEffect(()=>{if(ye)return R.enableForceKeepVisible(),()=>{R.disableForceKeepVisible()}},[ye,R]);const bn=[{label:I.t("hyperLink.form.link"),value:_.SheetHyperLinkType.URL},{label:I.t("hyperLink.form.range"),value:_.SheetHyperLinkType.RANGE},{label:I.t("hyperLink.form.worksheet"),value:_.SheetHyperLinkType.SHEET},{label:I.t("hyperLink.form.definedName"),value:_.SheetHyperLinkType.DEFINE_NAME},...x];if(!Y)return;const wn=Y.getHiddenWorksheets(),Xe=Y.getSheets().map(v=>({label:v.getName(),value:v.getSheetId()})).filter(v=>wn.indexOf(v.value)===-1),Je=Object.values((yt=S.getDefinedNameMap(Y.getUnitId()))!=null?yt:{}).map(v=>({label:v.name,value:v.id})),ft=(v,O)=>{if(v===_.SheetHyperLinkType.URL)return Vt(O);if(v===_.SheetHyperLinkType.RANGE){const D=q.deserializeRangeWithSheet(O),N=Y.getSheetBySheetName(D.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${q.serializeRange(D.range)}`}return`#${v}=${O}`},Nn=m.useEvent(v=>{var A;const D=v.split(",").map(q.deserializeRangeWithSheet)[0];if(!D||!o.isValidRange(D.range))return;D.sheetName||(D.sheetName=((A=Y.getActiveSheet())==null?void 0:A.getName())||"");const N=q.serializeRangeToRefString(D);p(N),N&&(j.current||!r)&&(ee(N),j.current=!0)}),Qe=async()=>{if(a&&!r||!u||d===_.SheetHyperLinkType.URL&&!Ee(u)){On(!0);return}if(c)if(e){const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?_.UpdateRichHyperLinkCommand.id:_.UpdateHyperLinkCommand.id;await M.executeCommand(v,{id:e,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:a?r:"",payload:ft(d,u)},row:c.row,column:c.col,documentId:c.type===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:R.getCurrentEditorId()})}else{const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?_.AddRichHyperLinkCommand.id:_.AddHyperLinkCommand.id;await M.executeCommand(v,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:o.generateRandomId(),row:c.row,column:c.col,payload:ft(d,u),display:a?r:""},documentId:c.type===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:R.getCurrentEditorId()})}if((c==null?void 0:c.type)===C.VIEWING){await M.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const v=1;await M.executeCommand(L.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-v,0),endRow:c.row+v,startColumn:Math.max(c.col-v,0),endColumn:c.col+v}})}M.executeCommand(ve.id)};return c?y.jsxs("div",{className:ot.cellLinkEdit,style:{display:t?"none":"block"},children:[a?y.jsx(b.FormLayout,{label:I.t("hyperLink.form.label"),error:de&&!r?I.t("hyperLink.form.inputError"):"",children:y.jsx(b.Input,{value:r,onChange:v=>{ee(v),j.current=!1},placeholder:I.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Qe()}})}):null,y.jsx(b.FormLayout,{label:I.t("hyperLink.form.type"),children:y.jsx(b.Select,{options:bn,value:d,onChange:v=>{h(v),p("")}})}),d===_.SheetHyperLinkType.URL&&y.jsx(b.FormLayout,{error:de?u?Ee(u)?"":I.t("hyperLink.form.linkError"):I.t("hyperLink.form.inputError"):"",children:y.jsx(b.Input,{value:u,onChange:v=>{p(v),v&&(j.current||!r||r===u)&&(ee(v),j.current=!0)},placeholder:I.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Qe()}})}),d===_.SheetHyperLinkType.RANGE&&y.jsx(b.FormLayout,{error:de&&!u?I.t("hyperLink.form.inputError"):"",children:y.jsx(Ht.RangeSelector,{unitId:Y.getUnitId(),subUnitId:Dn,maxRangeCount:1,supportAcrossSheet:!0,initialValue:u,resetRange:kn,onChange:(v,O)=>Nn(O),onRangeSelectorDialogVisibleChange:async v=>{var O,D;if($e(v),v)c.type===C.ZEN_EDITOR&&($.hide(),se.setContextValue(o.FOCUSING_SHEET,!0)),c.type!==C.VIEWING&&R.enableForceKeepVisible(),i(!0);else{if(await B.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===C.ZEN_EDITOR){await M.executeCommand(f.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),$.show(),se.setContextValue(o.FOCUSING_SHEET,!1);const N=(O=X.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:O.with(Q.DocBackScrollRenderController),A=(D=me.getTextRanges({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:D[0];N&&A&&(N.scrollToRange(A),me.refreshSelection({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}R.disableForceKeepVisible(),i(!1)}},onFocusChange:v=>mt(v)})}),d===_.SheetHyperLinkType.SHEET&&y.jsx(b.FormLayout,{error:de&&!u?I.t("hyperLink.form.selectError"):"",children:y.jsx(b.Select,{options:Xe,value:u,onChange:v=>{var N,A;p(v);const O=(N=Xe.find(G=>G.value===v))==null?void 0:N.label,D=(A=Xe.find(G=>G.value===u))==null?void 0:A.label;O&&(j.current||!r||r===D)&&(ee(O),j.current=!0)}})}),d===_.SheetHyperLinkType.DEFINE_NAME&&y.jsx(b.FormLayout,{error:de&&!u?I.t("hyperLink.form.selectError"):"",children:y.jsx(b.Select,{options:Je,value:u,onChange:v=>{var N,A;p(v);const O=(N=Je.find(G=>G.value===v))==null?void 0:N.label,D=(A=Je.find(G=>G.value===u))==null?void 0:A.label;O&&(j.current||!r||r===D)&&(ee(O),j.current=!0)}})}),(xe==null?void 0:xe.Form)&&y.jsx(xe.Form,{linkId:e,payload:u,display:r,showError:de,setByPayload:j,setDisplay:v=>{ee(v),j.current=!0},setPayload:p}),y.jsxs("div",{className:ot.cellLinkEditButtons,children:[y.jsx(b.Button,{onClick:()=>{c&&B.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),M.executeCommand(ve.id)},children:I.t("hyperLink.form.cancel")}),y.jsx(b.Button,{variant:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:I.t("hyperLink.form.ok")})]})]}):null};Re.componentKey="univer.sheet.cell-link-edit";var Z=function(){return Z=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Z.apply(this,arguments)},Kt=function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)n.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(t[i[r]]=e[i[r]]);return t},ie=E.forwardRef(function(e,n){var t=e.icon,i=e.id,r=e.className,s=e.extend,a=Kt(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),d=E.useRef("_".concat(Gt()));return st(t,"".concat(i),{defIds:t.defIds,idSuffix:d.current},Z({ref:n,className:l},a),s)});function st(e,n,t,i,r){return E.createElement(e.tag,Z(Z({key:n},Wt(e,t,r)),i),(Yt(e,t).children||[]).map(function(s,a){return st(s,"".concat(n,"-").concat(e.tag,"-").concat(a),t,void 0,r)}))}function Wt(e,n,t){var i=Z({},e.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1),e.tag==="mask"&&i.id&&(i.id=i.id+n.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],l=s[1];a==="mask"&&typeof l=="string"&&(i[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var r=n.defIds;return!r||r.length===0||(e.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(i[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),i}function Yt(e,n){var t,i=n.defIds;return!i||i.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?Z(Z({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?Z(Z({},r),{attrs:Z(Z({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):e}function Gt(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var zt={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=E.forwardRef(function(e,n){return E.createElement(ie,Object.assign({},e,{id:"all-border-single",ref:n,icon:zt}))});Pe.displayName="AllBorderSingle";var qt={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"}}]},at=E.forwardRef(function(e,n){return E.createElement(ie,Object.assign({},e,{id:"copy-single",ref:n,icon:qt}))});at.displayName="CopySingle";var Xt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},Fe=E.forwardRef(function(e,n){return E.createElement(ie,Object.assign({},e,{id:"link-single",ref:n,icon:Xt}))});Fe.displayName="LinkSingle";var Jt={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"}}]},ct=E.forwardRef(function(e,n){return E.createElement(ie,Object.assign({},e,{id:"unlink-single",ref:n,icon:Jt}))});ct.displayName="UnlinkSingle";var Qt={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"}}]},lt=E.forwardRef(function(e,n){return E.createElement(ie,Object.assign({},e,{id:"write-single",ref:n,icon:Qt}))});lt.displayName="WriteSingle";var en={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.4538 1.12549C2.70051 1.12549 2.08984 1.73615 2.08984 2.48945V13.5104C2.08984 14.2637 2.70051 14.8744 3.4538 14.8744H12.5468C13.3001 14.8744 13.9108 14.2637 13.9108 13.5104V5.0992L10.0094 1.12549H3.4538Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M10.0078 1.12549L13.9107 5.09842H10.6745C10.3063 5.09842 10.0078 4.79994 10.0078 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.80941 10.2949L6.37701 12.403C6.2632 12.5705 6.03516 12.614 5.86766 12.5002C5.70017 12.3864 5.65664 12.1584 5.77045 11.9909L7.36611 9.64252L5.94103 7.54519C5.82722 7.37769 5.87074 7.14964 6.03824 7.03583C6.20573 6.92202 6.43378 6.96555 6.54759 7.13304L7.80941 8.9901L9.07123 7.13304C9.18504 6.96555 9.41309 6.92202 9.58059 7.03583C9.74808 7.14964 9.7916 7.37769 9.67779 7.54519L8.25271 9.64252L9.84837 11.9909C9.96218 12.1584 9.91866 12.3864 9.75116 12.5002C9.58366 12.614 9.35562 12.5705 9.24181 12.403L7.80941 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},dt=E.forwardRef(function(e,n){return E.createElement(ie,Object.assign({},e,{id:"xlsx",ref:n,icon:en}))});dt.displayName="Xlsx";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"},tn={[_.SheetHyperLinkType.URL]:y.jsx(Fe,{}),[_.SheetHyperLinkType.SHEET]:y.jsx(dt,{}),[_.SheetHyperLinkType.RANGE]:y.jsx(Pe,{}),[_.SheetHyperLinkType.DEFINE_NAME]:y.jsx(Pe,{}),[_.SheetHyperLinkType.INVALID]:y.jsx(Pe,{})},ut=e=>{var B,M;const n=m.useDependency(g.SheetsHyperLinkPopupService),t=m.useDependency(o.ICommandService),i=m.useDependency(m.IMessageService),r=m.useDependency(o.LocaleService),s=m.useDependency(g.SheetsHyperLinkResolverService),a=m.useDependency(L.IEditorBridgeService),l=m.useDependency(_.SheetsHyperLinkParserService),d=m.useDependency(m.IZenZoneService),{customRange:h,row:u,col:p,unitId:I,subUnitId:S,editPermission:R,copyPermission:T,type:P}=e;if(!((B=h==null?void 0:h.properties)!=null&&B.url))return null;const c=l.parseHyperLink((M=h.properties.url)!=null?M:""),k=c.type===_.SheetHyperLinkType.INVALID;return y.jsxs("div",{className:K.cellLink,onClick:()=>n.hideCurrentPopup(),children:[y.jsxs("div",{className:b.clsx(K.cellLinkContent,{[K.cellLinkContentError]:k}),onClick:()=>{d.visible||k||s.navigate(c)},children:[y.jsx("div",{className:K.cellLinkType,children:tn[c.type]}),y.jsx(b.Tooltip,{showIfEllipsis:!0,title:c.name,asChild:!0,children:y.jsx("span",{className:K.cellLinkUrl,children:c.name})})]}),y.jsxs("div",{className:K.cellLinkOperations,children:[T&&y.jsx("div",{className:b.clsx(K.cellLinkOperation,{[K.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==_.SheetHyperLinkType.URL){const U=new URL(window.location.href);U.hash=c.url.slice(1),navigator.clipboard.writeText(U.href)}else navigator.clipboard.writeText(c.url);i.show({content:r.t("hyperLink.message.coped"),type:b.MessageType.Info})}},children:y.jsx(b.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:y.jsx(at,{})})}),R&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:K.cellLinkOperation,onClick:()=>{t.executeCommand(ke.id,{unitId:I,subUnitId:S,row:u,col:p,customRangeId:h.rangeId,type:P})},children:y.jsx(b.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:y.jsx(lt,{})})}),y.jsx("div",{className:K.cellLinkOperation,onClick:()=>{const U=P===C.EDITING||P===C.ZEN_EDITOR?_.CancelRichHyperLinkCommand.id:_.CancelHyperLinkCommand.id;t.syncExecuteCommand(U,{unitId:I,subUnitId:S,id:h.rangeId,row:u,column:p,documentId:P===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:a.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:y.jsx(b.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:y.jsx(ct,{})})})]})]})]})},Te=()=>{var r,s;const e=m.useDependency(g.SheetsHyperLinkPopupService),[n,t]=E.useState(null),i=m.useDependency(o.IUniverInstanceService);if(E.useEffect(()=>{t(e.currentPopup);const a=e.currentPopup$.subscribe(l=>{t(l)});return()=>{a.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){const a=i.getUnit(n.unitId,o.UniverInstanceType.UNIVER_SHEET),l=a==null?void 0:a.getSheetBySheetId(n.subUnitId),d=l==null?void 0:l.getCell(n.row,n.col),h=(s=(r=d==null?void 0:d.p)==null?void 0:r.body)==null?void 0:s.customRanges;return h!=null&&h.length?y.jsx("div",{children:h.map(u=>y.jsx(ut,{...n,customRange:u},u.rangeId))}):null}return y.jsx(ut,{...n})};Te.componentKey="univer.sheet.cell-link-popup";var nn=Object.getOwnPropertyDescriptor,rn=(e,n,t,i)=>{for(var r=i>1?void 0:i?nn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},re=(e,n)=>(t,i)=>n(t,i,e);const pt=(e,n)=>{var t,i;return e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.row===n.row&&e.col===n.col&&((t=e.customRange)==null?void 0:t.rangeId)===((i=n.customRange)==null?void 0:i.rangeId)&&e.type===n.type};g.SheetsHyperLinkPopupService=class extends o.Disposable{constructor(t,i,r,s,a,l,d){super();F(this,"_currentPopup",null);F(this,"_currentPopup$",new w.Subject);F(this,"currentPopup$",this._currentPopup$.asObservable());F(this,"_currentEditingPopup",null);F(this,"_currentEditing$",new w.BehaviorSubject(null));F(this,"currentEditing$",this._currentEditing$.asObservable());F(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=i,this._univerInstanceService=r,this._editorBridgeService=s,this._textSelectionManagerService=a,this._docCanvasPopManagerService=l,this._zenZoneService=d,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){if(this._currentPopup&&pt(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==C.ZEN_EDITOR&&this._zenZoneService.visible))return;const i=this._currentEditing$.getValue();if(i&&pt(t,i))return;const{unitId:r,subUnitId:s,row:a,col:l,customRangeRect:d,customRange:h}=t;let u;const p={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===C.EDITING){if(!h)return;u=d&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(d,p)}else if(t.type===C.ZEN_EDITOR){if(!h)return;u=this._docCanvasPopManagerService.attachPopupToRange({startOffset:h.startIndex,endOffset:h.endIndex+1,collapsed:!1},p,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)u=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,p,r,s);else{if(!h)return;u=d&&this._sheetCanvasPopManagerService.attachPopupByPosition(d,p,t)}u&&(this._currentPopup={unitId:r,subUnitId:s,disposable:u,row:a,col:l,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:h,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,i){var r,s;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||i)&&((s=(r=this._currentPopup)==null?void 0:r.disposable)==null||s.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,s,a;const t=this._editorBridgeService.isVisible().visible,i=this._editorBridgeService.getEditCellState();if(t&&i){const l=this._textSelectionManagerService.getActiveTextRange(),d=(r=i.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!d)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:d.dataStream.length-2,collapsed:d.dataStream.length-2===0,label:o.BuildTextUtils.transform.getPlainText(d.dataStream)};const h=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(a=(s=d.customRanges)==null?void 0:s.filter(I=>I.rangeType===o.CustomRangeType.HYPERLINK))!=null?a:[]);let u=l.startOffset,p=l.endOffset;return h.forEach(I=>{u=Math.min(u,I.startIndex),p=Math.max(p,I.endIndex+1)}),{startOffset:u,endOffset:p,collapsed:u===p,label:o.BuildTextUtils.transform.getPlainText(d.dataStream.slice(u,p))}}return null}get _editPopup(){return{componentKey:Re.componentKey,direction:"vertical",onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var a,l,d,h,u;const{unitId:i,subUnitId:r,type:s}=t;if(s===C.ZEN_EDITOR){const p=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(!p)return;const I=this._textSelectionManagerService.getActiveTextRange();if(!I)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(I,this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const S=(a=p.getBody())==null?void 0:a.dataStream.slice(I.startOffset,I.endOffset);this._currentEditing$.next({...t,label:S})}else if(s===C.EDITING){const p=this._getEditingRange();if(!p)return;this._textSelectionManagerService.replaceDocRanges([{...p}],{unitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const I=this._injector.get(pe.IRenderManagerService).getRenderById(o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!I)return;const S=Q.calcDocRangePositions(p,I);if(!(S!=null&&S.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.pop(),this._editPopup,i,r),this._currentEditing$.next({...t,label:(l=p==null?void 0:p.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r);const p=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),I=p==null?void 0:p.getSheetBySheetId(r),S=I==null?void 0:I.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:S!=null&&S.p?o.BuildTextUtils.transform.getPlainText((h=(d=S.p.body)==null?void 0:d.dataStream)!=null?h:""):((u=S==null?void 0:S.v)!=null?u:"").toString()})}}startEditing(t){var l,d,h,u,p,I;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:i,subUnitId:r}=t;let s,a;if(t.type===C.ZEN_EDITOR){const S=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(s=(h=(d=S==null?void 0:S.getBody())==null?void 0:d.customRanges)==null?void 0:h.find(R=>R.rangeId===t.customRangeId),a=s?(u=S==null?void 0:S.getBody())==null?void 0:u.dataStream.slice(s.startIndex,s.endIndex+1):"",!s||!a)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:s.startIndex,endOffset:s.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:s.startIndex,endOffset:s.endIndex,collapsed:!1},this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===C.EDITING){const S=L.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!S||!((p=S.rects)!=null&&p.length))return;s=S.customRange,a=S.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:s.startIndex,endOffset:s.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.rects.pop(),this._editPopup,i,r)}else{const S=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),R=S==null?void 0:S.getSheetBySheetId(r),T=R==null?void 0:R.getCellRaw(t.row,t.col),P=S==null?void 0:S.getStyles().getStyleByCell(T),c=P==null?void 0:P.tr,k=L.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!k||!((I=k.rects)!=null&&I.length))return;s=k.customRange,a=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:i,subUnitId:r,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:s,label:a})}endEditing(t){var r;if(this.getIsKeepVisible())return;const i=this._currentEditing$.getValue();i&&(!t||t===i.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},g.SheetsHyperLinkPopupService=rn([re(0,o.Inject(L.SheetCanvasPopManagerService)),re(1,o.Inject(o.Injector)),re(2,o.IUniverInstanceService),re(3,L.IEditorBridgeService),re(4,o.Inject(he.DocSelectionManagerService)),re(5,o.Inject(Q.DocCanvasPopManagerService)),re(6,m.IZenZoneService)],g.SheetsHyperLinkPopupService);var ge=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(ge||{});const on=new Set([o.DataValidationType.CHECKBOX,o.DataValidationType.LIST,o.DataValidationType.LIST_MULTIPLE]),Ke=(e,n,t,i)=>{var l,d,h,u,p;const r=n.getCell(t,i);if(r!=null&&r.f||r!=null&&r.si||(h=(d=(l=r==null?void 0:r.p)==null?void 0:l.body)==null?void 0:d.customBlocks)!=null&&h.length)return 1;const s=e.has(nt.SheetDataValidationModel)?e.get(nt.SheetDataValidationModel):null,a=s==null?void 0:s.getRuleByLocation(n.getUnitId(),n.getSheetId(),t,i);return a&&on.has(a.type)?!0:(p=(u=r==null?void 0:r.p)==null?void 0:u.drawingsOrder)!=null&&p.length?2:0},sn=e=>{const n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const t=n.getActiveSheet(),i=e.get(f.SheetsSelectionsService).getCurrentSelections();if(!i.length)return!0;const r=i[0].range.startRow,s=i[0].range.startColumn;return Ke(e,t,r,s)===1},an=e=>{const n=e.get(he.DocSelectionManagerService),t=e.get(o.IUniverInstanceService),i=n.getTextRanges();if(!(i!=null&&i.length))return!0;const r=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);return!!(!r||i.every(a=>a.collapsed)||!r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody())},ke={type:o.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,n){if(!n)return!1;const t=e.get(g.SheetsHyperLinkPopupService);return n.customRangeId?t.startEditing(n):t.startAddEditing(n),!0}},ve={type:o.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(g.SheetsHyperLinkPopupService).endEditing(),!0}},Oe={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var p;const n=e.get(o.IUniverInstanceService),t=f.getSheetCommandTarget(n),i=e.get(L.IEditorBridgeService);if(!t)return!1;const r=e.get(o.ICommandService),a=e.get(f.SheetsSelectionsService).getCurrentLastSelection();if(!a)return!1;const l=a.range.startRow,d=a.range.startColumn,h=i.isVisible(),u=((p=n.getFocusedUnit())==null?void 0:p.getUnitId())===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(ke.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:l,col:d,type:u?C.ZEN_EDITOR:h.visible?C.EDITING:C.VIEWING})}},oe={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(sn(e))return!1;const n=e.get(o.ICommandService);return e.get(g.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(ve.id):n.executeCommand(Oe.id)}},We=(e,n=o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const t=e.get(o.IUniverInstanceService),i=(r=e.get(pe.IRenderManagerService).getRenderById(n))==null?void 0:r.with(Q.DocSelectionRenderService);return i?i.textSelectionInner$.pipe(w.map(()=>{const a=e.get(L.IEditorBridgeService).getEditCellState();if(!a)return!0;const l=f.getSheetCommandTarget(t,{unitId:a.unitId,subUnitId:a.sheetId});return!(l!=null&&l.worksheet)||Ke(e,l.worksheet,a.row,a.column)===1?!0:an(e)})):w.of(!0)},ht=e=>{var r;const n=e.get(o.IUniverInstanceService),t=e.has(L.IEditorBridgeService)?e.get(L.IEditorBridgeService):null;return((r=t==null?void 0:t.currentEditCellState$.pipe(w.map(s=>{if(!s)return ge.DISABLED_BY_CELL;const a=f.getSheetCommandTarget(n,{unitId:s.unitId,subUnitId:s.sheetId});return a?Ke(e,a.worksheet,s.row,s.column):ge.DISABLED_BY_CELL}),w.switchMap(s=>{if(s===ge.DISABLED_BY_CELL)return w.of(!0);const a=t?t.visible$:w.of(null);return w.combineLatest([a,n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC)]).pipe(w.switchMap(([l,d])=>l!=null&&l.visible?(d==null?void 0:d.getUnitId())===o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?w.of(!0):We(e,o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):w.of(s!==ge.ALLOWED)))})))!=null?r:w.of(!0)).pipe(w.switchMap(s=>s?w.of(!0):L.getCurrentRangeDisable$(e,{workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},!0)))},De={commandId:Oe.id,type:m.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},be=e=>`${e}-zen-editor`,cn=e=>({...De,id:De.commandId,hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:ht(e)}),ln=e=>({...De,id:be(De.commandId),hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:We(e)}),we={tooltip:"hyperLink.form.addTitle",commandId:oe.id,type:m.MenuItemType.BUTTON,icon:"LinkSingle"},dn=e=>({...we,id:we.commandId,hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:ht(e)}),un=e=>({...we,id:be(we.commandId),hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:We(e)}),Ye={id:oe.id,binding:m.KeyCode.K|m.MetaKeys.CTRL_COMMAND,preconditions:L.whenSheetEditorFocused};var pn=Object.getOwnPropertyDescriptor,hn=(e,n,t,i)=>{for(var r=i>1?void 0:i?pn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},gt=(e,n)=>(t,i)=>n(t,i,e);let Ne=class extends o.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(i,r)=>{const{source:s,target:a,unitId:l,subUnitId:d}=i,h=L.virtualizeDiscreteRanges([s,a]),[u,p]=h.ranges,{mapFunc:I}=h,S={row:u.startRow,col:u.startColumn},R=L.getAutoFillRepeatRange(u,p),T=[],P=[];return R.forEach(c=>{const k=c.repeatStartCell,B=c.relativeRange,M={startRow:S.row,startColumn:S.col,endColumn:S.col,endRow:S.row},U={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};o.Range.foreach(B,(x,$)=>{const X=o.Rectangle.getPositionRange({startRow:x,startColumn:$,endColumn:$,endRow:x},M),{row:_e,col:Ve}=I(X.startRow,X.startColumn),se=this._hyperLinkModel.getHyperLinkByLocation(l,d,_e,Ve),Ie=o.Rectangle.getPositionRange({startRow:x,startColumn:$,endColumn:$,endRow:x},U),{row:me,col:fe}=I(Ie.startRow,Ie.startColumn),$e=o.Tools.generateRandomId(),le=this._hyperLinkModel.getHyperLinkByLocation(l,d,me,fe);le&&T.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:d,id:le.id}}),(L.APPLY_TYPE.COPY===r||L.APPLY_TYPE.SERIES===r)&&se&&(T.push({id:_.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:d,link:{...se,id:$e,row:me,column:fe}}}),P.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:d,id:$e}})),le&&P.push({id:_.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:d,link:le}})})}),{undos:P,redos:T}},t={id:je,onFillData:(i,r,s)=>s===L.APPLY_TYPE.COPY||s===L.APPLY_TYPE.ONLY_FORMAT||s===L.APPLY_TYPE.SERIES?n(i,s):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};Ne=hn([gt(0,L.IAutoFillService),gt(1,o.Inject(_.HyperLinkModel))],Ne);var gn=Object.getOwnPropertyDescriptor,vn=(e,n,t,i)=>{for(var r=i>1?void 0:i?gn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Ge=(e,n)=>(t,i)=>n(t,i,e);let Me=class extends o.Disposable{constructor(e,n,t){super(),this._localeService=e,this._commandService=n,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===Ye.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],rangeTypes:[f.RangeProtectionPermissionEditPoint],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=vn([Ge(0,o.Inject(o.LocaleService)),Ge(1,o.ICommandService),Ge(2,o.Inject(f.SheetPermissionCheckController))],Me);var Sn=Object.getOwnPropertyDescriptor,_n=(e,n,t,i)=>{for(var r=i>1?void 0:i?Sn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},W=(e,n)=>(t,i)=>n(t,i,e);let Ue=class extends o.Disposable{constructor(e,n,t,i,r,s,a,l,d,h){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=i,this._sheetPermissionCheckController=r,this._commandService=s,this._editorBridgeService=a,this._textSelectionManagerService=l,this._univerInstanceService=d,this._zenZoneService=h,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:n,subUnitId:t,row:i,col:r}=e,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET);if(!(s==null?void 0:s.getSheetBySheetId(t)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookViewPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),d=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),h=this._permissionService.composePermission([new f.WorkbookCopyPermission(n).id,new f.WorksheetCopyPermission(n,t).id]).every(u=>u.value);return{viewPermission:l,editPermission:d,copyPermission:h}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(w.debounceTime(200)).subscribe(e=>{var M,U;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:t,row:i,col:r}=e,s=this._renderManagerService.getRenderById(n);if(!s)return;const a=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),l=a==null?void 0:a.getSheetBySheetId(t);if(!l)return;if(!s.with(L.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING);return}const h=(M=s==null?void 0:s.with(L.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:M.skeleton,u=r,p=i;let I=p,S=u;h&&h.overflowCache.forValue((x,$,X)=>{o.Rectangle.contains(X,{startColumn:u,endColumn:u,startRow:p,endRow:p})&&(I=x,S=$)});const{viewPermission:R,editPermission:T,copyPermission:P}=this._getLinkPermission(e);if(!R){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(I,S),k=a.getStyles().getStyleByCell(c),B=(U=k==null?void 0:k.tr)==null?void 0:U.a;if(!B&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:I,col:S,editPermission:T,copyPermission:P,customRange:e.customRange,customRangeRect:e.rect,type:C.VIEWING,unitId:n,subUnitId:t,showAll:!!B})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(w.switchMap(n=>this._editorBridgeService.visible$.pipe(w.map(t=>({visible:t,state:n}))))).subscribe(({visible:n,state:t})=>{if(!t||t.editorUnitId!==o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING);return}const{editorUnitId:i,unitId:r,sheetId:s,row:a,column:l}=t,d=this._renderManagerService.getRenderById(i);if(!d)return;const{editPermission:h,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:r,subUnitId:s,row:a,col:l}),I=d.with(Q.DocEventManagerService);u&&(e==null||e.unsubscribe(),e=I.hoverCustomRanges$.pipe(w.debounceTime(200)).subscribe(S=>{var k,B;const R=S.find(M=>M.range.rangeType===o.CustomRangeType.HYPERLINK);if(!R){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const T=R.rects[R.rects.length-1];if(!((B=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(L.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton)||!T)return;const c=d.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:s,row:a,col:l,customRange:R.range,customRangeRect:{left:T.left+c.left,top:T.top+c.top,bottom:T.bottom+c.top,right:T.right+c.left},editPermission:h,copyPermission:p,type:C.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(C.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(w.switchMap(e=>{const n=e===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(Q.DocEventManagerService).hoverCustomRanges$.pipe(w.debounceTime(200)):new w.Observable(t=>{t.next(null)})})).subscribe(e=>{const n=e==null?void 0:e.find(i=>i.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(n&&t){const{unitId:i,sheetId:r,row:s,column:a}=t,{editPermission:l,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:i,subUnitId:r,row:s,col:a});d&&this._sheetsHyperLinkPopupService.showPopup({type:C.ZEN_EDITOR,unitId:i,subUnitId:r,row:s,col:a,customRange:n.range,editPermission:l,copyPermission:h})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(C.EDITING)}))}_initCommandListener(){const e=[f.ClearSelectionContentCommand.id,f.ClearSelectionAllCommand.id,f.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{e.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=_n([W(0,o.Inject(L.HoverManagerService)),W(1,o.Inject(g.SheetsHyperLinkPopupService)),W(2,o.Inject(pe.IRenderManagerService)),W(3,o.Inject(o.IPermissionService)),W(4,o.Inject(f.SheetPermissionCheckController)),W(5,o.ICommandService),W(6,L.IEditorBridgeService),W(7,o.Inject(he.DocSelectionManagerService)),W(8,o.IUniverInstanceService),W(9,m.IZenZoneService)],Ue);var In=Object.getOwnPropertyDescriptor,vt=(e,n,t,i)=>{for(var r=i>1?void 0:i?In(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ze=(e,n)=>(t,i)=>n(t,i,e);let qe=class extends o.Disposable{constructor(e,n){super(),this._context=e,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(w.debounceTime(16)).subscribe(()=>{e()}))}};qe=vt([ze(1,o.Inject(_.HyperLinkModel))],qe);let He=class extends o.Disposable{constructor(e,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Value,priority:100,handler:(e,n,t)=>{const{row:i,col:r,unitId:s,subUnitId:a}=n,l=this._hyperLinkModel.getHyperLinkByLocation(s,a,i,r);return t(l?{...e,linkUrl:l.payload,linkId:l.id}:e)}}))}};He=vt([ze(0,o.Inject(f.SheetInterceptorService)),ze(1,o.Inject(_.HyperLinkModel))],He);const mn={[m.RibbonStartGroup.OTHERS]:{[oe.id]:{order:2,menuItemFactory:dn},[be(oe.id)]:{order:2,menuItemFactory:un}},[m.ContextMenuPosition.MAIN_AREA]:{[m.ContextMenuGroup.OTHERS]:{order:1,[oe.id]:{order:0,menuItemFactory:cn},[be(oe.id)]:{order:0,menuItemFactory:ln}}}};var fn=Object.getOwnPropertyDescriptor,yn=(e,n,t,i)=>{for(var r=i>1?void 0:i?fn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Se=(e,n)=>(t,i)=>n(t,i,e);let Ae=class extends o.Disposable{constructor(e,n,t,i,r){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._injector=i,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Re,Re.componentKey],[Fe,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[ke,ve,Oe,oe].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(mn)}_initShortCut(){this._shortcutService.registerShortcut(Ye)}};Ae=yn([Se(0,o.Inject(m.ComponentManager)),Se(1,o.ICommandService),Se(2,m.IMenuManagerService),Se(3,o.Inject(o.Injector)),Se(4,o.Inject(m.IShortcutService))],Ae);var Cn=Object.getOwnPropertyDescriptor,En=(e,n,t,i)=>{for(var r=i>1?void 0:i?Cn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},St=(e,n)=>(t,i)=>n(t,i,e);let Be=class extends o.Disposable{constructor(e,n){super(),this._parserService=e,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const n=this._parserService.parseHyperLink(e);this._resolverService.navigate(n)}}};Be=En([St(0,o.Inject(_.SheetsHyperLinkParserService)),St(1,o.Inject(g.SheetsHyperLinkResolverService))],Be);var Ln=Object.defineProperty,Rn=Object.getOwnPropertyDescriptor,Pn=(e,n,t)=>n in e?Ln(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Tn=(e,n,t,i)=>{for(var r=i>1?void 0:i?Rn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},_t=(e,n)=>(t,i)=>n(t,i,e),It=(e,n,t)=>Pn(e,typeof n!="symbol"?n+"":n,t);g.UniverSheetsHyperLinkUIPlugin=class extends o.Plugin{constructor(n=rt,t,i){super(),this._config=n,this._injector=t,this._configService=i;const{menu:r,...s}=o.merge({},rt,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(it,s)}onStarting(){[[g.SheetsHyperLinkResolverService],[g.SheetsHyperLinkPopupService],[Ze],[He],[Ue],[Ae],[Ne],[g.SheetsHyperLinkCopyPasteController],[Me],[Be]].forEach(t=>this._injector.add(t)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[qe]),this._injector.get(Ne),this._injector.get(g.SheetsHyperLinkCopyPasteController),this._injector.get(Ae)}onRendered(){this._injector.get(Me),this._injector.get(Be),this._injector.get(Ue)}},It(g.UniverSheetsHyperLinkUIPlugin,"pluginName",je),It(g.UniverSheetsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkUIPlugin=Tn([o.DependentOn(_.UniverSheetsHyperLinkPlugin,Q.UniverDocsUIPlugin),_t(1,o.Inject(o.Injector)),_t(2,o.IConfigService)],g.UniverSheetsHyperLinkUIPlugin),g.CloseHyperLinkPopupOperation=ve,g.InsertHyperLinkOperation=Oe,g.InsertLinkShortcut=Ye,g.OpenHyperLinkEditPanelOperation=ke,g.SheetsHyperLinkSidePanelService=Ze,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
11
11
 
12
12
 
13
13
  // @univerjs/sheets-hyper-link-ui/facade
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-hyper-link",
3
- "version": "0.6.10-nightly.202504161609",
3
+ "version": "0.6.10-nightly.202504181606",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,15 +57,15 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/sheets-hyper-link": "0.6.10-nightly.202504161609",
61
- "@univerjs/sheets-hyper-link-ui": "0.6.10-nightly.202504161609"
60
+ "@univerjs/sheets-hyper-link": "0.6.10-nightly.202504181606",
61
+ "@univerjs/sheets-hyper-link-ui": "0.6.10-nightly.202504181606"
62
62
  },
63
63
  "devDependencies": {
64
- "@univerjs/core": "0.6.10-nightly.202504161609",
64
+ "@univerjs/core": "0.6.10-nightly.202504181606",
65
65
  "react": "18.3.1",
66
66
  "react-dom": "18.3.1",
67
67
  "typescript": "^5.8.2",
68
- "@univerjs-infra/shared": "0.6.10-alpha.0"
68
+ "@univerjs-infra/shared": "0.6.10"
69
69
  },
70
70
  "scripts": {
71
71
  "prebuild:preset": "tsx prepare.ts",