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