@univerjs/sheets-hyper-link-ui 0.7.0-nightly.202505251606 → 0.8.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/LICENSE +176 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -2
- package/lib/index.css +1 -1
- package/lib/index.js +1 -2
- package/lib/umd/index.js +1 -1
- package/package.json +14 -14
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var At=Object.defineProperty;var Vt=(e,n,t)=>n in e?At(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var F=(e,n,t)=>Vt(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),C=require("@univerjs/sheets"),m=require("@univerjs/sheets-hyper-link"),E=require("@univerjs/sheets-ui"),T=require("@univerjs/design"),q=require("@univerjs/engine-formula"),I=require("@univerjs/ui"),ee=require("@univerjs/docs-ui"),ye=require("@univerjs/engine-render"),O=require("rxjs"),Ie=require("@univerjs/docs"),_=require("react/jsx-runtime"),Bt=require("@univerjs/sheets-formula-ui"),f=require("react"),mt=require("@univerjs/sheets-data-validation");function Pe(e){return s.Tools.isLegalUrl(e)}function $t(e){return/^[a-zA-Z]+:\/\//.test(e)}function Ft(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Zt(e){if(Pe(e)){const n=$t(e)?e:Ft(e)?`mailto://${e}`:`http://${e}`;let t;try{t=new URL(n)}catch{return e}return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:n}return e}const Rt="sheets-hyper-link-ui.config",It={};var Kt=Object.getOwnPropertyDescriptor,Wt=(e,n,t,r)=>{for(var i=r>1?void 0:r?Kt(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},ue=(e,n)=>(t,r)=>n(t,r,e);function Yt(e,n){const t=n.getMergeData(),r=n.getMaxColumns()-1,i=n.getMaxRows()-1;if(r<e.endColumn&&(e.endColumn=r),i<e.endRow&&(e.endRow=i),e.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return e;const o=[];return t.forEach(a=>{s.Rectangle.intersects(e,a)&&o.push(a)}),s.Rectangle.realUnion(e,...o)}exports.SheetsHyperLinkResolverService=class{constructor(n,t,r,i,o,a){this._univerInstanceService=n,this._commandService=t,this._definedNamesService=r,this._messageService=i,this._localeService=o,this._configService=a}navigate(n){switch(n.type){case m.SheetHyperLinkType.URL:this.navigateToOtherWebsite(n.url);break;default:this._navigateToUniver(n.searchObj)}}_navigateToUniver(n){const{gid:t,range:r,rangeid:i}=n,o=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return;const a=o.getUnitId();if(i){const u=this._definedNamesService.getValueById(a,i);if(!u)return;const{formulaOrRefString:l}=u,h=this._definedNamesService.getWorksheetByRef(a,l);if(!h){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:T.MessageType.Error});return}if(h.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:T.MessageType.Error});return}this.navigateToDefineName(a,i)}if(t){if(r){const u=q.deserializeRangeWithSheet(r);s.isValidRange(u.range)&&r!==m.ERROR_RANGE&&this.navigateToRange(a,t,u.range);return}this.navigateToSheetById(a,t)}}async navigateToRange(n,t,r,i){const o=await this.navigateToSheetById(n,t);if(o){const a=Yt(r,o);await this._commandService.executeCommand(C.SetSelectionsOperation.id,{unitId:n,subUnitId:t,selections:[{range:a,primary:null}]}),await this._commandService.executeCommand(E.ScrollToRangeOperation.id,{range:a,forceTop:i})}}async navigateToSheetById(n,t){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()===t)return i;const o=r.getSheetBySheetId(t);return o?r.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:T.MessageType.Error}),!1):await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:t})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:T.MessageType.Error}),!1)}async navigateToDefineName(n,t){return this._definedNamesService.focusRange(n,t),!0}async navigateToOtherWebsite(n){var r;const t=this._configService.getConfig(Rt);if((r=t==null?void 0:t.urlHandler)!=null&&r.navigateToOtherWebsite)return t.urlHandler.navigateToOtherWebsite(n);window.open(n,"_blank","noopener noreferrer")}};exports.SheetsHyperLinkResolverService=Wt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,q.IDefinedNamesService),ue(3,I.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],exports.SheetsHyperLinkResolverService);const Ge="SHEET_HYPER_LINK_UI_PLUGIN";var Gt=Object.getOwnPropertyDescriptor,zt=(e,n,t,r)=>{for(var i=r>1?void 0:r?Gt(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Re=(e,n)=>(t,r)=>n(t,r,e);exports.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(t,r,i,o){super();F(this,"_plainTextFilter",new Set);F(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=r,this._injector=i,this._resolverService=o,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(t){this._plainTextFilter.add(t)}removePlainTextFilter(t){this._plainTextFilter.delete(t)}_filterPlainText(t){return Array.from(this._plainTextFilter).every(r=>r(t))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ge,onBeforeCopy:(t,r,i)=>this._collect(t,r,i),onPasteCells:(t,r,i,o)=>{const{copyType:a=E.COPY_TYPE.COPY,pasteType:u}=o,{range:l}=t||{},{range:h,unitId:d,subUnitId:p}=r;return this._generateMutations(h,{copyType:a,pasteType:u,copyRange:l,unitId:d,subUnitId:p})},onPastePlainText:(t,r)=>{const i=this._filterPlainText(r);if(Pe(r)&&i){const{range:o,unitId:a,subUnitId:u}=t,{ranges:[l],mapFunc:h}=E.virtualizeDiscreteRanges([o]),d=[],p=[];return s.Range.foreach(l,(S,v)=>{const{row:R,col:P}=h(S,v),L=this._hyperLinkModel.getHyperLinkByLocation(a,u,R,P);L&&d.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:u,id:L.id}}),L&&p.push({id:m.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:u,link:L}})}),{redos:d,undos:p}}return{undos:[],redos:[]}},priority:99})}_collect(t,r,i){const o=new s.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:r,matrix:o};const a=this._injector.invoke(h=>C.rangeToDiscreteRange(i,h,t,r));if(!a)return;const{rows:u,cols:l}=a;u.forEach((h,d)=>{l.forEach((p,S)=>{var R;const v=this._hyperLinkModel.getHyperLinkByLocation(t,r,h,p);o.setValue(d,S,(R=v==null?void 0:v.id)!=null?R:"")})})}_generateMutations(t,r){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{unitId:o,subUnitId:a}=this._copyInfo,u=[],l=[],{ranges:[h,d],mapFunc:p}=E.virtualizeDiscreteRanges([r.copyRange,t]);return E.getRepeatRange(h,d,!0).forEach(({startRange:v})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((P,L,c)=>{const k=s.Rectangle.getPositionRange({startRow:P,endRow:P,startColumn:L,endColumn:L},v),M=this._hyperLinkModel.getHyperLink(o,a,c),{row:N,col:H}=p(k.startRow,k.startColumn),V=this._hyperLinkModel.getHyperLinkByLocation(r.unitId,r.subUnitId,N,H),A=s.Tools.generateRandomId();V&&u.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,id:V.id}}),M&&(u.push({id:m.AddHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,link:{...M,id:A,row:N,column:H}}}),l.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,id:A}})),V&&l.push({id:m.AddHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,link:V}})})}),{redos:u,undos:l}}};exports.SheetsHyperLinkCopyPasteController=zt([Re(0,E.ISheetClipboardService),Re(1,s.Inject(m.HyperLinkModel)),Re(2,s.Inject(s.Injector)),Re(3,s.Inject(exports.SheetsHyperLinkResolverService))],exports.SheetsHyperLinkCopyPasteController);var y=(e=>(e.EDITING="editing",e.VIEWING="viewing",e.ZEN_EDITOR="zen_mode",e))(y||{});class ze extends s.Disposable{constructor(){super(...arguments);F(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==m.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(i=>i.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:r}=this;r.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const Te=()=>{var nt;const[e,n]=f.useState(""),[t,r]=f.useState(!1),[i,o]=f.useState(""),[a,u]=f.useState(!0),[l,h]=f.useState(m.SheetHyperLinkType.URL),[d,p]=f.useState(""),S=I.useDependency(s.LocaleService),v=I.useDependency(q.IDefinedNamesService),R=I.useDependency(E.IEditorBridgeService),P=I.useDependency(s.IUniverInstanceService),L=I.useDependency(exports.SheetsHyperLinkPopupService),c=I.useObservable(L.currentEditing$),k=I.useDependency(m.SheetsHyperLinkParserService),M=I.useDependency(exports.SheetsHyperLinkResolverService),N=I.useDependency(s.ICommandService),H=I.useDependency(ze),V=f.useMemo(()=>H.getOptions(),[H]),A=I.useDependency(I.IZenZoneService),G=I.useDependency(ye.IRenderManagerService),le=I.useDependency(E.IMarkSelectionService),fe=I.useDependency(Ie.DocSelectionManagerService),te=I.useDependency(s.IContextService),de=I.useDependency(s.ThemeService),pe=I.useDependency(Ie.DocSelectionManagerService),[he,Ce]=f.useState(!1),oe=I.useDependency(C.SheetsSelectionsService),Nt=f.useMemo(()=>oe.getCurrentSelections(),[]),Ee=f.useMemo(()=>{if(!H.isBuiltInLinkType(l))return H.getCustomHyperLink(l)},[H,l]),[ae,Ht]=f.useState(!1),[ge,et]=f.useState(!1),B=f.useRef(!1),Z=P.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),xt=(Z==null?void 0:Z.getActiveSheet().getSheetId())||"",X=f.useCallback(g=>{o(g.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[o]);f.useEffect(()=>{var g,b,D,w,U,K,rt,it,st,ot,at,ct,ut,lt,dt,pt,ht;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:ne,row:Fe,col:Ze}=c;let{label:z}=c;typeof z=="number"&&(z=`${z}`);let W;if(ne)W={id:(g=ne==null?void 0:ne.rangeId)!=null?g:"",display:z!=null?z:"",payload:(D=(b=ne==null?void 0:ne.properties)==null?void 0:b.url)!=null?D:"",row:Fe,column:Ze};else if(c.type===y.VIEWING){const x=P.getUnit(c.unitId),Q=x==null?void 0:x.getSheetBySheetId(c.subUnitId),j=Q==null?void 0:Q.getCellRaw(c.row,c.col),ce=(K=(U=(w=j==null?void 0:j.p)==null?void 0:w.body)==null?void 0:U.customRanges)==null?void 0:K.find(vt=>{var St;return vt.rangeType===s.CustomRangeType.HYPERLINK&&((St=vt.properties)==null?void 0:St.url)}),ve=j==null?void 0:j.v;j&&(!s.BuildTextUtils.transform.isEmptyDocument((it=(rt=j.p)==null?void 0:rt.body)==null?void 0:it.dataStream)||s.Tools.isDefine(ve))&&u(!1),W={id:"",display:"",payload:(ot=(st=ce==null?void 0:ce.properties)==null?void 0:st.url)!=null?ot:"",row:Fe,column:Ze}}else{const x=P.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),Q=fe.getActiveTextRange(),j=x==null?void 0:x.getBody(),ce=Q&&j?Q:null,ve=ce&&((ct=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ce,(at=j==null?void 0:j.customRanges)!=null?at:[]))==null?void 0:ct[0]);u(!1),W={id:"",display:z!=null?z:"",payload:(lt=(ut=ve==null?void 0:ve.properties)==null?void 0:ut.url)!=null?lt:"",row:Fe,column:Ze}}n(W.id);const gt=H.findCustomHyperLink(W);if(gt){const x=gt.convert(W);h(x.type),p(x.payload),X(x.display);return}X(W.display);const J=k.parseHyperLink(W.payload);switch(h(J.type===m.SheetHyperLinkType.INVALID?m.SheetHyperLinkType.RANGE:J.type),J.type){case m.SheetHyperLinkType.URL:{p(J.url),J.url===W.display&&(B.current=!0);break}case m.SheetHyperLinkType.RANGE:{const x=J.searchObj,Q=x.gid&&(ht=(pt=(dt=P.getUnit(c.unitId))==null?void 0:dt.getSheetBySheetId(x.gid))==null?void 0:pt.getName())!=null?ht:"",j=q.serializeRangeWithSheet(Q,q.deserializeRangeWithSheet(x.range).range);p(j),j===W.display&&(B.current=!0);break}case m.SheetHyperLinkType.SHEET:{const x=J.searchObj;p(x.gid);break}case m.SheetHyperLinkType.DEFINE_NAME:{const x=J.searchObj;p(x.rangeid);break}default:p("");break}}},[c,M,H,fe,P]),f.useEffect(()=>{let g=null;if(c&&!c.customRangeId&&c.type===y.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=P.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),D=b==null?void 0:b.getSheetBySheetId(c.subUnitId),w=D==null?void 0:D.getMergedCell(c.row,c.col),U=new s.ColorKit(de.getColorFromTheme("primary.600")).toRgb();g=le.addShape({range:w!=null?w:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${U.r}, ${U.g}, ${U.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{g&&le.removeShape(g)}},[c,le,de,P]),f.useEffect(()=>{et(l===m.SheetHyperLinkType.RANGE)},[l]),f.useEffect(()=>{const g=(c==null?void 0:c.type)===y.ZEN_EDITOR?G.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):G.getRenderById(R.getCurrentEditorId()),b=new s.DisposableCollection;if(g){const D=g.with(ee.DocSelectionRenderService);D.setReserveRangesStatus(!0),b.add(()=>{D.setReserveRangesStatus(!1)})}return()=>{R.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,R,G]),f.useEffect(()=>(ge&&L.setIsKeepVisible(ge),L.setIsKeepVisible(he),()=>{L.setIsKeepVisible(!1)}),[ge,he,L]),f.useEffect(()=>()=>{A.temporaryHidden&&(A.show(),te.setContextValue(s.FOCUSING_SHEET,!1))},[te,A]),f.useEffect(()=>{if(ge)return R.enableForceKeepVisible(),()=>{R.disableForceKeepVisible()}},[ge,R]);const Ut=[{label:S.t("hyperLink.form.link"),value:m.SheetHyperLinkType.URL},{label:S.t("hyperLink.form.range"),value:m.SheetHyperLinkType.RANGE},{label:S.t("hyperLink.form.worksheet"),value:m.SheetHyperLinkType.SHEET},{label:S.t("hyperLink.form.definedName"),value:m.SheetHyperLinkType.DEFINE_NAME},...V];if(!Z)return;const Mt=Z.getHiddenWorksheets(),Ve=Z.getSheets().map(g=>({label:g.getName(),value:g.getSheetId()})).filter(g=>Mt.indexOf(g.value)===-1),Be=Object.values((nt=v.getDefinedNameMap(Z.getUnitId()))!=null?nt:{}).map(g=>({label:g.name,value:g.id})),tt=(g,b)=>{if(g===m.SheetHyperLinkType.URL)return Zt(b);if(g===m.SheetHyperLinkType.RANGE){const D=q.deserializeRangeWithSheet(b),w=Z.getSheetBySheetName(D.sheetName);if(w)return`#gid=${w.getSheetId()}&range=${q.serializeRange(D.range)}`}return`#${g}=${b}`},jt=I.useEvent(g=>{var U;const D=g.split(",").map(q.deserializeRangeWithSheet)[0];if(!D||!s.isValidRange(D.range))return;D.sheetName||(D.sheetName=((U=Z.getActiveSheet())==null?void 0:U.getName())||"");const w=q.serializeRangeToRefString(D);p(w),w&&(B.current||!i)&&(X(w),B.current=!0)}),$e=async()=>{if(a&&!i||!d||l===m.SheetHyperLinkType.URL&&!Pe(d)){Ht(!0);return}if(c)if(e){const g=c.type===y.ZEN_EDITOR||c.type===y.EDITING?m.UpdateRichHyperLinkCommand.id:m.UpdateHyperLinkCommand.id;await N.executeCommand(g,{id:e,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:a?i:"",payload:tt(l,d)},row:c.row,column:c.col,documentId:c.type===y.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:R.getCurrentEditorId()})}else{const g=c.type===y.ZEN_EDITOR||c.type===y.EDITING?m.AddRichHyperLinkCommand.id:m.AddHyperLinkCommand.id;await N.executeCommand(g,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:tt(l,d),display:a?i:""},documentId:c.type===y.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:R.getCurrentEditorId()})}if((c==null?void 0:c.type)===y.VIEWING){await N.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const g=1;await N.executeCommand(E.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-g,0),endRow:c.row+g,startColumn:Math.max(c.col-g,0),endColumn:c.col+g}})}N.executeCommand(_e.id)};return c?_.jsxs("div",{className:T.clsx("univer-box-border univer-w-[296px] univer-rounded-xl univer-bg-white univer-p-4 univer-shadow-md dark:!univer-bg-gray-900",T.borderClassName),children:[a?_.jsx(T.FormLayout,{label:S.t("hyperLink.form.label"),error:ae&&!i?S.t("hyperLink.form.inputError"):"",children:_.jsx(T.Input,{value:i,onChange:g=>{X(g),B.current=!1},placeholder:S.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:g=>{g.keyCode===I.KeyCode.ENTER&&$e()}})}):null,_.jsx(T.FormLayout,{label:S.t("hyperLink.form.type"),children:_.jsx(T.Select,{className:"univer-w-full",options:Ut,value:l,onChange:g=>{h(g),p("")}})}),l===m.SheetHyperLinkType.URL&&_.jsx(T.FormLayout,{error:ae?d?Pe(d)?"":S.t("hyperLink.form.linkError"):S.t("hyperLink.form.inputError"):"",children:_.jsx(T.Input,{value:d,onChange:g=>{p(g),g&&(B.current||!i||i===g)&&(X(g),B.current=!0)},placeholder:S.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:g=>{g.keyCode===I.KeyCode.ENTER&&$e()}})}),l===m.SheetHyperLinkType.RANGE&&_.jsx(T.FormLayout,{error:ae&&!d?S.t("hyperLink.form.inputError"):"",children:_.jsx(Bt.RangeSelector,{unitId:Z.getUnitId(),subUnitId:xt,maxRangeCount:1,supportAcrossSheet:!0,initialValue:d,resetRange:Nt,onChange:(g,b)=>jt(b),onRangeSelectorDialogVisibleChange:async g=>{var b,D;if(Ce(g),g)c.type===y.ZEN_EDITOR&&(A.hide(),te.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==y.VIEWING&&R.enableForceKeepVisible(),r(!0);else{if(await M.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===y.ZEN_EDITOR){await N.executeCommand(C.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),A.show(),te.setContextValue(s.FOCUSING_SHEET,!1);const w=(b=G.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(ee.DocBackScrollRenderController),U=(D=pe.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:D[0];w&&U&&(w.scrollToRange(U),pe.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}R.disableForceKeepVisible(),r(!1)}},onFocusChange:g=>et(g)})}),l===m.SheetHyperLinkType.SHEET&&_.jsx(T.FormLayout,{error:ae&&!d?S.t("hyperLink.form.selectError"):"",children:_.jsx(T.Select,{className:"univer-w-full",options:Ve,value:d,onChange:g=>{var w,U;p(g);const b=(w=Ve.find(K=>K.value===g))==null?void 0:w.label,D=(U=Ve.find(K=>K.value===d))==null?void 0:U.label;b&&(B.current||!i||i===D)&&(X(b),B.current=!0)}})}),l===m.SheetHyperLinkType.DEFINE_NAME&&_.jsx(T.FormLayout,{error:ae&&!d?S.t("hyperLink.form.selectError"):"",children:_.jsx(T.Select,{className:"univer-w-full",options:Be,value:d,onChange:g=>{var w,U;p(g);const b=(w=Be.find(K=>K.value===g))==null?void 0:w.label,D=(U=Be.find(K=>K.value===d))==null?void 0:U.label;b&&(B.current||!i||i===D)&&(X(b),B.current=!0)}})}),(Ee==null?void 0:Ee.Form)&&_.jsx(Ee.Form,{linkId:e,payload:d,display:i,showError:ae,setByPayload:B,setDisplay:g=>{X(g),B.current=!0},setPayload:p}),_.jsxs("div",{className:"univer-flex univer-flex-row univer-justify-end",children:[_.jsx(T.Button,{onClick:()=>{c&&M.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),N.executeCommand(_e.id)},children:S.t("hyperLink.form.cancel")}),_.jsx(T.Button,{variant:"primary",style:{marginLeft:8},onClick:async()=>{$e()},children:S.t("hyperLink.form.ok")})]})]}):null};Te.componentKey="univer.sheet.cell-link-edit";var $=function(){return $=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},$.apply(this,arguments)},qt=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(t[r[i]]=e[r[i]]);return t},se=f.forwardRef(function(e,n){var t=e.icon,r=e.id,i=e.className,o=e.extend,a=qt(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),l=f.useRef("_".concat(Qt()));return Lt(t,"".concat(r),{defIds:t.defIds,idSuffix:l.current},$({ref:n,className:u},a),o)});function Lt(e,n,t,r,i){return f.createElement(e.tag,$($({key:n},Xt(e,t,i)),r),(Jt(e,t).children||[]).map(function(o,a){return Lt(o,"".concat(n,"-").concat(e.tag,"-").concat(a),t,void 0,i)}))}function Xt(e,n,t){var r=$({},e.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+n.idSuffix),Object.entries(r).forEach(function(o){var a=o[0],u=o[1];a==="mask"&&typeof u=="string"&&(r[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+n.idSuffix),Object.entries(r).forEach(function(o){var a=o[0],u=o[1];typeof u=="string"&&(r[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),r}function Jt(e,n){var t,r=n.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?$($({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?$($({},i),{attrs:$($({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function Qt(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var en={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"all-border-single",ref:n,icon:en}))});Le.displayName="AllBorderSingle";var tn={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"}}]},Pt=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"copy-single",ref:n,icon:tn}))});Pt.displayName="CopySingle";var nn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},qe=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"link-single",ref:n,icon:nn}))});qe.displayName="LinkSingle";var rn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},Tt=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"unlink-single",ref:n,icon:rn}))});Tt.displayName="UnlinkSingle";var sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},kt=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"write-single",ref:n,icon:sn}))});kt.displayName="WriteSingle";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.4538 1.12549C2.70051 1.12549 2.08984 1.73615 2.08984 2.48945V13.5104C2.08984 14.2637 2.70051 14.8744 3.4538 14.8744H12.5468C13.3001 14.8744 13.9108 14.2637 13.9108 13.5104V5.0992L10.0094 1.12549H3.4538Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M10.0078 1.12549L13.9107 5.09842H10.6745C10.3063 5.09842 10.0078 4.79994 10.0078 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.80941 10.2949L6.37701 12.403C6.2632 12.5705 6.03516 12.614 5.86766 12.5002C5.70017 12.3864 5.65664 12.1584 5.77045 11.9909L7.36611 9.64252L5.94103 7.54519C5.82722 7.37769 5.87074 7.14964 6.03824 7.03583C6.20573 6.92202 6.43378 6.96555 6.54759 7.13304L7.80941 8.9901L9.07123 7.13304C9.18504 6.96555 9.41309 6.92202 9.58059 7.03583C9.74808 7.14964 9.7916 7.37769 9.67779 7.54519L8.25271 9.64252L9.84837 11.9909C9.96218 12.1584 9.91866 12.3864 9.75116 12.5002C9.58366 12.614 9.35562 12.5705 9.24181 12.403L7.80941 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},bt=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"xlsx",ref:n,icon:on}))});bt.displayName="Xlsx";const an={[m.SheetHyperLinkType.URL]:_.jsx(qe,{}),[m.SheetHyperLinkType.SHEET]:_.jsx(bt,{}),[m.SheetHyperLinkType.RANGE]:_.jsx(Le,{}),[m.SheetHyperLinkType.DEFINE_NAME]:_.jsx(Le,{}),[m.SheetHyperLinkType.INVALID]:_.jsx(Le,{})},_t=e=>{var M,N;const n=I.useDependency(exports.SheetsHyperLinkPopupService),t=I.useDependency(s.ICommandService),r=I.useDependency(I.IMessageService),i=I.useDependency(s.LocaleService),o=I.useDependency(exports.SheetsHyperLinkResolverService),a=I.useDependency(E.IEditorBridgeService),u=I.useDependency(m.SheetsHyperLinkParserService),l=I.useDependency(I.IZenZoneService),{customRange:h,row:d,col:p,unitId:S,subUnitId:v,editPermission:R,copyPermission:P,type:L}=e;if(!((M=h==null?void 0:h.properties)!=null&&M.url))return null;const c=u.parseHyperLink((N=h.properties.url)!=null?N:""),k=c.type===m.SheetHyperLinkType.INVALID;return _.jsxs("div",{className:T.clsx("univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow-md dark:!univer-bg-gray-900",T.borderClassName),onClick:()=>n.hideCurrentPopup(),children:[_.jsxs("div",{className:T.clsx("univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600",{"univer-text-red-500":k}),onClick:()=>{l.visible||k||o.navigate(c)},children:[_.jsx("div",{className:"univer-mr-2 univer-flex univer-h-5 univer-w-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white",children:an[c.type]}),_.jsx(T.Tooltip,{showIfEllipsis:!0,title:c.name,asChild:!0,children:_.jsx("span",{className:"univer-flex-1 univer-overflow-hidden univer-text-ellipsis",children:c.name})})]}),_.jsxs("div",{className:"univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center",children:[P&&_.jsx("div",{className:T.clsx("univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-text-red-500":k}),onClick:()=>{if(!k){if(c.type!==m.SheetHyperLinkType.URL){const H=new URL(window.location.href);H.hash=c.url.slice(1),navigator.clipboard.writeText(H.href)}else navigator.clipboard.writeText(c.url);r.show({content:i.t("hyperLink.message.coped"),type:T.MessageType.Info})}},children:_.jsx(T.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.copy"),children:_.jsx(Pt,{className:"dark:!univer-text-white"})})}),R&&_.jsxs(_.Fragment,{children:[_.jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",onClick:()=>{t.executeCommand(je.id,{unitId:S,subUnitId:v,row:d,col:p,customRangeId:h.rangeId,type:L})},children:_.jsx(T.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.edit"),children:_.jsx(kt,{className:"dark:!univer-text-white"})})}),_.jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",onClick:()=>{const H=L===y.EDITING||L===y.ZEN_EDITOR?m.CancelRichHyperLinkCommand.id:m.CancelHyperLinkCommand.id;t.syncExecuteCommand(H,{unitId:S,subUnitId:v,id:h.rangeId,row:d,column:p,documentId:L===y.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:a.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:_.jsx(T.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.cancel"),children:_.jsx(Tt,{className:"dark:!univer-text-white"})})})]})]})]})},ke=()=>{var i,o;const e=I.useDependency(exports.SheetsHyperLinkPopupService),[n,t]=f.useState(null),r=I.useDependency(s.IUniverInstanceService);if(f.useEffect(()=>{t(e.currentPopup);const a=e.currentPopup$.subscribe(u=>{t(u)});return()=>{a.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){const a=r.getUnit(n.unitId,s.UniverInstanceType.UNIVER_SHEET),u=a==null?void 0:a.getSheetBySheetId(n.subUnitId),l=u==null?void 0:u.getCell(n.row,n.col),h=(o=(i=l==null?void 0:l.p)==null?void 0:i.body)==null?void 0:o.customRanges;return h!=null&&h.length?_.jsx("div",{children:h.map(d=>_.jsx(_t,{...n,customRange:d},d.rangeId))}):null}return _.jsx(_t,{...n})};ke.componentKey="univer.sheet.cell-link-popup";var cn=Object.getOwnPropertyDescriptor,un=(e,n,t,r)=>{for(var i=r>1?void 0:r?cn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},re=(e,n)=>(t,r)=>n(t,r,e);const yt=(e,n)=>{var t,r;return e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.row===n.row&&e.col===n.col&&((t=e.customRange)==null?void 0:t.rangeId)===((r=n.customRange)==null?void 0:r.rangeId)&&e.type===n.type};exports.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(t,r,i,o,a,u,l){super();F(this,"_currentPopup",null);F(this,"_currentPopup$",new O.Subject);F(this,"currentPopup$",this._currentPopup$.asObservable());F(this,"_currentEditingPopup",null);F(this,"_currentEditing$",new O.BehaviorSubject(null));F(this,"currentEditing$",this._currentEditing$.asObservable());F(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=r,this._univerInstanceService=i,this._editorBridgeService=o,this._textSelectionManagerService=a,this._docCanvasPopManagerService=u,this._zenZoneService=l,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){if(this._currentPopup&&yt(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==y.ZEN_EDITOR&&this._zenZoneService.visible))return;const r=this._currentEditing$.getValue();if(r&&yt(t,r))return;const{unitId:i,subUnitId:o,row:a,col:u,customRangeRect:l,customRange:h}=t;let d;const p={componentKey:ke.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===y.EDITING){if(!h)return;d=l&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(l,p)}else if(t.type===y.ZEN_EDITOR){if(!h)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:h.startIndex,endOffset:h.endIndex+1,collapsed:!1},p,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,p,i,o);else{if(!h)return;d=l&&this._sheetCanvasPopManagerService.attachPopupByPosition(l,p,t)}d&&(this._currentPopup={unitId:i,subUnitId:o,disposable:d,row:a,col:u,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:h,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,r){var i,o;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||r)&&((o=(i=this._currentPopup)==null?void 0:i.disposable)==null||o.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var i,o,a;const t=this._editorBridgeService.isVisible().visible,r=this._editorBridgeService.getEditCellState();if(t&&r){const u=this._textSelectionManagerService.getActiveTextRange(),l=(i=r.documentLayoutObject.documentModel)==null?void 0:i.getBody();if(!l)return null;if(!u||u.collapsed)return{startOffset:0,endOffset:l.dataStream.length-2,collapsed:l.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(l.dataStream)};const h=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(u,(a=(o=l.customRanges)==null?void 0:o.filter(S=>S.rangeType===s.CustomRangeType.HYPERLINK))!=null?a:[]);let d=u.startOffset,p=u.endOffset;return h.forEach(S=>{d=Math.min(d,S.startIndex),p=Math.max(p,S.endIndex+1)}),{startOffset:d,endOffset:p,collapsed:d===p,label:s.BuildTextUtils.transform.getPlainText(l.dataStream.slice(d,p))}}return null}get _editPopup(){return{componentKey:Te.componentKey,direction:"vertical",onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var a,u,l,h,d;const{unitId:r,subUnitId:i,type:o}=t;if(o===y.ZEN_EDITOR){const p=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!p)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 v=(a=p.getBody())==null?void 0:a.dataStream.slice(S.startOffset,S.endOffset);this._currentEditing$.next({...t,label:v})}else if(o===y.EDITING){const p=this._getEditingRange();if(!p)return;this._textSelectionManagerService.replaceDocRanges([{...p}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const S=this._injector.get(ye.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!S)return;const v=ee.calcDocRangePositions(p,S);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,r,i),this._currentEditing$.next({...t,label:(u=p==null?void 0:p.label)!=null?u:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,r,i);const p=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),S=p==null?void 0:p.getSheetBySheetId(i),v=S==null?void 0:S.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:v!=null&&v.p?s.BuildTextUtils.transform.getPlainText((h=(l=v.p.body)==null?void 0:l.dataStream)!=null?h:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(t){var u,l,h,d,p,S;(u=this._currentEditingPopup)==null||u.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:r,subUnitId:i}=t;let o,a;if(t.type===y.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(o=(h=(l=v==null?void 0:v.getBody())==null?void 0:l.customRanges)==null?void 0:h.find(R=>R.rangeId===t.customRangeId),a=o?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(o.startIndex,o.endIndex+1):"",!o||!a)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:o.startIndex,endOffset:o.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===y.EDITING){const v=E.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!v||!((p=v.rects)!=null&&p.length))return;o=v.customRange,a=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,r,i)}else{const v=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),R=v==null?void 0:v.getSheetBySheetId(i),P=R==null?void 0:R.getCellRaw(t.row,t.col),L=v==null?void 0:v.getStyles().getStyleByCell(P),c=L==null?void 0:L.tr,k=E.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!k||!((S=k.rects)!=null&&S.length))return;o=k.customRange,a=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,r,i):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:r,subUnitId:i,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:o,label:a})}endEditing(t){var i;if(this.getIsKeepVisible())return;const r=this._currentEditing$.getValue();r&&(!t||t===r.type)&&((i=this._currentEditingPopup)==null||i.dispose(),this._currentEditing$.next(null))}};exports.SheetsHyperLinkPopupService=un([re(0,s.Inject(E.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,E.IEditorBridgeService),re(4,s.Inject(Ie.DocSelectionManagerService)),re(5,s.Inject(ee.DocCanvasPopManagerService)),re(6,I.IZenZoneService)],exports.SheetsHyperLinkPopupService);var me=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(me||{});const ln=new Set([s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE]),Xe=(e,n,t,r)=>{var u,l,h,d,p;const i=n.getCell(t,r);if(i!=null&&i.f||i!=null&&i.si||(h=(l=(u=i==null?void 0:i.p)==null?void 0:u.body)==null?void 0:l.customBlocks)!=null&&h.length)return 1;const o=e.has(mt.SheetDataValidationModel)?e.get(mt.SheetDataValidationModel):null,a=o==null?void 0:o.getRuleByLocation(n.getUnitId(),n.getSheetId(),t,r);return a&&ln.has(a.type)?!0:(p=(d=i==null?void 0:i.p)==null?void 0:d.drawingsOrder)!=null&&p.length?2:0},dn=e=>{const n=e.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const t=n.getActiveSheet(),r=e.get(C.SheetsSelectionsService).getCurrentSelections();if(!r.length)return!0;const i=r[0].range.startRow,o=r[0].range.startColumn;return Xe(e,t,i,o)===1},pn=e=>{const n=e.get(Ie.DocSelectionManagerService),t=e.get(s.IUniverInstanceService),r=n.getTextRanges();if(!(r!=null&&r.length))return!0;const i=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);return!!(!i||r.every(a=>a.collapsed)||!i.getSelfOrHeaderFooterModel(r[0].segmentId).getBody())},je={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,n){if(!n)return!1;const t=e.get(exports.SheetsHyperLinkPopupService);return n.customRangeId?t.startEditing(n):t.startAddEditing(n),!0}},_e={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(exports.SheetsHyperLinkPopupService).endEditing(),!0}},Ae={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var p;const n=e.get(s.IUniverInstanceService),t=C.getSheetCommandTarget(n),r=e.get(E.IEditorBridgeService);if(!t)return!1;const i=e.get(s.ICommandService),a=e.get(C.SheetsSelectionsService).getCurrentLastSelection();if(!a)return!1;const u=a.range.startRow,l=a.range.startColumn,h=r.isVisible(),d=((p=n.getFocusedUnit())==null?void 0:p.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return i.executeCommand(je.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:u,col:l,type:d?y.ZEN_EDITOR:h.visible?y.EDITING:y.VIEWING})}},ie={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(dn(e))return!1;const n=e.get(s.ICommandService);return e.get(exports.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(_e.id):n.executeCommand(Ae.id)}},Je=(e,n=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var i;const t=e.get(s.IUniverInstanceService),r=(i=e.get(ye.IRenderManagerService).getRenderById(n))==null?void 0:i.with(ee.DocSelectionRenderService);return r?r.textSelectionInner$.pipe(O.map(()=>{const a=e.get(E.IEditorBridgeService).getEditCellState();if(!a)return!0;const u=C.getSheetCommandTarget(t,{unitId:a.unitId,subUnitId:a.sheetId});return!(u!=null&&u.worksheet)||Xe(e,u.worksheet,a.row,a.column)===1?!0:pn(e)})):O.of(!0)},Dt=e=>{var i;const n=e.get(s.IUniverInstanceService),t=e.has(E.IEditorBridgeService)?e.get(E.IEditorBridgeService):null;return((i=t==null?void 0:t.currentEditCellState$.pipe(O.map(o=>{if(!o)return me.DISABLED_BY_CELL;const a=C.getSheetCommandTarget(n,{unitId:o.unitId,subUnitId:o.sheetId});return a?Xe(e,a.worksheet,o.row,o.column):me.DISABLED_BY_CELL}),O.switchMap(o=>{if(o===me.DISABLED_BY_CELL)return O.of(!0);const a=t?t.visible$:O.of(null);return O.combineLatest([a,n.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_DOC)]).pipe(O.switchMap(([u,l])=>u!=null&&u.visible?(l==null?void 0:l.getUnitId())===s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?O.of(!0):Je(e,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):O.of(o!==me.ALLOWED)))})))!=null?i:O.of(!0)).pipe(O.switchMap(o=>o?O.of(!0):E.getCurrentRangeDisable$(e,{workbookTypes:[C.WorkbookEditablePermission],worksheetTypes:[C.WorksheetEditPermission,C.WorksheetSetCellValuePermission,C.WorksheetInsertHyperlinkPermission],rangeTypes:[C.RangeProtectionPermissionEditPoint]},!0)))},be={commandId:Ae.id,type:I.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=e=>`${e}-zen-editor`,hn=e=>({...be,id:be.commandId,hidden$:I.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:Dt(e)}),gn=e=>({...be,id:De(be.commandId),hidden$:I.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Je(e)}),Oe={tooltip:"hyperLink.form.addTitle",commandId:ie.id,type:I.MenuItemType.BUTTON,icon:"LinkSingle"},vn=e=>({...Oe,id:Oe.commandId,hidden$:I.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:Dt(e)}),Sn=e=>({...Oe,id:De(Oe.commandId),hidden$:I.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Je(e)}),Qe={id:ie.id,binding:I.KeyCode.K|I.MetaKeys.CTRL_COMMAND,preconditions:E.whenSheetEditorFocused};var mn=Object.getOwnPropertyDescriptor,In=(e,n,t,r)=>{for(var i=r>1?void 0:r?mn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},ft=(e,n)=>(t,r)=>n(t,r,e);let we=class extends s.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(r,i)=>{const{source:o,target:a,unitId:u,subUnitId:l}=r,h=E.virtualizeDiscreteRanges([o,a]),[d,p]=h.ranges,{mapFunc:S}=h,v={row:d.startRow,col:d.startColumn},R=E.getAutoFillRepeatRange(d,p),P=[],L=[];return R.forEach(c=>{const k=c.repeatStartCell,M=c.relativeRange,N={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},H={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(M,(V,A)=>{const G=s.Rectangle.getPositionRange({startRow:V,startColumn:A,endColumn:A,endRow:V},N),{row:le,col:fe}=S(G.startRow,G.startColumn),te=this._hyperLinkModel.getHyperLinkByLocation(u,l,le,fe),de=s.Rectangle.getPositionRange({startRow:V,startColumn:A,endColumn:A,endRow:V},H),{row:pe,col:he}=S(de.startRow,de.startColumn),Ce=s.Tools.generateRandomId(),oe=this._hyperLinkModel.getHyperLinkByLocation(u,l,pe,he);oe&&P.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:u,subUnitId:l,id:oe.id}}),(E.APPLY_TYPE.COPY===i||E.APPLY_TYPE.SERIES===i)&&te&&(P.push({id:m.AddHyperLinkMutation.id,params:{unitId:u,subUnitId:l,link:{...te,id:Ce,row:pe,column:he}}}),L.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:u,subUnitId:l,id:Ce}})),oe&&L.push({id:m.AddHyperLinkMutation.id,params:{unitId:u,subUnitId:l,link:oe}})})}),{undos:L,redos:P}},t={id:Ge,onFillData:(r,i,o)=>o===E.APPLY_TYPE.COPY||o===E.APPLY_TYPE.ONLY_FORMAT||o===E.APPLY_TYPE.SERIES?n(r,o):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};we=In([ft(0,E.IAutoFillService),ft(1,s.Inject(m.HyperLinkModel))],we);var _n=Object.getOwnPropertyDescriptor,yn=(e,n,t,r)=>{for(var i=r>1?void 0:r?_n(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Ke=(e,n)=>(t,r)=>n(t,r,e);let Ne=class extends s.Disposable{constructor(e,n,t){super(),this._localeService=e,this._commandService=n,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===Qe.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookEditablePermission],rangeTypes:[C.RangeProtectionPermissionEditPoint],worksheetTypes:[C.WorksheetEditPermission,C.WorksheetSetCellValuePermission,C.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Ne=yn([Ke(0,s.Inject(s.LocaleService)),Ke(1,s.ICommandService),Ke(2,s.Inject(C.SheetPermissionCheckController))],Ne);var fn=Object.getOwnPropertyDescriptor,Cn=(e,n,t,r)=>{for(var i=r>1?void 0:r?fn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Y=(e,n)=>(t,r)=>n(t,r,e);let He=class extends s.Disposable{constructor(e,n,t,r,i,o,a,u,l,h){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=r,this._sheetPermissionCheckController=i,this._commandService=o,this._editorBridgeService=a,this._textSelectionManagerService=u,this._univerInstanceService=l,this._zenZoneService=h,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:n,subUnitId:t,row:r,col:i}=e,o=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!(o==null?void 0:o.getSheetBySheetId(t)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const u=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookViewPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookEditablePermission],worksheetTypes:[C.WorksheetEditPermission,C.WorksheetInsertHyperlinkPermission],rangeTypes:[C.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),h=this._permissionService.composePermission([new C.WorkbookCopyPermission(n).id,new C.WorksheetCopyPermission(n,t).id]).every(d=>d.value);return{viewPermission:u,editPermission:l,copyPermission:h}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(O.debounceTime(200)).subscribe(e=>{var N,H;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:t,row:r,col:i}=e,o=this._renderManagerService.getRenderById(n);if(!o)return;const a=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),u=a==null?void 0:a.getSheetBySheetId(t);if(!u)return;if(!o.with(E.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(y.VIEWING);return}const h=(N=o==null?void 0:o.with(E.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:N.skeleton,d=i,p=r;let S=p,v=d;h&&h.overflowCache.forValue((V,A,G)=>{s.Rectangle.contains(G,{startColumn:d,endColumn:d,startRow:p,endRow:p})&&(S=V,v=A)});const{viewPermission:R,editPermission:P,copyPermission:L}=this._getLinkPermission(e);if(!R){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=u.getCellStyleOnly(S,v),k=a.getStyles().getStyleByCell(c),M=(H=k==null?void 0:k.tr)==null?void 0:H.a;if(!M&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:S,col:v,editPermission:P,copyPermission:L,customRange:e.customRange,customRangeRect:e.rect,type:y.VIEWING,unitId:n,subUnitId:t,showAll:!!M})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(O.switchMap(n=>this._editorBridgeService.visible$.pipe(O.map(t=>({visible:t,state:n}))))).subscribe(({visible:n,state:t})=>{if(!t||t.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(y.EDITING),this._sheetsHyperLinkPopupService.endEditing(y.EDITING);return}const{editorUnitId:r,unitId:i,sheetId:o,row:a,column:u}=t,l=this._renderManagerService.getRenderById(r);if(!l)return;const{editPermission:h,viewPermission:d,copyPermission:p}=this._getLinkPermission({unitId:i,subUnitId:o,row:a,col:u}),S=l.with(ee.DocEventManagerService);d&&(e==null||e.unsubscribe(),e=S.hoverCustomRanges$.pipe(O.debounceTime(200)).subscribe(v=>{var k,M;const R=v.find(N=>N.range.rangeType===s.CustomRangeType.HYPERLINK);if(!R){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const P=R.rects[R.rects.length-1];if(!((M=(k=this._renderManagerService.getRenderById(i))==null?void 0:k.with(E.SheetSkeletonManagerService).getSkeletonParam(o))==null?void 0:M.skeleton)||!P)return;const c=l.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:i,subUnitId:o,row:a,col:u,customRange:R.range,customRangeRect:{left:P.left+c.left,top:P.top+c.top,bottom:P.bottom+c.top,right:P.right+c.left},editPermission:h,copyPermission:p,type:y.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(y.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(y.EDITING),this._sheetsHyperLinkPopupService.endEditing(y.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(y.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(y.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(y.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(O.switchMap(e=>{const n=e===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(ee.DocEventManagerService).hoverCustomRanges$.pipe(O.debounceTime(200)):new O.Observable(t=>{t.next(null)})})).subscribe(e=>{const n=e==null?void 0:e.find(r=>r.range.rangeType===s.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(n&&t){const{unitId:r,sheetId:i,row:o,column:a}=t,{editPermission:u,viewPermission:l,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:i,row:o,col:a});l&&this._sheetsHyperLinkPopupService.showPopup({type:y.ZEN_EDITOR,unitId:r,subUnitId:i,row:o,col:a,customRange:n.range,editPermission:u,copyPermission:h})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(y.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(y.EDITING)}))}_initCommandListener(){const e=[C.ClearSelectionContentCommand.id,C.ClearSelectionAllCommand.id,C.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{e.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};He=Cn([Y(0,s.Inject(E.HoverManagerService)),Y(1,s.Inject(exports.SheetsHyperLinkPopupService)),Y(2,s.Inject(ye.IRenderManagerService)),Y(3,s.Inject(s.IPermissionService)),Y(4,s.Inject(C.SheetPermissionCheckController)),Y(5,s.ICommandService),Y(6,E.IEditorBridgeService),Y(7,s.Inject(Ie.DocSelectionManagerService)),Y(8,s.IUniverInstanceService),Y(9,I.IZenZoneService)],He);var En=Object.getOwnPropertyDescriptor,Ot=(e,n,t,r)=>{for(var i=r>1?void 0:r?En(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},We=(e,n)=>(t,r)=>n(t,r,e);let Ye=class extends s.Disposable{constructor(e,n){super(),this._context=e,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(O.debounceTime(16)).subscribe(()=>{e()}))}};Ye=Ot([We(1,s.Inject(m.HyperLinkModel))],Ye);let xe=class extends s.Disposable{constructor(e,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(e,n,t)=>{const{row:r,col:i,unitId:o,subUnitId:a}=n,u=this._hyperLinkModel.getHyperLinkByLocation(o,a,r,i);return t(u?{...e,linkUrl:u.payload,linkId:u.id}:e)}}))}};xe=Ot([We(0,s.Inject(C.SheetInterceptorService)),We(1,s.Inject(m.HyperLinkModel))],xe);const Rn={[I.RibbonInsertGroup.MEDIA]:{[ie.id]:{order:1,menuItemFactory:vn},[De(ie.id)]:{order:1,menuItemFactory:Sn}},[I.ContextMenuPosition.MAIN_AREA]:{[I.ContextMenuGroup.OTHERS]:{order:1,[ie.id]:{order:0,menuItemFactory:hn},[De(ie.id)]:{order:0,menuItemFactory:gn}}}};var Ln=Object.getOwnPropertyDescriptor,Pn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Ln(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Se=(e,n)=>(t,r)=>n(t,r,e);let Ue=class extends s.Disposable{constructor(e,n,t,r,i){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._injector=r,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[ke,ke.componentKey],[Te,Te.componentKey],[qe,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[je,_e,Ae,ie].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(Rn)}_initShortCut(){this._shortcutService.registerShortcut(Qe)}};Ue=Pn([Se(0,s.Inject(I.ComponentManager)),Se(1,s.ICommandService),Se(2,I.IMenuManagerService),Se(3,s.Inject(s.Injector)),Se(4,s.Inject(I.IShortcutService))],Ue);var Tn=Object.getOwnPropertyDescriptor,kn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Tn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Ct=(e,n)=>(t,r)=>n(t,r,e);let Me=class extends s.Disposable{constructor(e,n){super(),this._parserService=e,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const n=this._parserService.parseHyperLink(e);this._resolverService.navigate(n)}}};Me=kn([Ct(0,s.Inject(m.SheetsHyperLinkParserService)),Ct(1,s.Inject(exports.SheetsHyperLinkResolverService))],Me);var bn=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,On=(e,n,t)=>n in e?bn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,wn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Dn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Et=(e,n)=>(t,r)=>n(t,r,e),wt=(e,n,t)=>On(e,typeof n!="symbol"?n+"":n,t);exports.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(n=It,t,r){super(),this._config=n,this._injector=t,this._configService=r;const{menu:i,...o}=s.merge({},It,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Rt,o)}onStarting(){[[exports.SheetsHyperLinkResolverService],[exports.SheetsHyperLinkPopupService],[ze],[xe],[He],[Ue],[we],[exports.SheetsHyperLinkCopyPasteController],[Ne],[Me]].forEach(t=>this._injector.add(t)),this._injector.get(xe)}onReady(){this._injector.get(ye.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[Ye]),this._injector.get(we),this._injector.get(exports.SheetsHyperLinkCopyPasteController),this._injector.get(Ue)}onRendered(){this._injector.get(Ne),this._injector.get(Me),this._injector.get(He)}};wt(exports.UniverSheetsHyperLinkUIPlugin,"pluginName",Ge);wt(exports.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkUIPlugin=wn([s.DependentOn(m.UniverSheetsHyperLinkPlugin,ee.UniverDocsUIPlugin),Et(1,s.Inject(s.Injector)),Et(2,s.IConfigService)],exports.UniverSheetsHyperLinkUIPlugin);exports.CloseHyperLinkPopupOperation=_e;exports.InsertHyperLinkOperation=Ae;exports.InsertLinkShortcut=Qe;exports.OpenHyperLinkEditPanelOperation=je;exports.SheetsHyperLinkSidePanelService=ze;
|
|
1
|
+
"use strict";var At=Object.defineProperty;var Vt=(e,n,t)=>n in e?At(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var F=(e,n,t)=>Vt(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),C=require("@univerjs/sheets"),m=require("@univerjs/sheets-hyper-link"),E=require("@univerjs/sheets-ui"),T=require("@univerjs/design"),q=require("@univerjs/engine-formula"),I=require("@univerjs/ui"),ee=require("@univerjs/docs-ui"),ye=require("@univerjs/engine-render"),O=require("rxjs"),Ie=require("@univerjs/docs"),_=require("react/jsx-runtime"),Bt=require("@univerjs/sheets-formula-ui"),f=require("react"),mt=require("@univerjs/sheets-data-validation");function Pe(e){return s.Tools.isLegalUrl(e)}function $t(e){return/^[a-zA-Z]+:\/\//.test(e)}function Ft(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Zt(e){if(Pe(e)){const n=$t(e)?e:Ft(e)?`mailto://${e}`:`http://${e}`;let t;try{t=new URL(n)}catch{return e}return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:n}return e}const Rt="sheets-hyper-link-ui.config",It={};var Kt=Object.getOwnPropertyDescriptor,Wt=(e,n,t,r)=>{for(var i=r>1?void 0:r?Kt(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},ue=(e,n)=>(t,r)=>n(t,r,e);function Yt(e,n){const t=n.getMergeData(),r=n.getMaxColumns()-1,i=n.getMaxRows()-1;if(r<e.endColumn&&(e.endColumn=r),i<e.endRow&&(e.endRow=i),e.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return e;const o=[];return t.forEach(a=>{s.Rectangle.intersects(e,a)&&o.push(a)}),s.Rectangle.realUnion(e,...o)}exports.SheetsHyperLinkResolverService=class{constructor(n,t,r,i,o,a){this._univerInstanceService=n,this._commandService=t,this._definedNamesService=r,this._messageService=i,this._localeService=o,this._configService=a}navigate(n){switch(n.type){case m.SheetHyperLinkType.URL:this.navigateToOtherWebsite(n.url);break;default:this._navigateToUniver(n.searchObj)}}_navigateToUniver(n){const{gid:t,range:r,rangeid:i}=n,o=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return;const a=o.getUnitId();if(i){const u=this._definedNamesService.getValueById(a,i);if(!u)return;const{formulaOrRefString:l}=u,h=this._definedNamesService.getWorksheetByRef(a,l);if(!h){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:T.MessageType.Error});return}if(h.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:T.MessageType.Error});return}this.navigateToDefineName(a,i)}if(t){if(r){const u=q.deserializeRangeWithSheet(r);s.isValidRange(u.range)&&r!==m.ERROR_RANGE&&this.navigateToRange(a,t,u.range);return}this.navigateToSheetById(a,t)}}async navigateToRange(n,t,r,i){const o=await this.navigateToSheetById(n,t);if(o){const a=Yt(r,o);await this._commandService.executeCommand(C.SetSelectionsOperation.id,{unitId:n,subUnitId:t,selections:[{range:a,primary:null}]}),await this._commandService.executeCommand(E.ScrollToRangeOperation.id,{range:a,forceTop:i})}}async navigateToSheetById(n,t){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()===t)return i;const o=r.getSheetBySheetId(t);return o?r.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:T.MessageType.Error}),!1):await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:t})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:T.MessageType.Error}),!1)}async navigateToDefineName(n,t){return this._definedNamesService.focusRange(n,t),!0}async navigateToOtherWebsite(n){var r;const t=this._configService.getConfig(Rt);if((r=t==null?void 0:t.urlHandler)!=null&&r.navigateToOtherWebsite)return t.urlHandler.navigateToOtherWebsite(n);window.open(n,"_blank","noopener noreferrer")}};exports.SheetsHyperLinkResolverService=Wt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,q.IDefinedNamesService),ue(3,I.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],exports.SheetsHyperLinkResolverService);const Ge="SHEET_HYPER_LINK_UI_PLUGIN";var Gt=Object.getOwnPropertyDescriptor,zt=(e,n,t,r)=>{for(var i=r>1?void 0:r?Gt(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Re=(e,n)=>(t,r)=>n(t,r,e);exports.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(t,r,i,o){super();F(this,"_plainTextFilter",new Set);F(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=r,this._injector=i,this._resolverService=o,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(t){this._plainTextFilter.add(t)}removePlainTextFilter(t){this._plainTextFilter.delete(t)}_filterPlainText(t){return Array.from(this._plainTextFilter).every(r=>r(t))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ge,onBeforeCopy:(t,r,i)=>this._collect(t,r,i),onPasteCells:(t,r,i,o)=>{const{copyType:a=E.COPY_TYPE.COPY,pasteType:u}=o,{range:l}=t||{},{range:h,unitId:d,subUnitId:p}=r;return this._generateMutations(h,{copyType:a,pasteType:u,copyRange:l,unitId:d,subUnitId:p})},onPastePlainText:(t,r)=>{const i=this._filterPlainText(r);if(Pe(r)&&i){const{range:o,unitId:a,subUnitId:u}=t,{ranges:[l],mapFunc:h}=E.virtualizeDiscreteRanges([o]),d=[],p=[];return s.Range.foreach(l,(S,v)=>{const{row:R,col:P}=h(S,v),L=this._hyperLinkModel.getHyperLinkByLocation(a,u,R,P);L&&d.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:u,id:L.id}}),L&&p.push({id:m.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:u,link:L}})}),{redos:d,undos:p}}return{undos:[],redos:[]}},priority:99})}_collect(t,r,i){const o=new s.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:r,matrix:o};const a=this._injector.invoke(h=>C.rangeToDiscreteRange(i,h,t,r));if(!a)return;const{rows:u,cols:l}=a;u.forEach((h,d)=>{l.forEach((p,S)=>{var R;const v=this._hyperLinkModel.getHyperLinkByLocation(t,r,h,p);o.setValue(d,S,(R=v==null?void 0:v.id)!=null?R:"")})})}_generateMutations(t,r){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{unitId:o,subUnitId:a}=this._copyInfo,u=[],l=[],{ranges:[h,d],mapFunc:p}=E.virtualizeDiscreteRanges([r.copyRange,t]);return E.getRepeatRange(h,d,!0).forEach(({startRange:v})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((P,L,c)=>{const k=s.Rectangle.getPositionRange({startRow:P,endRow:P,startColumn:L,endColumn:L},v),M=this._hyperLinkModel.getHyperLink(o,a,c),{row:N,col:H}=p(k.startRow,k.startColumn),V=this._hyperLinkModel.getHyperLinkByLocation(r.unitId,r.subUnitId,N,H),A=s.Tools.generateRandomId();V&&u.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,id:V.id}}),M&&(u.push({id:m.AddHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,link:{...M,id:A,row:N,column:H}}}),l.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,id:A}})),V&&l.push({id:m.AddHyperLinkMutation.id,params:{unitId:r.unitId,subUnitId:r.subUnitId,link:V}})})}),{redos:u,undos:l}}};exports.SheetsHyperLinkCopyPasteController=zt([Re(0,E.ISheetClipboardService),Re(1,s.Inject(m.HyperLinkModel)),Re(2,s.Inject(s.Injector)),Re(3,s.Inject(exports.SheetsHyperLinkResolverService))],exports.SheetsHyperLinkCopyPasteController);var y=(e=>(e.EDITING="editing",e.VIEWING="viewing",e.ZEN_EDITOR="zen_mode",e))(y||{});class ze extends s.Disposable{constructor(){super(...arguments);F(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==m.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(i=>i.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:r}=this;r.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const Te=()=>{var nt;const[e,n]=f.useState(""),[t,r]=f.useState(!1),[i,o]=f.useState(""),[a,u]=f.useState(!0),[l,h]=f.useState(m.SheetHyperLinkType.URL),[d,p]=f.useState(""),S=I.useDependency(s.LocaleService),v=I.useDependency(q.IDefinedNamesService),R=I.useDependency(E.IEditorBridgeService),P=I.useDependency(s.IUniverInstanceService),L=I.useDependency(exports.SheetsHyperLinkPopupService),c=I.useObservable(L.currentEditing$),k=I.useDependency(m.SheetsHyperLinkParserService),M=I.useDependency(exports.SheetsHyperLinkResolverService),N=I.useDependency(s.ICommandService),H=I.useDependency(ze),V=f.useMemo(()=>H.getOptions(),[H]),A=I.useDependency(I.IZenZoneService),G=I.useDependency(ye.IRenderManagerService),le=I.useDependency(E.IMarkSelectionService),fe=I.useDependency(Ie.DocSelectionManagerService),te=I.useDependency(s.IContextService),de=I.useDependency(s.ThemeService),pe=I.useDependency(Ie.DocSelectionManagerService),[he,Ce]=f.useState(!1),oe=I.useDependency(C.SheetsSelectionsService),Nt=f.useMemo(()=>oe.getCurrentSelections(),[]),Ee=f.useMemo(()=>{if(!H.isBuiltInLinkType(l))return H.getCustomHyperLink(l)},[H,l]),[ae,Ht]=f.useState(!1),[ge,et]=f.useState(!1),B=f.useRef(!1),Z=P.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),xt=(Z==null?void 0:Z.getActiveSheet().getSheetId())||"",X=f.useCallback(g=>{o(g.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[o]);f.useEffect(()=>{var g,b,D,w,U,K,rt,it,st,ot,at,ct,ut,lt,dt,pt,ht;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:ne,row:Fe,col:Ze}=c;let{label:z}=c;typeof z=="number"&&(z=`${z}`);let W;if(ne)W={id:(g=ne==null?void 0:ne.rangeId)!=null?g:"",display:z!=null?z:"",payload:(D=(b=ne==null?void 0:ne.properties)==null?void 0:b.url)!=null?D:"",row:Fe,column:Ze};else if(c.type===y.VIEWING){const x=P.getUnit(c.unitId),Q=x==null?void 0:x.getSheetBySheetId(c.subUnitId),j=Q==null?void 0:Q.getCellRaw(c.row,c.col),ce=(K=(U=(w=j==null?void 0:j.p)==null?void 0:w.body)==null?void 0:U.customRanges)==null?void 0:K.find(vt=>{var St;return vt.rangeType===s.CustomRangeType.HYPERLINK&&((St=vt.properties)==null?void 0:St.url)}),ve=j==null?void 0:j.v;j&&(!s.BuildTextUtils.transform.isEmptyDocument((it=(rt=j.p)==null?void 0:rt.body)==null?void 0:it.dataStream)||s.Tools.isDefine(ve))&&u(!1),W={id:"",display:"",payload:(ot=(st=ce==null?void 0:ce.properties)==null?void 0:st.url)!=null?ot:"",row:Fe,column:Ze}}else{const x=P.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),Q=fe.getActiveTextRange(),j=x==null?void 0:x.getBody(),ce=Q&&j?Q:null,ve=ce&&((ct=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ce,(at=j==null?void 0:j.customRanges)!=null?at:[]))==null?void 0:ct[0]);u(!1),W={id:"",display:z!=null?z:"",payload:(lt=(ut=ve==null?void 0:ve.properties)==null?void 0:ut.url)!=null?lt:"",row:Fe,column:Ze}}n(W.id);const gt=H.findCustomHyperLink(W);if(gt){const x=gt.convert(W);h(x.type),p(x.payload),X(x.display);return}X(W.display);const J=k.parseHyperLink(W.payload);switch(h(J.type===m.SheetHyperLinkType.INVALID?m.SheetHyperLinkType.RANGE:J.type),J.type){case m.SheetHyperLinkType.URL:{p(J.url),J.url===W.display&&(B.current=!0);break}case m.SheetHyperLinkType.RANGE:{const x=J.searchObj,Q=x.gid&&(ht=(pt=(dt=P.getUnit(c.unitId))==null?void 0:dt.getSheetBySheetId(x.gid))==null?void 0:pt.getName())!=null?ht:"",j=q.serializeRangeWithSheet(Q,q.deserializeRangeWithSheet(x.range).range);p(j),j===W.display&&(B.current=!0);break}case m.SheetHyperLinkType.SHEET:{const x=J.searchObj;p(x.gid);break}case m.SheetHyperLinkType.DEFINE_NAME:{const x=J.searchObj;p(x.rangeid);break}default:p("");break}}},[c,M,H,fe,P]),f.useEffect(()=>{let g=null;if(c&&!c.customRangeId&&c.type===y.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=P.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),D=b==null?void 0:b.getSheetBySheetId(c.subUnitId),w=D==null?void 0:D.getMergedCell(c.row,c.col),U=new s.ColorKit(de.getColorFromTheme("primary.600")).toRgb();g=le.addShape({range:w!=null?w:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${U.r}, ${U.g}, ${U.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{g&&le.removeShape(g)}},[c,le,de,P]),f.useEffect(()=>{et(l===m.SheetHyperLinkType.RANGE)},[l]),f.useEffect(()=>{const g=(c==null?void 0:c.type)===y.ZEN_EDITOR?G.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):G.getRenderById(R.getCurrentEditorId()),b=new s.DisposableCollection;if(g){const D=g.with(ee.DocSelectionRenderService);D.setReserveRangesStatus(!0),b.add(()=>{D.setReserveRangesStatus(!1)})}return()=>{R.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,R,G]),f.useEffect(()=>(ge&&L.setIsKeepVisible(ge),L.setIsKeepVisible(he),()=>{L.setIsKeepVisible(!1)}),[ge,he,L]),f.useEffect(()=>()=>{A.temporaryHidden&&(A.show(),te.setContextValue(s.FOCUSING_SHEET,!1))},[te,A]),f.useEffect(()=>{if(ge)return R.enableForceKeepVisible(),()=>{R.disableForceKeepVisible()}},[ge,R]);const Ut=[{label:S.t("hyperLink.form.link"),value:m.SheetHyperLinkType.URL},{label:S.t("hyperLink.form.range"),value:m.SheetHyperLinkType.RANGE},{label:S.t("hyperLink.form.worksheet"),value:m.SheetHyperLinkType.SHEET},{label:S.t("hyperLink.form.definedName"),value:m.SheetHyperLinkType.DEFINE_NAME},...V];if(!Z)return;const Mt=Z.getHiddenWorksheets(),Ve=Z.getSheets().map(g=>({label:g.getName(),value:g.getSheetId()})).filter(g=>Mt.indexOf(g.value)===-1),Be=Object.values((nt=v.getDefinedNameMap(Z.getUnitId()))!=null?nt:{}).map(g=>({label:g.name,value:g.id})),tt=(g,b)=>{if(g===m.SheetHyperLinkType.URL)return Zt(b);if(g===m.SheetHyperLinkType.RANGE){const D=q.deserializeRangeWithSheet(b),w=Z.getSheetBySheetName(D.sheetName);if(w)return`#gid=${w.getSheetId()}&range=${q.serializeRange(D.range)}`}return`#${g}=${b}`},jt=I.useEvent(g=>{var U;const D=g.split(",").map(q.deserializeRangeWithSheet)[0];if(!D||!s.isValidRange(D.range))return;D.sheetName||(D.sheetName=((U=Z.getActiveSheet())==null?void 0:U.getName())||"");const w=q.serializeRangeToRefString(D);p(w),w&&(B.current||!i)&&(X(w),B.current=!0)}),$e=async()=>{if(a&&!i||!d||l===m.SheetHyperLinkType.URL&&!Pe(d)){Ht(!0);return}if(c)if(e){const g=c.type===y.ZEN_EDITOR||c.type===y.EDITING?m.UpdateRichHyperLinkCommand.id:m.UpdateHyperLinkCommand.id;await N.executeCommand(g,{id:e,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:a?i:"",payload:tt(l,d)},row:c.row,column:c.col,documentId:c.type===y.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:R.getCurrentEditorId()})}else{const g=c.type===y.ZEN_EDITOR||c.type===y.EDITING?m.AddRichHyperLinkCommand.id:m.AddHyperLinkCommand.id;await N.executeCommand(g,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:tt(l,d),display:a?i:""},documentId:c.type===y.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:R.getCurrentEditorId()})}if((c==null?void 0:c.type)===y.VIEWING){await N.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const g=1;await N.executeCommand(E.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-g,0),endRow:c.row+g,startColumn:Math.max(c.col-g,0),endColumn:c.col+g}})}N.executeCommand(_e.id)};return c?_.jsxs("div",{className:T.clsx("univer-box-border univer-w-[296px] univer-rounded-xl univer-bg-white univer-p-4 univer-shadow-md dark:!univer-bg-gray-900",T.borderClassName),children:[a?_.jsx(T.FormLayout,{label:S.t("hyperLink.form.label"),error:ae&&!i?S.t("hyperLink.form.inputError"):"",children:_.jsx(T.Input,{value:i,onChange:g=>{X(g),B.current=!1},placeholder:S.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:g=>{g.keyCode===I.KeyCode.ENTER&&$e()}})}):null,_.jsx(T.FormLayout,{label:S.t("hyperLink.form.type"),children:_.jsx(T.Select,{className:"univer-w-full",options:Ut,value:l,onChange:g=>{h(g),p("")}})}),l===m.SheetHyperLinkType.URL&&_.jsx(T.FormLayout,{error:ae?d?Pe(d)?"":S.t("hyperLink.form.linkError"):S.t("hyperLink.form.inputError"):"",children:_.jsx(T.Input,{value:d,onChange:g=>{p(g),g&&(B.current||!i||i===g)&&(X(g),B.current=!0)},placeholder:S.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:g=>{g.keyCode===I.KeyCode.ENTER&&$e()}})}),l===m.SheetHyperLinkType.RANGE&&_.jsx(T.FormLayout,{error:ae&&!d?S.t("hyperLink.form.inputError"):"",children:_.jsx(Bt.RangeSelector,{unitId:Z.getUnitId(),subUnitId:xt,maxRangeCount:1,supportAcrossSheet:!0,initialValue:d,resetRange:Nt,onChange:(g,b)=>jt(b),onRangeSelectorDialogVisibleChange:async g=>{var b,D;if(Ce(g),g)c.type===y.ZEN_EDITOR&&(A.hide(),te.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==y.VIEWING&&R.enableForceKeepVisible(),r(!0);else{if(await M.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===y.ZEN_EDITOR){await N.executeCommand(C.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),A.show(),te.setContextValue(s.FOCUSING_SHEET,!1);const w=(b=G.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(ee.DocBackScrollRenderController),U=(D=pe.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:D[0];w&&U&&(w.scrollToRange(U),pe.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}R.disableForceKeepVisible(),r(!1)}},onFocusChange:g=>et(g)})}),l===m.SheetHyperLinkType.SHEET&&_.jsx(T.FormLayout,{error:ae&&!d?S.t("hyperLink.form.selectError"):"",children:_.jsx(T.Select,{className:"univer-w-full",options:Ve,value:d,onChange:g=>{var w,U;p(g);const b=(w=Ve.find(K=>K.value===g))==null?void 0:w.label,D=(U=Ve.find(K=>K.value===d))==null?void 0:U.label;b&&(B.current||!i||i===D)&&(X(b),B.current=!0)}})}),l===m.SheetHyperLinkType.DEFINE_NAME&&_.jsx(T.FormLayout,{error:ae&&!d?S.t("hyperLink.form.selectError"):"",children:_.jsx(T.Select,{className:"univer-w-full",options:Be,value:d,onChange:g=>{var w,U;p(g);const b=(w=Be.find(K=>K.value===g))==null?void 0:w.label,D=(U=Be.find(K=>K.value===d))==null?void 0:U.label;b&&(B.current||!i||i===D)&&(X(b),B.current=!0)}})}),(Ee==null?void 0:Ee.Form)&&_.jsx(Ee.Form,{linkId:e,payload:d,display:i,showError:ae,setByPayload:B,setDisplay:g=>{X(g),B.current=!0},setPayload:p}),_.jsxs("div",{className:"univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[_.jsx(T.Button,{onClick:()=>{c&&M.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),N.executeCommand(_e.id)},children:S.t("hyperLink.form.cancel")}),_.jsx(T.Button,{variant:"primary",onClick:async()=>{$e()},children:S.t("hyperLink.form.ok")})]})]}):null};Te.componentKey="univer.sheet.cell-link-edit";var $=function(){return $=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},$.apply(this,arguments)},qt=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(t[r[i]]=e[r[i]]);return t},se=f.forwardRef(function(e,n){var t=e.icon,r=e.id,i=e.className,o=e.extend,a=qt(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),l=f.useRef("_".concat(Qt()));return Lt(t,"".concat(r),{defIds:t.defIds,idSuffix:l.current},$({ref:n,className:u},a),o)});function Lt(e,n,t,r,i){return f.createElement(e.tag,$($({key:n},Xt(e,t,i)),r),(Jt(e,t).children||[]).map(function(o,a){return Lt(o,"".concat(n,"-").concat(e.tag,"-").concat(a),t,void 0,i)}))}function Xt(e,n,t){var r=$({},e.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+n.idSuffix),Object.entries(r).forEach(function(o){var a=o[0],u=o[1];a==="mask"&&typeof u=="string"&&(r[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+n.idSuffix),Object.entries(r).forEach(function(o){var a=o[0],u=o[1];typeof u=="string"&&(r[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),r}function Jt(e,n){var t,r=n.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?$($({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?$($({},i),{attrs:$($({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function Qt(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var en={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"all-border-single",ref:n,icon:en}))});Le.displayName="AllBorderSingle";var tn={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"}}]},Pt=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"copy-single",ref:n,icon:tn}))});Pt.displayName="CopySingle";var nn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},qe=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"link-single",ref:n,icon:nn}))});qe.displayName="LinkSingle";var rn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},Tt=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"unlink-single",ref:n,icon:rn}))});Tt.displayName="UnlinkSingle";var sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},kt=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"write-single",ref:n,icon:sn}))});kt.displayName="WriteSingle";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.4538 1.12549C2.70051 1.12549 2.08984 1.73615 2.08984 2.48945V13.5104C2.08984 14.2637 2.70051 14.8744 3.4538 14.8744H12.5468C13.3001 14.8744 13.9108 14.2637 13.9108 13.5104V5.0992L10.0094 1.12549H3.4538Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M10.0078 1.12549L13.9107 5.09842H10.6745C10.3063 5.09842 10.0078 4.79994 10.0078 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.80941 10.2949L6.37701 12.403C6.2632 12.5705 6.03516 12.614 5.86766 12.5002C5.70017 12.3864 5.65664 12.1584 5.77045 11.9909L7.36611 9.64252L5.94103 7.54519C5.82722 7.37769 5.87074 7.14964 6.03824 7.03583C6.20573 6.92202 6.43378 6.96555 6.54759 7.13304L7.80941 8.9901L9.07123 7.13304C9.18504 6.96555 9.41309 6.92202 9.58059 7.03583C9.74808 7.14964 9.7916 7.37769 9.67779 7.54519L8.25271 9.64252L9.84837 11.9909C9.96218 12.1584 9.91866 12.3864 9.75116 12.5002C9.58366 12.614 9.35562 12.5705 9.24181 12.403L7.80941 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},bt=f.forwardRef(function(e,n){return f.createElement(se,Object.assign({},e,{id:"xlsx",ref:n,icon:on}))});bt.displayName="Xlsx";const an={[m.SheetHyperLinkType.URL]:_.jsx(qe,{}),[m.SheetHyperLinkType.SHEET]:_.jsx(bt,{}),[m.SheetHyperLinkType.RANGE]:_.jsx(Le,{}),[m.SheetHyperLinkType.DEFINE_NAME]:_.jsx(Le,{}),[m.SheetHyperLinkType.INVALID]:_.jsx(Le,{})},_t=e=>{var M,N;const n=I.useDependency(exports.SheetsHyperLinkPopupService),t=I.useDependency(s.ICommandService),r=I.useDependency(I.IMessageService),i=I.useDependency(s.LocaleService),o=I.useDependency(exports.SheetsHyperLinkResolverService),a=I.useDependency(E.IEditorBridgeService),u=I.useDependency(m.SheetsHyperLinkParserService),l=I.useDependency(I.IZenZoneService),{customRange:h,row:d,col:p,unitId:S,subUnitId:v,editPermission:R,copyPermission:P,type:L}=e;if(!((M=h==null?void 0:h.properties)!=null&&M.url))return null;const c=u.parseHyperLink((N=h.properties.url)!=null?N:""),k=c.type===m.SheetHyperLinkType.INVALID;return _.jsxs("div",{className:T.clsx("univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow-md dark:!univer-bg-gray-900",T.borderClassName),onClick:()=>n.hideCurrentPopup(),children:[_.jsxs("div",{className:T.clsx("univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600",{"univer-text-red-500":k}),onClick:()=>{l.visible||k||o.navigate(c)},children:[_.jsx("div",{className:"univer-mr-2 univer-flex univer-h-5 univer-w-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white",children:an[c.type]}),_.jsx(T.Tooltip,{showIfEllipsis:!0,title:c.name,asChild:!0,children:_.jsx("span",{className:"univer-flex-1 univer-overflow-hidden univer-text-ellipsis",children:c.name})})]}),_.jsxs("div",{className:"univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center",children:[P&&_.jsx("div",{className:T.clsx("univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-text-red-500":k}),onClick:()=>{if(!k){if(c.type!==m.SheetHyperLinkType.URL){const H=new URL(window.location.href);H.hash=c.url.slice(1),navigator.clipboard.writeText(H.href)}else navigator.clipboard.writeText(c.url);r.show({content:i.t("hyperLink.message.coped"),type:T.MessageType.Info})}},children:_.jsx(T.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.copy"),children:_.jsx(Pt,{className:"dark:!univer-text-white"})})}),R&&_.jsxs(_.Fragment,{children:[_.jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",onClick:()=>{t.executeCommand(je.id,{unitId:S,subUnitId:v,row:d,col:p,customRangeId:h.rangeId,type:L})},children:_.jsx(T.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.edit"),children:_.jsx(kt,{className:"dark:!univer-text-white"})})}),_.jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",onClick:()=>{const H=L===y.EDITING||L===y.ZEN_EDITOR?m.CancelRichHyperLinkCommand.id:m.CancelHyperLinkCommand.id;t.syncExecuteCommand(H,{unitId:S,subUnitId:v,id:h.rangeId,row:d,column:p,documentId:L===y.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:a.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:_.jsx(T.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.cancel"),children:_.jsx(Tt,{className:"dark:!univer-text-white"})})})]})]})]})},ke=()=>{var i,o;const e=I.useDependency(exports.SheetsHyperLinkPopupService),[n,t]=f.useState(null),r=I.useDependency(s.IUniverInstanceService);if(f.useEffect(()=>{t(e.currentPopup);const a=e.currentPopup$.subscribe(u=>{t(u)});return()=>{a.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){const a=r.getUnit(n.unitId,s.UniverInstanceType.UNIVER_SHEET),u=a==null?void 0:a.getSheetBySheetId(n.subUnitId),l=u==null?void 0:u.getCell(n.row,n.col),h=(o=(i=l==null?void 0:l.p)==null?void 0:i.body)==null?void 0:o.customRanges;return h!=null&&h.length?_.jsx("div",{children:h.map(d=>_.jsx(_t,{...n,customRange:d},d.rangeId))}):null}return _.jsx(_t,{...n})};ke.componentKey="univer.sheet.cell-link-popup";var cn=Object.getOwnPropertyDescriptor,un=(e,n,t,r)=>{for(var i=r>1?void 0:r?cn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},re=(e,n)=>(t,r)=>n(t,r,e);const yt=(e,n)=>{var t,r;return e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.row===n.row&&e.col===n.col&&((t=e.customRange)==null?void 0:t.rangeId)===((r=n.customRange)==null?void 0:r.rangeId)&&e.type===n.type};exports.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(t,r,i,o,a,u,l){super();F(this,"_currentPopup",null);F(this,"_currentPopup$",new O.Subject);F(this,"currentPopup$",this._currentPopup$.asObservable());F(this,"_currentEditingPopup",null);F(this,"_currentEditing$",new O.BehaviorSubject(null));F(this,"currentEditing$",this._currentEditing$.asObservable());F(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=r,this._univerInstanceService=i,this._editorBridgeService=o,this._textSelectionManagerService=a,this._docCanvasPopManagerService=u,this._zenZoneService=l,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){if(this._currentPopup&&yt(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==y.ZEN_EDITOR&&this._zenZoneService.visible))return;const r=this._currentEditing$.getValue();if(r&&yt(t,r))return;const{unitId:i,subUnitId:o,row:a,col:u,customRangeRect:l,customRange:h}=t;let d;const p={componentKey:ke.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===y.EDITING){if(!h)return;d=l&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(l,p)}else if(t.type===y.ZEN_EDITOR){if(!h)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:h.startIndex,endOffset:h.endIndex+1,collapsed:!1},p,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,p,i,o);else{if(!h)return;d=l&&this._sheetCanvasPopManagerService.attachPopupByPosition(l,p,t)}d&&(this._currentPopup={unitId:i,subUnitId:o,disposable:d,row:a,col:u,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:h,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,r){var i,o;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||r)&&((o=(i=this._currentPopup)==null?void 0:i.disposable)==null||o.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var i,o,a;const t=this._editorBridgeService.isVisible().visible,r=this._editorBridgeService.getEditCellState();if(t&&r){const u=this._textSelectionManagerService.getActiveTextRange(),l=(i=r.documentLayoutObject.documentModel)==null?void 0:i.getBody();if(!l)return null;if(!u||u.collapsed)return{startOffset:0,endOffset:l.dataStream.length-2,collapsed:l.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(l.dataStream)};const h=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(u,(a=(o=l.customRanges)==null?void 0:o.filter(S=>S.rangeType===s.CustomRangeType.HYPERLINK))!=null?a:[]);let d=u.startOffset,p=u.endOffset;return h.forEach(S=>{d=Math.min(d,S.startIndex),p=Math.max(p,S.endIndex+1)}),{startOffset:d,endOffset:p,collapsed:d===p,label:s.BuildTextUtils.transform.getPlainText(l.dataStream.slice(d,p))}}return null}get _editPopup(){return{componentKey:Te.componentKey,direction:"vertical",onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var a,u,l,h,d;const{unitId:r,subUnitId:i,type:o}=t;if(o===y.ZEN_EDITOR){const p=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!p)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 v=(a=p.getBody())==null?void 0:a.dataStream.slice(S.startOffset,S.endOffset);this._currentEditing$.next({...t,label:v})}else if(o===y.EDITING){const p=this._getEditingRange();if(!p)return;this._textSelectionManagerService.replaceDocRanges([{...p}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const S=this._injector.get(ye.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!S)return;const v=ee.calcDocRangePositions(p,S);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,r,i),this._currentEditing$.next({...t,label:(u=p==null?void 0:p.label)!=null?u:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,r,i);const p=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),S=p==null?void 0:p.getSheetBySheetId(i),v=S==null?void 0:S.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:v!=null&&v.p?s.BuildTextUtils.transform.getPlainText((h=(l=v.p.body)==null?void 0:l.dataStream)!=null?h:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(t){var u,l,h,d,p,S;(u=this._currentEditingPopup)==null||u.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:r,subUnitId:i}=t;let o,a;if(t.type===y.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(o=(h=(l=v==null?void 0:v.getBody())==null?void 0:l.customRanges)==null?void 0:h.find(R=>R.rangeId===t.customRangeId),a=o?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(o.startIndex,o.endIndex+1):"",!o||!a)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:o.startIndex,endOffset:o.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===y.EDITING){const v=E.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!v||!((p=v.rects)!=null&&p.length))return;o=v.customRange,a=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,r,i)}else{const v=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),R=v==null?void 0:v.getSheetBySheetId(i),P=R==null?void 0:R.getCellRaw(t.row,t.col),L=v==null?void 0:v.getStyles().getStyleByCell(P),c=L==null?void 0:L.tr,k=E.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!k||!((S=k.rects)!=null&&S.length))return;o=k.customRange,a=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,r,i):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:r,subUnitId:i,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:o,label:a})}endEditing(t){var i;if(this.getIsKeepVisible())return;const r=this._currentEditing$.getValue();r&&(!t||t===r.type)&&((i=this._currentEditingPopup)==null||i.dispose(),this._currentEditing$.next(null))}};exports.SheetsHyperLinkPopupService=un([re(0,s.Inject(E.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,E.IEditorBridgeService),re(4,s.Inject(Ie.DocSelectionManagerService)),re(5,s.Inject(ee.DocCanvasPopManagerService)),re(6,I.IZenZoneService)],exports.SheetsHyperLinkPopupService);var me=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(me||{});const ln=new Set([s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE]),Xe=(e,n,t,r)=>{var u,l,h,d,p;const i=n.getCell(t,r);if(i!=null&&i.f||i!=null&&i.si||(h=(l=(u=i==null?void 0:i.p)==null?void 0:u.body)==null?void 0:l.customBlocks)!=null&&h.length)return 1;const o=e.has(mt.SheetDataValidationModel)?e.get(mt.SheetDataValidationModel):null,a=o==null?void 0:o.getRuleByLocation(n.getUnitId(),n.getSheetId(),t,r);return a&&ln.has(a.type)?!0:(p=(d=i==null?void 0:i.p)==null?void 0:d.drawingsOrder)!=null&&p.length?2:0},dn=e=>{const n=e.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const t=n.getActiveSheet(),r=e.get(C.SheetsSelectionsService).getCurrentSelections();if(!r.length)return!0;const i=r[0].range.startRow,o=r[0].range.startColumn;return Xe(e,t,i,o)===1},pn=e=>{const n=e.get(Ie.DocSelectionManagerService),t=e.get(s.IUniverInstanceService),r=n.getTextRanges();if(!(r!=null&&r.length))return!0;const i=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);return!!(!i||r.every(a=>a.collapsed)||!i.getSelfOrHeaderFooterModel(r[0].segmentId).getBody())},je={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,n){if(!n)return!1;const t=e.get(exports.SheetsHyperLinkPopupService);return n.customRangeId?t.startEditing(n):t.startAddEditing(n),!0}},_e={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(exports.SheetsHyperLinkPopupService).endEditing(),!0}},Ae={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var p;const n=e.get(s.IUniverInstanceService),t=C.getSheetCommandTarget(n),r=e.get(E.IEditorBridgeService);if(!t)return!1;const i=e.get(s.ICommandService),a=e.get(C.SheetsSelectionsService).getCurrentLastSelection();if(!a)return!1;const u=a.range.startRow,l=a.range.startColumn,h=r.isVisible(),d=((p=n.getFocusedUnit())==null?void 0:p.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return i.executeCommand(je.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:u,col:l,type:d?y.ZEN_EDITOR:h.visible?y.EDITING:y.VIEWING})}},ie={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(dn(e))return!1;const n=e.get(s.ICommandService);return e.get(exports.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(_e.id):n.executeCommand(Ae.id)}},Je=(e,n=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var i;const t=e.get(s.IUniverInstanceService),r=(i=e.get(ye.IRenderManagerService).getRenderById(n))==null?void 0:i.with(ee.DocSelectionRenderService);return r?r.textSelectionInner$.pipe(O.map(()=>{const a=e.get(E.IEditorBridgeService).getEditCellState();if(!a)return!0;const u=C.getSheetCommandTarget(t,{unitId:a.unitId,subUnitId:a.sheetId});return!(u!=null&&u.worksheet)||Xe(e,u.worksheet,a.row,a.column)===1?!0:pn(e)})):O.of(!0)},Dt=e=>{var i;const n=e.get(s.IUniverInstanceService),t=e.has(E.IEditorBridgeService)?e.get(E.IEditorBridgeService):null;return((i=t==null?void 0:t.currentEditCellState$.pipe(O.map(o=>{if(!o)return me.DISABLED_BY_CELL;const a=C.getSheetCommandTarget(n,{unitId:o.unitId,subUnitId:o.sheetId});return a?Xe(e,a.worksheet,o.row,o.column):me.DISABLED_BY_CELL}),O.switchMap(o=>{if(o===me.DISABLED_BY_CELL)return O.of(!0);const a=t?t.visible$:O.of(null);return O.combineLatest([a,n.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_DOC)]).pipe(O.switchMap(([u,l])=>u!=null&&u.visible?(l==null?void 0:l.getUnitId())===s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?O.of(!0):Je(e,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):O.of(o!==me.ALLOWED)))})))!=null?i:O.of(!0)).pipe(O.switchMap(o=>o?O.of(!0):E.getCurrentRangeDisable$(e,{workbookTypes:[C.WorkbookEditablePermission],worksheetTypes:[C.WorksheetEditPermission,C.WorksheetSetCellValuePermission,C.WorksheetInsertHyperlinkPermission],rangeTypes:[C.RangeProtectionPermissionEditPoint]},!0)))},be={commandId:Ae.id,type:I.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=e=>`${e}-zen-editor`,hn=e=>({...be,id:be.commandId,hidden$:I.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:Dt(e)}),gn=e=>({...be,id:De(be.commandId),hidden$:I.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Je(e)}),Oe={tooltip:"hyperLink.form.addTitle",commandId:ie.id,type:I.MenuItemType.BUTTON,icon:"LinkSingle"},vn=e=>({...Oe,id:Oe.commandId,hidden$:I.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:Dt(e)}),Sn=e=>({...Oe,id:De(Oe.commandId),hidden$:I.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Je(e)}),Qe={id:ie.id,binding:I.KeyCode.K|I.MetaKeys.CTRL_COMMAND,preconditions:E.whenSheetEditorFocused};var mn=Object.getOwnPropertyDescriptor,In=(e,n,t,r)=>{for(var i=r>1?void 0:r?mn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},ft=(e,n)=>(t,r)=>n(t,r,e);let we=class extends s.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(r,i)=>{const{source:o,target:a,unitId:u,subUnitId:l}=r,h=E.virtualizeDiscreteRanges([o,a]),[d,p]=h.ranges,{mapFunc:S}=h,v={row:d.startRow,col:d.startColumn},R=E.getAutoFillRepeatRange(d,p),P=[],L=[];return R.forEach(c=>{const k=c.repeatStartCell,M=c.relativeRange,N={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},H={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(M,(V,A)=>{const G=s.Rectangle.getPositionRange({startRow:V,startColumn:A,endColumn:A,endRow:V},N),{row:le,col:fe}=S(G.startRow,G.startColumn),te=this._hyperLinkModel.getHyperLinkByLocation(u,l,le,fe),de=s.Rectangle.getPositionRange({startRow:V,startColumn:A,endColumn:A,endRow:V},H),{row:pe,col:he}=S(de.startRow,de.startColumn),Ce=s.Tools.generateRandomId(),oe=this._hyperLinkModel.getHyperLinkByLocation(u,l,pe,he);oe&&P.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:u,subUnitId:l,id:oe.id}}),(E.APPLY_TYPE.COPY===i||E.APPLY_TYPE.SERIES===i)&&te&&(P.push({id:m.AddHyperLinkMutation.id,params:{unitId:u,subUnitId:l,link:{...te,id:Ce,row:pe,column:he}}}),L.push({id:m.RemoveHyperLinkMutation.id,params:{unitId:u,subUnitId:l,id:Ce}})),oe&&L.push({id:m.AddHyperLinkMutation.id,params:{unitId:u,subUnitId:l,link:oe}})})}),{undos:L,redos:P}},t={id:Ge,onFillData:(r,i,o)=>o===E.APPLY_TYPE.COPY||o===E.APPLY_TYPE.ONLY_FORMAT||o===E.APPLY_TYPE.SERIES?n(r,o):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};we=In([ft(0,E.IAutoFillService),ft(1,s.Inject(m.HyperLinkModel))],we);var _n=Object.getOwnPropertyDescriptor,yn=(e,n,t,r)=>{for(var i=r>1?void 0:r?_n(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Ke=(e,n)=>(t,r)=>n(t,r,e);let Ne=class extends s.Disposable{constructor(e,n,t){super(),this._localeService=e,this._commandService=n,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===Qe.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookEditablePermission],rangeTypes:[C.RangeProtectionPermissionEditPoint],worksheetTypes:[C.WorksheetEditPermission,C.WorksheetSetCellValuePermission,C.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Ne=yn([Ke(0,s.Inject(s.LocaleService)),Ke(1,s.ICommandService),Ke(2,s.Inject(C.SheetPermissionCheckController))],Ne);var fn=Object.getOwnPropertyDescriptor,Cn=(e,n,t,r)=>{for(var i=r>1?void 0:r?fn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Y=(e,n)=>(t,r)=>n(t,r,e);let He=class extends s.Disposable{constructor(e,n,t,r,i,o,a,u,l,h){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=r,this._sheetPermissionCheckController=i,this._commandService=o,this._editorBridgeService=a,this._textSelectionManagerService=u,this._univerInstanceService=l,this._zenZoneService=h,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:n,subUnitId:t,row:r,col:i}=e,o=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!(o==null?void 0:o.getSheetBySheetId(t)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const u=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookViewPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[C.WorkbookEditablePermission],worksheetTypes:[C.WorksheetEditPermission,C.WorksheetInsertHyperlinkPermission],rangeTypes:[C.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),h=this._permissionService.composePermission([new C.WorkbookCopyPermission(n).id,new C.WorksheetCopyPermission(n,t).id]).every(d=>d.value);return{viewPermission:u,editPermission:l,copyPermission:h}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(O.debounceTime(200)).subscribe(e=>{var N,H;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:t,row:r,col:i}=e,o=this._renderManagerService.getRenderById(n);if(!o)return;const a=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),u=a==null?void 0:a.getSheetBySheetId(t);if(!u)return;if(!o.with(E.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(y.VIEWING);return}const h=(N=o==null?void 0:o.with(E.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:N.skeleton,d=i,p=r;let S=p,v=d;h&&h.overflowCache.forValue((V,A,G)=>{s.Rectangle.contains(G,{startColumn:d,endColumn:d,startRow:p,endRow:p})&&(S=V,v=A)});const{viewPermission:R,editPermission:P,copyPermission:L}=this._getLinkPermission(e);if(!R){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=u.getCellStyleOnly(S,v),k=a.getStyles().getStyleByCell(c),M=(H=k==null?void 0:k.tr)==null?void 0:H.a;if(!M&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:S,col:v,editPermission:P,copyPermission:L,customRange:e.customRange,customRangeRect:e.rect,type:y.VIEWING,unitId:n,subUnitId:t,showAll:!!M})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(O.switchMap(n=>this._editorBridgeService.visible$.pipe(O.map(t=>({visible:t,state:n}))))).subscribe(({visible:n,state:t})=>{if(!t||t.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(y.EDITING),this._sheetsHyperLinkPopupService.endEditing(y.EDITING);return}const{editorUnitId:r,unitId:i,sheetId:o,row:a,column:u}=t,l=this._renderManagerService.getRenderById(r);if(!l)return;const{editPermission:h,viewPermission:d,copyPermission:p}=this._getLinkPermission({unitId:i,subUnitId:o,row:a,col:u}),S=l.with(ee.DocEventManagerService);d&&(e==null||e.unsubscribe(),e=S.hoverCustomRanges$.pipe(O.debounceTime(200)).subscribe(v=>{var k,M;const R=v.find(N=>N.range.rangeType===s.CustomRangeType.HYPERLINK);if(!R){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const P=R.rects[R.rects.length-1];if(!((M=(k=this._renderManagerService.getRenderById(i))==null?void 0:k.with(E.SheetSkeletonManagerService).getSkeletonParam(o))==null?void 0:M.skeleton)||!P)return;const c=l.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:i,subUnitId:o,row:a,col:u,customRange:R.range,customRangeRect:{left:P.left+c.left,top:P.top+c.top,bottom:P.bottom+c.top,right:P.right+c.left},editPermission:h,copyPermission:p,type:y.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(y.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(y.EDITING),this._sheetsHyperLinkPopupService.endEditing(y.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(y.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(y.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(y.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(O.switchMap(e=>{const n=e===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(ee.DocEventManagerService).hoverCustomRanges$.pipe(O.debounceTime(200)):new O.Observable(t=>{t.next(null)})})).subscribe(e=>{const n=e==null?void 0:e.find(r=>r.range.rangeType===s.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(n&&t){const{unitId:r,sheetId:i,row:o,column:a}=t,{editPermission:u,viewPermission:l,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:i,row:o,col:a});l&&this._sheetsHyperLinkPopupService.showPopup({type:y.ZEN_EDITOR,unitId:r,subUnitId:i,row:o,col:a,customRange:n.range,editPermission:u,copyPermission:h})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(y.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(y.EDITING)}))}_initCommandListener(){const e=[C.ClearSelectionContentCommand.id,C.ClearSelectionAllCommand.id,C.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{e.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};He=Cn([Y(0,s.Inject(E.HoverManagerService)),Y(1,s.Inject(exports.SheetsHyperLinkPopupService)),Y(2,s.Inject(ye.IRenderManagerService)),Y(3,s.Inject(s.IPermissionService)),Y(4,s.Inject(C.SheetPermissionCheckController)),Y(5,s.ICommandService),Y(6,E.IEditorBridgeService),Y(7,s.Inject(Ie.DocSelectionManagerService)),Y(8,s.IUniverInstanceService),Y(9,I.IZenZoneService)],He);var En=Object.getOwnPropertyDescriptor,Ot=(e,n,t,r)=>{for(var i=r>1?void 0:r?En(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},We=(e,n)=>(t,r)=>n(t,r,e);let Ye=class extends s.Disposable{constructor(e,n){super(),this._context=e,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(O.debounceTime(16)).subscribe(()=>{e()}))}};Ye=Ot([We(1,s.Inject(m.HyperLinkModel))],Ye);let xe=class extends s.Disposable{constructor(e,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(e,n,t)=>{const{row:r,col:i,unitId:o,subUnitId:a}=n,u=this._hyperLinkModel.getHyperLinkByLocation(o,a,r,i);return t(u?{...e,linkUrl:u.payload,linkId:u.id}:e)}}))}};xe=Ot([We(0,s.Inject(C.SheetInterceptorService)),We(1,s.Inject(m.HyperLinkModel))],xe);const Rn={[I.RibbonInsertGroup.MEDIA]:{[ie.id]:{order:1,menuItemFactory:vn},[De(ie.id)]:{order:1,menuItemFactory:Sn}},[I.ContextMenuPosition.MAIN_AREA]:{[I.ContextMenuGroup.OTHERS]:{order:1,[ie.id]:{order:0,menuItemFactory:hn},[De(ie.id)]:{order:0,menuItemFactory:gn}}}};var Ln=Object.getOwnPropertyDescriptor,Pn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Ln(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Se=(e,n)=>(t,r)=>n(t,r,e);let Ue=class extends s.Disposable{constructor(e,n,t,r,i){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._injector=r,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[ke,ke.componentKey],[Te,Te.componentKey],[qe,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[je,_e,Ae,ie].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(Rn)}_initShortCut(){this._shortcutService.registerShortcut(Qe)}};Ue=Pn([Se(0,s.Inject(I.ComponentManager)),Se(1,s.ICommandService),Se(2,I.IMenuManagerService),Se(3,s.Inject(s.Injector)),Se(4,s.Inject(I.IShortcutService))],Ue);var Tn=Object.getOwnPropertyDescriptor,kn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Tn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Ct=(e,n)=>(t,r)=>n(t,r,e);let Me=class extends s.Disposable{constructor(e,n){super(),this._parserService=e,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const n=this._parserService.parseHyperLink(e);this._resolverService.navigate(n)}}};Me=kn([Ct(0,s.Inject(m.SheetsHyperLinkParserService)),Ct(1,s.Inject(exports.SheetsHyperLinkResolverService))],Me);var bn=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,On=(e,n,t)=>n in e?bn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,wn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Dn(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},Et=(e,n)=>(t,r)=>n(t,r,e),wt=(e,n,t)=>On(e,typeof n!="symbol"?n+"":n,t);exports.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(n=It,t,r){super(),this._config=n,this._injector=t,this._configService=r;const{menu:i,...o}=s.merge({},It,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Rt,o)}onStarting(){[[exports.SheetsHyperLinkResolverService],[exports.SheetsHyperLinkPopupService],[ze],[xe],[He],[Ue],[we],[exports.SheetsHyperLinkCopyPasteController],[Ne],[Me]].forEach(t=>this._injector.add(t)),this._injector.get(xe)}onReady(){this._injector.get(ye.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[Ye]),this._injector.get(we),this._injector.get(exports.SheetsHyperLinkCopyPasteController),this._injector.get(Ue)}onRendered(){this._injector.get(Ne),this._injector.get(Me),this._injector.get(He)}};wt(exports.UniverSheetsHyperLinkUIPlugin,"pluginName",Ge);wt(exports.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkUIPlugin=wn([s.DependentOn(m.UniverSheetsHyperLinkPlugin,ee.UniverDocsUIPlugin),Et(1,s.Inject(s.Injector)),Et(2,s.IConfigService)],exports.UniverSheetsHyperLinkUIPlugin);exports.CloseHyperLinkPopupOperation=_e;exports.InsertHyperLinkOperation=Ae;exports.InsertLinkShortcut=Qe;exports.OpenHyperLinkEditPanelOperation=je;exports.SheetsHyperLinkSidePanelService=ze;
|
package/lib/es/index.js
CHANGED
|
@@ -689,7 +689,7 @@ const Xe = () => {
|
|
|
689
689
|
setPayload: g
|
|
690
690
|
}
|
|
691
691
|
),
|
|
692
|
-
/* @__PURE__ */ _e("div", { className: "univer-flex univer-flex-row univer-justify-end", children: [
|
|
692
|
+
/* @__PURE__ */ _e("div", { className: "univer-flex univer-flex-row univer-justify-end univer-gap-2", children: [
|
|
693
693
|
/* @__PURE__ */ m(
|
|
694
694
|
dn,
|
|
695
695
|
{
|
|
@@ -703,7 +703,6 @@ const Xe = () => {
|
|
|
703
703
|
dn,
|
|
704
704
|
{
|
|
705
705
|
variant: "primary",
|
|
706
|
-
style: { marginLeft: 8 },
|
|
707
706
|
onClick: async () => {
|
|
708
707
|
ft();
|
|
709
708
|
},
|
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-mb-1{margin-bottom:4px}.univer-ml-2{margin-left:8px}.univer-mr-2{margin-right:8px}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-size-6{width:24px;height:24px}.univer-h-5{height:20px}.univer-h-6{height:24px}.univer-w-5{width:20px}.univer-w-\[296px\]{width:296px}.univer-w-full{width:100%}.univer-max-w-80{max-width:320px}.univer-flex-1{flex:1 1 0%}.univer-flex-none{flex:none}.univer-cursor-pointer{cursor:pointer}.univer-flex-row{flex-direction:row}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-overflow-hidden{overflow:hidden}.univer-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-text-ellipsis{text-overflow:ellipsis}.univer-rounded{border-radius:4px}.univer-rounded-lg{border-radius:8px}.univer-rounded-xl{border-radius:12px}.univer-bg-white{background-color:var(--univer-white)}.univer-p-3{padding:12px}.univer-p-4{padding:16px}.univer-text-base{font-size:16px;line-height:24px}.univer-text-sm{font-size:14px;line-height:20px}.univer-leading-5{line-height:20px}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-primary-600{color:var(--univer-primary-600)}.univer-text-red-500{color:var(--univer-red-500)}.univer-shadow-md{--tw-shadow: 0px 1px 6px -2px rgba(30, 40, 77, .08), 0px 2px 6px -1px rgba(30, 40, 77, .1);--tw-shadow-colored: 0px 1px 6px -2px var(--tw-shadow-color), 0px 2px 6px -1px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 6px -2px #1e284d14,0 2px 6px -1px #1e284d1a;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.dark\:\!univer-bg-gray-900:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}
|
|
1
|
+
.univer-mb-1{margin-bottom:4px}.univer-ml-2{margin-left:8px}.univer-mr-2{margin-right:8px}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-size-6{width:24px;height:24px}.univer-h-5{height:20px}.univer-h-6{height:24px}.univer-w-5{width:20px}.univer-w-\[296px\]{width:296px}.univer-w-full{width:100%}.univer-max-w-80{max-width:320px}.univer-flex-1{flex:1 1 0%}.univer-flex-none{flex:none}.univer-cursor-pointer{cursor:pointer}.univer-flex-row{flex-direction:row}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:8px}.univer-overflow-hidden{overflow:hidden}.univer-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-text-ellipsis{text-overflow:ellipsis}.univer-rounded{border-radius:4px}.univer-rounded-lg{border-radius:8px}.univer-rounded-xl{border-radius:12px}.univer-bg-white{background-color:var(--univer-white)}.univer-p-3{padding:12px}.univer-p-4{padding:16px}.univer-text-base{font-size:16px;line-height:24px}.univer-text-sm{font-size:14px;line-height:20px}.univer-leading-5{line-height:20px}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-primary-600{color:var(--univer-primary-600)}.univer-text-red-500{color:var(--univer-red-500)}.univer-shadow-md{--tw-shadow: 0px 1px 6px -2px rgba(30, 40, 77, .08), 0px 2px 6px -1px rgba(30, 40, 77, .1);--tw-shadow-colored: 0px 1px 6px -2px var(--tw-shadow-color), 0px 2px 6px -1px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 6px -2px #1e284d14,0 2px 6px -1px #1e284d1a;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.dark\:\!univer-bg-gray-900:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}
|
package/lib/index.js
CHANGED
|
@@ -689,7 +689,7 @@ const Xe = () => {
|
|
|
689
689
|
setPayload: g
|
|
690
690
|
}
|
|
691
691
|
),
|
|
692
|
-
/* @__PURE__ */ _e("div", { className: "univer-flex univer-flex-row univer-justify-end", children: [
|
|
692
|
+
/* @__PURE__ */ _e("div", { className: "univer-flex univer-flex-row univer-justify-end univer-gap-2", children: [
|
|
693
693
|
/* @__PURE__ */ m(
|
|
694
694
|
dn,
|
|
695
695
|
{
|
|
@@ -703,7 +703,6 @@ const Xe = () => {
|
|
|
703
703
|
dn,
|
|
704
704
|
{
|
|
705
705
|
variant: "primary",
|
|
706
|
-
style: { marginLeft: 8 },
|
|
707
706
|
onClick: async () => {
|
|
708
707
|
ft();
|
|
709
708
|
},
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(g,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react/jsx-runtime"),require("@univerjs/sheets-formula-ui"),require("react"),require("@univerjs/sheets-data-validation")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react/jsx-runtime","@univerjs/sheets-formula-ui","react","@univerjs/sheets-data-validation"],o):(g=typeof globalThis<"u"?globalThis:g||self,o(g.UniverSheetsHyperLinkUi={},g.UniverCore,g.UniverSheets,g.UniverSheetsHyperLink,g.UniverSheetsUi,g.UniverDesign,g.UniverEngineFormula,g.UniverUi,g.UniverDocsUi,g.UniverEngineRender,g.rxjs,g.UniverDocs,g.React,g.UniverSheetsFormulaUi,g.React,g.UniverSheetsDataValidation))})(this,function(g,o,f,I,R,L,z,m,J,de,w,pe,y,Mt,E,tt){"use strict";var wn=Object.defineProperty;var Nn=(g,o,f)=>o in g?wn(g,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):g[o]=f;var F=(g,o,f)=>Nn(g,typeof o!="symbol"?o+"":o,f);function Ce(e){return o.Tools.isLegalUrl(e)}function Ut(e){return/^[a-zA-Z]+:\/\//.test(e)}function Ht(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function xt(e){if(Ce(e)){const n=Ut(e)?e:Ht(e)?`mailto://${e}`:`http://${e}`;let t;try{t=new URL(n)}catch{return e}return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:n}return e}const nt="sheets-hyper-link-ui.config",it={};var At=Object.getOwnPropertyDescriptor,Bt=(e,n,t,i)=>{for(var r=i>1?void 0:i?At(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ae=(e,n)=>(t,i)=>n(t,i,e);function Vt(e,n){const t=n.getMergeData(),i=n.getMaxColumns()-1,r=n.getMaxRows()-1;if(i<e.endColumn&&(e.endColumn=i),r<e.endRow&&(e.endRow=r),e.rangeType===o.RANGE_TYPE.COLUMN||o.RANGE_TYPE.ROW)return e;const s=[];return t.forEach(a=>{o.Rectangle.intersects(e,a)&&s.push(a)}),o.Rectangle.realUnion(e,...s)}g.SheetsHyperLinkResolverService=class{constructor(n,t,i,r,s,a){this._univerInstanceService=n,this._commandService=t,this._definedNamesService=i,this._messageService=r,this._localeService=s,this._configService=a}navigate(n){switch(n.type){case I.SheetHyperLinkType.URL:this.navigateToOtherWebsite(n.url);break;default:this._navigateToUniver(n.searchObj)}}_navigateToUniver(n){const{gid:t,range:i,rangeid:r}=n,s=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const a=s.getUnitId();if(r){const l=this._definedNamesService.getValueById(a,r);if(!l)return;const{formulaOrRefString:u}=l,h=this._definedNamesService.getWorksheetByRef(a,u);if(!h){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:L.MessageType.Error});return}if(h.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:L.MessageType.Error});return}this.navigateToDefineName(a,r)}if(t){if(i){const l=z.deserializeRangeWithSheet(i);o.isValidRange(l.range)&&i!==I.ERROR_RANGE&&this.navigateToRange(a,t,l.range);return}this.navigateToSheetById(a,t)}}async navigateToRange(n,t,i,r){const s=await this.navigateToSheetById(n,t);if(s){const a=Vt(i,s);await this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:n,subUnitId:t,selections:[{range:a,primary:null}]}),await this._commandService.executeCommand(R.ScrollToRangeOperation.id,{range:a,forceTop:r})}}async navigateToSheetById(n,t){const i=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;const r=i.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const s=i.getSheetBySheetId(t);return s?i.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:L.MessageType.Error}),!1):await this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:t})?s:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:L.MessageType.Error}),!1)}async navigateToDefineName(n,t){return this._definedNamesService.focusRange(n,t),!0}async navigateToOtherWebsite(n){var i;const t=this._configService.getConfig(nt);if((i=t==null?void 0:t.urlHandler)!=null&&i.navigateToOtherWebsite)return t.urlHandler.navigateToOtherWebsite(n);window.open(n,"_blank","noopener noreferrer")}},g.SheetsHyperLinkResolverService=Bt([ae(0,o.IUniverInstanceService),ae(1,o.ICommandService),ae(2,z.IDefinedNamesService),ae(3,m.IMessageService),ae(4,o.Inject(o.LocaleService)),ae(5,o.IConfigService)],g.SheetsHyperLinkResolverService);const je="SHEET_HYPER_LINK_UI_PLUGIN";var jt=Object.getOwnPropertyDescriptor,$t=(e,n,t,i)=>{for(var r=i>1?void 0:i?jt(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Ee=(e,n)=>(t,i)=>n(t,i,e);g.SheetsHyperLinkCopyPasteController=class extends o.Disposable{constructor(t,i,r,s){super();F(this,"_plainTextFilter",new Set);F(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=i,this._injector=r,this._resolverService=s,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(t){this._plainTextFilter.add(t)}removePlainTextFilter(t){this._plainTextFilter.delete(t)}_filterPlainText(t){return Array.from(this._plainTextFilter).every(i=>i(t))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:je,onBeforeCopy:(t,i,r)=>this._collect(t,i,r),onPasteCells:(t,i,r,s)=>{const{copyType:a=R.COPY_TYPE.COPY,pasteType:l}=s,{range:u}=t||{},{range:h,unitId:d,subUnitId:p}=i;return this._generateMutations(h,{copyType:a,pasteType:l,copyRange:u,unitId:d,subUnitId:p})},onPastePlainText:(t,i)=>{const r=this._filterPlainText(i);if(Ce(i)&&r){const{range:s,unitId:a,subUnitId:l}=t,{ranges:[u],mapFunc:h}=R.virtualizeDiscreteRanges([s]),d=[],p=[];return o.Range.foreach(u,(_,S)=>{const{row:P,col:D}=h(_,S),T=this._hyperLinkModel.getHyperLinkByLocation(a,l,P,D);T&&d.push({id:I.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:l,id:T.id}}),T&&p.push({id:I.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:l,link:T}})}),{redos:d,undos:p}}return{undos:[],redos:[]}},priority:99})}_collect(t,i,r){const s=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:i,matrix:s};const a=this._injector.invoke(h=>f.rangeToDiscreteRange(r,h,t,i));if(!a)return;const{rows:l,cols:u}=a;l.forEach((h,d)=>{u.forEach((p,_)=>{var P;const S=this._hyperLinkModel.getHyperLinkByLocation(t,i,h,p);s.setValue(d,_,(P=S==null?void 0:S.id)!=null?P:"")})})}_generateMutations(t,i){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!i.copyRange)return{redos:[],undos:[]};if([R.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,R.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,R.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,R.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(i.pasteType))return{redos:[],undos:[]};const{unitId:s,subUnitId:a}=this._copyInfo,l=[],u=[],{ranges:[h,d],mapFunc:p}=R.virtualizeDiscreteRanges([i.copyRange,t]);return R.getRepeatRange(h,d,!0).forEach(({startRange:S})=>{var P;(P=this._copyInfo)==null||P.matrix.forValue((D,T,c)=>{const b=o.Rectangle.getPositionRange({startRow:D,endRow:D,startColumn:T,endColumn:T},S),A=this._hyperLinkModel.getHyperLink(s,a,c),{row:M,col:U}=p(b.startRow,b.startColumn),j=this._hyperLinkModel.getHyperLinkByLocation(i.unitId,i.subUnitId,M,U),V=o.Tools.generateRandomId();j&&l.push({id:I.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:j.id}}),A&&(l.push({id:I.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:{...A,id:V,row:M,column:U}}}),u.push({id:I.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:V}})),j&&u.push({id:I.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:j}})})}),{redos:l,undos:u}}},g.SheetsHyperLinkCopyPasteController=$t([Ee(0,R.ISheetClipboardService),Ee(1,o.Inject(I.HyperLinkModel)),Ee(2,o.Inject(o.Injector)),Ee(3,o.Inject(g.SheetsHyperLinkResolverService))],g.SheetsHyperLinkCopyPasteController);var C=(e=>(e.EDITING="editing",e.VIEWING="viewing",e.ZEN_EDITOR="zen_mode",e))(C||{});class $e extends o.Disposable{constructor(){super(...arguments);F(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==I.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(r=>r.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:i}=this;i.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const Re=()=>{var mt;const[e,n]=E.useState(""),[t,i]=E.useState(!1),[r,s]=E.useState(""),[a,l]=E.useState(!0),[u,h]=E.useState(I.SheetHyperLinkType.URL),[d,p]=E.useState(""),_=m.useDependency(o.LocaleService),S=m.useDependency(z.IDefinedNamesService),P=m.useDependency(R.IEditorBridgeService),D=m.useDependency(o.IUniverInstanceService),T=m.useDependency(g.SheetsHyperLinkPopupService),c=m.useObservable(T.currentEditing$),b=m.useDependency(I.SheetsHyperLinkParserService),A=m.useDependency(g.SheetsHyperLinkResolverService),M=m.useDependency(o.ICommandService),U=m.useDependency($e),j=E.useMemo(()=>U.getOptions(),[U]),V=m.useDependency(m.IZenZoneService),q=m.useDependency(de.IRenderManagerService),Se=m.useDependency(R.IMarkSelectionService),Ae=m.useDependency(pe.DocSelectionManagerService),oe=m.useDependency(o.IContextService),Ie=m.useDependency(o.ThemeService),_e=m.useDependency(pe.DocSelectionManagerService),[me,Be]=E.useState(!1),ce=m.useDependency(f.SheetsSelectionsService),Tn=E.useMemo(()=>ce.getCurrentSelections(),[]),Ve=E.useMemo(()=>{if(!U.isBuiltInLinkType(u))return U.getCustomHyperLink(u)},[U,u]),[le,Ln]=E.useState(!1),[fe,It]=E.useState(!1),$=E.useRef(!1),W=D.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),Dn=(W==null?void 0:W.getActiveSheet().getSheetId())||"",Q=E.useCallback(v=>{s(v.replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[s]);E.useEffect(()=>{var v,O,k,N,x,Y,ft,yt,Ct,Et,Rt,Pt,Tt,Lt,Dt,bt,Ot;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:se,row:Qe,col:et}=c;let{label:X}=c;typeof X=="number"&&(X=`${X}`);let G;if(se)G={id:(v=se==null?void 0:se.rangeId)!=null?v:"",display:X!=null?X:"",payload:(k=(O=se==null?void 0:se.properties)==null?void 0:O.url)!=null?k:"",row:Qe,column:et};else if(c.type===C.VIEWING){const H=D.getUnit(c.unitId),te=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=te==null?void 0:te.getCellRaw(c.row,c.col),ue=(Y=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:Y.find(wt=>{var Nt;return wt.rangeType===o.CustomRangeType.HYPERLINK&&((Nt=wt.properties)==null?void 0:Nt.url)}),ye=B==null?void 0:B.v;B&&(!o.BuildTextUtils.transform.isEmptyDocument((yt=(ft=B.p)==null?void 0:ft.body)==null?void 0:yt.dataStream)||o.Tools.isDefine(ye))&&l(!1),G={id:"",display:"",payload:(Et=(Ct=ue==null?void 0:ue.properties)==null?void 0:Ct.url)!=null?Et:"",row:Qe,column:et}}else{const H=D.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),te=Ae.getActiveTextRange(),B=H==null?void 0:H.getBody(),ue=te&&B?te:null,ye=ue&&((Pt=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ue,(Rt=B==null?void 0:B.customRanges)!=null?Rt:[]))==null?void 0:Pt[0]);l(!1),G={id:"",display:X!=null?X:"",payload:(Lt=(Tt=ye==null?void 0:ye.properties)==null?void 0:Tt.url)!=null?Lt:"",row:Qe,column:et}}n(G.id);const kt=U.findCustomHyperLink(G);if(kt){const H=kt.convert(G);h(H.type),p(H.payload),Q(H.display);return}Q(G.display);const ee=b.parseHyperLink(G.payload);switch(h(ee.type===I.SheetHyperLinkType.INVALID?I.SheetHyperLinkType.RANGE:ee.type),ee.type){case I.SheetHyperLinkType.URL:{p(ee.url),ee.url===G.display&&($.current=!0);break}case I.SheetHyperLinkType.RANGE:{const H=ee.searchObj,te=H.gid&&(Ot=(bt=(Dt=D.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:bt.getName())!=null?Ot:"",B=z.serializeRangeWithSheet(te,z.deserializeRangeWithSheet(H.range).range);p(B),B===G.display&&($.current=!0);break}case I.SheetHyperLinkType.SHEET:{const H=ee.searchObj;p(H.gid);break}case I.SheetHyperLinkType.DEFINE_NAME:{const H=ee.searchObj;p(H.rangeid);break}default:p("");break}}},[c,A,U,Ae,D]),E.useEffect(()=>{let v=null;if(c&&!c.customRangeId&&c.type===C.VIEWING&&o.Tools.isDefine(c.row)&&o.Tools.isDefine(c.col)){const O=D.getUnit(c.unitId,o.UniverInstanceType.UNIVER_SHEET),k=O==null?void 0:O.getSheetBySheetId(c.subUnitId),N=k==null?void 0:k.getMergedCell(c.row,c.col),x=new o.ColorKit(Ie.getColorFromTheme("primary.600")).toRgb();v=Se.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{v&&Se.removeShape(v)}},[c,Se,Ie,D]),E.useEffect(()=>{It(u===I.SheetHyperLinkType.RANGE)},[u]),E.useEffect(()=>{const v=(c==null?void 0:c.type)===C.ZEN_EDITOR?q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY):q.getRenderById(P.getCurrentEditorId()),O=new o.DisposableCollection;if(v){const k=v.with(J.DocSelectionRenderService);k.setReserveRangesStatus(!0),O.add(()=>{k.setReserveRangesStatus(!1)})}return()=>{P.disableForceKeepVisible(),O.dispose()}},[c==null?void 0:c.type,P,q]),E.useEffect(()=>(fe&&T.setIsKeepVisible(fe),T.setIsKeepVisible(me),()=>{T.setIsKeepVisible(!1)}),[fe,me,T]),E.useEffect(()=>()=>{V.temporaryHidden&&(V.show(),oe.setContextValue(o.FOCUSING_SHEET,!1))},[oe,V]),E.useEffect(()=>{if(fe)return P.enableForceKeepVisible(),()=>{P.disableForceKeepVisible()}},[fe,P]);const bn=[{label:_.t("hyperLink.form.link"),value:I.SheetHyperLinkType.URL},{label:_.t("hyperLink.form.range"),value:I.SheetHyperLinkType.RANGE},{label:_.t("hyperLink.form.worksheet"),value:I.SheetHyperLinkType.SHEET},{label:_.t("hyperLink.form.definedName"),value:I.SheetHyperLinkType.DEFINE_NAME},...j];if(!W)return;const On=W.getHiddenWorksheets(),qe=W.getSheets().map(v=>({label:v.getName(),value:v.getSheetId()})).filter(v=>On.indexOf(v.value)===-1),Xe=Object.values((mt=S.getDefinedNameMap(W.getUnitId()))!=null?mt:{}).map(v=>({label:v.name,value:v.id})),_t=(v,O)=>{if(v===I.SheetHyperLinkType.URL)return xt(O);if(v===I.SheetHyperLinkType.RANGE){const k=z.deserializeRangeWithSheet(O),N=W.getSheetBySheetName(k.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${z.serializeRange(k.range)}`}return`#${v}=${O}`},kn=m.useEvent(v=>{var x;const k=v.split(",").map(z.deserializeRangeWithSheet)[0];if(!k||!o.isValidRange(k.range))return;k.sheetName||(k.sheetName=((x=W.getActiveSheet())==null?void 0:x.getName())||"");const N=z.serializeRangeToRefString(k);p(N),N&&($.current||!r)&&(Q(N),$.current=!0)}),Je=async()=>{if(a&&!r||!d||u===I.SheetHyperLinkType.URL&&!Ce(d)){Ln(!0);return}if(c)if(e){const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?I.UpdateRichHyperLinkCommand.id:I.UpdateHyperLinkCommand.id;await M.executeCommand(v,{id:e,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:a?r:"",payload:_t(u,d)},row:c.row,column:c.col,documentId:c.type===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:P.getCurrentEditorId()})}else{const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?I.AddRichHyperLinkCommand.id:I.AddHyperLinkCommand.id;await M.executeCommand(v,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:o.generateRandomId(),row:c.row,column:c.col,payload:_t(u,d),display:a?r:""},documentId:c.type===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:P.getCurrentEditorId()})}if((c==null?void 0:c.type)===C.VIEWING){await M.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const v=1;await M.executeCommand(R.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-v,0),endRow:c.row+v,startColumn:Math.max(c.col-v,0),endColumn:c.col+v}})}M.executeCommand(ve.id)};return c?y.jsxs("div",{className:L.clsx("univer-box-border univer-w-[296px] univer-rounded-xl univer-bg-white univer-p-4 univer-shadow-md dark:!univer-bg-gray-900",L.borderClassName),children:[a?y.jsx(L.FormLayout,{label:_.t("hyperLink.form.label"),error:le&&!r?_.t("hyperLink.form.inputError"):"",children:y.jsx(L.Input,{value:r,onChange:v=>{Q(v),$.current=!1},placeholder:_.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Je()}})}):null,y.jsx(L.FormLayout,{label:_.t("hyperLink.form.type"),children:y.jsx(L.Select,{className:"univer-w-full",options:bn,value:u,onChange:v=>{h(v),p("")}})}),u===I.SheetHyperLinkType.URL&&y.jsx(L.FormLayout,{error:le?d?Ce(d)?"":_.t("hyperLink.form.linkError"):_.t("hyperLink.form.inputError"):"",children:y.jsx(L.Input,{value:d,onChange:v=>{p(v),v&&($.current||!r||r===v)&&(Q(v),$.current=!0)},placeholder:_.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Je()}})}),u===I.SheetHyperLinkType.RANGE&&y.jsx(L.FormLayout,{error:le&&!d?_.t("hyperLink.form.inputError"):"",children:y.jsx(Mt.RangeSelector,{unitId:W.getUnitId(),subUnitId:Dn,maxRangeCount:1,supportAcrossSheet:!0,initialValue:d,resetRange:Tn,onChange:(v,O)=>kn(O),onRangeSelectorDialogVisibleChange:async v=>{var O,k;if(Be(v),v)c.type===C.ZEN_EDITOR&&(V.hide(),oe.setContextValue(o.FOCUSING_SHEET,!0)),c.type!==C.VIEWING&&P.enableForceKeepVisible(),i(!0);else{if(await A.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===C.ZEN_EDITOR){await M.executeCommand(f.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),V.show(),oe.setContextValue(o.FOCUSING_SHEET,!1);const N=(O=q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:O.with(J.DocBackScrollRenderController),x=(k=_e.getTextRanges({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:k[0];N&&x&&(N.scrollToRange(x),_e.refreshSelection({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}P.disableForceKeepVisible(),i(!1)}},onFocusChange:v=>It(v)})}),u===I.SheetHyperLinkType.SHEET&&y.jsx(L.FormLayout,{error:le&&!d?_.t("hyperLink.form.selectError"):"",children:y.jsx(L.Select,{className:"univer-w-full",options:qe,value:d,onChange:v=>{var N,x;p(v);const O=(N=qe.find(Y=>Y.value===v))==null?void 0:N.label,k=(x=qe.find(Y=>Y.value===d))==null?void 0:x.label;O&&($.current||!r||r===k)&&(Q(O),$.current=!0)}})}),u===I.SheetHyperLinkType.DEFINE_NAME&&y.jsx(L.FormLayout,{error:le&&!d?_.t("hyperLink.form.selectError"):"",children:y.jsx(L.Select,{className:"univer-w-full",options:Xe,value:d,onChange:v=>{var N,x;p(v);const O=(N=Xe.find(Y=>Y.value===v))==null?void 0:N.label,k=(x=Xe.find(Y=>Y.value===d))==null?void 0:x.label;O&&($.current||!r||r===k)&&(Q(O),$.current=!0)}})}),(Ve==null?void 0:Ve.Form)&&y.jsx(Ve.Form,{linkId:e,payload:d,display:r,showError:le,setByPayload:$,setDisplay:v=>{Q(v),$.current=!0},setPayload:p}),y.jsxs("div",{className:"univer-flex univer-flex-row univer-justify-end",children:[y.jsx(L.Button,{onClick:()=>{c&&A.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),M.executeCommand(ve.id)},children:_.t("hyperLink.form.cancel")}),y.jsx(L.Button,{variant:"primary",style:{marginLeft:8},onClick:async()=>{Je()},children:_.t("hyperLink.form.ok")})]})]}):null};Re.componentKey="univer.sheet.cell-link-edit";var Z=function(){return Z=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Z.apply(this,arguments)},Zt=function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)n.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(t[i[r]]=e[i[r]]);return t},ne=E.forwardRef(function(e,n){var t=e.icon,i=e.id,r=e.className,s=e.extend,a=Zt(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),u=E.useRef("_".concat(Wt()));return rt(t,"".concat(i),{defIds:t.defIds,idSuffix:u.current},Z({ref:n,className:l},a),s)});function rt(e,n,t,i,r){return E.createElement(e.tag,Z(Z({key:n},Ft(e,t,r)),i),(Kt(e,t).children||[]).map(function(s,a){return rt(s,"".concat(n,"-").concat(e.tag,"-").concat(a),t,void 0,r)}))}function Ft(e,n,t){var i=Z({},e.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1),e.tag==="mask"&&i.id&&(i.id=i.id+n.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],l=s[1];a==="mask"&&typeof l=="string"&&(i[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var r=n.defIds;return!r||r.length===0||(e.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(i[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),i}function Kt(e,n){var t,i=n.defIds;return!i||i.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?Z(Z({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?Z(Z({},r),{attrs:Z(Z({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):e}function Wt(){return Math.random().toString(36).substring(2,8)}ne.displayName="UniverIcon";var Yt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Pe=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"all-border-single",ref:n,icon:Yt}))});Pe.displayName="AllBorderSingle";var Gt={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"}}]},ot=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"copy-single",ref:n,icon:Gt}))});ot.displayName="CopySingle";var zt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},Ze=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"link-single",ref:n,icon:zt}))});Ze.displayName="LinkSingle";var qt={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"}}]},st=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"unlink-single",ref:n,icon:qt}))});st.displayName="UnlinkSingle";var Xt={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"}}]},at=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"write-single",ref:n,icon:Xt}))});at.displayName="WriteSingle";var Jt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.4538 1.12549C2.70051 1.12549 2.08984 1.73615 2.08984 2.48945V13.5104C2.08984 14.2637 2.70051 14.8744 3.4538 14.8744H12.5468C13.3001 14.8744 13.9108 14.2637 13.9108 13.5104V5.0992L10.0094 1.12549H3.4538Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M10.0078 1.12549L13.9107 5.09842H10.6745C10.3063 5.09842 10.0078 4.79994 10.0078 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.80941 10.2949L6.37701 12.403C6.2632 12.5705 6.03516 12.614 5.86766 12.5002C5.70017 12.3864 5.65664 12.1584 5.77045 11.9909L7.36611 9.64252L5.94103 7.54519C5.82722 7.37769 5.87074 7.14964 6.03824 7.03583C6.20573 6.92202 6.43378 6.96555 6.54759 7.13304L7.80941 8.9901L9.07123 7.13304C9.18504 6.96555 9.41309 6.92202 9.58059 7.03583C9.74808 7.14964 9.7916 7.37769 9.67779 7.54519L8.25271 9.64252L9.84837 11.9909C9.96218 12.1584 9.91866 12.3864 9.75116 12.5002C9.58366 12.614 9.35562 12.5705 9.24181 12.403L7.80941 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ct=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"xlsx",ref:n,icon:Jt}))});ct.displayName="Xlsx";const Qt={[I.SheetHyperLinkType.URL]:y.jsx(Ze,{}),[I.SheetHyperLinkType.SHEET]:y.jsx(ct,{}),[I.SheetHyperLinkType.RANGE]:y.jsx(Pe,{}),[I.SheetHyperLinkType.DEFINE_NAME]:y.jsx(Pe,{}),[I.SheetHyperLinkType.INVALID]:y.jsx(Pe,{})},lt=e=>{var A,M;const n=m.useDependency(g.SheetsHyperLinkPopupService),t=m.useDependency(o.ICommandService),i=m.useDependency(m.IMessageService),r=m.useDependency(o.LocaleService),s=m.useDependency(g.SheetsHyperLinkResolverService),a=m.useDependency(R.IEditorBridgeService),l=m.useDependency(I.SheetsHyperLinkParserService),u=m.useDependency(m.IZenZoneService),{customRange:h,row:d,col:p,unitId:_,subUnitId:S,editPermission:P,copyPermission:D,type:T}=e;if(!((A=h==null?void 0:h.properties)!=null&&A.url))return null;const c=l.parseHyperLink((M=h.properties.url)!=null?M:""),b=c.type===I.SheetHyperLinkType.INVALID;return y.jsxs("div",{className:L.clsx("univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow-md dark:!univer-bg-gray-900",L.borderClassName),onClick:()=>n.hideCurrentPopup(),children:[y.jsxs("div",{className:L.clsx("univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600",{"univer-text-red-500":b}),onClick:()=>{u.visible||b||s.navigate(c)},children:[y.jsx("div",{className:"univer-mr-2 univer-flex univer-h-5 univer-w-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white",children:Qt[c.type]}),y.jsx(L.Tooltip,{showIfEllipsis:!0,title:c.name,asChild:!0,children:y.jsx("span",{className:"univer-flex-1 univer-overflow-hidden univer-text-ellipsis",children:c.name})})]}),y.jsxs("div",{className:"univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center",children:[D&&y.jsx("div",{className:L.clsx("univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-text-red-500":b}),onClick:()=>{if(!b){if(c.type!==I.SheetHyperLinkType.URL){const U=new URL(window.location.href);U.hash=c.url.slice(1),navigator.clipboard.writeText(U.href)}else navigator.clipboard.writeText(c.url);i.show({content:r.t("hyperLink.message.coped"),type:L.MessageType.Info})}},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:y.jsx(ot,{className:"dark:!univer-text-white"})})}),P&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",onClick:()=>{t.executeCommand(Le.id,{unitId:_,subUnitId:S,row:d,col:p,customRangeId:h.rangeId,type:T})},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:y.jsx(at,{className:"dark:!univer-text-white"})})}),y.jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",onClick:()=>{const U=T===C.EDITING||T===C.ZEN_EDITOR?I.CancelRichHyperLinkCommand.id:I.CancelHyperLinkCommand.id;t.syncExecuteCommand(U,{unitId:_,subUnitId:S,id:h.rangeId,row:d,column:p,documentId:T===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:a.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:y.jsx(st,{className:"dark:!univer-text-white"})})})]})]})]})},Te=()=>{var r,s;const e=m.useDependency(g.SheetsHyperLinkPopupService),[n,t]=E.useState(null),i=m.useDependency(o.IUniverInstanceService);if(E.useEffect(()=>{t(e.currentPopup);const a=e.currentPopup$.subscribe(l=>{t(l)});return()=>{a.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){const a=i.getUnit(n.unitId,o.UniverInstanceType.UNIVER_SHEET),l=a==null?void 0:a.getSheetBySheetId(n.subUnitId),u=l==null?void 0:l.getCell(n.row,n.col),h=(s=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:s.customRanges;return h!=null&&h.length?y.jsx("div",{children:h.map(d=>y.jsx(lt,{...n,customRange:d},d.rangeId))}):null}return y.jsx(lt,{...n})};Te.componentKey="univer.sheet.cell-link-popup";var en=Object.getOwnPropertyDescriptor,tn=(e,n,t,i)=>{for(var r=i>1?void 0:i?en(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ie=(e,n)=>(t,i)=>n(t,i,e);const ut=(e,n)=>{var t,i;return e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.row===n.row&&e.col===n.col&&((t=e.customRange)==null?void 0:t.rangeId)===((i=n.customRange)==null?void 0:i.rangeId)&&e.type===n.type};g.SheetsHyperLinkPopupService=class extends o.Disposable{constructor(t,i,r,s,a,l,u){super();F(this,"_currentPopup",null);F(this,"_currentPopup$",new w.Subject);F(this,"currentPopup$",this._currentPopup$.asObservable());F(this,"_currentEditingPopup",null);F(this,"_currentEditing$",new w.BehaviorSubject(null));F(this,"currentEditing$",this._currentEditing$.asObservable());F(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=i,this._univerInstanceService=r,this._editorBridgeService=s,this._textSelectionManagerService=a,this._docCanvasPopManagerService=l,this._zenZoneService=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(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){if(this._currentPopup&&ut(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==C.ZEN_EDITOR&&this._zenZoneService.visible))return;const i=this._currentEditing$.getValue();if(i&&ut(t,i))return;const{unitId:r,subUnitId:s,row:a,col:l,customRangeRect:u,customRange:h}=t;let d;const p={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===C.EDITING){if(!h)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,p)}else if(t.type===C.ZEN_EDITOR){if(!h)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:h.startIndex,endOffset:h.endIndex+1,collapsed:!1},p,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,p,r,s);else{if(!h)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,p,t)}d&&(this._currentPopup={unitId:r,subUnitId:s,disposable:d,row:a,col:l,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:h,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,i){var r,s;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||i)&&((s=(r=this._currentPopup)==null?void 0:r.disposable)==null||s.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,s,a;const t=this._editorBridgeService.isVisible().visible,i=this._editorBridgeService.getEditCellState();if(t&&i){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=i.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:o.BuildTextUtils.transform.getPlainText(u.dataStream)};const h=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(a=(s=u.customRanges)==null?void 0:s.filter(_=>_.rangeType===o.CustomRangeType.HYPERLINK))!=null?a:[]);let d=l.startOffset,p=l.endOffset;return h.forEach(_=>{d=Math.min(d,_.startIndex),p=Math.max(p,_.endIndex+1)}),{startOffset:d,endOffset:p,collapsed:d===p,label:o.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,p))}}return null}get _editPopup(){return{componentKey:Re.componentKey,direction:"vertical",onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var a,l,u,h,d;const{unitId:i,subUnitId:r,type:s}=t;if(s===C.ZEN_EDITOR){const p=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(!p)return;const _=this._textSelectionManagerService.getActiveTextRange();if(!_)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(_,this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const S=(a=p.getBody())==null?void 0:a.dataStream.slice(_.startOffset,_.endOffset);this._currentEditing$.next({...t,label:S})}else if(s===C.EDITING){const p=this._getEditingRange();if(!p)return;this._textSelectionManagerService.replaceDocRanges([{...p}],{unitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const _=this._injector.get(de.IRenderManagerService).getRenderById(o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!_)return;const S=J.calcDocRangePositions(p,_);if(!(S!=null&&S.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.pop(),this._editPopup,i,r),this._currentEditing$.next({...t,label:(l=p==null?void 0:p.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r);const p=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),_=p==null?void 0:p.getSheetBySheetId(r),S=_==null?void 0:_.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:S!=null&&S.p?o.BuildTextUtils.transform.getPlainText((h=(u=S.p.body)==null?void 0:u.dataStream)!=null?h:""):((d=S==null?void 0:S.v)!=null?d:"").toString()})}}startEditing(t){var l,u,h,d,p,_;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:i,subUnitId:r}=t;let s,a;if(t.type===C.ZEN_EDITOR){const S=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(s=(h=(u=S==null?void 0:S.getBody())==null?void 0:u.customRanges)==null?void 0:h.find(P=>P.rangeId===t.customRangeId),a=s?(d=S==null?void 0:S.getBody())==null?void 0:d.dataStream.slice(s.startIndex,s.endIndex+1):"",!s||!a)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:s.startIndex,endOffset:s.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:s.startIndex,endOffset:s.endIndex,collapsed:!1},this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===C.EDITING){const S=R.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!S||!((p=S.rects)!=null&&p.length))return;s=S.customRange,a=S.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:s.startIndex,endOffset:s.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.rects.pop(),this._editPopup,i,r)}else{const S=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),P=S==null?void 0:S.getSheetBySheetId(r),D=P==null?void 0:P.getCellRaw(t.row,t.col),T=S==null?void 0:S.getStyles().getStyleByCell(D),c=T==null?void 0:T.tr,b=R.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!b||!((_=b.rects)!=null&&_.length))return;s=b.customRange,a=b.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(b.rects.pop(),this._editPopup,{unitId:i,subUnitId:r,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:s,label:a})}endEditing(t){var r;if(this.getIsKeepVisible())return;const i=this._currentEditing$.getValue();i&&(!t||t===i.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},g.SheetsHyperLinkPopupService=tn([ie(0,o.Inject(R.SheetCanvasPopManagerService)),ie(1,o.Inject(o.Injector)),ie(2,o.IUniverInstanceService),ie(3,R.IEditorBridgeService),ie(4,o.Inject(pe.DocSelectionManagerService)),ie(5,o.Inject(J.DocCanvasPopManagerService)),ie(6,m.IZenZoneService)],g.SheetsHyperLinkPopupService);var he=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(he||{});const nn=new Set([o.DataValidationType.CHECKBOX,o.DataValidationType.LIST,o.DataValidationType.LIST_MULTIPLE]),Fe=(e,n,t,i)=>{var l,u,h,d,p;const r=n.getCell(t,i);if(r!=null&&r.f||r!=null&&r.si||(h=(u=(l=r==null?void 0:r.p)==null?void 0:l.body)==null?void 0:u.customBlocks)!=null&&h.length)return 1;const s=e.has(tt.SheetDataValidationModel)?e.get(tt.SheetDataValidationModel):null,a=s==null?void 0:s.getRuleByLocation(n.getUnitId(),n.getSheetId(),t,i);return a&&nn.has(a.type)?!0:(p=(d=r==null?void 0:r.p)==null?void 0:d.drawingsOrder)!=null&&p.length?2:0},rn=e=>{const n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const t=n.getActiveSheet(),i=e.get(f.SheetsSelectionsService).getCurrentSelections();if(!i.length)return!0;const r=i[0].range.startRow,s=i[0].range.startColumn;return Fe(e,t,r,s)===1},on=e=>{const n=e.get(pe.DocSelectionManagerService),t=e.get(o.IUniverInstanceService),i=n.getTextRanges();if(!(i!=null&&i.length))return!0;const r=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);return!!(!r||i.every(a=>a.collapsed)||!r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody())},Le={type:o.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,n){if(!n)return!1;const t=e.get(g.SheetsHyperLinkPopupService);return n.customRangeId?t.startEditing(n):t.startAddEditing(n),!0}},ve={type:o.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(g.SheetsHyperLinkPopupService).endEditing(),!0}},De={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var p;const n=e.get(o.IUniverInstanceService),t=f.getSheetCommandTarget(n),i=e.get(R.IEditorBridgeService);if(!t)return!1;const r=e.get(o.ICommandService),a=e.get(f.SheetsSelectionsService).getCurrentLastSelection();if(!a)return!1;const l=a.range.startRow,u=a.range.startColumn,h=i.isVisible(),d=((p=n.getFocusedUnit())==null?void 0:p.getUnitId())===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Le.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:l,col:u,type:d?C.ZEN_EDITOR:h.visible?C.EDITING:C.VIEWING})}},re={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(rn(e))return!1;const n=e.get(o.ICommandService);return e.get(g.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(ve.id):n.executeCommand(De.id)}},Ke=(e,n=o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const t=e.get(o.IUniverInstanceService),i=(r=e.get(de.IRenderManagerService).getRenderById(n))==null?void 0:r.with(J.DocSelectionRenderService);return i?i.textSelectionInner$.pipe(w.map(()=>{const a=e.get(R.IEditorBridgeService).getEditCellState();if(!a)return!0;const l=f.getSheetCommandTarget(t,{unitId:a.unitId,subUnitId:a.sheetId});return!(l!=null&&l.worksheet)||Fe(e,l.worksheet,a.row,a.column)===1?!0:on(e)})):w.of(!0)},dt=e=>{var r;const n=e.get(o.IUniverInstanceService),t=e.has(R.IEditorBridgeService)?e.get(R.IEditorBridgeService):null;return((r=t==null?void 0:t.currentEditCellState$.pipe(w.map(s=>{if(!s)return he.DISABLED_BY_CELL;const a=f.getSheetCommandTarget(n,{unitId:s.unitId,subUnitId:s.sheetId});return a?Fe(e,a.worksheet,s.row,s.column):he.DISABLED_BY_CELL}),w.switchMap(s=>{if(s===he.DISABLED_BY_CELL)return w.of(!0);const a=t?t.visible$:w.of(null);return w.combineLatest([a,n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC)]).pipe(w.switchMap(([l,u])=>l!=null&&l.visible?(u==null?void 0:u.getUnitId())===o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?w.of(!0):Ke(e,o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):w.of(s!==he.ALLOWED)))})))!=null?r:w.of(!0)).pipe(w.switchMap(s=>s?w.of(!0):R.getCurrentRangeDisable$(e,{workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},!0)))},be={commandId:De.id,type:m.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},Oe=e=>`${e}-zen-editor`,sn=e=>({...be,id:be.commandId,hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:dt(e)}),an=e=>({...be,id:Oe(be.commandId),hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(e)}),ke={tooltip:"hyperLink.form.addTitle",commandId:re.id,type:m.MenuItemType.BUTTON,icon:"LinkSingle"},cn=e=>({...ke,id:ke.commandId,hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:dt(e)}),ln=e=>({...ke,id:Oe(ke.commandId),hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(e)}),We={id:re.id,binding:m.KeyCode.K|m.MetaKeys.CTRL_COMMAND,preconditions:R.whenSheetEditorFocused};var un=Object.getOwnPropertyDescriptor,dn=(e,n,t,i)=>{for(var r=i>1?void 0:i?un(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},pt=(e,n)=>(t,i)=>n(t,i,e);let we=class extends o.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(i,r)=>{const{source:s,target:a,unitId:l,subUnitId:u}=i,h=R.virtualizeDiscreteRanges([s,a]),[d,p]=h.ranges,{mapFunc:_}=h,S={row:d.startRow,col:d.startColumn},P=R.getAutoFillRepeatRange(d,p),D=[],T=[];return P.forEach(c=>{const b=c.repeatStartCell,A=c.relativeRange,M={startRow:S.row,startColumn:S.col,endColumn:S.col,endRow:S.row},U={startRow:b.row,startColumn:b.col,endColumn:b.col,endRow:b.row};o.Range.foreach(A,(j,V)=>{const q=o.Rectangle.getPositionRange({startRow:j,startColumn:V,endColumn:V,endRow:j},M),{row:Se,col:Ae}=_(q.startRow,q.startColumn),oe=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Ae),Ie=o.Rectangle.getPositionRange({startRow:j,startColumn:V,endColumn:V,endRow:j},U),{row:_e,col:me}=_(Ie.startRow,Ie.startColumn),Be=o.Tools.generateRandomId(),ce=this._hyperLinkModel.getHyperLinkByLocation(l,u,_e,me);ce&&D.push({id:I.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce.id}}),(R.APPLY_TYPE.COPY===r||R.APPLY_TYPE.SERIES===r)&&oe&&(D.push({id:I.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...oe,id:Be,row:_e,column:me}}}),T.push({id:I.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:Be}})),ce&&T.push({id:I.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:ce}})})}),{undos:T,redos:D}},t={id:je,onFillData:(i,r,s)=>s===R.APPLY_TYPE.COPY||s===R.APPLY_TYPE.ONLY_FORMAT||s===R.APPLY_TYPE.SERIES?n(i,s):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};we=dn([pt(0,R.IAutoFillService),pt(1,o.Inject(I.HyperLinkModel))],we);var pn=Object.getOwnPropertyDescriptor,hn=(e,n,t,i)=>{for(var r=i>1?void 0:i?pn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Ye=(e,n)=>(t,i)=>n(t,i,e);let Ne=class extends o.Disposable{constructor(e,n,t){super(),this._localeService=e,this._commandService=n,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===We.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],rangeTypes:[f.RangeProtectionPermissionEditPoint],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Ne=hn([Ye(0,o.Inject(o.LocaleService)),Ye(1,o.ICommandService),Ye(2,o.Inject(f.SheetPermissionCheckController))],Ne);var vn=Object.getOwnPropertyDescriptor,gn=(e,n,t,i)=>{for(var r=i>1?void 0:i?vn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},K=(e,n)=>(t,i)=>n(t,i,e);let Me=class extends o.Disposable{constructor(e,n,t,i,r,s,a,l,u,h){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=i,this._sheetPermissionCheckController=r,this._commandService=s,this._editorBridgeService=a,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=h,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:n,subUnitId:t,row:i,col:r}=e,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET);if(!(s==null?void 0:s.getSheetBySheetId(t)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookViewPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),u=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),h=this._permissionService.composePermission([new f.WorkbookCopyPermission(n).id,new f.WorksheetCopyPermission(n,t).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:h}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(w.debounceTime(200)).subscribe(e=>{var M,U;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:t,row:i,col:r}=e,s=this._renderManagerService.getRenderById(n);if(!s)return;const a=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),l=a==null?void 0:a.getSheetBySheetId(t);if(!l)return;if(!s.with(R.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING);return}const h=(M=s==null?void 0:s.with(R.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:M.skeleton,d=r,p=i;let _=p,S=d;h&&h.overflowCache.forValue((j,V,q)=>{o.Rectangle.contains(q,{startColumn:d,endColumn:d,startRow:p,endRow:p})&&(_=j,S=V)});const{viewPermission:P,editPermission:D,copyPermission:T}=this._getLinkPermission(e);if(!P){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(_,S),b=a.getStyles().getStyleByCell(c),A=(U=b==null?void 0:b.tr)==null?void 0:U.a;if(!A&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:_,col:S,editPermission:D,copyPermission:T,customRange:e.customRange,customRangeRect:e.rect,type:C.VIEWING,unitId:n,subUnitId:t,showAll:!!A})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(w.switchMap(n=>this._editorBridgeService.visible$.pipe(w.map(t=>({visible:t,state:n}))))).subscribe(({visible:n,state:t})=>{if(!t||t.editorUnitId!==o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING);return}const{editorUnitId:i,unitId:r,sheetId:s,row:a,column:l}=t,u=this._renderManagerService.getRenderById(i);if(!u)return;const{editPermission:h,viewPermission:d,copyPermission:p}=this._getLinkPermission({unitId:r,subUnitId:s,row:a,col:l}),_=u.with(J.DocEventManagerService);d&&(e==null||e.unsubscribe(),e=_.hoverCustomRanges$.pipe(w.debounceTime(200)).subscribe(S=>{var b,A;const P=S.find(M=>M.range.rangeType===o.CustomRangeType.HYPERLINK);if(!P){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const D=P.rects[P.rects.length-1];if(!((A=(b=this._renderManagerService.getRenderById(r))==null?void 0:b.with(R.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:A.skeleton)||!D)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:s,row:a,col:l,customRange:P.range,customRangeRect:{left:D.left+c.left,top:D.top+c.top,bottom:D.bottom+c.top,right:D.right+c.left},editPermission:h,copyPermission:p,type:C.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(C.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(w.switchMap(e=>{const n=e===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(J.DocEventManagerService).hoverCustomRanges$.pipe(w.debounceTime(200)):new w.Observable(t=>{t.next(null)})})).subscribe(e=>{const n=e==null?void 0:e.find(i=>i.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(n&&t){const{unitId:i,sheetId:r,row:s,column:a}=t,{editPermission:l,viewPermission:u,copyPermission:h}=this._getLinkPermission({unitId:i,subUnitId:r,row:s,col:a});u&&this._sheetsHyperLinkPopupService.showPopup({type:C.ZEN_EDITOR,unitId:i,subUnitId:r,row:s,col:a,customRange:n.range,editPermission:l,copyPermission:h})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(C.EDITING)}))}_initCommandListener(){const e=[f.ClearSelectionContentCommand.id,f.ClearSelectionAllCommand.id,f.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{e.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Me=gn([K(0,o.Inject(R.HoverManagerService)),K(1,o.Inject(g.SheetsHyperLinkPopupService)),K(2,o.Inject(de.IRenderManagerService)),K(3,o.Inject(o.IPermissionService)),K(4,o.Inject(f.SheetPermissionCheckController)),K(5,o.ICommandService),K(6,R.IEditorBridgeService),K(7,o.Inject(pe.DocSelectionManagerService)),K(8,o.IUniverInstanceService),K(9,m.IZenZoneService)],Me);var Sn=Object.getOwnPropertyDescriptor,ht=(e,n,t,i)=>{for(var r=i>1?void 0:i?Sn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Ge=(e,n)=>(t,i)=>n(t,i,e);let ze=class extends o.Disposable{constructor(e,n){super(),this._context=e,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(w.debounceTime(16)).subscribe(()=>{e()}))}};ze=ht([Ge(1,o.Inject(I.HyperLinkModel))],ze);let Ue=class extends o.Disposable{constructor(e,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Value,priority:100,handler:(e,n,t)=>{const{row:i,col:r,unitId:s,subUnitId:a}=n,l=this._hyperLinkModel.getHyperLinkByLocation(s,a,i,r);return t(l?{...e,linkUrl:l.payload,linkId:l.id}:e)}}))}};Ue=ht([Ge(0,o.Inject(f.SheetInterceptorService)),Ge(1,o.Inject(I.HyperLinkModel))],Ue);const In={[m.RibbonInsertGroup.MEDIA]:{[re.id]:{order:1,menuItemFactory:cn},[Oe(re.id)]:{order:1,menuItemFactory:ln}},[m.ContextMenuPosition.MAIN_AREA]:{[m.ContextMenuGroup.OTHERS]:{order:1,[re.id]:{order:0,menuItemFactory:sn},[Oe(re.id)]:{order:0,menuItemFactory:an}}}};var _n=Object.getOwnPropertyDescriptor,mn=(e,n,t,i)=>{for(var r=i>1?void 0:i?_n(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ge=(e,n)=>(t,i)=>n(t,i,e);let He=class extends o.Disposable{constructor(e,n,t,i,r){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._injector=i,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Re,Re.componentKey],[Ze,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[Le,ve,De,re].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(In)}_initShortCut(){this._shortcutService.registerShortcut(We)}};He=mn([ge(0,o.Inject(m.ComponentManager)),ge(1,o.ICommandService),ge(2,m.IMenuManagerService),ge(3,o.Inject(o.Injector)),ge(4,o.Inject(m.IShortcutService))],He);var fn=Object.getOwnPropertyDescriptor,yn=(e,n,t,i)=>{for(var r=i>1?void 0:i?fn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},vt=(e,n)=>(t,i)=>n(t,i,e);let xe=class extends o.Disposable{constructor(e,n){super(),this._parserService=e,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const n=this._parserService.parseHyperLink(e);this._resolverService.navigate(n)}}};xe=yn([vt(0,o.Inject(I.SheetsHyperLinkParserService)),vt(1,o.Inject(g.SheetsHyperLinkResolverService))],xe);var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(e,n,t)=>n in e?Cn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Pn=(e,n,t,i)=>{for(var r=i>1?void 0:i?En(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},gt=(e,n)=>(t,i)=>n(t,i,e),St=(e,n,t)=>Rn(e,typeof n!="symbol"?n+"":n,t);g.UniverSheetsHyperLinkUIPlugin=class extends o.Plugin{constructor(n=it,t,i){super(),this._config=n,this._injector=t,this._configService=i;const{menu:r,...s}=o.merge({},it,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(nt,s)}onStarting(){[[g.SheetsHyperLinkResolverService],[g.SheetsHyperLinkPopupService],[$e],[Ue],[Me],[He],[we],[g.SheetsHyperLinkCopyPasteController],[Ne],[xe]].forEach(t=>this._injector.add(t)),this._injector.get(Ue)}onReady(){this._injector.get(de.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ze]),this._injector.get(we),this._injector.get(g.SheetsHyperLinkCopyPasteController),this._injector.get(He)}onRendered(){this._injector.get(Ne),this._injector.get(xe),this._injector.get(Me)}},St(g.UniverSheetsHyperLinkUIPlugin,"pluginName",je),St(g.UniverSheetsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkUIPlugin=Pn([o.DependentOn(I.UniverSheetsHyperLinkPlugin,J.UniverDocsUIPlugin),gt(1,o.Inject(o.Injector)),gt(2,o.IConfigService)],g.UniverSheetsHyperLinkUIPlugin),g.CloseHyperLinkPopupOperation=ve,g.InsertHyperLinkOperation=De,g.InsertLinkShortcut=We,g.OpenHyperLinkEditPanelOperation=Le,g.SheetsHyperLinkSidePanelService=$e,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(g,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react/jsx-runtime"),require("@univerjs/sheets-formula-ui"),require("react"),require("@univerjs/sheets-data-validation")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react/jsx-runtime","@univerjs/sheets-formula-ui","react","@univerjs/sheets-data-validation"],o):(g=typeof globalThis<"u"?globalThis:g||self,o(g.UniverSheetsHyperLinkUi={},g.UniverCore,g.UniverSheets,g.UniverSheetsHyperLink,g.UniverSheetsUi,g.UniverDesign,g.UniverEngineFormula,g.UniverUi,g.UniverDocsUi,g.UniverEngineRender,g.rxjs,g.UniverDocs,g.React,g.UniverSheetsFormulaUi,g.React,g.UniverSheetsDataValidation))})(this,function(g,o,f,I,R,L,z,m,J,de,w,pe,y,Mt,E,tt){"use strict";var wn=Object.defineProperty;var Nn=(g,o,f)=>o in g?wn(g,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):g[o]=f;var F=(g,o,f)=>Nn(g,typeof o!="symbol"?o+"":o,f);function Ce(e){return o.Tools.isLegalUrl(e)}function Ut(e){return/^[a-zA-Z]+:\/\//.test(e)}function Ht(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function xt(e){if(Ce(e)){const n=Ut(e)?e:Ht(e)?`mailto://${e}`:`http://${e}`;let t;try{t=new URL(n)}catch{return e}return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:n}return e}const nt="sheets-hyper-link-ui.config",it={};var At=Object.getOwnPropertyDescriptor,Bt=(e,n,t,i)=>{for(var r=i>1?void 0:i?At(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ae=(e,n)=>(t,i)=>n(t,i,e);function Vt(e,n){const t=n.getMergeData(),i=n.getMaxColumns()-1,r=n.getMaxRows()-1;if(i<e.endColumn&&(e.endColumn=i),r<e.endRow&&(e.endRow=r),e.rangeType===o.RANGE_TYPE.COLUMN||o.RANGE_TYPE.ROW)return e;const s=[];return t.forEach(a=>{o.Rectangle.intersects(e,a)&&s.push(a)}),o.Rectangle.realUnion(e,...s)}g.SheetsHyperLinkResolverService=class{constructor(n,t,i,r,s,a){this._univerInstanceService=n,this._commandService=t,this._definedNamesService=i,this._messageService=r,this._localeService=s,this._configService=a}navigate(n){switch(n.type){case I.SheetHyperLinkType.URL:this.navigateToOtherWebsite(n.url);break;default:this._navigateToUniver(n.searchObj)}}_navigateToUniver(n){const{gid:t,range:i,rangeid:r}=n,s=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const a=s.getUnitId();if(r){const l=this._definedNamesService.getValueById(a,r);if(!l)return;const{formulaOrRefString:u}=l,h=this._definedNamesService.getWorksheetByRef(a,u);if(!h){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:L.MessageType.Error});return}if(h.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:L.MessageType.Error});return}this.navigateToDefineName(a,r)}if(t){if(i){const l=z.deserializeRangeWithSheet(i);o.isValidRange(l.range)&&i!==I.ERROR_RANGE&&this.navigateToRange(a,t,l.range);return}this.navigateToSheetById(a,t)}}async navigateToRange(n,t,i,r){const s=await this.navigateToSheetById(n,t);if(s){const a=Vt(i,s);await this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:n,subUnitId:t,selections:[{range:a,primary:null}]}),await this._commandService.executeCommand(R.ScrollToRangeOperation.id,{range:a,forceTop:r})}}async navigateToSheetById(n,t){const i=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;const r=i.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const s=i.getSheetBySheetId(t);return s?i.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:L.MessageType.Error}),!1):await this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:t})?s:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:L.MessageType.Error}),!1)}async navigateToDefineName(n,t){return this._definedNamesService.focusRange(n,t),!0}async navigateToOtherWebsite(n){var i;const t=this._configService.getConfig(nt);if((i=t==null?void 0:t.urlHandler)!=null&&i.navigateToOtherWebsite)return t.urlHandler.navigateToOtherWebsite(n);window.open(n,"_blank","noopener noreferrer")}},g.SheetsHyperLinkResolverService=Bt([ae(0,o.IUniverInstanceService),ae(1,o.ICommandService),ae(2,z.IDefinedNamesService),ae(3,m.IMessageService),ae(4,o.Inject(o.LocaleService)),ae(5,o.IConfigService)],g.SheetsHyperLinkResolverService);const je="SHEET_HYPER_LINK_UI_PLUGIN";var jt=Object.getOwnPropertyDescriptor,$t=(e,n,t,i)=>{for(var r=i>1?void 0:i?jt(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Ee=(e,n)=>(t,i)=>n(t,i,e);g.SheetsHyperLinkCopyPasteController=class extends o.Disposable{constructor(t,i,r,s){super();F(this,"_plainTextFilter",new Set);F(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=i,this._injector=r,this._resolverService=s,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(t){this._plainTextFilter.add(t)}removePlainTextFilter(t){this._plainTextFilter.delete(t)}_filterPlainText(t){return Array.from(this._plainTextFilter).every(i=>i(t))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:je,onBeforeCopy:(t,i,r)=>this._collect(t,i,r),onPasteCells:(t,i,r,s)=>{const{copyType:a=R.COPY_TYPE.COPY,pasteType:l}=s,{range:u}=t||{},{range:h,unitId:d,subUnitId:p}=i;return this._generateMutations(h,{copyType:a,pasteType:l,copyRange:u,unitId:d,subUnitId:p})},onPastePlainText:(t,i)=>{const r=this._filterPlainText(i);if(Ce(i)&&r){const{range:s,unitId:a,subUnitId:l}=t,{ranges:[u],mapFunc:h}=R.virtualizeDiscreteRanges([s]),d=[],p=[];return o.Range.foreach(u,(_,S)=>{const{row:P,col:D}=h(_,S),T=this._hyperLinkModel.getHyperLinkByLocation(a,l,P,D);T&&d.push({id:I.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:l,id:T.id}}),T&&p.push({id:I.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:l,link:T}})}),{redos:d,undos:p}}return{undos:[],redos:[]}},priority:99})}_collect(t,i,r){const s=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:i,matrix:s};const a=this._injector.invoke(h=>f.rangeToDiscreteRange(r,h,t,i));if(!a)return;const{rows:l,cols:u}=a;l.forEach((h,d)=>{u.forEach((p,_)=>{var P;const S=this._hyperLinkModel.getHyperLinkByLocation(t,i,h,p);s.setValue(d,_,(P=S==null?void 0:S.id)!=null?P:"")})})}_generateMutations(t,i){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!i.copyRange)return{redos:[],undos:[]};if([R.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,R.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,R.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,R.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(i.pasteType))return{redos:[],undos:[]};const{unitId:s,subUnitId:a}=this._copyInfo,l=[],u=[],{ranges:[h,d],mapFunc:p}=R.virtualizeDiscreteRanges([i.copyRange,t]);return R.getRepeatRange(h,d,!0).forEach(({startRange:S})=>{var P;(P=this._copyInfo)==null||P.matrix.forValue((D,T,c)=>{const b=o.Rectangle.getPositionRange({startRow:D,endRow:D,startColumn:T,endColumn:T},S),A=this._hyperLinkModel.getHyperLink(s,a,c),{row:M,col:U}=p(b.startRow,b.startColumn),j=this._hyperLinkModel.getHyperLinkByLocation(i.unitId,i.subUnitId,M,U),V=o.Tools.generateRandomId();j&&l.push({id:I.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:j.id}}),A&&(l.push({id:I.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:{...A,id:V,row:M,column:U}}}),u.push({id:I.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:V}})),j&&u.push({id:I.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:j}})})}),{redos:l,undos:u}}},g.SheetsHyperLinkCopyPasteController=$t([Ee(0,R.ISheetClipboardService),Ee(1,o.Inject(I.HyperLinkModel)),Ee(2,o.Inject(o.Injector)),Ee(3,o.Inject(g.SheetsHyperLinkResolverService))],g.SheetsHyperLinkCopyPasteController);var C=(e=>(e.EDITING="editing",e.VIEWING="viewing",e.ZEN_EDITOR="zen_mode",e))(C||{});class $e extends o.Disposable{constructor(){super(...arguments);F(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==I.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(r=>r.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:i}=this;i.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const Re=()=>{var mt;const[e,n]=E.useState(""),[t,i]=E.useState(!1),[r,s]=E.useState(""),[a,l]=E.useState(!0),[u,h]=E.useState(I.SheetHyperLinkType.URL),[d,p]=E.useState(""),_=m.useDependency(o.LocaleService),S=m.useDependency(z.IDefinedNamesService),P=m.useDependency(R.IEditorBridgeService),D=m.useDependency(o.IUniverInstanceService),T=m.useDependency(g.SheetsHyperLinkPopupService),c=m.useObservable(T.currentEditing$),b=m.useDependency(I.SheetsHyperLinkParserService),A=m.useDependency(g.SheetsHyperLinkResolverService),M=m.useDependency(o.ICommandService),U=m.useDependency($e),j=E.useMemo(()=>U.getOptions(),[U]),V=m.useDependency(m.IZenZoneService),q=m.useDependency(de.IRenderManagerService),Se=m.useDependency(R.IMarkSelectionService),Ae=m.useDependency(pe.DocSelectionManagerService),oe=m.useDependency(o.IContextService),Ie=m.useDependency(o.ThemeService),_e=m.useDependency(pe.DocSelectionManagerService),[me,Be]=E.useState(!1),ce=m.useDependency(f.SheetsSelectionsService),Tn=E.useMemo(()=>ce.getCurrentSelections(),[]),Ve=E.useMemo(()=>{if(!U.isBuiltInLinkType(u))return U.getCustomHyperLink(u)},[U,u]),[le,Ln]=E.useState(!1),[fe,It]=E.useState(!1),$=E.useRef(!1),W=D.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),Dn=(W==null?void 0:W.getActiveSheet().getSheetId())||"",Q=E.useCallback(v=>{s(v.replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[s]);E.useEffect(()=>{var v,O,k,N,x,Y,ft,yt,Ct,Et,Rt,Pt,Tt,Lt,Dt,bt,Ot;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:se,row:Qe,col:et}=c;let{label:X}=c;typeof X=="number"&&(X=`${X}`);let G;if(se)G={id:(v=se==null?void 0:se.rangeId)!=null?v:"",display:X!=null?X:"",payload:(k=(O=se==null?void 0:se.properties)==null?void 0:O.url)!=null?k:"",row:Qe,column:et};else if(c.type===C.VIEWING){const H=D.getUnit(c.unitId),te=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=te==null?void 0:te.getCellRaw(c.row,c.col),ue=(Y=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:Y.find(wt=>{var Nt;return wt.rangeType===o.CustomRangeType.HYPERLINK&&((Nt=wt.properties)==null?void 0:Nt.url)}),ye=B==null?void 0:B.v;B&&(!o.BuildTextUtils.transform.isEmptyDocument((yt=(ft=B.p)==null?void 0:ft.body)==null?void 0:yt.dataStream)||o.Tools.isDefine(ye))&&l(!1),G={id:"",display:"",payload:(Et=(Ct=ue==null?void 0:ue.properties)==null?void 0:Ct.url)!=null?Et:"",row:Qe,column:et}}else{const H=D.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),te=Ae.getActiveTextRange(),B=H==null?void 0:H.getBody(),ue=te&&B?te:null,ye=ue&&((Pt=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(ue,(Rt=B==null?void 0:B.customRanges)!=null?Rt:[]))==null?void 0:Pt[0]);l(!1),G={id:"",display:X!=null?X:"",payload:(Lt=(Tt=ye==null?void 0:ye.properties)==null?void 0:Tt.url)!=null?Lt:"",row:Qe,column:et}}n(G.id);const kt=U.findCustomHyperLink(G);if(kt){const H=kt.convert(G);h(H.type),p(H.payload),Q(H.display);return}Q(G.display);const ee=b.parseHyperLink(G.payload);switch(h(ee.type===I.SheetHyperLinkType.INVALID?I.SheetHyperLinkType.RANGE:ee.type),ee.type){case I.SheetHyperLinkType.URL:{p(ee.url),ee.url===G.display&&($.current=!0);break}case I.SheetHyperLinkType.RANGE:{const H=ee.searchObj,te=H.gid&&(Ot=(bt=(Dt=D.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:bt.getName())!=null?Ot:"",B=z.serializeRangeWithSheet(te,z.deserializeRangeWithSheet(H.range).range);p(B),B===G.display&&($.current=!0);break}case I.SheetHyperLinkType.SHEET:{const H=ee.searchObj;p(H.gid);break}case I.SheetHyperLinkType.DEFINE_NAME:{const H=ee.searchObj;p(H.rangeid);break}default:p("");break}}},[c,A,U,Ae,D]),E.useEffect(()=>{let v=null;if(c&&!c.customRangeId&&c.type===C.VIEWING&&o.Tools.isDefine(c.row)&&o.Tools.isDefine(c.col)){const O=D.getUnit(c.unitId,o.UniverInstanceType.UNIVER_SHEET),k=O==null?void 0:O.getSheetBySheetId(c.subUnitId),N=k==null?void 0:k.getMergedCell(c.row,c.col),x=new o.ColorKit(Ie.getColorFromTheme("primary.600")).toRgb();v=Se.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{v&&Se.removeShape(v)}},[c,Se,Ie,D]),E.useEffect(()=>{It(u===I.SheetHyperLinkType.RANGE)},[u]),E.useEffect(()=>{const v=(c==null?void 0:c.type)===C.ZEN_EDITOR?q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY):q.getRenderById(P.getCurrentEditorId()),O=new o.DisposableCollection;if(v){const k=v.with(J.DocSelectionRenderService);k.setReserveRangesStatus(!0),O.add(()=>{k.setReserveRangesStatus(!1)})}return()=>{P.disableForceKeepVisible(),O.dispose()}},[c==null?void 0:c.type,P,q]),E.useEffect(()=>(fe&&T.setIsKeepVisible(fe),T.setIsKeepVisible(me),()=>{T.setIsKeepVisible(!1)}),[fe,me,T]),E.useEffect(()=>()=>{V.temporaryHidden&&(V.show(),oe.setContextValue(o.FOCUSING_SHEET,!1))},[oe,V]),E.useEffect(()=>{if(fe)return P.enableForceKeepVisible(),()=>{P.disableForceKeepVisible()}},[fe,P]);const bn=[{label:_.t("hyperLink.form.link"),value:I.SheetHyperLinkType.URL},{label:_.t("hyperLink.form.range"),value:I.SheetHyperLinkType.RANGE},{label:_.t("hyperLink.form.worksheet"),value:I.SheetHyperLinkType.SHEET},{label:_.t("hyperLink.form.definedName"),value:I.SheetHyperLinkType.DEFINE_NAME},...j];if(!W)return;const On=W.getHiddenWorksheets(),qe=W.getSheets().map(v=>({label:v.getName(),value:v.getSheetId()})).filter(v=>On.indexOf(v.value)===-1),Xe=Object.values((mt=S.getDefinedNameMap(W.getUnitId()))!=null?mt:{}).map(v=>({label:v.name,value:v.id})),_t=(v,O)=>{if(v===I.SheetHyperLinkType.URL)return xt(O);if(v===I.SheetHyperLinkType.RANGE){const k=z.deserializeRangeWithSheet(O),N=W.getSheetBySheetName(k.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${z.serializeRange(k.range)}`}return`#${v}=${O}`},kn=m.useEvent(v=>{var x;const k=v.split(",").map(z.deserializeRangeWithSheet)[0];if(!k||!o.isValidRange(k.range))return;k.sheetName||(k.sheetName=((x=W.getActiveSheet())==null?void 0:x.getName())||"");const N=z.serializeRangeToRefString(k);p(N),N&&($.current||!r)&&(Q(N),$.current=!0)}),Je=async()=>{if(a&&!r||!d||u===I.SheetHyperLinkType.URL&&!Ce(d)){Ln(!0);return}if(c)if(e){const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?I.UpdateRichHyperLinkCommand.id:I.UpdateHyperLinkCommand.id;await M.executeCommand(v,{id:e,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:a?r:"",payload:_t(u,d)},row:c.row,column:c.col,documentId:c.type===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:P.getCurrentEditorId()})}else{const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?I.AddRichHyperLinkCommand.id:I.AddHyperLinkCommand.id;await M.executeCommand(v,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:o.generateRandomId(),row:c.row,column:c.col,payload:_t(u,d),display:a?r:""},documentId:c.type===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:P.getCurrentEditorId()})}if((c==null?void 0:c.type)===C.VIEWING){await M.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const v=1;await M.executeCommand(R.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-v,0),endRow:c.row+v,startColumn:Math.max(c.col-v,0),endColumn:c.col+v}})}M.executeCommand(ve.id)};return c?y.jsxs("div",{className:L.clsx("univer-box-border univer-w-[296px] univer-rounded-xl univer-bg-white univer-p-4 univer-shadow-md dark:!univer-bg-gray-900",L.borderClassName),children:[a?y.jsx(L.FormLayout,{label:_.t("hyperLink.form.label"),error:le&&!r?_.t("hyperLink.form.inputError"):"",children:y.jsx(L.Input,{value:r,onChange:v=>{Q(v),$.current=!1},placeholder:_.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Je()}})}):null,y.jsx(L.FormLayout,{label:_.t("hyperLink.form.type"),children:y.jsx(L.Select,{className:"univer-w-full",options:bn,value:u,onChange:v=>{h(v),p("")}})}),u===I.SheetHyperLinkType.URL&&y.jsx(L.FormLayout,{error:le?d?Ce(d)?"":_.t("hyperLink.form.linkError"):_.t("hyperLink.form.inputError"):"",children:y.jsx(L.Input,{value:d,onChange:v=>{p(v),v&&($.current||!r||r===v)&&(Q(v),$.current=!0)},placeholder:_.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Je()}})}),u===I.SheetHyperLinkType.RANGE&&y.jsx(L.FormLayout,{error:le&&!d?_.t("hyperLink.form.inputError"):"",children:y.jsx(Mt.RangeSelector,{unitId:W.getUnitId(),subUnitId:Dn,maxRangeCount:1,supportAcrossSheet:!0,initialValue:d,resetRange:Tn,onChange:(v,O)=>kn(O),onRangeSelectorDialogVisibleChange:async v=>{var O,k;if(Be(v),v)c.type===C.ZEN_EDITOR&&(V.hide(),oe.setContextValue(o.FOCUSING_SHEET,!0)),c.type!==C.VIEWING&&P.enableForceKeepVisible(),i(!0);else{if(await A.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===C.ZEN_EDITOR){await M.executeCommand(f.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),V.show(),oe.setContextValue(o.FOCUSING_SHEET,!1);const N=(O=q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:O.with(J.DocBackScrollRenderController),x=(k=_e.getTextRanges({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:k[0];N&&x&&(N.scrollToRange(x),_e.refreshSelection({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}P.disableForceKeepVisible(),i(!1)}},onFocusChange:v=>It(v)})}),u===I.SheetHyperLinkType.SHEET&&y.jsx(L.FormLayout,{error:le&&!d?_.t("hyperLink.form.selectError"):"",children:y.jsx(L.Select,{className:"univer-w-full",options:qe,value:d,onChange:v=>{var N,x;p(v);const O=(N=qe.find(Y=>Y.value===v))==null?void 0:N.label,k=(x=qe.find(Y=>Y.value===d))==null?void 0:x.label;O&&($.current||!r||r===k)&&(Q(O),$.current=!0)}})}),u===I.SheetHyperLinkType.DEFINE_NAME&&y.jsx(L.FormLayout,{error:le&&!d?_.t("hyperLink.form.selectError"):"",children:y.jsx(L.Select,{className:"univer-w-full",options:Xe,value:d,onChange:v=>{var N,x;p(v);const O=(N=Xe.find(Y=>Y.value===v))==null?void 0:N.label,k=(x=Xe.find(Y=>Y.value===d))==null?void 0:x.label;O&&($.current||!r||r===k)&&(Q(O),$.current=!0)}})}),(Ve==null?void 0:Ve.Form)&&y.jsx(Ve.Form,{linkId:e,payload:d,display:r,showError:le,setByPayload:$,setDisplay:v=>{Q(v),$.current=!0},setPayload:p}),y.jsxs("div",{className:"univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[y.jsx(L.Button,{onClick:()=>{c&&A.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),M.executeCommand(ve.id)},children:_.t("hyperLink.form.cancel")}),y.jsx(L.Button,{variant:"primary",onClick:async()=>{Je()},children:_.t("hyperLink.form.ok")})]})]}):null};Re.componentKey="univer.sheet.cell-link-edit";var Z=function(){return Z=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Z.apply(this,arguments)},Zt=function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)n.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(t[i[r]]=e[i[r]]);return t},ne=E.forwardRef(function(e,n){var t=e.icon,i=e.id,r=e.className,s=e.extend,a=Zt(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),u=E.useRef("_".concat(Wt()));return rt(t,"".concat(i),{defIds:t.defIds,idSuffix:u.current},Z({ref:n,className:l},a),s)});function rt(e,n,t,i,r){return E.createElement(e.tag,Z(Z({key:n},Ft(e,t,r)),i),(Kt(e,t).children||[]).map(function(s,a){return rt(s,"".concat(n,"-").concat(e.tag,"-").concat(a),t,void 0,r)}))}function Ft(e,n,t){var i=Z({},e.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1),e.tag==="mask"&&i.id&&(i.id=i.id+n.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],l=s[1];a==="mask"&&typeof l=="string"&&(i[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var r=n.defIds;return!r||r.length===0||(e.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(i[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),i}function Kt(e,n){var t,i=n.defIds;return!i||i.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?Z(Z({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?Z(Z({},r),{attrs:Z(Z({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):e}function Wt(){return Math.random().toString(36).substring(2,8)}ne.displayName="UniverIcon";var Yt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Pe=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"all-border-single",ref:n,icon:Yt}))});Pe.displayName="AllBorderSingle";var Gt={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"}}]},ot=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"copy-single",ref:n,icon:Gt}))});ot.displayName="CopySingle";var zt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},Ze=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"link-single",ref:n,icon:zt}))});Ze.displayName="LinkSingle";var qt={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"}}]},st=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"unlink-single",ref:n,icon:qt}))});st.displayName="UnlinkSingle";var Xt={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"}}]},at=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"write-single",ref:n,icon:Xt}))});at.displayName="WriteSingle";var Jt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.4538 1.12549C2.70051 1.12549 2.08984 1.73615 2.08984 2.48945V13.5104C2.08984 14.2637 2.70051 14.8744 3.4538 14.8744H12.5468C13.3001 14.8744 13.9108 14.2637 13.9108 13.5104V5.0992L10.0094 1.12549H3.4538Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M10.0078 1.12549L13.9107 5.09842H10.6745C10.3063 5.09842 10.0078 4.79994 10.0078 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.80941 10.2949L6.37701 12.403C6.2632 12.5705 6.03516 12.614 5.86766 12.5002C5.70017 12.3864 5.65664 12.1584 5.77045 11.9909L7.36611 9.64252L5.94103 7.54519C5.82722 7.37769 5.87074 7.14964 6.03824 7.03583C6.20573 6.92202 6.43378 6.96555 6.54759 7.13304L7.80941 8.9901L9.07123 7.13304C9.18504 6.96555 9.41309 6.92202 9.58059 7.03583C9.74808 7.14964 9.7916 7.37769 9.67779 7.54519L8.25271 9.64252L9.84837 11.9909C9.96218 12.1584 9.91866 12.3864 9.75116 12.5002C9.58366 12.614 9.35562 12.5705 9.24181 12.403L7.80941 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ct=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"xlsx",ref:n,icon:Jt}))});ct.displayName="Xlsx";const Qt={[I.SheetHyperLinkType.URL]:y.jsx(Ze,{}),[I.SheetHyperLinkType.SHEET]:y.jsx(ct,{}),[I.SheetHyperLinkType.RANGE]:y.jsx(Pe,{}),[I.SheetHyperLinkType.DEFINE_NAME]:y.jsx(Pe,{}),[I.SheetHyperLinkType.INVALID]:y.jsx(Pe,{})},lt=e=>{var A,M;const n=m.useDependency(g.SheetsHyperLinkPopupService),t=m.useDependency(o.ICommandService),i=m.useDependency(m.IMessageService),r=m.useDependency(o.LocaleService),s=m.useDependency(g.SheetsHyperLinkResolverService),a=m.useDependency(R.IEditorBridgeService),l=m.useDependency(I.SheetsHyperLinkParserService),u=m.useDependency(m.IZenZoneService),{customRange:h,row:d,col:p,unitId:_,subUnitId:S,editPermission:P,copyPermission:D,type:T}=e;if(!((A=h==null?void 0:h.properties)!=null&&A.url))return null;const c=l.parseHyperLink((M=h.properties.url)!=null?M:""),b=c.type===I.SheetHyperLinkType.INVALID;return y.jsxs("div",{className:L.clsx("univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow-md dark:!univer-bg-gray-900",L.borderClassName),onClick:()=>n.hideCurrentPopup(),children:[y.jsxs("div",{className:L.clsx("univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600",{"univer-text-red-500":b}),onClick:()=>{u.visible||b||s.navigate(c)},children:[y.jsx("div",{className:"univer-mr-2 univer-flex univer-h-5 univer-w-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white",children:Qt[c.type]}),y.jsx(L.Tooltip,{showIfEllipsis:!0,title:c.name,asChild:!0,children:y.jsx("span",{className:"univer-flex-1 univer-overflow-hidden univer-text-ellipsis",children:c.name})})]}),y.jsxs("div",{className:"univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center",children:[D&&y.jsx("div",{className:L.clsx("univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-text-red-500":b}),onClick:()=>{if(!b){if(c.type!==I.SheetHyperLinkType.URL){const U=new URL(window.location.href);U.hash=c.url.slice(1),navigator.clipboard.writeText(U.href)}else navigator.clipboard.writeText(c.url);i.show({content:r.t("hyperLink.message.coped"),type:L.MessageType.Info})}},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:y.jsx(ot,{className:"dark:!univer-text-white"})})}),P&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",onClick:()=>{t.executeCommand(Le.id,{unitId:_,subUnitId:S,row:d,col:p,customRangeId:h.rangeId,type:T})},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:y.jsx(at,{className:"dark:!univer-text-white"})})}),y.jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",onClick:()=>{const U=T===C.EDITING||T===C.ZEN_EDITOR?I.CancelRichHyperLinkCommand.id:I.CancelHyperLinkCommand.id;t.syncExecuteCommand(U,{unitId:_,subUnitId:S,id:h.rangeId,row:d,column:p,documentId:T===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:a.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:y.jsx(st,{className:"dark:!univer-text-white"})})})]})]})]})},Te=()=>{var r,s;const e=m.useDependency(g.SheetsHyperLinkPopupService),[n,t]=E.useState(null),i=m.useDependency(o.IUniverInstanceService);if(E.useEffect(()=>{t(e.currentPopup);const a=e.currentPopup$.subscribe(l=>{t(l)});return()=>{a.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){const a=i.getUnit(n.unitId,o.UniverInstanceType.UNIVER_SHEET),l=a==null?void 0:a.getSheetBySheetId(n.subUnitId),u=l==null?void 0:l.getCell(n.row,n.col),h=(s=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:s.customRanges;return h!=null&&h.length?y.jsx("div",{children:h.map(d=>y.jsx(lt,{...n,customRange:d},d.rangeId))}):null}return y.jsx(lt,{...n})};Te.componentKey="univer.sheet.cell-link-popup";var en=Object.getOwnPropertyDescriptor,tn=(e,n,t,i)=>{for(var r=i>1?void 0:i?en(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ie=(e,n)=>(t,i)=>n(t,i,e);const ut=(e,n)=>{var t,i;return e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.row===n.row&&e.col===n.col&&((t=e.customRange)==null?void 0:t.rangeId)===((i=n.customRange)==null?void 0:i.rangeId)&&e.type===n.type};g.SheetsHyperLinkPopupService=class extends o.Disposable{constructor(t,i,r,s,a,l,u){super();F(this,"_currentPopup",null);F(this,"_currentPopup$",new w.Subject);F(this,"currentPopup$",this._currentPopup$.asObservable());F(this,"_currentEditingPopup",null);F(this,"_currentEditing$",new w.BehaviorSubject(null));F(this,"currentEditing$",this._currentEditing$.asObservable());F(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=i,this._univerInstanceService=r,this._editorBridgeService=s,this._textSelectionManagerService=a,this._docCanvasPopManagerService=l,this._zenZoneService=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(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){if(this._currentPopup&&ut(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==C.ZEN_EDITOR&&this._zenZoneService.visible))return;const i=this._currentEditing$.getValue();if(i&&ut(t,i))return;const{unitId:r,subUnitId:s,row:a,col:l,customRangeRect:u,customRange:h}=t;let d;const p={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===C.EDITING){if(!h)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,p)}else if(t.type===C.ZEN_EDITOR){if(!h)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:h.startIndex,endOffset:h.endIndex+1,collapsed:!1},p,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,p,r,s);else{if(!h)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,p,t)}d&&(this._currentPopup={unitId:r,subUnitId:s,disposable:d,row:a,col:l,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:h,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,i){var r,s;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||i)&&((s=(r=this._currentPopup)==null?void 0:r.disposable)==null||s.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,s,a;const t=this._editorBridgeService.isVisible().visible,i=this._editorBridgeService.getEditCellState();if(t&&i){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=i.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:o.BuildTextUtils.transform.getPlainText(u.dataStream)};const h=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(a=(s=u.customRanges)==null?void 0:s.filter(_=>_.rangeType===o.CustomRangeType.HYPERLINK))!=null?a:[]);let d=l.startOffset,p=l.endOffset;return h.forEach(_=>{d=Math.min(d,_.startIndex),p=Math.max(p,_.endIndex+1)}),{startOffset:d,endOffset:p,collapsed:d===p,label:o.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,p))}}return null}get _editPopup(){return{componentKey:Re.componentKey,direction:"vertical",onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var a,l,u,h,d;const{unitId:i,subUnitId:r,type:s}=t;if(s===C.ZEN_EDITOR){const p=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(!p)return;const _=this._textSelectionManagerService.getActiveTextRange();if(!_)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(_,this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const S=(a=p.getBody())==null?void 0:a.dataStream.slice(_.startOffset,_.endOffset);this._currentEditing$.next({...t,label:S})}else if(s===C.EDITING){const p=this._getEditingRange();if(!p)return;this._textSelectionManagerService.replaceDocRanges([{...p}],{unitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const _=this._injector.get(de.IRenderManagerService).getRenderById(o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!_)return;const S=J.calcDocRangePositions(p,_);if(!(S!=null&&S.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.pop(),this._editPopup,i,r),this._currentEditing$.next({...t,label:(l=p==null?void 0:p.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r);const p=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),_=p==null?void 0:p.getSheetBySheetId(r),S=_==null?void 0:_.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:S!=null&&S.p?o.BuildTextUtils.transform.getPlainText((h=(u=S.p.body)==null?void 0:u.dataStream)!=null?h:""):((d=S==null?void 0:S.v)!=null?d:"").toString()})}}startEditing(t){var l,u,h,d,p,_;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:i,subUnitId:r}=t;let s,a;if(t.type===C.ZEN_EDITOR){const S=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(s=(h=(u=S==null?void 0:S.getBody())==null?void 0:u.customRanges)==null?void 0:h.find(P=>P.rangeId===t.customRangeId),a=s?(d=S==null?void 0:S.getBody())==null?void 0:d.dataStream.slice(s.startIndex,s.endIndex+1):"",!s||!a)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:s.startIndex,endOffset:s.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:s.startIndex,endOffset:s.endIndex,collapsed:!1},this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===C.EDITING){const S=R.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!S||!((p=S.rects)!=null&&p.length))return;s=S.customRange,a=S.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:s.startIndex,endOffset:s.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.rects.pop(),this._editPopup,i,r)}else{const S=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),P=S==null?void 0:S.getSheetBySheetId(r),D=P==null?void 0:P.getCellRaw(t.row,t.col),T=S==null?void 0:S.getStyles().getStyleByCell(D),c=T==null?void 0:T.tr,b=R.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!b||!((_=b.rects)!=null&&_.length))return;s=b.customRange,a=b.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(b.rects.pop(),this._editPopup,{unitId:i,subUnitId:r,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:s,label:a})}endEditing(t){var r;if(this.getIsKeepVisible())return;const i=this._currentEditing$.getValue();i&&(!t||t===i.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},g.SheetsHyperLinkPopupService=tn([ie(0,o.Inject(R.SheetCanvasPopManagerService)),ie(1,o.Inject(o.Injector)),ie(2,o.IUniverInstanceService),ie(3,R.IEditorBridgeService),ie(4,o.Inject(pe.DocSelectionManagerService)),ie(5,o.Inject(J.DocCanvasPopManagerService)),ie(6,m.IZenZoneService)],g.SheetsHyperLinkPopupService);var he=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(he||{});const nn=new Set([o.DataValidationType.CHECKBOX,o.DataValidationType.LIST,o.DataValidationType.LIST_MULTIPLE]),Fe=(e,n,t,i)=>{var l,u,h,d,p;const r=n.getCell(t,i);if(r!=null&&r.f||r!=null&&r.si||(h=(u=(l=r==null?void 0:r.p)==null?void 0:l.body)==null?void 0:u.customBlocks)!=null&&h.length)return 1;const s=e.has(tt.SheetDataValidationModel)?e.get(tt.SheetDataValidationModel):null,a=s==null?void 0:s.getRuleByLocation(n.getUnitId(),n.getSheetId(),t,i);return a&&nn.has(a.type)?!0:(p=(d=r==null?void 0:r.p)==null?void 0:d.drawingsOrder)!=null&&p.length?2:0},rn=e=>{const n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const t=n.getActiveSheet(),i=e.get(f.SheetsSelectionsService).getCurrentSelections();if(!i.length)return!0;const r=i[0].range.startRow,s=i[0].range.startColumn;return Fe(e,t,r,s)===1},on=e=>{const n=e.get(pe.DocSelectionManagerService),t=e.get(o.IUniverInstanceService),i=n.getTextRanges();if(!(i!=null&&i.length))return!0;const r=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);return!!(!r||i.every(a=>a.collapsed)||!r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody())},Le={type:o.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,n){if(!n)return!1;const t=e.get(g.SheetsHyperLinkPopupService);return n.customRangeId?t.startEditing(n):t.startAddEditing(n),!0}},ve={type:o.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(g.SheetsHyperLinkPopupService).endEditing(),!0}},De={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var p;const n=e.get(o.IUniverInstanceService),t=f.getSheetCommandTarget(n),i=e.get(R.IEditorBridgeService);if(!t)return!1;const r=e.get(o.ICommandService),a=e.get(f.SheetsSelectionsService).getCurrentLastSelection();if(!a)return!1;const l=a.range.startRow,u=a.range.startColumn,h=i.isVisible(),d=((p=n.getFocusedUnit())==null?void 0:p.getUnitId())===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Le.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:l,col:u,type:d?C.ZEN_EDITOR:h.visible?C.EDITING:C.VIEWING})}},re={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(rn(e))return!1;const n=e.get(o.ICommandService);return e.get(g.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(ve.id):n.executeCommand(De.id)}},Ke=(e,n=o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const t=e.get(o.IUniverInstanceService),i=(r=e.get(de.IRenderManagerService).getRenderById(n))==null?void 0:r.with(J.DocSelectionRenderService);return i?i.textSelectionInner$.pipe(w.map(()=>{const a=e.get(R.IEditorBridgeService).getEditCellState();if(!a)return!0;const l=f.getSheetCommandTarget(t,{unitId:a.unitId,subUnitId:a.sheetId});return!(l!=null&&l.worksheet)||Fe(e,l.worksheet,a.row,a.column)===1?!0:on(e)})):w.of(!0)},dt=e=>{var r;const n=e.get(o.IUniverInstanceService),t=e.has(R.IEditorBridgeService)?e.get(R.IEditorBridgeService):null;return((r=t==null?void 0:t.currentEditCellState$.pipe(w.map(s=>{if(!s)return he.DISABLED_BY_CELL;const a=f.getSheetCommandTarget(n,{unitId:s.unitId,subUnitId:s.sheetId});return a?Fe(e,a.worksheet,s.row,s.column):he.DISABLED_BY_CELL}),w.switchMap(s=>{if(s===he.DISABLED_BY_CELL)return w.of(!0);const a=t?t.visible$:w.of(null);return w.combineLatest([a,n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC)]).pipe(w.switchMap(([l,u])=>l!=null&&l.visible?(u==null?void 0:u.getUnitId())===o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?w.of(!0):Ke(e,o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):w.of(s!==he.ALLOWED)))})))!=null?r:w.of(!0)).pipe(w.switchMap(s=>s?w.of(!0):R.getCurrentRangeDisable$(e,{workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},!0)))},be={commandId:De.id,type:m.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},Oe=e=>`${e}-zen-editor`,sn=e=>({...be,id:be.commandId,hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:dt(e)}),an=e=>({...be,id:Oe(be.commandId),hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(e)}),ke={tooltip:"hyperLink.form.addTitle",commandId:re.id,type:m.MenuItemType.BUTTON,icon:"LinkSingle"},cn=e=>({...ke,id:ke.commandId,hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:dt(e)}),ln=e=>({...ke,id:Oe(ke.commandId),hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(e)}),We={id:re.id,binding:m.KeyCode.K|m.MetaKeys.CTRL_COMMAND,preconditions:R.whenSheetEditorFocused};var un=Object.getOwnPropertyDescriptor,dn=(e,n,t,i)=>{for(var r=i>1?void 0:i?un(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},pt=(e,n)=>(t,i)=>n(t,i,e);let we=class extends o.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(i,r)=>{const{source:s,target:a,unitId:l,subUnitId:u}=i,h=R.virtualizeDiscreteRanges([s,a]),[d,p]=h.ranges,{mapFunc:_}=h,S={row:d.startRow,col:d.startColumn},P=R.getAutoFillRepeatRange(d,p),D=[],T=[];return P.forEach(c=>{const b=c.repeatStartCell,A=c.relativeRange,M={startRow:S.row,startColumn:S.col,endColumn:S.col,endRow:S.row},U={startRow:b.row,startColumn:b.col,endColumn:b.col,endRow:b.row};o.Range.foreach(A,(j,V)=>{const q=o.Rectangle.getPositionRange({startRow:j,startColumn:V,endColumn:V,endRow:j},M),{row:Se,col:Ae}=_(q.startRow,q.startColumn),oe=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Ae),Ie=o.Rectangle.getPositionRange({startRow:j,startColumn:V,endColumn:V,endRow:j},U),{row:_e,col:me}=_(Ie.startRow,Ie.startColumn),Be=o.Tools.generateRandomId(),ce=this._hyperLinkModel.getHyperLinkByLocation(l,u,_e,me);ce&&D.push({id:I.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce.id}}),(R.APPLY_TYPE.COPY===r||R.APPLY_TYPE.SERIES===r)&&oe&&(D.push({id:I.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...oe,id:Be,row:_e,column:me}}}),T.push({id:I.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:Be}})),ce&&T.push({id:I.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:ce}})})}),{undos:T,redos:D}},t={id:je,onFillData:(i,r,s)=>s===R.APPLY_TYPE.COPY||s===R.APPLY_TYPE.ONLY_FORMAT||s===R.APPLY_TYPE.SERIES?n(i,s):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};we=dn([pt(0,R.IAutoFillService),pt(1,o.Inject(I.HyperLinkModel))],we);var pn=Object.getOwnPropertyDescriptor,hn=(e,n,t,i)=>{for(var r=i>1?void 0:i?pn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Ye=(e,n)=>(t,i)=>n(t,i,e);let Ne=class extends o.Disposable{constructor(e,n,t){super(),this._localeService=e,this._commandService=n,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===We.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],rangeTypes:[f.RangeProtectionPermissionEditPoint],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Ne=hn([Ye(0,o.Inject(o.LocaleService)),Ye(1,o.ICommandService),Ye(2,o.Inject(f.SheetPermissionCheckController))],Ne);var vn=Object.getOwnPropertyDescriptor,gn=(e,n,t,i)=>{for(var r=i>1?void 0:i?vn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},K=(e,n)=>(t,i)=>n(t,i,e);let Me=class extends o.Disposable{constructor(e,n,t,i,r,s,a,l,u,h){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=i,this._sheetPermissionCheckController=r,this._commandService=s,this._editorBridgeService=a,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=h,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:n,subUnitId:t,row:i,col:r}=e,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET);if(!(s==null?void 0:s.getSheetBySheetId(t)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookViewPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),u=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),h=this._permissionService.composePermission([new f.WorkbookCopyPermission(n).id,new f.WorksheetCopyPermission(n,t).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:h}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(w.debounceTime(200)).subscribe(e=>{var M,U;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:t,row:i,col:r}=e,s=this._renderManagerService.getRenderById(n);if(!s)return;const a=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),l=a==null?void 0:a.getSheetBySheetId(t);if(!l)return;if(!s.with(R.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING);return}const h=(M=s==null?void 0:s.with(R.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:M.skeleton,d=r,p=i;let _=p,S=d;h&&h.overflowCache.forValue((j,V,q)=>{o.Rectangle.contains(q,{startColumn:d,endColumn:d,startRow:p,endRow:p})&&(_=j,S=V)});const{viewPermission:P,editPermission:D,copyPermission:T}=this._getLinkPermission(e);if(!P){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(_,S),b=a.getStyles().getStyleByCell(c),A=(U=b==null?void 0:b.tr)==null?void 0:U.a;if(!A&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:_,col:S,editPermission:D,copyPermission:T,customRange:e.customRange,customRangeRect:e.rect,type:C.VIEWING,unitId:n,subUnitId:t,showAll:!!A})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(w.switchMap(n=>this._editorBridgeService.visible$.pipe(w.map(t=>({visible:t,state:n}))))).subscribe(({visible:n,state:t})=>{if(!t||t.editorUnitId!==o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING);return}const{editorUnitId:i,unitId:r,sheetId:s,row:a,column:l}=t,u=this._renderManagerService.getRenderById(i);if(!u)return;const{editPermission:h,viewPermission:d,copyPermission:p}=this._getLinkPermission({unitId:r,subUnitId:s,row:a,col:l}),_=u.with(J.DocEventManagerService);d&&(e==null||e.unsubscribe(),e=_.hoverCustomRanges$.pipe(w.debounceTime(200)).subscribe(S=>{var b,A;const P=S.find(M=>M.range.rangeType===o.CustomRangeType.HYPERLINK);if(!P){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const D=P.rects[P.rects.length-1];if(!((A=(b=this._renderManagerService.getRenderById(r))==null?void 0:b.with(R.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:A.skeleton)||!D)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:s,row:a,col:l,customRange:P.range,customRangeRect:{left:D.left+c.left,top:D.top+c.top,bottom:D.bottom+c.top,right:D.right+c.left},editPermission:h,copyPermission:p,type:C.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(C.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(w.switchMap(e=>{const n=e===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(J.DocEventManagerService).hoverCustomRanges$.pipe(w.debounceTime(200)):new w.Observable(t=>{t.next(null)})})).subscribe(e=>{const n=e==null?void 0:e.find(i=>i.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(n&&t){const{unitId:i,sheetId:r,row:s,column:a}=t,{editPermission:l,viewPermission:u,copyPermission:h}=this._getLinkPermission({unitId:i,subUnitId:r,row:s,col:a});u&&this._sheetsHyperLinkPopupService.showPopup({type:C.ZEN_EDITOR,unitId:i,subUnitId:r,row:s,col:a,customRange:n.range,editPermission:l,copyPermission:h})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(C.EDITING)}))}_initCommandListener(){const e=[f.ClearSelectionContentCommand.id,f.ClearSelectionAllCommand.id,f.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{e.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Me=gn([K(0,o.Inject(R.HoverManagerService)),K(1,o.Inject(g.SheetsHyperLinkPopupService)),K(2,o.Inject(de.IRenderManagerService)),K(3,o.Inject(o.IPermissionService)),K(4,o.Inject(f.SheetPermissionCheckController)),K(5,o.ICommandService),K(6,R.IEditorBridgeService),K(7,o.Inject(pe.DocSelectionManagerService)),K(8,o.IUniverInstanceService),K(9,m.IZenZoneService)],Me);var Sn=Object.getOwnPropertyDescriptor,ht=(e,n,t,i)=>{for(var r=i>1?void 0:i?Sn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Ge=(e,n)=>(t,i)=>n(t,i,e);let ze=class extends o.Disposable{constructor(e,n){super(),this._context=e,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(w.debounceTime(16)).subscribe(()=>{e()}))}};ze=ht([Ge(1,o.Inject(I.HyperLinkModel))],ze);let Ue=class extends o.Disposable{constructor(e,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Value,priority:100,handler:(e,n,t)=>{const{row:i,col:r,unitId:s,subUnitId:a}=n,l=this._hyperLinkModel.getHyperLinkByLocation(s,a,i,r);return t(l?{...e,linkUrl:l.payload,linkId:l.id}:e)}}))}};Ue=ht([Ge(0,o.Inject(f.SheetInterceptorService)),Ge(1,o.Inject(I.HyperLinkModel))],Ue);const In={[m.RibbonInsertGroup.MEDIA]:{[re.id]:{order:1,menuItemFactory:cn},[Oe(re.id)]:{order:1,menuItemFactory:ln}},[m.ContextMenuPosition.MAIN_AREA]:{[m.ContextMenuGroup.OTHERS]:{order:1,[re.id]:{order:0,menuItemFactory:sn},[Oe(re.id)]:{order:0,menuItemFactory:an}}}};var _n=Object.getOwnPropertyDescriptor,mn=(e,n,t,i)=>{for(var r=i>1?void 0:i?_n(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ge=(e,n)=>(t,i)=>n(t,i,e);let He=class extends o.Disposable{constructor(e,n,t,i,r){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._injector=i,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Re,Re.componentKey],[Ze,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[Le,ve,De,re].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(In)}_initShortCut(){this._shortcutService.registerShortcut(We)}};He=mn([ge(0,o.Inject(m.ComponentManager)),ge(1,o.ICommandService),ge(2,m.IMenuManagerService),ge(3,o.Inject(o.Injector)),ge(4,o.Inject(m.IShortcutService))],He);var fn=Object.getOwnPropertyDescriptor,yn=(e,n,t,i)=>{for(var r=i>1?void 0:i?fn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},vt=(e,n)=>(t,i)=>n(t,i,e);let xe=class extends o.Disposable{constructor(e,n){super(),this._parserService=e,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const n=this._parserService.parseHyperLink(e);this._resolverService.navigate(n)}}};xe=yn([vt(0,o.Inject(I.SheetsHyperLinkParserService)),vt(1,o.Inject(g.SheetsHyperLinkResolverService))],xe);var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(e,n,t)=>n in e?Cn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Pn=(e,n,t,i)=>{for(var r=i>1?void 0:i?En(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},gt=(e,n)=>(t,i)=>n(t,i,e),St=(e,n,t)=>Rn(e,typeof n!="symbol"?n+"":n,t);g.UniverSheetsHyperLinkUIPlugin=class extends o.Plugin{constructor(n=it,t,i){super(),this._config=n,this._injector=t,this._configService=i;const{menu:r,...s}=o.merge({},it,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(nt,s)}onStarting(){[[g.SheetsHyperLinkResolverService],[g.SheetsHyperLinkPopupService],[$e],[Ue],[Me],[He],[we],[g.SheetsHyperLinkCopyPasteController],[Ne],[xe]].forEach(t=>this._injector.add(t)),this._injector.get(Ue)}onReady(){this._injector.get(de.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ze]),this._injector.get(we),this._injector.get(g.SheetsHyperLinkCopyPasteController),this._injector.get(He)}onRendered(){this._injector.get(Ne),this._injector.get(xe),this._injector.get(Me)}},St(g.UniverSheetsHyperLinkUIPlugin,"pluginName",je),St(g.UniverSheetsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkUIPlugin=Pn([o.DependentOn(I.UniverSheetsHyperLinkPlugin,J.UniverDocsUIPlugin),gt(1,o.Inject(o.Injector)),gt(2,o.IConfigService)],g.UniverSheetsHyperLinkUIPlugin),g.CloseHyperLinkPopupOperation=ve,g.InsertHyperLinkOperation=De,g.InsertLinkShortcut=We,g.OpenHyperLinkEditPanelOperation=Le,g.SheetsHyperLinkSidePanelService=$e,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-hyper-link-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -65,18 +65,18 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@univerjs/icons": "^0.3.24",
|
|
68
|
-
"@univerjs/core": "0.
|
|
69
|
-
"@univerjs/docs": "0.
|
|
70
|
-
"@univerjs/
|
|
71
|
-
"@univerjs/
|
|
72
|
-
"@univerjs/
|
|
73
|
-
"@univerjs/engine-
|
|
74
|
-
"@univerjs/sheets
|
|
75
|
-
"@univerjs/sheets-
|
|
76
|
-
"@univerjs/sheets-formula-ui": "0.
|
|
77
|
-
"@univerjs/sheets": "0.
|
|
78
|
-
"@univerjs/sheets-ui": "0.
|
|
79
|
-
"@univerjs/ui": "0.
|
|
68
|
+
"@univerjs/core": "0.8.0-beta.0",
|
|
69
|
+
"@univerjs/docs": "0.8.0-beta.0",
|
|
70
|
+
"@univerjs/design": "0.8.0-beta.0",
|
|
71
|
+
"@univerjs/docs-ui": "0.8.0-beta.0",
|
|
72
|
+
"@univerjs/engine-render": "0.8.0-beta.0",
|
|
73
|
+
"@univerjs/engine-formula": "0.8.0-beta.0",
|
|
74
|
+
"@univerjs/sheets": "0.8.0-beta.0",
|
|
75
|
+
"@univerjs/sheets-data-validation": "0.8.0-beta.0",
|
|
76
|
+
"@univerjs/sheets-formula-ui": "0.8.0-beta.0",
|
|
77
|
+
"@univerjs/sheets-hyper-link": "0.8.0-beta.0",
|
|
78
|
+
"@univerjs/sheets-ui": "0.8.0-beta.0",
|
|
79
|
+
"@univerjs/ui": "0.8.0-beta.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"postcss": "^8.5.3",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"typescript": "^5.8.3",
|
|
87
87
|
"vite": "^6.3.5",
|
|
88
88
|
"vitest": "^3.1.4",
|
|
89
|
-
"@univerjs-infra/shared": "0.
|
|
89
|
+
"@univerjs-infra/shared": "0.8.0-beta.0"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"test": "vitest run",
|