@univerjs/sheets-data-validation-ui 0.5.0-alpha.0 → 0.5.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,14 @@
1
1
  import { ICellRenderContext, ICommandService, ThemeService } from '@univerjs/core';
2
2
  import { IBaseDataValidationWidget } from '@univerjs/data-validation';
3
- import { IMouseEvent, IPointerEvent, UniverRenderingContext2D } from '@univerjs/engine-render';
3
+ import { IMouseEvent, IPointerEvent, UniverRenderingContext2D, IRenderManagerService } from '@univerjs/engine-render';
4
4
  import { DataValidationFormulaService } from '@univerjs/sheets-data-validation';
5
5
  export declare class CheckboxRender implements IBaseDataValidationWidget {
6
6
  private readonly _commandService;
7
7
  private readonly _formulaService;
8
8
  private readonly _themeService;
9
+ private readonly _renderManagerService;
9
10
  private _calc;
10
- constructor(_commandService: ICommandService, _formulaService: DataValidationFormulaService, _themeService: ThemeService);
11
+ constructor(_commandService: ICommandService, _formulaService: DataValidationFormulaService, _themeService: ThemeService, _renderManagerService: IRenderManagerService);
11
12
  calcCellAutoHeight(info: ICellRenderContext): number | undefined;
12
13
  calcCellAutoWidth(info: ICellRenderContext): number | undefined;
13
14
  private _parseFormula;
@@ -17,4 +18,6 @@ export declare class CheckboxRender implements IBaseDataValidationWidget {
17
18
  y: number;
18
19
  }, info: ICellRenderContext): boolean;
19
20
  onPointerDown(info: ICellRenderContext, evt: IPointerEvent | IMouseEvent): Promise<void>;
21
+ onPointerEnter(info: ICellRenderContext, evt: IPointerEvent | IMouseEvent): void;
22
+ onPointerLeave(info: ICellRenderContext, evt: IPointerEvent | IMouseEvent): void;
20
23
  }
@@ -1,11 +1,12 @@
1
1
  import { ICellRenderContext, ICommandService } from '@univerjs/core';
2
2
  import { IBaseDataValidationWidget } from '@univerjs/data-validation';
3
- import { IMouseEvent, IPointerEvent, Spreadsheet, SpreadsheetSkeleton, UniverRenderingContext2D } from '@univerjs/engine-render';
3
+ import { IMouseEvent, IPointerEvent, Spreadsheet, SpreadsheetSkeleton, UniverRenderingContext2D, IRenderManagerService } from '@univerjs/engine-render';
4
4
  export declare class DropdownMultipleWidget implements IBaseDataValidationWidget {
5
5
  private readonly _commandService;
6
+ private readonly _renderManagerService;
6
7
  zIndex?: number | undefined;
7
8
  private _dropdownInfoMap;
8
- constructor(_commandService: ICommandService);
9
+ constructor(_commandService: ICommandService, _renderManagerService: IRenderManagerService);
9
10
  private _ensureMap;
10
11
  private _generateKey;
11
12
  private _drawDownIcon;
@@ -17,4 +18,6 @@ export declare class DropdownMultipleWidget implements IBaseDataValidationWidget
17
18
  y: number;
18
19
  }, info: ICellRenderContext): boolean;
19
20
  onPointerDown(info: ICellRenderContext, evt: IPointerEvent | IMouseEvent): void;
21
+ onPointerEnter(info: ICellRenderContext, evt: IPointerEvent | IMouseEvent): void;
22
+ onPointerLeave(info: ICellRenderContext, evt: IPointerEvent | IMouseEvent): void;
20
23
  }
@@ -1,6 +1,6 @@
1
1
  import { ICellRenderContext, ICommandService, LocaleService } from '@univerjs/core';
2
2
  import { IBaseDataValidationWidget } from '@univerjs/data-validation';
3
- import { IMouseEvent, IPointerEvent, SpreadsheetSkeleton, UniverRenderingContext2D } from '@univerjs/engine-render';
3
+ import { IMouseEvent, IPointerEvent, SpreadsheetSkeleton, UniverRenderingContext2D, IRenderManagerService } from '@univerjs/engine-render';
4
4
  export interface IDropdownInfo {
5
5
  top: number;
6
6
  left: number;
@@ -10,11 +10,10 @@ export interface IDropdownInfo {
10
10
  export declare class DropdownWidget implements IBaseDataValidationWidget {
11
11
  private readonly _localeService;
12
12
  private readonly _commandService;
13
+ private readonly _renderManagerService;
13
14
  private _dropdownInfoMap;
14
- constructor(_localeService: LocaleService, _commandService: ICommandService);
15
+ constructor(_localeService: LocaleService, _commandService: ICommandService, _renderManagerService: IRenderManagerService);
15
16
  zIndex?: number | undefined;
16
- onPointerEnter?: ((info: ICellRenderContext) => void) | undefined;
17
- onPointerLeave?: ((info: ICellRenderContext) => void) | undefined;
18
17
  private _ensureMap;
19
18
  private _generateKey;
20
19
  private _drawDownIcon;
@@ -26,4 +25,6 @@ export declare class DropdownWidget implements IBaseDataValidationWidget {
26
25
  y: number;
27
26
  }, info: ICellRenderContext): boolean;
28
27
  onPointerDown(info: ICellRenderContext, evt: IPointerEvent | IMouseEvent): void;
28
+ onPointerEnter(info: ICellRenderContext, evt: IPointerEvent | IMouseEvent): void;
29
+ onPointerLeave(info: ICellRenderContext, evt: IPointerEvent | IMouseEvent): void;
29
30
  }
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(q,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/data-validation"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","react","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],b):(q=typeof globalThis<"u"?globalThis:q||self,b(q.UniverSheetsDataValidationUi={},q.React,q.UniverCore,q.UniverDesign,q.UniverEngineRender,q.UniverSheets,q.UniverSheetsDataValidation,q.UniverSheetsNumfmt,q.UniverSheetsUi,q.UniverUi,q.UniverDataValidation,q.UniverDocs,q.rxjs,q.UniverEngineFormula,q.UniverSheetsFormulaUi))})(this,function(q,b,o,U,at,Q,x,an,K,tt,ot,on,dt,Qt,te){"use strict";var hi=Object.defineProperty;var fi=(q,b,o)=>b in q?hi(q,b,{enumerable:!0,configurable:!0,writable:!0,value:o}):q[b]=o;var B=(q,b,o)=>fi(q,typeof b!="symbol"?b+"":b,o);var qt,Jt;var De=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function we(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ye={exports:{}},At={};/**
1
+ (function(H,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/data-validation"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","react","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],g):(H=typeof globalThis<"u"?globalThis:H||self,g(H.UniverSheetsDataValidationUi={},H.React,H.UniverCore,H.UniverDesign,H.UniverEngineRender,H.UniverSheets,H.UniverSheetsDataValidation,H.UniverSheetsNumfmt,H.UniverSheetsUi,H.UniverUi,H.UniverDataValidation,H.UniverDocs,H.rxjs,H.UniverEngineFormula,H.UniverSheetsFormulaUi))})(this,function(H,g,o,T,B,X,R,Jt,N,z,Q,Qt,se,Je,Qe){"use strict";var ii=Object.defineProperty;var oi=(H,g,o)=>g in H?ii(H,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):H[g]=o;var L=(H,g,o)=>oi(H,typeof g!="symbol"?g+"":g,o);var qe,Ze;var Ct={exports:{}},je={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var rn=b,sn=Symbol.for("react.element"),ln=Symbol.for("react.fragment"),dn=Object.prototype.hasOwnProperty,cn=rn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,un={key:!0,ref:!0,__self:!0,__source:!0};function Me(t,e,a){var n,i={},r=null,s=null;a!==void 0&&(r=""+a),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)dn.call(e,n)&&!un.hasOwnProperty(n)&&(i[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)i[n]===void 0&&(i[n]=e[n]);return{$$typeof:sn,type:t,key:r,ref:s,props:i,_owner:cn.current}}At.Fragment=ln,At.jsx=Me,At.jsxs=Me,ye.exports=At;var m=ye.exports,Ve={exports:{}};(function(t,e){(function(a,n){t.exports=n()})(De,function(){var a=1e3,n=6e4,i=36e5,r="millisecond",s="second",d="minute",l="hour",u="day",h="week",f="month",c="quarter",C="year",v="date",p="Invalid Date",y=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,V=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,E={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(D){var S=["th","st","nd","rd"],g=D%100;return"["+D+(S[(g-20)%10]||S[g]||S[0])+"]"}},I=function(D,S,g){var w=String(D);return!w||w.length>=S?D:""+Array(S+1-w.length).join(g)+D},F={s:I,z:function(D){var S=-D.utcOffset(),g=Math.abs(S),w=Math.floor(g/60),_=g%60;return(S<=0?"+":"-")+I(w,2,"0")+":"+I(_,2,"0")},m:function D(S,g){if(S.date()<g.date())return-D(g,S);var w=12*(g.year()-S.year())+(g.month()-S.month()),_=S.clone().add(w,f),A=g-_<0,O=S.clone().add(w+(A?-1:1),f);return+(-(w+(g-_)/(A?_-O:O-_))||0)},a:function(D){return D<0?Math.ceil(D)||0:Math.floor(D)},p:function(D){return{M:f,y:C,w:h,d:u,D:v,h:l,m:d,s,ms:r,Q:c}[D]||String(D||"").toLowerCase().replace(/s$/,"")},u:function(D){return D===void 0}},L="en",P={};P[L]=E;var M="$isDayjsObject",j=function(D){return D instanceof H||!(!D||!D[M])},k=function D(S,g,w){var _;if(!S)return L;if(typeof S=="string"){var A=S.toLowerCase();P[A]&&(_=A),g&&(P[A]=g,_=A);var O=S.split("-");if(!_&&O.length>1)return D(O[0])}else{var Y=S.name;P[Y]=S,_=Y}return!w&&_&&(L=_),_||!w&&L},N=function(D,S){if(j(D))return D.clone();var g=typeof S=="object"?S:{};return g.date=D,g.args=arguments,new H(g)},R=F;R.l=k,R.i=j,R.w=function(D,S){return N(D,{locale:S.$L,utc:S.$u,x:S.$x,$offset:S.$offset})};var H=function(){function D(g){this.$L=k(g.locale,null,!0),this.parse(g),this.$x=this.$x||g.x||{},this[M]=!0}var S=D.prototype;return S.parse=function(g){this.$d=function(w){var _=w.date,A=w.utc;if(_===null)return new Date(NaN);if(R.u(_))return new Date;if(_ instanceof Date)return new Date(_);if(typeof _=="string"&&!/Z$/i.test(_)){var O=_.match(y);if(O){var Y=O[2]-1||0,G=(O[7]||"0").substring(0,3);return A?new Date(Date.UTC(O[1],Y,O[3]||1,O[4]||0,O[5]||0,O[6]||0,G)):new Date(O[1],Y,O[3]||1,O[4]||0,O[5]||0,O[6]||0,G)}}return new Date(_)}(g),this.init()},S.init=function(){var g=this.$d;this.$y=g.getFullYear(),this.$M=g.getMonth(),this.$D=g.getDate(),this.$W=g.getDay(),this.$H=g.getHours(),this.$m=g.getMinutes(),this.$s=g.getSeconds(),this.$ms=g.getMilliseconds()},S.$utils=function(){return R},S.isValid=function(){return this.$d.toString()!==p},S.isSame=function(g,w){var _=N(g);return this.startOf(w)<=_&&_<=this.endOf(w)},S.isAfter=function(g,w){return N(g)<this.startOf(w)},S.isBefore=function(g,w){return this.endOf(w)<N(g)},S.$g=function(g,w,_){return R.u(g)?this[w]:this.set(_,g)},S.unix=function(){return Math.floor(this.valueOf()/1e3)},S.valueOf=function(){return this.$d.getTime()},S.startOf=function(g,w){var _=this,A=!!R.u(w)||w,O=R.p(g),Y=function(z,W){var Z=R.w(_.$u?Date.UTC(_.$y,W,z):new Date(_.$y,W,z),_);return A?Z:Z.endOf(u)},G=function(z,W){return R.w(_.toDate()[z].apply(_.toDate("s"),(A?[0,0,0,0]:[23,59,59,999]).slice(W)),_)},J=this.$W,et=this.$M,nt=this.$D,it="set"+(this.$u?"UTC":"");switch(O){case C:return A?Y(1,0):Y(31,11);case f:return A?Y(1,et):Y(0,et+1);case h:var $=this.$locale().weekStart||0,T=(J<$?J+7:J)-$;return Y(A?nt-T:nt+(6-T),et);case u:case v:return G(it+"Hours",0);case l:return G(it+"Minutes",1);case d:return G(it+"Seconds",2);case s:return G(it+"Milliseconds",3);default:return this.clone()}},S.endOf=function(g){return this.startOf(g,!1)},S.$set=function(g,w){var _,A=R.p(g),O="set"+(this.$u?"UTC":""),Y=(_={},_[u]=O+"Date",_[v]=O+"Date",_[f]=O+"Month",_[C]=O+"FullYear",_[l]=O+"Hours",_[d]=O+"Minutes",_[s]=O+"Seconds",_[r]=O+"Milliseconds",_)[A],G=A===u?this.$D+(w-this.$W):w;if(A===f||A===C){var J=this.clone().set(v,1);J.$d[Y](G),J.init(),this.$d=J.set(v,Math.min(this.$D,J.daysInMonth())).$d}else Y&&this.$d[Y](G);return this.init(),this},S.set=function(g,w){return this.clone().$set(g,w)},S.get=function(g){return this[R.p(g)]()},S.add=function(g,w){var _,A=this;g=Number(g);var O=R.p(w),Y=function(et){var nt=N(A);return R.w(nt.date(nt.date()+Math.round(et*g)),A)};if(O===f)return this.set(f,this.$M+g);if(O===C)return this.set(C,this.$y+g);if(O===u)return Y(1);if(O===h)return Y(7);var G=(_={},_[d]=n,_[l]=i,_[s]=a,_)[O]||1,J=this.$d.getTime()+g*G;return R.w(J,this)},S.subtract=function(g,w){return this.add(-1*g,w)},S.format=function(g){var w=this,_=this.$locale();if(!this.isValid())return _.invalidDate||p;var A=g||"YYYY-MM-DDTHH:mm:ssZ",O=R.z(this),Y=this.$H,G=this.$m,J=this.$M,et=_.weekdays,nt=_.months,it=_.meridiem,$=function(W,Z,lt,Ot){return W&&(W[Z]||W(w,A))||lt[Z].slice(0,Ot)},T=function(W){return R.s(Y%12||12,W,"0")},z=it||function(W,Z,lt){var Ot=W<12?"AM":"PM";return lt?Ot.toLowerCase():Ot};return A.replace(V,function(W,Z){return Z||function(lt){switch(lt){case"YY":return String(w.$y).slice(-2);case"YYYY":return R.s(w.$y,4,"0");case"M":return J+1;case"MM":return R.s(J+1,2,"0");case"MMM":return $(_.monthsShort,J,nt,3);case"MMMM":return $(nt,J);case"D":return w.$D;case"DD":return R.s(w.$D,2,"0");case"d":return String(w.$W);case"dd":return $(_.weekdaysMin,w.$W,et,2);case"ddd":return $(_.weekdaysShort,w.$W,et,3);case"dddd":return et[w.$W];case"H":return String(Y);case"HH":return R.s(Y,2,"0");case"h":return T(1);case"hh":return T(2);case"a":return z(Y,G,!0);case"A":return z(Y,G,!1);case"m":return String(G);case"mm":return R.s(G,2,"0");case"s":return String(w.$s);case"ss":return R.s(w.$s,2,"0");case"SSS":return R.s(w.$ms,3,"0");case"Z":return O}return null}(W)||O.replace(":","")})},S.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},S.diff=function(g,w,_){var A,O=this,Y=R.p(w),G=N(g),J=(G.utcOffset()-this.utcOffset())*n,et=this-G,nt=function(){return R.m(O,G)};switch(Y){case C:A=nt()/12;break;case f:A=nt();break;case c:A=nt()/3;break;case h:A=(et-J)/6048e5;break;case u:A=(et-J)/864e5;break;case l:A=et/i;break;case d:A=et/n;break;case s:A=et/a;break;default:A=et}return _?A:R.a(A)},S.daysInMonth=function(){return this.endOf(f).$D},S.$locale=function(){return P[this.$L]},S.locale=function(g,w){if(!g)return this.$L;var _=this.clone(),A=k(g,w,!0);return A&&(_.$L=A),_},S.clone=function(){return R.w(this.$d,this)},S.toDate=function(){return new Date(this.valueOf())},S.toJSON=function(){return this.isValid()?this.toISOString():null},S.toISOString=function(){return this.$d.toISOString()},S.toString=function(){return this.$d.toUTCString()},D}(),X=H.prototype;return N.prototype=X,[["$ms",r],["$s",s],["$m",d],["$H",l],["$W",u],["$M",f],["$y",C],["$D",v]].forEach(function(D){X[D[1]]=function(S){return this.$g(S,D[0],D[1])}}),N.extend=function(D,S){return D.$i||(D(S,H,N),D.$i=!0),N},N.locale=k,N.isDayjs=j,N.unix=function(D){return N(1e3*D)},N.en=P[L],N.Ls=P,N.p={},N})})(Ve);var hn=Ve.exports;const $t=we(hn);var be={exports:{}};(function(t,e){(function(a,n){t.exports=n()})(De,function(){var a="minute",n=/[+-]\d\d(?::?\d\d)?/g,i=/([+-]|\d\d)/g;return function(r,s,d){var l=s.prototype;d.utc=function(p){var y={date:p,utc:!0,args:arguments};return new s(y)},l.utc=function(p){var y=d(this.toDate(),{locale:this.$L,utc:!0});return p?y.add(this.utcOffset(),a):y},l.local=function(){return d(this.toDate(),{locale:this.$L,utc:!1})};var u=l.parse;l.parse=function(p){p.utc&&(this.$u=!0),this.$utils().u(p.$offset)||(this.$offset=p.$offset),u.call(this,p)};var h=l.init;l.init=function(){if(this.$u){var p=this.$d;this.$y=p.getUTCFullYear(),this.$M=p.getUTCMonth(),this.$D=p.getUTCDate(),this.$W=p.getUTCDay(),this.$H=p.getUTCHours(),this.$m=p.getUTCMinutes(),this.$s=p.getUTCSeconds(),this.$ms=p.getUTCMilliseconds()}else h.call(this)};var f=l.utcOffset;l.utcOffset=function(p,y){var V=this.$utils().u;if(V(p))return this.$u?0:V(this.$offset)?f.call(this):this.$offset;if(typeof p=="string"&&(p=function(L){L===void 0&&(L="");var P=L.match(n);if(!P)return null;var M=(""+P[0]).match(i)||["-",0,0],j=M[0],k=60*+M[1]+ +M[2];return k===0?0:j==="+"?k:-k}(p),p===null))return this;var E=Math.abs(p)<=16?60*p:p,I=this;if(y)return I.$offset=E,I.$u=p===0,I;if(p!==0){var F=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(I=this.local().add(E+F,a)).$offset=E,I.$x.$localOffset=F}else I=this.utc();return I};var c=l.format;l.format=function(p){var y=p||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,y)},l.valueOf=function(){var p=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*p},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var C=l.toDate;l.toDate=function(p){return p==="s"&&this.$offset?d(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():C.call(this)};var v=l.diff;l.diff=function(p,y,V){if(p&&this.$u===p.$u)return v.call(this,p,y,V);var E=this.local(),I=d(p).local();return v.call(E,I,y,V)}}})})(be);var fn=be.exports;const pn=we(fn);var mn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,gn=(t,e,a,n)=>{for(var i=n>1?void 0:n?vn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&mn(e,a,i),i},Tt=(t,e)=>(a,n)=>e(a,n,t);let Lt=class extends o.Disposable{constructor(t,e,a,n,i){super(),this._sheetInterceptorService=t,this._dataValidationModel=e,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(Q.AFTER_CELL_EDIT_ASYNC,{handler:async(t,e,a)=>{var p;const n=await t,{worksheet:i,row:r,col:s,unitId:d,subUnitId:l,workbook:u}=e,h=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),f=h?this._dataValidationModel.getRuleById(d,l,h):void 0;if(!f||f.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(f.type);if(!c||await c.validator({value:x.getCellValueOrigin(n),interceptValue:x.getCellValueOrigin((p=e==null?void 0:e.origin)!=null?p:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:i,workbook:u,t:n==null?void 0:n.t},f))return a(Promise.resolve(n));const v=i.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(f)},footer:{title:b.createElement(U.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(v))}})}showReject(t){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:t},footer:{title:b.createElement(U.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Lt=gn([Tt(0,o.Inject(Q.SheetInterceptorService)),Tt(1,o.Inject(x.SheetDataValidationModel)),Tt(2,o.Inject(ot.DataValidatorRegistryService)),Tt(3,tt.IDialogService),Tt(4,o.Inject(o.LocaleService))],Lt);const Ee={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"};$t.extend(pn);const Sn=t=>{if(t==null||typeof t=="boolean")return;if(typeof t=="number"||!Number.isNaN(+t))return $t(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(t)));const e=$t(t);if(e.isValid())return e};function _n(t){var P,M,j;const{location:e,hideFn:a}=t,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d,workbook:l}=e,u=o.useDependency(o.ICommandService),h=o.useDependency(Lt),f=n.getCell(i,r),c=(P=f==null?void 0:f.dataValidation)==null?void 0:P.rule,C=(M=f==null?void 0:f.dataValidation)==null?void 0:M.validator,v=x.getCellValueOrigin(n.getCellRaw(i,r)),p=Sn(v),[y,V]=b.useState(p),E=!!((j=c==null?void 0:c.bizInfo)!=null&&j.showTime),I=y&&y.isValid()?y:$t(),F=o.useDependency(o.LocaleService);if(!f||!c||!C)return;const L=async()=>{var S,g,w;if(!I)return;const N=I.format(E?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),R=(S=o.numfmt.parseDate(N))==null?void 0:S.v,H=l.getStyles().getStyleByCell(f),X=(w=(g=H==null?void 0:H.n)==null?void 0:g.pattern)!=null?w:"",D=an.getPatternType(X);c.errorStyle!==o.DataValidationErrorStyle.STOP||await C.validator({value:R,unitId:s,subUnitId:d,row:i,column:r,worksheet:n,workbook:l,interceptValue:N.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(a(),await u.executeCommand(K.SetCellEditVisibleOperation.id,{visible:!1,eventType:at.DeviceInputEventType.Keyboard,unitId:s,keycode:tt.KeyCode.ESC}),await u.executeCommand(Q.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:R,t:2,p:null,f:null,si:null,s:{n:{pattern:E?D==="datetime"?X:"yyyy-MM-dd hh:mm:ss":D==="date"?X:"yyyy-MM-dd"}}}})):h.showReject(C.getRuleFinalError(c))};return m.jsxs("div",{className:Ee.dvDateDropdown,children:[m.jsx(U.DatePanel,{defaultValue:I,pickerValue:I,showTime:E||void 0,onSelect:async k=>{V(k)},onPanelChange:k=>{V(k)},disabledDate:k=>!o.numfmt.parseDate(k.format("YYYY-MM-DD"))}),m.jsx("div",{className:Ee.dvDateDropdownBtns,children:m.jsx(U.Button,{size:"small",type:"primary",onClick:L,disabled:!I.isValid(),children:F.t("dataValidation.alert.ok")})})]})}var ct=function(){return ct=Object.assign||function(t){for(var e,a=1,n=arguments.length;a<n;a++){e=arguments[a];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},ct.apply(this,arguments)},In=function(t,e){var a={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(a[n[i]]=t[n[i]]);return a},vt=b.forwardRef(function(t,e){var a=t.icon,n=t.id,i=t.className,r=t.extend,s=In(t,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=b.useRef("_".concat(wn()));return Re(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},ct({ref:e,className:d},s),r)});function Re(t,e,a,n,i){return b.createElement(t.tag,ct(ct({key:e},Cn(t,a,i)),n),(Dn(t,a).children||[]).map(function(r,s){return Re(r,"".concat(e,"-").concat(t.tag,"-").concat(s),a,void 0,i)}))}function Cn(t,e,a){var n=ct({},t.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var i=e.defIds;return!i||i.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Dn(t,e){var a,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((a=t.children)===null||a===void 0)&&a.length)?ct(ct({},t),{children:t.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?ct(ct({},i),{attrs:ct(ct({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):t}function wn(){return Math.random().toString(36).substring(2,8)}vt.displayName="UniverIcon";var yn={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"}}]},Oe=b.forwardRef(function(t,e){return b.createElement(vt,Object.assign({},t,{id:"check-mark-single",ref:e,icon:yn}))});Oe.displayName="CheckMarkSingle";var Mn={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"}}]},Te=b.forwardRef(function(t,e){return b.createElement(vt,Object.assign({},t,{id:"data-validation-single",ref:e,icon:Mn}))});Te.displayName="DataValidationSingle";var Vn={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"}}]},ee=b.forwardRef(function(t,e){return b.createElement(vt,Object.assign({},t,{id:"delete-single",ref:e,icon:Vn}))});ee.displayName="DeleteSingle";var bn={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"}}]},Le=b.forwardRef(function(t,e){return b.createElement(vt,Object.assign({},t,{id:"increase-single",ref:e,icon:bn}))});Le.displayName="IncreaseSingle";var En={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"}}]},Pe=b.forwardRef(function(t,e){return b.createElement(vt,Object.assign({},t,{id:"more-down-single",ref:e,icon:En}))});Pe.displayName="MoreDownSingle";var Rn={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"}}]},je=b.forwardRef(function(t,e){return b.createElement(vt,Object.assign({},t,{id:"more-up-single",ref:e,icon:Rn}))});je.displayName="MoreUpSingle";var On={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"}}]}]},Ae=b.forwardRef(function(t,e){return b.createElement(vt,Object.assign({},t,{id:"sequence-single",ref:e,icon:On}))});Ae.displayName="SequenceSingle";var Tn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Pn=(t,e,a,n)=>{for(var i=n>1?void 0:n?Ln(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Tn(e,a,i),i},$e=(t,e)=>(a,n)=>e(a,n,t);let ht=class extends o.Disposable{constructor(e,a){super();B(this,"_open$",new dt.BehaviorSubject(!1));B(this,"open$",this._open$.pipe(dt.distinctUntilChanged()));B(this,"_activeRule");B(this,"_activeRule$",new dt.BehaviorSubject(void 0));B(this,"activeRule$",this._activeRule$.asObservable());B(this,"_closeDisposable",null);this._univerInstanceService=e,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(dt.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===ne&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var e;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(e=this._closeDisposable)==null||e.dispose()}open(){this._open$.next(!0)}close(){var e;this._open$.next(!1),(e=this._closeDisposable)==null||e.dispose()}setCloseDisposable(e){this._closeDisposable=o.toDisposable(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}};ht=Pn([$e(0,o.IUniverInstanceService),$e(1,tt.ISidebarService)],ht);function jn(){const t=o.useDependency(gt),e=tt.useObservable(t.activeDropdown$,t.activeDropdown),a=o.useDependency(tt.ComponentManager);if(!e)return null;const{location:n,componentKey:i}=e,r=a.get(i),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{t.hideDropdown()};return m.jsx(r,{location:n,hideFn:d},s)}const Fe="sheet.ui.dropdown";var An=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Fn=(t,e,a,n)=>{for(var i=n>1?void 0:n?$n(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&An(e,a,i),i},St=(t,e)=>(a,n)=>e(a,n,t);let gt=class extends o.Disposable{constructor(e,a,n,i,r,s,d){super();B(this,"_activeDropdown");B(this,"_activeDropdown$",new dt.Subject);B(this,"_currentPopup",null);B(this,"activeDropdown$",this._activeDropdown$.asObservable());B(this,"_zenVisible",!1);this._canvasPopupManagerService=e,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=i,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{this._zenVisible=e,e&&this.hideDropdown()}))}_getDropdownByCell(e,a,n,i){const r=e?this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(e=>{e&&e.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(e,a=!0){const{location:n}=e,{row:i,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=e,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(i,r,{componentKey:Fe,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const h=new o.DisposableCollection;h.add(u),h.add({dispose:()=>{var f,c;(c=(f=this._activeDropdown)==null?void 0:f.onHide)==null||c.call(f)}}),this._currentPopup=h}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(e,a,n,i,r){const s=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,i);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:i,unitId:e,subUnitId:a},componentKey:u.dropdown,onHide:r})}};gt=Fn([St(0,o.Inject(K.SheetCanvasPopManagerService)),St(1,o.IUniverInstanceService),St(2,o.Inject(ot.DataValidatorRegistryService)),St(3,tt.IZenZoneService),St(4,at.IRenderManagerService),St(5,o.Inject(x.SheetDataValidationModel)),St(6,o.Inject(Q.SheetsSelectionsService))],gt);const ne="DataValidationPanel",_t={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(t,e){if(!e)return!1;const{ruleId:a,isAdd:n}=e,i=t.get(ht),r=t.get(ot.DataValidationModel),s=t.get(o.IUniverInstanceService),d=t.get(tt.ISidebarService),l=Q.getSheetCommandTarget(s);if(!l)return!1;const{unitId:u,subUnitId:h}=l,f=a?r.getRuleById(u,h,a):void 0;i.open(),i.setActiveRule(f&&{unitId:u,subUnitId:h,rule:f});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:ne},width:312,onClose:()=>i.close()});return i.setCloseDisposable(c),!0}},ae={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(t){return t.get(ht).close(),!0}},xe={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(t){const e=t.get(o.ICommandService),a=t.get(ht);return a.open(),a.isOpen?e.executeCommand(ae.id):e.executeCommand(_t.id),!0}},Ft={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(t,e){if(!e)return!1;const a=t.get(gt),{unitId:n,subUnitId:i,row:r,column:s}=e,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===i&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,i,r,s),!0}},Ne={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(t,e){return e?(t.get(gt).hideDropdown(),!0):!1}},It="#ECECEC",ie="sheets-data-validation-ui.config",Ue={},mt={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},xn=t=>{var L,P;const{value:e,onChange:a,multiple:n,options:i,title:r,onEdit:s,style:d,filter:l,location:u}=t,h=o.useDependency(o.LocaleService),f=o.useDependency(o.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:C,col:v,unitId:p,subUnitId:y}=u,V=i.filter(M=>c?M.label.toLowerCase().includes(c):!0),E=(P=(L=f.getConfig(ie))==null?void 0:L.showEditOnDropdown)!=null?P:!0,I=o.useDependency(K.SheetPermissionInterceptorBaseController),F=b.useMemo(()=>I.permissionCheckWithRanges({workbookTypes:[Q.WorkbookEditablePermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint],worksheetTypes:[Q.WorksheetEditPermission]},[{startColumn:v,startRow:C,endColumn:v,endRow:C}],p,y),[I,v,C,p,y]);return m.jsxs("div",{className:mt.dvListDropdown,style:d,children:[m.jsx("div",{className:mt.dvListDropdownTitle,children:r}),m.jsx("div",{className:mt.dvListDropdownList,children:m.jsx(U.Scrollbar,{children:m.jsx("div",{className:mt.dvListDropdownListContainer,children:V.map((M,j)=>{const k=e.indexOf(M.value)>-1,N=()=>{let H;k?H=new Set(e.filter(D=>D!==M.value)):H=new Set(n?[...e,M.value]:[M.value]);const X=[];i.forEach(D=>{H.has(D.value)&&X.push(D.value)}),a(X)},R=M.label.toLocaleLowerCase().indexOf(c);return m.jsxs("div",{className:mt.dvListDropdownItemContainer,onClick:N,children:[m.jsx("div",{className:mt.dvListDropdownItem,style:{background:M.color||It},children:c&&M.label.toLowerCase().includes(c)?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:M.label.substring(0,R)}),m.jsx("span",{style:{fontWeight:"bold"},children:M.label.substring(R,R+c.length)}),m.jsx("span",{children:M.label.substring(R+c.length)})]}):M.label}),m.jsx("div",{className:mt.dvListDropdownSelectedIcon,children:k?m.jsx(Oe,{}):null})]},j)})})},l)}),E&&F?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:mt.dvListDropdownSplit}),m.jsx("div",{className:mt.dvListDropdownEdit,children:m.jsx("a",{onClick:s,children:h.t("dataValidation.list.edit")})})]}):null]})};function Nn(t){var D,S,g,w,_,A;const{location:e,hideFn:a}=t,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d}=e,l=o.useDependency(ot.DataValidationModel),[u,h]=b.useState(""),f=o.useDependency(o.ICommandService),c=o.useDependency(o.LocaleService),[C,v]=b.useState(""),p=o.useDependency(K.IEditorBridgeService),y=o.useDependency(o.IUniverInstanceService),V=b.useMemo(()=>l.ruleChange$.pipe(dt.debounceTime(16)),[]);tt.useObservable(V);const E=tt.RectPopup.useContext(),I=((S=(D=E.current)==null?void 0:D.right)!=null?S:0)-((w=(g=E.current)==null?void 0:g.left)!=null?w:0);if(b.useEffect(()=>{const O=f.onCommandExecuted(Y=>{var G,J;if(Y.id===on.RichTextEditingMutation.id){const et=Y.params,{unitId:nt}=et,it=y.getUnit(nt,o.UniverInstanceType.UNIVER_DOC);if(!it)return;const $=o.BuildTextUtils.transform.getPlainText((J=(G=it.getSnapshot().body)==null?void 0:G.dataStream)!=null?J:"");h($)}});return()=>{O.dispose()}},[f,y]),!n)return null;const F=n.getCell(i,r),L=(_=F==null?void 0:F.dataValidation)==null?void 0:_.rule,P=(A=F==null?void 0:F.dataValidation)==null?void 0:A.validator,M=(L==null?void 0:L.renderMode)===o.DataValidationRenderMode.CUSTOM||(L==null?void 0:L.renderMode)===void 0;if(!F||!L||!P||P.id.indexOf(o.DataValidationType.LIST)!==0)return;const j=L.type===o.DataValidationType.LIST_MULTIPLE,k=P.getListWithColor(L,s,d),N=C||x.getDataValidationCellValue(n.getCellRaw(i,r)),R=x.deserializeListOptions(N),H=()=>{f.executeCommand(_t.id,{ruleId:L.uid}),a()},X=k.map(O=>({label:O.label,value:O.label,color:M||O.color?O.color:"transparent"}));return m.jsx(xn,{style:{minWidth:I,maxWidth:Math.max(I,200)},title:j?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:R,multiple:j,onChange:async O=>{const Y=x.serializeListOptions(O),G={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:Y,p:null,f:null,si:null}};p.isVisible()&&p.changeVisible({visible:!1,keycode:tt.KeyCode.ESC,eventType:at.DeviceInputEventType.Keyboard,unitId:s}),v(Y),j||a(),p.isVisible().visible&&await f.executeCommand(K.SetCellEditVisibleOperation.id,{visible:!1,eventType:at.DeviceInputEventType.Keyboard,unitId:s,keycode:tt.KeyCode.ESC}),f.executeCommand(Q.SetRangeValuesCommand.id,G)},options:X,onEdit:H,filter:u,location:e})}const oe={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function Un(t){var u;const e=o.useDependency(o.LocaleService),a=o.useDependency(tt.ComponentManager),{value:n,onChange:i,extraComponent:r}=t,[s,d]=b.useState(!1),l=r?a.get(r):null;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:oe.dataValidationOptionsButton,onClick:()=>d(!s),children:[e.t("dataValidation.panel.options"),s?m.jsx(je,{className:oe.dataValidationOptionsButtonIcon}):m.jsx(Pe,{className:oe.dataValidationOptionsButtonIcon})]}),s&&m.jsxs(m.Fragment,{children:[l?m.jsx(l,{value:n,onChange:i}):null,m.jsx(U.FormLayout,{label:e.t("dataValidation.panel.invalid"),children:m.jsxs(U.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:o.DataValidationErrorStyle.WARNING}`,onChange:h=>i({...n,errorStyle:+h}),children:[m.jsx(U.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:e.t("dataValidation.panel.showWarning")}),m.jsx(U.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:e.t("dataValidation.panel.rejectInput")})]})}),m.jsx(U.FormLayout,{label:e.t("dataValidation.panel.messageInfo"),children:m.jsx(U.Checkbox,{checked:n.showErrorMessage,onChange:()=>i({...n,showErrorMessage:!n.showErrorMessage}),children:e.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?m.jsx(U.FormLayout,{children:m.jsx(U.Input,{value:n.error,onChange:h=>i({...n,error:h})})}):null]})]})}const wt={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},kn=t=>o.debounce(async(e,a,n,i)=>{const r=await t.executeCommand(e,a,n);i==null||i(r)},1e3);function Bn(t,e,a){var n,i,r,s;return e?((i=(n=t.getUnit(e))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Wn(){var it;const[t,e]=b.useState(0),a=o.useDependency(ht),n=tt.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},d=s.uid,l=o.useDependency(ot.DataValidatorRegistryService),u=o.useDependency(o.IUniverInstanceService),h=o.useDependency(tt.ComponentManager),f=o.useDependency(o.ICommandService),c=o.useDependency(ot.DataValidationModel),C=o.useDependency(o.LocaleService),[v,p]=b.useState(s),y=l.getValidatorItem(v.type),[V,E]=b.useState(!1),I=l.getValidatorsByScope(ot.DataValidatorRegistryScope.SHEET),[F,L]=b.useState(()=>v.ranges.map($=>({unitId:"",sheetId:"",range:$}))),P=b.useMemo(()=>kn(f),[f]),[M,j]=b.useState(!1),k=b.useRef({}),[N,R]=b.useState(!1),H=o.useDependency(Q.SheetsSelectionsService);if(b.useEffect(()=>()=>{const $=H.getCurrentLastSelection();$&&H.setSelections([$])},[H]),b.useEffect(()=>{f.onCommandExecuted($=>{($.id===o.UndoCommand.id||$.id===o.RedoCommand.id)&&setTimeout(()=>{const T=c.getRuleById(i,r,d);e(z=>z+1),T&&(p(T),L(T.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[f,c,d,r,i]),!y)return null;const X=y.operators,D=y.operatorNames,S=v.operator?ot.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,g=()=>{!v.ranges.length||M||(y.validatorFormula(v,i,r).success?a.setActiveRule(null):E(!0))},w=tt.useEvent($=>{const T=$.split(",").map(Qt.deserializeRangeWithSheet).map(Z=>{const lt=Z.sheetName;if(lt){const Ot=Bn(u,Z.unitId,lt);return{...Z,sheetId:Ot}}return{...Z,sheetId:""}});if(o.isUnitRangesEqual(T,F))return;L(T);const z=T.filter(Z=>(!Z.unitId||Z.unitId===i)&&(!Z.sheetId||Z.sheetId===r)).map(Z=>Z.range);if(p({...v,ranges:z}),z.length===0)return;const W={unitId:i,subUnitId:r,ruleId:d,ranges:z};P(x.UpdateSheetDataValidationRangeCommand.id,W)}),_=$=>{if(o.shallowEqual($,ot.getRuleSetting(v)))return;p({...v,...$});const T={unitId:i,subUnitId:r,ruleId:d,setting:$};P(x.UpdateSheetDataValidationSettingCommand.id,T,void 0)},A=async()=>{await f.executeCommand(x.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:r}),a.setActiveRule(null)},O={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},Y=$=>{const T=l.getValidatorItem($);if(!T)return;const z=T.operators,W=c.getRuleById(i,r,d),Z=$===(W==null?void 0:W.type)||$.includes("list")&&(W!=null&&W.type.includes("list"))?{...W,type:$}:{...v,type:$,operator:z[0],formula1:void 0,formula2:void 0};p(Z),f.executeCommand(x.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:v.uid,setting:ot.getRuleSetting(Z)})},G=h.get(y.formulaInput),J=b.useMemo(()=>F.map($=>Qt.serializeRange($.range)).join(","),[]),et=ot.getRuleOptions(v),nt=$=>{o.shallowEqual($,ot.getRuleOptions(v))||(p({...v,...$}),P(x.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:d,options:$}))};return tt.useSidebarClick($=>{var z;const T=(z=k.current)==null?void 0:z.handleOutClick;T&&T($,()=>R(!1))}),m.jsxs("div",{className:wt.dataValidationDetail,children:[m.jsx(U.FormLayout,{label:C.t("dataValidation.panel.range"),error:!v.ranges.length||M?C.t("dataValidation.panel.rangeError"):"",children:m.jsx(te.RangeSelector,{unitId:i,subUnitId:r,initValue:J,onChange:w,onFocus:()=>R(!0),isFocus:N,actions:k.current,onVerify:$=>j(!$)})}),m.jsx(U.FormLayout,{label:C.t("dataValidation.panel.type"),children:m.jsx(U.Select,{options:I==null?void 0:I.map($=>({label:C.t($.title),value:$.id})),value:v.type,onChange:Y,className:wt.dataValidationDetailFormItem})}),X!=null&&X.length?m.jsx(U.FormLayout,{label:C.t("dataValidation.panel.operator"),children:m.jsx(U.Select,{options:X.map(($,T)=>({value:`${$}`,label:D[T]})),value:`${v.operator}`,onChange:$=>{_({...O,operator:$})},className:wt.dataValidationDetailFormItem})}):null,G?m.jsx(G,{isTwoFormula:S,value:{formula1:v.formula1,formula2:v.formula2},onChange:$=>{_({...O,...$})},showError:V,validResult:y.validatorFormula(v,i,r),unitId:i,subUnitId:r,ruleId:d},t+v.type):null,m.jsx(U.FormLayout,{children:m.jsx(U.Checkbox,{checked:(it=v.allowBlank)!=null?it:!0,onChange:()=>{var $;return _({...O,allowBlank:!(($=v.allowBlank)==null||$)})},children:C.t("dataValidation.panel.allowBlank")})}),m.jsx(Un,{value:et,onChange:nt,extraComponent:y.optionsInput}),m.jsxs("div",{className:wt.dataValidationDetailButtons,children:[m.jsx(U.Button,{className:wt.dataValidationDetailButton,onClick:A,children:C.t("dataValidation.panel.removeRule")}),m.jsx(U.Button,{className:wt.dataValidationDetailButton,type:"primary",onClick:g,children:C.t("dataValidation.panel.done")})]})]})}const xt={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Hn=t=>{const{rule:e,onClick:a,unitId:n,subUnitId:i,disable:r}=t,s=o.useDependency(ot.DataValidatorRegistryService),d=o.useDependency(o.ICommandService),l=o.useDependency(K.IMarkSelectionService),u=s.getValidatorItem(e.type),h=b.useRef(),[f,c]=b.useState(!1),C=v=>{d.executeCommand(x.RemoveSheetDataValidationCommand.id,{ruleId:e.uid,unitId:n,subUnitId:i}),v.stopPropagation()};return b.useEffect(()=>()=>{var v;h.current&&((v=h.current)==null||v.forEach(p=>{p&&l.removeShape(p)}))},[l]),m.jsxs("div",{className:xt.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),h.current=e.ranges.map(v=>l.addShape({range:v,style:{hasAutoFill:!1,fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:{startColumn:v.startColumn,endColumn:v.endColumn,startRow:v.startRow,endRow:v.endRow,actualRow:v.startRow,actualColumn:v.startColumn,isMerged:!1,isMergedMainCell:!1}})))},onMouseLeave:()=>{var v;c(!1),(v=h.current)==null||v.forEach(p=>{p&&l.removeShape(p)}),h.current=void 0},children:[m.jsx("div",{className:xt.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(e)}),m.jsx("div",{className:xt.dataValidationItemContent,children:e.ranges.map(v=>Qt.serializeRange(v)).join(",")}),f?m.jsx("div",{className:xt.dataValidationItemIcon,onClick:C,children:m.jsx(ee,{})}):null]})},Nt={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function Yn(){const t=o.useDependency(o.IUniverInstanceService),e=tt.useObservable(()=>t.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return e?m.jsx(Xn,{workbook:e}):null}function Xn(t){const e=o.useDependency(x.SheetDataValidationModel),a=o.useDependency(o.IUniverInstanceService),n=o.useDependency(o.ICommandService),i=o.useDependency(o.Injector),r=o.useDependency(ht),s=o.useDependency(o.LocaleService),[d,l]=b.useState([]),{workbook:u}=t,h=tt.useObservable(u.activeSheet$,void 0,!0),f=u.getUnitId(),c=h==null?void 0:h.getSheetId();b.useEffect(()=>{l(e.getRules(f,c));const E=e.ruleChange$.subscribe(I=>{I.unitId===f&&I.subUnitId===c&&l(e.getRules(f,c))});return()=>{E.unsubscribe()}},[f,c,e]);const C=async()=>{const E=x.createDefaultNewRule(i),I={unitId:f,subUnitId:c,rule:E};await n.executeCommand(x.AddSheetDataValidationCommand.id,I),r.setActiveRule({unitId:f,subUnitId:c,rule:E})},v=()=>{n.executeCommand(x.RemoveSheetAllDataValidationCommand.id,{unitId:f,subUnitId:c})},y=(E=>{const I=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),F=I.getActiveSheet(),L=I.getUnitId(),P=F.getSheetId();return E.map(j=>Q.checkRangesEditablePermission(i,L,P,j.ranges)?{...j}:{...j,disable:!0})})(d),V=y==null?void 0:y.some(E=>E.disable);return m.jsxs("div",{className:Nt.dataValidationList,children:[y==null?void 0:y.map(E=>{var I;return m.jsx(Hn,{unitId:f,subUnitId:c,onClick:()=>{E.disable||r.setActiveRule({unitId:f,subUnitId:c,rule:E})},rule:E,disable:(I=E.disable)!=null?I:!1},E.uid)}),m.jsxs("div",{className:Nt.dataValidationListButtons,children:[d.length&&!V?m.jsx(U.Button,{className:Nt.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,m.jsx(U.Button,{className:Nt.dataValidationListButton,type:"primary",onClick:C,children:s.t("dataValidation.panel.add")})]})]})}const zn=()=>{const t=o.useDependency(ht),e=tt.useObservable(t.activeRule$,t.activeRule);return e?m.jsx(Wn,{},e.rule.uid):m.jsx(Yn,{})},Ut="data-validation.list.dropdown",re="data-validation.date.dropdown",kt={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(t){const e=t.get(o.IUniverInstanceService),a=Q.getSheetCommandTarget(e);if(!a)return!1;const{workbook:n,worksheet:i}=a,r=x.createDefaultNewRule(t),s=t.get(o.ICommandService),d=n.getUnitId(),l=i.getSheetId(),u={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(x.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(_t.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var Kn=Object.defineProperty,Gn=Object.getOwnPropertyDescriptor,Zn=(t,e,a,n)=>{for(var i=n>1?void 0:n?Gn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Kn(e,a,i),i},Pt=(t,e)=>(a,n)=>e(a,n,t);const Bt="SHEET_DATA_VALIDATION_ALERT";let jt=class extends o.Disposable{constructor(t,e,a,n,i){super(),this._hoverManagerService=t,this._cellAlertManagerService=e,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(dt.debounceTime(100)).subscribe(t=>{var e,a;if(t){const i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!i)return;const r=i.getCell(t.location.row,t.location.col);if(((e=r==null?void 0:r.dataValidation)==null?void 0:e.validStatus)===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Bt),d=(a=s==null?void 0:s.alert)==null?void 0:a.location;if(d&&d.row===t.location.row&&d.col===t.location.col&&d.subUnitId===t.location.subUnitId&&d.unitId===t.location.unitId)return;const l=r.dataValidation.validator,u=r.dataValidation.rule;if(!l)return;this._cellAlertManagerService.showAlert({type:K.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(u),location:t.location,width:200,height:74,key:Bt});return}}this._cellAlertManagerService.removeAlert(Bt)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this._cellAlertManagerService.removeAlert(Bt)}))}};jt=Zn([Pt(0,o.Inject(K.HoverManagerService)),Pt(1,o.Inject(K.CellAlertManagerService)),Pt(2,o.IUniverInstanceService),Pt(3,o.Inject(o.LocaleService)),Pt(4,tt.IZenZoneService)],jt);var qn=Object.defineProperty,Jn=Object.getOwnPropertyDescriptor,Qn=(t,e,a,n)=>{for(var i=n>1?void 0:n?Jn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&qn(e,a,i),i},se=(t,e)=>(a,n)=>e(a,n,t);let yt=class extends o.Disposable{constructor(t,e,a){super(),this._autoFillService=t,this._dataValidationModel=e,this._injector=a,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),e=(i,r)=>{const{source:s,target:d,unitId:l,subUnitId:u}=i,h=this._dataValidationModel.getRuleObjectMatrix(l,u).clone(),f=K.virtualizeDiscreteRanges([s,d]),[c,C]=f.ranges,{mapFunc:v}=f,p={row:c.startRow,col:c.startColumn},y=K.getAutoFillRepeatRange(c,C),V=new o.ObjectMatrix,E=new Set;y.forEach(M=>{const j=M.repeatStartCell,k=M.relativeRange,N={startRow:p.row,startColumn:p.col,endColumn:p.col,endRow:p.row},R={startRow:j.row,startColumn:j.col,endColumn:j.col,endRow:j.row};o.Range.foreach(k,(H,X)=>{const D=o.Rectangle.getPositionRange({startRow:H,startColumn:X,endColumn:X,endRow:H},N),{row:S,col:g}=v(D.startRow,D.startColumn),w=this._dataValidationModel.getRuleIdByLocation(l,u,S,g);if(w){const _=o.Rectangle.getPositionRange({startRow:H,startColumn:X,endColumn:X,endRow:H},R),{row:A,col:O}=v(_.startRow,_.startColumn);V.setValue(A,O,w),E.add(w)}})});const I=Array.from(E).map(M=>({id:M,ranges:o.queryObjectMatrix(V,j=>j===M)}));h.addRangeRules(I);const F=h.diff(this._dataValidationModel.getRules(l,u)),{redoMutations:L,undoMutations:P}=x.getDataValidationDiffMutations(l,u,F,this._injector,"patched",r===K.APPLY_TYPE.ONLY_FORMAT);return{undos:P,redos:L}},a=[o.DataValidationType.CHECKBOX],n={id:x.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:i=>{const{source:r,unitId:s,subUnitId:d}=i;for(const l of r.rows)for(const u of r.cols){const h=this._dataValidationModel.getRuleByLocation(s,d,l,u);if(h&&a.indexOf(h.type)>-1){this._autoFillService.setDisableApplyType(K.APPLY_TYPE.SERIES,!0);return}}},onFillData:(i,r,s)=>s===K.APPLY_TYPE.COPY||s===K.APPLY_TYPE.ONLY_FORMAT||s===K.APPLY_TYPE.SERIES?e(i,s):t(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};yt=Qn([se(0,K.IAutoFillService),se(1,o.Inject(x.SheetDataValidationModel)),se(2,o.Inject(o.Injector))],yt);var ta=Object.defineProperty,ea=Object.getOwnPropertyDescriptor,na=(t,e,a,n)=>{for(var i=n>1?void 0:n?ea(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ta(e,a,i),i},le=(t,e)=>(a,n)=>e(a,n,t);let Mt=class extends o.Disposable{constructor(e,a,n){super();B(this,"_copyInfo");this._sheetClipboardService=e,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:x.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(e,a,n)=>this._collect(e,a,n),onPasteCells:(e,a,n,i)=>{const{copyType:r=K.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=e||{},{range:l,unitId:u,subUnitId:h}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:u,subUnitId:h})}})}_collect(e,a,n){const i=new o.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:a,matrix:i};const r=this._injector.invoke(l=>K.rangeToDiscreteRange(n,l,e,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,u)=>{d.forEach((h,f)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(e,a,l,h);i.setValue(u,f,c!=null?c:"")})})}_generateMutations(e,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===K.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:n,subUnitId:i}=this._copyInfo;if(a.unitId!==n||i!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=K.virtualizeDiscreteRanges([a.copyRange,e]),f=K.getRepeatRange(l,u,!0),c=new Map;f.forEach(({startRange:y})=>{var V;(V=this._copyInfo)==null||V.matrix.forValue((E,I,F)=>{const L=o.Rectangle.getPositionRange({startRow:E,endRow:E,startColumn:I,endColumn:I},y),P=`${i}-${F}`,M=this._sheetDataValidationModel.getRuleById(n,i,F);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,P)&&M&&c.set(P,{...M,uid:P});const{row:j,col:k}=h(L.startRow,L.startColumn);d.add(P),s.setValue(j,k,P)})});const C=Array.from(d).map(y=>({id:y,ranges:o.queryObjectMatrix(s,V=>V===y)}));r.addRangeRules(C);const{redoMutations:v,undoMutations:p}=x.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:v,undos:p}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,i).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=K.virtualizeDiscreteRanges([a.copyRange,e]);K.getRepeatRange(l,u,!0).forEach(({startRange:p})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((V,E,I)=>{const F=o.Rectangle.getPositionRange({startRow:V,endRow:V,startColumn:E,endColumn:E},p),{row:L,col:P}=h(F.startRow,F.startColumn);s.setValue(L,P,I),d.add(I)})});const c=Array.from(d).map(p=>({id:p,ranges:o.queryObjectMatrix(s,y=>y===p)}));r.addRangeRules(c);const{redoMutations:C,undoMutations:v}=x.getDataValidationDiffMutations(n,i,r.diff(this._sheetDataValidationModel.getRules(n,i)),this._injector,"patched",!1);return{redos:C,undos:v}}}};Mt=na([le(0,K.ISheetClipboardService),le(1,o.Inject(x.SheetDataValidationModel)),le(2,o.Inject(o.Injector))],Mt);var aa=Object.defineProperty,ia=Object.getOwnPropertyDescriptor,oa=(t,e,a,n)=>{for(var i=n>1?void 0:n?ia(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&aa(e,a,i),i},de=(t,e)=>(a,n)=>e(a,n,t);let Vt=class extends o.Disposable{constructor(t,e,a){super(),this._localeService=t,this._commandService=e,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===x.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[Q.WorkbookEditablePermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint],worksheetTypes:[Q.WorksheetEditPermission,Q.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),t.id===x.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[Q.WorkbookEditablePermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint],worksheetTypes:[Q.WorksheetEditPermission,Q.WorksheetSetCellStylePermission]},t.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Vt=oa([de(0,o.Inject(o.LocaleService)),de(1,o.ICommandService),de(2,o.Inject(K.SheetPermissionInterceptorBaseController))],Vt);const ke="data-validation-single",Be="sheet.menu.data-validation";function ra(t){return{id:Be,type:tt.MenuItemType.SUBITEMS,icon:ke,tooltip:"dataValidation.title",hidden$:tt.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:K.getCurrentRangeDisable$(t,{workbookTypes:[Q.WorkbookEditablePermission],worksheetTypes:[Q.WorksheetSetCellStylePermission,Q.WorksheetEditPermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint]})}}function sa(t){return{id:_t.id,title:"dataValidation.panel.title",type:tt.MenuItemType.BUTTON}}function la(t){return{id:kt.id,title:"dataValidation.panel.add",type:tt.MenuItemType.BUTTON}}const da={[tt.RibbonStartGroup.FORMULAS_INSERT]:{[Be]:{order:9,menuItemFactory:ra,[_t.id]:{order:0,menuItemFactory:sa},[kt.id]:{order:1,menuItemFactory:la}}}};var ca=Object.defineProperty,ua=Object.getOwnPropertyDescriptor,We=(t,e,a,n)=>{for(var i=n>1?void 0:n?ua(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ca(e,a,i),i},rt=(t,e)=>(a,n)=>e(a,n,t);const He={tr:{size:6,color:"#fe4b4b"}};let bt=class extends o.RxDisposable{constructor(t,e,a,n,i,r,s,d,l,u,h){super(),this._commandService=t,this._menuManagerService=e,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=i,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=u,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(da)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{var a;if(!t.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const e=this._editorBridgeService.getEditCellState();if(e){const{unitId:n,sheetId:i,row:r,column:s}=e,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,i,r,s);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(u!=null&&u.dropdown))return;const h=d.getActiveSheet();if(!h)return;const f=this._dropdownManagerService.activeDropdown,c=f==null?void 0:f.location;if(c&&c.unitId===n&&c.subUnitId===i&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:i,row:r,col:s,workbook:d,worksheet:h},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Q.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:Q.InterceptCellContentPriority.DATA_VALIDATION,handler:(t,e,a)=>{var V,E,I,F,L,P;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=e,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(t);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(t);const f=(E=(V=this._dataValidationCacheService.getValue(r,s,n,i))==null?void 0:V.status)!=null?E:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),C=e.rawData;let v;const p={get value(){var M;return v!==void 0||(v=(M=x.getCellValueOrigin(C))!=null?M:null),v}},y={get value(){var M;return`${(M=p.value)!=null?M:""}`}};return a({...t,dataValidation:{ruleId:u,validStatus:f,rule:h,validator:c},markers:{...t==null?void 0:t.markers,...f===o.DataValidationStatus.INVALID?He:null},customRender:[...(I=t==null?void 0:t.customRender)!=null?I:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...t==null?void 0:t.fontRenderExtension,isSkip:((F=t==null?void 0:t.fontRenderExtension)==null?void 0:F.isSkip)||((L=c==null?void 0:c.skipDefaultFontRender)==null?void 0:L.call(c,h,p.value,e))},interceptorStyle:{...t==null?void 0:t.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,y.value,{get style(){const M=d.getStyles();return(typeof(t==null?void 0:t.s)=="string"?M.get(t==null?void 0:t.s):t==null?void 0:t.s)||{}}},n,i)},interceptorAutoHeight:()=>{var N,R,H,X,D,S;const M=(R=(N=this._renderManagerService.getRenderById(r))==null?void 0:N.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:R.skeleton;if(!M)return;const j=M.worksheet.getMergedCell(n,i),k={data:{...t,dataValidation:{ruleId:u,validStatus:f,rule:h,validator:c}},style:M.getsStyles().getStyleByCell(t),primaryWithCoord:M.getCellByIndex((H=j==null?void 0:j.startRow)!=null?H:n,(X=j==null?void 0:j.startColumn)!=null?X:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(S=(D=c==null?void 0:c.canvasRender)==null?void 0:D.calcCellAutoHeight)==null?void 0:S.call(D,k)},interceptorAutoWidth:()=>{var N,R,H,X,D,S;const M=(R=(N=this._renderManagerService.getRenderById(r))==null?void 0:N.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:R.skeleton;if(!M)return;const j=M.worksheet.getMergedCell(n,i),k={data:{...t,dataValidation:{ruleId:u,validStatus:f,rule:h,validator:c}},style:M.getsStyles().getStyleByCell(t),primaryWithCoord:M.getCellByIndex((H=j==null?void 0:j.startRow)!=null?H:n,(X=j==null?void 0:j.startColumn)!=null?X:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(S=(D=c==null?void 0:c.canvasRender)==null?void 0:D.calcCellAutoWidth)==null?void 0:S.call(D,k)},coverable:((P=t==null?void 0:t.coverable)!=null?P:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(dt.filter(t=>t.source==="command"),dt.bufferTime(16)).subscribe(t=>{const e=[];if(t.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&e.push(...a.rule.ranges)}),e.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(e);o.sequenceExecute(a.redos,this._commandService)}})}};bt=We([rt(0,o.ICommandService),rt(1,tt.IMenuManagerService),rt(2,at.IRenderManagerService),rt(3,o.IUniverInstanceService),rt(4,o.Inject(K.AutoHeightController)),rt(5,o.Inject(gt)),rt(6,o.Inject(x.SheetDataValidationModel)),rt(7,o.Inject(ot.DataValidatorRegistryService)),rt(8,o.Inject(Q.SheetInterceptorService)),rt(9,o.Inject(x.DataValidationCacheService)),rt(10,o.Optional(K.IEditorBridgeService))],bt);let Ye=class extends o.RxDisposable{constructor(t,e,a,n,i,r,s){super(),this._commandService=t,this._renderManagerService=e,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=i,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Q.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:Q.InterceptCellContentPriority.DATA_VALIDATION,handler:(t,e,a)=>{var y,V,E,I,F,L;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=e,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(t);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(t);const f=(V=(y=this._dataValidationCacheService.getValue(r,s,n,i))==null?void 0:y.status)!=null?V:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),C=l.getCellRaw(n,i),v=x.getCellValueOrigin(C),p=`${v!=null?v:""}`;return a({...t,dataValidation:{ruleId:u,validStatus:f,rule:h,validator:c},markers:{...t==null?void 0:t.markers,...f===o.DataValidationStatus.INVALID?He:null},customRender:[...(E=t==null?void 0:t.customRender)!=null?E:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...t==null?void 0:t.fontRenderExtension,isSkip:((I=t==null?void 0:t.fontRenderExtension)==null?void 0:I.isSkip)||((F=c==null?void 0:c.skipDefaultFontRender)==null?void 0:F.call(c,h,v,e))},interceptorStyle:{...t==null?void 0:t.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,p,{get style(){const P=d.getStyles();return(typeof(t==null?void 0:t.s)=="string"?P.get(t==null?void 0:t.s):t==null?void 0:t.s)||{}}},n,i)},interceptorAutoHeight:()=>{var k,N,R,H,X,D;const P=(N=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:N.skeleton;if(!P)return;const M=P.worksheet.getMergedCell(n,i),j={data:{...t,dataValidation:{ruleId:u,validStatus:f,rule:h,validator:c}},style:P.getsStyles().getStyleByCell(t),primaryWithCoord:P.getCellByIndex((R=M==null?void 0:M.startRow)!=null?R:n,(H=M==null?void 0:M.startColumn)!=null?H:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(D=(X=c==null?void 0:c.canvasRender)==null?void 0:X.calcCellAutoHeight)==null?void 0:D.call(X,j)},coverable:((L=t==null?void 0:t.coverable)!=null?L:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(dt.filter(t=>t.source==="command"),dt.bufferTime(16)).subscribe(t=>{const e=[];if(t.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&e.push(...a.rule.ranges)}),e.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(e);o.sequenceExecute(a.redos,this._commandService)}})}};Ye=We([rt(0,o.ICommandService),rt(1,at.IRenderManagerService),rt(2,o.Inject(K.AutoHeightController)),rt(3,o.Inject(ot.DataValidatorRegistryService)),rt(4,o.Inject(Q.SheetInterceptorService)),rt(5,o.Inject(x.SheetDataValidationModel)),rt(6,o.Inject(x.DataValidationCacheService))],Ye);var ha=Object.defineProperty,fa=Object.getOwnPropertyDescriptor,pa=(t,e,a,n)=>{for(var i=n>1?void 0:n?fa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ha(e,a,i),i},Xe=(t,e)=>(a,n)=>e(a,n,t);let Wt=class extends o.Disposable{constructor(t,e,a){super(),this._context=t,this._sheetDataValidationModel=e,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const t=e=>{var n;if(!e.length)return;const a=new Set;e.forEach(i=>{a.add(i.subUnitId)}),a.forEach(i=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(i))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(t))}};Wt=pa([Xe(1,o.Inject(x.SheetDataValidationModel)),Xe(2,o.Inject(K.SheetSkeletonManagerService))],Wt);const st={dataValidationFormula:"univer-data-validation-formula",dataValidationFormulaAnd:"univer-data-validation-formula-and",dataValidationFormulaListItem:"univer-data-validation-formula-list-item",dataValidationFormulaListItemIcon:"univer-data-validation-formula-list-item-icon",dataValidationFormulaListItemDrag:"univer-data-validation-formula-list-item-drag",dataValidationFormulaListAdd:"univer-data-validation-formula-list-add",dataValidationFormulaColorSelect:"univer-data-validation-formula-color-select",dataValidationFormulaColorSelectPanel:"univer-data-validation-formula-color-select-panel",dataValidationFormulaColorItem:"univer-data-validation-formula-color-item"},ma=t=>{const{isTwoFormula:e=!1,value:a,onChange:n,showError:i,validResult:r}=t,s=o.useDependency(o.LocaleService),d=i?r==null?void 0:r.formula1:"",l=i?r==null?void 0:r.formula2:"";return e?m.jsxs(m.Fragment,{children:[m.jsx(U.FormLayout,{error:d,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),m.jsx("div",{className:st.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),m.jsx(U.FormLayout,{error:l,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):m.jsx(U.FormLayout,{error:d,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function va(t){const{value:e,onChange:a,showError:n,validResult:i}=t,r=o.useDependency(o.LocaleService),s=n?i==null?void 0:i.formula1:"",d=n?i==null?void 0:i.formula2:"",[l,u]=b.useState(!((e==null?void 0:e.formula1)===void 0&&(e==null?void 0:e.formula2)===void 0));return m.jsxs(m.Fragment,{children:[m.jsx(U.FormLayout,{children:m.jsx(U.Checkbox,{checked:l,onChange:h=>{h?u(!0):(u(!1),a==null||a({...e,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?m.jsx(U.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:e==null?void 0:e.formula1,onChange:h=>{a==null||a({...e,formula1:h||void 0})}})}):null,l?m.jsx(U.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:e==null?void 0:e.formula2,onChange:h=>{a==null||a({...e,formula2:h||void 0})}})}):null]})}function ga(t){var f;const{unitId:e,subUnitId:a,value:n,onChange:i,showError:r,validResult:s}=t,d=r?s==null?void 0:s.formula1:void 0,l=b.useRef({}),[u,h]=b.useState(!1);return tt.useSidebarClick(c=>{var v;const C=(v=l.current)==null?void 0:v.handleOutClick;C&&C(c,()=>h(!1))}),m.jsx(te.FormulaEditor,{initValue:(f=n==null?void 0:n.formula1)!=null?f:"",unitId:e,subUnitId:a,isFocus:u,onChange:c=>{const C=(c!=null?c:"").trim();C!==(n==null?void 0:n.formula1)&&(i==null||i({...n,formula1:C}))},errorText:d,onFocus:()=>h(!0),actions:l.current})}function ze(t){var e,a,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(a=ze(t[e]))&&(n&&(n+=" "),n+=a)}else for(a in t)t[a]&&(n&&(n+=" "),n+=a);return n}function Sa(){for(var t,e,a=0,n="",i=arguments.length;a<i;a++)(t=arguments[a])&&(e=ze(t))&&(n&&(n+=" "),n+=e);return n}const _a=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Ia=t=>{const{value:e,onChange:a,disabled:n}=t,[i,r]=b.useState(!1);return m.jsx(U.Select,{disabled:n,open:i,onDropdownVisibleChange:r,dropdownStyle:{width:112},className:st.dataValidationFormulaColorSelect,value:e,onChange:a,labelRender:s=>m.jsx("div",{className:st.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>m.jsx("div",{className:st.dataValidationFormulaColorSelectPanel,children:_a.map(s=>m.jsx("div",{onClick:()=>{a(s),r(!1)},className:st.dataValidationFormulaColorItem,style:{background:s}},s))})})},Ke=t=>{const{item:e,commonProps:a,style:n}=t,{onItemChange:i,onItemDelete:r}=a;return m.jsxs("div",{className:st.dataValidationFormulaListItem,style:n,children:[e.isRef?null:m.jsx("div",{className:Sa(st.dataValidationFormulaListItemDrag,"draggableHandle"),children:m.jsx(Ae,{})}),m.jsx(Ia,{value:e.color,onChange:s=>{i(e.id,e.label,s)}}),m.jsx(U.Input,{disabled:e.isRef,value:e.label,onChange:s=>{i(e.id,s,e.color)}}),e.isRef?null:m.jsx("div",{className:st.dataValidationFormulaListItemIcon,children:m.jsx(ee,{onClick:()=>r(e.id)})})]})};function Ca(t){const{value:e,onChange:a=()=>{},unitId:n,subUnitId:i,validResult:r,showError:s,ruleId:d}=t,{formula1:l="",formula2:u=""}=e||{},h=b.useRef(null),[f,c]=b.useState(()=>o.isFormulaString(l)?"1":"0"),[C,v]=b.useState(f==="1"?l:"="),[p,y]=b.useState(f==="1"?l:"="),V=o.useDependency(o.LocaleService),E=o.useDependency(ot.DataValidatorRegistryService),I=o.useDependency(ot.DataValidationModel),F=o.useDependency(x.DataValidationFormulaController),[L,P]=b.useState(()=>u.split(",")),M=E.getValidatorItem(o.DataValidationType.LIST),[j,k]=b.useState([]),[N,R]=b.useState(""),H=s?r==null?void 0:r.formula1:"",X=b.useMemo(()=>I.ruleChange$.pipe(dt.debounceTime(16)),[]),D=tt.useObservable(X),S=tt.useEvent(a);b.useEffect(()=>{(async()=>{await new Promise(W=>{setTimeout(()=>W(!0),100)});const T=I.getRuleById(n,i,d),z=T==null?void 0:T.formula1;if(o.isFormulaString(z)&&M&&T){const W=await M.getListAsync(T,n,i);k(W)}})()},[I,D,M,d,i,n]),b.useEffect(()=>{o.isFormulaString(l)&&l!==p&&(v(l),y(p))},[p,l]);const[g,w]=b.useState(()=>{const T=f!=="1"?x.deserializeListOptions(l):[],z=u.split(",");return T.map((W,Z)=>({label:W,color:z[Z]||It,isRef:!1,id:o.Tools.generateRandomId(4)}))}),_=(T,z,W)=>{const Z=g.find(lt=>lt.id===T);Z&&(Z.label=z,Z.color=W,w([...g]))},A=T=>{const z=g.findIndex(W=>W.id===T);z!==-1&&(g.splice(z,1),w([...g]))},O=u.split(","),Y=b.useMemo(()=>j.map((T,z)=>({label:T,color:O[z]||It,id:`${z}`,isRef:!0})),[O,j]),G=(T,z,W)=>{const Z=[...L];Z[+T]=W,P(Z),S({formula1:l,formula2:Z.join(",")})},J=()=>{w([...g,{label:"",color:It,isRef:!1,id:o.Tools.generateRandomId(4)}])};b.useEffect(()=>{if(f==="1")return;const T=new Set,z=[];g.map(W=>({labelList:W.label.split(","),item:W})).forEach(({item:W,labelList:Z})=>{Z.forEach(lt=>{T.has(lt)||(T.add(lt),z.push({label:lt,color:W.color}))})}),S({formula1:x.serializeListOptions(z.map(W=>W.label)),formula2:z.map(W=>W.color===It?"":W.color).join(",")})},[g,S,f,p,L]);const et=b.useMemo(()=>async T=>{if(!o.isFormulaString(T)){S==null||S({formula1:"",formula2:u});return}F.getFormulaRefCheck(T)?(S==null||S({formula1:o.isFormulaString(T)?T:"",formula2:u}),R("")):(S==null||S({formula1:"",formula2:u}),v("="),R(V.t("dataValidation.validFail.formulaError")))},[u,S]),nt=b.useRef({}),[it,$]=b.useState(!1);return tt.useSidebarClick(T=>{var W;const z=(W=nt.current)==null?void 0:W.handleOutClick;z&&z(T,()=>$(!1))}),m.jsxs(m.Fragment,{children:[m.jsx(U.FormLayout,{label:V.t("dataValidation.list.options"),children:m.jsxs(U.RadioGroup,{value:f,onChange:T=>{c(T),v(p),T==="1"&&S({formula1:p==="="?"":p,formula2:L.join(",")})},children:[m.jsx(U.Radio,{value:"0",children:V.t("dataValidation.list.customOptions")}),m.jsx(U.Radio,{value:"1",children:V.t("dataValidation.list.refOptions")})]})}),f==="1"?m.jsxs(m.Fragment,{children:[m.jsx(te.FormulaEditor,{initValue:C,unitId:n,subUnitId:i,isFocus:it,onChange:(T="")=>{const z=(T!=null?T:"").trim();y(z),et(z)},errorText:H||N||void 0,onFocus:()=>$(!0),actions:nt.current}),m.jsx("div",{ref:h,style:{marginTop:"12px"},children:Y.map(T=>m.jsx(Ke,{item:T,commonProps:{onItemChange:G},style:{marginBottom:12}},T.id))})]}):m.jsx(U.FormLayout,{error:H,children:m.jsxs("div",{ref:h,style:{marginTop:"-12px"},children:[m.jsx(U.DraggableList,{list:g,onListChange:w,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:T=>m.jsx(Ke,{item:T,commonProps:{onItemChange:_,onItemDelete:A}},T.id),idKey:"id"}),m.jsxs("a",{className:st.dataValidationFormulaListAdd,onClick:J,children:[m.jsx(Le,{}),V.t("dataValidation.list.add")]})]})})]})}const Ge="data-validation.custom-formula-input",Ht="data-validation.formula-input",ce="data-validation.list-formula-input",Ze="data-validation.checkbox-formula-input",Da=[[Ge,ga],[Ht,ma],[ce,Ca],[Ze,va]],wa="LIST_RENDER_MODE_OPTION_INPUT";function Yt(t){var i;const{value:e,onChange:a}=t,n=o.useDependency(o.LocaleService);return m.jsx(U.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:m.jsxs(U.RadioGroup,{value:`${(i=e.renderMode)!=null?i:o.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...e,renderMode:+r}),children:[m.jsx(U.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),m.jsx(U.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),m.jsx(U.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Yt.componentKey=wa;const ya="DATE_SHOW_TIME_OPTION";function Xt(t){var i;const{value:e,onChange:a}=t,n=o.useDependency(o.LocaleService);return m.jsx(U.FormLayout,{children:m.jsx(U.Checkbox,{checked:(i=e.bizInfo)==null?void 0:i.showTime,onChange:r=>{a({...e,bizInfo:{...e.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}Xt.componentKey=ya;var Ma=Object.defineProperty,Va=Object.getOwnPropertyDescriptor,ba=(t,e,a,n)=>{for(var i=n>1?void 0:n?Va(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Ma(e,a,i),i},ue=(t,e)=>(a,n)=>e(a,n,t);const zt=6;let he=class{constructor(t,e,a){this._commandService=t,this._formulaService=e,this._themeService=a}_calc(t,e){var u,h,f;const{vt:a,ht:n}=e||{},i=t.endX-t.startX-zt*2,r=t.endY-t.startY,s=((u=e==null?void 0:e.fs)!=null?u:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=zt;break;case o.HorizontalAlign.RIGHT:d=zt+(i-s);break;default:d=zt+(i-s)/2;break}return{left:t.startX+d,top:t.startY+l,width:((h=e==null?void 0:e.fs)!=null?h:10)*1.6,height:((f=e==null?void 0:e.fs)!=null?f:10)*1.6}}calcCellAutoHeight(t){var a;const{style:e}=t;return((a=e==null?void 0:e.fs)!=null?a:10)*1.6}calcCellAutoWidth(t){var a;const{style:e}=t;return((a=e==null?void 0:e.fs)!=null?a:10)*1.6}async _parseFormula(t,e,a){var u,h,f,c,C,v,p,y,V;const{formula1:n=x.CHECKBOX_FORMULA_1,formula2:i=x.CHECKBOX_FORMULA_2}=t,r=await this._formulaService.getRuleFormulaResult(e,a,t.uid),s=x.getFormulaResult((f=(h=(u=r==null?void 0:r[0])==null?void 0:u.result)==null?void 0:h[0])==null?void 0:f[0]),d=x.getFormulaResult((v=(C=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:C[0])==null?void 0:v[0]),l=x.isLegalFormulaResult(String(s))&&x.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?x.getFormulaResult((V=(y=(p=r==null?void 0:r[0])==null?void 0:p.result)==null?void 0:y[0])==null?void 0:V[0]):n,formula2:o.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(t,e){var X,D,S,g,w,_;const{style:a,data:n,primaryWithCoord:i,unitId:r,subUnitId:s,worksheet:d,row:l,col:u}=e,h=i.isMergedMainCell?i.mergeInfo:i,f=x.getCellValueOrigin(d.getCellRaw(l,u)),c=(X=n.dataValidation)==null?void 0:X.rule,C=(D=n.dataValidation)==null?void 0:D.validator;if(!c||!C)return;const v=this._themeService.getCurrentTheme();if(!((S=C.skipDefaultFontRender)!=null&&S.call(C,c,f,{unitId:r,subUnitId:s,row:l,column:u})))return;const p=C.parseFormulaSync(c,r,s),{formula1:y}=p,V=this._calc(h,a),{a:E,d:I}=t.getTransform(),F=at.fixLineWidthByScale(V.left,E),L=at.fixLineWidthByScale(V.top,I),P=at.Transform.create().composeMatrix({left:F,top:L,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),M=h.endX-h.startX,j=h.endY-h.startY;t.save(),t.beginPath(),t.rect(h.startX,h.startY,M,j),t.clip();const k=P.getMatrix();t.transform(k[0],k[1],k[2],k[3],k[4],k[5]);const N=((g=a==null?void 0:a.fs)!=null?g:10)*1.6,R=String(f)===String(y),H=v.hyacinth500;at.Checkbox.drawWith(t,{checked:R,width:N,height:N,fill:(_=(w=a==null?void 0:a.cl)==null?void 0:w.rgb)!=null?_:H}),t.restore()}isHit(t,e){const a=e.primaryWithCoord.isMergedMainCell?e.primaryWithCoord.mergeInfo:e.primaryWithCoord,n=this._calc(a,e.style),i=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:u}=t;return l<=d&&l>=s&&u<=r&&u>=i}async onPointerDown(t,e){var p,y,V;if(e.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:i,data:r,worksheet:s,row:d,col:l}=t,u=x.getCellValueOrigin(s.getCellRaw(d,l)),h=(p=r.dataValidation)==null?void 0:p.rule,f=(y=r.dataValidation)==null?void 0:y.validator;if(!h||!f||!((V=f.skipDefaultFontRender)!=null&&V.call(f,h,u,{unitId:n,subUnitId:i,row:d,column:l})))return;const{formula1:c,formula2:C}=await this._parseFormula(h,n,i),v={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(u)===x.transformCheckboxValue(String(c))?C:c,p:null}};this._commandService.executeCommand(Q.SetRangeValuesCommand.id,v)}};he=ba([ue(0,o.ICommandService),ue(1,o.Inject(x.DataValidationFormulaService)),ue(2,o.Inject(o.ThemeService))],he);var Ea=Object.defineProperty,Ra=Object.getOwnPropertyDescriptor,Oa=(t,e,a,n)=>{for(var i=n>1?void 0:n?Ra(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Ea(e,a,i),i},Ta=(t,e)=>(a,n)=>e(a,n,t);let ft=class{constructor(t){B(this,"canvasRender",null);B(this,"dropdown");B(this,"optionsInput");B(this,"formulaInput",ce);this.injector=t}};ft=Oa([Ta(0,o.Inject(o.Injector))],ft);class La extends ft{constructor(){super(...arguments);B(this,"id",o.DataValidationType.CHECKBOX);B(this,"canvasRender",this.injector.createInstance(he));B(this,"formulaInput",Ze)}}class Pa extends ft{constructor(){super(...arguments);B(this,"id",o.DataValidationType.CUSTOM);B(this,"formulaInput",Ge)}}const ja="data-validation.formula-input";class Aa extends ft{constructor(){super(...arguments);B(this,"id",o.DataValidationType.DATE);B(this,"formulaInput",ja);B(this,"optionsInput",Xt.componentKey);B(this,"dropdown",re)}}class $a extends ft{constructor(){super(...arguments);B(this,"id",o.DataValidationType.DECIMAL);B(this,"formulaInput",Ht)}}const qe=4,Fa=0,fe=4,Je=4,pe=6,Kt=6,Ct=14;function xa(t,e){const a=at.FontCache.getTextSize(t,e),n=a.width+qe*2,{ba:i,bd:r}=a,s=i+r;return{width:n,height:s+Fa*2,ba:i}}function me(t,e,a,n){const i=Ct+pe*2,r=a-i,s=n-Kt*2,d=t.map(c=>({layout:xa(c,e),text:c}));let l;const u=[];d.forEach(c=>{const{layout:C}=c,{width:v,height:p}=C;!l||l.width+v+fe>r?(l={width:v,height:p,items:[{...c,left:0}]},u.push(l)):(l.items.push({...c,left:l.width+fe}),l.width=l.width+v+fe)});let h=0,f=0;return u.forEach((c,C)=>{f=Math.max(f,c.width),C===u.length-1?h+=c.height:h+=c.height+Je}),{lines:u,totalHeight:h,contentWidth:r,contentHeight:s,cellAutoHeight:h+Kt*2,calcAutoWidth:f+i}}const Na=8;class Ua extends at.Shape{static drawWith(e,a){const{fontString:n,info:i,fill:r,color:s}=a,{layout:d,text:l}=i;e.save(),at.Rect.drawWith(e,{width:d.width,height:d.height,radius:Na,fill:r||It}),e.translateWithPrecision(qe,d.ba),e.font=n,e.fillStyle=s,e.fillText(l,0,0),e.restore()}}var ka=Object.defineProperty,Ba=Object.getOwnPropertyDescriptor,Wa=(t,e,a,n)=>{for(var i=n>1?void 0:n?Ba(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ka(e,a,i),i},Ha=(t,e)=>(a,n)=>e(a,n,t);const Ya=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");let ve=class{constructor(t){B(this,"zIndex");B(this,"_dropdownInfoMap",new Map);this._commandService=t}_ensureMap(t){let e=this._dropdownInfoMap.get(t);return e||(e=new Map,this._dropdownInfoMap.set(t,e)),e}_generateKey(t,e){return`${t}.${e}`}_drawDownIcon(t,e,a,n,i){const r=a-Ct+4;let s=4;switch(i){case o.VerticalAlign.MIDDLE:s=(n-Ct)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-Ct+4;break}t.save(),t.translateWithPrecision(e.startX+r,e.startY+s),t.fillStyle="#565656",t.fill(Ya),t.restore()}drawWith(t,e,a,n){var O,Y;const{primaryWithCoord:i,row:r,col:s,style:d,data:l,subUnitId:u}=e,h=i.isMergedMainCell?i.mergeInfo:i,f=l.fontRenderExtension,{leftOffset:c=0,rightOffset:C=0,topOffset:v=0,downOffset:p=0}=f||{},y=l.dataValidation,V=this._ensureMap(u),E=this._generateKey(r,s);if(!y)return;const I={startX:h.startX+c,endX:h.endX-C,startY:h.startY+v,endY:h.endY-p},F=I.endX-I.startX,L=I.endY-I.startY,{cl:P}=d||{},M=(O=typeof P=="object"?P==null?void 0:P.rgb:P)!=null?O:"#000",j=at.getFontStyleString(d!=null?d:void 0),{rule:k,validator:N}=y,R=N,{vt:H,ht:X}=d||{},D=H!=null?H:o.VerticalAlign.MIDDLE,S=(Y=x.getCellValueOrigin(l))!=null?Y:"",g=R.parseCellValue(S),w=R.getListWithColorMap(k),_=me(g,j,F,L);this._drawDownIcon(t,I,F,L,D),t.save(),t.translateWithPrecision(I.startX,I.startY),t.beginPath(),t.rect(0,0,F-Ct,L),t.clip(),t.translateWithPrecision(pe,Kt);let A=0;switch(D){case o.VerticalAlign.MIDDLE:A=(_.contentHeight-_.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:A=_.contentHeight-_.totalHeight;break}t.translateWithPrecision(0,A),_.lines.forEach((G,J)=>{t.save();const{width:et,height:nt,items:it}=G;let $=0;switch(X){case o.HorizontalAlign.RIGHT:$=_.contentWidth-et;break;case o.HorizontalAlign.CENTER:$=(_.contentWidth-et)/2;break}t.translate($,J*(nt+Je)),it.forEach(T=>{t.save(),t.translateWithPrecision(T.left,0),Ua.drawWith(t,{...j,info:T,color:M,fill:w[T.text]}),t.restore()}),t.restore()}),t.restore(),V.set(E,{left:I.startX,top:I.startY,width:_.contentWidth+pe+Ct,height:_.contentHeight+Kt*2})}calcCellAutoHeight(t){var F;const{primaryWithCoord:e,style:a,data:n}=t,i=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=i||{},u=e.isMergedMainCell?e.mergeInfo:e,h={startX:u.startX+r,endX:u.endX-s,startY:u.startY+d,endY:u.endY-l},f=n.dataValidation;if(!f)return;const c=h.endX-h.startX,C=h.endY-h.startY,v=(F=x.getCellValueOrigin(n))!=null?F:"",{validator:p}=f,V=p.parseCellValue(v),E=at.getFontStyleString(a!=null?a:void 0);return me(V,E,c,C).cellAutoHeight}calcCellAutoWidth(t){var F;const{primaryWithCoord:e,style:a,data:n}=t,i=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=i||{},u=e.isMergedMainCell?e.mergeInfo:e,h={startX:u.startX+r,endX:u.endX-s,startY:u.startY+d,endY:u.endY-l},f=n.dataValidation;if(!f)return;const c=h.endX-h.startX,C=h.endY-h.startY,v=(F=x.getCellValueOrigin(n))!=null?F:"",{validator:p}=f,V=p.parseCellValue(v),E=at.getFontStyleString(a!=null?a:void 0);return me(V,E,c,C).calcAutoWidth}isHit(t,e){const{primaryWithCoord:a}=e,n=a.isMergedMainCell?a.mergeInfo:a,{endX:i}=n,{x:r}=t;return r>=i-Ct&&r<=i}onPointerDown(t,e){if(e.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=t,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ft.id,s)}};ve=Wa([Ha(0,o.ICommandService)],ve);class Xa extends ft{constructor(){super(...arguments);B(this,"id",o.DataValidationType.LIST_MULTIPLE);B(this,"canvasRender",this.injector.createInstance(ve));B(this,"dropdown",Ut)}}var za=Object.defineProperty,Ka=Object.getOwnPropertyDescriptor,Ga=(t,e,a,n)=>{for(var i=n>1?void 0:n?Ka(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&za(e,a,i),i},Qe=(t,e)=>(a,n)=>e(a,n,t);const Dt=4,Gt=4,ut=14,pt=6,Et=4,ge=8,Za="#565656",tn=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");function qa(t,e){const a=t.length;return{id:"d",body:{dataStream:`${t}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...e,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function en(t,e,a){const n=qa(t,a),i=new o.DocumentDataModel(n),r=new at.DocumentViewModel(i);return{documentSkeleton:at.DocumentSkeleton.create(r,e),docModel:i,docViewModel:r}}function Zt(t,e,a){const{documentSkeleton:n,docModel:i,docViewModel:r}=en(t,e,a);return{documents:new at.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:i,docViewModel:r}}function nn(t,e,a,n,i,r,s=!0){let d=0;const l=s?Et:0;switch(i){case o.VerticalAlign.BOTTOM:d=e-n-l;break;case o.VerticalAlign.MIDDLE:d=(e-n)/2;break;default:d=l;break}d=Math.max(Et,d);let u=0;switch(r){case o.HorizontalAlign.CENTER:u=(t-a)/2;break;case o.HorizontalAlign.RIGHT:u=t-a;break}return u=Math.max(pt,u),{paddingLeft:u,paddingTop:d}}let Se=class{constructor(t,e){B(this,"_dropdownInfoMap",new Map);B(this,"zIndex");B(this,"onPointerEnter");B(this,"onPointerLeave");this._localeService=t,this._commandService=e}_ensureMap(t){let e=this._dropdownInfoMap.get(t);return e||(e=new Map,this._dropdownInfoMap.set(t,e)),e}_generateKey(t,e){return`${t}.${e}`}_drawDownIcon(t,e,a,n,i,r,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,u=a-ut;let h;switch(r){case o.VerticalAlign.MIDDLE:h=(n-Gt)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-i-Et+(i/2-Gt/2);break;default:h=d+Et+(i/2-Gt/2);break}t.save(),t.translateWithPrecision(e.startX+u,e.startY+h),t.fillStyle="#565656",t.fill(tn),t.restore()}drawWith(t,e,a){var D,S;const{primaryWithCoord:n,row:i,col:r,style:s,data:d,subUnitId:l}=e,u=n.isMergedMainCell?n.mergeInfo:n,h=(D=d.dataValidation)==null?void 0:D.rule,f=(S=d.dataValidation)==null?void 0:S.validator,c=d.fontRenderExtension,{leftOffset:C=0,rightOffset:v=0,topOffset:p=0,downOffset:y=0}=c||{};if(!h||!f||!f||f.id.indexOf(o.DataValidationType.LIST)!==0||!f.skipDefaultFontRender(h))return;const V={startX:u.startX+C,endX:u.endX-v,startY:u.startY+p,endY:u.endY-y},E=V.endX-V.startX,I=V.endY-V.startY,F=this._ensureMap(l),L=this._generateKey(i,r),P=f.getListWithColor(h),M=x.getCellValueOrigin(d),j=`${M!=null?M:""}`,k=P.find(g=>g.label===j);let{tb:N,vt:R,ht:H,pd:X}=s||{};if(N=N!=null?N:o.WrapStrategy.WRAP,R=R!=null?R:o.VerticalAlign.BOTTOM,H=H!=null?H:o.DEFAULT_STYLES.ht,X=X!=null?X:o.DEFAULT_STYLES.pd,h.renderMode===o.DataValidationRenderMode.ARROW){const{l:g=o.DEFAULT_STYLES.pd.l,t:w=o.DEFAULT_STYLES.pd.t,r:_=o.DEFAULT_STYLES.pd.r,b:A=o.DEFAULT_STYLES.pd.b}=X,O=E-g-_-ut-4,{documentSkeleton:Y,documents:G,docModel:J}=Zt(j,this._localeService,s);N===o.WrapStrategy.WRAP&&J.updateDocumentDataPageSize(Math.max(O,1)),Y.calculate(),Y.getActualSize();const et=at.getDocsSkeletonPageSize(Y),{height:nt,width:it}=et,{paddingTop:$,paddingLeft:T}=nn(O,I-w-A,it,nt,R,H,!0);this._drawDownIcon(t,V,E,I,nt,R,X),t.save(),t.translateWithPrecision(V.startX+g,V.startY+w),t.beginPath(),t.rect(0,0,E-g-_,I-w-A),t.clip(),t.translateWithPrecision(0,$),t.save(),t.translateWithPrecision(Dt,0),t.beginPath(),t.rect(0,0,O,nt),t.clip(),G.render(t),t.translateWithPrecision(T,0),t.restore(),t.restore(),F.set(L,{left:V.endX+g+a.rowHeaderWidth-ut,top:V.startY+w+a.columnHeaderHeight,width:ut,height:I-w-A})}else{t.save(),t.translateWithPrecision(V.startX,V.startY),t.beginPath(),t.rect(0,0,E,I),t.clip();const g=E-pt*2-Dt-ut-4,{documentSkeleton:w,documents:_,docModel:A}=Zt(j,this._localeService,s);N===o.WrapStrategy.WRAP&&A.updateDocumentDataPageSize(Math.max(g,1)),w.calculate();const O=at.getDocsSkeletonPageSize(w),{height:Y,width:G}=O,{paddingTop:J,paddingLeft:et}=nn(g,I,G,Y,R,H);t.translateWithPrecision(pt,J);const nt=Math.max(E-pt*2,1),it=Y;at.Rect.drawWith(t,{width:nt,height:it,fill:(k==null?void 0:k.color)||It,radius:ge}),t.save(),t.translateWithPrecision(Dt,0),t.beginPath(),t.rect(0,0,g,Y),t.clip(),t.translateWithPrecision(et,0),_.render(t),t.restore(),t.translateWithPrecision(g+Dt+4,(Y-Gt)/2),t.fillStyle=Za,t.fill(tn),t.restore(),F.set(L,{left:V.startX+pt+a.rowHeaderWidth,top:V.startY+J+a.columnHeaderHeight,width:nt,height:it})}}calcCellAutoHeight(t){var I;const{primaryWithCoord:e,style:a,data:n}=t,i=e.isMergedMainCell?e.mergeInfo:e,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:u=0}=r||{},h=(I=n.dataValidation)==null?void 0:I.rule;if(!h||h.renderMode===o.DataValidationRenderMode.TEXT)return;const f={startX:i.startX+s,endX:i.endX-d,startY:i.startY+l,endY:i.endY-u},c=f.endX-f.startX,C=x.getCellValueOrigin(n),v=`${C!=null?C:""}`;let{tb:p,pd:y}=a||{};const{t:V=o.DEFAULT_STYLES.pd.t,b:E=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(p=p!=null?p:o.WrapStrategy.WRAP,h.renderMode===o.DataValidationRenderMode.ARROW){const F=c-ut,{documentSkeleton:L,docModel:P}=Zt(v,this._localeService,a);p===o.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(F,1)),L.calculate(),L.getActualSize();const M=at.getDocsSkeletonPageSize(L),{height:j}=M;return j+V+E+Et*2}else{const F=c-pt*2-Dt-ut,{documentSkeleton:L,docModel:P}=en(v,this._localeService,a);p===o.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(F,1)),L.calculate();const M=at.getDocsSkeletonPageSize(L),{height:j}=M;return j+Et*2}}calcCellAutoWidth(t){var j;const{primaryWithCoord:e,style:a,data:n}=t,i=e.isMergedMainCell?e.mergeInfo:e,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:u=0}=r||{},h=(j=n.dataValidation)==null?void 0:j.rule;if(!h||h.renderMode===o.DataValidationRenderMode.TEXT)return;const f={startX:i.startX+s,endX:i.endX-d,startY:i.startY+l,endY:i.endY-u},c=f.endX-f.startX,C=x.getCellValueOrigin(n),v=`${C!=null?C:""}`;let{tb:p,pd:y}=a||{};const{l:V=o.DEFAULT_STYLES.pd.l,r:E=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};p=p!=null?p:o.WrapStrategy.WRAP;let I=pt*2+ut;switch(h.renderMode){case o.DataValidationRenderMode.ARROW:I=ut+pt*2+E+V;break;case o.DataValidationRenderMode.CUSTOM:I=ut+pt*2+Dt*2+E+V+ge/2+1;break;default:I=ut+pt*2+Dt*2+E+V+ge/2+1}const F=c-I,{documentSkeleton:L,docModel:P}=Zt(v,this._localeService,a);return p===o.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(F,1)),L.calculate(),L.getActualSize(),at.getDocsSkeletonPageSize(L).width+I}isHit(t,e){const{data:a,subUnitId:n,row:i,col:r}=e,d=this._ensureMap(n).get(this._generateKey(i,r)),l=a.dataValidation;if(!l||!d||l.rule.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:u,left:h,width:f,height:c}=d,{x:C,y:v}=t;return C>=h&&C<=h+f&&v>=u&&v<=u+c}onPointerDown(t,e){if(e.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=t,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ft.id,s)}};Se=Ga([Qe(0,o.Inject(o.LocaleService)),Qe(1,o.ICommandService)],Se);class Ja extends ft{constructor(){super(...arguments);B(this,"id",o.DataValidationType.LIST);B(this,"canvasRender",this.injector.createInstance(Se));B(this,"dropdown",Ut);B(this,"optionsInput",Yt.componentKey);B(this,"formulaInput",ce)}}class Qa extends ft{constructor(){super(...arguments);B(this,"id",o.DataValidationType.TEXT_LENGTH);B(this,"formulaInput",Ht)}}class ti extends ft{constructor(){super(...arguments);B(this,"id",o.DataValidationType.WHOLE);B(this,"formulaInput",Ht)}}var ei=Object.defineProperty,ni=Object.getOwnPropertyDescriptor,ai=(t,e,a,n)=>{for(var i=n>1?void 0:n?ni(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ei(e,a,i),i},_e=(t,e)=>(a,n)=>e(a,n,t);let Rt=class extends o.RxDisposable{constructor(t,e,a){super(),this._injector=t,this._componentManger=e,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[ke,Te],[ne,zn],[Fe,jn],[Ut,Nn],[re,_n],[Yt.componentKey,Yt],[Xt.componentKey,Xt],...Da].forEach(([t,e])=>{this.disposeWithMe(this._componentManger.register(t,e))})}_registerValidatorViews(){[$a,ti,Qa,Aa,La,Ja,Xa,Pa].forEach(t=>{const e=this._injector.createInstance(t),a=this._dataValidatorRegistryService.getValidatorItem(e.id);a&&(a.formulaInput=e.formulaInput,a.canvasRender=e.canvasRender,a.dropdown=e.dropdown,a.optionsInput=e.optionsInput)})}};Rt=ai([_e(0,o.Inject(o.Injector)),_e(1,o.Inject(tt.ComponentManager)),_e(2,o.Inject(ot.DataValidatorRegistryService))],Rt);var ii=Object.defineProperty,oi=Object.getOwnPropertyDescriptor,ri=(t,e,a,n)=>{for(var i=n>1?void 0:n?oi(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ii(e,a,i),i},Ie=(t,e)=>(a,n)=>e(a,n,t);const si="SHEET_DATA_VALIDATION_UI_PLUGIN";q.UniverSheetsDataValidationUIPlugin=(qt=class extends o.Plugin{constructor(e=Ue,a,n,i){super(),this._config=e,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(ie,s)}onStarting(){[[ht],[gt],[jt],[yt],[bt],[Vt],[Mt],[Lt],[Rt]].forEach(e=>{this._injector.add(e)}),[kt,Ft,Ne,ae,_t,xe].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(Mt),this._injector.get(Vt),this._injector.get(Lt),this._injector.get(jt),this._injector.get(at.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Wt])}onRendered(){this._injector.get(Rt),this._injector.get(bt)}onSteady(){this._injector.get(yt)}},B(qt,"pluginName",si),B(qt,"type",o.UniverInstanceType.UNIVER_SHEET),qt),q.UniverSheetsDataValidationUIPlugin=ri([Ie(1,o.Inject(o.Injector)),Ie(2,o.ICommandService),Ie(3,o.IConfigService)],q.UniverSheetsDataValidationUIPlugin);var li=Object.defineProperty,di=Object.getOwnPropertyDescriptor,ci=(t,e,a,n)=>{for(var i=n>1?void 0:n?di(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&li(e,a,i),i},Ce=(t,e)=>(a,n)=>e(a,n,t);const ui="SHEET_DATA_VALIDATION_UI_PLUGIN";q.UniverSheetsDataValidationMobileUIPlugin=(Jt=class extends o.Plugin{constructor(e=Ue,a,n,i){super(),this._config=e,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(ie,s)}onStarting(){[[ht],[gt],[jt],[yt],[bt],[Vt],[Mt],[Rt]].forEach(e=>{this._injector.add(e)}),[kt,Ft,Ne,ae,_t,xe].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(Mt),this._injector.get(Vt),this._injector.get(at.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Wt])}onRendered(){this._injector.get(Rt),this._injector.get(bt)}onSteady(){this._injector.get(yt)}},B(Jt,"pluginName",ui),B(Jt,"type",o.UniverInstanceType.UNIVER_SHEET),Jt),q.UniverSheetsDataValidationMobileUIPlugin=ci([Ce(1,o.Inject(o.Injector)),Ce(2,o.ICommandService),Ce(3,o.IConfigService)],q.UniverSheetsDataValidationMobileUIPlugin),q.DATE_DROPDOWN_KEY=re,q.LIST_DROPDOWN_KEY=Ut,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});
9
+ */var en=g,tn=Symbol.for("react.element"),nn=Symbol.for("react.fragment"),an=Object.prototype.hasOwnProperty,on=en.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,rn={key:!0,ref:!0,__self:!0,__source:!0};function Dt(e,t,a){var n,i={},r=null,s=null;a!==void 0&&(r=""+a),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)an.call(t,n)&&!rn.hasOwnProperty(n)&&(i[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)i[n]===void 0&&(i[n]=t[n]);return{$$typeof:tn,type:e,key:r,ref:s,props:i,_owner:on.current}}je.Fragment=nn,je.jsx=Dt,je.jsxs=Dt,Ct.exports=je;var h=Ct.exports,sn=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,dn=(e,t,a,n)=>{for(var i=n>1?void 0:n?ln(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&sn(t,a,i),i},Oe=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends o.Disposable{constructor(e,t,a,n,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var f;const n=await e,{worksheet:i,row:r,col:s,unitId:d,subUnitId:l,workbook:p}=t,u=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),m=u?this._dataValidationModel.getRuleById(d,l,u):void 0;if(!m||m.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(m.type);if(!c||await c.validator({value:R.getCellValueOrigin(n),interceptValue:R.getCellValueOrigin((f=t==null?void 0:t.origin)!=null?f:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:i,workbook:p,t:n==null?void 0:n.t},m))return a(Promise.resolve(n));const v=i.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(m,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:g.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(v))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:g.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Te=dn([Oe(0,o.Inject(X.SheetInterceptorService)),Oe(1,o.Inject(R.SheetDataValidationModel)),Oe(2,o.Inject(Q.DataValidatorRegistryService)),Oe(3,z.IDialogService),Oe(4,o.Inject(o.LocaleService))],Te);const wt={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},cn=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function un(e){var b,I,V;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d,workbook:l}=t,p=o.useDependency(o.ICommandService),u=o.useDependency(Te),m=n.getCell(i,r),c=(b=m==null?void 0:m.dataValidation)==null?void 0:b.rule,S=(I=m==null?void 0:m.dataValidation)==null?void 0:I.validator,v=R.getCellValueOrigin(n.getCellRaw(i,r)),f=cn(v),[D,C]=g.useState(f),w=!!((V=c==null?void 0:c.bizInfo)!=null&&V.showTime),_=D&&D.isValid()?D:o.dayjs(),M=o.useDependency(o.LocaleService);if(!m||!c||!S)return;const E=async()=>{var U,k,K;if(!_)return;const Y=_.format(w?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),F=(U=o.numfmt.parseDate(Y))==null?void 0:U.v,P=l.getStyles().getStyleByCell(m),j=(K=(k=P==null?void 0:P.n)==null?void 0:k.pattern)!=null?K:"",x=Jt.getPatternType(j);c.errorStyle!==o.DataValidationErrorStyle.STOP||await S.validator({value:F,unitId:s,subUnitId:d,row:i,column:r,worksheet:n,workbook:l,interceptValue:Y.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(a(),await p.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),await p.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:F,t:2,p:null,f:null,si:null,s:{n:{pattern:w?x==="datetime"?j:"yyyy-MM-dd hh:mm:ss":x==="date"?j:"yyyy-MM-dd"}}}})):u.showReject(S.getRuleFinalError(c,{row:i,col:r,unitId:s,subUnitId:d}))};return h.jsxs("div",{className:wt.dvDateDropdown,children:[h.jsx(T.DatePanel,{defaultValue:_,pickerValue:_,showTime:w||void 0,onSelect:async A=>{C(A)},onPanelChange:A=>{C(A)},disabledDate:A=>!o.numfmt.parseDate(A.format("YYYY-MM-DD"))}),h.jsx("div",{className:wt.dvDateDropdownBtns,children:h.jsx(T.Button,{size:"small",type:"primary",onClick:E,disabled:!_.isValid(),children:M.t("dataValidation.alert.ok")})})]})}var le=function(){return le=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},le.apply(this,arguments)},pn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(a[n[i]]=e[n[i]]);return a},ve=g.forwardRef(function(e,t){var a=e.icon,n=e.id,i=e.className,r=e.extend,s=pn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=g.useRef("_".concat(vn()));return yt(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},le({ref:t,className:d},s),r)});function yt(e,t,a,n,i){return g.createElement(e.tag,le(le({key:t},hn(e,a,i)),n),(mn(e,a).children||[]).map(function(r,s){return yt(r,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,i)}))}function hn(e,t,a){var n=le({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function mn(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?le(le({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?le(le({},i),{attrs:le(le({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function vn(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var fn={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"}}]},Vt=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"check-mark-single",ref:t,icon:fn}))});Vt.displayName="CheckMarkSingle";var gn={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"}}]},Et=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:gn}))});Et.displayName="DataValidationSingle";var Sn={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"}}]},et=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:Sn}))});et.displayName="DeleteSingle";var _n={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"}}]},Rt=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:_n}))});Rt.displayName="IncreaseSingle";var In={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"}}]},Mt=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:In}))});Mt.displayName="MoreDownSingle";var Cn={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"}}]},bt=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:Cn}))});bt.displayName="MoreUpSingle";var Dn={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"}}]}]},Ot=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:Dn}))});Ot.displayName="SequenceSingle";var wn=Object.defineProperty,yn=Object.getOwnPropertyDescriptor,Vn=(e,t,a,n)=>{for(var i=n>1?void 0:n?yn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&wn(t,a,i),i},Tt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends o.Disposable{constructor(t,a){super();L(this,"_open$",new se.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(se.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new se.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(se.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===tt&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=Vn([Tt(0,o.IUniverInstanceService),Tt(1,z.ISidebarService)],ue);function En(){const e=o.useDependency(fe),t=z.useObservable(e.activeDropdown$,e.activeDropdown),a=o.useDependency(z.ComponentManager);if(!t)return null;const{location:n,componentKey:i}=t,r=a.get(i),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{e.hideDropdown()};return h.jsx(r,{location:n,hideFn:d},s)}const Lt="sheet.ui.dropdown";var Rn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,bn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Mn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Rn(t,a,i),i},Se=(e,t)=>(a,n)=>t(a,n,e);let fe=class extends o.Disposable{constructor(t,a,n,i,r,s,d){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new se.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=i,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,i){const r=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t,a=!0){const{location:n}=t,{row:i,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),p=this._canvasPopupManagerService.attachPopupToCell(i,r,{componentKey:Lt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const u=new o.DisposableCollection;u.add(p),u.add({dispose:()=>{var m,c;(c=(m=this._activeDropdown)==null?void 0:m.onHide)==null||c.call(m)}}),this._currentPopup=u}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,i,r){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,i);if(!l)return;const p=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!p||!p.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:i,unitId:t,subUnitId:a},componentKey:p.dropdown,onHide:r})}};fe=bn([Se(0,o.Inject(N.SheetCanvasPopManagerService)),Se(1,o.IUniverInstanceService),Se(2,o.Inject(Q.DataValidatorRegistryService)),Se(3,z.IZenZoneService),Se(4,B.IRenderManagerService),Se(5,o.Inject(R.SheetDataValidationModel)),Se(6,o.Inject(X.SheetsSelectionsService))],fe);const tt="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,i=e.get(ue),r=e.get(Q.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(z.ISidebarService),l=X.getSheetCommandTarget(s);if(!l)return!1;const{unitId:p,subUnitId:u}=l,m=a?r.getRuleById(p,u,a):void 0;i.open(),i.setActiveRule(m&&{unitId:p,subUnitId:u,rule:m});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:tt},width:312,onClose:()=>i.close()});return i.setCloseDisposable(c),!0}},nt={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Pt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(nt.id):t.executeCommand(_e.id),!0}},Ae={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(fe),{unitId:n,subUnitId:i,row:r,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===i&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,i,r,s),!0}},jt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Ie="#ECECEC",at="sheets-data-validation-ui.config",At={},me={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},On=e=>{var E,b;const{value:t,onChange:a,multiple:n,options:i,title:r,onEdit:s,style:d,filter:l,location:p}=e,u=o.useDependency(o.LocaleService),m=o.useDependency(o.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:S,col:v,unitId:f,subUnitId:D}=p,C=i.filter(I=>c?I.label.toLowerCase().includes(c):!0),w=(b=(E=m.getConfig(at))==null?void 0:E.showEditOnDropdown)!=null?b:!0,_=o.useDependency(N.SheetPermissionInterceptorBaseController),M=g.useMemo(()=>_.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:v,startRow:S,endColumn:v,endRow:S}],f,D),[_,v,S,f,D]);return h.jsxs("div",{className:me.dvListDropdown,style:d,children:[h.jsx("div",{className:me.dvListDropdownTitle,children:r}),h.jsx("div",{className:me.dvListDropdownList,children:h.jsx(T.Scrollbar,{children:h.jsx("div",{className:me.dvListDropdownListContainer,children:C.map((I,V)=>{const A=t.indexOf(I.value)>-1,Y=()=>{let P;A?P=new Set(t.filter(x=>x!==I.value)):P=new Set(n?[...t,I.value]:[I.value]);const j=[];i.forEach(x=>{P.has(x.value)&&j.push(x.value)}),a(j)},F=I.label.toLocaleLowerCase().indexOf(c);return h.jsxs("div",{className:me.dvListDropdownItemContainer,onClick:Y,children:[h.jsx("div",{className:me.dvListDropdownItem,style:{background:I.color||Ie},children:c&&I.label.toLowerCase().includes(c)?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:I.label.substring(0,F)}),h.jsx("span",{style:{fontWeight:"bold"},children:I.label.substring(F,F+c.length)}),h.jsx("span",{children:I.label.substring(F+c.length)})]}):I.label}),h.jsx("div",{className:me.dvListDropdownSelectedIcon,children:A?h.jsx(Vt,{}):null})]},V)})})},l)}),w&&M?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:me.dvListDropdownSplit}),h.jsx("div",{className:me.dvListDropdownEdit,children:h.jsx("a",{onClick:s,children:u.t("dataValidation.list.edit")})})]}):null]})};function Tn(e){var x,U,k,K,G,te;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d}=t,l=o.useDependency(Q.DataValidationModel),[p,u]=g.useState(""),m=o.useDependency(o.ICommandService),c=o.useDependency(o.LocaleService),[S,v]=g.useState(""),f=o.useDependency(N.IEditorBridgeService),D=o.useDependency(o.IUniverInstanceService),C=g.useMemo(()=>l.ruleChange$.pipe(se.debounceTime(16)),[]);z.useObservable(C);const w=z.RectPopup.useContext(),_=((U=(x=w.current)==null?void 0:x.right)!=null?U:0)-((K=(k=w.current)==null?void 0:k.left)!=null?K:0);if(g.useEffect(()=>{const Z=m.onCommandExecuted(J=>{var ne,re;if(J.id===Qt.RichTextEditingMutation.id){const de=J.params,{unitId:ae}=de,oe=D.getUnit(ae,o.UniverInstanceType.UNIVER_DOC);if(!oe)return;const O=o.BuildTextUtils.transform.getPlainText((re=(ne=oe.getSnapshot().body)==null?void 0:ne.dataStream)!=null?re:"");u(O)}});return()=>{Z.dispose()}},[m,D]),!n)return null;const M=n.getCell(i,r),E=(G=M==null?void 0:M.dataValidation)==null?void 0:G.rule,b=(te=M==null?void 0:M.dataValidation)==null?void 0:te.validator,I=(E==null?void 0:E.renderMode)===o.DataValidationRenderMode.CUSTOM||(E==null?void 0:E.renderMode)===void 0;if(!M||!E||!b||b.id.indexOf(o.DataValidationType.LIST)!==0)return;const V=E.type===o.DataValidationType.LIST_MULTIPLE,A=b.getListWithColor(E,s,d),Y=S||R.getDataValidationCellValue(n.getCellRaw(i,r)),F=R.deserializeListOptions(Y),P=()=>{m.executeCommand(_e.id,{ruleId:E.uid}),a()},j=A.map(Z=>({label:Z.label,value:Z.label,color:I||Z.color?Z.color:"transparent"}));return h.jsx(On,{style:{minWidth:_,maxWidth:Math.max(_,200)},title:V?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:F,multiple:V,onChange:async Z=>{const J=R.serializeListOptions(Z),ne={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:J,p:null,f:null,si:null}};f.isVisible()&&f.changeVisible({visible:!1,keycode:z.KeyCode.ESC,eventType:B.DeviceInputEventType.Keyboard,unitId:s}),v(J),V||a(),f.isVisible().visible&&await m.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),m.executeCommand(X.SetRangeValuesCommand.id,ne)},options:j,onEdit:P,filter:p,location:t})}const it={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function Ln(e){var p;const t=o.useDependency(o.LocaleService),a=o.useDependency(z.ComponentManager),{value:n,onChange:i,extraComponent:r}=e,[s,d]=g.useState(!1),l=r?a.get(r):null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:it.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?h.jsx(bt,{className:it.dataValidationOptionsButtonIcon}):h.jsx(Mt,{className:it.dataValidationOptionsButtonIcon})]}),s&&h.jsxs(h.Fragment,{children:[l?h.jsx(l,{value:n,onChange:i}):null,h.jsx(T.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:h.jsxs(T.RadioGroup,{value:`${(p=n.errorStyle)!=null?p:o.DataValidationErrorStyle.WARNING}`,onChange:u=>i({...n,errorStyle:+u}),children:[h.jsx(T.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),h.jsx(T.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),h.jsx(T.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:h.jsx(T.Checkbox,{checked:n.showErrorMessage,onChange:()=>i({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?h.jsx(T.FormLayout,{children:h.jsx(T.Input,{value:n.error,onChange:u=>i({...n,error:u})})}):null]})]})}const we={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},Pn=e=>o.debounce(async(t,a,n,i)=>{const r=await e.executeCommand(t,a,n);i==null||i(r)},1e3);function jn(e,t,a){var n,i,r,s;return t?((i=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function An(){var oe;const[e,t]=g.useState(0),a=o.useDependency(ue),n=z.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},d=s.uid,l=o.useDependency(Q.DataValidatorRegistryService),p=o.useDependency(o.IUniverInstanceService),u=o.useDependency(z.ComponentManager),m=o.useDependency(o.ICommandService),c=o.useDependency(Q.DataValidationModel),S=o.useDependency(o.LocaleService),[v,f]=g.useState(s),D=l.getValidatorItem(v.type),[C,w]=g.useState(!1),_=l.getValidatorsByScope(Q.DataValidatorRegistryScope.SHEET),[M,E]=g.useState(()=>v.ranges.map(O=>({unitId:"",sheetId:"",range:O}))),b=g.useMemo(()=>Pn(m),[m]),[I,V]=g.useState(!1),A=g.useRef({}),[Y,F]=g.useState(!1),P=o.useDependency(X.SheetsSelectionsService);if(g.useEffect(()=>()=>{const O=P.getCurrentLastSelection();O&&P.setSelections([O])},[P]),g.useEffect(()=>{m.onCommandExecuted(O=>{(O.id===o.UndoCommand.id||O.id===o.RedoCommand.id)&&setTimeout(()=>{const y=c.getRuleById(i,r,d);t(W=>W+1),y&&(f(y),E(y.ranges.map(W=>({unitId:"",sheetId:"",range:W}))))},20)})},[m,c,d,r,i]),!D)return null;const j=D.operators,x=D.operatorNames,U=v.operator?Q.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,k=()=>{!v.ranges.length||I||(D.validatorFormula(v,i,r).success?a.setActiveRule(null):w(!0))},K=z.useEvent(O=>{const y=O.split(",").map(Je.deserializeRangeWithSheet).map(q=>{const ge=q.sheetName;if(ge){const ai=jn(p,q.unitId,ge);return{...q,sheetId:ai}}return{...q,sheetId:""}});if(o.isUnitRangesEqual(y,M))return;E(y);const W=y.filter(q=>(!q.unitId||q.unitId===i)&&(!q.sheetId||q.sheetId===r)).map(q=>q.range);if(f({...v,ranges:W}),W.length===0)return;const $={unitId:i,subUnitId:r,ruleId:d,ranges:W};b(R.UpdateSheetDataValidationRangeCommand.id,$)}),G=O=>{if(o.shallowEqual(O,Q.getRuleSetting(v)))return;f({...v,...O});const y={unitId:i,subUnitId:r,ruleId:d,setting:O};b(R.UpdateSheetDataValidationSettingCommand.id,y,void 0)},te=async()=>{await m.executeCommand(R.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:r}),a.setActiveRule(null)},Z={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},J=O=>{const y=l.getValidatorItem(O);if(!y)return;const W=y.operators,$=c.getRuleById(i,r,d),q=O===($==null?void 0:$.type)||O.includes("list")&&($!=null&&$.type.includes("list"))?{...$,type:O}:{...v,type:O,operator:W[0],formula1:void 0,formula2:void 0};f(q),m.executeCommand(R.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:v.uid,setting:Q.getRuleSetting(q)})},ne=u.get(D.formulaInput),re=g.useMemo(()=>M.map(O=>Je.serializeRange(O.range)).join(","),[]),de=Q.getRuleOptions(v),ae=O=>{o.shallowEqual(O,Q.getRuleOptions(v))||(f({...v,...O}),b(R.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:d,options:O}))};return z.useSidebarClick(O=>{var W;const y=(W=A.current)==null?void 0:W.handleOutClick;y&&y(O,()=>F(!1))}),h.jsxs("div",{className:we.dataValidationDetail,children:[h.jsx(T.FormLayout,{label:S.t("dataValidation.panel.range"),error:!v.ranges.length||I?S.t("dataValidation.panel.rangeError"):"",children:h.jsx(Qe.RangeSelector,{unitId:i,subUnitId:r,initValue:re,onChange:K,onFocus:()=>F(!0),isFocus:Y,actions:A.current,onVerify:O=>V(!O)})}),h.jsx(T.FormLayout,{label:S.t("dataValidation.panel.type"),children:h.jsx(T.Select,{options:_==null?void 0:_.map(O=>({label:S.t(O.title),value:O.id})),value:v.type,onChange:J,className:we.dataValidationDetailFormItem})}),j!=null&&j.length?h.jsx(T.FormLayout,{label:S.t("dataValidation.panel.operator"),children:h.jsx(T.Select,{options:j.map((O,y)=>({value:`${O}`,label:x[y]})),value:`${v.operator}`,onChange:O=>{G({...Z,operator:O})},className:we.dataValidationDetailFormItem})}):null,ne?h.jsx(ne,{isTwoFormula:U,value:{formula1:v.formula1,formula2:v.formula2},onChange:O=>{G({...Z,...O})},showError:C,validResult:D.validatorFormula(v,i,r),unitId:i,subUnitId:r,ruleId:d},e+v.type):null,h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:(oe=v.allowBlank)!=null?oe:!0,onChange:()=>{var O;return G({...Z,allowBlank:!((O=v.allowBlank)==null||O)})},children:S.t("dataValidation.panel.allowBlank")})}),h.jsx(Ln,{value:de,onChange:ae,extraComponent:D.optionsInput}),h.jsxs("div",{className:we.dataValidationDetailButtons,children:[h.jsx(T.Button,{className:we.dataValidationDetailButton,onClick:te,children:S.t("dataValidation.panel.removeRule")}),h.jsx(T.Button,{className:we.dataValidationDetailButton,type:"primary",onClick:k,children:S.t("dataValidation.panel.done")})]})]})}const Fe={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Fn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:i,disable:r}=e,s=o.useDependency(Q.DataValidatorRegistryService),d=o.useDependency(o.ICommandService),l=o.useDependency(N.IMarkSelectionService),p=s.getValidatorItem(t.type),u=g.useRef(),[m,c]=g.useState(!1),S=v=>{d.executeCommand(R.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:i}),v.stopPropagation()};return g.useEffect(()=>()=>{var v;u.current&&((v=u.current)==null||v.forEach(f=>{f&&l.removeShape(f)}))},[l]),h.jsxs("div",{className:Fe.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),u.current=t.ranges.map(v=>l.addShape({range:v,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var v;c(!1),(v=u.current)==null||v.forEach(f=>{f&&l.removeShape(f)}),u.current=void 0},children:[h.jsx("div",{className:Fe.dataValidationItemTitle,children:p==null?void 0:p.generateRuleName(t)}),h.jsx("div",{className:Fe.dataValidationItemContent,children:t.ranges.map(v=>Je.serializeRange(v)).join(",")}),m?h.jsx("div",{className:Fe.dataValidationItemIcon,onClick:S,children:h.jsx(et,{})}):null]})},xe={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function xn(){const e=o.useDependency(o.IUniverInstanceService),t=z.useObservable(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?h.jsx(Nn,{workbook:t}):null}function Nn(e){const t=o.useDependency(R.SheetDataValidationModel),a=o.useDependency(o.IUniverInstanceService),n=o.useDependency(o.ICommandService),i=o.useDependency(o.Injector),r=o.useDependency(ue),s=o.useDependency(o.LocaleService),[d,l]=g.useState([]),{workbook:p}=e,u=z.useObservable(p.activeSheet$,void 0,!0),m=p.getUnitId(),c=u==null?void 0:u.getSheetId();g.useEffect(()=>{l(t.getRules(m,c));const w=t.ruleChange$.subscribe(_=>{_.unitId===m&&_.subUnitId===c&&l(t.getRules(m,c))});return()=>{w.unsubscribe()}},[m,c,t]);const S=async()=>{const w=R.createDefaultNewRule(i),_={unitId:m,subUnitId:c,rule:w};await n.executeCommand(R.AddSheetDataValidationCommand.id,_),r.setActiveRule({unitId:m,subUnitId:c,rule:w})},v=()=>{n.executeCommand(R.RemoveSheetAllDataValidationCommand.id,{unitId:m,subUnitId:c})},D=(w=>{const _=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),M=_.getActiveSheet(),E=_.getUnitId(),b=M.getSheetId();return w.map(V=>X.checkRangesEditablePermission(i,E,b,V.ranges)?{...V}:{...V,disable:!0})})(d),C=D==null?void 0:D.some(w=>w.disable);return h.jsxs("div",{className:xe.dataValidationList,children:[D==null?void 0:D.map(w=>{var _;return h.jsx(Fn,{unitId:m,subUnitId:c,onClick:()=>{w.disable||r.setActiveRule({unitId:m,subUnitId:c,rule:w})},rule:w,disable:(_=w.disable)!=null?_:!1},w.uid)}),h.jsxs("div",{className:xe.dataValidationListButtons,children:[d.length&&!C?h.jsx(T.Button,{className:xe.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,h.jsx(T.Button,{className:xe.dataValidationListButton,type:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const Un=()=>{const e=o.useDependency(ue),t=z.useObservable(e.activeRule$,e.activeRule);return t?h.jsx(An,{},t.rule.uid):h.jsx(xn,{})},Ne="data-validation.list.dropdown",ot="data-validation.date.dropdown",Ue={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:i}=a,r=R.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=i.getSheetId(),p={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(R.AddSheetDataValidationCommand.id,p)?(s.syncExecuteCommand(_e.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var Bn=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Wn=(e,t,a,n)=>{for(var i=n>1?void 0:n?kn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Bn(t,a,i),i},Le=(e,t)=>(a,n)=>t(a,n,e);const Be="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends o.Disposable{constructor(e,t,a,n,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(se.debounceTime(100)).subscribe(e=>{var t,a;if(e){const i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!i)return;const r=i.getCell(e.location.row,e.location.col);if(((t=r==null?void 0:r.dataValidation)==null?void 0:t.validStatus)===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Be),d=(a=s==null?void 0:s.alert)==null?void 0:a.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId)return;const l=r.dataValidation.validator,p=r.dataValidation.rule;if(!l)return;this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(p,e.location),location:e.location,width:200,height:74,key:Be});return}}this._cellAlertManagerService.removeAlert(Be)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Be)}))}};Pe=Wn([Le(0,o.Inject(N.HoverManagerService)),Le(1,o.Inject(N.CellAlertManagerService)),Le(2,o.IUniverInstanceService),Le(3,o.Inject(o.LocaleService)),Le(4,z.IZenZoneService)],Pe);var $n=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,Yn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Hn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&$n(t,a,i),i},rt=(e,t)=>(a,n)=>t(a,n,e);let ye=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._dataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(i,r)=>{const{source:s,target:d,unitId:l,subUnitId:p}=i,u=this._dataValidationModel.getRuleObjectMatrix(l,p).clone(),m=N.virtualizeDiscreteRanges([s,d]),[c,S]=m.ranges,{mapFunc:v}=m,f={row:c.startRow,col:c.startColumn},D=N.getAutoFillRepeatRange(c,S),C=new o.ObjectMatrix,w=new Set;D.forEach(I=>{const V=I.repeatStartCell,A=I.relativeRange,Y={startRow:f.row,startColumn:f.col,endColumn:f.col,endRow:f.row},F={startRow:V.row,startColumn:V.col,endColumn:V.col,endRow:V.row};o.Range.foreach(A,(P,j)=>{const x=o.Rectangle.getPositionRange({startRow:P,startColumn:j,endColumn:j,endRow:P},Y),{row:U,col:k}=v(x.startRow,x.startColumn),K=this._dataValidationModel.getRuleIdByLocation(l,p,U,k);if(K){const G=o.Rectangle.getPositionRange({startRow:P,startColumn:j,endColumn:j,endRow:P},F),{row:te,col:Z}=v(G.startRow,G.startColumn);C.setValue(te,Z,K),w.add(K)}})});const _=Array.from(w).map(I=>({id:I,ranges:o.queryObjectMatrix(C,V=>V===I)}));u.addRangeRules(_);const M=u.diff(this._dataValidationModel.getRules(l,p)),{redoMutations:E,undoMutations:b}=R.getDataValidationDiffMutations(l,p,M,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:b,redos:E}},a=[o.DataValidationType.CHECKBOX],n={id:R.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:i=>{const{source:r,unitId:s,subUnitId:d}=i;for(const l of r.rows)for(const p of r.cols){const u=this._dataValidationModel.getRuleByLocation(s,d,l,p);if(u&&a.indexOf(u.type)>-1){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(i,r,s)=>s===N.APPLY_TYPE.COPY||s===N.APPLY_TYPE.ONLY_FORMAT||s===N.APPLY_TYPE.SERIES?t(i,s):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};ye=Yn([rt(0,N.IAutoFillService),rt(1,o.Inject(R.SheetDataValidationModel)),rt(2,o.Inject(o.Injector))],ye);var Xn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,Kn=(e,t,a,n)=>{for(var i=n>1?void 0:n?zn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xn(t,a,i),i},st=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends o.Disposable{constructor(t,a,n){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:R.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,i)=>{const{copyType:r=N.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:p,subUnitId:u}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:p,subUnitId:u})}})}_collect(t,a,n){const i=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:i};const r=this._injector.invoke(l=>N.rangeToDiscreteRange(n,l,t,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,p)=>{d.forEach((u,m)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,u);i.setValue(p,m,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:n,subUnitId:i}=this._copyInfo;if(a.unitId!==n||i!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,p],mapFunc:u}=N.virtualizeDiscreteRanges([a.copyRange,t]),m=N.getRepeatRange(l,p,!0),c=new Map;m.forEach(({startRange:D})=>{var C;(C=this._copyInfo)==null||C.matrix.forValue((w,_,M)=>{const E=o.Rectangle.getPositionRange({startRow:w,endRow:w,startColumn:_,endColumn:_},D),b=`${i}-${M}`,I=this._sheetDataValidationModel.getRuleById(n,i,M);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,b)&&I&&c.set(b,{...I,uid:b});const{row:V,col:A}=u(E.startRow,E.startColumn);d.add(b),s.setValue(V,A,b)})});const S=Array.from(d).map(D=>({id:D,ranges:o.queryObjectMatrix(s,C=>C===D)}));r.addRangeRules(S);const{redoMutations:v,undoMutations:f}=R.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:v,undos:f}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,i).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,p],mapFunc:u}=N.virtualizeDiscreteRanges([a.copyRange,t]);N.getRepeatRange(l,p,!0).forEach(({startRange:f})=>{var D;(D=this._copyInfo)==null||D.matrix.forValue((C,w,_)=>{const M=o.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:w,endColumn:w},f),{row:E,col:b}=u(M.startRow,M.startColumn);s.setValue(E,b,_),d.add(_)})});const c=Array.from(d).map(f=>({id:f,ranges:o.queryObjectMatrix(s,D=>D===f)}));r.addRangeRules(c);const{redoMutations:S,undoMutations:v}=R.getDataValidationDiffMutations(n,i,r.diff(this._sheetDataValidationModel.getRules(n,i)),this._injector,"patched",!1);return{redos:S,undos:v}}}};Ve=Kn([st(0,N.ISheetClipboardService),st(1,o.Inject(R.SheetDataValidationModel)),st(2,o.Inject(o.Injector))],Ve);var Gn=Object.defineProperty,qn=Object.getOwnPropertyDescriptor,Zn=(e,t,a,n)=>{for(var i=n>1?void 0:n?qn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Gn(t,a,i),i},lt=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===R.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),e.id===R.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Ee=Zn([lt(0,o.Inject(o.LocaleService)),lt(1,o.ICommandService),lt(2,o.Inject(N.SheetPermissionInterceptorBaseController))],Ee);const Ft="data-validation-single",xt="sheet.menu.data-validation";function Jn(e){return{id:xt,type:z.MenuItemType.SUBITEMS,icon:Ft,tooltip:"dataValidation.title",hidden$:z.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function Qn(e){return{id:_e.id,title:"dataValidation.panel.title",type:z.MenuItemType.BUTTON}}function ea(e){return{id:Ue.id,title:"dataValidation.panel.add",type:z.MenuItemType.BUTTON}}const ta={[z.RibbonStartGroup.FORMULAS_INSERT]:{[xt]:{order:9,menuItemFactory:Jn,[_e.id]:{order:0,menuItemFactory:Qn},[Ue.id]:{order:1,menuItemFactory:ea}}}};var na=Object.defineProperty,aa=Object.getOwnPropertyDescriptor,Nt=(e,t,a,n)=>{for(var i=n>1?void 0:n?aa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&na(t,a,i),i},ee=(e,t)=>(a,n)=>t(a,n,e);const Ut={tr:{size:6,color:"#fe4b4b"}};let Re=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s,d,l,p,u){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=i,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=p,this._editorBridgeService=u,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(ta)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:i,row:r,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,i,r,s);if(!l)return;const p=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(p!=null&&p.dropdown))return;const u=d.getActiveSheet();if(!u)return;const m=this._dropdownManagerService.activeDropdown,c=m==null?void 0:m.location;if(c&&c.unitId===n&&c.subUnitId===i&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:i,row:r,col:s,workbook:d,worksheet:u},componentKey:p.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var C,w,_,M,E,b;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,p=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!p)return a(e);const u=this._sheetDataValidationModel.getRuleById(r,s,p);if(!u)return a(e);const m=(w=(C=this._dataValidationCacheService.getValue(r,s,n,i))==null?void 0:C.status)!=null?w:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(u.type),S=t.rawData;let v;const f={get value(){var I;return v!==void 0||(v=(I=R.getCellValueOrigin(S))!=null?I:null),v}},D={get value(){var I;return`${(I=f.value)!=null?I:""}`}};return a({...e,dataValidation:{ruleId:p,validStatus:m,rule:u,validator:c},markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?Ut:null},customRender:[...(_=e==null?void 0:e.customRender)!=null?_:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((M=e==null?void 0:e.fontRenderExtension)==null?void 0:M.isSkip)||((E=c==null?void 0:c.skipDefaultFontRender)==null?void 0:E.call(c,u,f.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(u,D.value,{get style(){const I=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?I.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var Y,F,P,j,x,U;const I=(F=(Y=this._renderManagerService.getRenderById(r))==null?void 0:Y.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:F.skeleton;if(!I)return;const V=I.worksheet.getMergedCell(n,i),A={data:{...e,dataValidation:{ruleId:p,validStatus:m,rule:u,validator:c}},style:I.getsStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((P=V==null?void 0:V.startRow)!=null?P:n,(j=V==null?void 0:V.startColumn)!=null?j:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(U=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:U.call(x,A)},interceptorAutoWidth:()=>{var Y,F,P,j,x,U;const I=(F=(Y=this._renderManagerService.getRenderById(r))==null?void 0:Y.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:F.skeleton;if(!I)return;const V=I.worksheet.getMergedCell(n,i),A={data:{...e,dataValidation:{ruleId:p,validStatus:m,rule:u,validator:c}},style:I.getsStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((P=V==null?void 0:V.startRow)!=null?P:n,(j=V==null?void 0:V.startColumn)!=null?j:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(U=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:U.call(x,A)},coverable:((b=e==null?void 0:e.coverable)!=null?b:!0)&&!(u.type===o.DataValidationType.LIST||u.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(se.filter(e=>e.source==="command"),se.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};Re=Nt([ee(0,o.ICommandService),ee(1,z.IMenuManagerService),ee(2,B.IRenderManagerService),ee(3,o.IUniverInstanceService),ee(4,o.Inject(N.AutoHeightController)),ee(5,o.Inject(fe)),ee(6,o.Inject(R.SheetDataValidationModel)),ee(7,o.Inject(Q.DataValidatorRegistryService)),ee(8,o.Inject(X.SheetInterceptorService)),ee(9,o.Inject(R.DataValidationCacheService)),ee(10,o.Optional(N.IEditorBridgeService))],Re);let Bt=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=i,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var D,C,w,_,M,E;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,p=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!p)return a(e);const u=this._sheetDataValidationModel.getRuleById(r,s,p);if(!u)return a(e);const m=(C=(D=this._dataValidationCacheService.getValue(r,s,n,i))==null?void 0:D.status)!=null?C:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(u.type),S=l.getCellRaw(n,i),v=R.getCellValueOrigin(S),f=`${v!=null?v:""}`;return a({...e,dataValidation:{ruleId:p,validStatus:m,rule:u,validator:c},markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?Ut:null},customRender:[...(w=e==null?void 0:e.customRender)!=null?w:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((_=e==null?void 0:e.fontRenderExtension)==null?void 0:_.isSkip)||((M=c==null?void 0:c.skipDefaultFontRender)==null?void 0:M.call(c,u,v,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(u,f,{get style(){const b=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?b.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var A,Y,F,P,j,x;const b=(Y=(A=this._renderManagerService.getRenderById(r))==null?void 0:A.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:Y.skeleton;if(!b)return;const I=b.worksheet.getMergedCell(n,i),V={data:{...e,dataValidation:{ruleId:p,validStatus:m,rule:u,validator:c}},style:b.getsStyles().getStyleByCell(e),primaryWithCoord:b.getCellWithCoordByIndex((F=I==null?void 0:I.startRow)!=null?F:n,(P=I==null?void 0:I.startColumn)!=null?P:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(x=(j=c==null?void 0:c.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:x.call(j,V)},coverable:((E=e==null?void 0:e.coverable)!=null?E:!0)&&!(u.type===o.DataValidationType.LIST||u.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(se.filter(e=>e.source==="command"),se.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};Bt=Nt([ee(0,o.ICommandService),ee(1,B.IRenderManagerService),ee(2,o.Inject(N.AutoHeightController)),ee(3,o.Inject(Q.DataValidatorRegistryService)),ee(4,o.Inject(X.SheetInterceptorService)),ee(5,o.Inject(R.SheetDataValidationModel)),ee(6,o.Inject(R.DataValidationCacheService))],Bt);var ia=Object.defineProperty,oa=Object.getOwnPropertyDescriptor,ra=(e,t,a,n)=>{for(var i=n>1?void 0:n?oa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ia(t,a,i),i},kt=(e,t)=>(a,n)=>t(a,n,e);let ke=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(i=>{a.add(i.subUnitId)}),a.forEach(i=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(i))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};ke=ra([kt(1,o.Inject(R.SheetDataValidationModel)),kt(2,o.Inject(N.SheetSkeletonManagerService))],ke);const ie={dataValidationFormula:"univer-data-validation-formula",dataValidationFormulaAnd:"univer-data-validation-formula-and",dataValidationFormulaListItem:"univer-data-validation-formula-list-item",dataValidationFormulaListItemIcon:"univer-data-validation-formula-list-item-icon",dataValidationFormulaListItemDrag:"univer-data-validation-formula-list-item-drag",dataValidationFormulaListAdd:"univer-data-validation-formula-list-add",dataValidationFormulaColorSelect:"univer-data-validation-formula-color-select",dataValidationFormulaColorSelectPanel:"univer-data-validation-formula-color-select-panel",dataValidationFormulaColorItem:"univer-data-validation-formula-color-item"},sa=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:i,validResult:r}=e,s=o.useDependency(o.LocaleService),d=i?r==null?void 0:r.formula1:"",l=i?r==null?void 0:r.formula2:"";return t?h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{error:d,children:h.jsx(T.Input,{className:ie.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:p=>{n==null||n({...a,formula1:p})}})}),h.jsx("div",{className:ie.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),h.jsx(T.FormLayout,{error:l,children:h.jsx(T.Input,{className:ie.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:p=>{n==null||n({...a,formula2:p})}})})]}):h.jsx(T.FormLayout,{error:d,children:h.jsx(T.Input,{className:ie.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:p=>{n==null||n({formula1:p})}})})};function la(e){const{value:t,onChange:a,showError:n,validResult:i}=e,r=o.useDependency(o.LocaleService),s=n?i==null?void 0:i.formula1:"",d=n?i==null?void 0:i.formula2:"",[l,p]=g.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:l,onChange:u=>{u?p(!0):(p(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?h.jsx(T.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:h.jsx(T.Input,{className:ie.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:u=>{a==null||a({...t,formula1:u||void 0})}})}):null,l?h.jsx(T.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:h.jsx(T.Input,{className:ie.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:u=>{a==null||a({...t,formula2:u||void 0})}})}):null]})}function da(e){var m;const{unitId:t,subUnitId:a,value:n,onChange:i,showError:r,validResult:s}=e,d=r?s==null?void 0:s.formula1:void 0,l=g.useRef({}),[p,u]=g.useState(!1);return z.useSidebarClick(c=>{var v;const S=(v=l.current)==null?void 0:v.handleOutClick;S&&S(c,()=>u(!1))}),h.jsx(Qe.FormulaEditor,{initValue:(m=n==null?void 0:n.formula1)!=null?m:"",unitId:t,subUnitId:a,isFocus:p,onChange:c=>{const S=(c!=null?c:"").trim();S!==(n==null?void 0:n.formula1)&&(i==null||i({...n,formula1:S}))},errorText:d,onFocus:()=>u(!0),actions:l.current,isSupportAcrossSheet:!0})}function Wt(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(a=Wt(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function ca(){for(var e,t,a=0,n="",i=arguments.length;a<i;a++)(e=arguments[a])&&(t=Wt(e))&&(n&&(n+=" "),n+=t);return n}const ua=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],pa=e=>{const{value:t,onChange:a,disabled:n}=e,[i,r]=g.useState(!1);return h.jsx(T.Select,{disabled:n,open:i,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ie.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>h.jsx("div",{className:ie.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>h.jsx("div",{className:ie.dataValidationFormulaColorSelectPanel,children:ua.map(s=>h.jsx("div",{onClick:()=>{a(s),r(!1)},className:ie.dataValidationFormulaColorItem,style:{background:s}},s))})})},$t=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:i,onItemDelete:r}=a;return h.jsxs("div",{className:ie.dataValidationFormulaListItem,style:n,children:[t.isRef?null:h.jsx("div",{className:ca(ie.dataValidationFormulaListItemDrag,"draggableHandle"),children:h.jsx(Ot,{})}),h.jsx(pa,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),h.jsx(T.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)}}),t.isRef?null:h.jsx("div",{className:ie.dataValidationFormulaListItemIcon,children:h.jsx(et,{onClick:()=>r(t.id)})})]})};function ha(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:i,validResult:r,showError:s,ruleId:d}=e,{formula1:l="",formula2:p=""}=t||{},u=g.useRef(null),[m,c]=g.useState(()=>o.isFormulaString(l)?"1":"0"),[S,v]=g.useState(m==="1"?l:"="),[f,D]=g.useState(m==="1"?l:"="),C=o.useDependency(o.LocaleService),w=o.useDependency(Q.DataValidatorRegistryService),_=o.useDependency(Q.DataValidationModel),M=o.useDependency(R.DataValidationFormulaController),[E,b]=g.useState(()=>p.split(",")),I=w.getValidatorItem(o.DataValidationType.LIST),[V,A]=g.useState([]),[Y,F]=g.useState(""),P=s?r==null?void 0:r.formula1:"",j=g.useMemo(()=>_.ruleChange$.pipe(se.debounceTime(16)),[]),x=z.useObservable(j),U=z.useEvent(a);g.useEffect(()=>{(async()=>{await new Promise($=>{setTimeout(()=>$(!0),100)});const y=_.getRuleById(n,i,d),W=y==null?void 0:y.formula1;if(o.isFormulaString(W)&&I&&y){const $=await I.getListAsync(y,n,i);A($)}})()},[_,x,I,d,i,n]),g.useEffect(()=>{o.isFormulaString(l)&&l!==f&&(v(l),D(f))},[f,l]);const[k,K]=g.useState(()=>{const y=m!=="1"?R.deserializeListOptions(l):[],W=p.split(",");return y.map(($,q)=>({label:$,color:W[q]||Ie,isRef:!1,id:o.Tools.generateRandomId(4)}))}),G=(y,W,$)=>{const q=k.find(ge=>ge.id===y);q&&(q.label=W,q.color=$,K([...k]))},te=y=>{const W=k.findIndex($=>$.id===y);W!==-1&&(k.splice(W,1),K([...k]))},Z=p.split(","),J=g.useMemo(()=>V.map((y,W)=>({label:y,color:Z[W]||Ie,id:`${W}`,isRef:!0})),[Z,V]),ne=(y,W,$)=>{const q=[...E];q[+y]=$,b(q),U({formula1:l,formula2:q.join(",")})},re=()=>{K([...k,{label:"",color:Ie,isRef:!1,id:o.Tools.generateRandomId(4)}])};g.useEffect(()=>{if(m==="1")return;const y=new Set,W=[];k.map($=>({labelList:$.label.split(","),item:$})).forEach(({item:$,labelList:q})=>{q.forEach(ge=>{y.has(ge)||(y.add(ge),W.push({label:ge,color:$.color}))})}),U({formula1:R.serializeListOptions(W.map($=>$.label)),formula2:W.map($=>$.color===Ie?"":$.color).join(",")})},[k,U,m,f,E]);const de=g.useMemo(()=>async y=>{if(!o.isFormulaString(y)){U==null||U({formula1:"",formula2:p});return}M.getFormulaRefCheck(y)?(U==null||U({formula1:o.isFormulaString(y)?y:"",formula2:p}),F("")):(U==null||U({formula1:"",formula2:p}),v("="),F(C.t("dataValidation.validFail.formulaError")))},[p,U]),ae=g.useRef({}),[oe,O]=g.useState(!1);return z.useSidebarClick(y=>{var $;const W=($=ae.current)==null?void 0:$.handleOutClick;W&&W(y,()=>O(!1))}),h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{label:C.t("dataValidation.list.options"),children:h.jsxs(T.RadioGroup,{value:m,onChange:y=>{c(y),v(f),y==="1"&&U({formula1:f==="="?"":f,formula2:E.join(",")})},children:[h.jsx(T.Radio,{value:"0",children:C.t("dataValidation.list.customOptions")}),h.jsx(T.Radio,{value:"1",children:C.t("dataValidation.list.refOptions")})]})}),m==="1"?h.jsxs(h.Fragment,{children:[h.jsx(Qe.FormulaEditor,{initValue:S,unitId:n,subUnitId:i,isFocus:oe,onChange:(y="")=>{const W=(y!=null?y:"").trim();D(W),de(W)},errorText:P||Y||void 0,onFocus:()=>O(!0),actions:ae.current,isSupportAcrossSheet:!0}),h.jsx("div",{ref:u,style:{marginTop:"12px"},children:J.map(y=>h.jsx($t,{item:y,commonProps:{onItemChange:ne},style:{marginBottom:12}},y.id))})]}):h.jsx(T.FormLayout,{error:P,children:h.jsxs("div",{ref:u,style:{marginTop:"-12px"},children:[h.jsx(T.DraggableList,{list:k,onListChange:K,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:y=>h.jsx($t,{item:y,commonProps:{onItemChange:G,onItemDelete:te}},y.id),idKey:"id"}),h.jsxs("a",{className:ie.dataValidationFormulaListAdd,onClick:re,children:[h.jsx(Rt,{}),C.t("dataValidation.list.add")]})]})})]})}const Ht="data-validation.custom-formula-input",We="data-validation.formula-input",dt="data-validation.list-formula-input",Yt="data-validation.checkbox-formula-input",ma=[[Ht,da],[We,sa],[dt,ha],[Yt,la]],va="LIST_RENDER_MODE_OPTION_INPUT";function $e(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(T.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:h.jsxs(T.RadioGroup,{value:`${(i=t.renderMode)!=null?i:o.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...t,renderMode:+r}),children:[h.jsx(T.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),h.jsx(T.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),h.jsx(T.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}$e.componentKey=va;const fa="DATE_SHOW_TIME_OPTION";function He(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:r=>{a({...t,bizInfo:{...t.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}He.componentKey=fa;var ga=Object.defineProperty,Sa=Object.getOwnPropertyDescriptor,_a=(e,t,a,n)=>{for(var i=n>1?void 0:n?Sa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ga(t,a,i),i},Ye=(e,t)=>(a,n)=>t(a,n,e);const Xe=6;let ct=class{constructor(e,t,a,n){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n}_calc(e,t){var p,u,m;const{vt:a,ht:n}=t||{},i=e.endX-e.startX-Xe*2,r=e.endY-e.startY,s=((p=t==null?void 0:t.fs)!=null?p:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Xe;break;case o.HorizontalAlign.RIGHT:d=Xe+(i-s);break;default:d=Xe+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((u=t==null?void 0:t.fs)!=null?u:10)*1.6,height:((m=t==null?void 0:t.fs)!=null?m:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var p,u,m,c,S,v,f,D,C;const{formula1:n=R.CHECKBOX_FORMULA_1,formula2:i=R.CHECKBOX_FORMULA_2}=e,r=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=R.getFormulaResult((m=(u=(p=r==null?void 0:r[0])==null?void 0:p.result)==null?void 0:u[0])==null?void 0:m[0]),d=R.getFormulaResult((v=(S=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:S[0])==null?void 0:v[0]),l=R.isLegalFormulaResult(String(s))&&R.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?R.getFormulaResult((C=(D=(f=r==null?void 0:r[0])==null?void 0:f.result)==null?void 0:D[0])==null?void 0:C[0]):n,formula2:o.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var j,x,U,k,K,G;const{style:a,data:n,primaryWithCoord:i,unitId:r,subUnitId:s,worksheet:d,row:l,col:p}=t,u=i.isMergedMainCell?i.mergeInfo:i,m=R.getCellValueOrigin(d.getCellRaw(l,p)),c=(j=n.dataValidation)==null?void 0:j.rule,S=(x=n.dataValidation)==null?void 0:x.validator;if(!c||!S)return;const v=this._themeService.getCurrentTheme();if(!((U=S.skipDefaultFontRender)!=null&&U.call(S,c,m,{unitId:r,subUnitId:s,row:l,column:p})))return;const f=S.parseFormulaSync(c,r,s),{formula1:D}=f,C=this._calc(u,a),{a:w,d:_}=e.getTransform(),M=B.fixLineWidthByScale(C.left,w),E=B.fixLineWidthByScale(C.top,_),b=B.Transform.create().composeMatrix({left:M,top:E,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),I=u.endX-u.startX,V=u.endY-u.startY;e.save(),e.beginPath(),e.rect(u.startX,u.startY,I,V),e.clip();const A=b.getMatrix();e.transform(A[0],A[1],A[2],A[3],A[4],A[5]);const Y=((k=a==null?void 0:a.fs)!=null?k:10)*1.6,F=String(m)===String(D),P=v.hyacinth500;B.Checkbox.drawWith(e,{checked:F,width:Y,height:Y,fill:(G=(K=a==null?void 0:a.cl)==null?void 0:K.rgb)!=null?G:P}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),i=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:p}=e;return l<=d&&l>=s&&p<=r&&p>=i}async onPointerDown(e,t){var f,D,C;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:i,data:r,worksheet:s,row:d,col:l}=e,p=R.getCellValueOrigin(s.getCellRaw(d,l)),u=(f=r.dataValidation)==null?void 0:f.rule,m=(D=r.dataValidation)==null?void 0:D.validator;if(!u||!m||!((C=m.skipDefaultFontRender)!=null&&C.call(m,u,p,{unitId:n,subUnitId:i,row:d,column:l})))return;const{formula1:c,formula2:S}=await this._parseFormula(u,n,i),v={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(p)===R.transformCheckboxValue(String(c))?S:c,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,v)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};ct=_a([Ye(0,o.ICommandService),Ye(1,o.Inject(R.DataValidationFormulaService)),Ye(2,o.Inject(o.ThemeService)),Ye(3,o.Inject(B.IRenderManagerService))],ct);var Ia=Object.defineProperty,Ca=Object.getOwnPropertyDescriptor,Da=(e,t,a,n)=>{for(var i=n>1?void 0:n?Ca(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ia(t,a,i),i},wa=(e,t)=>(a,n)=>t(a,n,e);let pe=class{constructor(e){L(this,"canvasRender",null);L(this,"dropdown");L(this,"optionsInput");L(this,"formulaInput",dt);this.injector=e}};pe=Da([wa(0,o.Inject(o.Injector))],pe);class ya extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(ct));L(this,"formulaInput",Yt)}}class Va extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",Ht)}}const Ea="data-validation.formula-input";class Ra extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",Ea);L(this,"optionsInput",He.componentKey);L(this,"dropdown",ot)}}class Ma extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",We)}}const Xt=4,ba=0,ut=4,zt=4,pt=6,ze=6,Ce=14;function Oa(e,t){const a=B.FontCache.getTextSize(e,t),n=a.width+Xt*2,{ba:i,bd:r}=a,s=i+r;return{width:n,height:s+ba*2,ba:i}}function ht(e,t,a,n){const i=Ce+pt*2,r=a-i,s=n-ze*2,d=e.map(c=>({layout:Oa(c,t),text:c}));let l;const p=[];d.forEach(c=>{const{layout:S}=c,{width:v,height:f}=S;!l||l.width+v+ut>r?(l={width:v,height:f,items:[{...c,left:0}]},p.push(l)):(l.items.push({...c,left:l.width+ut}),l.width=l.width+v+ut)});let u=0,m=0;return p.forEach((c,S)=>{m=Math.max(m,c.width),S===p.length-1?u+=c.height:u+=c.height+zt}),{lines:p,totalHeight:u,contentWidth:r,contentHeight:s,cellAutoHeight:u+ze*2,calcAutoWidth:m+i}}const Ta=8;class La extends B.Shape{static drawWith(t,a){const{fontString:n,info:i,fill:r,color:s}=a,{layout:d,text:l}=i;t.save(),B.Rect.drawWith(t,{width:d.width,height:d.height,radius:Ta,fill:r||Ie}),t.translateWithPrecision(Xt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Pa=Object.defineProperty,ja=Object.getOwnPropertyDescriptor,Aa=(e,t,a,n)=>{for(var i=n>1?void 0:n?ja(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Pa(t,a,i),i},Kt=(e,t)=>(a,n)=>t(a,n,e);const Fa=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");let mt=class{constructor(e,t){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._renderManagerService=t}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,i){const r=a-Ce+4;let s=4;switch(i){case o.VerticalAlign.MIDDLE:s=(n-Ce)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-Ce+4;break}e.save(),e.translateWithPrecision(t.startX+r,t.startY+s),e.fillStyle="#565656",e.fill(Fa),e.restore()}drawWith(e,t,a,n){var Z,J;const{primaryWithCoord:i,row:r,col:s,style:d,data:l,subUnitId:p}=t,u=i.isMergedMainCell?i.mergeInfo:i,m=l.fontRenderExtension,{leftOffset:c=0,rightOffset:S=0,topOffset:v=0,downOffset:f=0}=m||{},D=l.dataValidation,C=this._ensureMap(p),w=this._generateKey(r,s);if(!D)return;const _={startX:u.startX+c,endX:u.endX-S,startY:u.startY+v,endY:u.endY-f},M=_.endX-_.startX,E=_.endY-_.startY,{cl:b}=d||{},I=(Z=typeof b=="object"?b==null?void 0:b.rgb:b)!=null?Z:"#000",V=B.getFontStyleString(d!=null?d:void 0),{rule:A,validator:Y}=D,F=Y,{vt:P,ht:j}=d||{},x=P!=null?P:o.VerticalAlign.MIDDLE,U=(J=R.getCellValueOrigin(l))!=null?J:"",k=F.parseCellValue(U),K=F.getListWithColorMap(A),G=ht(k,V,M,E);this._drawDownIcon(e,_,M,E,x),e.save(),e.translateWithPrecision(_.startX,_.startY),e.beginPath(),e.rect(0,0,M-Ce,E),e.clip(),e.translateWithPrecision(pt,ze);let te=0;switch(x){case o.VerticalAlign.MIDDLE:te=(G.contentHeight-G.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:te=G.contentHeight-G.totalHeight;break}e.translateWithPrecision(0,te),G.lines.forEach((ne,re)=>{e.save();const{width:de,height:ae,items:oe}=ne;let O=0;switch(j){case o.HorizontalAlign.RIGHT:O=G.contentWidth-de;break;case o.HorizontalAlign.CENTER:O=(G.contentWidth-de)/2;break}e.translate(O,re*(ae+zt)),oe.forEach(y=>{e.save(),e.translateWithPrecision(y.left,0),La.drawWith(e,{...V,info:y,color:I,fill:K[y.text]}),e.restore()}),e.restore()}),e.restore(),C.set(w,{left:_.startX,top:_.startY,width:G.contentWidth+pt+Ce,height:G.contentHeight+ze*2})}calcCellAutoHeight(e){var M;const{primaryWithCoord:t,style:a,data:n}=e,i=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=i||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+r,endX:p.endX-s,startY:p.startY+d,endY:p.endY-l},m=n.dataValidation;if(!m)return;const c=u.endX-u.startX,S=u.endY-u.startY,v=(M=R.getCellValueOrigin(n))!=null?M:"",{validator:f}=m,C=f.parseCellValue(v),w=B.getFontStyleString(a!=null?a:void 0);return ht(C,w,c,S).cellAutoHeight}calcCellAutoWidth(e){var M;const{primaryWithCoord:t,style:a,data:n}=e,i=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=i||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+r,endX:p.endX-s,startY:p.startY+d,endY:p.endY-l},m=n.dataValidation;if(!m)return;const c=u.endX-u.startX,S=u.endY-u.startY,v=(M=R.getCellValueOrigin(n))!=null?M:"",{validator:f}=m,C=f.parseCellValue(v),w=B.getFontStyleString(a!=null?a:void 0);return ht(C,w,c,S).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:i}=n,{x:r}=e;return r>=i-Ce&&r<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ae.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};mt=Aa([Kt(0,o.ICommandService),Kt(1,o.Inject(B.IRenderManagerService))],mt);class xa extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(mt));L(this,"dropdown",Ne)}}var Na=Object.defineProperty,Ua=Object.getOwnPropertyDescriptor,Ba=(e,t,a,n)=>{for(var i=n>1?void 0:n?Ua(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Na(t,a,i),i},vt=(e,t)=>(a,n)=>t(a,n,e);const De=4,Ke=4,ce=14,he=6,Me=4,ft=8,ka="#565656",Gt=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");function Wa(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function qt(e,t,a){const n=Wa(e,a),i=new o.DocumentDataModel(n),r=new B.DocumentViewModel(i);return{documentSkeleton:B.DocumentSkeleton.create(r,t),docModel:i,docViewModel:r}}function Ge(e,t,a){const{documentSkeleton:n,docModel:i,docViewModel:r}=qt(e,t,a);return{documents:new B.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:i,docViewModel:r}}function Zt(e,t,a,n,i,r,s=!0){let d=0;const l=s?Me:0;switch(i){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(Me,d);let p=0;switch(r){case o.HorizontalAlign.CENTER:p=(e-a)/2;break;case o.HorizontalAlign.RIGHT:p=e-a;break}return p=Math.max(he,p),{paddingLeft:p,paddingTop:d}}let gt=class{constructor(e,t,a){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._localeService=e,this._commandService=t,this._renderManagerService=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,i,r,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,p=a-ce;let u;switch(r){case o.VerticalAlign.MIDDLE:u=(n-Ke)/2;break;case o.VerticalAlign.BOTTOM:u=n-l-i-Me+(i/2-Ke/2);break;default:u=d+Me+(i/2-Ke/2);break}e.save(),e.translateWithPrecision(t.startX+p,t.startY+u),e.fillStyle="#565656",e.fill(Gt),e.restore()}drawWith(e,t,a){var x,U;const{primaryWithCoord:n,row:i,col:r,style:s,data:d,subUnitId:l}=t,p=n.isMergedMainCell?n.mergeInfo:n,u=(x=d.dataValidation)==null?void 0:x.rule,m=(U=d.dataValidation)==null?void 0:U.validator,c=d.fontRenderExtension,{leftOffset:S=0,rightOffset:v=0,topOffset:f=0,downOffset:D=0}=c||{};if(!u||!m||!m||m.id.indexOf(o.DataValidationType.LIST)!==0||!m.skipDefaultFontRender(u))return;const C={startX:p.startX+S,endX:p.endX-v,startY:p.startY+f,endY:p.endY-D},w=C.endX-C.startX,_=C.endY-C.startY,M=this._ensureMap(l),E=this._generateKey(i,r),b=m.getListWithColor(u),I=R.getCellValueOrigin(d),V=`${I!=null?I:""}`,A=b.find(k=>k.label===V);let{tb:Y,vt:F,ht:P,pd:j}=s||{};if(Y=Y!=null?Y:o.WrapStrategy.WRAP,F=F!=null?F:o.VerticalAlign.BOTTOM,P=P!=null?P:o.DEFAULT_STYLES.ht,j=j!=null?j:o.DEFAULT_STYLES.pd,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:k=o.DEFAULT_STYLES.pd.l,t:K=o.DEFAULT_STYLES.pd.t,r:G=o.DEFAULT_STYLES.pd.r,b:te=o.DEFAULT_STYLES.pd.b}=j,Z=w-k-G-ce-4,{documentSkeleton:J,documents:ne,docModel:re}=Ge(V,this._localeService,s);Y===o.WrapStrategy.WRAP&&re.updateDocumentDataPageSize(Math.max(Z,1)),J.calculate(),J.getActualSize();const de=B.getDocsSkeletonPageSize(J),{height:ae,width:oe}=de,{paddingTop:O,paddingLeft:y}=Zt(Z,_-K-te,oe,ae,F,P,!0);this._drawDownIcon(e,C,w,_,ae,F,j),e.save(),e.translateWithPrecision(C.startX+k,C.startY+K),e.beginPath(),e.rect(0,0,w-k-G,_-K-te),e.clip(),e.translateWithPrecision(0,O),e.save(),e.translateWithPrecision(De,0),e.beginPath(),e.rect(0,0,Z,ae),e.clip(),ne.render(e),e.translateWithPrecision(y,0),e.restore(),e.restore(),M.set(E,{left:C.endX+k+a.rowHeaderWidth-ce,top:C.startY+K+a.columnHeaderHeight,width:ce,height:_-K-te})}else{e.save(),e.translateWithPrecision(C.startX,C.startY),e.beginPath(),e.rect(0,0,w,_),e.clip();const k=w-he*2-De-ce-4,{documentSkeleton:K,documents:G,docModel:te}=Ge(V,this._localeService,s);Y===o.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(k,1)),K.calculate();const Z=B.getDocsSkeletonPageSize(K),{height:J,width:ne}=Z,{paddingTop:re,paddingLeft:de}=Zt(k,_,ne,J,F,P);e.translateWithPrecision(he,re);const ae=Math.max(w-he*2,1),oe=J;B.Rect.drawWith(e,{width:ae,height:oe,fill:(A==null?void 0:A.color)||Ie,radius:ft}),e.save(),e.translateWithPrecision(De,0),e.beginPath(),e.rect(0,0,k,J),e.clip(),e.translateWithPrecision(de,0),G.render(e),e.restore(),e.translateWithPrecision(k+De+4,(J-Ke)/2),e.fillStyle=ka,e.fill(Gt),e.restore(),M.set(E,{left:C.startX+he+a.rowHeaderWidth,top:C.startY+re+a.columnHeaderHeight,width:ae,height:oe})}}calcCellAutoHeight(e){var _;const{primaryWithCoord:t,style:a,data:n}=e,i=t.isMergedMainCell?t.mergeInfo:t,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:p=0}=r||{},u=(_=n.dataValidation)==null?void 0:_.rule;if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const m={startX:i.startX+s,endX:i.endX-d,startY:i.startY+l,endY:i.endY-p},c=m.endX-m.startX,S=R.getCellValueOrigin(n),v=`${S!=null?S:""}`;let{tb:f,pd:D}=a||{};const{t:C=o.DEFAULT_STYLES.pd.t,b:w=o.DEFAULT_STYLES.pd.b}=D!=null?D:{};if(f=f!=null?f:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const M=c-ce,{documentSkeleton:E,docModel:b}=Ge(v,this._localeService,a);f===o.WrapStrategy.WRAP&&b.updateDocumentDataPageSize(Math.max(M,1)),E.calculate(),E.getActualSize();const I=B.getDocsSkeletonPageSize(E),{height:V}=I;return V+C+w+Me*2}else{const M=c-he*2-De-ce,{documentSkeleton:E,docModel:b}=qt(v,this._localeService,a);f===o.WrapStrategy.WRAP&&b.updateDocumentDataPageSize(Math.max(M,1)),E.calculate();const I=B.getDocsSkeletonPageSize(E),{height:V}=I;return V+Me*2}}calcCellAutoWidth(e){var V;const{primaryWithCoord:t,style:a,data:n}=e,i=t.isMergedMainCell?t.mergeInfo:t,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:p=0}=r||{},u=(V=n.dataValidation)==null?void 0:V.rule;if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const m={startX:i.startX+s,endX:i.endX-d,startY:i.startY+l,endY:i.endY-p},c=m.endX-m.startX,S=R.getCellValueOrigin(n),v=`${S!=null?S:""}`;let{tb:f,pd:D}=a||{};const{l:C=o.DEFAULT_STYLES.pd.l,r:w=o.DEFAULT_STYLES.pd.r}=D!=null?D:{};f=f!=null?f:o.WrapStrategy.WRAP;let _=he*2+ce;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:_=ce+he*2+w+C;break;case o.DataValidationRenderMode.CUSTOM:_=ce+he*2+De*2+w+C+ft/2+1;break;default:_=ce+he*2+De*2+w+C+ft/2+1}const M=c-_,{documentSkeleton:E,docModel:b}=Ge(v,this._localeService,a);return f===o.WrapStrategy.WRAP&&b.updateDocumentDataPageSize(Math.max(M,1)),E.calculate(),E.getActualSize(),B.getDocsSkeletonPageSize(E).width+_}isHit(e,t){const{data:a,subUnitId:n,row:i,col:r}=t,d=this._ensureMap(n).get(this._generateKey(i,r)),l=a.dataValidation;if(!l||!d||l.rule.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:p,left:u,width:m,height:c}=d,{x:S,y:v}=e;return S>=u&&S<=u+m&&v>=p&&v<=p+c}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ae.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};gt=Ba([vt(0,o.Inject(o.LocaleService)),vt(1,o.ICommandService),vt(2,o.Inject(B.IRenderManagerService))],gt);class $a extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(gt));L(this,"dropdown",Ne);L(this,"optionsInput",$e.componentKey);L(this,"formulaInput",dt)}}class Ha extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",We)}}class Ya extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",We)}}var Xa=Object.defineProperty,za=Object.getOwnPropertyDescriptor,Ka=(e,t,a,n)=>{for(var i=n>1?void 0:n?za(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xa(t,a,i),i},St=(e,t)=>(a,n)=>t(a,n,e);let be=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Ft,Et],[tt,Un],[Lt,En],[Ne,Tn],[ot,un],[$e.componentKey,$e],[He.componentKey,He],...ma].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Ma,Ya,Ha,Ra,ya,$a,xa,Va].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdown=t.dropdown,a.optionsInput=t.optionsInput)})}};be=Ka([St(0,o.Inject(o.Injector)),St(1,o.Inject(z.ComponentManager)),St(2,o.Inject(Q.DataValidatorRegistryService))],be);var Ga=Object.defineProperty,qa=Object.getOwnPropertyDescriptor,Za=(e,t,a,n)=>{for(var i=n>1?void 0:n?qa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ga(t,a,i),i},_t=(e,t)=>(a,n)=>t(a,n,e);const Ja="SHEET_DATA_VALIDATION_UI_PLUGIN";H.UniverSheetsDataValidationUIPlugin=(qe=class extends o.Plugin{constructor(t=At,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(at,s)}onStarting(){[[ue],[fe],[Pe],[ye],[Re],[Ee],[Ve],[Te],[be]].forEach(t=>{this._injector.add(t)}),[Ue,Ae,jt,nt,_e,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(Te),this._injector.get(Pe),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(be),this._injector.get(Re)}onSteady(){this._injector.get(ye)}},L(qe,"pluginName",Ja),L(qe,"type",o.UniverInstanceType.UNIVER_SHEET),qe),H.UniverSheetsDataValidationUIPlugin=Za([_t(1,o.Inject(o.Injector)),_t(2,o.ICommandService),_t(3,o.IConfigService)],H.UniverSheetsDataValidationUIPlugin);var Qa=Object.defineProperty,ei=Object.getOwnPropertyDescriptor,ti=(e,t,a,n)=>{for(var i=n>1?void 0:n?ei(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Qa(t,a,i),i},It=(e,t)=>(a,n)=>t(a,n,e);const ni="SHEET_DATA_VALIDATION_UI_PLUGIN";H.UniverSheetsDataValidationMobileUIPlugin=(Ze=class extends o.Plugin{constructor(t=At,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(at,s)}onStarting(){[[ue],[fe],[Pe],[ye],[Re],[Ee],[Ve],[be]].forEach(t=>{this._injector.add(t)}),[Ue,Ae,jt,nt,_e,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(be),this._injector.get(Re)}onSteady(){this._injector.get(ye)}},L(Ze,"pluginName",ni),L(Ze,"type",o.UniverInstanceType.UNIVER_SHEET),Ze),H.UniverSheetsDataValidationMobileUIPlugin=ti([It(1,o.Inject(o.Injector)),It(2,o.ICommandService),It(3,o.IConfigService)],H.UniverSheetsDataValidationMobileUIPlugin),H.DATE_DROPDOWN_KEY=ot,H.LIST_DROPDOWN_KEY=Ne,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});