@univerjs_sheets-data-validation-ui.js 115 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388
  1. import {
  2. Qe as Qe2
  3. } from "./chunk-KVSOW4CT.js";
  4. import {
  5. C,
  6. Ea,
  7. F as F2,
  8. K,
  9. Ma,
  10. Me as Me2,
  11. Ra as Ra2,
  12. Sa,
  13. Te as Te2,
  14. Ve,
  15. Yt,
  16. _e,
  17. be as be2,
  18. ir,
  19. ne,
  20. or,
  21. pa,
  22. pe,
  23. q as q4,
  24. se,
  25. sr,
  26. va
  27. } from "./chunk-Q35HEJKG.js";
  28. import {
  29. Ei,
  30. fc
  31. } from "./chunk-U3EPM6JO.js";
  32. import "./chunk-ALDCSYO3.js";
  33. import {
  34. Er,
  35. Et,
  36. Hr,
  37. Ks,
  38. Sn,
  39. Ys,
  40. _s,
  41. bi,
  42. gr,
  43. ke as ke2,
  44. me as me2,
  45. ri,
  46. rt as rt2,
  47. sE,
  48. tE,
  49. tt,
  50. ue,
  51. vi,
  52. ws
  53. } from "./chunk-T4NNB5UY.js";
  54. import {
  55. F,
  56. Me,
  57. N,
  58. Nn as Nn2,
  59. Pe,
  60. Te,
  61. V,
  62. Zn,
  63. ar as ar2,
  64. ea,
  65. et,
  66. on,
  67. yh
  68. } from "./chunk-BW43Z7N3.js";
  69. import {
  70. fn,
  71. fr
  72. } from "./chunk-QRYBFJ3R.js";
  73. import "./chunk-MIOQ566M.js";
  74. import {
  75. $e,
  76. Fa,
  77. I1,
  78. Kl,
  79. h3,
  80. i3,
  81. l1,
  82. m1,
  83. n1,
  84. n3,
  85. rt,
  86. u3
  87. } from "./chunk-POAJ2YNP.js";
  88. import {
  89. FO,
  90. HO,
  91. Po,
  92. QC,
  93. e_,
  94. g_,
  95. n_,
  96. r_,
  97. t_,
  98. um
  99. } from "./chunk-GBYP4PB2.js";
  100. import {
  101. H,
  102. be,
  103. j,
  104. m,
  105. me,
  106. q
  107. } from "./chunk-757T4GCY.js";
  108. import {
  109. M
  110. } from "./chunk-PZD7N4BC.js";
  111. import {
  112. A1,
  113. Qe,
  114. S1,
  115. V2,
  116. Yx,
  117. Z,
  118. ee,
  119. k3,
  120. ke,
  121. p1,
  122. q2,
  123. q3,
  124. u6,
  125. vf
  126. } from "./chunk-2MK3Q52E.js";
  127. import "./chunk-BSDDCPAW.js";
  128. import "./chunk-QG2HZMYH.js";
  129. import {
  130. BehaviorSubject,
  131. Cl,
  132. Df,
  133. Fe,
  134. Il,
  135. J0,
  136. Mi,
  137. Nn,
  138. Op,
  139. Ot,
  140. Pt,
  141. Ra,
  142. Rl,
  143. S0,
  144. SE,
  145. Subject,
  146. Tn,
  147. Vn,
  148. Vr,
  149. W0,
  150. WC,
  151. Wd,
  152. Xt,
  153. Ze,
  154. _l,
  155. _n,
  156. ar,
  157. bufferTime,
  158. debounceTime,
  159. distinctUntilChanged,
  160. dn,
  161. en,
  162. filter,
  163. gt,
  164. hn,
  165. iu,
  166. jt,
  167. kt,
  168. ml,
  169. mu,
  170. nf,
  171. nt,
  172. nu,
  173. ot,
  174. q0,
  175. re,
  176. rn,
  177. st,
  178. tr,
  179. uR,
  180. vC,
  181. we,
  182. xn,
  183. z0
  184. } from "./chunk-23V3HWTR.js";
  185. import {
  186. require_react
  187. } from "./chunk-GNR2UJZM.js";
  188. import {
  189. __toESM
  190. } from "./chunk-2LSFTFF7.js";
  191. // node_modules/.pnpm/@univerjs+sheets-data-validation-ui@0.5.5_@grpc+grpc-js@1.13.4_react-dom@18.3.1_react@18.3.1_rxjs@7.8.1_typescript@5.4.5/node_modules/@univerjs/sheets-data-validation-ui/lib/es/index.js
  192. var import_react = __toESM(require_react());
  193. var ko = Object.defineProperty;
  194. var Wo = (e, t, o) => t in e ? ko(e, t, { enumerable: true, configurable: true, writable: true, value: o }) : e[t] = o;
  195. var M2 = (e, t, o) => Wo(e, typeof t != "symbol" ? t + "" : t, o);
  196. var Nt = { exports: {} };
  197. var nt2 = {};
  198. var Fn;
  199. function Ka() {
  200. if (Fn)
  201. return nt2;
  202. Fn = 1;
  203. var e = import_react.default, t = Symbol.for("react.element"), o = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, a = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: true, ref: true, __self: true, __source: true };
  204. function r(l, s, c) {
  205. var u, p = {}, d = null, g = null;
  206. c !== void 0 && (d = "" + c), s.key !== void 0 && (d = "" + s.key), s.ref !== void 0 && (g = s.ref);
  207. for (u in s)
  208. n.call(s, u) && !i.hasOwnProperty(u) && (p[u] = s[u]);
  209. if (l && l.defaultProps)
  210. for (u in s = l.defaultProps, s)
  211. p[u] === void 0 && (p[u] = s[u]);
  212. return { $$typeof: t, type: l, key: d, ref: g, props: p, _owner: a.current };
  213. }
  214. return nt2.Fragment = o, nt2.jsx = r, nt2.jsxs = r, nt2;
  215. }
  216. var Nn3;
  217. function Ga() {
  218. return Nn3 || (Nn3 = 1, Nt.exports = Ka()), Nt.exports;
  219. }
  220. var h = Ga();
  221. var Za = Object.defineProperty;
  222. var qa = Object.getOwnPropertyDescriptor;
  223. var Ja = (e, t, o, n) => {
  224. for (var a = n > 1 ? void 0 : n ? qa(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  225. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  226. return n && a && Za(t, o, a), a;
  227. };
  228. var ot2 = (e, t) => (o, n) => t(o, n, e);
  229. var st2 = class extends nt {
  230. constructor(e, t, o, n, a) {
  231. super(), this._sheetInterceptorService = e, this._dataValidationModel = t, this._dataValidatorRegistryService = o, this._dialogService = n, this._localeService = a, this._initEditorBridgeInterceptor();
  232. }
  233. _initEditorBridgeInterceptor() {
  234. this._sheetInterceptorService.writeCellInterceptor.intercept(
  235. Zn,
  236. {
  237. handler: async (e, t, o) => {
  238. var C2;
  239. const n = await e, { worksheet: a, row: i, col: r, unitId: l, subUnitId: s, workbook: c } = t, u = this._dataValidationModel.getRuleIdByLocation(l, s, i, r), p = u ? this._dataValidationModel.getRuleById(l, s, u) : void 0;
  240. if (!p || p.errorStyle !== _l.STOP)
  241. return o(Promise.resolve(n));
  242. const d = await this._dataValidatorRegistryService.getValidatorItem(p.type);
  243. if (!d || await d.validator(
  244. {
  245. value: ne(n),
  246. interceptValue: ne((C2 = t == null ? void 0 : t.origin) != null ? C2 : n),
  247. row: i,
  248. column: r,
  249. unitId: l,
  250. subUnitId: s,
  251. worksheet: a,
  252. workbook: c,
  253. t: n == null ? void 0 : n.t
  254. },
  255. p
  256. ))
  257. return o(Promise.resolve(n));
  258. const f = a.getCellRaw(i, r);
  259. return this._dialogService.open({
  260. width: 368,
  261. title: {
  262. title: this._localeService.t("dataValidation.alert.title")
  263. },
  264. id: "reject-input-dialog",
  265. children: {
  266. title: d.getRuleFinalError(p, { row: i, col: r, unitId: l, subUnitId: s })
  267. },
  268. footer: {
  269. title: import_react.default.createElement(
  270. Po,
  271. {
  272. type: "primary",
  273. onClick: () => this._dialogService.close("reject-input-dialog")
  274. },
  275. this._localeService.t("dataValidation.alert.ok")
  276. )
  277. },
  278. onClose: () => {
  279. this._dialogService.close("reject-input-dialog");
  280. }
  281. }), o(Promise.resolve(f));
  282. }
  283. }
  284. );
  285. }
  286. showReject(e) {
  287. this._dialogService.open({
  288. width: 368,
  289. title: {
  290. title: this._localeService.t("dataValidation.alert.title")
  291. },
  292. id: "reject-input-dialog",
  293. children: {
  294. title: e
  295. },
  296. footer: {
  297. title: import_react.default.createElement(
  298. Po,
  299. {
  300. type: "primary",
  301. onClick: () => this._dialogService.close("reject-input-dialog")
  302. },
  303. this._localeService.t("dataValidation.alert.ok")
  304. )
  305. },
  306. onClose: () => {
  307. this._dialogService.close("reject-input-dialog");
  308. }
  309. });
  310. }
  311. };
  312. st2 = Ja([
  313. ot2(0, ot(V)),
  314. ot2(1, ot(F2)),
  315. ot2(2, ot(j)),
  316. ot2(3, h3),
  317. ot2(4, ot(Vr))
  318. ], st2);
  319. var Qa = "univer-dv-date-dropdown";
  320. var ei = "univer-dv-date-dropdown-btns";
  321. var Un = {
  322. dvDateDropdown: Qa,
  323. dvDateDropdownBtns: ei
  324. };
  325. var ti = (e) => {
  326. if (e == null || typeof e == "boolean")
  327. return;
  328. if (typeof e == "number" || !Number.isNaN(+e))
  329. return rn(Op.format("yyyy-MM-dd HH:mm:ss", Number(e)));
  330. const t = rn(e);
  331. if (t.isValid())
  332. return t;
  333. };
  334. function ni(e) {
  335. var m2;
  336. const { location: t, hideFn: o } = e, { worksheet: n, row: a, col: i, unitId: r, subUnitId: l, workbook: s } = t, c = W0(Pt), u = W0(st2), p = n.getCell(a, i), d = ne(n.getCellRaw(a, i)), g = ti(d), [f, C2] = (0, import_react.useState)(g), R = f && f.isValid() ? f : rn(), v = W0(Vr), w = W0(F2), I = w.getRuleByLocation(r, l, a, i);
  337. if (!I)
  338. return null;
  339. const V3 = w.getValidator(I.type);
  340. if (!p || !V3)
  341. return;
  342. const _ = !!((m2 = I.bizInfo) != null && m2.showTime), S = async () => {
  343. var x, j2, N2;
  344. if (!R)
  345. return;
  346. const P = R.format(_ ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"), F3 = (x = Op.parseDate(P)) == null ? void 0 : x.v, T = s.getStyles().getStyleByCell(p), E = (N2 = (j2 = T == null ? void 0 : T.n) == null ? void 0 : j2.pattern) != null ? N2 : "", A = Qe2(E);
  347. I.errorStyle !== _l.STOP || await V3.validator({
  348. value: F3,
  349. unitId: r,
  350. subUnitId: l,
  351. row: a,
  352. column: i,
  353. worksheet: n,
  354. workbook: s,
  355. interceptValue: P.replace("Z", "").replace("T", " "),
  356. t: dn.NUMBER
  357. }, I) ? (o(), await c.executeCommand(Et.id, {
  358. visible: false,
  359. eventType: vf.Keyboard,
  360. unitId: r,
  361. keycode: I1.ESC
  362. }), await c.executeCommand(on.id, {
  363. unitId: r,
  364. subUnitId: l,
  365. range: {
  366. startColumn: i,
  367. endColumn: i,
  368. startRow: a,
  369. endRow: a
  370. },
  371. value: {
  372. v: F3,
  373. t: 2,
  374. p: null,
  375. f: null,
  376. si: null,
  377. s: {
  378. n: {
  379. pattern: _ ? A === "datetime" ? E : "yyyy-MM-dd hh:mm:ss" : A === "date" ? E : "yyyy-MM-dd"
  380. }
  381. }
  382. }
  383. })) : u.showReject(V3.getRuleFinalError(I, { row: a, col: i, unitId: r, subUnitId: l }));
  384. };
  385. return h.jsxs("div", { className: Un.dvDateDropdown, children: [
  386. h.jsx(
  387. FO,
  388. {
  389. defaultValue: R,
  390. pickerValue: R,
  391. showTime: _ || void 0,
  392. onSelect: async (y) => {
  393. C2(y);
  394. },
  395. onPanelChange: (y) => {
  396. C2(y);
  397. },
  398. disabledDate: (y) => !Op.parseDate(y.format("YYYY-MM-DD"))
  399. }
  400. ),
  401. h.jsx("div", { className: Un.dvDateDropdownBtns, children: h.jsx(Po, { size: "small", type: "primary", onClick: S, disabled: !R.isValid(), children: v.t("dataValidation.alert.ok") }) })
  402. ] });
  403. }
  404. var ce = function() {
  405. return ce = Object.assign || function(e) {
  406. for (var t, o = 1, n = arguments.length; o < n; o++) {
  407. t = arguments[o];
  408. for (var a in t)
  409. Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
  410. }
  411. return e;
  412. }, ce.apply(this, arguments);
  413. };
  414. var oi = function(e, t) {
  415. var o = {};
  416. for (var n in e)
  417. Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (o[n] = e[n]);
  418. if (e != null && typeof Object.getOwnPropertySymbols == "function")
  419. for (var a = 0, n = Object.getOwnPropertySymbols(e); a < n.length; a++)
  420. t.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[a]) && (o[n[a]] = e[n[a]]);
  421. return o;
  422. };
  423. var Me3 = (0, import_react.forwardRef)(function(e, t) {
  424. var o = e.icon, n = e.id, a = e.className, i = e.extend, r = oi(e, ["icon", "id", "className", "extend"]), l = "univerjs-icon univerjs-icon-".concat(n, " ").concat(a || "").trim(), s = (0, import_react.useRef)("_".concat(ri2()));
  425. return Co(o, "".concat(n), { defIds: o.defIds, idSuffix: s.current }, ce({ ref: t, className: l }, r), i);
  426. });
  427. function Co(e, t, o, n, a) {
  428. return (0, import_react.createElement)(e.tag, ce(ce({ key: t }, ai(e, o, a)), n), (ii(e, o).children || []).map(function(i, r) {
  429. return Co(i, "".concat(t, "-").concat(e.tag, "-").concat(r), o, void 0, a);
  430. }));
  431. }
  432. function ai(e, t, o) {
  433. var n = ce({}, e.attrs);
  434. o != null && o.colorChannel1 && n.fill === "colorChannel1" && (n.fill = o.colorChannel1);
  435. var a = t.defIds;
  436. return !a || a.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(i) {
  437. var r = i[0], l = i[1];
  438. typeof l == "string" && (n[r] = l.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
  439. })), n;
  440. }
  441. function ii(e, t) {
  442. var o, n = t.defIds;
  443. return !n || n.length === 0 ? e : e.tag === "defs" && (!((o = e.children) === null || o === void 0) && o.length) ? ce(ce({}, e), { children: e.children.map(function(a) {
  444. return typeof a.attrs.id == "string" && n && n.indexOf(a.attrs.id) > -1 ? ce(ce({}, a), { attrs: ce(ce({}, a.attrs), { id: a.attrs.id + t.idSuffix }) }) : a;
  445. }) }) : e;
  446. }
  447. function ri2() {
  448. return Math.random().toString(36).substring(2, 8);
  449. }
  450. Me3.displayName = "UniverIcon";
  451. var si = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
  452. var Io = (0, import_react.forwardRef)(function(e, t) {
  453. return (0, import_react.createElement)(Me3, Object.assign({}, e, {
  454. id: "check-mark-single",
  455. ref: t,
  456. icon: si
  457. }));
  458. });
  459. Io.displayName = "CheckMarkSingle";
  460. var li = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
  461. var wo = (0, import_react.forwardRef)(function(e, t) {
  462. return (0, import_react.createElement)(Me3, Object.assign({}, e, {
  463. id: "data-validation-single",
  464. ref: t,
  465. icon: li
  466. }));
  467. });
  468. wo.displayName = "DataValidationSingle";
  469. var di = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
  470. var Rn = (0, import_react.forwardRef)(function(e, t) {
  471. return (0, import_react.createElement)(Me3, Object.assign({}, e, {
  472. id: "delete-single",
  473. ref: t,
  474. icon: di
  475. }));
  476. });
  477. Rn.displayName = "DeleteSingle";
  478. var ci = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z" } }] };
  479. var Ro = (0, import_react.forwardRef)(function(e, t) {
  480. return (0, import_react.createElement)(Me3, Object.assign({}, e, {
  481. id: "increase-single",
  482. ref: t,
  483. icon: ci
  484. }));
  485. });
  486. Ro.displayName = "IncreaseSingle";
  487. var ui = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
  488. var Do = (0, import_react.forwardRef)(function(e, t) {
  489. return (0, import_react.createElement)(Me3, Object.assign({}, e, {
  490. id: "more-down-single",
  491. ref: t,
  492. icon: ui
  493. }));
  494. });
  495. Do.displayName = "MoreDownSingle";
  496. var hi = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
  497. var Vo = (0, import_react.forwardRef)(function(e, t) {
  498. return (0, import_react.createElement)(Me3, Object.assign({}, e, {
  499. id: "more-up-single",
  500. ref: t,
  501. icon: hi
  502. }));
  503. });
  504. Vo.displayName = "MoreUpSingle";
  505. var pi = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "mask", attrs: { id: "mask0_622_8", style: { maskType: "alpha" }, width: 16, height: 16, x: 0, y: 0, maskUnits: "userSpaceOnUse" }, children: [{ tag: "path", attrs: { fill: "#D9D9D9", d: "M0 0H16V16H0z" } }] }, { tag: "g", attrs: { fill: "currentColor", mask: "url(#mask0_622_8)" }, children: [{ tag: "path", attrs: { d: "M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z" } }] }] };
  506. var yo = (0, import_react.forwardRef)(function(e, t) {
  507. return (0, import_react.createElement)(Me3, Object.assign({}, e, {
  508. id: "sequence-single",
  509. ref: t,
  510. icon: pi
  511. }));
  512. });
  513. yo.displayName = "SequenceSingle";
  514. var fi = Object.defineProperty;
  515. var mi = Object.getOwnPropertyDescriptor;
  516. var gi = (e, t, o, n) => {
  517. for (var a = n > 1 ? void 0 : n ? mi(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  518. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  519. return n && a && fi(t, o, a), a;
  520. };
  521. var Bn = (e, t) => (o, n) => t(o, n, e);
  522. var fe = class extends nt {
  523. constructor(t, o) {
  524. super();
  525. M2(this, "_open$", new BehaviorSubject(false));
  526. M2(this, "open$", this._open$.pipe(distinctUntilChanged()));
  527. M2(this, "_activeRule");
  528. M2(this, "_activeRule$", new BehaviorSubject(void 0));
  529. M2(this, "activeRule$", this._activeRule$.asObservable());
  530. M2(this, "_closeDisposable", null);
  531. this._univerInstanceService = t, this._sidebarService = o, this.disposeWithMe(
  532. this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET).pipe(filter((n) => !n)).subscribe(() => {
  533. this.close();
  534. })
  535. ), this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe((n) => {
  536. n.id === Dt && (n.visible || setTimeout(() => {
  537. this._sidebarService.sidebarOptions$.next({ visible: false });
  538. }));
  539. }));
  540. }
  541. get activeRule() {
  542. return this._activeRule;
  543. }
  544. get isOpen() {
  545. return this._open$.getValue();
  546. }
  547. dispose() {
  548. var t;
  549. super.dispose(), this._open$.next(false), this._open$.complete(), this._activeRule$.complete(), (t = this._closeDisposable) == null || t.dispose();
  550. }
  551. open() {
  552. this._open$.next(true);
  553. }
  554. close() {
  555. var t;
  556. this._open$.next(false), (t = this._closeDisposable) == null || t.dispose();
  557. }
  558. setCloseDisposable(t) {
  559. this._closeDisposable = Ze(() => {
  560. t.dispose(), this._closeDisposable = null;
  561. });
  562. }
  563. setActiveRule(t) {
  564. this._activeRule = t, this._activeRule$.next(t);
  565. }
  566. };
  567. fe = gi([
  568. Bn(0, _n),
  569. Bn(1, rt)
  570. ], fe);
  571. function vi2() {
  572. const e = W0(Ie), t = z0(e.activeDropdown$, e.activeDropdown), o = W0(n1);
  573. if (!t)
  574. return null;
  575. const { location: n, componentKey: a } = t, i = o.get(a), r = `${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;
  576. if (!i)
  577. return null;
  578. const l = () => {
  579. e.hideDropdown();
  580. };
  581. return h.jsx(
  582. i,
  583. {
  584. location: n,
  585. hideFn: l
  586. },
  587. r
  588. );
  589. }
  590. var Mo = "sheet.ui.dropdown";
  591. var _i = Object.defineProperty;
  592. var Si = Object.getOwnPropertyDescriptor;
  593. var Ci = (e, t, o, n) => {
  594. for (var a = n > 1 ? void 0 : n ? Si(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  595. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  596. return n && a && _i(t, o, a), a;
  597. };
  598. var be3 = (e, t) => (o, n) => t(o, n, e);
  599. var Ie = class extends nt {
  600. constructor(t, o, n, a, i, r, l) {
  601. super();
  602. M2(this, "_activeDropdown");
  603. M2(this, "_activeDropdown$", new Subject());
  604. M2(this, "_currentPopup", null);
  605. M2(this, "activeDropdown$", this._activeDropdown$.asObservable());
  606. M2(this, "_zenVisible", false);
  607. this._canvasPopupManagerService = t, this._univerInstanceService = o, this._dataValidatorRegistryService = n, this._zenZoneService = a, this._renderManagerService = i, this._dataValidationModel = r, this._sheetsSelectionsService = l, this._init(), this._initSelectionChange(), this.disposeWithMe(() => {
  608. this._activeDropdown$.complete();
  609. });
  610. }
  611. get activeDropdown() {
  612. return this._activeDropdown;
  613. }
  614. _init() {
  615. this.disposeWithMe(this._zenZoneService.visible$.subscribe((t) => {
  616. this._zenVisible = t, t && this.hideDropdown();
  617. }));
  618. }
  619. _getDropdownByCell(t, o, n, a) {
  620. const i = t ? this._univerInstanceService.getUnit(t, Fe.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET);
  621. if (!i)
  622. return;
  623. const r = o ? i.getSheetBySheetId(o) : i.getActiveSheet();
  624. if (!r)
  625. return;
  626. const l = this._dataValidationModel.getRuleByLocation(i.getUnitId(), r.getSheetId(), n, a);
  627. if (!l)
  628. return;
  629. const s = this._dataValidatorRegistryService.getValidatorItem(l.type);
  630. return s == null ? void 0 : s.dropdown;
  631. }
  632. _initSelectionChange() {
  633. this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe((t) => {
  634. t && t.every((o) => !(o.primary && this._getDropdownByCell(o.primary.unitId, o.primary.sheetId, o.primary.actualRow, o.primary.actualColumn))) && this.hideDropdown();
  635. }));
  636. }
  637. showDropdown(t, o = true) {
  638. const { location: n } = t, { row: a, col: i, unitId: r, subUnitId: l } = n;
  639. if (this._currentPopup && this._currentPopup.dispose(), this._zenVisible)
  640. return;
  641. this._activeDropdown = t, this._activeDropdown$.next(this._activeDropdown);
  642. const s = this._renderManagerService.getRenderById(iu), c = this._canvasPopupManagerService.attachPopupToCell(
  643. a,
  644. i,
  645. {
  646. componentKey: Mo,
  647. onClickOutside: () => {
  648. o && this.hideDropdown();
  649. },
  650. offset: [0, 3],
  651. excludeOutside: [s == null ? void 0 : s.engine.getCanvasElement()].filter(Boolean)
  652. },
  653. r,
  654. l
  655. );
  656. if (!c)
  657. throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");
  658. const u = new Mi();
  659. u.add(c), u.add({
  660. dispose: () => {
  661. var p, d;
  662. (d = (p = this._activeDropdown) == null ? void 0 : p.onHide) == null || d.call(p);
  663. }
  664. }), this._currentPopup = u;
  665. }
  666. hideDropdown() {
  667. this._activeDropdown && (this._currentPopup && this._currentPopup.dispose(), this._currentPopup = null, this._activeDropdown = null, this._activeDropdown$.next(null));
  668. }
  669. showDataValidationDropdown(t, o, n, a, i) {
  670. const r = this._univerInstanceService.getUnit(t, Fe.UNIVER_SHEET);
  671. if (!r)
  672. return;
  673. const l = r.getSheetBySheetId(o);
  674. if (!l)
  675. return;
  676. const s = this._dataValidationModel.getRuleByLocation(r.getUnitId(), l.getSheetId(), n, a);
  677. if (!s)
  678. return;
  679. const c = this._dataValidatorRegistryService.getValidatorItem(s.type);
  680. if (!c || !c.dropdown) {
  681. this.hideDropdown();
  682. return;
  683. }
  684. this.showDropdown({
  685. location: {
  686. workbook: r,
  687. worksheet: l,
  688. row: n,
  689. col: a,
  690. unitId: t,
  691. subUnitId: o
  692. },
  693. componentKey: c.dropdown,
  694. onHide: i
  695. });
  696. }
  697. };
  698. Ie = Ci([
  699. be3(0, ot(vi)),
  700. be3(1, _n),
  701. be3(2, ot(j)),
  702. be3(3, u3),
  703. be3(4, Yx),
  704. be3(5, ot(F2)),
  705. be3(6, ot(F))
  706. ], Ie);
  707. var Dt = "DataValidationPanel";
  708. var Ue = {
  709. id: "data-validation.operation.open-validation-panel",
  710. type: ar.OPERATION,
  711. handler(e, t) {
  712. if (!t)
  713. return false;
  714. const { ruleId: o, isAdd: n } = t, a = e.get(fe), i = e.get(m), r = e.get(_n), l = e.get(rt), s = N(r);
  715. if (!s)
  716. return false;
  717. const { unitId: c, subUnitId: u } = s, p = o ? i.getRuleById(c, u, o) : void 0;
  718. a.open(), a.setActiveRule(p && {
  719. unitId: c,
  720. subUnitId: u,
  721. rule: p
  722. });
  723. const d = l.open({
  724. id: Dt,
  725. header: { title: n ? "dataValidation.panel.addTitle" : "dataValidation.panel.title" },
  726. children: { label: Dt },
  727. width: 312,
  728. onClose: () => a.close()
  729. });
  730. return a.setCloseDisposable(d), true;
  731. }
  732. };
  733. var Dn = {
  734. id: "data-validation.operation.close-validation-panel",
  735. type: ar.OPERATION,
  736. handler(e) {
  737. return e.get(fe).close(), true;
  738. }
  739. };
  740. var bo = {
  741. id: "data-validation.operation.toggle-validation-panel",
  742. type: ar.OPERATION,
  743. handler(e) {
  744. const t = e.get(Pt), o = e.get(fe);
  745. return o.open(), o.isOpen ? t.executeCommand(Dn.id) : t.executeCommand(Ue.id), true;
  746. }
  747. };
  748. var Tt = {
  749. type: ar.OPERATION,
  750. id: "sheet.operation.show-data-validation-dropdown",
  751. handler(e, t) {
  752. if (!t)
  753. return false;
  754. const o = e.get(Ie), { unitId: n, subUnitId: a, row: i, column: r } = t, l = o.activeDropdown, s = l == null ? void 0 : l.location;
  755. return s && s.unitId === n && s.subUnitId === a && s.row === i && s.col === r || o.showDataValidationDropdown(
  756. n,
  757. a,
  758. i,
  759. r
  760. ), true;
  761. }
  762. };
  763. var Eo = {
  764. type: ar.OPERATION,
  765. id: "sheet.operation.hide-data-validation-dropdown",
  766. handler(e, t) {
  767. return t ? (e.get(Ie).hideDropdown(), true) : false;
  768. }
  769. };
  770. var Te3 = "#ECECEC";
  771. var Vn2 = "sheets-data-validation-ui.config";
  772. var Vt = {};
  773. var Ii = "univer-dv-list-dropdown";
  774. var wi = "univer-dv-list-dropdown-title";
  775. var Ri = "univer-dv-list-dropdown-list";
  776. var Di = "univer-dv-list-dropdown-list-container";
  777. var Vi = "univer-dv-list-dropdown-selected-icon";
  778. var yi = "univer-dv-list-dropdown-item-container";
  779. var Mi2 = "univer-dv-list-dropdown-item";
  780. var bi2 = "univer-dv-list-dropdown-split";
  781. var Ei2 = "univer-dv-list-dropdown-edit";
  782. var ve = {
  783. dvListDropdown: Ii,
  784. dvListDropdownTitle: wi,
  785. dvListDropdownList: Ri,
  786. dvListDropdownListContainer: Di,
  787. dvListDropdownSelectedIcon: Vi,
  788. dvListDropdownItemContainer: yi,
  789. dvListDropdownItem: Mi2,
  790. dvListDropdownSplit: bi2,
  791. dvListDropdownEdit: Ei2
  792. };
  793. var Oi = (e) => {
  794. var _, S;
  795. const { value: t, onChange: o, multiple: n, options: a, title: i, onEdit: r, style: l, filter: s, location: c } = e, u = W0(Vr), p = W0(SE), d = s == null ? void 0 : s.toLowerCase(), { row: g, col: f, unitId: C2, subUnitId: R } = c, v = a.filter((m2) => d ? m2.label.toLowerCase().includes(d) : true), w = (S = (_ = p.getConfig(Vn2)) == null ? void 0 : _.showEditOnDropdown) != null ? S : true, I = W0(Nn2), V3 = (0, import_react.useMemo)(() => I.permissionCheckWithRanges(
  796. {
  797. workbookTypes: [Me],
  798. rangeTypes: [Pe],
  799. worksheetTypes: [Te]
  800. },
  801. [{ startColumn: f, startRow: g, endColumn: f, endRow: g }],
  802. C2,
  803. R
  804. ), [I, f, g, C2, R]);
  805. return h.jsxs("div", { className: ve.dvListDropdown, style: l, children: [
  806. h.jsx("div", { className: ve.dvListDropdownTitle, children: i }),
  807. h.jsx("div", { className: ve.dvListDropdownList, children: h.jsx(n_, { children: h.jsx("div", { className: ve.dvListDropdownListContainer, children: v.map((m2, y) => {
  808. const P = t.indexOf(m2.value) > -1, F3 = () => {
  809. let E;
  810. P ? E = new Set(t.filter((x) => x !== m2.value)) : E = new Set(n ? [...t, m2.value] : [m2.value]);
  811. const A = [];
  812. a.forEach((x) => {
  813. E.has(x.value) && A.push(x.value);
  814. }), o(A);
  815. }, T = m2.label.toLocaleLowerCase().indexOf(d);
  816. return h.jsxs("div", { className: ve.dvListDropdownItemContainer, onClick: F3, children: [
  817. h.jsx("div", { className: ve.dvListDropdownItem, style: { background: m2.color || Te3 }, children: d && m2.label.toLowerCase().includes(d) ? h.jsxs(h.Fragment, { children: [
  818. h.jsx("span", { children: m2.label.substring(0, T) }),
  819. h.jsx("span", { style: { fontWeight: "bold" }, children: m2.label.substring(T, T + d.length) }),
  820. h.jsx("span", { children: m2.label.substring(T + d.length) })
  821. ] }) : m2.label }),
  822. h.jsx("div", { className: ve.dvListDropdownSelectedIcon, children: P ? h.jsx(Io, {}) : null })
  823. ] }, y);
  824. }) }) }, s) }),
  825. w && V3 ? h.jsxs(h.Fragment, { children: [
  826. h.jsx("div", { className: ve.dvListDropdownSplit }),
  827. h.jsx("div", { className: ve.dvListDropdownEdit, children: h.jsx("a", { onClick: r, children: u.t("dataValidation.list.edit") }) })
  828. ] }) : null
  829. ] });
  830. };
  831. function Li(e) {
  832. var j2, N2, H2, X;
  833. const { location: t, hideFn: o } = e, { worksheet: n, row: a, col: i, unitId: r, subUnitId: l } = t, s = W0(m), [c, u] = (0, import_react.useState)(""), p = W0(Pt), d = W0(Vr), [g, f] = (0, import_react.useState)(""), C2 = W0(tt), R = W0(_n), v = (0, import_react.useMemo)(() => s.ruleChange$.pipe(debounceTime(16)), []), w = W0(F2);
  834. z0(v);
  835. const I = i3.useContext(), V3 = ((N2 = (j2 = I.current) == null ? void 0 : j2.right) != null ? N2 : 0) - ((X = (H2 = I.current) == null ? void 0 : H2.left) != null ? X : 0);
  836. if ((0, import_react.useEffect)(() => {
  837. const k = p.onCommandExecuted((K2) => {
  838. var q5, ee2;
  839. if (K2.id === M.id) {
  840. const te = K2.params, { unitId: re2 } = te, ae = R.getUnit(re2, Fe.UNIVER_DOC);
  841. if (!ae || !C2.isVisible().visible)
  842. return;
  843. const se2 = st.transform.getPlainText((ee2 = (q5 = ae.getSnapshot().body) == null ? void 0 : q5.dataStream) != null ? ee2 : "");
  844. u(se2);
  845. }
  846. });
  847. return () => {
  848. k.dispose();
  849. };
  850. }, [p, C2, R]), !n)
  851. return null;
  852. const _ = w.getRuleByLocation(r, l, a, i);
  853. if (!_)
  854. return null;
  855. const S = w.getValidator(_.type);
  856. if (!S)
  857. return null;
  858. const m2 = n.getCell(a, i), y = (_ == null ? void 0 : _.renderMode) === Cl.CUSTOM || (_ == null ? void 0 : _.renderMode) === void 0;
  859. if (!m2 || !_ || !S || S.id.indexOf(Il.LIST) !== 0)
  860. return;
  861. const P = _.type === Il.LIST_MULTIPLE, F3 = S.getListWithColor(_, r, l), T = g || sr(n.getCellRaw(a, i)), E = pe(T), A = () => {
  862. p.executeCommand(Ue.id, {
  863. ruleId: _.uid
  864. }), o();
  865. }, x = F3.map((k) => ({
  866. label: k.label,
  867. value: k.label,
  868. color: y || k.color ? k.color : "transparent"
  869. }));
  870. return h.jsx(
  871. Oi,
  872. {
  873. style: { minWidth: V3, maxWidth: Math.max(V3, 200) },
  874. title: P ? d.t("dataValidation.listMultiple.dropdown") : d.t("dataValidation.list.dropdown"),
  875. value: E,
  876. multiple: P,
  877. onChange: async (k) => {
  878. const K2 = ir(k), q5 = {
  879. unitId: r,
  880. subUnitId: l,
  881. range: {
  882. startColumn: i,
  883. endColumn: i,
  884. startRow: a,
  885. endRow: a
  886. },
  887. value: {
  888. v: K2,
  889. p: null,
  890. f: null,
  891. si: null
  892. }
  893. };
  894. C2.isVisible() && C2.changeVisible({
  895. visible: false,
  896. keycode: I1.ESC,
  897. eventType: vf.Keyboard,
  898. unitId: r
  899. }), f(K2), P || o(), C2.isVisible().visible && await p.executeCommand(Et.id, {
  900. visible: false,
  901. eventType: vf.Keyboard,
  902. unitId: r,
  903. keycode: I1.ESC
  904. }), p.executeCommand(on.id, q5);
  905. },
  906. options: x,
  907. onEdit: A,
  908. filter: c,
  909. location: t
  910. }
  911. );
  912. }
  913. var Pi = "univer-data-validation-options-button";
  914. var Ti = "univer-data-validation-options-button-icon";
  915. var Ut = {
  916. dataValidationOptionsButton: Pi,
  917. dataValidationOptionsButtonIcon: Ti
  918. };
  919. function Ai(e) {
  920. var c;
  921. const t = W0(Vr), o = W0(n1), { value: n, onChange: a, extraComponent: i } = e, [r, l] = (0, import_react.useState)(false), s = i ? o.get(i) : null;
  922. return h.jsxs(h.Fragment, { children: [
  923. h.jsxs("div", { className: Ut.dataValidationOptionsButton, onClick: () => l(!r), children: [
  924. t.t("dataValidation.panel.options"),
  925. r ? h.jsx(Vo, { className: Ut.dataValidationOptionsButtonIcon }) : h.jsx(Do, { className: Ut.dataValidationOptionsButtonIcon })
  926. ] }),
  927. r && h.jsxs(h.Fragment, { children: [
  928. s ? h.jsx(s, { value: n, onChange: a }) : null,
  929. h.jsx(
  930. HO,
  931. {
  932. label: t.t("dataValidation.panel.invalid"),
  933. children: h.jsxs(
  934. t_,
  935. {
  936. value: `${(c = n.errorStyle) != null ? c : _l.WARNING}`,
  937. onChange: (u) => a({ ...n, errorStyle: +u }),
  938. children: [
  939. h.jsx(e_, { value: `${_l.WARNING}`, children: t.t("dataValidation.panel.showWarning") }),
  940. h.jsx(e_, { value: `${_l.STOP}`, children: t.t("dataValidation.panel.rejectInput") })
  941. ]
  942. }
  943. )
  944. }
  945. ),
  946. h.jsx(
  947. HO,
  948. {
  949. label: t.t("dataValidation.panel.messageInfo"),
  950. children: h.jsx(
  951. um,
  952. {
  953. checked: n.showErrorMessage,
  954. onChange: () => a({
  955. ...n,
  956. showErrorMessage: !n.showErrorMessage
  957. }),
  958. children: t.t("dataValidation.panel.showInfo")
  959. }
  960. )
  961. }
  962. ),
  963. n.showErrorMessage ? h.jsx(HO, { children: h.jsx(QC, { value: n.error, onChange: (u) => a({ ...n, error: u }) }) }) : null
  964. ] })
  965. ] });
  966. }
  967. var xi = "univer-data-validation-detail";
  968. var ji = "univer-data-validation-detail-form-item";
  969. var Fi = "univer-data-validation-detail-buttons";
  970. var Ni = "univer-data-validation-detail-button";
  971. var Be = {
  972. dataValidationDetail: xi,
  973. dataValidationDetailFormItem: ji,
  974. dataValidationDetailButtons: Fi,
  975. dataValidationDetailButton: Ni
  976. };
  977. var Ui = (e) => S0(
  978. async (t, o, n, a) => {
  979. const i = await e.executeCommand(t, o, n);
  980. a == null || a(i);
  981. },
  982. 1e3
  983. );
  984. function Bi(e, t, o) {
  985. var n, a, i, r;
  986. return t ? ((a = (n = e.getUnit(t)) == null ? void 0 : n.getSheetBySheetName(o)) == null ? void 0 : a.getSheetId()) || "" : ((r = (i = e.getCurrentUnitForType(Fe.UNIVER_SHEET)) == null ? void 0 : i.getSheetBySheetName(o)) == null ? void 0 : r.getSheetId()) || "";
  987. }
  988. function $i() {
  989. var se2;
  990. const [e, t] = (0, import_react.useState)(0), o = W0(fe), n = z0(o.activeRule$, o.activeRule), { unitId: a, subUnitId: i, rule: r } = n || {}, l = r.uid, s = W0(j), c = W0(_n), u = W0(n1), p = W0(Pt), d = W0(m), g = W0(Vr), [f, C2] = (0, import_react.useState)(r), R = s.getValidatorItem(f.type), [v, w] = (0, import_react.useState)(false), I = s.getValidatorsByScope(me.SHEET), [V3, _] = (0, import_react.useState)(() => f.ranges.map((O) => ({ unitId: "", sheetId: "", range: O }))), S = (0, import_react.useMemo)(() => Ui(p), [p]), [m2, y] = (0, import_react.useState)(false), P = (0, import_react.useRef)({}), [F3, T] = (0, import_react.useState)(false), E = W0(F);
  991. if ((0, import_react.useEffect)(() => () => {
  992. const O = E.getCurrentLastSelection();
  993. O && E.setSelections([O]);
  994. }, [E]), (0, import_react.useEffect)(() => {
  995. p.onCommandExecuted((O) => {
  996. (O.id === Nn.id || O.id === Tn.id) && setTimeout(() => {
  997. const D = d.getRuleById(a, i, l);
  998. t((U) => U + 1), D && (C2(D), _(D.ranges.map((U) => ({ unitId: "", sheetId: "", range: U }))));
  999. }, 20);
  1000. });
  1001. }, [p, d, l, i, a]), !R)
  1002. return null;
  1003. const A = R.operators, x = R.operatorNames, j2 = f.operator ? be.includes(f.operator) : false, N2 = () => {
  1004. !f.ranges.length || m2 || (R.validatorFormula(f, a, i).success ? o.setActiveRule(null) : w(true));
  1005. }, H2 = n3((O) => {
  1006. const D = O.split(",").filter(Boolean).map(fn).map(($) => {
  1007. const _e2 = $.sheetName;
  1008. if (_e2) {
  1009. const $o = Bi(c, $.unitId, _e2);
  1010. return { ...$, sheetId: $o };
  1011. }
  1012. return {
  1013. ...$,
  1014. sheetId: ""
  1015. };
  1016. });
  1017. if (uR(D, V3))
  1018. return;
  1019. _(D);
  1020. const U = D.filter(($) => (!$.unitId || $.unitId === a) && (!$.sheetId || $.sheetId === i)).map(($) => $.range);
  1021. if (C2({
  1022. ...f,
  1023. ranges: U
  1024. }), U.length === 0)
  1025. return;
  1026. const B = {
  1027. unitId: a,
  1028. subUnitId: i,
  1029. ruleId: l,
  1030. ranges: U
  1031. };
  1032. S(pa.id, B);
  1033. }), X = (O) => {
  1034. if (Df(O, q(f)))
  1035. return;
  1036. C2({
  1037. ...f,
  1038. ...O
  1039. });
  1040. const D = {
  1041. unitId: a,
  1042. subUnitId: i,
  1043. ruleId: l,
  1044. setting: O
  1045. };
  1046. S(
  1047. Sa.id,
  1048. D,
  1049. void 0
  1050. );
  1051. }, k = async () => {
  1052. await p.executeCommand(Ea.id, {
  1053. ruleId: l,
  1054. unitId: a,
  1055. subUnitId: i
  1056. }), o.setActiveRule(null);
  1057. }, K2 = {
  1058. type: f.type,
  1059. operator: f.operator,
  1060. formula1: f.formula1,
  1061. formula2: f.formula2,
  1062. allowBlank: f.allowBlank
  1063. }, q5 = (O) => {
  1064. const D = s.getValidatorItem(O);
  1065. if (!D)
  1066. return;
  1067. const U = D.operators, B = d.getRuleById(a, i, l), $ = O === (B == null ? void 0 : B.type) || O.includes("list") && (B != null && B.type.includes("list")) ? {
  1068. ...B,
  1069. type: O
  1070. } : {
  1071. ...f,
  1072. type: O,
  1073. operator: U[0],
  1074. formula1: void 0,
  1075. formula2: void 0
  1076. };
  1077. C2($), p.executeCommand(Sa.id, {
  1078. unitId: a,
  1079. subUnitId: i,
  1080. ruleId: f.uid,
  1081. setting: q($)
  1082. });
  1083. }, ee2 = u.get(R.formulaInput), te = (0, import_react.useMemo)(() => V3.map((O) => fr(O.range)).join(","), []), re2 = H(f), ae = (O) => {
  1084. Df(O, H(f)) || (C2({
  1085. ...f,
  1086. ...O
  1087. }), S(
  1088. va.id,
  1089. {
  1090. unitId: a,
  1091. subUnitId: i,
  1092. ruleId: l,
  1093. options: O
  1094. }
  1095. ));
  1096. };
  1097. return Kl((O) => {
  1098. var U;
  1099. const D = (U = P.current) == null ? void 0 : U.handleOutClick;
  1100. D && D(O, () => T(false));
  1101. }), h.jsxs("div", { className: Be.dataValidationDetail, children: [
  1102. h.jsx(
  1103. HO,
  1104. {
  1105. label: g.t("dataValidation.panel.range"),
  1106. error: !f.ranges.length || m2 ? g.t("dataValidation.panel.rangeError") : "",
  1107. children: h.jsx(
  1108. Ei,
  1109. {
  1110. unitId: a,
  1111. subUnitId: i,
  1112. initValue: te,
  1113. onChange: H2,
  1114. onFocus: () => T(true),
  1115. isFocus: F3,
  1116. actions: P.current,
  1117. onVerify: (O) => y(!O)
  1118. }
  1119. )
  1120. }
  1121. ),
  1122. h.jsx(HO, { label: g.t("dataValidation.panel.type"), children: h.jsx(
  1123. r_,
  1124. {
  1125. options: I == null ? void 0 : I.map((O) => ({
  1126. label: g.t(O.title),
  1127. value: O.id
  1128. })),
  1129. value: f.type,
  1130. onChange: q5,
  1131. className: Be.dataValidationDetailFormItem
  1132. }
  1133. ) }),
  1134. A != null && A.length ? h.jsx(HO, { label: g.t("dataValidation.panel.operator"), children: h.jsx(
  1135. r_,
  1136. {
  1137. options: A.map((O, D) => ({
  1138. value: `${O}`,
  1139. label: x[D]
  1140. })),
  1141. value: `${f.operator}`,
  1142. onChange: (O) => {
  1143. X({
  1144. ...K2,
  1145. operator: O
  1146. });
  1147. },
  1148. className: Be.dataValidationDetailFormItem
  1149. }
  1150. ) }) : null,
  1151. ee2 ? h.jsx(
  1152. ee2,
  1153. {
  1154. isTwoFormula: j2,
  1155. value: {
  1156. formula1: f.formula1,
  1157. formula2: f.formula2
  1158. },
  1159. onChange: (O) => {
  1160. X({
  1161. ...K2,
  1162. ...O
  1163. });
  1164. },
  1165. showError: v,
  1166. validResult: R.validatorFormula(f, a, i),
  1167. unitId: a,
  1168. subUnitId: i,
  1169. ruleId: l
  1170. },
  1171. e + f.type
  1172. ) : null,
  1173. h.jsx(HO, { children: h.jsx(
  1174. um,
  1175. {
  1176. checked: (se2 = f.allowBlank) != null ? se2 : true,
  1177. onChange: () => {
  1178. var O;
  1179. return X({
  1180. ...K2,
  1181. allowBlank: !((O = f.allowBlank) == null || O)
  1182. });
  1183. },
  1184. children: g.t("dataValidation.panel.allowBlank")
  1185. }
  1186. ) }),
  1187. h.jsx(Ai, { value: re2, onChange: ae, extraComponent: R.optionsInput }),
  1188. h.jsxs("div", { className: Be.dataValidationDetailButtons, children: [
  1189. h.jsx(Po, { className: Be.dataValidationDetailButton, onClick: k, children: g.t("dataValidation.panel.removeRule") }),
  1190. h.jsx(Po, { className: Be.dataValidationDetailButton, type: "primary", onClick: N2, children: g.t("dataValidation.panel.done") })
  1191. ] })
  1192. ] });
  1193. }
  1194. var ki = "univer-data-validation-item-container";
  1195. var Wi = "univer-data-validation-item-title";
  1196. var Hi = "univer-data-validation-item-content";
  1197. var Yi = "univer-data-validation-item-icon";
  1198. var ct = {
  1199. dataValidationItemContainer: ki,
  1200. dataValidationItemTitle: Wi,
  1201. dataValidationItemContent: Hi,
  1202. dataValidationItemIcon: Yi
  1203. };
  1204. var Xi = (e) => {
  1205. const { rule: t, onClick: o, unitId: n, subUnitId: a, disable: i } = e, r = W0(j), l = W0(Pt), s = W0(ws), c = r.getValidatorItem(t.type), u = (0, import_react.useRef)(), [p, d] = (0, import_react.useState)(false), g = (f) => {
  1206. l.executeCommand(Ea.id, {
  1207. ruleId: t.uid,
  1208. unitId: n,
  1209. subUnitId: a
  1210. }), f.stopPropagation();
  1211. };
  1212. return (0, import_react.useEffect)(() => () => {
  1213. var f;
  1214. u.current && ((f = u.current) == null || f.forEach((C2) => {
  1215. C2 && s.removeShape(C2);
  1216. }));
  1217. }, [s]), h.jsxs(
  1218. "div",
  1219. {
  1220. className: ct.dataValidationItemContainer,
  1221. onClick: o,
  1222. onMouseEnter: () => {
  1223. i || (d(true), u.current = t.ranges.map((f) => s.addShape({
  1224. range: f,
  1225. style: {
  1226. // hasAutoFill: false,
  1227. fill: "rgba(73, 184, 17, 0.05)",
  1228. strokeWidth: 1,
  1229. stroke: "#49B811",
  1230. widgets: {}
  1231. },
  1232. primary: null
  1233. })));
  1234. },
  1235. onMouseLeave: () => {
  1236. var f;
  1237. d(false), (f = u.current) == null || f.forEach((C2) => {
  1238. C2 && s.removeShape(C2);
  1239. }), u.current = void 0;
  1240. },
  1241. children: [
  1242. h.jsx("div", { className: ct.dataValidationItemTitle, children: c == null ? void 0 : c.generateRuleName(t) }),
  1243. h.jsx("div", { className: ct.dataValidationItemContent, children: t.ranges.map((f) => fr(f)).join(",") }),
  1244. p ? h.jsx("div", { className: ct.dataValidationItemIcon, onClick: g, children: h.jsx(Rn, {}) }) : null
  1245. ]
  1246. }
  1247. );
  1248. };
  1249. var zi = "univer-data-validation-list";
  1250. var Ki = "univer-data-validation-list-buttons";
  1251. var Gi = "univer-data-validation-list-button";
  1252. var ut = {
  1253. dataValidationList: zi,
  1254. dataValidationListButtons: Ki,
  1255. dataValidationListButton: Gi
  1256. };
  1257. function Zi() {
  1258. const e = W0(_n), t = z0(
  1259. () => e.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET),
  1260. void 0,
  1261. void 0,
  1262. []
  1263. );
  1264. return t ? h.jsx(qi, { workbook: t }) : null;
  1265. }
  1266. function qi(e) {
  1267. const t = W0(F2), o = W0(_n), n = W0(Pt), a = W0(Ot), i = W0(fe), r = W0(Vr), [l, s] = (0, import_react.useState)([]), { workbook: c } = e, u = z0(c.activeSheet$, void 0, true), p = c.getUnitId(), d = u == null ? void 0 : u.getSheetId();
  1268. (0, import_react.useEffect)(() => {
  1269. s(t.getRules(p, d));
  1270. const w = t.ruleChange$.subscribe((I) => {
  1271. I.unitId === p && I.subUnitId === d && s(t.getRules(p, d));
  1272. });
  1273. return () => {
  1274. w.unsubscribe();
  1275. };
  1276. }, [p, d, t]);
  1277. const g = async () => {
  1278. const w = or(a), I = {
  1279. unitId: p,
  1280. subUnitId: d,
  1281. rule: w
  1282. };
  1283. await n.executeCommand(Ra2.id, I), i.setActiveRule({
  1284. unitId: p,
  1285. subUnitId: d,
  1286. rule: w
  1287. });
  1288. }, f = () => {
  1289. n.executeCommand(Ma.id, {
  1290. unitId: p,
  1291. subUnitId: d
  1292. });
  1293. }, R = ((w) => {
  1294. const I = o.getCurrentUnitForType(Fe.UNIVER_SHEET), V3 = I.getActiveSheet(), _ = I.getUnitId(), S = V3.getSheetId();
  1295. return w.map((y) => yh(a, _, S, y.ranges) ? { ...y } : { ...y, disable: true });
  1296. })(l), v = R == null ? void 0 : R.some((w) => w.disable);
  1297. return h.jsxs("div", { className: ut.dataValidationList, children: [
  1298. R == null ? void 0 : R.map((w) => {
  1299. var I;
  1300. return h.jsx(
  1301. Xi,
  1302. {
  1303. unitId: p,
  1304. subUnitId: d,
  1305. onClick: () => {
  1306. w.disable || i.setActiveRule({
  1307. unitId: p,
  1308. subUnitId: d,
  1309. rule: w
  1310. });
  1311. },
  1312. rule: w,
  1313. disable: (I = w.disable) != null ? I : false
  1314. },
  1315. w.uid
  1316. );
  1317. }),
  1318. h.jsxs("div", { className: ut.dataValidationListButtons, children: [
  1319. l.length && !v ? h.jsx(Po, { className: ut.dataValidationListButton, onClick: f, children: r.t("dataValidation.panel.removeAll") }) : null,
  1320. h.jsx(Po, { className: ut.dataValidationListButton, type: "primary", onClick: g, children: r.t("dataValidation.panel.add") })
  1321. ] })
  1322. ] });
  1323. }
  1324. var Ji = () => {
  1325. const e = W0(fe), t = z0(e.activeRule$, e.activeRule);
  1326. return t ? h.jsx($i, {}, t.rule.uid) : h.jsx(Zi, {});
  1327. };
  1328. var yn = "data-validation.list.dropdown";
  1329. var Oo = "data-validation.date.dropdown";
  1330. var At = {
  1331. type: ar.COMMAND,
  1332. id: "data-validation.command.addRuleAndOpen",
  1333. handler(e) {
  1334. const t = e.get(_n), o = N(t);
  1335. if (!o)
  1336. return false;
  1337. const { workbook: n, worksheet: a } = o, i = or(e), r = e.get(Pt), l = n.getUnitId(), s = a.getSheetId(), c = {
  1338. rule: i,
  1339. unitId: l,
  1340. subUnitId: s
  1341. };
  1342. return r.syncExecuteCommand(Ra2.id, c) ? (r.syncExecuteCommand(Ue.id, {
  1343. ruleId: i.uid,
  1344. isAdd: true
  1345. }), true) : false;
  1346. }
  1347. };
  1348. var Qi = Object.defineProperty;
  1349. var er = Object.getOwnPropertyDescriptor;
  1350. var tr2 = (e, t, o, n) => {
  1351. for (var a = n > 1 ? void 0 : n ? er(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1352. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1353. return n && a && Qi(t, o, a), a;
  1354. };
  1355. var $e2 = (e, t) => (o, n) => t(o, n, e);
  1356. var Ee = "SHEET_DATA_VALIDATION_ALERT";
  1357. var lt = class extends nt {
  1358. constructor(e, t, o, n, a, i) {
  1359. super(), this._hoverManagerService = e, this._cellAlertManagerService = t, this._univerInstanceService = o, this._localeService = n, this._zenZoneService = a, this._dataValidationModel = i, this._init();
  1360. }
  1361. _init() {
  1362. this._initCellAlertPopup(), this._initZenService();
  1363. }
  1364. _initCellAlertPopup() {
  1365. this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((e) => {
  1366. var t;
  1367. if (e) {
  1368. const o = this._univerInstanceService.getUnit(e.location.unitId, Fe.UNIVER_SHEET), n = o.getSheetBySheetId(e.location.subUnitId);
  1369. if (!n)
  1370. return;
  1371. const a = this._dataValidationModel.getRuleByLocation(e.location.unitId, e.location.subUnitId, e.location.row, e.location.col);
  1372. if (!a) {
  1373. this._cellAlertManagerService.removeAlert(Ee);
  1374. return;
  1375. }
  1376. if (this._dataValidationModel.validator(a, { ...e.location, workbook: o, worksheet: n }) === Rl.INVALID) {
  1377. const r = this._cellAlertManagerService.currentAlert.get(Ee), l = (t = r == null ? void 0 : r.alert) == null ? void 0 : t.location;
  1378. if (l && l.row === e.location.row && l.col === e.location.col && l.subUnitId === e.location.subUnitId && l.unitId === e.location.unitId) {
  1379. this._cellAlertManagerService.removeAlert(Ee);
  1380. return;
  1381. }
  1382. const s = this._dataValidationModel.getValidator(a.type);
  1383. if (!s) {
  1384. this._cellAlertManagerService.removeAlert(Ee);
  1385. return;
  1386. }
  1387. this._cellAlertManagerService.showAlert({
  1388. type: Ks.ERROR,
  1389. title: this._localeService.t("dataValidation.error.title"),
  1390. message: s == null ? void 0 : s.getRuleFinalError(a, e.location),
  1391. location: e.location,
  1392. width: 200,
  1393. height: 74,
  1394. key: Ee
  1395. });
  1396. return;
  1397. }
  1398. }
  1399. this._cellAlertManagerService.removeAlert(Ee);
  1400. }));
  1401. }
  1402. _initZenService() {
  1403. this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
  1404. e && this._cellAlertManagerService.removeAlert(Ee);
  1405. }));
  1406. }
  1407. };
  1408. lt = tr2([
  1409. $e2(0, ot(Er)),
  1410. $e2(1, ot(bi)),
  1411. $e2(2, _n),
  1412. $e2(3, ot(Vr)),
  1413. $e2(4, u3),
  1414. $e2(5, ot(F2))
  1415. ], lt);
  1416. var nr = Object.defineProperty;
  1417. var or2 = Object.getOwnPropertyDescriptor;
  1418. var ar3 = (e, t, o, n) => {
  1419. for (var a = n > 1 ? void 0 : n ? or2(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1420. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1421. return n && a && nr(t, o, a), a;
  1422. };
  1423. var Bt = (e, t) => (o, n) => t(o, n, e);
  1424. var ze = class extends nt {
  1425. constructor(e, t, o) {
  1426. super(), this._autoFillService = e, this._sheetDataValidationModel = t, this._injector = o, this._initAutoFill();
  1427. }
  1428. // eslint-disable-next-line max-lines-per-function
  1429. _initAutoFill() {
  1430. const e = () => ({ redos: [], undos: [] }), t = (n, a) => {
  1431. const { source: i, target: r, unitId: l, subUnitId: s } = n, c = this._sheetDataValidationModel.getRuleObjectMatrix(l, s).clone(), u = _s([i, r]), [p, d] = u.ranges, { mapFunc: g } = u, f = {
  1432. row: p.startRow,
  1433. col: p.startColumn
  1434. }, C2 = tE(p, d), R = new kt(), v = /* @__PURE__ */ new Set();
  1435. C2.forEach((S) => {
  1436. const m2 = S.repeatStartCell, y = S.relativeRange, P = {
  1437. startRow: f.row,
  1438. startColumn: f.col,
  1439. endColumn: f.col,
  1440. endRow: f.row
  1441. }, F3 = {
  1442. startRow: m2.row,
  1443. startColumn: m2.col,
  1444. endColumn: m2.col,
  1445. endRow: m2.row
  1446. };
  1447. tr.foreach(y, (T, E) => {
  1448. const A = en.getPositionRange(
  1449. {
  1450. startRow: T,
  1451. startColumn: E,
  1452. endColumn: E,
  1453. endRow: T
  1454. },
  1455. P
  1456. ), { row: x, col: j2 } = g(A.startRow, A.startColumn), N2 = this._sheetDataValidationModel.getRuleIdByLocation(l, s, x, j2) || "", H2 = en.getPositionRange(
  1457. {
  1458. startRow: T,
  1459. startColumn: E,
  1460. endColumn: E,
  1461. endRow: T
  1462. },
  1463. F3
  1464. ), { row: X, col: k } = g(H2.startRow, H2.startColumn);
  1465. R.setValue(X, k, N2), v.add(N2);
  1466. });
  1467. });
  1468. const w = Array.from(v).map((S) => ({ id: S, ranges: WC(R, (m2) => m2 === S) }));
  1469. c.addRangeRules(w);
  1470. const I = c.diff(this._sheetDataValidationModel.getRules(l, s)), { redoMutations: V3, undoMutations: _ } = be2(l, s, I, this._injector, "patched", a === ke2.ONLY_FORMAT);
  1471. return {
  1472. undos: _,
  1473. redos: V3
  1474. };
  1475. }, o = {
  1476. id: Yt,
  1477. onBeforeFillData: (n) => {
  1478. const { source: a, unitId: i, subUnitId: r } = n;
  1479. for (const l of a.rows)
  1480. for (const s of a.cols) {
  1481. const c = this._sheetDataValidationModel.getRuleByLocation(i, r, l, s);
  1482. if (c && c.type === Il.CHECKBOX) {
  1483. this._autoFillService.setDisableApplyType(ke2.SERIES, true);
  1484. return;
  1485. }
  1486. }
  1487. },
  1488. onFillData: (n, a, i) => i === ke2.COPY || i === ke2.ONLY_FORMAT || i === ke2.SERIES ? t(n, i) : e(),
  1489. onAfterFillData: () => {
  1490. }
  1491. };
  1492. this.disposeWithMe(this._autoFillService.addHook(o));
  1493. }
  1494. };
  1495. ze = ar3([
  1496. Bt(0, Hr),
  1497. Bt(1, ot(F2)),
  1498. Bt(2, ot(Ot))
  1499. ], ze);
  1500. var ir2 = Object.defineProperty;
  1501. var rr = Object.getOwnPropertyDescriptor;
  1502. var sr2 = (e, t, o, n) => {
  1503. for (var a = n > 1 ? void 0 : n ? rr(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1504. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1505. return n && a && ir2(t, o, a), a;
  1506. };
  1507. var $t = (e, t) => (o, n) => t(o, n, e);
  1508. var Ke = class extends nt {
  1509. constructor(t, o, n) {
  1510. super();
  1511. M2(this, "_copyInfo");
  1512. this._sheetClipboardService = t, this._sheetDataValidationModel = o, this._injector = n, this._initCopyPaste();
  1513. }
  1514. _initCopyPaste() {
  1515. this._sheetClipboardService.addClipboardHook({
  1516. id: Yt,
  1517. onBeforeCopy: (t, o, n) => this._collect(t, o, n),
  1518. onPasteCells: (t, o, n, a) => {
  1519. const { copyType: i = gr.COPY, pasteType: r } = a, { range: l } = t || {}, { range: s, unitId: c, subUnitId: u } = o;
  1520. return this._generateMutations(s, { copyType: i, pasteType: r, copyRange: l, unitId: c, subUnitId: u });
  1521. }
  1522. });
  1523. }
  1524. _collect(t, o, n) {
  1525. const a = new kt();
  1526. this._copyInfo = {
  1527. unitId: t,
  1528. subUnitId: o,
  1529. matrix: a
  1530. };
  1531. const i = this._injector.invoke((s) => Ys(n, s, t, o));
  1532. if (!i)
  1533. return;
  1534. const { rows: r, cols: l } = i;
  1535. r.forEach((s, c) => {
  1536. l.forEach((u, p) => {
  1537. const d = this._sheetDataValidationModel.getRuleIdByLocation(t, o, s, u);
  1538. a.setValue(c, p, d != null ? d : "");
  1539. });
  1540. });
  1541. }
  1542. // eslint-disable-next-line max-lines-per-function
  1543. _generateMutations(t, o) {
  1544. if (!this._copyInfo)
  1545. return { redos: [], undos: [] };
  1546. if (o.copyType === gr.CUT)
  1547. return this._copyInfo = null, { redos: [], undos: [] };
  1548. if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !o.copyRange)
  1549. return { redos: [], undos: [] };
  1550. if ([
  1551. rt2.SPECIAL_PASTE_COL_WIDTH,
  1552. rt2.SPECIAL_PASTE_VALUE,
  1553. rt2.SPECIAL_PASTE_FORMAT,
  1554. rt2.SPECIAL_PASTE_FORMULA
  1555. ].includes(o.pasteType))
  1556. return { redos: [], undos: [] };
  1557. const { unitId: a, subUnitId: i } = this._copyInfo;
  1558. if (o.unitId !== a || i !== o.subUnitId) {
  1559. const r = this._sheetDataValidationModel.getRuleObjectMatrix(o.unitId, o.subUnitId).clone(), l = new kt(), s = /* @__PURE__ */ new Set(), { ranges: [c, u], mapFunc: p } = _s([o.copyRange, t]), d = sE(c, u, true), g = /* @__PURE__ */ new Map();
  1560. d.forEach(({ startRange: v }) => {
  1561. var w;
  1562. (w = this._copyInfo) == null || w.matrix.forValue((I, V3, _) => {
  1563. const S = en.getPositionRange(
  1564. {
  1565. startRow: I,
  1566. endRow: I,
  1567. startColumn: V3,
  1568. endColumn: V3
  1569. },
  1570. v
  1571. ), m2 = `${i}-${_}`, y = this._sheetDataValidationModel.getRuleById(a, i, _);
  1572. !this._sheetDataValidationModel.getRuleById(o.unitId, o.subUnitId, m2) && y && g.set(m2, { ...y, uid: m2 });
  1573. const { row: P, col: F3 } = p(S.startRow, S.startColumn);
  1574. s.add(m2), l.setValue(P, F3, m2);
  1575. });
  1576. });
  1577. const f = Array.from(s).map((v) => ({ id: v, ranges: WC(l, (w) => w === v) }));
  1578. r.addRangeRules(f);
  1579. const { redoMutations: C2, undoMutations: R } = be2(
  1580. o.unitId,
  1581. o.subUnitId,
  1582. r.diffWithAddition(this._sheetDataValidationModel.getRules(o.unitId, o.subUnitId), g.values()),
  1583. this._injector,
  1584. "patched",
  1585. false
  1586. );
  1587. return {
  1588. redos: C2,
  1589. undos: R
  1590. };
  1591. } else {
  1592. const r = this._sheetDataValidationModel.getRuleObjectMatrix(a, i).clone(), l = new kt(), s = /* @__PURE__ */ new Set(), { ranges: [c, u], mapFunc: p } = _s([o.copyRange, t]);
  1593. sE(c, u, true).forEach(({ startRange: R }) => {
  1594. var v;
  1595. (v = this._copyInfo) == null || v.matrix.forValue((w, I, V3) => {
  1596. const _ = en.getPositionRange(
  1597. {
  1598. startRow: w,
  1599. endRow: w,
  1600. startColumn: I,
  1601. endColumn: I
  1602. },
  1603. R
  1604. ), { row: S, col: m2 } = p(_.startRow, _.startColumn);
  1605. l.setValue(S, m2, V3), s.add(V3);
  1606. });
  1607. });
  1608. const g = Array.from(s).map((R) => ({ id: R, ranges: WC(l, (v) => v === R) }));
  1609. r.addRangeRules(g);
  1610. const { redoMutations: f, undoMutations: C2 } = be2(
  1611. a,
  1612. i,
  1613. r.diff(this._sheetDataValidationModel.getRules(a, i)),
  1614. this._injector,
  1615. "patched",
  1616. false
  1617. );
  1618. return {
  1619. redos: f,
  1620. undos: C2
  1621. };
  1622. }
  1623. }
  1624. };
  1625. Ke = sr2([
  1626. $t(0, Sn),
  1627. $t(1, ot(F2)),
  1628. $t(2, ot(Ot))
  1629. ], Ke);
  1630. var lr = Object.defineProperty;
  1631. var dr = Object.getOwnPropertyDescriptor;
  1632. var cr = (e, t, o, n) => {
  1633. for (var a = n > 1 ? void 0 : n ? dr(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1634. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1635. return n && a && lr(t, o, a), a;
  1636. };
  1637. var kt2 = (e, t) => (o, n) => t(o, n, e);
  1638. var Ge = class extends nt {
  1639. constructor(e, t, o) {
  1640. super(), this._localeService = e, this._commandService = t, this._sheetPermissionCheckController = o, this._commandExecutedListener();
  1641. }
  1642. _commandExecutedListener() {
  1643. this.disposeWithMe(
  1644. this._commandService.beforeCommandExecuted((e) => {
  1645. e.id === Ra2.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
  1646. workbookTypes: [Me],
  1647. rangeTypes: [Pe],
  1648. worksheetTypes: [Te, ar2]
  1649. }) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))), e.id === pa.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
  1650. workbookTypes: [Me],
  1651. rangeTypes: [Pe],
  1652. worksheetTypes: [Te, ar2]
  1653. }, e.params.ranges) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")));
  1654. })
  1655. );
  1656. }
  1657. };
  1658. Ge = cr([
  1659. kt2(0, ot(Vr)),
  1660. kt2(1, Pt),
  1661. kt2(2, ot(Nn2))
  1662. ], Ge);
  1663. var Lo = "data-validation-single";
  1664. var Po2 = "sheet.menu.data-validation";
  1665. function ur(e) {
  1666. return {
  1667. id: Po2,
  1668. type: $e.SUBITEMS,
  1669. icon: Lo,
  1670. tooltip: "dataValidation.title",
  1671. hidden$: Fa(e, Fe.UNIVER_SHEET),
  1672. disabled$: ue(e, { workbookTypes: [Me], worksheetTypes: [ar2, Te], rangeTypes: [Pe] })
  1673. };
  1674. }
  1675. function hr(e) {
  1676. return {
  1677. id: Ue.id,
  1678. title: "dataValidation.panel.title",
  1679. type: $e.BUTTON
  1680. };
  1681. }
  1682. function pr(e) {
  1683. return {
  1684. id: At.id,
  1685. title: "dataValidation.panel.add",
  1686. type: $e.BUTTON
  1687. };
  1688. }
  1689. var fr2 = {
  1690. [l1.FORMULAS_INSERT]: {
  1691. [Po2]: {
  1692. order: 9,
  1693. menuItemFactory: ur,
  1694. [Ue.id]: {
  1695. order: 0,
  1696. menuItemFactory: hr
  1697. },
  1698. [At.id]: {
  1699. order: 1,
  1700. menuItemFactory: pr
  1701. }
  1702. }
  1703. }
  1704. };
  1705. var mr = Object.defineProperty;
  1706. var gr2 = Object.getOwnPropertyDescriptor;
  1707. var To = (e, t, o, n) => {
  1708. for (var a = n > 1 ? void 0 : n ? gr2(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1709. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1710. return n && a && mr(t, o, a), a;
  1711. };
  1712. var G = (e, t) => (o, n) => t(o, n, e);
  1713. var Ao = {
  1714. tr: {
  1715. size: 6,
  1716. color: "#fe4b4b"
  1717. }
  1718. };
  1719. var Ze2 = class extends J0 {
  1720. constructor(e, t, o, n, a, i, r, l, s, c, u) {
  1721. super(), this._commandService = e, this._menuManagerService = t, this._renderManagerService = o, this._univerInstanceService = n, this._autoHeightController = a, this._dropdownManagerService = i, this._sheetDataValidationModel = r, this._dataValidatorRegistryService = l, this._sheetInterceptorService = s, this._dataValidationCacheService = c, this._editorBridgeService = u, this._initMenu(), this._initDropdown(), this._initViewModelIntercept(), this._initAutoHeight();
  1722. }
  1723. _initMenu() {
  1724. this._menuManagerService.mergeMenu(fr2);
  1725. }
  1726. _initDropdown() {
  1727. this._editorBridgeService && this.disposeWithMe(this._editorBridgeService.visible$.subscribe((e) => {
  1728. var o;
  1729. if (!e.visible) {
  1730. ((o = this._dropdownManagerService.activeDropdown) == null ? void 0 : o.trigger) === "editor-bridge" && this._dropdownManagerService.hideDropdown();
  1731. return;
  1732. }
  1733. const t = this._editorBridgeService.getEditCellState();
  1734. if (t) {
  1735. const { unitId: n, sheetId: a, row: i, column: r } = t, l = this._univerInstanceService.getUniverSheetInstance(n);
  1736. if (!l)
  1737. return;
  1738. const s = this._sheetDataValidationModel.getRuleByLocation(n, a, i, r);
  1739. if (!s)
  1740. return;
  1741. const c = this._dataValidatorRegistryService.getValidatorItem(s.type);
  1742. if (!(c != null && c.dropdown))
  1743. return;
  1744. const u = l.getActiveSheet();
  1745. if (!u)
  1746. return;
  1747. const p = this._dropdownManagerService.activeDropdown, d = p == null ? void 0 : p.location;
  1748. if (d && d.unitId === n && d.subUnitId === a && d.row === i && d.col === r)
  1749. return;
  1750. this._dropdownManagerService.showDropdown(
  1751. {
  1752. location: {
  1753. unitId: n,
  1754. subUnitId: a,
  1755. row: i,
  1756. col: r,
  1757. workbook: l,
  1758. worksheet: u
  1759. },
  1760. componentKey: c.dropdown,
  1761. onHide: () => {
  1762. },
  1763. trigger: "editor-bridge"
  1764. },
  1765. false
  1766. );
  1767. }
  1768. }));
  1769. }
  1770. // eslint-disable-next-line max-lines-per-function
  1771. _initViewModelIntercept() {
  1772. this.disposeWithMe(
  1773. this._sheetInterceptorService.intercept(
  1774. et.CELL_CONTENT,
  1775. {
  1776. effect: Vn.Style,
  1777. // must be after numfmt
  1778. priority: ea.DATA_VALIDATION,
  1779. // eslint-disable-next-line max-lines-per-function, complexity
  1780. handler: (e, t, o) => {
  1781. var v, w, I, V3, _;
  1782. const { row: n, col: a, unitId: i, subUnitId: r, workbook: l, worksheet: s } = t, c = this._sheetDataValidationModel.getRuleIdByLocation(i, r, n, a);
  1783. if (!c)
  1784. return o(e);
  1785. const u = this._sheetDataValidationModel.getRuleById(i, r, c);
  1786. if (!u)
  1787. return o(e);
  1788. const p = (v = this._dataValidationCacheService.getValue(i, r, n, a)) != null ? v : Rl.VALID, d = this._dataValidatorRegistryService.getValidatorItem(u.type), g = t.rawData;
  1789. let f;
  1790. const C2 = {
  1791. get value() {
  1792. var S;
  1793. return f !== void 0 || (f = (S = ne(g)) != null ? S : null), f;
  1794. }
  1795. }, R = {
  1796. get value() {
  1797. var S;
  1798. return `${(S = C2.value) != null ? S : ""}`;
  1799. }
  1800. };
  1801. return o({
  1802. ...e,
  1803. markers: {
  1804. ...e == null ? void 0 : e.markers,
  1805. ...p === Rl.INVALID ? Ao : null
  1806. },
  1807. customRender: [
  1808. ...(w = e == null ? void 0 : e.customRender) != null ? w : [],
  1809. ...d != null && d.canvasRender ? [d.canvasRender] : []
  1810. ],
  1811. fontRenderExtension: {
  1812. ...e == null ? void 0 : e.fontRenderExtension,
  1813. isSkip: ((I = e == null ? void 0 : e.fontRenderExtension) == null ? void 0 : I.isSkip) || ((V3 = d == null ? void 0 : d.skipDefaultFontRender) == null ? void 0 : V3.call(d, u, C2.value, t))
  1814. },
  1815. interceptorStyle: {
  1816. ...e == null ? void 0 : e.interceptorStyle,
  1817. ...d == null ? void 0 : d.getExtraStyle(u, R.value, {
  1818. get style() {
  1819. const S = l.getStyles();
  1820. return (typeof (e == null ? void 0 : e.s) == "string" ? S.get(e == null ? void 0 : e.s) : e == null ? void 0 : e.s) || {};
  1821. }
  1822. }, n, a)
  1823. },
  1824. interceptorAutoHeight: () => {
  1825. var P, F3, T, E, A, x;
  1826. const S = (F3 = (P = this._renderManagerService.getRenderById(i)) == null ? void 0 : P.with(me2).getWorksheetSkeleton(r)) == null ? void 0 : F3.skeleton;
  1827. if (!S)
  1828. return;
  1829. const m2 = S.worksheet.getMergedCell(n, a), y = {
  1830. data: e,
  1831. style: S.getsStyles().getStyleByCell(e),
  1832. primaryWithCoord: S.getCellWithCoordByIndex((T = m2 == null ? void 0 : m2.startRow) != null ? T : n, (E = m2 == null ? void 0 : m2.startColumn) != null ? E : a),
  1833. unitId: i,
  1834. subUnitId: r,
  1835. row: n,
  1836. col: a,
  1837. workbook: l,
  1838. worksheet: s
  1839. };
  1840. return (x = (A = d == null ? void 0 : d.canvasRender) == null ? void 0 : A.calcCellAutoHeight) == null ? void 0 : x.call(A, y);
  1841. },
  1842. interceptorAutoWidth: () => {
  1843. var P, F3, T, E, A, x;
  1844. const S = (F3 = (P = this._renderManagerService.getRenderById(i)) == null ? void 0 : P.with(me2).getWorksheetSkeleton(r)) == null ? void 0 : F3.skeleton;
  1845. if (!S)
  1846. return;
  1847. const m2 = S.worksheet.getMergedCell(n, a), y = {
  1848. data: e,
  1849. style: S.getsStyles().getStyleByCell(e),
  1850. primaryWithCoord: S.getCellWithCoordByIndex((T = m2 == null ? void 0 : m2.startRow) != null ? T : n, (E = m2 == null ? void 0 : m2.startColumn) != null ? E : a),
  1851. unitId: i,
  1852. subUnitId: r,
  1853. row: n,
  1854. col: a,
  1855. workbook: l,
  1856. worksheet: s
  1857. };
  1858. return (x = (A = d == null ? void 0 : d.canvasRender) == null ? void 0 : A.calcCellAutoWidth) == null ? void 0 : x.call(A, y);
  1859. },
  1860. coverable: ((_ = e == null ? void 0 : e.coverable) != null ? _ : true) && !(u.type === Il.LIST || u.type === Il.LIST_MULTIPLE)
  1861. });
  1862. }
  1863. }
  1864. )
  1865. );
  1866. }
  1867. _initAutoHeight() {
  1868. this._sheetDataValidationModel.ruleChange$.pipe(
  1869. // patched data-validation change don't need to re-calc row height
  1870. // re-calc of row height will be triggered precisely by the origin command
  1871. filter((e) => e.source === "command"),
  1872. bufferTime(100)
  1873. ).subscribe((e) => {
  1874. if (e.length === 0)
  1875. return;
  1876. const t = [];
  1877. if (e.forEach((o) => {
  1878. var n;
  1879. (o.rule.type === Il.LIST_MULTIPLE || o.rule.type === Il.LIST) && (n = o.rule) != null && n.ranges && t.push(...o.rule.ranges);
  1880. }), t.length) {
  1881. const o = this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);
  1882. mu(o.redos, this._commandService);
  1883. }
  1884. });
  1885. }
  1886. };
  1887. Ze2 = To([
  1888. G(0, Pt),
  1889. G(1, m1),
  1890. G(2, Yx),
  1891. G(3, _n),
  1892. G(4, ot(ri)),
  1893. G(5, ot(Ie)),
  1894. G(6, ot(F2)),
  1895. G(7, ot(j)),
  1896. G(8, ot(V)),
  1897. G(9, ot(q4)),
  1898. G(10, nf(tt))
  1899. ], Ze2);
  1900. var $n = class extends J0 {
  1901. constructor(e, t, o, n, a, i, r) {
  1902. super(), this._commandService = e, this._renderManagerService = t, this._autoHeightController = o, this._dataValidatorRegistryService = n, this._sheetInterceptorService = a, this._sheetDataValidationModel = i, this._dataValidationCacheService = r, this._initViewModelIntercept(), this._initAutoHeight();
  1903. }
  1904. _initViewModelIntercept() {
  1905. this.disposeWithMe(
  1906. this._sheetInterceptorService.intercept(
  1907. et.CELL_CONTENT,
  1908. {
  1909. effect: Vn.Style,
  1910. // must be after numfmt
  1911. priority: ea.DATA_VALIDATION,
  1912. // eslint-disable-next-line complexity
  1913. handler: (e, t, o) => {
  1914. var R, v, w, I, V3;
  1915. const { row: n, col: a, unitId: i, subUnitId: r, workbook: l, worksheet: s } = t, c = this._sheetDataValidationModel.getRuleIdByLocation(i, r, n, a);
  1916. if (!c)
  1917. return o(e);
  1918. const u = this._sheetDataValidationModel.getRuleById(i, r, c);
  1919. if (!u)
  1920. return o(e);
  1921. const p = (R = this._dataValidationCacheService.getValue(i, r, n, a)) != null ? R : Rl.VALID, d = this._dataValidatorRegistryService.getValidatorItem(u.type), g = s.getCellRaw(n, a), f = ne(g), C2 = `${f != null ? f : ""}`;
  1922. return o({
  1923. ...e,
  1924. markers: {
  1925. ...e == null ? void 0 : e.markers,
  1926. ...p === Rl.INVALID ? Ao : null
  1927. },
  1928. customRender: [
  1929. ...(v = e == null ? void 0 : e.customRender) != null ? v : [],
  1930. ...d != null && d.canvasRender ? [d.canvasRender] : []
  1931. ],
  1932. fontRenderExtension: {
  1933. ...e == null ? void 0 : e.fontRenderExtension,
  1934. isSkip: ((w = e == null ? void 0 : e.fontRenderExtension) == null ? void 0 : w.isSkip) || ((I = d == null ? void 0 : d.skipDefaultFontRender) == null ? void 0 : I.call(d, u, f, t))
  1935. },
  1936. interceptorStyle: {
  1937. ...e == null ? void 0 : e.interceptorStyle,
  1938. ...d == null ? void 0 : d.getExtraStyle(u, C2, {
  1939. get style() {
  1940. const _ = l.getStyles();
  1941. return (typeof (e == null ? void 0 : e.s) == "string" ? _.get(e == null ? void 0 : e.s) : e == null ? void 0 : e.s) || {};
  1942. }
  1943. }, n, a)
  1944. },
  1945. interceptorAutoHeight: () => {
  1946. var y, P, F3, T, E, A;
  1947. const _ = (P = (y = this._renderManagerService.getRenderById(i)) == null ? void 0 : y.with(me2).getWorksheetSkeleton(r)) == null ? void 0 : P.skeleton;
  1948. if (!_)
  1949. return;
  1950. const S = _.worksheet.getMergedCell(n, a), m2 = {
  1951. data: e,
  1952. style: _.getsStyles().getStyleByCell(e),
  1953. primaryWithCoord: _.getCellWithCoordByIndex((F3 = S == null ? void 0 : S.startRow) != null ? F3 : n, (T = S == null ? void 0 : S.startColumn) != null ? T : a),
  1954. unitId: i,
  1955. subUnitId: r,
  1956. row: n,
  1957. col: a,
  1958. workbook: l,
  1959. worksheet: s
  1960. };
  1961. return (A = (E = d == null ? void 0 : d.canvasRender) == null ? void 0 : E.calcCellAutoHeight) == null ? void 0 : A.call(E, m2);
  1962. },
  1963. coverable: ((V3 = e == null ? void 0 : e.coverable) != null ? V3 : true) && !(u.type === Il.LIST || u.type === Il.LIST_MULTIPLE)
  1964. });
  1965. }
  1966. }
  1967. )
  1968. );
  1969. }
  1970. _initAutoHeight() {
  1971. this._sheetDataValidationModel.ruleChange$.pipe(
  1972. filter((e) => e.source === "command"),
  1973. bufferTime(16)
  1974. ).subscribe((e) => {
  1975. const t = [];
  1976. if (e.forEach((o) => {
  1977. var n;
  1978. (n = o.rule) != null && n.ranges && t.push(...o.rule.ranges);
  1979. }), t.length) {
  1980. const o = this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);
  1981. mu(o.redos, this._commandService);
  1982. }
  1983. });
  1984. }
  1985. };
  1986. $n = To([
  1987. G(0, Pt),
  1988. G(1, Yx),
  1989. G(2, ot(ri)),
  1990. G(3, ot(j)),
  1991. G(4, ot(V)),
  1992. G(5, ot(F2)),
  1993. G(6, ot(q4))
  1994. ], $n);
  1995. var vr = Object.defineProperty;
  1996. var _r = Object.getOwnPropertyDescriptor;
  1997. var Sr = (e, t, o, n) => {
  1998. for (var a = n > 1 ? void 0 : n ? _r(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1999. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2000. return n && a && vr(t, o, a), a;
  2001. };
  2002. var kn = (e, t) => (o, n) => t(o, n, e);
  2003. var yt = class extends nt {
  2004. constructor(e, t, o) {
  2005. super(), this._context = e, this._sheetDataValidationModel = t, this._sheetSkeletonManagerService = o, this._initSkeletonChange();
  2006. }
  2007. _initSkeletonChange() {
  2008. const e = (t) => {
  2009. var n;
  2010. if (!t.length)
  2011. return;
  2012. const o = /* @__PURE__ */ new Set();
  2013. t.forEach((a) => {
  2014. o.add(a.subUnitId);
  2015. }), o.forEach((a) => {
  2016. var i;
  2017. (i = this._sheetSkeletonManagerService.getWorksheetSkeleton(a)) == null || i.skeleton.makeDirty(true);
  2018. }), (n = this._context.mainComponent) == null || n.makeForceDirty();
  2019. };
  2020. this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(q0(16)).subscribe(e));
  2021. }
  2022. };
  2023. yt = Sr([
  2024. kn(1, ot(F2)),
  2025. kn(2, ot(me2))
  2026. ], yt);
  2027. var Cr = "univer-data-validation-formula";
  2028. var Ir = "univer-data-validation-formula-and";
  2029. var wr = "univer-data-validation-formula-list-item";
  2030. var Rr = "univer-data-validation-formula-list-item-icon";
  2031. var Dr = "univer-data-validation-formula-list-item-drag";
  2032. var Vr2 = "univer-data-validation-formula-list-add";
  2033. var yr = "univer-data-validation-formula-color-select";
  2034. var Mr = "univer-data-validation-formula-color-select-panel";
  2035. var br = "univer-data-validation-formula-color-item";
  2036. var ne2 = {
  2037. dataValidationFormula: Cr,
  2038. dataValidationFormulaAnd: Ir,
  2039. dataValidationFormulaListItem: wr,
  2040. dataValidationFormulaListItemIcon: Rr,
  2041. dataValidationFormulaListItemDrag: Dr,
  2042. dataValidationFormulaListAdd: Vr2,
  2043. dataValidationFormulaColorSelect: yr,
  2044. dataValidationFormulaColorSelectPanel: Mr,
  2045. dataValidationFormulaColorItem: br
  2046. };
  2047. var Er2 = (e) => {
  2048. const { isTwoFormula: t = false, value: o, onChange: n, showError: a, validResult: i } = e, r = W0(Vr), l = a ? i == null ? void 0 : i.formula1 : "", s = a ? i == null ? void 0 : i.formula2 : "";
  2049. return t ? h.jsxs(h.Fragment, { children: [
  2050. h.jsx(HO, { error: l, children: h.jsx(
  2051. QC,
  2052. {
  2053. className: ne2.dataValidationFormula,
  2054. placeholder: r.t("dataValidation.panel.formulaPlaceholder"),
  2055. value: o == null ? void 0 : o.formula1,
  2056. onChange: (c) => {
  2057. n == null || n({
  2058. ...o,
  2059. formula1: c
  2060. });
  2061. }
  2062. }
  2063. ) }),
  2064. h.jsx("div", { className: ne2.dataValidationFormulaAnd, children: r.t("dataValidation.panel.formulaAnd") }),
  2065. h.jsx(HO, { error: s, children: h.jsx(
  2066. QC,
  2067. {
  2068. className: ne2.dataValidationFormula,
  2069. placeholder: r.t("dataValidation.panel.formulaPlaceholder"),
  2070. value: o == null ? void 0 : o.formula2,
  2071. onChange: (c) => {
  2072. n == null || n({
  2073. ...o,
  2074. formula2: c
  2075. });
  2076. }
  2077. }
  2078. ) })
  2079. ] }) : h.jsx(HO, { error: l, children: h.jsx(
  2080. QC,
  2081. {
  2082. className: ne2.dataValidationFormula,
  2083. placeholder: r.t("dataValidation.panel.formulaPlaceholder"),
  2084. value: o == null ? void 0 : o.formula1,
  2085. onChange: (c) => {
  2086. n == null || n({ formula1: c });
  2087. }
  2088. }
  2089. ) });
  2090. };
  2091. function Or(e) {
  2092. const { value: t, onChange: o, showError: n, validResult: a } = e, i = W0(Vr), r = n ? a == null ? void 0 : a.formula1 : "", l = n ? a == null ? void 0 : a.formula2 : "", [s, c] = (0, import_react.useState)(!((t == null ? void 0 : t.formula1) === void 0 && (t == null ? void 0 : t.formula2) === void 0));
  2093. return h.jsxs(h.Fragment, { children: [
  2094. h.jsx(HO, { children: h.jsx(
  2095. um,
  2096. {
  2097. checked: s,
  2098. onChange: (u) => {
  2099. u ? c(true) : (c(false), o == null || o({
  2100. ...t,
  2101. formula1: void 0,
  2102. formula2: void 0
  2103. }));
  2104. },
  2105. children: i.t("dataValidation.checkbox.tips")
  2106. }
  2107. ) }),
  2108. s ? h.jsx(HO, { label: i.t("dataValidation.checkbox.checked"), error: r, children: h.jsx(
  2109. QC,
  2110. {
  2111. className: ne2.dataValidationFormula,
  2112. placeholder: i.t("dataValidation.panel.valuePlaceholder"),
  2113. value: t == null ? void 0 : t.formula1,
  2114. onChange: (u) => {
  2115. o == null || o({
  2116. ...t,
  2117. formula1: u || void 0
  2118. });
  2119. }
  2120. }
  2121. ) }) : null,
  2122. s ? h.jsx(HO, { label: i.t("dataValidation.checkbox.unchecked"), error: l, children: h.jsx(
  2123. QC,
  2124. {
  2125. className: ne2.dataValidationFormula,
  2126. placeholder: i.t("dataValidation.panel.valuePlaceholder"),
  2127. value: t == null ? void 0 : t.formula2,
  2128. onChange: (u) => {
  2129. o == null || o({
  2130. ...t,
  2131. formula2: u || void 0
  2132. });
  2133. }
  2134. }
  2135. ) }) : null
  2136. ] });
  2137. }
  2138. function Lr(e) {
  2139. var p;
  2140. const { unitId: t, subUnitId: o, value: n, onChange: a, showError: i, validResult: r } = e, l = i ? r == null ? void 0 : r.formula1 : void 0, s = (0, import_react.useRef)({}), [c, u] = (0, import_react.useState)(false);
  2141. return Kl((d) => {
  2142. var f;
  2143. const g = (f = s.current) == null ? void 0 : f.handleOutClick;
  2144. g && g(d, () => u(false));
  2145. }), h.jsx(
  2146. fc,
  2147. {
  2148. initValue: (p = n == null ? void 0 : n.formula1) != null ? p : "=",
  2149. unitId: t,
  2150. subUnitId: o,
  2151. isFocus: c,
  2152. onChange: (d) => {
  2153. const g = (d != null ? d : "").trim();
  2154. g !== (n == null ? void 0 : n.formula1) && (a == null || a({
  2155. ...n,
  2156. formula1: g
  2157. }));
  2158. },
  2159. errorText: l,
  2160. onFocus: () => u(true),
  2161. actions: s.current,
  2162. isSupportAcrossSheet: true
  2163. }
  2164. );
  2165. }
  2166. function xo(e) {
  2167. var t, o, n = "";
  2168. if (typeof e == "string" || typeof e == "number")
  2169. n += e;
  2170. else if (typeof e == "object")
  2171. if (Array.isArray(e)) {
  2172. var a = e.length;
  2173. for (t = 0; t < a; t++)
  2174. e[t] && (o = xo(e[t])) && (n && (n += " "), n += o);
  2175. } else
  2176. for (o in e)
  2177. e[o] && (n && (n += " "), n += o);
  2178. return n;
  2179. }
  2180. function Pr() {
  2181. for (var e, t, o = 0, n = "", a = arguments.length; o < a; o++)
  2182. (e = arguments[o]) && (t = xo(e)) && (n && (n += " "), n += t);
  2183. return n;
  2184. }
  2185. var Tr = [
  2186. "#FFFFFF",
  2187. "#FEE7E7",
  2188. "#FEF0E6",
  2189. "#EFFBD0",
  2190. "#E4F4FE",
  2191. "#E8ECFD",
  2192. "#F1EAFA",
  2193. "#FDE8F3",
  2194. "#E5E5E5",
  2195. "#FDCECE",
  2196. "#FDC49B",
  2197. "#DEF6A2",
  2198. "#9FDAFF",
  2199. "#D0D9FB",
  2200. "#E3D5F6",
  2201. "#FBD0E8",
  2202. "#656565",
  2203. "#FE4B4B",
  2204. "#FF8C51",
  2205. "#8BBB11",
  2206. "#0B9EFB",
  2207. "#3A60F7",
  2208. "#9E6DE3",
  2209. "#F248A6"
  2210. ];
  2211. var Ar = (e) => {
  2212. const { value: t, onChange: o, disabled: n } = e, [a, i] = (0, import_react.useState)(false);
  2213. return h.jsx(
  2214. r_,
  2215. {
  2216. disabled: n,
  2217. open: a,
  2218. onDropdownVisibleChange: i,
  2219. dropdownStyle: { width: 112 },
  2220. style: { width: 96, cursor: "pointer" },
  2221. className: ne2.dataValidationFormulaColorSelect,
  2222. value: t,
  2223. onChange: o,
  2224. labelRender: (r) => h.jsx(
  2225. "div",
  2226. {
  2227. className: ne2.dataValidationFormulaColorItem,
  2228. style: { background: r.value, marginTop: 5 }
  2229. }
  2230. ),
  2231. dropdownRender: () => h.jsx("div", { className: ne2.dataValidationFormulaColorSelectPanel, children: Tr.map(
  2232. (r) => h.jsx(
  2233. "div",
  2234. {
  2235. onClick: () => {
  2236. o(r), i(false);
  2237. },
  2238. className: ne2.dataValidationFormulaColorItem,
  2239. style: { background: r }
  2240. },
  2241. r
  2242. )
  2243. ) })
  2244. }
  2245. );
  2246. };
  2247. var Wn = (e) => {
  2248. const { item: t, commonProps: o, style: n } = e, { onItemChange: a, onItemDelete: i } = o;
  2249. return h.jsxs("div", { className: ne2.dataValidationFormulaListItem, style: n, children: [
  2250. t.isRef ? null : h.jsx("div", { className: Pr(ne2.dataValidationFormulaListItemDrag, "draggableHandle"), children: h.jsx(yo, {}) }),
  2251. h.jsx(
  2252. Ar,
  2253. {
  2254. value: t.color,
  2255. onChange: (r) => {
  2256. a(t.id, t.label, r);
  2257. }
  2258. }
  2259. ),
  2260. h.jsx(
  2261. QC,
  2262. {
  2263. disabled: t.isRef,
  2264. value: t.label,
  2265. onChange: (r) => {
  2266. a(t.id, r, t.color);
  2267. }
  2268. }
  2269. ),
  2270. t.isRef ? null : h.jsx("div", { className: ne2.dataValidationFormulaListItemIcon, children: h.jsx(Rn, { onClick: () => i(t.id) }) })
  2271. ] });
  2272. };
  2273. function xr(e) {
  2274. const { value: t, onChange: o = () => {
  2275. }, unitId: n, subUnitId: a, validResult: i, showError: r, ruleId: l } = e, { formula1: s = "", formula2: c = "" } = t || {}, u = (0, import_react.useRef)(null), [p, d] = (0, import_react.useState)(() => vC(s) ? "1" : "0"), [g, f] = (0, import_react.useState)(p === "1" ? s : "="), [C2, R] = (0, import_react.useState)(p === "1" ? s : "="), v = W0(Vr), w = W0(j), I = W0(m), V3 = W0(Te2), [_, S] = (0, import_react.useState)(() => c.split(",")), m2 = w.getValidatorItem(Il.LIST), [y, P] = (0, import_react.useState)([]), [F3, T] = (0, import_react.useState)(""), E = r ? i == null ? void 0 : i.formula1 : "", A = (0, import_react.useMemo)(() => I.ruleChange$.pipe(debounceTime(16)), []), x = z0(A), j2 = n3(o);
  2276. (0, import_react.useEffect)(() => {
  2277. (async () => {
  2278. await new Promise((B) => {
  2279. setTimeout(() => B(true), 100);
  2280. });
  2281. const D = I.getRuleById(n, a, l), U = D == null ? void 0 : D.formula1;
  2282. if (vC(U) && m2 && D) {
  2283. const B = await m2.getListAsync(D, n, a);
  2284. P(B);
  2285. }
  2286. })();
  2287. }, [I, x, m2, l, a, n]), (0, import_react.useEffect)(() => {
  2288. vC(s) && s !== C2 && (f(s), R(C2));
  2289. }, [C2, s]);
  2290. const [N2, H2] = (0, import_react.useState)(() => {
  2291. const D = p !== "1" ? pe(s) : [], U = c.split(",");
  2292. return D.map((B, $) => ({
  2293. label: B,
  2294. color: U[$] || Te3,
  2295. isRef: false,
  2296. id: re.generateRandomId(4)
  2297. }));
  2298. }), X = (D, U, B) => {
  2299. const $ = N2.find((_e2) => _e2.id === D);
  2300. $ && ($.label = U, $.color = B, H2([...N2]));
  2301. }, k = (D) => {
  2302. const U = N2.findIndex((B) => B.id === D);
  2303. U !== -1 && (N2.splice(U, 1), H2([...N2]));
  2304. }, K2 = c.split(","), q5 = (0, import_react.useMemo)(() => y.map((D, U) => ({
  2305. label: D,
  2306. color: K2[U] || Te3,
  2307. id: `${U}`,
  2308. isRef: true
  2309. })), [K2, y]), ee2 = (D, U, B) => {
  2310. const $ = [..._];
  2311. $[+D] = B, S($), j2({
  2312. formula1: s,
  2313. formula2: $.join(",")
  2314. });
  2315. }, te = () => {
  2316. H2([
  2317. ...N2,
  2318. {
  2319. label: "",
  2320. color: Te3,
  2321. isRef: false,
  2322. id: re.generateRandomId(4)
  2323. }
  2324. ]);
  2325. };
  2326. (0, import_react.useEffect)(() => {
  2327. if (p === "1")
  2328. return;
  2329. const D = /* @__PURE__ */ new Set(), U = [];
  2330. N2.map((B) => ({
  2331. labelList: B.label.split(","),
  2332. item: B
  2333. })).forEach(({ item: B, labelList: $ }) => {
  2334. $.forEach((_e2) => {
  2335. D.has(_e2) || (D.add(_e2), U.push({
  2336. label: _e2,
  2337. color: B.color
  2338. }));
  2339. });
  2340. }), j2({
  2341. formula1: ir(U.map((B) => B.label)),
  2342. formula2: U.map((B) => B.color === Te3 ? "" : B.color).join(",")
  2343. });
  2344. }, [N2, j2, p, C2, _]);
  2345. const re2 = n3(async (D) => {
  2346. if (!vC(D)) {
  2347. j2 == null || j2({
  2348. formula1: "",
  2349. formula2: c
  2350. });
  2351. return;
  2352. }
  2353. V3.getFormulaRefCheck(D) ? (j2 == null || j2({
  2354. formula1: vC(D) ? D : "",
  2355. formula2: c
  2356. }), T("")) : (j2 == null || j2({
  2357. formula1: "",
  2358. formula2: c
  2359. }), f("="), T(v.t("dataValidation.validFail.formulaError")));
  2360. }), ae = (0, import_react.useRef)({}), [se2, O] = (0, import_react.useState)(false);
  2361. return Kl((D) => {
  2362. var B;
  2363. const U = (B = ae.current) == null ? void 0 : B.handleOutClick;
  2364. U && U(D, () => O(false));
  2365. }), h.jsxs(h.Fragment, { children: [
  2366. h.jsx(HO, { label: v.t("dataValidation.list.options"), children: h.jsxs(
  2367. t_,
  2368. {
  2369. value: p,
  2370. onChange: (D) => {
  2371. d(D), f(C2), D === "1" && j2({
  2372. formula1: C2 === "=" ? "" : C2,
  2373. formula2: _.join(",")
  2374. });
  2375. },
  2376. children: [
  2377. h.jsx(e_, { value: "0", children: v.t("dataValidation.list.customOptions") }),
  2378. h.jsx(e_, { value: "1", children: v.t("dataValidation.list.refOptions") })
  2379. ]
  2380. }
  2381. ) }),
  2382. p === "1" ? h.jsxs(h.Fragment, { children: [
  2383. h.jsx(
  2384. fc,
  2385. {
  2386. initValue: g,
  2387. unitId: n,
  2388. subUnitId: a,
  2389. isFocus: se2,
  2390. onChange: (D = "") => {
  2391. const U = (D != null ? D : "").trim();
  2392. R(U), re2(U);
  2393. },
  2394. errorText: E || F3 || void 0,
  2395. onFocus: () => O(true),
  2396. actions: ae.current,
  2397. isSupportAcrossSheet: true
  2398. }
  2399. ),
  2400. h.jsx("div", { ref: u, style: { marginTop: "12px" }, children: q5.map((D) => h.jsx(Wn, { item: D, commonProps: { onItemChange: ee2 }, style: { marginBottom: 12 } }, D.id)) })
  2401. ] }) : h.jsx(HO, { error: E, children: h.jsxs("div", { ref: u, style: { marginTop: "-12px" }, children: [
  2402. h.jsx(
  2403. g_,
  2404. {
  2405. list: N2,
  2406. onListChange: H2,
  2407. rowHeight: 32,
  2408. margin: [0, 12],
  2409. draggableHandle: ".draggableHandle",
  2410. itemRender: (D) => h.jsx(
  2411. Wn,
  2412. {
  2413. item: D,
  2414. commonProps: {
  2415. onItemChange: X,
  2416. onItemDelete: k
  2417. }
  2418. },
  2419. D.id
  2420. ),
  2421. idKey: "id"
  2422. }
  2423. ),
  2424. h.jsxs("a", { className: ne2.dataValidationFormulaListAdd, onClick: te, children: [
  2425. h.jsx(Ro, {}),
  2426. v.t("dataValidation.list.add")
  2427. ] })
  2428. ] }) })
  2429. ] });
  2430. }
  2431. var jo = "data-validation.custom-formula-input";
  2432. var xt = "data-validation.formula-input";
  2433. var Mn = "data-validation.list-formula-input";
  2434. var Fo = "data-validation.checkbox-formula-input";
  2435. var jr = [
  2436. [
  2437. jo,
  2438. Lr
  2439. ],
  2440. [
  2441. xt,
  2442. Er2
  2443. ],
  2444. [
  2445. Mn,
  2446. xr
  2447. ],
  2448. [
  2449. Fo,
  2450. Or
  2451. ]
  2452. ];
  2453. var Fr = "LIST_RENDER_MODE_OPTION_INPUT";
  2454. function Mt(e) {
  2455. var a;
  2456. const { value: t, onChange: o } = e, n = W0(Vr);
  2457. return h.jsx(HO, { label: n.t("dataValidation.renderMode.label"), children: h.jsxs(t_, { value: `${(a = t.renderMode) != null ? a : Cl.CUSTOM}`, onChange: (i) => o({ ...t, renderMode: +i }), children: [
  2458. h.jsx(e_, { value: `${Cl.CUSTOM}`, children: n.t("dataValidation.renderMode.chip") }),
  2459. h.jsx(e_, { value: `${Cl.ARROW}`, children: n.t("dataValidation.renderMode.arrow") }),
  2460. h.jsx(e_, { value: `${Cl.TEXT}`, children: n.t("dataValidation.renderMode.text") })
  2461. ] }) });
  2462. }
  2463. Mt.componentKey = Fr;
  2464. var Nr = "DATE_SHOW_TIME_OPTION";
  2465. function bt(e) {
  2466. var a;
  2467. const { value: t, onChange: o } = e, n = W0(Vr);
  2468. return h.jsx(HO, { children: h.jsx(
  2469. um,
  2470. {
  2471. checked: (a = t.bizInfo) == null ? void 0 : a.showTime,
  2472. onChange: (i) => {
  2473. o({
  2474. ...t,
  2475. bizInfo: {
  2476. ...t.bizInfo,
  2477. showTime: i
  2478. }
  2479. });
  2480. },
  2481. children: n.t("dataValidation.showTime.label")
  2482. }
  2483. ) });
  2484. }
  2485. bt.componentKey = Nr;
  2486. var Ur = Object.defineProperty;
  2487. var Br = Object.getOwnPropertyDescriptor;
  2488. var $r = (e, t, o, n) => {
  2489. for (var a = n > 1 ? void 0 : n ? Br(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2490. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2491. return n && a && Ur(t, o, a), a;
  2492. };
  2493. var at = (e, t) => (o, n) => t(o, n, e);
  2494. var ht = 6;
  2495. var dn2 = class {
  2496. constructor(e, t, o, n, a) {
  2497. this._commandService = e, this._formulaService = t, this._themeService = o, this._renderManagerService = n, this._dataValidationModel = a;
  2498. }
  2499. _calc(e, t) {
  2500. var c, u, p;
  2501. const { vt: o, ht: n } = t || {}, a = e.endX - e.startX - ht * 2, i = e.endY - e.startY, r = ((c = t == null ? void 0 : t.fs) != null ? c : 10) * 1.6;
  2502. let l = 0, s = 0;
  2503. switch (o) {
  2504. case hn.TOP:
  2505. s = 0;
  2506. break;
  2507. case hn.BOTTOM:
  2508. s = 0 + (i - r);
  2509. break;
  2510. default:
  2511. s = 0 + (i - r) / 2;
  2512. break;
  2513. }
  2514. switch (n) {
  2515. case Xt.LEFT:
  2516. l = ht;
  2517. break;
  2518. case Xt.RIGHT:
  2519. l = ht + (a - r);
  2520. break;
  2521. default:
  2522. l = ht + (a - r) / 2;
  2523. break;
  2524. }
  2525. return {
  2526. left: e.startX + l,
  2527. top: e.startY + s,
  2528. width: ((u = t == null ? void 0 : t.fs) != null ? u : 10) * 1.6,
  2529. height: ((p = t == null ? void 0 : t.fs) != null ? p : 10) * 1.6
  2530. };
  2531. }
  2532. calcCellAutoHeight(e) {
  2533. var o;
  2534. const { style: t } = e;
  2535. return ((o = t == null ? void 0 : t.fs) != null ? o : 10) * 1.6;
  2536. }
  2537. calcCellAutoWidth(e) {
  2538. var o;
  2539. const { style: t } = e;
  2540. return ((o = t == null ? void 0 : t.fs) != null ? o : 10) * 1.6;
  2541. }
  2542. async _parseFormula(e, t, o) {
  2543. var c, u, p, d, g, f, C2, R, v;
  2544. const { formula1: n = Ve, formula2: a = Me2 } = e, i = await this._formulaService.getRuleFormulaResult(t, o, e.uid), r = se((p = (u = (c = i == null ? void 0 : i[0]) == null ? void 0 : c.result) == null ? void 0 : u[0]) == null ? void 0 : p[0]), l = se((f = (g = (d = i == null ? void 0 : i[1]) == null ? void 0 : d.result) == null ? void 0 : g[0]) == null ? void 0 : f[0]), s = C(String(r)) && C(String(l));
  2545. return {
  2546. formula1: vC(n) ? se((v = (R = (C2 = i == null ? void 0 : i[0]) == null ? void 0 : C2.result) == null ? void 0 : R[0]) == null ? void 0 : v[0]) : n,
  2547. formula2: vC(a) ? l : a,
  2548. isFormulaValid: s
  2549. };
  2550. }
  2551. drawWith(e, t) {
  2552. var E, A, x, j2;
  2553. const { style: o, primaryWithCoord: n, unitId: a, subUnitId: i, worksheet: r, row: l, col: s } = t, c = n.isMergedMainCell ? n.mergeInfo : n, u = ne(r.getCellRaw(l, s)), p = this._dataValidationModel.getRuleByLocation(a, i, l, s);
  2554. if (!p)
  2555. return;
  2556. const d = this._dataValidationModel.getValidator(p.type);
  2557. if (!d)
  2558. return;
  2559. const g = this._themeService.getCurrentTheme();
  2560. if (!((E = d.skipDefaultFontRender) != null && E.call(d, p, u, { unitId: a, subUnitId: i, row: l, column: s })))
  2561. return;
  2562. const f = d.parseFormulaSync(p, a, i), { formula1: C2 } = f, R = this._calc(c, o), { a: v, d: w } = e.getTransform(), I = Z(R.left, v), V3 = Z(R.top, w), _ = S1.create().composeMatrix({
  2563. left: I,
  2564. top: V3,
  2565. scaleX: 1,
  2566. scaleY: 1,
  2567. angle: 0,
  2568. skewX: 0,
  2569. skewY: 0,
  2570. flipX: false,
  2571. flipY: false
  2572. }), S = c.endX - c.startX, m2 = c.endY - c.startY;
  2573. e.save(), e.beginPath(), e.rect(c.startX, c.startY, S, m2), e.clip();
  2574. const y = _.getMatrix();
  2575. e.transform(y[0], y[1], y[2], y[3], y[4], y[5]);
  2576. const P = ((A = o == null ? void 0 : o.fs) != null ? A : 10) * 1.6, F3 = String(u) === String(C2), T = g.hyacinth500;
  2577. u6.drawWith(e, {
  2578. checked: F3,
  2579. width: P,
  2580. height: P,
  2581. fill: (j2 = (x = o == null ? void 0 : o.cl) == null ? void 0 : x.rgb) != null ? j2 : T
  2582. }), e.restore();
  2583. }
  2584. isHit(e, t) {
  2585. const o = t.primaryWithCoord.isMergedMainCell ? t.primaryWithCoord.mergeInfo : t.primaryWithCoord, n = this._calc(o, t.style), a = n.top, i = n.top + n.height, r = n.left, l = n.left + n.width, { x: s, y: c } = e;
  2586. return s <= l && s >= r && c <= i && c >= a;
  2587. }
  2588. async onPointerDown(e, t) {
  2589. var f;
  2590. if (t.button === 2)
  2591. return;
  2592. const { primaryWithCoord: o, unitId: n, subUnitId: a, worksheet: i, row: r, col: l } = e, s = ne(i.getCellRaw(r, l)), c = this._dataValidationModel.getRuleByLocation(n, a, r, l);
  2593. if (!c)
  2594. return;
  2595. const u = this._dataValidationModel.getValidator(c.type);
  2596. if (!u || !((f = u.skipDefaultFontRender) != null && f.call(u, c, s, { unitId: n, subUnitId: a, row: r, column: l })))
  2597. return;
  2598. const { formula1: p, formula2: d } = await this._parseFormula(c, n, a), g = {
  2599. range: {
  2600. startColumn: o.actualColumn,
  2601. endColumn: o.actualColumn,
  2602. startRow: o.actualRow,
  2603. endRow: o.actualRow
  2604. },
  2605. value: {
  2606. v: String(s) === _e(String(p)) ? d : p,
  2607. p: null
  2608. }
  2609. };
  2610. this._commandService.executeCommand(
  2611. on.id,
  2612. g
  2613. );
  2614. }
  2615. onPointerEnter(e, t) {
  2616. var o, n;
  2617. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Fe.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(p1.POINTER);
  2618. }
  2619. onPointerLeave(e, t) {
  2620. var o, n;
  2621. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Fe.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(p1.DEFAULT);
  2622. }
  2623. };
  2624. dn2 = $r([
  2625. at(0, Pt),
  2626. at(1, ot(K)),
  2627. at(2, ot(ml)),
  2628. at(3, ot(Yx)),
  2629. at(4, ot(F2))
  2630. ], dn2);
  2631. var kr = Object.defineProperty;
  2632. var Wr = Object.getOwnPropertyDescriptor;
  2633. var Hr2 = (e, t, o, n) => {
  2634. for (var a = n > 1 ? void 0 : n ? Wr(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2635. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2636. return n && a && kr(t, o, a), a;
  2637. };
  2638. var Yr = (e, t) => (o, n) => t(o, n, e);
  2639. var me3 = class {
  2640. constructor(e) {
  2641. M2(this, "canvasRender", null);
  2642. M2(this, "dropdown");
  2643. M2(this, "optionsInput");
  2644. M2(this, "formulaInput", Mn);
  2645. this.injector = e;
  2646. }
  2647. };
  2648. me3 = Hr2([
  2649. Yr(0, ot(Ot))
  2650. ], me3);
  2651. var Xr = class extends me3 {
  2652. constructor() {
  2653. super(...arguments);
  2654. M2(this, "id", Il.CHECKBOX);
  2655. M2(this, "canvasRender", this.injector.createInstance(dn2));
  2656. M2(this, "formulaInput", Fo);
  2657. }
  2658. };
  2659. var zr = class extends me3 {
  2660. constructor() {
  2661. super(...arguments);
  2662. M2(this, "id", Il.CUSTOM);
  2663. M2(this, "formulaInput", jo);
  2664. }
  2665. };
  2666. var Kr = "data-validation.formula-input";
  2667. var Gr = class extends me3 {
  2668. constructor() {
  2669. super(...arguments);
  2670. M2(this, "id", Il.DATE);
  2671. M2(this, "formulaInput", Kr);
  2672. M2(this, "optionsInput", bt.componentKey);
  2673. M2(this, "dropdown", Oo);
  2674. }
  2675. };
  2676. var Zr = class extends me3 {
  2677. constructor() {
  2678. super(...arguments);
  2679. M2(this, "id", Il.DECIMAL);
  2680. M2(this, "formulaInput", xt);
  2681. }
  2682. };
  2683. var No = 4;
  2684. var qr = 0;
  2685. var Wt = 4;
  2686. var Uo = 4;
  2687. var cn = 6;
  2688. var Et2 = 6;
  2689. var Le = 14;
  2690. function Jr(e, t) {
  2691. const o = q2.getTextSize(e, t), n = o.width + No * 2, { ba: a, bd: i } = o, r = a + i;
  2692. return {
  2693. width: n,
  2694. height: r + qr * 2,
  2695. ba: a
  2696. };
  2697. }
  2698. function Ht(e, t, o, n) {
  2699. const a = Le + cn * 2, i = o - a, r = n - Et2 * 2, l = e.map((d) => ({
  2700. layout: Jr(d, t),
  2701. text: d
  2702. }));
  2703. let s;
  2704. const c = [];
  2705. l.forEach((d) => {
  2706. const { layout: g } = d, { width: f, height: C2 } = g;
  2707. !s || s.width + f + Wt > i ? (s = {
  2708. width: f,
  2709. height: C2,
  2710. items: [{
  2711. ...d,
  2712. left: 0
  2713. }]
  2714. }, c.push(s)) : (s.items.push({
  2715. ...d,
  2716. left: s.width + Wt
  2717. }), s.width = s.width + f + Wt);
  2718. });
  2719. let u = 0, p = 0;
  2720. return c.forEach((d, g) => {
  2721. p = Math.max(p, d.width), g === c.length - 1 ? u += d.height : u += d.height + Uo;
  2722. }), {
  2723. lines: c,
  2724. totalHeight: u,
  2725. contentWidth: i,
  2726. contentHeight: r,
  2727. cellAutoHeight: u + Et2 * 2,
  2728. calcAutoWidth: p + a
  2729. };
  2730. }
  2731. var Qr = 8;
  2732. var es = class extends q3 {
  2733. static drawWith(t, o) {
  2734. const { fontString: n, info: a, fill: i, color: r } = o, { layout: l, text: s } = a;
  2735. t.save(), A1.drawWith(t, {
  2736. width: l.width,
  2737. height: l.height,
  2738. radius: Qr,
  2739. fill: i || Te3
  2740. }), t.translateWithPrecision(No, l.ba), t.font = n, t.fillStyle = r, t.fillText(s, 0, 0), t.restore();
  2741. }
  2742. };
  2743. var ts = Object.defineProperty;
  2744. var ns = Object.getOwnPropertyDescriptor;
  2745. var os = (e, t, o, n) => {
  2746. for (var a = n > 1 ? void 0 : n ? ns(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2747. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2748. return n && a && ts(t, o, a), a;
  2749. };
  2750. var Yt2 = (e, t) => (o, n) => t(o, n, e);
  2751. var as = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
  2752. var un = class {
  2753. constructor(e, t, o) {
  2754. M2(this, "zIndex");
  2755. M2(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
  2756. this._commandService = e, this._renderManagerService = t, this._dataValidationModel = o;
  2757. }
  2758. _ensureMap(e) {
  2759. let t = this._dropdownInfoMap.get(e);
  2760. return t || (t = /* @__PURE__ */ new Map(), this._dropdownInfoMap.set(e, t)), t;
  2761. }
  2762. _generateKey(e, t) {
  2763. return `${e}.${t}`;
  2764. }
  2765. _drawDownIcon(e, t, o, n, a) {
  2766. const i = o - Le + 4;
  2767. let r = 4;
  2768. switch (a) {
  2769. case hn.MIDDLE:
  2770. r = (n - Le) / 2 + 4;
  2771. break;
  2772. case hn.BOTTOM:
  2773. r = n - Le + 4;
  2774. break;
  2775. }
  2776. e.save(), e.translateWithPrecision(t.startX + i, t.startY + r), e.fillStyle = "#565656", e.fill(as), e.restore();
  2777. }
  2778. // eslint-disable-next-line max-lines-per-function
  2779. drawWith(e, t, o, n) {
  2780. var X, k;
  2781. const { primaryWithCoord: a, row: i, col: r, style: l, data: s, subUnitId: c } = t, u = a.isMergedMainCell ? a.mergeInfo : a, p = s == null ? void 0 : s.fontRenderExtension, { leftOffset: d = 0, rightOffset: g = 0, topOffset: f = 0, downOffset: C2 = 0 } = p || {}, R = this._ensureMap(c), v = this._generateKey(i, r), w = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, i, r);
  2782. if (!w)
  2783. return;
  2784. const I = this._dataValidationModel.getValidator(w.type);
  2785. if (!I)
  2786. return;
  2787. const V3 = {
  2788. startX: u.startX + d,
  2789. endX: u.endX - g,
  2790. startY: u.startY + f,
  2791. endY: u.endY - C2
  2792. }, _ = V3.endX - V3.startX, S = V3.endY - V3.startY, { cl: m2 } = l || {}, y = (X = typeof m2 == "object" ? m2 == null ? void 0 : m2.rgb : m2) != null ? X : "#000", P = Qe(l != null ? l : void 0), { vt: F3, ht: T } = l || {}, E = F3 != null ? F3 : hn.MIDDLE, A = (k = ne(s)) != null ? k : "", x = I.parseCellValue(A), j2 = I.getListWithColorMap(w), N2 = Ht(x, P, _, S);
  2793. this._drawDownIcon(e, V3, _, S, E), e.save(), e.translateWithPrecision(V3.startX, V3.startY), e.beginPath(), e.rect(0, 0, _ - Le, S), e.clip(), e.translateWithPrecision(cn, Et2);
  2794. let H2 = 0;
  2795. switch (E) {
  2796. case hn.MIDDLE:
  2797. H2 = (N2.contentHeight - N2.totalHeight) / 2;
  2798. break;
  2799. case hn.BOTTOM:
  2800. H2 = N2.contentHeight - N2.totalHeight;
  2801. break;
  2802. }
  2803. e.translateWithPrecision(0, H2), N2.lines.forEach((K2, q5) => {
  2804. e.save();
  2805. const { width: ee2, height: te, items: re2 } = K2;
  2806. let ae = 0;
  2807. switch (T) {
  2808. case Xt.RIGHT:
  2809. ae = N2.contentWidth - ee2;
  2810. break;
  2811. case Xt.CENTER:
  2812. ae = (N2.contentWidth - ee2) / 2;
  2813. break;
  2814. }
  2815. e.translate(ae, q5 * (te + Uo)), re2.forEach((se2) => {
  2816. e.save(), e.translateWithPrecision(se2.left, 0), es.drawWith(e, {
  2817. ...P,
  2818. info: se2,
  2819. color: y,
  2820. fill: j2[se2.text]
  2821. }), e.restore();
  2822. }), e.restore();
  2823. }), e.restore(), R.set(v, {
  2824. left: V3.startX,
  2825. top: V3.startY,
  2826. width: N2.contentWidth + cn + Le,
  2827. height: N2.contentHeight + Et2 * 2
  2828. });
  2829. }
  2830. calcCellAutoHeight(e) {
  2831. var _;
  2832. const { primaryWithCoord: t, style: o, data: n, row: a, col: i } = e, r = n == null ? void 0 : n.fontRenderExtension, { leftOffset: l = 0, rightOffset: s = 0, topOffset: c = 0, downOffset: u = 0 } = r || {}, p = t.isMergedMainCell ? t.mergeInfo : t, d = {
  2833. startX: p.startX + l,
  2834. endX: p.endX - s,
  2835. startY: p.startY + c,
  2836. endY: p.endY - u
  2837. }, g = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, a, i);
  2838. if (!g)
  2839. return;
  2840. const f = this._dataValidationModel.getValidator(g.type);
  2841. if (!f)
  2842. return;
  2843. const C2 = d.endX - d.startX, R = d.endY - d.startY, v = (_ = ne(n)) != null ? _ : "", w = f.parseCellValue(v), I = Qe(o != null ? o : void 0);
  2844. return Ht(w, I, C2, R).cellAutoHeight;
  2845. }
  2846. calcCellAutoWidth(e) {
  2847. var _;
  2848. const { primaryWithCoord: t, style: o, data: n, row: a, col: i } = e, r = n == null ? void 0 : n.fontRenderExtension, { leftOffset: l = 0, rightOffset: s = 0, topOffset: c = 0, downOffset: u = 0 } = r || {}, p = t.isMergedMainCell ? t.mergeInfo : t, d = {
  2849. startX: p.startX + l,
  2850. endX: p.endX - s,
  2851. startY: p.startY + c,
  2852. endY: p.endY - u
  2853. }, g = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, a, i);
  2854. if (!g)
  2855. return;
  2856. const f = this._dataValidationModel.getValidator(g.type);
  2857. if (!f)
  2858. return;
  2859. const C2 = d.endX - d.startX, R = d.endY - d.startY, v = (_ = ne(n)) != null ? _ : "", w = f.parseCellValue(v), I = Qe(o != null ? o : void 0);
  2860. return Ht(w, I, C2, R).calcAutoWidth;
  2861. }
  2862. isHit(e, t) {
  2863. const { primaryWithCoord: o } = t, n = o.isMergedMainCell ? o.mergeInfo : o, { endX: a } = n, { x: i } = e;
  2864. return i >= a - Le && i <= a;
  2865. }
  2866. onPointerDown(e, t) {
  2867. if (t.button === 2)
  2868. return;
  2869. const { unitId: o, subUnitId: n, row: a, col: i } = e, r = {
  2870. unitId: o,
  2871. subUnitId: n,
  2872. row: a,
  2873. column: i
  2874. };
  2875. this._commandService.executeCommand(Tt.id, r);
  2876. }
  2877. onPointerEnter(e, t) {
  2878. var o, n;
  2879. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Fe.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(p1.POINTER);
  2880. }
  2881. onPointerLeave(e, t) {
  2882. var o, n;
  2883. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Fe.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(p1.DEFAULT);
  2884. }
  2885. };
  2886. un = os([
  2887. Yt2(0, Pt),
  2888. Yt2(1, ot(Yx)),
  2889. Yt2(2, ot(F2))
  2890. ], un);
  2891. var is = class extends me3 {
  2892. constructor() {
  2893. super(...arguments);
  2894. M2(this, "id", Il.LIST_MULTIPLE);
  2895. M2(this, "canvasRender", this.injector.createInstance(un));
  2896. M2(this, "dropdown", yn);
  2897. }
  2898. };
  2899. var rs = Object.defineProperty;
  2900. var ss = Object.getOwnPropertyDescriptor;
  2901. var ls = (e, t, o, n) => {
  2902. for (var a = n > 1 ? void 0 : n ? ss(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2903. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2904. return n && a && rs(t, o, a), a;
  2905. };
  2906. var pt = (e, t) => (o, n) => t(o, n, e);
  2907. var Oe = 4;
  2908. var ft = 4;
  2909. var he = 14;
  2910. var pe2 = 6;
  2911. var ke3 = 4;
  2912. var Xt2 = 8;
  2913. var ds = "#565656";
  2914. var Hn = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
  2915. function cs(e, t) {
  2916. const o = e.length;
  2917. return {
  2918. id: "d",
  2919. body: {
  2920. dataStream: `${e}${Wd}`,
  2921. textRuns: [
  2922. {
  2923. ts: {
  2924. fs: 11,
  2925. ff: void 0,
  2926. it: we.FALSE,
  2927. bl: we.FALSE,
  2928. ul: {
  2929. s: we.FALSE
  2930. },
  2931. st: {
  2932. s: we.FALSE
  2933. },
  2934. ol: {
  2935. s: we.FALSE
  2936. },
  2937. cl: void 0,
  2938. ...t,
  2939. bg: void 0,
  2940. bd: void 0
  2941. },
  2942. st: 0,
  2943. ed: o
  2944. }
  2945. ]
  2946. },
  2947. documentStyle: {
  2948. pageSize: {
  2949. width: Number.POSITIVE_INFINITY,
  2950. height: Number.POSITIVE_INFINITY
  2951. }
  2952. }
  2953. };
  2954. }
  2955. function Bo(e, t, o) {
  2956. const n = cs(e, o), a = new jt(n), i = new V2(a);
  2957. return {
  2958. documentSkeleton: k3.create(i, t),
  2959. docModel: a,
  2960. docViewModel: i
  2961. };
  2962. }
  2963. function mt(e, t, o) {
  2964. const {
  2965. documentSkeleton: n,
  2966. docModel: a,
  2967. docViewModel: i
  2968. } = Bo(e, t, o);
  2969. return {
  2970. documents: new ke(`DOCUMENTS_${re.generateRandomId()}`, n, {
  2971. pageMarginLeft: 0,
  2972. pageMarginTop: 0
  2973. }),
  2974. documentSkeleton: n,
  2975. docModel: a,
  2976. docViewModel: i
  2977. };
  2978. }
  2979. function Yn(e, t, o, n, a, i, r = true) {
  2980. let l = 0;
  2981. const s = r ? ke3 : 0;
  2982. switch (a) {
  2983. case hn.BOTTOM:
  2984. l = t - n - s;
  2985. break;
  2986. case hn.MIDDLE:
  2987. l = (t - n) / 2;
  2988. break;
  2989. default:
  2990. l = s;
  2991. break;
  2992. }
  2993. l = Math.max(ke3, l);
  2994. let c = 0;
  2995. switch (i) {
  2996. case Xt.CENTER:
  2997. c = (e - o) / 2;
  2998. break;
  2999. case Xt.RIGHT:
  3000. c = e - o;
  3001. break;
  3002. }
  3003. return c = Math.max(pe2, c), {
  3004. paddingLeft: c,
  3005. paddingTop: l
  3006. };
  3007. }
  3008. var hn2 = class {
  3009. constructor(e, t, o, n) {
  3010. M2(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
  3011. M2(this, "zIndex");
  3012. this._localeService = e, this._commandService = t, this._renderManagerService = o, this._dataValidationModel = n;
  3013. }
  3014. _ensureMap(e) {
  3015. let t = this._dropdownInfoMap.get(e);
  3016. return t || (t = /* @__PURE__ */ new Map(), this._dropdownInfoMap.set(e, t)), t;
  3017. }
  3018. _generateKey(e, t) {
  3019. return `${e}.${t}`;
  3020. }
  3021. _drawDownIcon(e, t, o, n, a, i, r) {
  3022. const { t: l = gt.pd.t, b: s = gt.pd.b } = r, c = o - he;
  3023. let u;
  3024. switch (i) {
  3025. case hn.MIDDLE:
  3026. u = (n - ft) / 2;
  3027. break;
  3028. case hn.BOTTOM:
  3029. u = n - s - a - ke3 + (a / 2 - ft / 2);
  3030. break;
  3031. default:
  3032. u = l + ke3 + (a / 2 - ft / 2);
  3033. break;
  3034. }
  3035. e.save(), e.translateWithPrecision(t.startX + c, t.startY + u), e.fillStyle = "#565656", e.fill(Hn), e.restore();
  3036. }
  3037. // eslint-disable-next-line max-lines-per-function, complexity
  3038. drawWith(e, t, o) {
  3039. const { primaryWithCoord: n, row: a, col: i, style: r, data: l, subUnitId: s } = t, c = n.isMergedMainCell ? n.mergeInfo : n, u = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, a, i);
  3040. if (!u)
  3041. return;
  3042. const p = this._dataValidationModel.getValidator(u.type);
  3043. if (!p)
  3044. return;
  3045. const d = l == null ? void 0 : l.fontRenderExtension, { leftOffset: g = 0, rightOffset: f = 0, topOffset: C2 = 0, downOffset: R = 0 } = d || {};
  3046. if (!u || !p || !p || p.id.indexOf(Il.LIST) !== 0 || !p.skipDefaultFontRender(u))
  3047. return;
  3048. const v = {
  3049. startX: c.startX + g,
  3050. endX: c.endX - f,
  3051. startY: c.startY + C2,
  3052. endY: c.endY - R
  3053. }, w = v.endX - v.startX, I = v.endY - v.startY, V3 = this._ensureMap(s), _ = this._generateKey(a, i), S = p.getListWithColor(u), m2 = ne(l), y = `${m2 != null ? m2 : ""}`, P = S.find((x) => x.label === y);
  3054. let { tb: F3, vt: T, ht: E, pd: A } = r || {};
  3055. if (F3 = F3 != null ? F3 : xn.WRAP, T = T != null ? T : hn.BOTTOM, E = E != null ? E : gt.ht, A = A != null ? A : gt.pd, u.renderMode === Cl.ARROW) {
  3056. const { l: x = gt.pd.l, t: j2 = gt.pd.t, r: N2 = gt.pd.r, b: H2 = gt.pd.b } = A, X = w - x - N2 - he - 4, { documentSkeleton: k, documents: K2, docModel: q5 } = mt(y, this._localeService, r);
  3057. F3 === xn.WRAP && q5.updateDocumentDataPageSize(Math.max(X, 1)), k.calculate(), k.getActualSize();
  3058. const ee2 = ee(k), { height: te, width: re2 } = ee2, { paddingTop: ae, paddingLeft: se2 } = Yn(X, I - j2 - H2, re2, te, T, E, true);
  3059. this._drawDownIcon(e, v, w, I, te, T, A), e.save(), e.translateWithPrecision(v.startX + x, v.startY + j2), e.beginPath(), e.rect(0, 0, w - x - N2, I - j2 - H2), e.clip(), e.translateWithPrecision(0, ae), e.save(), e.translateWithPrecision(Oe, 0), e.beginPath(), e.rect(0, 0, X, te), e.clip(), K2.render(e), e.translateWithPrecision(se2, 0), e.restore(), e.restore(), V3.set(_, {
  3060. left: v.endX + x + o.rowHeaderWidth - he,
  3061. top: v.startY + j2 + o.columnHeaderHeight,
  3062. width: he,
  3063. height: I - j2 - H2
  3064. });
  3065. } else {
  3066. e.save(), e.translateWithPrecision(v.startX, v.startY), e.beginPath(), e.rect(0, 0, w, I), e.clip();
  3067. const x = w - pe2 * 2 - Oe - he - 4, { documentSkeleton: j2, documents: N2, docModel: H2 } = mt(y, this._localeService, r);
  3068. F3 === xn.WRAP && H2.updateDocumentDataPageSize(Math.max(x, 1)), j2.calculate();
  3069. const X = ee(j2), { height: k, width: K2 } = X, { paddingTop: q5, paddingLeft: ee2 } = Yn(x, I, K2, k, T, E);
  3070. e.translateWithPrecision(pe2, q5);
  3071. const te = Math.max(w - pe2 * 2, 1), re2 = k;
  3072. A1.drawWith(e, {
  3073. width: te,
  3074. height: re2,
  3075. fill: (P == null ? void 0 : P.color) || Te3,
  3076. radius: Xt2
  3077. }), e.save(), e.translateWithPrecision(Oe, 0), e.beginPath(), e.rect(0, 0, x, k), e.clip(), e.translateWithPrecision(ee2, 0), N2.render(e), e.restore(), e.translateWithPrecision(x + Oe + 4, (k - ft) / 2), e.fillStyle = ds, e.fill(Hn), e.restore(), V3.set(_, {
  3078. left: v.startX + pe2 + o.rowHeaderWidth,
  3079. top: v.startY + q5 + o.columnHeaderHeight,
  3080. width: te,
  3081. height: re2
  3082. });
  3083. }
  3084. }
  3085. calcCellAutoHeight(e) {
  3086. const { primaryWithCoord: t, style: o, data: n, row: a, col: i } = e, r = t.isMergedMainCell ? t.mergeInfo : t, l = n == null ? void 0 : n.fontRenderExtension, { leftOffset: s = 0, rightOffset: c = 0, topOffset: u = 0, downOffset: p = 0 } = l || {}, d = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, a, i);
  3087. if (!d || d.renderMode === Cl.TEXT)
  3088. return;
  3089. const g = {
  3090. startX: r.startX + s,
  3091. endX: r.endX - c,
  3092. startY: r.startY + u,
  3093. endY: r.endY - p
  3094. }, f = g.endX - g.startX, C2 = ne(n), R = `${C2 != null ? C2 : ""}`;
  3095. let { tb: v, pd: w } = o || {};
  3096. const { t: I = gt.pd.t, b: V3 = gt.pd.b } = w != null ? w : {};
  3097. if (v = v != null ? v : xn.WRAP, d.renderMode === Cl.ARROW) {
  3098. const _ = f - he, { documentSkeleton: S, docModel: m2 } = mt(R, this._localeService, o);
  3099. v === xn.WRAP && m2.updateDocumentDataPageSize(Math.max(_, 1)), S.calculate(), S.getActualSize();
  3100. const y = ee(S), { height: P } = y;
  3101. return P + I + V3 + ke3 * 2;
  3102. } else {
  3103. const _ = f - pe2 * 2 - Oe - he, { documentSkeleton: S, docModel: m2 } = Bo(R, this._localeService, o);
  3104. v === xn.WRAP && m2.updateDocumentDataPageSize(Math.max(_, 1)), S.calculate();
  3105. const y = ee(S), {
  3106. height: P
  3107. } = y;
  3108. return P + ke3 * 2;
  3109. }
  3110. }
  3111. calcCellAutoWidth(e) {
  3112. const { primaryWithCoord: t, style: o, data: n, row: a, col: i } = e, r = t.isMergedMainCell ? t.mergeInfo : t, l = n == null ? void 0 : n.fontRenderExtension, { leftOffset: s = 0, rightOffset: c = 0, topOffset: u = 0, downOffset: p = 0 } = l || {}, d = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, a, i);
  3113. if (!d || d.renderMode === Cl.TEXT)
  3114. return;
  3115. const g = {
  3116. startX: r.startX + s,
  3117. endX: r.endX - c,
  3118. startY: r.startY + u,
  3119. endY: r.endY - p
  3120. }, f = g.endX - g.startX, C2 = ne(n), R = `${C2 != null ? C2 : ""}`;
  3121. let { tb: v, pd: w } = o || {};
  3122. const { l: I = gt.pd.l, r: V3 = gt.pd.r } = w != null ? w : {};
  3123. v = v != null ? v : xn.WRAP;
  3124. let _ = pe2 * 2 + he;
  3125. switch (d.renderMode) {
  3126. case Cl.ARROW:
  3127. _ = he + pe2 * 2 + V3 + I;
  3128. break;
  3129. case Cl.CUSTOM:
  3130. _ = he + pe2 * 2 + Oe * 2 + V3 + I + Xt2 / 2 + 1;
  3131. break;
  3132. default:
  3133. _ = he + pe2 * 2 + Oe * 2 + V3 + I + Xt2 / 2 + 1;
  3134. }
  3135. const S = f - _, { documentSkeleton: m2, docModel: y } = mt(R, this._localeService, o);
  3136. return v === xn.WRAP && y.updateDocumentDataPageSize(Math.max(S, 1)), m2.calculate(), m2.getActualSize(), ee(m2).width + _;
  3137. }
  3138. isHit(e, t) {
  3139. const { subUnitId: o, row: n, col: a } = t, r = this._ensureMap(o).get(this._generateKey(n, a)), l = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, n, a);
  3140. if (!l || !r || l.renderMode === Cl.TEXT)
  3141. return false;
  3142. const { top: s, left: c, width: u, height: p } = r, { x: d, y: g } = e;
  3143. return d >= c && d <= c + u && g >= s && g <= s + p;
  3144. }
  3145. onPointerDown(e, t) {
  3146. if (t.button === 2)
  3147. return;
  3148. const { unitId: o, subUnitId: n, row: a, col: i } = e, r = {
  3149. unitId: o,
  3150. subUnitId: n,
  3151. row: a,
  3152. column: i
  3153. };
  3154. this._commandService.executeCommand(Tt.id, r);
  3155. }
  3156. onPointerEnter(e, t) {
  3157. var o, n;
  3158. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Fe.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(p1.POINTER);
  3159. }
  3160. onPointerLeave(e, t) {
  3161. var o, n;
  3162. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Fe.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(p1.DEFAULT);
  3163. }
  3164. };
  3165. hn2 = ls([
  3166. pt(0, ot(Vr)),
  3167. pt(1, Pt),
  3168. pt(2, ot(Yx)),
  3169. pt(3, ot(F2))
  3170. ], hn2);
  3171. var us = class extends me3 {
  3172. constructor() {
  3173. super(...arguments);
  3174. M2(this, "id", Il.LIST);
  3175. M2(this, "canvasRender", this.injector.createInstance(hn2));
  3176. M2(this, "dropdown", yn);
  3177. M2(this, "optionsInput", Mt.componentKey);
  3178. M2(this, "formulaInput", Mn);
  3179. }
  3180. };
  3181. var hs = class extends me3 {
  3182. constructor() {
  3183. super(...arguments);
  3184. M2(this, "id", Il.TEXT_LENGTH);
  3185. M2(this, "formulaInput", xt);
  3186. }
  3187. };
  3188. var ps = class extends me3 {
  3189. constructor() {
  3190. super(...arguments);
  3191. M2(this, "id", Il.WHOLE);
  3192. M2(this, "formulaInput", xt);
  3193. }
  3194. };
  3195. var fs = Object.defineProperty;
  3196. var ms = Object.getOwnPropertyDescriptor;
  3197. var gs = (e, t, o, n) => {
  3198. for (var a = n > 1 ? void 0 : n ? ms(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  3199. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  3200. return n && a && fs(t, o, a), a;
  3201. };
  3202. var zt = (e, t) => (o, n) => t(o, n, e);
  3203. var qe = class extends J0 {
  3204. constructor(e, t, o) {
  3205. super(), this._injector = e, this._componentManger = t, this._dataValidatorRegistryService = o, this._initComponents(), this._registerValidatorViews();
  3206. }
  3207. _initComponents() {
  3208. [
  3209. [Lo, wo],
  3210. [Dt, Ji],
  3211. [Mo, vi2],
  3212. [yn, Li],
  3213. [Oo, ni],
  3214. [Mt.componentKey, Mt],
  3215. [bt.componentKey, bt],
  3216. ...jr
  3217. ].forEach(([e, t]) => {
  3218. this.disposeWithMe(this._componentManger.register(
  3219. e,
  3220. t
  3221. ));
  3222. });
  3223. }
  3224. _registerValidatorViews() {
  3225. [
  3226. Zr,
  3227. ps,
  3228. hs,
  3229. Gr,
  3230. Xr,
  3231. us,
  3232. is,
  3233. zr
  3234. ].forEach((e) => {
  3235. const t = this._injector.createInstance(e), o = this._dataValidatorRegistryService.getValidatorItem(t.id);
  3236. o && (o.formulaInput = t.formulaInput, o.canvasRender = t.canvasRender, o.dropdown = t.dropdown, o.optionsInput = t.optionsInput);
  3237. });
  3238. }
  3239. };
  3240. qe = gs([
  3241. zt(0, ot(Ot)),
  3242. zt(1, ot(n1)),
  3243. zt(2, ot(j))
  3244. ], qe);
  3245. var vs = Object.defineProperty;
  3246. var _s2 = Object.getOwnPropertyDescriptor;
  3247. var Ss = (e, t, o, n) => {
  3248. for (var a = n > 1 ? void 0 : n ? _s2(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  3249. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  3250. return n && a && vs(t, o, a), a;
  3251. };
  3252. var Kt = (e, t) => (o, n) => t(o, n, e);
  3253. var Cs = "SHEET_DATA_VALIDATION_UI_PLUGIN";
  3254. var gt2;
  3255. var Xn = (gt2 = class extends Ra {
  3256. constructor(e = Vt, t, o, n) {
  3257. super(), this._config = e, this._injector = t, this._commandService = o, this._configService = n;
  3258. const { menu: a, ...i } = nu(
  3259. {},
  3260. Vt,
  3261. this._config
  3262. );
  3263. a && this._configService.setConfig("menu", a, { merge: true }), this._configService.setConfig(Vn2, i);
  3264. }
  3265. onStarting() {
  3266. [
  3267. [fe],
  3268. [Ie],
  3269. [lt],
  3270. [ze],
  3271. [Ze2],
  3272. [Ge],
  3273. [Ke],
  3274. [st2],
  3275. [qe]
  3276. ].forEach((e) => {
  3277. this._injector.add(e);
  3278. }), [
  3279. At,
  3280. Tt,
  3281. Eo,
  3282. Dn,
  3283. Ue,
  3284. bo
  3285. ].forEach((e) => {
  3286. this._commandService.registerCommand(e);
  3287. });
  3288. }
  3289. onReady() {
  3290. this._injector.get(Ke), this._injector.get(Ge), this._injector.get(st2), this._injector.get(lt), this._injector.get(Yx).registerRenderModule(
  3291. Fe.UNIVER_SHEET,
  3292. [yt]
  3293. );
  3294. }
  3295. onRendered() {
  3296. this._injector.get(qe), this._injector.get(Ze2);
  3297. }
  3298. onSteady() {
  3299. this._injector.get(ze);
  3300. }
  3301. }, M2(gt2, "pluginName", Cs), M2(gt2, "type", Fe.UNIVER_SHEET), gt2);
  3302. Xn = Ss([
  3303. Kt(1, ot(Ot)),
  3304. Kt(2, Pt),
  3305. Kt(3, SE)
  3306. ], Xn);
  3307. var Is = Object.defineProperty;
  3308. var ws2 = Object.getOwnPropertyDescriptor;
  3309. var Rs = (e, t, o, n) => {
  3310. for (var a = n > 1 ? void 0 : n ? ws2(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  3311. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  3312. return n && a && Is(t, o, a), a;
  3313. };
  3314. var Gt = (e, t) => (o, n) => t(o, n, e);
  3315. var Ds = "SHEET_DATA_VALIDATION_UI_PLUGIN";
  3316. var vt;
  3317. var zn = (vt = class extends Ra {
  3318. constructor(e = Vt, t, o, n) {
  3319. super(), this._config = e, this._injector = t, this._commandService = o, this._configService = n;
  3320. const { menu: a, ...i } = nu(
  3321. {},
  3322. Vt,
  3323. this._config
  3324. );
  3325. a && this._configService.setConfig("menu", a, { merge: true }), this._configService.setConfig(Vn2, i);
  3326. }
  3327. onStarting() {
  3328. [
  3329. [fe],
  3330. [Ie],
  3331. [lt],
  3332. [ze],
  3333. [Ze2],
  3334. [Ge],
  3335. [Ke],
  3336. [qe]
  3337. ].forEach((e) => {
  3338. this._injector.add(e);
  3339. }), [
  3340. At,
  3341. Tt,
  3342. Eo,
  3343. Dn,
  3344. Ue,
  3345. bo
  3346. ].forEach((e) => {
  3347. this._commandService.registerCommand(e);
  3348. });
  3349. }
  3350. onReady() {
  3351. this._injector.get(Ke), this._injector.get(Ge), this._injector.get(Yx).registerRenderModule(
  3352. Fe.UNIVER_SHEET,
  3353. [yt]
  3354. );
  3355. }
  3356. onRendered() {
  3357. this._injector.get(qe), this._injector.get(Ze2);
  3358. }
  3359. onSteady() {
  3360. this._injector.get(ze);
  3361. }
  3362. }, M2(vt, "pluginName", Ds), M2(vt, "type", Fe.UNIVER_SHEET), vt);
  3363. zn = Rs([
  3364. Gt(1, ot(Ot)),
  3365. Gt(2, Pt),
  3366. Gt(3, SE)
  3367. ], zn);
  3368. export {
  3369. Oo as DATE_DROPDOWN_KEY,
  3370. yn as LIST_DROPDOWN_KEY,
  3371. zn as UniverSheetsDataValidationMobileUIPlugin,
  3372. Xn as UniverSheetsDataValidationUIPlugin
  3373. };
  3374. /*! Bundled license information:
  3375. @univerjs/sheets-data-validation-ui/lib/es/index.js:
  3376. (**
  3377. * @license React
  3378. * react-jsx-runtime.production.min.js
  3379. *
  3380. * Copyright (c) Facebook, Inc. and its affiliates.
  3381. *
  3382. * This source code is licensed under the MIT license found in the
  3383. * LICENSE file in the root directory of this source tree.
  3384. *)
  3385. */
  3386. //# sourceMappingURL=@univerjs_sheets-data-validation-ui.js.map