@univerjs/sheets-hyper-link-ui 0.5.0-alpha.0 → 0.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +586 -581
- package/lib/types/controllers/menu.d.ts +1 -5
- package/lib/types/services/popup.service.d.ts +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +16 -16
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Vt=Object.defineProperty;var Ft=(t,n,e)=>n in t?Vt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var Z=(t,n,e)=>Ft(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),
|
|
1
|
+
"use strict";var Vt=Object.defineProperty;var Ft=(t,n,e)=>n in t?Vt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var Z=(t,n,e)=>Ft(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),_=require("@univerjs/sheets-hyper-link"),f=require("@univerjs/sheets-ui"),w=require("@univerjs/design"),X=require("@univerjs/engine-formula"),E=require("@univerjs/sheets"),b=require("@univerjs/ui"),te=require("@univerjs/docs-ui"),fe=require("@univerjs/engine-render"),R=require("rxjs"),me=require("@univerjs/docs"),y=require("react"),Zt=require("@univerjs/sheets-formula-ui");function Re(t){return s.Tools.isLegalUrl(t)}function Kt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Wt(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function Yt(t){if(Re(t)){const n=Kt(t)?t:Wt(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(n)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:n}return t}const Et="sheets-hyper-link-ui.config",Gt={};var zt=Object.defineProperty,qt=Object.getOwnPropertyDescriptor,Xt=(t,n,e,r)=>{for(var i=r>1?void 0:r?qt(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&zt(n,e,i),i},ue=(t,n)=>(e,r)=>n(e,r,t);function Jt(t,n){const e=n.getMergeData(),r=n.getMaxColumns()-1,i=n.getMaxRows()-1;if(r<t.endColumn&&(t.endColumn=r),i<t.endRow&&(t.endRow=i),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const c=[];return e.forEach(o=>{s.Rectangle.intersects(t,o)&&c.push(o)}),s.Rectangle.realUnion(t,...c)}exports.SheetsHyperLinkResolverService=class{constructor(n,e,r,i,c,o){this._univerInstanceService=n,this._commandService=e,this._definedNamesService=r,this._messageService=i,this._localeService=c,this._configService=o}navigate(n){switch(n.type){case _.SheetHyperLinkType.URL:this.navigateToOtherWebsite(n.url);break;default:this._navigateToUniver(n.searchObj)}}_navigateToUniver(n){const{gid:e,range:r,rangeid:i}=n,c=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!c)return;const o=c.getUnitId();if(i){const l=this._definedNamesService.getValueById(o,i);if(!l)return;const{formulaOrRefString:u}=l,d=this._definedNamesService.getWorksheetByRef(o,u);if(!d){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:w.MessageType.Error});return}if(d.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error});return}this.navigateToDefineName(o,i)}if(e){if(r){const l=X.deserializeRangeWithSheet(r);s.isValidRange(l.range)&&r!==_.ERROR_RANGE&&this.navigateToRange(o,e,l.range);return}this.navigateToSheetById(o,e)}}async navigateToRange(n,e,r,i){const c=await this.navigateToSheetById(n,e);if(c){const o=Jt(r,c);await this._commandService.executeCommand(E.SetSelectionsOperation.id,{unitId:n,subUnitId:e,selections:[{range:o}]}),await this._commandService.executeCommand(f.ScrollToRangeOperation.id,{range:o,forceTop:i})}}async navigateToSheetById(n,e){const r=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!r)return!1;const i=r.getActiveSheet();if(!i)return!1;if(i.getSheetId()===e)return i;const c=r.getSheetBySheetId(e);return c?r.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error}),!1):await this._commandService.executeCommand(E.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:e})?c:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:w.MessageType.Error}),!1)}async navigateToDefineName(n,e){return this._definedNamesService.focusRange(n,e),!0}async navigateToOtherWebsite(n){var r;const e=this._configService.getConfig(Et);if((r=e==null?void 0:e.urlHandler)!=null&&r.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(n);window.open(n,"_blank","noopener noreferrer")}};exports.SheetsHyperLinkResolverService=Xt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,X.IDefinedNamesService),ue(3,b.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],exports.SheetsHyperLinkResolverService);const Ge="SHEET_HYPER_LINK_UI_PLUGIN";var Qt=Object.defineProperty,en=Object.getOwnPropertyDescriptor,tn=(t,n,e,r)=>{for(var i=r>1?void 0:r?en(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Qt(n,e,i),i},Ce=(t,n)=>(e,r)=>n(e,r,t);exports.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,r,i,c){super();Z(this,"_plainTextFilter",new Set);Z(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=r,this._injector=i,this._resolverService=c,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(r=>r(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ge,onBeforeCopy:(e,r,i)=>this._collect(e,r,i),onPasteCells:(e,r,i,c)=>{const{copyType:o=f.COPY_TYPE.COPY,pasteType:l}=c,{range:u}=e||{},{range:d,unitId:p,subUnitId:h}=r;return this._generateMutations(d,{copyType:o,pasteType:l,copyRange:u,unitId:p,subUnitId:h})},onPastePlainText:(e,r)=>{const i=this._filterPlainText(r);if(Re(r)&&i){const{range:c,unitId:o,subUnitId:l}=e,{ranges:[u],mapFunc:d}=f.virtualizeDiscreteRanges([c]),p=[],h=[];return s.Range.foreach(u,(S,g)=>{const{row:C,col:L}=d(S,g),T=this._hyperLinkModel.getHyperLinkByLocation(o,l,C,L);T&&p.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:l,id:T.id}}),T&&h.push({id:_.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:l,link:T}})}),{redos:p,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,r,i){const c=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:r,matrix:c};const o=this._injector.invoke(d=>f.rangeToDiscreteRange(i,d,e,r));if(!o)return;const{rows:l,cols:u}=o;l.forEach((d,p)=>{u.forEach((h,S)=>{var C;const g=this._hyperLinkModel.getHyperLinkByLocation(e,r,d,h);c.setValue(p,S,(C=g==null?void 0:g.id)!=null?C:"")})})}_generateMutations(e,r){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{unitId:i,subUnitId:c}=this._copyInfo,o=[],l=[],{ranges:[u,d],mapFunc:p}=f.virtualizeDiscreteRanges([r.copyRange,e]);return f.getRepeatRange(u,d,!0).forEach(({startRange:S})=>{var g;(g=this._copyInfo)==null||g.matrix.forValue((C,L,T)=>{const a=s.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:L,endColumn:L},S),k=this._hyperLinkModel.getHyperLink(i,c,T),{row:x,col:N}=p(a.startRow,a.startColumn),H=this._hyperLinkModel.getHyperLinkByLocation(r.unitId,r.subUnitId,x,N),V=s.Tools.generateRandomId();H&&o.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,id:H.id}}),k&&(o.push({id:_.AddHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,link:{...k,id:V,row:x,column:N}}}),l.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,id:V}})),H&&l.push({id:_.AddHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,link:H}})})}),{redos:o,undos:l}}};exports.SheetsHyperLinkCopyPasteController=tn([Ce(0,f.ISheetClipboardService),Ce(1,s.Inject(_.HyperLinkModel)),Ce(2,s.Inject(s.Injector)),Ce(3,s.Inject(exports.SheetsHyperLinkResolverService))],exports.SheetsHyperLinkCopyPasteController);var I=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(I||{}),Rt={exports:{}},Me={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var nn=y,rn=Symbol.for("react.element"),sn=Symbol.for("react.fragment"),on=Object.prototype.hasOwnProperty,cn=nn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,an={key:!0,ref:!0,__self:!0,__source:!0};function Lt(t,n,e){var r,i={},c=null,o=null;e!==void 0&&(c=""+e),n.key!==void 0&&(c=""+n.key),n.ref!==void 0&&(o=n.ref);for(r in n)on.call(n,r)&&!an.hasOwnProperty(r)&&(i[r]=n[r]);if(t&&t.defaultProps)for(r in n=t.defaultProps,n)i[r]===void 0&&(i[r]=n[r]);return{$$typeof:rn,type:t,key:c,ref:o,props:i,_owner:cn.current}}Me.Fragment=sn;Me.jsx=Lt;Me.jsxs=Lt;Rt.exports=Me;var _=Rt.exports;class ze extends s.Disposable{constructor(){super(...arguments);Z(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==S.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(i=>i.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:r}=this;r.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const ln="univer-cell-link-edit",un="univer-cell-link-edit-buttons",St={cellLinkEdit:ln,cellLinkEditButtons:un},Re=()=>{var tt;const[t,n]=y.useState(""),[e,r]=y.useState(!1),[i,c]=y.useState(""),[o,l]=y.useState(!0),[u,d]=y.useState(S.SheetHyperLinkType.URL),[p,h]=y.useState(""),m=s.useDependency(s.LocaleService),g=s.useDependency(X.IDefinedNamesService),C=s.useDependency(f.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),T=s.useDependency(exports.SheetsHyperLinkPopupService),a=O.useObservable(T.currentEditing$),k=s.useDependency(S.SheetsHyperLinkParserService),x=s.useDependency(exports.SheetsHyperLinkResolverService),N=s.useDependency(s.ICommandService),H=s.useDependency(ze),V=y.useMemo(()=>H.getOptions(),[H]),$=s.useDependency(O.IZenZoneService),te=s.useDependency(Ue.IRenderManagerService),pe=s.useDependency(f.IMarkSelectionService),fe=s.useDependency(_e.DocSelectionManagerService),ne=s.useDependency(s.IContextService),de=s.useDependency(s.ThemeService),he=s.useDependency(_e.DocSelectionManagerService),ge=y.useRef({}),re=y.useMemo(()=>{if(!H.isBuiltInLinkType(u))return H.getCustomHyperLink(u)},[H,u]),[F,Mt]=y.useState(!1),[ve,Be]=y.useState(!1),B=y.useRef(!1),K=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),xt=(K==null?void 0:K.getActiveSheet().getSheetId())||"",J=y.useCallback(v=>{c(v.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[c]);y.useEffect(()=>{var v,b,P,D,M,W,nt,rt,it,st,ot,ct,at,lt,ut,pt,dt;if((a==null?void 0:a.row)!==void 0&&a.col!==void 0){const{customRange:ie,row:Fe,col:Ze}=a;let{label:q}=a;typeof q=="number"&&(q=`${q}`);let G;if(ie)G={id:(v=ie==null?void 0:ie.rangeId)!=null?v:"",display:q!=null?q:"",payload:(P=(b=ie==null?void 0:ie.properties)==null?void 0:b.url)!=null?P:"",row:Fe,column:Ze};else if(a.type===I.VIEWING){const U=L.getUnit(a.unitId),ee=U==null?void 0:U.getSheetBySheetId(a.subUnitId),j=ee==null?void 0:ee.getCellRaw(a.row,a.col),le=(W=(M=(D=j==null?void 0:j.p)==null?void 0:D.body)==null?void 0:M.customRanges)==null?void 0:W.find(gt=>{var vt;return gt.rangeType===s.CustomRangeType.HYPERLINK&&((vt=gt.properties)==null?void 0:vt.url)}),Se=j==null?void 0:j.v;j&&(!s.BuildTextUtils.transform.isEmptyDocument((rt=(nt=j.p)==null?void 0:nt.body)==null?void 0:rt.dataStream)||s.Tools.isDefine(Se))&&l(!1),G={id:"",display:"",payload:(st=(it=le==null?void 0:le.properties)==null?void 0:it.url)!=null?st:"",row:Fe,column:Ze}}else{const U=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ee=fe.getActiveTextRange(),j=U==null?void 0:U.getBody(),le=ee&&j?ee:null,Se=le&&((ct=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(le,(ot=j==null?void 0:j.customRanges)!=null?ot:[]))==null?void 0:ct[0]);l(!1),G={id:"",display:q!=null?q:"",payload:(lt=(at=Se==null?void 0:Se.properties)==null?void 0:at.url)!=null?lt:"",row:Fe,column:Ze}}n(G.id);const ht=H.findCustomHyperLink(G);if(ht){const U=ht.convert(G);d(U.type),h(U.payload),J(U.display);return}J(G.display);const Q=k.parseHyperLink(G.payload);switch(d(Q.type===S.SheetHyperLinkType.INVALID?S.SheetHyperLinkType.RANGE:Q.type),Q.type){case S.SheetHyperLinkType.URL:{h(Q.url),Q.url===G.display&&(B.current=!0);break}case S.SheetHyperLinkType.RANGE:{const U=Q.searchObj,ee=U.gid&&(dt=(pt=(ut=L.getUnit(a.unitId))==null?void 0:ut.getSheetBySheetId(U.gid))==null?void 0:pt.getName())!=null?dt:"",j=X.serializeRangeWithSheet(ee,X.deserializeRangeWithSheet(U.range).range);h(j),j===G.display&&(B.current=!0);break}case S.SheetHyperLinkType.SHEET:{const U=Q.searchObj;h(U.gid);break}case S.SheetHyperLinkType.DEFINE_NAME:{const U=Q.searchObj;h(U.rangeid);break}default:h("");break}}},[a,x,H,fe,L]),y.useEffect(()=>{let v=null;if(a&&!a.customRangeId&&a.type===I.VIEWING&&s.Tools.isDefine(a.row)&&s.Tools.isDefine(a.col)){const b=L.getUnit(a.unitId,s.UniverInstanceType.UNIVER_SHEET),P=b==null?void 0:b.getSheetBySheetId(a.subUnitId),D=P==null?void 0:P.getMergedCell(a.row,a.col),M=new s.ColorKit(de.getCurrentTheme().hyacinth500).toRgb();v=pe.addShape({range:D!=null?D:{startColumn:a.col,endColumn:a.col,startRow:a.row,endRow:a.row},style:{hasAutoFill:!1,fill:`rgb(${M.r}, ${M.g}, ${M.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{v&&pe.removeShape(v)}},[a,pe,de,L]),y.useEffect(()=>{Be(u===S.SheetHyperLinkType.RANGE)},[u]),y.useEffect(()=>{const v=(a==null?void 0:a.type)===I.ZEN_EDITOR?te.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):te.getRenderById(C.getCurrentEditorId()),b=new s.DisposableCollection;if(v){const P=v.with(ce.DocSelectionRenderService);P.setReserveRangesStatus(!0),b.add(()=>{P.setReserveRangesStatus(!1)})}return()=>{C.disableForceKeepVisible(),b.dispose()}},[a==null?void 0:a.type,C,te]),y.useEffect(()=>(T.setIsKeepVisible(ve),()=>{T.setIsKeepVisible(!1)}),[ve,T]),y.useEffect(()=>()=>{$.temporaryHidden&&($.show(),ne.setContextValue(s.FOCUSING_SHEET,!1))},[ne,$]),y.useEffect(()=>{if(ve)return C.enableForceKeepVisible(),()=>{C.disableForceKeepVisible()}},[ve,C]);const jt=[{label:m.t("hyperLink.form.link"),value:S.SheetHyperLinkType.URL},{label:m.t("hyperLink.form.range"),value:S.SheetHyperLinkType.RANGE},{label:m.t("hyperLink.form.worksheet"),value:S.SheetHyperLinkType.SHEET},{label:m.t("hyperLink.form.definedName"),value:S.SheetHyperLinkType.DEFINE_NAME},...V];if(!K)return;const Bt=K.getHiddenWorksheets(),$e=K.getSheets().map(v=>({label:v.getName(),value:v.getSheetId()})).filter(v=>Bt.indexOf(v.value)===-1),Ae=Object.values((tt=g.getDefinedNameMap(K.getUnitId()))!=null?tt:{}).map(v=>({label:v.name,value:v.id})),et=(v,b)=>{if(v===S.SheetHyperLinkType.URL)return Gt(b);if(v===S.SheetHyperLinkType.RANGE){const P=X.deserializeRangeWithSheet(b),D=K.getSheetBySheetName(P.sheetName);if(D)return`#gid=${D.getSheetId()}&range=${X.serializeRange(P.range)}`}return`#${v}=${b}`},$t=O.useEvent(v=>{var M;const P=v.split(",").map(X.deserializeRangeWithSheet)[0];if(!P||!s.isValidRange(P.range))return;P.sheetName||(P.sheetName=((M=K.getActiveSheet())==null?void 0:M.getName())||"");const D=X.serializeRangeToRefString(P);h(D),D&&(B.current||!i)&&(J(D),B.current=!0)}),Ve=async()=>{if(o&&!i||!p||u===S.SheetHyperLinkType.URL&&!Ee(p)){Mt(!0);return}if(a)if(t){const v=a.type===I.ZEN_EDITOR||a.type===I.EDITING?S.UpdateRichHyperLinkCommand.id:S.UpdateHyperLinkCommand.id;await N.executeCommand(v,{id:t,unitId:a.unitId,subUnitId:a.subUnitId,payload:{display:o?i:"",payload:et(u,p)},row:a.row,column:a.col,documentId:a.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:C.getCurrentEditorId()})}else{const v=a.type===I.ZEN_EDITOR||a.type===I.EDITING?S.AddRichHyperLinkCommand.id:S.AddHyperLinkCommand.id;await N.executeCommand(v,{unitId:a.unitId,subUnitId:a.subUnitId,link:{id:s.generateRandomId(),row:a.row,column:a.col,payload:et(u,p),display:o?i:""},documentId:a.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:C.getCurrentEditorId()})}if((a==null?void 0:a.type)===I.VIEWING){await N.executeCommand(E.SetWorksheetActiveOperation.id,{unitId:a.unitId,subUnitId:a.subUnitId});const v=1;await N.executeCommand(f.ScrollToRangeOperation.id,{range:{startRow:Math.max(a.row-v,0),endRow:a.row+v,startColumn:Math.max(a.col-v,0),endColumn:a.col+v}})}N.executeCommand(Ie.id)},At=v=>{var P;if(u!==S.SheetHyperLinkType.RANGE)return;const b=(P=ge.current)==null?void 0:P.handleOutClick;b&&b(v,()=>Be(!1))};return a?_.jsxs("div",{className:St.cellLinkEdit,style:{display:e?"none":"block"},onClick:At,children:[o?_.jsx(w.FormLayout,{label:m.t("hyperLink.form.label"),error:F&&!i?m.t("hyperLink.form.inputError"):"",children:_.jsx(w.Input,{value:i,onChange:v=>{J(v),B.current=!1},placeholder:m.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===O.KeyCode.ENTER&&Ve()}})}):null,_.jsx(w.FormLayout,{label:m.t("hyperLink.form.type"),children:_.jsx(w.Select,{options:jt,value:u,onChange:v=>{d(v),h("")}})}),u===S.SheetHyperLinkType.URL&&_.jsx(w.FormLayout,{error:F?p?Ee(p)?"":m.t("hyperLink.form.linkError"):m.t("hyperLink.form.inputError"):"",children:_.jsx(w.Input,{value:p,onChange:v=>{h(v),v&&(B.current||!i||i===p)&&(J(v),B.current=!0)},placeholder:m.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===O.KeyCode.ENTER&&Ve()}})}),u===S.SheetHyperLinkType.RANGE&&_.jsx(w.FormLayout,{error:F&&!p?m.t("hyperLink.form.inputError"):"",children:_.jsx(Zt.RangeSelector,{unitId:K.getUnitId(),subUnitId:xt,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:p,onChange:$t,isFocus:ve,onFocus:()=>Be(!0),actions:ge.current,onRangeSelectorDialogVisibleChange:async v=>{var b,P;if(v)a.type===I.ZEN_EDITOR&&($.hide(),ne.setContextValue(s.FOCUSING_SHEET,!0)),a.type!==I.VIEWING&&C.enableForceKeepVisible(),r(!0);else{if(await x.navigateToRange(a.unitId,a.subUnitId,{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col},!0),a.type===I.ZEN_EDITOR){await N.executeCommand(E.SetSelectionsOperation.id,{unitId:a.unitId,subUnitId:a.subUnitId,selections:[{range:{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col}}]}),$.show(),ne.setContextValue(s.FOCUSING_SHEET,!1);const D=(b=te.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(ce.DocBackScrollRenderController),M=(P=he.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:P[0];D&&M&&(D.scrollToRange(M),he.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}C.disableForceKeepVisible(),r(!1)}}})}),u===S.SheetHyperLinkType.SHEET&&_.jsx(w.FormLayout,{error:F&&!p?m.t("hyperLink.form.selectError"):"",children:_.jsx(w.Select,{options:$e,value:p,onChange:v=>{var D,M;h(v);const b=(D=$e.find(W=>W.value===v))==null?void 0:D.label,P=(M=$e.find(W=>W.value===p))==null?void 0:M.label;b&&(B.current||!i||i===P)&&(J(b),B.current=!0)}})}),u===S.SheetHyperLinkType.DEFINE_NAME&&_.jsx(w.FormLayout,{error:F&&!p?m.t("hyperLink.form.selectError"):"",children:_.jsx(w.Select,{options:Ae,value:p,onChange:v=>{var D,M;h(v);const b=(D=Ae.find(W=>W.value===v))==null?void 0:D.label,P=(M=Ae.find(W=>W.value===p))==null?void 0:M.label;b&&(B.current||!i||i===P)&&(J(b),B.current=!0)}})}),(re==null?void 0:re.Form)&&_.jsx(re.Form,{linkId:t,payload:p,display:i,showError:F,setByPayload:B,setDisplay:v=>{J(v),B.current=!0},setPayload:h}),_.jsxs("div",{className:St.cellLinkEditButtons,children:[_.jsx(w.Button,{onClick:()=>{a&&x.navigateToRange(a.unitId,a.subUnitId,{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col},!0),N.executeCommand(Ie.id)},children:m.t("hyperLink.form.cancel")}),_.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Ve()},children:m.t("hyperLink.form.ok")})]})]}):null};Re.componentKey="univer.sheet.cell-link-edit";var A=function(){return A=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++){n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},A.apply(this,arguments)},pn=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]]);return e},ae=y.forwardRef(function(t,n){var e=t.icon,r=t.id,i=t.className,c=t.extend,o=pn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),u=y.useRef("_".concat(gn()));return Pt(e,"".concat(r),{defIds:e.defIds,idSuffix:u.current},A({ref:n,className:l},o),c)});function Pt(t,n,e,r,i){return y.createElement(t.tag,A(A({key:n},dn(t,e,i)),r),(hn(t,e).children||[]).map(function(c,o){return Pt(c,"".concat(n,"-").concat(t.tag,"-").concat(o),e,void 0,i)}))}function dn(t,n,e){var r=A({},t.attrs);e!=null&&e.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=e.colorChannel1);var i=n.defIds;return!i||i.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+n.idSuffix),Object.entries(r).forEach(function(c){var o=c[0],l=c[1];typeof l=="string"&&(r[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),r}function hn(t,n){var e,r=n.defIds;return!r||r.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?A(A({},t),{children:t.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?A(A({},i),{attrs:A(A({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):t}function gn(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var vn={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"}}]},Ce=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"all-border-single",ref:n,icon:vn}))});Ce.displayName="AllBorderSingle";var Sn={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"}}]},Tt=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"copy-single",ref:n,icon:Sn}))});Tt.displayName="CopySingle";var mn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},qe=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"link-single",ref:n,icon:mn}))});qe.displayName="LinkSingle";var _n={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"}}]},kt=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"unlink-single",ref:n,icon:_n}))});kt.displayName="UnlinkSingle";var In={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"}}]},Ot=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"write-single",ref:n,icon:In}))});Ot.displayName="WriteSingle";var fn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},bt=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"xlsx",ref:n,icon:fn}))});bt.displayName="Xlsx";function Dt(t){var n,e,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(n=0;n<i;n++)t[n]&&(e=Dt(t[n]))&&(r&&(r+=" "),r+=e)}else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function mt(){for(var t,n,e=0,r="",i=arguments.length;e<i;e++)(t=arguments[e])&&(n=Dt(t))&&(r&&(r+=" "),r+=n);return r}const yn="univer-cell-link",Cn="univer-cell-link-type",En="univer-cell-link-content",Rn="univer-cell-link-content-error",Ln="univer-cell-link-url",Pn="univer-cell-link-operations",Tn="univer-cell-link-operation",kn="univer-cell-link-operation-error",Y={cellLink:yn,cellLinkType:Cn,cellLinkContent:En,cellLinkContentError:Rn,cellLinkUrl:Ln,cellLinkOperations:Pn,cellLinkOperation:Tn,cellLinkOperationError:kn},On={[S.SheetHyperLinkType.URL]:_.jsx(qe,{}),[S.SheetHyperLinkType.SHEET]:_.jsx(bt,{}),[S.SheetHyperLinkType.RANGE]:_.jsx(Ce,{}),[S.SheetHyperLinkType.DEFINE_NAME]:_.jsx(Ce,{}),[S.SheetHyperLinkType.INVALID]:_.jsx(Ce,{})},_t=t=>{var x,N;const n=s.useDependency(exports.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),r=s.useDependency(O.IMessageService),i=s.useDependency(s.LocaleService),c=s.useDependency(exports.SheetsHyperLinkResolverService),o=s.useDependency(f.IEditorBridgeService),l=s.useDependency(S.SheetsHyperLinkParserService),u=s.useDependency(O.IZenZoneService),{customRange:d,row:p,col:h,unitId:m,subUnitId:g,editPermission:C,copyPermission:L,type:T}=t;if(!((x=d==null?void 0:d.properties)!=null&&x.url))return null;const a=l.parseHyperLink((N=d.properties.url)!=null?N:""),k=a.type===S.SheetHyperLinkType.INVALID;return _.jsxs("div",{className:Y.cellLink,onClick:()=>n.hideCurrentPopup(),children:[_.jsxs("div",{className:mt(Y.cellLinkContent,{[Y.cellLinkContentError]:k}),onClick:()=>{u.visible||k||c.navigate(a)},children:[_.jsx("div",{className:Y.cellLinkType,children:On[a.type]}),_.jsx(w.Tooltip,{showIfEllipsis:!0,title:a.name,children:_.jsx("span",{className:Y.cellLinkUrl,children:a.name})})]}),_.jsxs("div",{className:Y.cellLinkOperations,children:[L&&_.jsx("div",{className:mt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(a.type!==S.SheetHyperLinkType.URL){const H=new URL(window.location.href);H.hash=a.url.slice(1),navigator.clipboard.writeText(H.href)}else navigator.clipboard.writeText(a.url);r.show({content:i.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:_.jsx(w.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.copy"),children:_.jsx(Tt,{})})}),C&&_.jsxs(_.Fragment,{children:[_.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{e.executeCommand(xe.id,{unitId:m,subUnitId:g,row:p,col:h,customRangeId:d.rangeId,type:T})},children:_.jsx(w.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.edit"),children:_.jsx(Ot,{})})}),_.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const H=T===I.EDITING||T===I.ZEN_EDITOR?S.CancelRichHyperLinkCommand.id:S.CancelHyperLinkCommand.id;e.syncExecuteCommand(H,{unitId:m,subUnitId:g,id:d.rangeId,row:p,column:h,documentId:T===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:_.jsx(w.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.cancel"),children:_.jsx(kt,{})})})]})]})]})},Le=()=>{var i,c;const t=s.useDependency(exports.SheetsHyperLinkPopupService),[n,e]=y.useState(null),r=s.useDependency(s.IUniverInstanceService);if(y.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!n)return null;if(n.showAll){const o=r.getUnit(n.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(n.subUnitId),u=l==null?void 0:l.getCell(n.row,n.col),d=(c=(i=u==null?void 0:u.p)==null?void 0:i.body)==null?void 0:c.customRanges;return d!=null&&d.length?_.jsx("div",{children:d.map(p=>_.jsx(_t,{...n,customRange:p},p.rangeId))}):null}return _.jsx(_t,{...n})};Le.componentKey="univer.sheet.cell-link-popup";var bn=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,wn=(t,n,e,r)=>{for(var i=r>1?void 0:r?Dn(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&bn(n,e,i),i},se=(t,n)=>(e,r)=>n(e,r,t);const It=(t,n)=>{var e,r;return t.unitId===n.unitId&&t.subUnitId===n.subUnitId&&t.row===n.row&&t.col===n.col&&((e=t.customRange)==null?void 0:e.rangeId)===((r=n.customRange)==null?void 0:r.rangeId)&&t.type===n.type};exports.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,r,i,c,o,l,u){super();Z(this,"_currentPopup",null);Z(this,"_currentPopup$",new R.Subject);Z(this,"currentPopup$",this._currentPopup$.asObservable());Z(this,"_currentEditingPopup",null);Z(this,"_currentEditing$",new R.BehaviorSubject(null));Z(this,"currentEditing$",this._currentEditing$.asObservable());Z(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=r,this._univerInstanceService=i,this._editorBridgeService=c,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&It(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const r=this._currentEditing$.getValue();if(r&&It(e,r))return;const{unitId:i,subUnitId:c,row:o,col:l,customRangeRect:u,customRange:d}=e;let p;const h={componentKey:Le.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!d)return;p=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!d)return;p=this._docCanvasPopManagerService.attachPopupToRange({startOffset:d.startIndex,endOffset:d.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)p=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,i,c);else{if(!d)return;p=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}p&&(this._currentPopup={unitId:i,subUnitId:c,disposable:p,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:d,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,r){var i,c;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||r)&&((c=(i=this._currentPopup)==null?void 0:i.disposable)==null||c.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var i,c,o;const e=this._editorBridgeService.isVisible().visible,r=this._editorBridgeService.getEditCellState();if(e&&r){const l=this._textSelectionManagerService.getActiveTextRange(),u=(i=r.documentLayoutObject.documentModel)==null?void 0:i.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const d=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(c=u.customRanges)==null?void 0:c.filter(m=>m.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let p=l.startOffset,h=l.endOffset;return d.forEach(m=>{p=Math.min(p,m.startIndex),h=Math.max(h,m.endIndex+1)}),{startOffset:p,endOffset:h,collapsed:p===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(p,h))}}return null}get _editPopup(){return{componentKey:Re.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,d,p;const{unitId:r,subUnitId:i,type:c}=e;if(c===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const m=this._textSelectionManagerService.getActiveTextRange();if(!m)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(m,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const g=(o=h.getBody())==null?void 0:o.dataStream.slice(m.startOffset,m.endOffset);this._currentEditing$.next({...e,label:g})}else if(c===I.EDITING){const h=this._getEditingRange();h&&this._textSelectionManagerService.replaceTextRanges([{...h}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,r,i),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,r,i);const h=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),m=h==null?void 0:h.getSheetBySheetId(i),g=m==null?void 0:m.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:g!=null&&g.p?s.BuildTextUtils.transform.getPlainText((d=(u=g.p.body)==null?void 0:u.dataStream)!=null?d:""):((p=g==null?void 0:g.v)!=null?p:"").toString()})}}startEditing(e){var l,u,d,p,h,m;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:r,subUnitId:i}=e;let c,o;if(e.type===I.ZEN_EDITOR){const g=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(c=(d=(u=g==null?void 0:g.getBody())==null?void 0:u.customRanges)==null?void 0:d.find(C=>C.rangeId===e.customRangeId),o=c?(p=g==null?void 0:g.getBody())==null?void 0:p.dataStream.slice(c.startIndex,c.endIndex+1):"",!c||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:c.startIndex,endOffset:c.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:c.startIndex,endOffset:c.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const g=f.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!g||!((h=g.rects)!=null&&h.length))return;c=g.customRange,o=g.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:c.startIndex,endOffset:c.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(g.rects.pop(),this._editPopup,r,i)}else{const g=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),C=g==null?void 0:g.getSheetBySheetId(i),L=C==null?void 0:C.getCellRaw(e.row,e.col),T=g==null?void 0:g.getStyles().getStyleByCell(L),a=T==null?void 0:T.tr,k=f.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((m=k.rects)!=null&&m.length))return;c=k.customRange,o=k.label,a?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,r,i):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:r,subUnitId:i,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:c,label:o})}endEditing(e){var i;const r=this._currentEditing$.getValue();r&&(!e||e===r.type)&&((i=this._currentEditingPopup)==null||i.dispose(),this._currentEditing$.next(null))}};exports.SheetsHyperLinkPopupService=wn([se(0,s.Inject(f.SheetCanvasPopManagerService)),se(1,s.Inject(s.Injector)),se(2,s.IUniverInstanceService),se(3,f.IEditorBridgeService),se(4,s.Inject(_e.DocSelectionManagerService)),se(5,s.Inject(ce.DocCanvasPopManagerService)),se(6,O.IZenZoneService)],exports.SheetsHyperLinkPopupService);const Xe=(t,n,e)=>{const r=t.getCell(n,e);if(r!=null&&r.f||r!=null&&r.si)return!0;const i=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(r!=null&&r.dataValidation&&i.includes(r.dataValidation.rule.type))},Hn=t=>{const n=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const e=n.getActiveSheet(),r=t.get(E.SheetsSelectionsService).getCurrentSelections();if(!r.length)return!0;const i=r[0].range.startRow,c=r[0].range.startColumn;return Xe(e,i,c)},Nn=t=>{var d,p;const n=t.get(_e.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),r=n.getDocRanges();if(!r.length||r.length>1)return!0;const i=r[0],c=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!c||!i||i.collapsed)return!0;const o=c.getSelfOrHeaderFooterModel(i.segmentId).getBody();if(!o)return!0;const l=(d=o==null?void 0:o.paragraphs)!=null?d:[];for(let h=0,m=l.length;h<m;h++){const g=l[h];if(i.startOffset<=g.startIndex&&i.endOffset>g.startIndex)return!0;if(g.startIndex>i.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(i,(p=o.customRanges)!=null?p:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},xe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,n){if(!n)return!1;const e=t.get(exports.SheetsHyperLinkPopupService);return n.customRangeId?e.startEditing(n):e.startAddEditing(n),!0}},Ie={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(exports.SheetsHyperLinkPopupService).endEditing(),!0}},je={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const n=t.get(s.IUniverInstanceService),e=E.getSheetCommandTarget(n),r=t.get(f.IEditorBridgeService);if(!e)return!1;const i=t.get(s.ICommandService),o=t.get(E.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,d=r.isVisible(),p=((h=n.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return i.executeCommand(xe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:p?I.ZEN_EDITOR:d.visible?I.EDITING:I.VIEWING})}},oe={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Hn(t))return!1;const n=t.get(s.ICommandService);return t.get(exports.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(Ie.id):n.executeCommand(je.id)}},Je=(t,n=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var i;const e=t.get(s.IUniverInstanceService),r=(i=t.get(Ue.IRenderManagerService).getRenderById(n))==null?void 0:i.with(ce.DocSelectionRenderService);return r?r.textSelectionInner$.pipe(R.map(()=>{const o=t.get(f.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=E.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Xe(l.worksheet,o.row,o.column)?!0:Nn(t)})):R.of(!0)},wt=t=>{const n=f.getCurrentRangeDisable$(t,{workbookTypes:[E.WorkbookEditablePermission],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetSetCellValuePermission,E.WorksheetInsertHyperlinkPermission],rangeTypes:[E.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),r=t.get(E.SheetsSelectionsService),i=t.has(f.IEditorBridgeService)?t.get(f.IEditorBridgeService):null,c=e.focused$.pipe(R.filter(o=>!!o),R.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),R.filter(o=>!!o),R.switchMap(o=>o.activeSheet$),R.switchMap(o=>r.selectionMoveEnd$.pipe(R.map(l=>o&&{selections:l,sheet:o}))),R.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const d=l[0].range.startRow,p=l[0].range.startColumn;if(Xe(u,d,p))return!0}),R.switchMap(o=>{if(o)return R.of(!0);const l=(i?i.visible$:R.of(null)).pipe(R.map(d=>d!=null&&d.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return R.combineLatest([l,u]).pipe(R.switchMap(([d,p])=>d?p?R.of(!0):Je(t,d):R.of(!1)))}));return n.pipe(R.distinctUntilChanged(),R.switchMap(o=>c.pipe(R.map(l=>o||l))))},Pe={commandId:je.id,type:O.MenuItemType.BUTTON,positions:[O.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",icon:"LinkSingle"},Te=t=>`${t}-zen-editor`,Un=t=>({...Pe,id:Pe.commandId,hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:wt(t)}),Mn=t=>({...Pe,id:Te(Pe.commandId),hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Je(t)}),ke={tooltip:"hyperLink.form.addTitle",positions:O.MenuPosition.TOOLBAR_START,group:O.MenuGroup.TOOLBAR_OTHERS,commandId:oe.id,type:O.MenuItemType.BUTTON,icon:"LinkSingle"},xn=t=>({...ke,id:ke.commandId,hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:wt(t)}),jn=t=>({...ke,id:Te(ke.commandId),hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Je(t)}),Qe={id:oe.id,binding:O.KeyCode.K|O.MetaKeys.CTRL_COMMAND,preconditions:f.whenSheetEditorFocused};var Bn=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,An=(t,n,e,r)=>{for(var i=r>1?void 0:r?$n(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Bn(n,e,i),i},ft=(t,n)=>(e,r)=>n(e,r,t);let Oe=class extends s.Disposable{constructor(t,n){super(),this._autoFillService=t,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),n=(r,i)=>{const{source:c,target:o,unitId:l,subUnitId:u}=r,d=f.virtualizeDiscreteRanges([c,o]),[p,h]=d.ranges,{mapFunc:m}=d,g={row:p.startRow,col:p.startColumn},C=f.getAutoFillRepeatRange(p,h),L=[],T=[];return C.forEach(a=>{const k=a.repeatStartCell,x=a.relativeRange,N={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},H={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(x,(V,$)=>{const te=s.Rectangle.getPositionRange({startRow:V,startColumn:$,endColumn:$,endRow:V},N),{row:pe,col:fe}=m(te.startRow,te.startColumn),ne=this._hyperLinkModel.getHyperLinkByLocation(l,u,pe,fe),de=s.Rectangle.getPositionRange({startRow:V,startColumn:$,endColumn:$,endRow:V},H),{row:he,col:ge}=m(de.startRow,de.startColumn),re=s.Tools.generateRandomId(),F=this._hyperLinkModel.getHyperLinkByLocation(l,u,he,ge);F&&L.push({id:S.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:F.id}}),(f.APPLY_TYPE.COPY===i||f.APPLY_TYPE.SERIES===i)&&ne&&(L.push({id:S.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ne,id:re,row:he,column:ge}}}),T.push({id:S.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:re}})),F&&T.push({id:S.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:F}})})}),{undos:T,redos:L}},e={id:Ye,onFillData:(r,i,c)=>c===f.APPLY_TYPE.COPY||c===f.APPLY_TYPE.ONLY_FORMAT||c===f.APPLY_TYPE.SERIES?n(r,c):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Oe=An([ft(0,f.IAutoFillService),ft(1,s.Inject(S.HyperLinkModel))],Oe);var Vn=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,Zn=(t,n,e,r)=>{for(var i=r>1?void 0:r?Fn(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Vn(n,e,i),i},Ke=(t,n)=>(e,r)=>n(e,r,t);let be=class extends s.Disposable{constructor(t,n,e){super(),this._localeService=t,this._commandService=n,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===Qe.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookEditablePermission],rangeTypes:[E.RangeProtectionPermissionEditPoint],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetSetCellValuePermission,E.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};be=Zn([Ke(0,s.Inject(s.LocaleService)),Ke(1,s.ICommandService),Ke(2,s.Inject(f.SheetPermissionInterceptorBaseController))],be);var Kn=Object.defineProperty,Wn=Object.getOwnPropertyDescriptor,Gn=(t,n,e,r)=>{for(var i=r>1?void 0:r?Wn(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Kn(n,e,i),i},z=(t,n)=>(e,r)=>n(e,r,t);let De=class extends s.Disposable{constructor(t,n,e,r,i,c,o,l,u,d){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=n,this._renderManagerService=e,this._permissionService=r,this._sheetPermissionInterceptorBaseController=i,this._commandService=c,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=d,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:n,subUnitId:e,row:r,col:i}=t,c=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!(c==null?void 0:c.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookViewPermission],worksheetTypes:[E.WorksheetViewPermission],rangeTypes:[E.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookEditablePermission],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetInsertHyperlinkPermission],rangeTypes:[E.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),d=this._permissionService.composePermission([new E.WorkbookCopyPermission(n).id,new E.WorksheetCopyPermission(n,e).id]).every(p=>p.value);return{viewPermission:l,editPermission:u,copyPermission:d}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(R.debounceTime(200)).subscribe(t=>{var N;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:e,row:r,col:i}=t,c=this._renderManagerService.getRenderById(n);if(!c)return;const o=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!c.with(f.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const d=(N=c==null?void 0:c.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:N.skeleton,p=i,h=r;let m=h,g=p;d&&d.overflowCache.forValue((H,V,$)=>{s.Rectangle.contains($,{startColumn:p,endColumn:p,startRow:h,endRow:h})&&(m=H,g=V)});const{viewPermission:C,editPermission:L,copyPermission:T}=this._getLinkPermission(t);if(!C){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const a=l.getCellStyleOnly(m,g),k=o.getStyles().getStyleByCell(a),x=k==null?void 0:k.tr;if(!x&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:m,col:g,editPermission:L,copyPermission:T,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:n,subUnitId:e,showAll:!!x})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(R.switchMap(n=>this._editorBridgeService.visible$.pipe(R.map(e=>({visible:e,state:n}))))).subscribe(({visible:n,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:r,unitId:i,sheetId:c,row:o,column:l}=e,u=this._renderManagerService.getRenderById(r);if(!u)return;const{editPermission:d,viewPermission:p,copyPermission:h}=this._getLinkPermission({unitId:i,subUnitId:c,row:o,col:l}),m=u.with(ce.DocEventManagerService);p&&(t==null||t.unsubscribe(),t=m.hoverCustomRanges$.pipe(R.debounceTime(200)).subscribe(g=>{var k,x;const C=g.find(N=>N.range.rangeType===s.CustomRangeType.HYPERLINK);if(!C){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=C.rects[C.rects.length-1];if(!((x=(k=this._renderManagerService.getRenderById(i))==null?void 0:k.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(c))==null?void 0:x.skeleton)||!L)return;const a=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:i,subUnitId:c,row:o,col:l,customRange:C.range,customRangeRect:{left:L.left+a.left,top:L.top+a.top,bottom:L.bottom+a.top,right:L.right+a.left},editPermission:d,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(R.switchMap(t=>{const n=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return n?n.with(ce.DocEventManagerService).hoverCustomRanges$.pipe(R.debounceTime(200)):new R.Observable(e=>{e.next(null)})})).subscribe(t=>{const n=t==null?void 0:t.find(r=>r.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(n&&e){const{unitId:r,sheetId:i,row:c,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:d}=this._getLinkPermission({unitId:r,subUnitId:i,row:c,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:r,subUnitId:i,row:c,col:o,customRange:n.range,editPermission:l,copyPermission:d})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[E.ClearSelectionContentCommand.id,E.ClearSelectionAllCommand.id,E.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{t.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};De=Gn([z(0,s.Inject(f.HoverManagerService)),z(1,s.Inject(exports.SheetsHyperLinkPopupService)),z(2,s.Inject(Ue.IRenderManagerService)),z(3,s.Inject(s.IPermissionService)),z(4,s.Inject(f.SheetPermissionInterceptorBaseController)),z(5,s.ICommandService),z(6,f.IEditorBridgeService),z(7,s.Inject(_e.DocSelectionManagerService)),z(8,s.IUniverInstanceService),z(9,O.IZenZoneService)],De);var Yn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,Ht=(t,n,e,r)=>{for(var i=r>1?void 0:r?zn(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Yn(n,e,i),i},We=(t,n)=>(e,r)=>n(e,r,t);let Ge=class extends s.Disposable{constructor(t,n){super(),this._context=t,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(R.debounceTime(16)).subscribe(()=>{t()}))}};Ge=Ht([We(1,s.Inject(S.HyperLinkModel))],Ge);let we=class extends s.Disposable{constructor(t,n){super(),this._sheetInterceptorService=t,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(E.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,n,e)=>{const{row:r,col:i,unitId:c,subUnitId:o}=n,l=this._hyperLinkModel.getHyperLinkByLocation(c,o,r,i);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};we=Ht([We(0,s.Inject(E.SheetInterceptorService)),We(1,s.Inject(S.HyperLinkModel))],we);const qn={[O.RibbonStartGroup.OTHERS]:{[oe.id]:{order:2,menuItemFactory:xn},[Te(oe.id)]:{order:2,menuItemFactory:jn}},[O.ContextMenuPosition.MAIN_AREA]:{[O.ContextMenuGroup.OTHERS]:{order:1,[oe.id]:{order:0,menuItemFactory:Un},[Te(oe.id)]:{order:0,menuItemFactory:Mn}}}};var Xn=Object.defineProperty,Jn=Object.getOwnPropertyDescriptor,Qn=(t,n,e,r)=>{for(var i=r>1?void 0:r?Jn(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Xn(n,e,i),i},me=(t,n)=>(e,r)=>n(e,r,t);let He=class extends s.Disposable{constructor(t,n,e,r,i){super(),this._componentManager=t,this._commandService=n,this._menuManagerService=e,this._injector=r,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Le,Le.componentKey],[Re,Re.componentKey],[qe,"LinkSingle"]].forEach(([t,n])=>{this._componentManager.register(n,t)})}_initCommands(){[xe,Ie,je,oe].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(qn)}_initShortCut(){this._shortcutService.registerShortcut(Qe)}};He=Qn([me(0,s.Inject(O.ComponentManager)),me(1,s.ICommandService),me(2,O.IMenuManagerService),me(3,s.Inject(s.Injector)),me(4,s.Inject(O.IShortcutService))],He);var er=Object.defineProperty,tr=Object.getOwnPropertyDescriptor,nr=(t,n,e,r)=>{for(var i=r>1?void 0:r?tr(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&er(n,e,i),i},yt=(t,n)=>(e,r)=>n(e,r,t);let Ne=class extends s.Disposable{constructor(t,n){super(),this._parserService=t,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const n=this._parserService.parseHyperLink(t);this._resolverService.navigate(n)}}};Ne=nr([yt(0,s.Inject(S.SheetsHyperLinkParserService)),yt(1,s.Inject(exports.SheetsHyperLinkResolverService))],Ne);var Nt=Object.defineProperty,rr=Object.getOwnPropertyDescriptor,ir=(t,n,e)=>n in t?Nt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,sr=(t,n,e,r)=>{for(var i=r>1?void 0:r?rr(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Nt(n,e,i),i},Ct=(t,n)=>(e,r)=>n(e,r,t),Ut=(t,n,e)=>ir(t,typeof n!="symbol"?n+"":n,e);exports.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(n=Yt,e,r){super(),this._config=n,this._injector=e,this._configService=r;const{menu:i,...c}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Et,c)}onStarting(){[[exports.SheetsHyperLinkResolverService],[exports.SheetsHyperLinkPopupService],[ze],[we],[De],[He],[Oe],[exports.SheetsHyperLinkCopyPasteController],[be],[Ne]].forEach(e=>this._injector.add(e)),this._injector.get(we)}onReady(){this._injector.get(Ue.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[Ge]),this._injector.get(Oe),this._injector.get(exports.SheetsHyperLinkCopyPasteController),this._injector.get(He)}onRendered(){this._injector.get(be),this._injector.get(Ne),this._injector.get(De)}};Ut(exports.UniverSheetsHyperLinkUIPlugin,"pluginName",Ye);Ut(exports.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkUIPlugin=sr([s.DependentOn(S.UniverSheetsHyperLinkPlugin,ce.UniverDocsUIPlugin),Ct(1,s.Inject(s.Injector)),Ct(2,s.IConfigService)],exports.UniverSheetsHyperLinkUIPlugin);exports.CloseHyperLinkPopupOperation=Ie;exports.InsertHyperLinkOperation=je;exports.InsertLinkShortcut=Qe;exports.OpenHyperLinkEditPanelOperation=xe;exports.SheetsHyperLinkSidePanelService=ze;
|
|
9
|
+
*/var nn=y,rn=Symbol.for("react.element"),sn=Symbol.for("react.fragment"),on=Object.prototype.hasOwnProperty,cn=nn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,an={key:!0,ref:!0,__self:!0,__source:!0};function Lt(t,n,e){var r,i={},c=null,o=null;e!==void 0&&(c=""+e),n.key!==void 0&&(c=""+n.key),n.ref!==void 0&&(o=n.ref);for(r in n)on.call(n,r)&&!an.hasOwnProperty(r)&&(i[r]=n[r]);if(t&&t.defaultProps)for(r in n=t.defaultProps,n)i[r]===void 0&&(i[r]=n[r]);return{$$typeof:rn,type:t,key:c,ref:o,props:i,_owner:cn.current}}Me.Fragment=sn;Me.jsx=Lt;Me.jsxs=Lt;Rt.exports=Me;var m=Rt.exports;class ze extends s.Disposable{constructor(){super(...arguments);Z(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==_.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(i=>i.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:r}=this;r.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const ln="univer-cell-link-edit",un="univer-cell-link-edit-buttons",St={cellLinkEdit:ln,cellLinkEditButtons:un},Le=()=>{var tt;const[t,n]=y.useState(""),[e,r]=y.useState(!1),[i,c]=y.useState(""),[o,l]=y.useState(!0),[u,d]=y.useState(_.SheetHyperLinkType.URL),[p,h]=y.useState(""),S=s.useDependency(s.LocaleService),g=s.useDependency(X.IDefinedNamesService),C=s.useDependency(f.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),T=s.useDependency(exports.SheetsHyperLinkPopupService),a=b.useObservable(T.currentEditing$),k=s.useDependency(_.SheetsHyperLinkParserService),x=s.useDependency(exports.SheetsHyperLinkResolverService),N=s.useDependency(s.ICommandService),H=s.useDependency(ze),V=y.useMemo(()=>H.getOptions(),[H]),$=s.useDependency(b.IZenZoneService),ne=s.useDependency(fe.IRenderManagerService),pe=s.useDependency(f.IMarkSelectionService),ye=s.useDependency(me.DocSelectionManagerService),re=s.useDependency(s.IContextService),de=s.useDependency(s.ThemeService),he=s.useDependency(me.DocSelectionManagerService),ge=y.useRef({}),ie=y.useMemo(()=>{if(!H.isBuiltInLinkType(u))return H.getCustomHyperLink(u)},[H,u]),[F,Mt]=y.useState(!1),[ve,Be]=y.useState(!1),B=y.useRef(!1),K=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),xt=(K==null?void 0:K.getActiveSheet().getSheetId())||"",J=y.useCallback(v=>{c(v.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[c]);y.useEffect(()=>{var v,O,P,D,M,W,nt,rt,it,st,ot,ct,at,lt,ut,pt,dt;if((a==null?void 0:a.row)!==void 0&&a.col!==void 0){const{customRange:se,row:Fe,col:Ze}=a;let{label:q}=a;typeof q=="number"&&(q=`${q}`);let Y;if(se)Y={id:(v=se==null?void 0:se.rangeId)!=null?v:"",display:q!=null?q:"",payload:(P=(O=se==null?void 0:se.properties)==null?void 0:O.url)!=null?P:"",row:Fe,column:Ze};else if(a.type===I.VIEWING){const U=L.getUnit(a.unitId),ee=U==null?void 0:U.getSheetBySheetId(a.subUnitId),j=ee==null?void 0:ee.getCellRaw(a.row,a.col),le=(W=(M=(D=j==null?void 0:j.p)==null?void 0:D.body)==null?void 0:M.customRanges)==null?void 0:W.find(gt=>{var vt;return gt.rangeType===s.CustomRangeType.HYPERLINK&&((vt=gt.properties)==null?void 0:vt.url)}),Se=j==null?void 0:j.v;j&&(!s.BuildTextUtils.transform.isEmptyDocument((rt=(nt=j.p)==null?void 0:nt.body)==null?void 0:rt.dataStream)||s.Tools.isDefine(Se))&&l(!1),Y={id:"",display:"",payload:(st=(it=le==null?void 0:le.properties)==null?void 0:it.url)!=null?st:"",row:Fe,column:Ze}}else{const U=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ee=ye.getActiveTextRange(),j=U==null?void 0:U.getBody(),le=ee&&j?ee:null,Se=le&&((ct=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(le,(ot=j==null?void 0:j.customRanges)!=null?ot:[]))==null?void 0:ct[0]);l(!1),Y={id:"",display:q!=null?q:"",payload:(lt=(at=Se==null?void 0:Se.properties)==null?void 0:at.url)!=null?lt:"",row:Fe,column:Ze}}n(Y.id);const ht=H.findCustomHyperLink(Y);if(ht){const U=ht.convert(Y);d(U.type),h(U.payload),J(U.display);return}J(Y.display);const Q=k.parseHyperLink(Y.payload);switch(d(Q.type===_.SheetHyperLinkType.INVALID?_.SheetHyperLinkType.RANGE:Q.type),Q.type){case _.SheetHyperLinkType.URL:{h(Q.url),Q.url===Y.display&&(B.current=!0);break}case _.SheetHyperLinkType.RANGE:{const U=Q.searchObj,ee=U.gid&&(dt=(pt=(ut=L.getUnit(a.unitId))==null?void 0:ut.getSheetBySheetId(U.gid))==null?void 0:pt.getName())!=null?dt:"",j=X.serializeRangeWithSheet(ee,X.deserializeRangeWithSheet(U.range).range);h(j),j===Y.display&&(B.current=!0);break}case _.SheetHyperLinkType.SHEET:{const U=Q.searchObj;h(U.gid);break}case _.SheetHyperLinkType.DEFINE_NAME:{const U=Q.searchObj;h(U.rangeid);break}default:h("");break}}},[a,x,H,ye,L]),y.useEffect(()=>{let v=null;if(a&&!a.customRangeId&&a.type===I.VIEWING&&s.Tools.isDefine(a.row)&&s.Tools.isDefine(a.col)){const O=L.getUnit(a.unitId,s.UniverInstanceType.UNIVER_SHEET),P=O==null?void 0:O.getSheetBySheetId(a.subUnitId),D=P==null?void 0:P.getMergedCell(a.row,a.col),M=new s.ColorKit(de.getCurrentTheme().hyacinth500).toRgb();v=pe.addShape({range:D!=null?D:{startColumn:a.col,endColumn:a.col,startRow:a.row,endRow:a.row},style:{fill:`rgb(${M.r}, ${M.g}, ${M.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{v&&pe.removeShape(v)}},[a,pe,de,L]),y.useEffect(()=>{Be(u===_.SheetHyperLinkType.RANGE)},[u]),y.useEffect(()=>{const v=(a==null?void 0:a.type)===I.ZEN_EDITOR?ne.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):ne.getRenderById(C.getCurrentEditorId()),O=new s.DisposableCollection;if(v){const P=v.with(te.DocSelectionRenderService);P.setReserveRangesStatus(!0),O.add(()=>{P.setReserveRangesStatus(!1)})}return()=>{C.disableForceKeepVisible(),O.dispose()}},[a==null?void 0:a.type,C,ne]),y.useEffect(()=>(T.setIsKeepVisible(ve),()=>{T.setIsKeepVisible(!1)}),[ve,T]),y.useEffect(()=>()=>{$.temporaryHidden&&($.show(),re.setContextValue(s.FOCUSING_SHEET,!1))},[re,$]),y.useEffect(()=>{if(ve)return C.enableForceKeepVisible(),()=>{C.disableForceKeepVisible()}},[ve,C]);const jt=[{label:S.t("hyperLink.form.link"),value:_.SheetHyperLinkType.URL},{label:S.t("hyperLink.form.range"),value:_.SheetHyperLinkType.RANGE},{label:S.t("hyperLink.form.worksheet"),value:_.SheetHyperLinkType.SHEET},{label:S.t("hyperLink.form.definedName"),value:_.SheetHyperLinkType.DEFINE_NAME},...V];if(!K)return;const Bt=K.getHiddenWorksheets(),$e=K.getSheets().map(v=>({label:v.getName(),value:v.getSheetId()})).filter(v=>Bt.indexOf(v.value)===-1),Ae=Object.values((tt=g.getDefinedNameMap(K.getUnitId()))!=null?tt:{}).map(v=>({label:v.name,value:v.id})),et=(v,O)=>{if(v===_.SheetHyperLinkType.URL)return Yt(O);if(v===_.SheetHyperLinkType.RANGE){const P=X.deserializeRangeWithSheet(O),D=K.getSheetBySheetName(P.sheetName);if(D)return`#gid=${D.getSheetId()}&range=${X.serializeRange(P.range)}`}return`#${v}=${O}`},$t=b.useEvent(v=>{var M;const P=v.split(",").map(X.deserializeRangeWithSheet)[0];if(!P||!s.isValidRange(P.range))return;P.sheetName||(P.sheetName=((M=K.getActiveSheet())==null?void 0:M.getName())||"");const D=X.serializeRangeToRefString(P);h(D),D&&(B.current||!i)&&(J(D),B.current=!0)}),Ve=async()=>{if(o&&!i||!p||u===_.SheetHyperLinkType.URL&&!Re(p)){Mt(!0);return}if(a)if(t){const v=a.type===I.ZEN_EDITOR||a.type===I.EDITING?_.UpdateRichHyperLinkCommand.id:_.UpdateHyperLinkCommand.id;await N.executeCommand(v,{id:t,unitId:a.unitId,subUnitId:a.subUnitId,payload:{display:o?i:"",payload:et(u,p)},row:a.row,column:a.col,documentId:a.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:C.getCurrentEditorId()})}else{const v=a.type===I.ZEN_EDITOR||a.type===I.EDITING?_.AddRichHyperLinkCommand.id:_.AddHyperLinkCommand.id;await N.executeCommand(v,{unitId:a.unitId,subUnitId:a.subUnitId,link:{id:s.generateRandomId(),row:a.row,column:a.col,payload:et(u,p),display:o?i:""},documentId:a.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:C.getCurrentEditorId()})}if((a==null?void 0:a.type)===I.VIEWING){await N.executeCommand(E.SetWorksheetActiveOperation.id,{unitId:a.unitId,subUnitId:a.subUnitId});const v=1;await N.executeCommand(f.ScrollToRangeOperation.id,{range:{startRow:Math.max(a.row-v,0),endRow:a.row+v,startColumn:Math.max(a.col-v,0),endColumn:a.col+v}})}N.executeCommand(Ie.id)},At=v=>{var P;if(u!==_.SheetHyperLinkType.RANGE)return;const O=(P=ge.current)==null?void 0:P.handleOutClick;O&&O(v,()=>Be(!1))};return a?m.jsxs("div",{className:St.cellLinkEdit,style:{display:e?"none":"block"},onClick:At,children:[o?m.jsx(w.FormLayout,{label:S.t("hyperLink.form.label"),error:F&&!i?S.t("hyperLink.form.inputError"):"",children:m.jsx(w.Input,{value:i,onChange:v=>{J(v),B.current=!1},placeholder:S.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===b.KeyCode.ENTER&&Ve()}})}):null,m.jsx(w.FormLayout,{label:S.t("hyperLink.form.type"),children:m.jsx(w.Select,{options:jt,value:u,onChange:v=>{d(v),h("")}})}),u===_.SheetHyperLinkType.URL&&m.jsx(w.FormLayout,{error:F?p?Re(p)?"":S.t("hyperLink.form.linkError"):S.t("hyperLink.form.inputError"):"",children:m.jsx(w.Input,{value:p,onChange:v=>{h(v),v&&(B.current||!i||i===p)&&(J(v),B.current=!0)},placeholder:S.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===b.KeyCode.ENTER&&Ve()}})}),u===_.SheetHyperLinkType.RANGE&&m.jsx(w.FormLayout,{error:F&&!p?S.t("hyperLink.form.inputError"):"",children:m.jsx(Zt.RangeSelector,{unitId:K.getUnitId(),subUnitId:xt,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:p,onChange:$t,isFocus:ve,onFocus:()=>Be(!0),actions:ge.current,onRangeSelectorDialogVisibleChange:async v=>{var O,P;if(v)a.type===I.ZEN_EDITOR&&($.hide(),re.setContextValue(s.FOCUSING_SHEET,!0)),a.type!==I.VIEWING&&C.enableForceKeepVisible(),r(!0);else{if(await x.navigateToRange(a.unitId,a.subUnitId,{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col},!0),a.type===I.ZEN_EDITOR){await N.executeCommand(E.SetSelectionsOperation.id,{unitId:a.unitId,subUnitId:a.subUnitId,selections:[{range:{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col}}]}),$.show(),re.setContextValue(s.FOCUSING_SHEET,!1);const D=(O=ne.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:O.with(te.DocBackScrollRenderController),M=(P=he.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:P[0];D&&M&&(D.scrollToRange(M),he.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}C.disableForceKeepVisible(),r(!1)}}})}),u===_.SheetHyperLinkType.SHEET&&m.jsx(w.FormLayout,{error:F&&!p?S.t("hyperLink.form.selectError"):"",children:m.jsx(w.Select,{options:$e,value:p,onChange:v=>{var D,M;h(v);const O=(D=$e.find(W=>W.value===v))==null?void 0:D.label,P=(M=$e.find(W=>W.value===p))==null?void 0:M.label;O&&(B.current||!i||i===P)&&(J(O),B.current=!0)}})}),u===_.SheetHyperLinkType.DEFINE_NAME&&m.jsx(w.FormLayout,{error:F&&!p?S.t("hyperLink.form.selectError"):"",children:m.jsx(w.Select,{options:Ae,value:p,onChange:v=>{var D,M;h(v);const O=(D=Ae.find(W=>W.value===v))==null?void 0:D.label,P=(M=Ae.find(W=>W.value===p))==null?void 0:M.label;O&&(B.current||!i||i===P)&&(J(O),B.current=!0)}})}),(ie==null?void 0:ie.Form)&&m.jsx(ie.Form,{linkId:t,payload:p,display:i,showError:F,setByPayload:B,setDisplay:v=>{J(v),B.current=!0},setPayload:h}),m.jsxs("div",{className:St.cellLinkEditButtons,children:[m.jsx(w.Button,{onClick:()=>{a&&x.navigateToRange(a.unitId,a.subUnitId,{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col},!0),N.executeCommand(Ie.id)},children:S.t("hyperLink.form.cancel")}),m.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Ve()},children:S.t("hyperLink.form.ok")})]})]}):null};Le.componentKey="univer.sheet.cell-link-edit";var A=function(){return A=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++){n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},A.apply(this,arguments)},pn=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]]);return e},ae=y.forwardRef(function(t,n){var e=t.icon,r=t.id,i=t.className,c=t.extend,o=pn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),u=y.useRef("_".concat(gn()));return Pt(e,"".concat(r),{defIds:e.defIds,idSuffix:u.current},A({ref:n,className:l},o),c)});function Pt(t,n,e,r,i){return y.createElement(t.tag,A(A({key:n},dn(t,e,i)),r),(hn(t,e).children||[]).map(function(c,o){return Pt(c,"".concat(n,"-").concat(t.tag,"-").concat(o),e,void 0,i)}))}function dn(t,n,e){var r=A({},t.attrs);e!=null&&e.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=e.colorChannel1);var i=n.defIds;return!i||i.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+n.idSuffix),Object.entries(r).forEach(function(c){var o=c[0],l=c[1];typeof l=="string"&&(r[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),r}function hn(t,n){var e,r=n.defIds;return!r||r.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?A(A({},t),{children:t.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?A(A({},i),{attrs:A(A({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):t}function gn(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var vn={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"}}]},Ee=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"all-border-single",ref:n,icon:vn}))});Ee.displayName="AllBorderSingle";var Sn={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"}}]},Tt=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"copy-single",ref:n,icon:Sn}))});Tt.displayName="CopySingle";var _n={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},qe=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"link-single",ref:n,icon:_n}))});qe.displayName="LinkSingle";var mn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},kt=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"unlink-single",ref:n,icon:mn}))});kt.displayName="UnlinkSingle";var In={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"}}]},Ot=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"write-single",ref:n,icon:In}))});Ot.displayName="WriteSingle";var fn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},bt=y.forwardRef(function(t,n){return y.createElement(ae,Object.assign({},t,{id:"xlsx",ref:n,icon:fn}))});bt.displayName="Xlsx";function Dt(t){var n,e,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(n=0;n<i;n++)t[n]&&(e=Dt(t[n]))&&(r&&(r+=" "),r+=e)}else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function _t(){for(var t,n,e=0,r="",i=arguments.length;e<i;e++)(t=arguments[e])&&(n=Dt(t))&&(r&&(r+=" "),r+=n);return r}const yn="univer-cell-link",Cn="univer-cell-link-type",En="univer-cell-link-content",Rn="univer-cell-link-content-error",Ln="univer-cell-link-url",Pn="univer-cell-link-operations",Tn="univer-cell-link-operation",kn="univer-cell-link-operation-error",G={cellLink:yn,cellLinkType:Cn,cellLinkContent:En,cellLinkContentError:Rn,cellLinkUrl:Ln,cellLinkOperations:Pn,cellLinkOperation:Tn,cellLinkOperationError:kn},On={[_.SheetHyperLinkType.URL]:m.jsx(qe,{}),[_.SheetHyperLinkType.SHEET]:m.jsx(bt,{}),[_.SheetHyperLinkType.RANGE]:m.jsx(Ee,{}),[_.SheetHyperLinkType.DEFINE_NAME]:m.jsx(Ee,{}),[_.SheetHyperLinkType.INVALID]:m.jsx(Ee,{})},mt=t=>{var x,N;const n=s.useDependency(exports.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),r=s.useDependency(b.IMessageService),i=s.useDependency(s.LocaleService),c=s.useDependency(exports.SheetsHyperLinkResolverService),o=s.useDependency(f.IEditorBridgeService),l=s.useDependency(_.SheetsHyperLinkParserService),u=s.useDependency(b.IZenZoneService),{customRange:d,row:p,col:h,unitId:S,subUnitId:g,editPermission:C,copyPermission:L,type:T}=t;if(!((x=d==null?void 0:d.properties)!=null&&x.url))return null;const a=l.parseHyperLink((N=d.properties.url)!=null?N:""),k=a.type===_.SheetHyperLinkType.INVALID;return m.jsxs("div",{className:G.cellLink,onClick:()=>n.hideCurrentPopup(),children:[m.jsxs("div",{className:_t(G.cellLinkContent,{[G.cellLinkContentError]:k}),onClick:()=>{u.visible||k||c.navigate(a)},children:[m.jsx("div",{className:G.cellLinkType,children:On[a.type]}),m.jsx(w.Tooltip,{showIfEllipsis:!0,title:a.name,children:m.jsx("span",{className:G.cellLinkUrl,children:a.name})})]}),m.jsxs("div",{className:G.cellLinkOperations,children:[L&&m.jsx("div",{className:_t(G.cellLinkOperation,{[G.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(a.type!==_.SheetHyperLinkType.URL){const H=new URL(window.location.href);H.hash=a.url.slice(1),navigator.clipboard.writeText(H.href)}else navigator.clipboard.writeText(a.url);r.show({content:i.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:m.jsx(w.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.copy"),children:m.jsx(Tt,{})})}),C&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:G.cellLinkOperation,onClick:()=>{e.executeCommand(xe.id,{unitId:S,subUnitId:g,row:p,col:h,customRangeId:d.rangeId,type:T})},children:m.jsx(w.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.edit"),children:m.jsx(Ot,{})})}),m.jsx("div",{className:G.cellLinkOperation,onClick:()=>{const H=T===I.EDITING||T===I.ZEN_EDITOR?_.CancelRichHyperLinkCommand.id:_.CancelHyperLinkCommand.id;e.syncExecuteCommand(H,{unitId:S,subUnitId:g,id:d.rangeId,row:p,column:h,documentId:T===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:m.jsx(w.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.cancel"),children:m.jsx(kt,{})})})]})]})]})},Pe=()=>{var i,c;const t=s.useDependency(exports.SheetsHyperLinkPopupService),[n,e]=y.useState(null),r=s.useDependency(s.IUniverInstanceService);if(y.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!n)return null;if(n.showAll){const o=r.getUnit(n.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(n.subUnitId),u=l==null?void 0:l.getCell(n.row,n.col),d=(c=(i=u==null?void 0:u.p)==null?void 0:i.body)==null?void 0:c.customRanges;return d!=null&&d.length?m.jsx("div",{children:d.map(p=>m.jsx(mt,{...n,customRange:p},p.rangeId))}):null}return m.jsx(mt,{...n})};Pe.componentKey="univer.sheet.cell-link-popup";var bn=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,wn=(t,n,e,r)=>{for(var i=r>1?void 0:r?Dn(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&bn(n,e,i),i},oe=(t,n)=>(e,r)=>n(e,r,t);const It=(t,n)=>{var e,r;return t.unitId===n.unitId&&t.subUnitId===n.subUnitId&&t.row===n.row&&t.col===n.col&&((e=t.customRange)==null?void 0:e.rangeId)===((r=n.customRange)==null?void 0:r.rangeId)&&t.type===n.type};exports.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,r,i,c,o,l,u){super();Z(this,"_currentPopup",null);Z(this,"_currentPopup$",new R.Subject);Z(this,"currentPopup$",this._currentPopup$.asObservable());Z(this,"_currentEditingPopup",null);Z(this,"_currentEditing$",new R.BehaviorSubject(null));Z(this,"currentEditing$",this._currentEditing$.asObservable());Z(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=r,this._univerInstanceService=i,this._editorBridgeService=c,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&It(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const r=this._currentEditing$.getValue();if(r&&It(e,r))return;const{unitId:i,subUnitId:c,row:o,col:l,customRangeRect:u,customRange:d}=e;let p;const h={componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!d)return;p=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!d)return;p=this._docCanvasPopManagerService.attachPopupToRange({startOffset:d.startIndex,endOffset:d.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)p=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,i,c);else{if(!d)return;p=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}p&&(this._currentPopup={unitId:i,subUnitId:c,disposable:p,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:d,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,r){var i,c;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||r)&&((c=(i=this._currentPopup)==null?void 0:i.disposable)==null||c.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var i,c,o;const e=this._editorBridgeService.isVisible().visible,r=this._editorBridgeService.getEditCellState();if(e&&r){const l=this._textSelectionManagerService.getActiveTextRange(),u=(i=r.documentLayoutObject.documentModel)==null?void 0:i.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const d=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(c=u.customRanges)==null?void 0:c.filter(S=>S.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let p=l.startOffset,h=l.endOffset;return d.forEach(S=>{p=Math.min(p,S.startIndex),h=Math.max(h,S.endIndex+1)}),{startOffset:p,endOffset:h,collapsed:p===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(p,h))}}return null}get _editPopup(){return{componentKey:Le.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,d,p;const{unitId:r,subUnitId:i,type:c}=e;if(c===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const S=this._textSelectionManagerService.getActiveTextRange();if(!S)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(S,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const g=(o=h.getBody())==null?void 0:o.dataStream.slice(S.startOffset,S.endOffset);this._currentEditing$.next({...e,label:g})}else if(c===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const S=this._injector.get(fe.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!S)return;const g=te.calcDocRangePositions(h,S);if(!(g!=null&&g.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(g.pop(),this._editPopup,r,i),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,r,i);const h=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),S=h==null?void 0:h.getSheetBySheetId(i),g=S==null?void 0:S.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:g!=null&&g.p?s.BuildTextUtils.transform.getPlainText((d=(u=g.p.body)==null?void 0:u.dataStream)!=null?d:""):((p=g==null?void 0:g.v)!=null?p:"").toString()})}}startEditing(e){var l,u,d,p,h,S;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:r,subUnitId:i}=e;let c,o;if(e.type===I.ZEN_EDITOR){const g=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(c=(d=(u=g==null?void 0:g.getBody())==null?void 0:u.customRanges)==null?void 0:d.find(C=>C.rangeId===e.customRangeId),o=c?(p=g==null?void 0:g.getBody())==null?void 0:p.dataStream.slice(c.startIndex,c.endIndex+1):"",!c||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:c.startIndex,endOffset:c.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:c.startIndex,endOffset:c.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const g=f.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!g||!((h=g.rects)!=null&&h.length))return;c=g.customRange,o=g.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:c.startIndex,endOffset:c.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(g.rects.pop(),this._editPopup,r,i)}else{const g=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),C=g==null?void 0:g.getSheetBySheetId(i),L=C==null?void 0:C.getCellRaw(e.row,e.col),T=g==null?void 0:g.getStyles().getStyleByCell(L),a=T==null?void 0:T.tr,k=f.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((S=k.rects)!=null&&S.length))return;c=k.customRange,o=k.label,a?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,r,i):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:r,subUnitId:i,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:c,label:o})}endEditing(e){var i;const r=this._currentEditing$.getValue();r&&(!e||e===r.type)&&((i=this._currentEditingPopup)==null||i.dispose(),this._currentEditing$.next(null))}};exports.SheetsHyperLinkPopupService=wn([oe(0,s.Inject(f.SheetCanvasPopManagerService)),oe(1,s.Inject(s.Injector)),oe(2,s.IUniverInstanceService),oe(3,f.IEditorBridgeService),oe(4,s.Inject(me.DocSelectionManagerService)),oe(5,s.Inject(te.DocCanvasPopManagerService)),oe(6,b.IZenZoneService)],exports.SheetsHyperLinkPopupService);const Xe=(t,n,e)=>{const r=t.getCell(n,e);if(r!=null&&r.f||r!=null&&r.si)return!0;const i=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(r!=null&&r.dataValidation&&i.includes(r.dataValidation.rule.type))},Hn=t=>{const n=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const e=n.getActiveSheet(),r=t.get(E.SheetsSelectionsService).getCurrentSelections();if(!r.length)return!0;const i=r[0].range.startRow,c=r[0].range.startColumn;return Xe(e,i,c)},Nn=t=>{var d,p;const n=t.get(me.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),r=n.getDocRanges();if(!r.length||r.length>1)return!0;const i=r[0],c=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!c||!i||i.collapsed)return!0;const o=c.getSelfOrHeaderFooterModel(i.segmentId).getBody();if(!o)return!0;const l=(d=o==null?void 0:o.paragraphs)!=null?d:[];for(let h=0,S=l.length;h<S;h++){const g=l[h];if(i.startOffset<=g.startIndex&&i.endOffset>g.startIndex)return!0;if(g.startIndex>i.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(i,(p=o.customRanges)!=null?p:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},xe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,n){if(!n)return!1;const e=t.get(exports.SheetsHyperLinkPopupService);return n.customRangeId?e.startEditing(n):e.startAddEditing(n),!0}},Ie={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(exports.SheetsHyperLinkPopupService).endEditing(),!0}},je={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const n=t.get(s.IUniverInstanceService),e=E.getSheetCommandTarget(n),r=t.get(f.IEditorBridgeService);if(!e)return!1;const i=t.get(s.ICommandService),o=t.get(E.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,d=r.isVisible(),p=((h=n.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return i.executeCommand(xe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:p?I.ZEN_EDITOR:d.visible?I.EDITING:I.VIEWING})}},ce={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Hn(t))return!1;const n=t.get(s.ICommandService);return t.get(exports.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(Ie.id):n.executeCommand(je.id)}},Je=(t,n=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var i;const e=t.get(s.IUniverInstanceService),r=(i=t.get(fe.IRenderManagerService).getRenderById(n))==null?void 0:i.with(te.DocSelectionRenderService);return r?r.textSelectionInner$.pipe(R.map(()=>{const o=t.get(f.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=E.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Xe(l.worksheet,o.row,o.column)?!0:Nn(t)})):R.of(!0)},wt=t=>{const n=f.getCurrentRangeDisable$(t,{workbookTypes:[E.WorkbookEditablePermission],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetSetCellValuePermission,E.WorksheetInsertHyperlinkPermission],rangeTypes:[E.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),r=t.get(E.SheetsSelectionsService),i=t.has(f.IEditorBridgeService)?t.get(f.IEditorBridgeService):null,c=e.focused$.pipe(R.filter(o=>!!o),R.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),R.filter(o=>!!o),R.switchMap(o=>o.activeSheet$),R.switchMap(o=>r.selectionMoveEnd$.pipe(R.map(l=>o&&{selections:l,sheet:o}))),R.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const d=l[0].range.startRow,p=l[0].range.startColumn;if(Xe(u,d,p))return!0}),R.switchMap(o=>{if(o)return R.of(!0);const l=(i?i.visible$:R.of(null)).pipe(R.map(d=>d!=null&&d.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return R.combineLatest([l,u]).pipe(R.switchMap(([d,p])=>d?p?R.of(!0):Je(t,d):R.of(!1)))}));return n.pipe(R.distinctUntilChanged(),R.switchMap(o=>c.pipe(R.map(l=>o||l))))},Te={commandId:je.id,type:b.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},ke=t=>`${t}-zen-editor`,Un=t=>({...Te,id:Te.commandId,hidden$:b.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:wt(t)}),Mn=t=>({...Te,id:ke(Te.commandId),hidden$:b.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Je(t)}),Oe={tooltip:"hyperLink.form.addTitle",commandId:ce.id,type:b.MenuItemType.BUTTON,icon:"LinkSingle"},xn=t=>({...Oe,id:Oe.commandId,hidden$:b.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:wt(t)}),jn=t=>({...Oe,id:ke(Oe.commandId),hidden$:b.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Je(t)}),Qe={id:ce.id,binding:b.KeyCode.K|b.MetaKeys.CTRL_COMMAND,preconditions:f.whenSheetEditorFocused};var Bn=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,An=(t,n,e,r)=>{for(var i=r>1?void 0:r?$n(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Bn(n,e,i),i},ft=(t,n)=>(e,r)=>n(e,r,t);let be=class extends s.Disposable{constructor(t,n){super(),this._autoFillService=t,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),n=(r,i)=>{const{source:c,target:o,unitId:l,subUnitId:u}=r,d=f.virtualizeDiscreteRanges([c,o]),[p,h]=d.ranges,{mapFunc:S}=d,g={row:p.startRow,col:p.startColumn},C=f.getAutoFillRepeatRange(p,h),L=[],T=[];return C.forEach(a=>{const k=a.repeatStartCell,x=a.relativeRange,N={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},H={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(x,(V,$)=>{const ne=s.Rectangle.getPositionRange({startRow:V,startColumn:$,endColumn:$,endRow:V},N),{row:pe,col:ye}=S(ne.startRow,ne.startColumn),re=this._hyperLinkModel.getHyperLinkByLocation(l,u,pe,ye),de=s.Rectangle.getPositionRange({startRow:V,startColumn:$,endColumn:$,endRow:V},H),{row:he,col:ge}=S(de.startRow,de.startColumn),ie=s.Tools.generateRandomId(),F=this._hyperLinkModel.getHyperLinkByLocation(l,u,he,ge);F&&L.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:F.id}}),(f.APPLY_TYPE.COPY===i||f.APPLY_TYPE.SERIES===i)&&re&&(L.push({id:_.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...re,id:ie,row:he,column:ge}}}),T.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ie}})),F&&T.push({id:_.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:F}})})}),{undos:T,redos:L}},e={id:Ge,onFillData:(r,i,c)=>c===f.APPLY_TYPE.COPY||c===f.APPLY_TYPE.ONLY_FORMAT||c===f.APPLY_TYPE.SERIES?n(r,c):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};be=An([ft(0,f.IAutoFillService),ft(1,s.Inject(_.HyperLinkModel))],be);var Vn=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,Zn=(t,n,e,r)=>{for(var i=r>1?void 0:r?Fn(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Vn(n,e,i),i},Ke=(t,n)=>(e,r)=>n(e,r,t);let De=class extends s.Disposable{constructor(t,n,e){super(),this._localeService=t,this._commandService=n,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===Qe.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookEditablePermission],rangeTypes:[E.RangeProtectionPermissionEditPoint],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetSetCellValuePermission,E.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};De=Zn([Ke(0,s.Inject(s.LocaleService)),Ke(1,s.ICommandService),Ke(2,s.Inject(f.SheetPermissionInterceptorBaseController))],De);var Kn=Object.defineProperty,Wn=Object.getOwnPropertyDescriptor,Yn=(t,n,e,r)=>{for(var i=r>1?void 0:r?Wn(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Kn(n,e,i),i},z=(t,n)=>(e,r)=>n(e,r,t);let we=class extends s.Disposable{constructor(t,n,e,r,i,c,o,l,u,d){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=n,this._renderManagerService=e,this._permissionService=r,this._sheetPermissionInterceptorBaseController=i,this._commandService=c,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=d,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:n,subUnitId:e,row:r,col:i}=t,c=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!(c==null?void 0:c.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookViewPermission],worksheetTypes:[E.WorksheetViewPermission],rangeTypes:[E.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookEditablePermission],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetInsertHyperlinkPermission],rangeTypes:[E.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),d=this._permissionService.composePermission([new E.WorkbookCopyPermission(n).id,new E.WorksheetCopyPermission(n,e).id]).every(p=>p.value);return{viewPermission:l,editPermission:u,copyPermission:d}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(R.debounceTime(200)).subscribe(t=>{var N;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:e,row:r,col:i}=t,c=this._renderManagerService.getRenderById(n);if(!c)return;const o=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!c.with(f.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const d=(N=c==null?void 0:c.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:N.skeleton,p=i,h=r;let S=h,g=p;d&&d.overflowCache.forValue((H,V,$)=>{s.Rectangle.contains($,{startColumn:p,endColumn:p,startRow:h,endRow:h})&&(S=H,g=V)});const{viewPermission:C,editPermission:L,copyPermission:T}=this._getLinkPermission(t);if(!C){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const a=l.getCellStyleOnly(S,g),k=o.getStyles().getStyleByCell(a),x=k==null?void 0:k.tr;if(!x&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:S,col:g,editPermission:L,copyPermission:T,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:n,subUnitId:e,showAll:!!x})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(R.switchMap(n=>this._editorBridgeService.visible$.pipe(R.map(e=>({visible:e,state:n}))))).subscribe(({visible:n,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:r,unitId:i,sheetId:c,row:o,column:l}=e,u=this._renderManagerService.getRenderById(r);if(!u)return;const{editPermission:d,viewPermission:p,copyPermission:h}=this._getLinkPermission({unitId:i,subUnitId:c,row:o,col:l}),S=u.with(te.DocEventManagerService);p&&(t==null||t.unsubscribe(),t=S.hoverCustomRanges$.pipe(R.debounceTime(200)).subscribe(g=>{var k,x;const C=g.find(N=>N.range.rangeType===s.CustomRangeType.HYPERLINK);if(!C){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=C.rects[C.rects.length-1];if(!((x=(k=this._renderManagerService.getRenderById(i))==null?void 0:k.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(c))==null?void 0:x.skeleton)||!L)return;const a=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:i,subUnitId:c,row:o,col:l,customRange:C.range,customRangeRect:{left:L.left+a.left,top:L.top+a.top,bottom:L.bottom+a.top,right:L.right+a.left},editPermission:d,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(R.switchMap(t=>{const n=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return n?n.with(te.DocEventManagerService).hoverCustomRanges$.pipe(R.debounceTime(200)):new R.Observable(e=>{e.next(null)})})).subscribe(t=>{const n=t==null?void 0:t.find(r=>r.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(n&&e){const{unitId:r,sheetId:i,row:c,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:d}=this._getLinkPermission({unitId:r,subUnitId:i,row:c,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:r,subUnitId:i,row:c,col:o,customRange:n.range,editPermission:l,copyPermission:d})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[E.ClearSelectionContentCommand.id,E.ClearSelectionAllCommand.id,E.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{t.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};we=Yn([z(0,s.Inject(f.HoverManagerService)),z(1,s.Inject(exports.SheetsHyperLinkPopupService)),z(2,s.Inject(fe.IRenderManagerService)),z(3,s.Inject(s.IPermissionService)),z(4,s.Inject(f.SheetPermissionInterceptorBaseController)),z(5,s.ICommandService),z(6,f.IEditorBridgeService),z(7,s.Inject(me.DocSelectionManagerService)),z(8,s.IUniverInstanceService),z(9,b.IZenZoneService)],we);var Gn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,Ht=(t,n,e,r)=>{for(var i=r>1?void 0:r?zn(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Gn(n,e,i),i},We=(t,n)=>(e,r)=>n(e,r,t);let Ye=class extends s.Disposable{constructor(t,n){super(),this._context=t,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(R.debounceTime(16)).subscribe(()=>{t()}))}};Ye=Ht([We(1,s.Inject(_.HyperLinkModel))],Ye);let He=class extends s.Disposable{constructor(t,n){super(),this._sheetInterceptorService=t,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(E.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,n,e)=>{const{row:r,col:i,unitId:c,subUnitId:o}=n,l=this._hyperLinkModel.getHyperLinkByLocation(c,o,r,i);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=Ht([We(0,s.Inject(E.SheetInterceptorService)),We(1,s.Inject(_.HyperLinkModel))],He);const qn={[b.RibbonStartGroup.OTHERS]:{[ce.id]:{order:2,menuItemFactory:xn},[ke(ce.id)]:{order:2,menuItemFactory:jn}},[b.ContextMenuPosition.MAIN_AREA]:{[b.ContextMenuGroup.OTHERS]:{order:1,[ce.id]:{order:0,menuItemFactory:Un},[ke(ce.id)]:{order:0,menuItemFactory:Mn}}}};var Xn=Object.defineProperty,Jn=Object.getOwnPropertyDescriptor,Qn=(t,n,e,r)=>{for(var i=r>1?void 0:r?Jn(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Xn(n,e,i),i},_e=(t,n)=>(e,r)=>n(e,r,t);let Ne=class extends s.Disposable{constructor(t,n,e,r,i){super(),this._componentManager=t,this._commandService=n,this._menuManagerService=e,this._injector=r,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Pe,Pe.componentKey],[Le,Le.componentKey],[qe,"LinkSingle"]].forEach(([t,n])=>{this._componentManager.register(n,t)})}_initCommands(){[xe,Ie,je,ce].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(qn)}_initShortCut(){this._shortcutService.registerShortcut(Qe)}};Ne=Qn([_e(0,s.Inject(b.ComponentManager)),_e(1,s.ICommandService),_e(2,b.IMenuManagerService),_e(3,s.Inject(s.Injector)),_e(4,s.Inject(b.IShortcutService))],Ne);var er=Object.defineProperty,tr=Object.getOwnPropertyDescriptor,nr=(t,n,e,r)=>{for(var i=r>1?void 0:r?tr(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&er(n,e,i),i},yt=(t,n)=>(e,r)=>n(e,r,t);let Ue=class extends s.Disposable{constructor(t,n){super(),this._parserService=t,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const n=this._parserService.parseHyperLink(t);this._resolverService.navigate(n)}}};Ue=nr([yt(0,s.Inject(_.SheetsHyperLinkParserService)),yt(1,s.Inject(exports.SheetsHyperLinkResolverService))],Ue);var Nt=Object.defineProperty,rr=Object.getOwnPropertyDescriptor,ir=(t,n,e)=>n in t?Nt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,sr=(t,n,e,r)=>{for(var i=r>1?void 0:r?rr(n,e):n,c=t.length-1,o;c>=0;c--)(o=t[c])&&(i=(r?o(n,e,i):o(i))||i);return r&&i&&Nt(n,e,i),i},Ct=(t,n)=>(e,r)=>n(e,r,t),Ut=(t,n,e)=>ir(t,typeof n!="symbol"?n+"":n,e);exports.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(n=Gt,e,r){super(),this._config=n,this._injector=e,this._configService=r;const{menu:i,...c}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Et,c)}onStarting(){[[exports.SheetsHyperLinkResolverService],[exports.SheetsHyperLinkPopupService],[ze],[He],[we],[Ne],[be],[exports.SheetsHyperLinkCopyPasteController],[De],[Ue]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(fe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[Ye]),this._injector.get(be),this._injector.get(exports.SheetsHyperLinkCopyPasteController),this._injector.get(Ne)}onRendered(){this._injector.get(De),this._injector.get(Ue),this._injector.get(we)}};Ut(exports.UniverSheetsHyperLinkUIPlugin,"pluginName",Ge);Ut(exports.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkUIPlugin=sr([s.DependentOn(_.UniverSheetsHyperLinkPlugin,te.UniverDocsUIPlugin),Ct(1,s.Inject(s.Injector)),Ct(2,s.IConfigService)],exports.UniverSheetsHyperLinkUIPlugin);exports.CloseHyperLinkPopupOperation=Ie;exports.InsertHyperLinkOperation=je;exports.InsertLinkShortcut=Qe;exports.OpenHyperLinkEditPanelOperation=xe;exports.SheetsHyperLinkSidePanelService=ze;
|