@univerjs/sheets-conditional-formatting-ui 0.7.0-nightly.202505061607 → 0.7.0-nightly.202505071607

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/umd/index.js CHANGED
@@ -1,54 +1,76 @@
1
- (function(Y,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("react-dom"),require("rxjs"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","react-dom","rxjs","@univerjs/engine-render","rxjs/operators"],w):(Y=typeof globalThis<"u"?globalThis:Y||self,w(Y.UniverSheetsConditionalFormattingUi={},Y.UniverCore,Y.UniverSheetsConditionalFormatting,Y.UniverSheets,Y.UniverUi,Y.React,Y.React,Y.UniverDesign,Y.UniverEngineFormula,Y.UniverSheetsFormulaUi,Y.UniverSheetsUi,Y.ReactDOM,Y.rxjs,Y.UniverEngineRender,Y.rxjs.operators))})(this,function(Y,w,u,q,$,R,V,J,Lt,He,de,Vt,ye,cr,We){"use strict";var di=Object.defineProperty;var fi=(Y,w,u)=>w in Y?di(Y,w,{enumerable:!0,configurable:!0,writable:!0,value:u}):Y[w]=u;var Re=(Y,w,u)=>fi(Y,typeof w!="symbol"?w+"":w,u);const Ut={type:w.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:r,style:n,stopIfTrue:a,operator:i}=t,d=e.get(u.ConditionalFormattingRuleModel),S=e.get(w.ICommandService),h=e.get(w.IUniverInstanceService),C=q.getSheetCommandTarget(h);if(!C)return!1;const{unitId:m,subUnitId:b}=C,E=d.createCfId(m,b),I={ranges:r,cfId:E,stopIfTrue:!!a,rule:{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.average,operator:i,style:n}};return S.executeCommand(u.AddConditionalRuleMutation.id,{unitId:m,subUnitId:b,rule:I})}},zt={type:w.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:r,config:n,stopIfTrue:a}=t,i=e.get(u.ConditionalFormattingRuleModel),d=e.get(w.ICommandService),S=e.get(w.IUniverInstanceService),h=q.getSheetCommandTarget(S);if(!h)return!1;const{unitId:C,subUnitId:m}=h,b=i.createCfId(C,m),E={ranges:r,cfId:b,stopIfTrue:!!a,rule:{type:u.CFRuleType.colorScale,config:n}};return d.executeCommand(u.AddConditionalRuleMutation.id,{unitId:C,subUnitId:m,rule:E})}},kt={type:w.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:r,min:n,max:a,nativeColor:i,positiveColor:d,isGradient:S,stopIfTrue:h,isShowValue:C}=t,m=e.get(u.ConditionalFormattingRuleModel),b=e.get(w.IUniverInstanceService),E=q.getSheetCommandTarget(b);if(!E)return!1;const{unitId:I,subUnitId:_}=E,T=e.get(w.ICommandService),p=m.createCfId(I,_),o={ranges:r,cfId:p,stopIfTrue:!!h,rule:{type:u.CFRuleType.dataBar,isShowValue:C,config:{min:n,max:a,nativeColor:i,positiveColor:d,isGradient:S}}};return T.executeCommand(u.AddConditionalRuleMutation.id,{unitId:I,subUnitId:_,rule:o})}},jt={type:w.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:r,style:n,stopIfTrue:a}=t,i=e.get(u.ConditionalFormattingRuleModel),d=e.get(w.ICommandService),S=e.get(w.IUniverInstanceService),h=q.getSheetCommandTarget(S);if(!h)return!1;const{unitId:C,subUnitId:m}=h,b=i.createCfId(C,m),E={ranges:r,cfId:b,stopIfTrue:!!a,rule:{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.duplicateValues,style:n}};return d.executeCommand(u.AddConditionalRuleMutation.id,{unitId:C,subUnitId:m,rule:E})}},At={type:w.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:r,style:n,stopIfTrue:a,operator:i,value:d}=t,S=e.get(u.ConditionalFormattingRuleModel),h=e.get(w.ICommandService),C=e.get(w.IUniverInstanceService),m=q.getSheetCommandTarget(C);if(!m)return!1;const{unitId:b,subUnitId:E}=m,I=S.createCfId(b,E);let _;if([u.CFNumberOperator.between,u.CFNumberOperator.notBetween].includes(i)){const T=d;if(T.length!==2||!Array.isArray(T))return!1;_={ranges:r,cfId:I,stopIfTrue:!!a,rule:{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.number,operator:i,style:n,value:T}}}else{const T=d;if(typeof T!="number")return!1;_={ranges:r,cfId:I,stopIfTrue:!!a,rule:{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.number,operator:i,style:n,value:T}}}return h.executeCommand(u.AddConditionalRuleMutation.id,{unitId:b,subUnitId:E,rule:_})}},Ht={type:w.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:r,style:n,stopIfTrue:a,isPercent:i,isBottom:d,value:S}=t,h=e.get(u.ConditionalFormattingRuleModel),C=e.get(w.IUniverInstanceService),m=e.get(w.ICommandService),b=q.getSheetCommandTarget(C);if(!b)return!1;const{unitId:E,subUnitId:I}=b,_=h.createCfId(E,I),T={ranges:r,cfId:_,stopIfTrue:!!a,rule:{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.rank,isPercent:i,isBottom:d,style:n,value:S}};return m.executeCommand(u.AddConditionalRuleMutation.id,{unitId:E,subUnitId:I,rule:T})}},Wt={type:w.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:r,style:n,stopIfTrue:a,operator:i,value:d}=t,S=e.get(u.ConditionalFormattingRuleModel),h=e.get(w.IUniverInstanceService),C=q.getSheetCommandTarget(h);if(!C)return!1;const{unitId:m,subUnitId:b}=C,E=e.get(w.ICommandService),I=S.createCfId(m,b),_={ranges:r,cfId:I,stopIfTrue:!!a,rule:{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.text,operator:i,style:n,value:d}};return E.executeCommand(u.AddConditionalRuleMutation.id,{unitId:m,subUnitId:b,rule:_})}},Bt={type:w.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:r,style:n,stopIfTrue:a,operator:i}=t,d=e.get(u.ConditionalFormattingRuleModel),S=e.get(w.IUniverInstanceService),h=e.get(w.ICommandService),C=q.getSheetCommandTarget(S);if(!C)return!1;const{unitId:m,subUnitId:b}=C,E=d.createCfId(m,b),I={ranges:r,cfId:E,stopIfTrue:!!a,rule:{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.timePeriod,operator:i,style:n}};return h.executeCommand(u.AddConditionalRuleMutation.id,{unitId:m,subUnitId:b,rule:I})}},Ft={type:w.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:r,style:n,stopIfTrue:a}=t,i=e.get(u.ConditionalFormattingRuleModel),d=e.get(w.IUniverInstanceService),S=e.get(w.ICommandService),h=q.getSheetCommandTarget(d);if(!h)return!1;const{unitId:C,subUnitId:m}=h,b=i.createCfId(C,m),E={ranges:r,cfId:b,stopIfTrue:!!a,rule:{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.uniqueValues,style:n}};return S.executeCommand(u.AddConditionalRuleMutation.id,{unitId:C,subUnitId:m,rule:E})}};var ge=function(){return ge=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},ge.apply(this,arguments)},Sn=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r},Me=V.forwardRef(function(e,t){var r=e.icon,n=e.id,a=e.className,i=e.extend,d=Sn(e,["icon","id","className","extend"]),S="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),h=V.useRef("_".concat(wn()));return dr(r,"".concat(n),{defIds:r.defIds,idSuffix:h.current},ge({ref:t,className:S},d),i)});function dr(e,t,r,n,a){return V.createElement(e.tag,ge(ge({key:t},Cn(e,r,a)),n),(Tn(e,r).children||[]).map(function(i,d){return dr(i,"".concat(t,"-").concat(e.tag,"-").concat(d),r,void 0,a)}))}function Cn(e,t,r){var n=ge({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var d=i[0],S=i[1];d==="mask"&&typeof S=="string"&&(n[d]=S.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var a=t.defIds;return!a||a.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var d=i[0],S=i[1];typeof S=="string"&&(n[d]=S.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Tn(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?ge(ge({},e),{children:e.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.indexOf(a.attrs.id)>-1?ge(ge({},a),{attrs:ge(ge({},a.attrs),{id:a.attrs.id+t.idSuffix})}):a})}):e}function wn(){return Math.random().toString(36).substring(2,8)}Me.displayName="UniverIcon";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"}}]},ft=V.forwardRef(function(e,t){return V.createElement(Me,Object.assign({},e,{id:"delete-single",ref:t,icon:_n}))});ft.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"}}]},fr=V.forwardRef(function(e,t){return V.createElement(Me,Object.assign({},e,{id:"increase-single",ref:t,icon:In}))});fr.displayName="IncreaseSingle";var Rn={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"}}]},pt=V.forwardRef(function(e,t){return V.createElement(Me,Object.assign({},e,{id:"more-down-single",ref:t,icon:Rn}))});pt.displayName="MoreDownSingle";var En={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"}}]}]},pr=V.forwardRef(function(e,t){return V.createElement(Me,Object.assign({},e,{id:"sequence-single",ref:t,icon:En}))});pr.displayName="SequenceSingle";var On={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_436_41",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.35 0.48H16.35V16.48H0.35z"}}]},{tag:"g",attrs:{mask:"url(#mask0_436_41)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z"}},{tag:"path",attrs:{fill:"#E5E5E5",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z"}}]}]},Be=V.forwardRef(function(e,t){return V.createElement(Me,Object.assign({},e,{id:"slash-single",ref:t,icon:On}))});Be.displayName="SlashSingle";const Ee=e=>{const{color:t,onChange:r,disable:n=!1,iconId:a="PaintBucket",className:i,isNeedDropdownIcon:d=!0}=e,S=$.useDependency($.ComponentManager),h=V.useMemo(()=>new w.ColorKit(t),[t]),C=S.get(a);return C?n?R.jsx(C,{className:J.clsx("univer-fill-primary-600",i),extend:{colorChannel1:h.isValid?t:""}}):R.jsx(J.Dropdown,{overlay:R.jsx("div",{className:"univer-rounded-lg univer-p-4",children:R.jsx(J.ColorPicker,{value:t,onChange:r})}),children:R.jsxs("span",{className:J.clsx(`
1
+ (function(P,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","rxjs","@univerjs/engine-render","rxjs/operators"],i):(P=typeof globalThis<"u"?globalThis:P||self,i(P.UniverSheetsConditionalFormattingUi={},P.UniverCore,P.UniverSheetsConditionalFormatting,P.UniverSheets,P.UniverUi,P.React,P.React,P.UniverDesign,P.UniverEngineFormula,P.UniverSheetsFormulaUi,P.UniverSheetsUi,P.rxjs,P.UniverEngineRender,P.rxjs.operators))})(this,function(P,i,r,k,j,s,m,D,Be,pe,W,X,lr,fe){"use strict";var Ot=Object.defineProperty;var Ut=(P,i,r)=>i in P?Ot(P,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):P[i]=r;var ee=(P,i,r)=>Ut(P,typeof i!="symbol"?i+"":i,r);const He={type:i.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:l,operator:a}=e,c=t.get(r.ConditionalFormattingRuleModel),p=t.get(i.ICommandService),o=t.get(i.IUniverInstanceService),v=k.getSheetCommandTarget(o);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=c.createCfId(d,f),S={ranges:u,cfId:h,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:a,style:n}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:S})}},We={type:i.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,config:n,stopIfTrue:l}=e,a=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.ICommandService),p=t.get(i.IUniverInstanceService),o=k.getSheetCommandTarget(p);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=a.createCfId(v,d),h={ranges:u,cfId:f,stopIfTrue:!!l,rule:{type:r.CFRuleType.colorScale,config:n}};return c.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}},qe={type:i.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,min:n,max:l,nativeColor:a,positiveColor:c,isGradient:p,stopIfTrue:o,isShowValue:v}=e,d=t.get(r.ConditionalFormattingRuleModel),f=t.get(i.IUniverInstanceService),h=k.getSheetCommandTarget(f);if(!h)return!1;const{unitId:S,subUnitId:_}=h,b=t.get(i.ICommandService),x=d.createCfId(S,_),N={ranges:u,cfId:x,stopIfTrue:!!o,rule:{type:r.CFRuleType.dataBar,isShowValue:v,config:{min:n,max:l,nativeColor:a,positiveColor:c,isGradient:p}}};return b.executeCommand(r.AddConditionalRuleMutation.id,{unitId:S,subUnitId:_,rule:N})}},Ge={type:i.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:l}=e,a=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.ICommandService),p=t.get(i.IUniverInstanceService),o=k.getSheetCommandTarget(p);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=a.createCfId(v,d),h={ranges:u,cfId:f,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:n}};return c.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}},ze={type:i.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:l,operator:a,value:c}=e,p=t.get(r.ConditionalFormattingRuleModel),o=t.get(i.ICommandService),v=t.get(i.IUniverInstanceService),d=k.getSheetCommandTarget(v);if(!d)return!1;const{unitId:f,subUnitId:h}=d,S=p.createCfId(f,h);let _;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(a)){const b=c;if(b.length!==2||!Array.isArray(b))return!1;_={ranges:u,cfId:S,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:a,style:n,value:b}}}else{const b=c;if(typeof b!="number")return!1;_={ranges:u,cfId:S,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:a,style:n,value:b}}}return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:h,rule:_})}},Ye={type:i.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:l,isPercent:a,isBottom:c,value:p}=e,o=t.get(r.ConditionalFormattingRuleModel),v=t.get(i.IUniverInstanceService),d=t.get(i.ICommandService),f=k.getSheetCommandTarget(v);if(!f)return!1;const{unitId:h,subUnitId:S}=f,_=o.createCfId(h,S),b={ranges:u,cfId:_,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:a,isBottom:c,style:n,value:p}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:S,rule:b})}},Ze={type:i.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:l,operator:a,value:c}=e,p=t.get(r.ConditionalFormattingRuleModel),o=t.get(i.IUniverInstanceService),v=k.getSheetCommandTarget(o);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=t.get(i.ICommandService),S=p.createCfId(d,f),_={ranges:u,cfId:S,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:a,style:n,value:c}};return h.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:_})}},Ke={type:i.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:l,operator:a}=e,c=t.get(r.ConditionalFormattingRuleModel),p=t.get(i.IUniverInstanceService),o=t.get(i.ICommandService),v=k.getSheetCommandTarget(p);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=c.createCfId(d,f),S={ranges:u,cfId:h,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:a,style:n}};return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:S})}},Xe={type:i.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:l}=e,a=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.IUniverInstanceService),p=t.get(i.ICommandService),o=k.getSheetCommandTarget(c);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=a.createCfId(v,d),h={ranges:u,cfId:f,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:n}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}};var K=function(){return K=Object.assign||function(t){for(var e,u=1,n=arguments.length;u<n;u++){e=arguments[u];for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&(t[l]=e[l])}return t},K.apply(this,arguments)},Tr=function(t,e){var u={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(u[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var l=0,n=Object.getOwnPropertySymbols(t);l<n.length;l++)e.indexOf(n[l])<0&&Object.prototype.propertyIsEnumerable.call(t,n[l])&&(u[n[l]]=t[n[l]]);return u},ue=m.forwardRef(function(t,e){var u=t.icon,n=t.id,l=t.className,a=t.extend,c=Tr(t,["icon","id","className","extend"]),p="univerjs-icon univerjs-icon-".concat(n," ").concat(l||"").trim(),o=m.useRef("_".concat(Nr()));return ur(u,"".concat(n),{defIds:u.defIds,idSuffix:o.current},K({ref:e,className:p},c),a)});function ur(t,e,u,n,l){return m.createElement(t.tag,K(K({key:e},_r(t,u,l)),n),(Er(t,u).children||[]).map(function(a,c){return ur(a,"".concat(e,"-").concat(t.tag,"-").concat(c),u,void 0,l)}))}function _r(t,e,u){var n=K({},t.attrs);u!=null&&u.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=u.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(a){var c=a[0],p=a[1];c==="mask"&&typeof p=="string"&&(n[c]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var l=e.defIds;return!l||l.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(a){var c=a[0],p=a[1];typeof p=="string"&&(n[c]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Er(t,e){var u,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((u=t.children)===null||u===void 0)&&u.length)?K(K({},t),{children:t.children.map(function(l){return typeof l.attrs.id=="string"&&n&&n.indexOf(l.attrs.id)>-1?K(K({},l),{attrs:K(K({},l.attrs),{id:l.attrs.id+e.idSuffix})}):l})}):t}function Nr(){return Math.random().toString(36).substring(2,8)}ue.displayName="UniverIcon";var xr={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"}}]},Re=m.forwardRef(function(t,e){return m.createElement(ue,Object.assign({},t,{id:"delete-single",ref:e,icon:xr}))});Re.displayName="DeleteSingle";var Rr={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"}}]},ar=m.forwardRef(function(t,e){return m.createElement(ue,Object.assign({},t,{id:"increase-single",ref:e,icon:Rr}))});ar.displayName="IncreaseSingle";var Mr={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"}}]},Me=m.forwardRef(function(t,e){return m.createElement(ue,Object.assign({},t,{id:"more-down-single",ref:e,icon:Mr}))});Me.displayName="MoreDownSingle";var wr={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"}}]}]},ir=m.forwardRef(function(t,e){return m.createElement(ue,Object.assign({},t,{id:"sequence-single",ref:e,icon:wr}))});ir.displayName="SequenceSingle";var Vr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_436_41",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.35 0.48H16.35V16.48H0.35z"}}]},{tag:"g",attrs:{mask:"url(#mask0_436_41)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z"}},{tag:"path",attrs:{fill:"#E5E5E5",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z"}}]}]},he=m.forwardRef(function(t,e){return m.createElement(ue,Object.assign({},t,{id:"slash-single",ref:e,icon:Vr}))});he.displayName="SlashSingle";const re=t=>{const{color:e,onChange:u,disable:n=!1,iconId:l="PaintBucket",className:a,isNeedDropdownIcon:c=!0}=t,p=j.useDependency(j.ComponentManager),o=m.useMemo(()=>new i.ColorKit(e),[e]),v=p.get(l);return v?n?s.jsx(v,{className:D.clsx("univer-fill-primary-600",a),extend:{colorChannel1:o.isValid?e:""}}):s.jsx(D.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(D.ColorPicker,{value:e,onChange:u})}),children:s.jsxs("span",{className:D.clsx(`
2
2
  univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1
3
3
  hover:univer-bg-gray-100
4
- `,i),children:[R.jsx(C,{className:"univer-fill-primary-600",extend:{colorChannel1:h.isValid?t:""}}),d&&R.jsx(pt,{className:"univer-ml-1.5 univer-text-[10px] univer-text-gray-400"})]})}):null},Ne=e=>{var i,d,S;const t=e.rule;if(!t)return null;const r=V.useMemo(()=>{if(t.type===u.CFRuleType.colorScale){const h=t.config.map((b,E)=>({color:new w.ColorKit(b.color),value:E})),C=h.length-1;return new Array(5).fill("").map((b,E,I)=>E*C/(I.length-1)).map(b=>u.getColorScaleFromValue(h,b))}return null},[t]),n=V.useMemo(()=>{if(t.type===u.CFRuleType.iconSet)return t.config.map(h=>{const C=u.iconMap[h.iconType];return C&&C[Number(h.iconId)]})},[t]),a=`univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center
5
- univer-justify-center univer-text-xs`;switch(t.type){case u.CFRuleType.dataBar:{const{isGradient:h}=t.config,C=h?`linear-gradient(to right, ${t.config.positiveColor||u.defaultDataBarPositiveColor}, rgb(255 255 255))`:t.config.positiveColor,m=h?`linear-gradient(to right, rgb(255 255 255),${t.config.nativeColor||u.defaultDataBarNativeColor})`:t.config.nativeColor;return R.jsxs("div",{className:a,children:[R.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:m,border:`1px solid ${t.config.nativeColor||u.defaultDataBarNativeColor}`}}),R.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:C,border:`1px solid ${t.config.positiveColor||u.defaultDataBarPositiveColor}`}})]})}case u.CFRuleType.colorScale:return r&&R.jsx("div",{className:a,children:r.map((h,C)=>R.jsx("div",{className:"univer-h-full",style:{width:`${100/r.length}%`,background:h}},C))});case u.CFRuleType.iconSet:return n&&R.jsx("div",{className:a,children:n.map((h,C)=>h?R.jsx("img",{className:"univer-h-full",src:h,draggable:!1},C):R.jsx(Be,{},C))});case u.CFRuleType.highlightCell:{const{ul:h,st:C,it:m,bl:b,bg:E,cl:I}=t.style,_=(h==null?void 0:h.s)===w.BooleanNumber.TRUE,T=(C==null?void 0:C.s)===w.BooleanNumber.TRUE,p=m===w.BooleanNumber.TRUE,o=b===w.BooleanNumber.TRUE,s=(i=E==null?void 0:E.rgb)!=null?i:u.DEFAULT_BG_COLOR,f=(d=I==null?void 0:I.rgb)!=null?d:u.DEFAULT_FONT_COLOR,y={textDecoration:(S=`${_?"underline":""} ${T?"line-through":""}`.replace(/^ /,""))!=null?S:void 0,backgroundColor:s,color:f};return R.jsx("div",{className:J.clsx(a,{"univer-font-bold":o,"univer-italic":p}),style:y,children:"123"})}}},Fe="univer-mt-5 univer-px-1 univer-py-2 univer-border univer-border-solid univer-border-gray-200 univer-rounded",Oe=(e,t)=>({label:t.t(`sheet.cf.valueType.${e}`),value:e}),Gt=e=>{var _;const{type:t,className:r,onChange:n,id:a,value:i}=e,d=$.useDependency(w.IUniverInstanceService),S=d.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getUnitId(),h=(_=d.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:_.getSheetId(),C=V.useMemo(()=>String(i).startsWith("=")?String(i):"=",[i]),m=V.useMemo(()=>[u.CFValueType.max,u.CFValueType.min,"none"].includes(t)?{disabled:!0}:[u.CFValueType.percent,u.CFValueType.percentile].includes(t)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[t]),b=V.useRef(null),[E,I]=V.useState(!1);return $.useSidebarClick(T=>{var o;((o=b.current)==null?void 0:o.isClickOutSide(T))&&I(!1)}),t===u.CFValueType.formula?R.jsx("div",{className:"univer-ml-1 univer-w-full",children:R.jsx(He.FormulaEditor,{initValue:C,unitId:S,subUnitId:h,isFocus:E,onChange:(T="")=>{n(T||"")},onFocus:()=>I(!0),ref:b})}):R.jsx(J.InputNumber,{className:r,value:Number(e.value)||0,onChange:T=>e.onChange(T||0),...m})},xn=e=>{var z;const{interceptorManager:t}=e,r=$.useDependency(w.LocaleService),n=((z=e.rule)==null?void 0:z.type)===u.CFRuleType.colorScale?e.rule:void 0,a=[Oe(u.CFValueType.num,r),Oe(u.CFValueType.percent,r),Oe(u.CFValueType.percentile,r),Oe(u.CFValueType.formula,r)],i=[Oe(u.CFValueType.min,r),...a],d=[Oe("none",r),...a],S=[Oe(u.CFValueType.max,r),...a],[h,C]=V.useState(()=>{var L;const O=u.CFValueType.min;return n&&((L=n.config[0])==null?void 0:L.value.type)||O}),[m,b]=V.useState(()=>{var L;const O="none";return!n||n.config.length!==3?O:((L=n.config[1])==null?void 0:L.value.type)||O}),[E,I]=V.useState(()=>{var L;const O=u.CFValueType.max;return n&&((L=n.config[n.config.length-1])==null?void 0:L.value.type)||O}),[_,T]=V.useState(()=>{if(!n)return 10;const L=n.config[0];return(L==null?void 0:L.value.value)===void 0?10:L==null?void 0:L.value.value}),[p,o]=V.useState(()=>{var W;if(!n||n.config.length!==3)return 50;const L=(W=n.config[1])==null?void 0:W.value.value;return L===void 0?50:L}),[s,f]=V.useState(()=>{var W;if(!n)return 90;const L=(W=n.config[n.config.length-1])==null?void 0:W.value.value;return L===void 0?90:L}),[y,l]=V.useState(()=>{var L;const O="#d0d9fb";return n&&((L=n.config[0])==null?void 0:L.color)||O}),[v,c]=V.useState(()=>{var L;const O="#7790f3";return!n||n.config.length!==3?O:((L=n.config[1])==null?void 0:L.color)||O}),[g,P]=V.useState(()=>{var L;const O="#2e55ef";return n&&((L=n.config[n.config.length-1])==null?void 0:L.color)||O}),M=V.useMemo(()=>O=>{const{minType:L,medianType:W,maxType:F,minValue:X,medianValue:ae,maxValue:ne,minColor:se,medianColor:j,maxColor:Q}=O,te=[];return te.push({color:se,value:{type:L,value:X}}),W!=="none"&&te.push({color:j,value:{type:W,value:ae}}),te.push({color:Q,value:{type:F,value:ne}}),{config:te.map((ce,pe)=>({...ce,index:pe})),type:u.CFRuleType.colorScale}},[]);V.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return M({minType:h,medianType:m,maxType:E,minValue:_,medianValue:p,maxValue:s,minColor:y,medianColor:v,maxColor:g})}}),[M,h,m,E,_,p,s,y,v,g,t]);const U=O=>{e.onChange(M(O))};return R.jsxs("div",{children:[R.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),R.jsx("div",{className:Fe,children:R.jsx(Ne,{rule:M({minType:h,medianType:m,maxType:E,minValue:_,medianValue:p,maxValue:s,minColor:y,medianColor:v,maxColor:g})})}),R.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:r.t("sheet.cf.valueType.min")}),R.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[R.jsx(J.Select,{className:"univer-flex-shrink-0",options:i,value:h,onChange:O=>{C(O);const L=u.createDefaultValueByValueType(O,10);T(L),U({minType:O,medianType:m,maxType:E,minValue:L,medianValue:p,maxValue:s,minColor:y,medianColor:v,maxColor:g})}}),R.jsx(Gt,{id:"min",className:"univer-ml-1",value:_,type:h,onChange:O=>{T(O),U({minType:h,medianType:m,maxType:E,minValue:O,medianValue:p,maxValue:s,minColor:y,medianColor:v,maxColor:g})}}),R.jsx(Ee,{className:"univer-ml-1",color:y,onChange:O=>{l(O),U({minType:h,medianType:m,maxType:E,minValue:_,medianValue:p,maxValue:s,minColor:O,medianColor:v,maxColor:g})}})]}),R.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:r.t("sheet.cf.panel.medianValue")}),R.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[R.jsx(J.Select,{className:"univer-flex-shrink-0",options:d,value:m,onChange:O=>{b(O);const L=u.createDefaultValueByValueType(O,50);o(L),U({minType:h,medianType:O,maxType:E,minValue:_,medianValue:L,maxValue:s,minColor:y,medianColor:v,maxColor:g})}}),R.jsx(Gt,{id:"median",className:"univer-ml-1",value:p,type:m,onChange:O=>{o(O),U({minType:h,medianType:m,maxType:E,minValue:_,medianValue:O,maxValue:s,minColor:y,medianColor:v,maxColor:g})}}),m!=="none"&&R.jsx(Ee,{className:"univer-ml-1",color:v,onChange:O=>{c(O),U({minType:h,medianType:m,maxType:E,minValue:_,medianValue:p,maxValue:s,minColor:y,medianColor:O,maxColor:g})}})]}),R.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:r.t("sheet.cf.valueType.max")}),R.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[R.jsx(J.Select,{className:"univer-flex-shrink-0",options:S,value:E,onChange:O=>{I(O);const L=u.createDefaultValueByValueType(O,90);f(L),U({minType:h,medianType:m,maxType:O,minValue:_,medianValue:p,maxValue:L,minColor:y,medianColor:v,maxColor:g})}}),R.jsx(Gt,{id:"max",className:"univer-ml-1",value:s,type:E,onChange:O=>{f(O),U({minType:h,medianType:m,maxType:E,minValue:_,medianValue:p,maxValue:O,minColor:y,medianColor:v,maxColor:g})}}),R.jsx(Ee,{className:"univer-ml-1",color:g,onChange:O=>{P(O),U({minType:h,medianType:m,maxType:E,minValue:_,medianValue:p,maxValue:s,minColor:y,medianColor:v,maxColor:O})}})]})]})},Le=(e,t)=>({label:t.t(`sheet.cf.valueType.${e}`),value:e}),hr=e=>{var T;const{onChange:t,className:r,value:n,type:a,id:i,disabled:d=!1}=e,S=$.useDependency(w.IUniverInstanceService),h=S.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getUnitId(),C=(T=S.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:T.getSheetId(),m=V.useRef(null),[b,E]=V.useState(!1);$.useSidebarClick(p=>{var s;((s=m.current)==null?void 0:s.isClickOutSide(p))&&E(!1)});const I=V.useRef(n),_=V.useMemo(()=>[u.CFValueType.percentile,u.CFValueType.percent].includes(a)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[a]);if(a===u.CFValueType.formula){const p=String(I.current).startsWith("=")?String(I.current)||"":"=";return R.jsx("div",{className:"univer-ml-3 univer-w-full",children:R.jsx(He.FormulaEditor,{initValue:p,unitId:h,subUnitId:C,isFocus:b,onChange:(o="")=>{t(o||"")},onFocus:()=>E(!0),ref:m})})}return R.jsx(J.InputNumber,{className:r,value:Number(n)||0,disabled:d,onChange:p=>{t(p||0)},..._})},Dn=e=>{var z;const{interceptorManager:t}=e,r=$.useDependency(w.LocaleService),n=((z=e.rule)==null?void 0:z.type)===u.CFRuleType.dataBar?e.rule:void 0,[a,i]=V.useState(()=>{var L;const O="0";return n?(L=n.config)!=null&&L.isGradient?"1":"0":O}),[d,S]=V.useState(()=>{var O;return n&&((O=n.config)==null?void 0:O.positiveColor)||u.defaultDataBarPositiveColor}),[h,C]=V.useState(()=>{var O;return n&&((O=n.config)==null?void 0:O.nativeColor)||u.defaultDataBarNativeColor}),m=[Le(u.CFValueType.num,r),Le(u.CFValueType.percent,r),Le(u.CFValueType.percentile,r),Le(u.CFValueType.formula,r)],b=[Le(u.CFValueType.min,r),...m],E=[Le(u.CFValueType.max,r),...m],[I,_]=V.useState(()=>{var L;const O=b[0].value;return n&&((L=n.config)==null?void 0:L.min.type)||O}),[T,p]=V.useState(()=>{var L;const O=E[0].value;return n&&((L=n.config)==null?void 0:L.max.type)||O}),[o,s]=V.useState(()=>{var W;if(!n)return 0;const L=((W=n.config)==null?void 0:W.min)||{};return L.type===u.CFValueType.formula?L.value||"=":L.value||0}),[f,y]=V.useState(()=>{var W;if(!n)return 100;const L=((W=n.config)==null?void 0:W.max)||{};return L.type===u.CFValueType.formula?L.value||"=":L.value===void 0?100:L.value}),[l,v]=V.useState(()=>n?n.isShowValue===void 0?!0:!!n.isShowValue:!0),c=O=>({config:{min:{type:O.minValueType,value:O.minValue},max:{type:O.maxValueType,value:O.maxValue},isGradient:O.isGradient==="1",positiveColor:O.positiveColor||u.defaultDataBarPositiveColor,nativeColor:O.nativeColor||u.defaultDataBarNativeColor},type:u.CFRuleType.dataBar,isShowValue:O.isShowValue});V.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return c({isGradient:a,minValue:o,minValueType:I,maxValue:f,maxValueType:T,positiveColor:d,nativeColor:h,isShowValue:l})}}),[a,o,I,f,T,d,h,t,l]);const g=O=>{e.onChange(c(O))},P=O=>{S(O),g({isGradient:a,minValue:o,minValueType:I,maxValue:f,maxValueType:T,positiveColor:O,nativeColor:h,isShowValue:l})},M=O=>{C(O),g({isGradient:a,minValue:o,minValueType:I,maxValue:f,maxValueType:T,positiveColor:d,nativeColor:O,isShowValue:l})},U=O=>m.map(L=>L.value).includes(O);return R.jsxs("div",{children:[R.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),R.jsx("div",{className:Fe,children:R.jsx(Ne,{rule:c({isGradient:a,minValue:o,minValueType:I,maxValue:f,maxValueType:T,positiveColor:d,nativeColor:h,isShowValue:l})})}),R.jsxs("div",{children:[R.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.fillType")}),R.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[R.jsxs(J.RadioGroup,{value:a,onChange:O=>{i(O),g({isGradient:O,minValue:o,minValueType:I,maxValue:f,maxValueType:T,positiveColor:d,nativeColor:h,isShowValue:l})},children:[R.jsx(J.Radio,{value:"0",children:R.jsx("span",{className:"univer-text-xs",children:r.t("sheet.cf.panel.pureColor")})}),R.jsx(J.Radio,{value:"1",children:R.jsx("span",{className:"univer-text-xs",children:r.t("sheet.cf.panel.gradient")})})]}),R.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[R.jsx(J.Checkbox,{checked:!l,onChange:O=>{v(!O),g({isGradient:O,minValue:o,minValueType:I,maxValue:f,maxValueType:T,positiveColor:d,nativeColor:h,isShowValue:!O})}}),r.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),R.jsxs("div",{children:[R.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.colorSet")}),R.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[R.jsxs("div",{className:"univer-flex univer-items-center",children:[R.jsx("div",{className:"univer-text-xs",children:r.t("sheet.cf.panel.native")}),R.jsx(Ee,{color:h,onChange:M})]}),R.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[R.jsx("div",{className:"univer-text-xs",children:r.t("sheet.cf.panel.positive")}),R.jsx(Ee,{color:d,onChange:P})]})]})]}),R.jsxs("div",{children:[R.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.valueType.min")}),R.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[R.jsx(J.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:b,value:I,onChange:O=>{_(O);const L=u.createDefaultValueByValueType(O,10);s(L),g({isGradient:a,minValue:L,minValueType:O,maxValue:f,maxValueType:T,positiveColor:d,nativeColor:h,isShowValue:l})}}),R.jsx(hr,{id:"min",className:"univer-ml-3",disabled:!U(I),type:I,value:o,onChange:O=>{s(O||0),g({isGradient:a,minValue:O||0,minValueType:I,maxValue:f,maxValueType:T,positiveColor:d,nativeColor:h,isShowValue:l})}})]}),R.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.valueType.max")}),R.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[R.jsx(J.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:E,value:T,onChange:O=>{p(O);const L=u.createDefaultValueByValueType(O,90);y(L),g({isGradient:a,minValue:o,minValueType:I,maxValue:L,maxValueType:O,positiveColor:d,nativeColor:h,isShowValue:l})}}),R.jsx(hr,{className:"univer-ml-3",disabled:!U(T),id:"max",type:T,value:f,onChange:O=>{y(O||0),g({isGradient:a,minValue:o,minValueType:I,maxValue:O||0,maxValueType:T,positiveColor:d,nativeColor:h,isShowValue:l})}})]})]})]})},ht=e=>[w.BooleanNumber.FALSE,void 0].includes(e)?w.BooleanNumber.TRUE:w.BooleanNumber.FALSE,vt=e=>e!==w.BooleanNumber.FALSE,qt=e=>{const{style:t,onChange:r,className:n}=e,a=$.useDependency($.ComponentManager),[i,d]=V.useState(()=>{if(t!=null&&t.bl)return t.bl}),[S,h]=V.useState(()=>{if(t!=null&&t.it)return t.it}),[C,m]=V.useState(()=>{if(t!=null&&t.ul)return t.ul.s}),[b,E]=V.useState(()=>{if(t!=null&&t.st)return t.st.s}),[I,_]=V.useState(()=>{var c;const v="#2f56ef";return(c=t==null?void 0:t.cl)!=null&&c.rgb?t.cl.rgb:v}),[T,p]=V.useState(()=>{var c;const v="#e8ecfc";return(c=t==null?void 0:t.bg)!=null&&c.rgb?t.bg.rgb:v}),o=a.get("BoldSingle"),s=a.get("ItalicSingle"),f=a.get("UnderlineSingle"),y=a.get("StrikethroughSingle");V.useEffect(()=>{const v={bl:i,it:S};I!==void 0&&(v.cl={rgb:I}),T!==void 0&&(v.bg={rgb:T}),b!==void 0&&(v.st={s:b}),C!==void 0&&(v.ul={s:C}),r(u.removeUndefinedAttr(v))},[i,S,C,b,I,T]);const l="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return R.jsxs("div",{className:J.clsx("univer-my-2.5 univer-flex univer-justify-between",n),children:[o&&R.jsx("div",{className:J.clsx(l,{"univer-bg-gray-100":vt(i||w.BooleanNumber.FALSE)}),onClick:()=>d(ht(i)),children:R.jsx(o,{})}),s&&R.jsx("div",{className:J.clsx(l,{"univer-bg-gray-100":vt(S||w.BooleanNumber.FALSE)}),onClick:()=>h(ht(S)),children:R.jsx(s,{})}),f&&R.jsx("div",{className:J.clsx(l,{"univer-bg-gray-100":vt(C||w.BooleanNumber.FALSE)}),onClick:()=>m(ht(C)),children:R.jsx(f,{})}),y&&R.jsx("div",{className:J.clsx(l,{"univer-bg-gray-100":vt(b||w.BooleanNumber.FALSE)}),onClick:()=>E(ht(b)),children:R.jsx(y,{})}),R.jsx(Ee,{color:I,onChange:_,iconId:"FontColor"}),R.jsx(Ee,{color:T,onChange:p,iconId:"PaintBucket"})]})},Pn=e=>{var y;const{onChange:t,interceptorManager:r}=e,n=$.useDependency(w.LocaleService),i=$.useDependency(w.IUniverInstanceService).getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET),d=i.getActiveSheet(),S=((y=e.rule)==null?void 0:y.type)===u.CFRuleType.highlightCell?e.rule:void 0,h=V.useRef(null),[C,m]=V.useState(!1),b=V.useRef(null),[E,I]=V.useState({}),[_,T]=V.useState(()=>(S==null?void 0:S.subType)===u.CFSubRuleType.formula?S.value:"="),[p,o]=V.useState(void 0),s=l=>({style:l.style,value:_,type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.formula});V.useEffect(()=>r.intercept(r.getInterceptPoints().submit,{handler(){return s({style:E})}}),[E,_,r]),V.useEffect(()=>r.intercept(r.getInterceptPoints().beforeSubmit,{handler:(v,c,g)=>p||_.length===1||!_.startsWith("=")?(o(n.t("sheet.cf.errorMessage.formulaError")),!1):g(v)}),[p,_]);const f=l=>{t(s(l))};return $.useSidebarClick(l=>{var c;((c=b.current)==null?void 0:c.isClickOutSide(l))&&m(!1)}),R.jsxs("div",{ref:h,children:[R.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),R.jsx("div",{className:"univer-mt-3",children:R.jsx(He.FormulaEditor,{onChange:l=>{T(l),f({style:E})},onVerify:(l,v)=>{!l||v.length===1?o(n.t("sheet.cf.errorMessage.formulaError")):o(void 0)},errorText:p,onFocus:()=>{m(!0)},isFocus:C,initValue:_,unitId:i.getUnitId(),subUnitId:d==null?void 0:d.getSheetId(),ref:b})}),R.jsx("div",{className:Fe,children:R.jsx(Ne,{rule:s({style:E})})}),R.jsx(qt,{style:S==null?void 0:S.style,className:"univer-mt-3",onChange:l=>{I(l),f({style:l})}})]})},gt=e=>R.jsxs("div",{style:{position:"relative"},children:[R.jsx("div",{style:{position:"absolute",zIndex:999,bottom:"-13px",fontSize:"10px",color:"red"},children:e.errorText}),e.children]}),le=(e,t)=>({label:t.t(`sheet.cf.operator.${e}`),value:e}),Mn=e=>{const{type:t,operator:r,onChange:n,value:a,interceptorManager:i}=e,d=$.useDependency(w.LocaleService),[S,h]=V.useState(()=>typeof a=="number"?a:0),[C,m]=V.useState(""),[b,E]=V.useState(()=>typeof a=="string"?a:""),[I,_]=V.useState(""),[T,p]=V.useState(()=>Array.isArray(a)?a[0]===void 0?0:a[0]:0),[o,s]=V.useState(""),[f,y]=V.useState(()=>Array.isArray(a)?a[1]===void 0?100:a[1]:100),[l,v]=V.useState("");switch(V.useEffect(()=>{switch(t){case u.CFSubRuleType.text:{[u.CFTextOperator.beginsWith,u.CFTextOperator.endsWith,u.CFTextOperator.containsText,u.CFTextOperator.notContainsText,u.CFTextOperator.equal,u.CFTextOperator.notEqual].includes(r)&&n(b);break}case u.CFSubRuleType.number:{[u.CFNumberOperator.equal,u.CFNumberOperator.notEqual,u.CFNumberOperator.greaterThan,u.CFNumberOperator.greaterThanOrEqual,u.CFNumberOperator.lessThan,u.CFNumberOperator.lessThanOrEqual].includes(r)&&n(S),[u.CFNumberOperator.between,u.CFNumberOperator.notBetween].includes(r)&&n([T,f]);break}}},[t]),V.useEffect(()=>{const c=i.intercept(i.getInterceptPoints().beforeSubmit,{handler:(g,P,M)=>{switch(t){case u.CFSubRuleType.text:if([u.CFTextOperator.beginsWith,u.CFTextOperator.containsText,u.CFTextOperator.endsWith,u.CFTextOperator.notEqual,u.CFTextOperator.notContainsText,u.CFTextOperator.equal].includes(r))return b?M(g):(_(d.t("sheet.cf.errorMessage.notBlank")),!1)}return M(g)}});return()=>{c()}},[t,S,b,r]),t){case u.CFSubRuleType.text:{if([u.CFTextOperator.beginsWith,u.CFTextOperator.endsWith,u.CFTextOperator.containsText,u.CFTextOperator.notContainsText,u.CFTextOperator.equal,u.CFTextOperator.notEqual].includes(r)){const c=g=>{E(g),n(g)};return R.jsx("div",{className:"univer-mt-3",children:R.jsx(gt,{errorText:I,children:R.jsx(J.Input,{value:b,onChange:g=>{_(""),c(g)}})})})}break}case u.CFSubRuleType.number:{if([u.CFNumberOperator.equal,u.CFNumberOperator.notEqual,u.CFNumberOperator.greaterThan,u.CFNumberOperator.greaterThanOrEqual,u.CFNumberOperator.lessThan,u.CFNumberOperator.lessThanOrEqual].includes(r)){const c=g=>{h(g||0),n(g||0),m("")};return R.jsx("div",{className:"univer-mt-3",children:R.jsx(gt,{errorText:C,children:R.jsx(J.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:S,onChange:c})})})}if([u.CFNumberOperator.between,u.CFNumberOperator.notBetween].includes(r)){const c=P=>{p(P||0),n([P||0,f]),s("")},g=P=>{y(P||0),n([T,P||0]),v("")};return R.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[R.jsx(gt,{errorText:o,children:R.jsx(J.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:T,onChange:c})}),R.jsx(gt,{errorText:l,children:R.jsx(J.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:f,onChange:g})})]})}}}return null},vr=(e,t)=>{switch(e){case u.CFSubRuleType.text:return[le(u.CFTextOperator.containsText,t),le(u.CFTextOperator.notContainsText,t),le(u.CFTextOperator.beginsWith,t),le(u.CFTextOperator.endsWith,t),le(u.CFTextOperator.equal,t),le(u.CFTextOperator.notEqual,t),le(u.CFTextOperator.containsBlanks,t),le(u.CFTextOperator.notContainsBlanks,t),le(u.CFTextOperator.containsErrors,t),le(u.CFTextOperator.notContainsErrors,t)];case u.CFSubRuleType.number:return[le(u.CFNumberOperator.between,t),le(u.CFNumberOperator.notBetween,t),le(u.CFNumberOperator.equal,t),le(u.CFNumberOperator.notEqual,t),le(u.CFNumberOperator.greaterThan,t),le(u.CFNumberOperator.greaterThanOrEqual,t),le(u.CFNumberOperator.lessThan,t),le(u.CFNumberOperator.lessThanOrEqual,t)];case u.CFSubRuleType.timePeriod:return[le(u.CFTimePeriodOperator.yesterday,t),le(u.CFTimePeriodOperator.today,t),le(u.CFTimePeriodOperator.tomorrow,t),le(u.CFTimePeriodOperator.last7Days,t),le(u.CFTimePeriodOperator.lastWeek,t),le(u.CFTimePeriodOperator.thisWeek,t),le(u.CFTimePeriodOperator.nextWeek,t),le(u.CFTimePeriodOperator.lastMonth,t),le(u.CFTimePeriodOperator.thisMonth,t),le(u.CFTimePeriodOperator.nextMonth,t)]}},gr=e=>{var y;const{interceptorManager:t,onChange:r}=e,n=$.useDependency(w.LocaleService),a=((y=e.rule)==null?void 0:y.type)===u.CFRuleType.highlightCell?e.rule:void 0,[i,d]=V.useState(()=>{const l=u.CFSubRuleType.text;return a&&a.subType||l}),S=[{value:u.CFSubRuleType.text,label:n.t("sheet.cf.subRuleType.text")},{value:u.CFSubRuleType.number,label:n.t("sheet.cf.subRuleType.number")},{value:u.CFSubRuleType.timePeriod,label:n.t("sheet.cf.subRuleType.timePeriod")},{value:u.CFSubRuleType.duplicateValues,label:n.t("sheet.cf.subRuleType.duplicateValues")},{value:u.CFSubRuleType.uniqueValues,label:n.t("sheet.cf.subRuleType.uniqueValues")}],h=V.useMemo(()=>vr(i,n),[i]),[C,m]=V.useState(()=>{const l=h?h[0].value:void 0;return a&&a.operator||l}),[b,E]=V.useState(()=>{var c;const l="";return a?(c=a.value)!=null?c:u.createDefaultValue(a.subType,a.operator):l}),[I,_]=V.useState({}),T=V.useMemo(()=>l=>{var v,c,g,P,M,U,z,O,L,W,F,X,ae,ne,se;switch(l.subType||i){case u.CFSubRuleType.text:{if([u.CFTextOperator.beginsWith,u.CFTextOperator.endsWith,u.CFTextOperator.containsText,u.CFTextOperator.notContainsText,u.CFTextOperator.equal,u.CFTextOperator.notEqual].includes(C))return{type:u.CFRuleType.highlightCell,subType:(v=l.subType)!=null?v:i,operator:(c=l.operator)!=null?c:C,style:(g=l.style)!=null?g:I,value:(P=l.value)!=null?P:b};break}case u.CFSubRuleType.number:{if([u.CFNumberOperator.equal,u.CFNumberOperator.notEqual,u.CFNumberOperator.greaterThan,u.CFNumberOperator.greaterThanOrEqual,u.CFNumberOperator.lessThan,u.CFNumberOperator.lessThanOrEqual].includes(C))return{type:u.CFRuleType.highlightCell,subType:(M=l.subType)!=null?M:i,operator:(U=l.operator)!=null?U:C,style:(z=l.style)!=null?z:I,value:(O=l.value)!=null?O:b};if([u.CFNumberOperator.between,u.CFNumberOperator.notBetween].includes(C))return{type:u.CFRuleType.highlightCell,subType:(L=l.subType)!=null?L:i,operator:(W=l.operator)!=null?W:C,style:(F=l.style)!=null?F:I,value:(X=l.value)!=null?X:b};break}}return{type:u.CFRuleType.highlightCell,subType:(ae=l.subType)!=null?ae:i,operator:(ne=l.operator)!=null?ne:C,style:(se=l.style)!=null?se:I}},[i,C,b,I]);V.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return T({})}}),[T,t]),V.useEffect(()=>{S.some(l=>l.value===i)||d(S[0].value)},[S]);const p=l=>{const v=l,c=vr(v,n),g=c&&c[0].value;d(v),m(g),g&&E(u.createDefaultValue(v,g)),r(T({subType:v,operator:g}))},o=l=>{const v=l;m(v),r(T({operator:v}))},s=l=>{E(l),r(T({value:l}))},f=V.useMemo(()=>`${i}_${C}_${Math.random()}`,[i,C]);return R.jsxs("div",{children:[R.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),R.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[R.jsx(J.Select,{className:"univer-mt-3 univer-w-full",onChange:p,value:i,options:S}),(h==null?void 0:h.length)&&R.jsx(J.Select,{className:"univer-mt-3 univer-w-full",onChange:o,value:C||"",options:h})]}),R.jsx(Mn,{value:b,interceptorManager:t,type:i,operator:C,rule:a,onChange:s},f),R.jsx("div",{className:Fe,children:R.jsx(Ne,{rule:T({})})}),R.jsx(qt,{style:a==null?void 0:a.style,className:"univer-ml-1",onChange:l=>{_(l),r(T({style:l}))}})]})},mr=(e,t)=>(u.iconMap[e]||[])[Number(t)]||"",Nn=e=>{var m;const{error:t,type:r,onChange:n}=e,a=$.useDependency(w.IUniverInstanceService),i=a.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(m=a.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:m.getSheetId(),S=V.useRef(null),[h,C]=V.useState(!1);return $.useSidebarClick(b=>{var I;((I=S.current)==null?void 0:I.isClickOutSide(b))&&C(!1)}),R.jsx("div",{className:"univer-relative",children:r!==u.CFValueType.formula?R.jsxs(R.Fragment,{children:[R.jsx(J.InputNumber,{className:J.clsx({"univer-border-red-500":t}),value:Number(e.value)||0,onChange:b=>n(b!=null?b:0)}),t&&R.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:t})]}):R.jsx("div",{className:"univer-w-full",children:R.jsx(He.FormulaEditor,{ref:S,initValue:String(e.value),unitId:i,subUnitId:d,isFocus:h,onChange:(b="")=>{n(b||"")},onFocus:()=>C(!0)})})})},yr=(e,t,r)=>({operator:u.CFNumberOperator.greaterThan,value:{type:u.CFValueType.num,value:(r.length-1-t)*10},iconType:e,iconId:String(t)}),Ln=V.forwardRef((e,t)=>{const{onClick:r}=e,n=$.useDependency(w.LocaleService),a=i=>{r(i)};return R.jsx("div",{ref:t,className:"univer-w-80",children:u.iconGroup.map((i,d)=>R.jsxs("div",{className:"univer-mb-3",children:[R.jsx("div",{className:"univer-mb-1 univer-text-sm",children:n.t(i.title)}),R.jsx("div",{className:"univer-flex univer-flex-wrap",children:i.group.map(S=>R.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{a(S.name)},children:R.jsx("a",{className:`
4
+ `,a),children:[s.jsx(v,{className:"univer-fill-primary-600",extend:{colorChannel1:o.isValid?e:""}}),c&&s.jsx(Me,{className:"univer-ml-1.5 univer-text-[10px] univer-text-gray-400"})]})}):null},ae=t=>{var a,c,p;const e=t.rule;if(!e)return null;const u=m.useMemo(()=>{if(e.type===r.CFRuleType.colorScale){const o=e.config.map((f,h)=>({color:new i.ColorKit(f.color),value:h})),v=o.length-1;return new Array(5).fill("").map((f,h,S)=>h*v/(S.length-1)).map(f=>r.getColorScaleFromValue(o,f))}return null},[e]),n=m.useMemo(()=>{if(e.type===r.CFRuleType.iconSet)return e.config.map(o=>{const v=r.iconMap[o.iconType];return v&&v[Number(o.iconId)]})},[e]),l=`univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center
5
+ univer-justify-center univer-text-xs`;switch(e.type){case r.CFRuleType.dataBar:{const{isGradient:o}=e.config,v=o?`linear-gradient(to right, ${e.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,d=o?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||r.defaultDataBarNativeColor})`:e.config.nativeColor;return s.jsxs("div",{className:l,children:[s.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:d,border:`1px solid ${e.config.nativeColor||r.defaultDataBarNativeColor}`}}),s.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:v,border:`1px solid ${e.config.positiveColor||r.defaultDataBarPositiveColor}`}})]})}case r.CFRuleType.colorScale:return u&&s.jsx("div",{className:l,children:u.map((o,v)=>s.jsx("div",{className:"univer-h-full",style:{width:`${100/u.length}%`,background:o}},v))});case r.CFRuleType.iconSet:return n&&s.jsx("div",{className:l,children:n.map((o,v)=>o?s.jsx("img",{className:"univer-h-full",src:o,draggable:!1},v):s.jsx(he,{},v))});case r.CFRuleType.highlightCell:{const{ul:o,st:v,it:d,bl:f,bg:h,cl:S}=e.style,_=(o==null?void 0:o.s)===i.BooleanNumber.TRUE,b=(v==null?void 0:v.s)===i.BooleanNumber.TRUE,x=d===i.BooleanNumber.TRUE,N=f===i.BooleanNumber.TRUE,R=(a=h==null?void 0:h.rgb)!=null?a:r.DEFAULT_BG_COLOR,w=(c=S==null?void 0:S.rgb)!=null?c:r.DEFAULT_FONT_COLOR,M={textDecoration:(p=`${_?"underline":""} ${b?"line-through":""}`.replace(/^ /,""))!=null?p:void 0,backgroundColor:R,color:w};return s.jsx("div",{className:D.clsx(l,{"univer-font-bold":N,"univer-italic":x}),style:M,children:"123"})}}},ge="univer-mt-5 univer-px-1 univer-py-2 univer-border univer-border-solid univer-border-gray-200 univer-rounded",te=(t,e)=>({label:e.t(`sheet.cf.valueType.${t}`),value:t}),Je=t=>{var _;const{type:e,className:u,onChange:n,id:l,value:a}=t,c=j.useDependency(i.IUniverInstanceService),p=c.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(_=c.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:_.getSheetId(),v=m.useMemo(()=>String(a).startsWith("=")?String(a):"=",[a]),d=m.useMemo(()=>[r.CFValueType.max,r.CFValueType.min,"none"].includes(e)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),f=m.useRef(null),[h,S]=m.useState(!1);return j.useSidebarClick(b=>{var N;((N=f.current)==null?void 0:N.isClickOutSide(b))&&S(!1)}),e===r.CFValueType.formula?s.jsx("div",{className:"univer-ml-1 univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:f,className:`
6
+ univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center
7
+ univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white
8
+ univer-pt-2 univer-transition-colors
9
+ [&>div:first-child]:univer-px-2.5
10
+ [&>div]:univer-h-5 [&>div]:univer-ring-transparent
11
+ dark:univer-border-gray-600 dark:univer-bg-gray-700 dark:univer-text-white
12
+ hover:univer-border-primary-600
13
+ `,initValue:v,unitId:p,subUnitId:o,isFocus:h,onChange:(b="")=>{n(b||"")},onFocus:()=>S(!0)})}):s.jsx(D.InputNumber,{className:u,value:Number(t.value)||0,onChange:b=>t.onChange(b||0),...d})},Or=t=>{var A;const{interceptorManager:e}=t,u=j.useDependency(i.LocaleService),n=((A=t.rule)==null?void 0:A.type)===r.CFRuleType.colorScale?t.rule:void 0,l=[te(r.CFValueType.num,u),te(r.CFValueType.percent,u),te(r.CFValueType.percentile,u),te(r.CFValueType.formula,u)],a=[te(r.CFValueType.min,u),...l],c=[te("none",u),...l],p=[te(r.CFValueType.max,u),...l],[o,v]=m.useState(()=>{var E;const y=r.CFValueType.min;return n&&((E=n.config[0])==null?void 0:E.value.type)||y}),[d,f]=m.useState(()=>{var E;const y="none";return!n||n.config.length!==3?y:((E=n.config[1])==null?void 0:E.value.type)||y}),[h,S]=m.useState(()=>{var E;const y=r.CFValueType.max;return n&&((E=n.config[n.config.length-1])==null?void 0:E.value.type)||y}),[_,b]=m.useState(()=>{if(!n)return 10;const E=n.config[0];return(E==null?void 0:E.value.value)===void 0?10:E==null?void 0:E.value.value}),[x,N]=m.useState(()=>{var F;if(!n||n.config.length!==3)return 50;const E=(F=n.config[1])==null?void 0:F.value.value;return E===void 0?50:E}),[R,w]=m.useState(()=>{var F;if(!n)return 90;const E=(F=n.config[n.config.length-1])==null?void 0:F.value.value;return E===void 0?90:E}),[M,g]=m.useState(()=>{var E;const y="#d0d9fb";return n&&((E=n.config[0])==null?void 0:E.color)||y}),[I,T]=m.useState(()=>{var E;const y="#7790f3";return!n||n.config.length!==3?y:((E=n.config[1])==null?void 0:E.color)||y}),[C,O]=m.useState(()=>{var E;const y="#2e55ef";return n&&((E=n.config[n.config.length-1])==null?void 0:E.color)||y}),V=m.useMemo(()=>y=>{const{minType:E,medianType:F,maxType:G,minValue:J,medianValue:Q,maxValue:de,minColor:ve,medianColor:L,maxColor:$}=y,H=[];return H.push({color:ve,value:{type:E,value:J}}),F!=="none"&&H.push({color:L,value:{type:F,value:Q}}),H.push({color:$,value:{type:G,value:de}}),{config:H.map((z,Y)=>({...z,index:Y})),type:r.CFRuleType.colorScale}},[]);m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return V({minType:o,medianType:d,maxType:h,minValue:_,medianValue:x,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),[V,o,d,h,_,x,R,M,I,C,e]);const U=y=>{t.onChange(V(y))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:u.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:ge,children:s.jsx(ae,{rule:V({minType:o,medianType:d,maxType:h,minValue:_,medianValue:x,maxValue:R,minColor:M,medianColor:I,maxColor:C})})}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:u.t("sheet.cf.valueType.min")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(D.Select,{className:"univer-flex-shrink-0",options:a,value:o,onChange:y=>{v(y);const E=r.createDefaultValueByValueType(y,10);b(E),U({minType:y,medianType:d,maxType:h,minValue:E,medianValue:x,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"min",className:"univer-ml-1",value:_,type:o,onChange:y=>{b(y),U({minType:o,medianType:d,maxType:h,minValue:y,medianValue:x,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(re,{className:"univer-ml-1",color:M,onChange:y=>{g(y),U({minType:o,medianType:d,maxType:h,minValue:_,medianValue:x,maxValue:R,minColor:y,medianColor:I,maxColor:C})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:u.t("sheet.cf.panel.medianValue")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(D.Select,{className:"univer-flex-shrink-0",options:c,value:d,onChange:y=>{f(y);const E=r.createDefaultValueByValueType(y,50);N(E),U({minType:o,medianType:y,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"median",className:"univer-ml-1",value:x,type:d,onChange:y=>{N(y),U({minType:o,medianType:d,maxType:h,minValue:_,medianValue:y,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),d!=="none"&&s.jsx(re,{className:"univer-ml-1",color:I,onChange:y=>{T(y),U({minType:o,medianType:d,maxType:h,minValue:_,medianValue:x,maxValue:R,minColor:M,medianColor:y,maxColor:C})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:u.t("sheet.cf.valueType.max")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(D.Select,{className:"univer-flex-shrink-0",options:p,value:h,onChange:y=>{S(y);const E=r.createDefaultValueByValueType(y,90);w(E),U({minType:o,medianType:d,maxType:y,minValue:_,medianValue:x,maxValue:E,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"max",className:"univer-ml-1",value:R,type:h,onChange:y=>{w(y),U({minType:o,medianType:d,maxType:h,minValue:_,medianValue:x,maxValue:y,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(re,{className:"univer-ml-1",color:C,onChange:y=>{O(y),U({minType:o,medianType:d,maxType:h,minValue:_,medianValue:x,maxValue:R,minColor:M,medianColor:I,maxColor:y})}})]})]})},ie=(t,e)=>({label:e.t(`sheet.cf.valueType.${t}`),value:t}),sr=t=>{var b;const{onChange:e,className:u,value:n,type:l,id:a,disabled:c=!1}=t,p=j.useDependency(i.IUniverInstanceService),o=p.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),v=(b=p.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId(),d=m.useRef(null),[f,h]=m.useState(!1);j.useSidebarClick(x=>{var R;((R=d.current)==null?void 0:R.isClickOutSide(x))&&h(!1)});const S=m.useRef(n),_=m.useMemo(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(l)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[l]);if(l===r.CFValueType.formula){const x=String(S.current).startsWith("=")?String(S.current)||"":"=";return s.jsx("div",{className:"univer-ml-3 univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:d,className:`
14
+ univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center
15
+ univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white
16
+ univer-pt-2 univer-transition-colors
17
+ [&>div:first-child]:univer-px-2.5
18
+ [&>div]:univer-h-5 [&>div]:univer-ring-transparent
19
+ dark:univer-border-gray-600 dark:univer-bg-gray-700 dark:univer-text-white
20
+ hover:univer-border-primary-600
21
+ `,initValue:x,unitId:o,subUnitId:v,isFocus:f,onChange:(N="")=>{e(N||"")},onFocus:()=>h(!0)})})}return s.jsx(D.InputNumber,{className:u,value:Number(n)||0,disabled:c,onChange:x=>{e(x||0)},..._})},Ur=t=>{var A;const{interceptorManager:e}=t,u=j.useDependency(i.LocaleService),n=((A=t.rule)==null?void 0:A.type)===r.CFRuleType.dataBar?t.rule:void 0,[l,a]=m.useState(()=>{var E;const y="0";return n?(E=n.config)!=null&&E.isGradient?"1":"0":y}),[c,p]=m.useState(()=>{var y;return n&&((y=n.config)==null?void 0:y.positiveColor)||r.defaultDataBarPositiveColor}),[o,v]=m.useState(()=>{var y;return n&&((y=n.config)==null?void 0:y.nativeColor)||r.defaultDataBarNativeColor}),d=[ie(r.CFValueType.num,u),ie(r.CFValueType.percent,u),ie(r.CFValueType.percentile,u),ie(r.CFValueType.formula,u)],f=[ie(r.CFValueType.min,u),...d],h=[ie(r.CFValueType.max,u),...d],[S,_]=m.useState(()=>{var E;const y=f[0].value;return n&&((E=n.config)==null?void 0:E.min.type)||y}),[b,x]=m.useState(()=>{var E;const y=h[0].value;return n&&((E=n.config)==null?void 0:E.max.type)||y}),[N,R]=m.useState(()=>{var F;if(!n)return 0;const E=((F=n.config)==null?void 0:F.min)||{};return E.type===r.CFValueType.formula?E.value||"=":E.value||0}),[w,M]=m.useState(()=>{var F;if(!n)return 100;const E=((F=n.config)==null?void 0:F.max)||{};return E.type===r.CFValueType.formula?E.value||"=":E.value===void 0?100:E.value}),[g,I]=m.useState(()=>n?n.isShowValue===void 0?!0:!!n.isShowValue:!0),T=y=>({config:{min:{type:y.minValueType,value:y.minValue},max:{type:y.maxValueType,value:y.maxValue},isGradient:y.isGradient==="1",positiveColor:y.positiveColor||r.defaultDataBarPositiveColor,nativeColor:y.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:y.isShowValue});m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return T({isGradient:l,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:g})}}),[l,N,S,w,b,c,o,e,g]);const C=y=>{t.onChange(T(y))},O=y=>{p(y),C({isGradient:l,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:y,nativeColor:o,isShowValue:g})},V=y=>{v(y),C({isGradient:l,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:y,isShowValue:g})},U=y=>d.map(E=>E.value).includes(y);return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:u.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:ge,children:s.jsx(ae,{rule:T({isGradient:l,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:g})})}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:u.t("sheet.cf.panel.fillType")}),s.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[s.jsxs(D.RadioGroup,{value:l,onChange:y=>{a(y),C({isGradient:y,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:g})},children:[s.jsx(D.Radio,{value:"0",children:s.jsx("span",{className:"univer-text-xs",children:u.t("sheet.cf.panel.pureColor")})}),s.jsx(D.Radio,{value:"1",children:s.jsx("span",{className:"univer-text-xs",children:u.t("sheet.cf.panel.gradient")})})]}),s.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[s.jsx(D.Checkbox,{checked:!g,onChange:y=>{I(!y),C({isGradient:y,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:!y})}}),u.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:u.t("sheet.cf.panel.colorSet")}),s.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[s.jsxs("div",{className:"univer-flex univer-items-center",children:[s.jsx("div",{className:"univer-text-xs",children:u.t("sheet.cf.panel.native")}),s.jsx(re,{color:o,onChange:V})]}),s.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[s.jsx("div",{className:"univer-text-xs",children:u.t("sheet.cf.panel.positive")}),s.jsx(re,{color:c,onChange:O})]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:u.t("sheet.cf.valueType.min")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(D.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:f,value:S,onChange:y=>{_(y);const E=r.createDefaultValueByValueType(y,10);R(E),C({isGradient:l,minValue:E,minValueType:y,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:g})}}),s.jsx(sr,{id:"min",className:"univer-ml-3",disabled:!U(S),type:S,value:N,onChange:y=>{R(y||0),C({isGradient:l,minValue:y||0,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:g})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:u.t("sheet.cf.valueType.max")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(D.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:b,onChange:y=>{x(y);const E=r.createDefaultValueByValueType(y,90);M(E),C({isGradient:l,minValue:N,minValueType:S,maxValue:E,maxValueType:y,positiveColor:c,nativeColor:o,isShowValue:g})}}),s.jsx(sr,{className:"univer-ml-3",disabled:!U(b),id:"max",type:b,value:w,onChange:y=>{M(y||0),C({isGradient:l,minValue:N,minValueType:S,maxValue:y||0,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:g})}})]})]})]})},we=t=>[i.BooleanNumber.FALSE,void 0].includes(t)?i.BooleanNumber.TRUE:i.BooleanNumber.FALSE,Ve=t=>t!==i.BooleanNumber.FALSE,Qe=t=>{const{style:e,onChange:u,className:n}=t,l=j.useDependency(j.ComponentManager),[a,c]=m.useState(()=>{if(e!=null&&e.bl)return e.bl}),[p,o]=m.useState(()=>{if(e!=null&&e.it)return e.it}),[v,d]=m.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[f,h]=m.useState(()=>{if(e!=null&&e.st)return e.st.s}),[S,_]=m.useState(()=>{var T;const I="#2f56ef";return(T=e==null?void 0:e.cl)!=null&&T.rgb?e.cl.rgb:I}),[b,x]=m.useState(()=>{var T;const I="#e8ecfc";return(T=e==null?void 0:e.bg)!=null&&T.rgb?e.bg.rgb:I}),N=l.get("BoldSingle"),R=l.get("ItalicSingle"),w=l.get("UnderlineSingle"),M=l.get("StrikethroughSingle");m.useEffect(()=>{const I={bl:a,it:p};S!==void 0&&(I.cl={rgb:S}),b!==void 0&&(I.bg={rgb:b}),f!==void 0&&(I.st={s:f}),v!==void 0&&(I.ul={s:v}),u(r.removeUndefinedAttr(I))},[a,p,v,f,S,b]);const g="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return s.jsxs("div",{className:D.clsx("univer-my-2.5 univer-flex univer-justify-between",n),children:[N&&s.jsx("div",{className:D.clsx(g,{"univer-bg-gray-100":Ve(a||i.BooleanNumber.FALSE)}),onClick:()=>c(we(a)),children:s.jsx(N,{})}),R&&s.jsx("div",{className:D.clsx(g,{"univer-bg-gray-100":Ve(p||i.BooleanNumber.FALSE)}),onClick:()=>o(we(p)),children:s.jsx(R,{})}),w&&s.jsx("div",{className:D.clsx(g,{"univer-bg-gray-100":Ve(v||i.BooleanNumber.FALSE)}),onClick:()=>d(we(v)),children:s.jsx(w,{})}),M&&s.jsx("div",{className:D.clsx(g,{"univer-bg-gray-100":Ve(f||i.BooleanNumber.FALSE)}),onClick:()=>h(we(f)),children:s.jsx(M,{})}),s.jsx(re,{color:S,onChange:_,iconId:"FontColor"}),s.jsx(re,{color:b,onChange:x,iconId:"PaintBucket"})]})},kr=t=>{var M;const{onChange:e,interceptorManager:u}=t,n=j.useDependency(i.LocaleService),a=j.useDependency(i.IUniverInstanceService).getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),c=a.getActiveSheet(),p=((M=t.rule)==null?void 0:M.type)===r.CFRuleType.highlightCell?t.rule:void 0,o=m.useRef(null),[v,d]=m.useState(!1),f=m.useRef(null),[h,S]=m.useState({}),[_,b]=m.useState(()=>(p==null?void 0:p.subType)===r.CFSubRuleType.formula?p.value:"="),[x,N]=m.useState(void 0),R=g=>({style:g.style,value:_,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});m.useEffect(()=>u.intercept(u.getInterceptPoints().submit,{handler(){return R({style:h})}}),[h,_,u]),m.useEffect(()=>u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(I,T,C)=>x||_.length===1||!_.startsWith("=")?(N(n.t("sheet.cf.errorMessage.formulaError")),!1):C(I)}),[x,_]);const w=g=>{e(R(g))};return j.useSidebarClick(g=>{var T;((T=f.current)==null?void 0:T.isClickOutSide(g))&&d(!1)}),s.jsxs("div",{ref:o,children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:"univer-mt-3",children:s.jsx(pe.FormulaEditor,{ref:f,className:`
22
+ univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center
23
+ univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white
24
+ univer-pt-2 univer-transition-colors
25
+ [&>div:first-child]:univer-px-2.5
26
+ [&>div]:univer-h-5 [&>div]:univer-ring-transparent
27
+ dark:univer-border-gray-600 dark:univer-bg-gray-700 dark:univer-text-white
28
+ hover:univer-border-primary-600
29
+ `,errorText:x,isFocus:v,initValue:_,unitId:a.getUnitId(),subUnitId:c==null?void 0:c.getSheetId(),onFocus:()=>{d(!0)},onChange:g=>{b(g),w({style:h})},onVerify:(g,I)=>{!g||I.length===1?N(n.t("sheet.cf.errorMessage.formulaError")):N(void 0)}})}),s.jsx("div",{className:ge,children:s.jsx(ae,{rule:R({style:h})})}),s.jsx(Qe,{style:p==null?void 0:p.style,className:"univer-mt-3",onChange:g=>{S(g),w({style:g})}})]})},Oe=t=>s.jsxs("div",{style:{position:"relative"},children:[s.jsx("div",{style:{position:"absolute",zIndex:999,bottom:"-13px",fontSize:"10px",color:"red"},children:t.errorText}),t.children]}),B=(t,e)=>({label:e.t(`sheet.cf.operator.${t}`),value:t}),Pr=t=>{const{type:e,operator:u,onChange:n,value:l,interceptorManager:a}=t,c=j.useDependency(i.LocaleService),[p,o]=m.useState(()=>typeof l=="number"?l:0),[v,d]=m.useState(""),[f,h]=m.useState(()=>typeof l=="string"?l:""),[S,_]=m.useState(""),[b,x]=m.useState(()=>Array.isArray(l)?l[0]===void 0?0:l[0]:0),[N,R]=m.useState(""),[w,M]=m.useState(()=>Array.isArray(l)?l[1]===void 0?100:l[1]:100),[g,I]=m.useState("");switch(m.useEffect(()=>{switch(e){case r.CFSubRuleType.text:{[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(u)&&n(f);break}case r.CFSubRuleType.number:{[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(u)&&n(p),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)&&n([b,w]);break}}},[e]),m.useEffect(()=>{const T=a.intercept(a.getInterceptPoints().beforeSubmit,{handler:(C,O,V)=>{switch(e){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(u))return f?V(C):(_(c.t("sheet.cf.errorMessage.notBlank")),!1)}return V(C)}});return()=>{T()}},[e,p,f,u]),e){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(u)){const T=C=>{h(C),n(C)};return s.jsx("div",{className:"univer-mt-3",children:s.jsx(Oe,{errorText:S,children:s.jsx(D.Input,{value:f,onChange:C=>{_(""),T(C)}})})})}break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(u)){const T=C=>{o(C||0),n(C||0),d("")};return s.jsx("div",{className:"univer-mt-3",children:s.jsx(Oe,{errorText:v,children:s.jsx(D.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:p,onChange:T})})})}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)){const T=O=>{x(O||0),n([O||0,w]),R("")},C=O=>{M(O||0),n([b,O||0]),I("")};return s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(Oe,{errorText:N,children:s.jsx(D.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:b,onChange:T})}),s.jsx(Oe,{errorText:g,children:s.jsx(D.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:w,onChange:C})})]})}}}return null},cr=(t,e)=>{switch(t){case r.CFSubRuleType.text:return[B(r.CFTextOperator.containsText,e),B(r.CFTextOperator.notContainsText,e),B(r.CFTextOperator.beginsWith,e),B(r.CFTextOperator.endsWith,e),B(r.CFTextOperator.equal,e),B(r.CFTextOperator.notEqual,e),B(r.CFTextOperator.containsBlanks,e),B(r.CFTextOperator.notContainsBlanks,e),B(r.CFTextOperator.containsErrors,e),B(r.CFTextOperator.notContainsErrors,e)];case r.CFSubRuleType.number:return[B(r.CFNumberOperator.between,e),B(r.CFNumberOperator.notBetween,e),B(r.CFNumberOperator.equal,e),B(r.CFNumberOperator.notEqual,e),B(r.CFNumberOperator.greaterThan,e),B(r.CFNumberOperator.greaterThanOrEqual,e),B(r.CFNumberOperator.lessThan,e),B(r.CFNumberOperator.lessThanOrEqual,e)];case r.CFSubRuleType.timePeriod:return[B(r.CFTimePeriodOperator.yesterday,e),B(r.CFTimePeriodOperator.today,e),B(r.CFTimePeriodOperator.tomorrow,e),B(r.CFTimePeriodOperator.last7Days,e),B(r.CFTimePeriodOperator.lastWeek,e),B(r.CFTimePeriodOperator.thisWeek,e),B(r.CFTimePeriodOperator.nextWeek,e),B(r.CFTimePeriodOperator.lastMonth,e),B(r.CFTimePeriodOperator.thisMonth,e),B(r.CFTimePeriodOperator.nextMonth,e)]}},or=t=>{var M;const{interceptorManager:e,onChange:u}=t,n=j.useDependency(i.LocaleService),l=((M=t.rule)==null?void 0:M.type)===r.CFRuleType.highlightCell?t.rule:void 0,[a,c]=m.useState(()=>{const g=r.CFSubRuleType.text;return l&&l.subType||g}),p=[{value:r.CFSubRuleType.text,label:n.t("sheet.cf.subRuleType.text")},{value:r.CFSubRuleType.number,label:n.t("sheet.cf.subRuleType.number")},{value:r.CFSubRuleType.timePeriod,label:n.t("sheet.cf.subRuleType.timePeriod")},{value:r.CFSubRuleType.duplicateValues,label:n.t("sheet.cf.subRuleType.duplicateValues")},{value:r.CFSubRuleType.uniqueValues,label:n.t("sheet.cf.subRuleType.uniqueValues")}],o=m.useMemo(()=>cr(a,n),[a]),[v,d]=m.useState(()=>{const g=o?o[0].value:void 0;return l&&l.operator||g}),[f,h]=m.useState(()=>{var T;const g="";return l?(T=l.value)!=null?T:r.createDefaultValue(l.subType,l.operator):g}),[S,_]=m.useState({}),b=m.useMemo(()=>g=>{var I,T,C,O,V,U,A,y,E,F,G,J,Q,de,ve;switch(g.subType||a){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(v))return{type:r.CFRuleType.highlightCell,subType:(I=g.subType)!=null?I:a,operator:(T=g.operator)!=null?T:v,style:(C=g.style)!=null?C:S,value:(O=g.value)!=null?O:f};break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(v))return{type:r.CFRuleType.highlightCell,subType:(V=g.subType)!=null?V:a,operator:(U=g.operator)!=null?U:v,style:(A=g.style)!=null?A:S,value:(y=g.value)!=null?y:f};if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(v))return{type:r.CFRuleType.highlightCell,subType:(E=g.subType)!=null?E:a,operator:(F=g.operator)!=null?F:v,style:(G=g.style)!=null?G:S,value:(J=g.value)!=null?J:f};break}}return{type:r.CFRuleType.highlightCell,subType:(Q=g.subType)!=null?Q:a,operator:(de=g.operator)!=null?de:v,style:(ve=g.style)!=null?ve:S}},[a,v,f,S]);m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return b({})}}),[b,e]),m.useEffect(()=>{p.some(g=>g.value===a)||c(p[0].value)},[p]);const x=g=>{const I=g,T=cr(I,n),C=T&&T[0].value;c(I),d(C),C&&h(r.createDefaultValue(I,C)),u(b({subType:I,operator:C}))},N=g=>{const I=g;d(I),u(b({operator:I}))},R=g=>{h(g),u(b({value:g}))},w=m.useMemo(()=>`${a}_${v}_${Math.random()}`,[a,v]);return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),s.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[s.jsx(D.Select,{className:"univer-mt-3 univer-w-full",onChange:x,value:a,options:p}),(o==null?void 0:o.length)&&s.jsx(D.Select,{className:"univer-mt-3 univer-w-full",onChange:N,value:v||"",options:o})]}),s.jsx(Pr,{value:f,interceptorManager:e,type:a,operator:v,rule:l,onChange:R},w),s.jsx("div",{className:ge,children:s.jsx(ae,{rule:b({})})}),s.jsx(Qe,{style:l==null?void 0:l.style,className:"univer-ml-1",onChange:g=>{_(g),u(b({style:g}))}})]})},dr=(t,e)=>(r.iconMap[t]||[])[Number(e)]||"",Dr=t=>{var d;const{error:e,type:u,onChange:n}=t,l=j.useDependency(i.IUniverInstanceService),a=l.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(d=l.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),p=m.useRef(null),[o,v]=m.useState(!1);return j.useSidebarClick(f=>{var S;((S=p.current)==null?void 0:S.isClickOutSide(f))&&v(!1)}),s.jsx("div",{className:"univer-relative",children:u!==r.CFValueType.formula?s.jsxs(s.Fragment,{children:[s.jsx(D.InputNumber,{className:D.clsx({"univer-border-red-500":e}),value:Number(t.value)||0,onChange:f=>n(f!=null?f:0)}),e&&s.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):s.jsx("div",{className:"univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:p,initValue:String(t.value),unitId:a,subUnitId:c,isFocus:o,onChange:(f="")=>{n(f||"")},onFocus:()=>v(!0)})})})},vr=(t,e,u)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(u.length-1-e)*10},iconType:t,iconId:String(e)}),jr=m.forwardRef((t,e)=>{const{onClick:u}=t,n=j.useDependency(i.LocaleService),l=a=>{u(a)};return s.jsx("div",{ref:e,className:"univer-w-80",children:r.iconGroup.map((a,c)=>s.jsxs("div",{className:"univer-mb-3",children:[s.jsx("div",{className:"univer-mb-1 univer-text-sm",children:n.t(a.title)}),s.jsx("div",{className:"univer-flex univer-flex-wrap",children:a.group.map(p=>s.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{l(p.name)},children:s.jsx("a",{className:`
6
30
  univer-cursor-pointer univer-rounded
7
31
  hover:univer-bg-gray-100
8
- `,children:S.list.map((h,C)=>R.jsx("img",{className:"univer-size-5",src:h,draggable:!1},C))})},S.name))})]},d))})}),Vn=e=>{const{onClick:t}=e,r=V.useMemo(()=>{const a=[];for(const i in u.iconMap){const d=u.iconMap[i],S=i;d.forEach((h,C)=>{a.push({iconType:S,base64:h,iconId:String(C)})})}return a},[]),n=a=>{t(a.iconType,a.iconId)};return R.jsxs("div",{children:[R.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>n({iconType:u.EMPTY_ICON_TYPE,iconId:""}),children:[R.jsx(Be,{className:"univer-size-5"}),R.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),R.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:r.map(a=>R.jsx("div",{className:`
32
+ `,children:p.list.map((o,v)=>s.jsx("img",{className:"univer-size-5",src:o,draggable:!1},v))})},p.name))})]},c))})}),Ar=t=>{const{onClick:e}=t,u=m.useMemo(()=>{const l=[];for(const a in r.iconMap){const c=r.iconMap[a],p=a;c.forEach((o,v)=>{l.push({iconType:p,base64:o,iconId:String(v)})})}return l},[]),n=l=>{e(l.iconType,l.iconId)};return s.jsxs("div",{children:[s.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>n({iconType:r.EMPTY_ICON_TYPE,iconId:""}),children:[s.jsx(he,{className:"univer-size-5"}),s.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),s.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:u.map(l=>s.jsx("div",{className:`
9
33
  univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center
10
34
  univer-justify-center univer-rounded
11
35
  hover:univer-bg-gray-100
12
- `,children:R.jsx("img",{className:"univer-size-5",src:a.base64,draggable:!1,onClick:()=>n(a)})},`${a.iconType}_${a.iconId}`))})]})},Un=e=>{const{onChange:t,configList:r,errorMap:n={}}=e,a=$.useDependency(w.LocaleService),i=[{label:a.t(`sheet.cf.symbol.${u.CFNumberOperator.greaterThan}`),value:u.CFNumberOperator.greaterThan},{label:a.t(`sheet.cf.symbol.${u.CFNumberOperator.greaterThanOrEqual}`),value:u.CFNumberOperator.greaterThanOrEqual}],d=[{label:a.t(`sheet.cf.valueType.${u.CFValueType.num}`),value:u.CFValueType.num},{label:a.t(`sheet.cf.valueType.${u.CFValueType.percent}`),value:u.CFValueType.percent},{label:a.t(`sheet.cf.valueType.${u.CFValueType.percentile}`),value:u.CFValueType.percentile},{label:a.t(`sheet.cf.valueType.${u.CFValueType.formula}`),value:u.CFValueType.formula}],S=(b,E)=>{t([String(E),"value","value"],b)},h=(b,E)=>{t([String(E),"operator"],b);const I=u.createDefaultValue(u.CFSubRuleType.number,b);S(I,E)},C=(b,E)=>{t([String(E),"value","type"],b);const I=r[E],_=u.createDefaultValue(u.CFSubRuleType.number,I.operator);S(_,E)};return V.useMemo(()=>r.map((b,E)=>{const I=n[E],_=mr(b.iconType,b.iconId),T=E===r.length-1,p=E===0,o=r[E-1],s=(o==null?void 0:o.value.type)===u.CFValueType.formula?a.t("sheet.cf.valueType.formula"):o==null?void 0:o.value.value,f=(y,l)=>{const v={...b,iconId:l,iconType:y};t([String(E)],v)};return R.jsxs("div",{className:E?"univer-mt-6":"univer-mt-3",children:[R.jsxs("div",{className:`
36
+ `,children:s.jsx("img",{className:"univer-size-5",src:l.base64,draggable:!1,onClick:()=>n(l)})},`${l.iconType}_${l.iconId}`))})]})},Lr=t=>{const{onChange:e,configList:u,errorMap:n={}}=t,l=j.useDependency(i.LocaleService),a=[{label:l.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:l.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],c=[{label:l.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:l.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:l.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:l.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],p=(f,h)=>{e([String(h),"value","value"],f)},o=(f,h)=>{e([String(h),"operator"],f);const S=r.createDefaultValue(r.CFSubRuleType.number,f);p(S,h)},v=(f,h)=>{e([String(h),"value","type"],f);const S=u[h],_=r.createDefaultValue(r.CFSubRuleType.number,S.operator);p(_,h)};return m.useMemo(()=>u.map((f,h)=>{const S=n[h],_=dr(f.iconType,f.iconId),b=h===u.length-1,x=h===0,N=u[h-1],R=(N==null?void 0:N.value.type)===r.CFValueType.formula?l.t("sheet.cf.valueType.formula"):N==null?void 0:N.value.value,w=(M,g)=>{const I={...f,iconId:g,iconType:M};e([String(h)],I)};return s.jsxs("div",{className:h?"univer-mt-6":"univer-mt-3",children:[s.jsxs("div",{className:`
13
37
  univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm
14
38
  univer-text-gray-600
15
- `,children:[R.jsxs("div",{className:"univer-w-[45%]",children:[a.t("sheet.cf.iconSet.icon"),E+1]}),R.jsx("div",{className:"univer-w-[45%]",children:R.jsxs(R.Fragment,{children:[!p&&!T&&a.t("sheet.cf.iconSet.rule"),!p&&!T&&R.jsxs("span",{className:"univer-font-medium univer-text-gray-600",children:["(",a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${u.getOppositeOperator(o.operator)}`),s,T?"":` ${a.t("sheet.cf.iconSet.and")} `,")"]})]})})]}),R.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[R.jsx("div",{className:"univer-flex univer-items-center",children:R.jsx(J.Dropdown,{overlay:R.jsx("div",{className:"univer-rounded-lg univer-p-4",children:R.jsx(Vn,{onClick:f,iconId:b.iconId,iconType:b.iconType})}),children:R.jsxs("div",{className:`
39
+ `,children:[s.jsxs("div",{className:"univer-w-[45%]",children:[l.t("sheet.cf.iconSet.icon"),h+1]}),s.jsx("div",{className:"univer-w-[45%]",children:s.jsxs(s.Fragment,{children:[!x&&!b&&l.t("sheet.cf.iconSet.rule"),!x&&!b&&s.jsxs("span",{className:"univer-font-medium univer-text-gray-600",children:["(",l.t("sheet.cf.iconSet.when"),l.t(`sheet.cf.symbol.${r.getOppositeOperator(N.operator)}`),R,b?"":` ${l.t("sheet.cf.iconSet.and")} `,")"]})]})})]}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[s.jsx("div",{className:"univer-flex univer-items-center",children:s.jsx(D.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(Ar,{onClick:w,iconId:f.iconId,iconType:f.iconType})}),children:s.jsxs("div",{className:`
16
40
  univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center
17
41
  univer-justify-between univer-rounded-md univer-border univer-border-solid
18
42
  univer-border-gray-200 univer-bg-white univer-px-4 univer-py-2 univer-text-xs
19
43
  univer-text-gray-600 univer-transition-all
20
44
  hover:univer-border-primary-600
21
- `,children:[_?R.jsx("img",{src:_,className:"univer-size-4",draggable:!1}):R.jsx(Be,{className:"univer-size-4"}),R.jsx(pt,{})]})})}),T?R.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600",children:[a.t("sheet.cf.iconSet.rule"),R.jsxs("span",{className:"univer-font-medium univer-text-gray-600",children:[a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${u.getOppositeOperator(o.operator)}`),s,T?"":` ${a.t("sheet.cf.iconSet.and")} `]})]}):R.jsx(J.Select,{options:i,value:b.operator,onChange:y=>{h(y,E)}})]}),T?R.jsx("div",{}):R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:`
45
+ `,children:[_?s.jsx("img",{src:_,className:"univer-size-4",draggable:!1}):s.jsx(he,{className:"univer-size-4"}),s.jsx(Me,{})]})})}),b?s.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600",children:[l.t("sheet.cf.iconSet.rule"),s.jsxs("span",{className:"univer-font-medium univer-text-gray-600",children:[l.t("sheet.cf.iconSet.when"),l.t(`sheet.cf.symbol.${r.getOppositeOperator(N.operator)}`),R,b?"":` ${l.t("sheet.cf.iconSet.and")} `]})]}):s.jsx(D.Select,{options:a,value:f.operator,onChange:M=>{o(M,h)}})]}),b?s.jsx("div",{}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`
22
46
  univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4
23
47
  univer-text-sm univer-text-gray-600
24
- `,children:[R.jsx("div",{children:a.t("sheet.cf.iconSet.type")}),R.jsx("div",{children:a.t("sheet.cf.iconSet.value")})]}),R.jsxs("div",{className:`
48
+ `,children:[s.jsx("div",{children:l.t("sheet.cf.iconSet.type")}),s.jsx("div",{children:l.t("sheet.cf.iconSet.value")})]}),s.jsxs("div",{className:`
25
49
  univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4
26
- `,children:[R.jsx(J.Select,{className:"univer-flex-shrink-0",options:d,value:b.value.type,onChange:y=>{C(y,E)}}),R.jsx("div",{children:R.jsx(Nn,{id:E,type:b.value.type,error:I,value:b.value.value||"",onChange:y=>{S(y,E)}})})]})]})]},E)}),[r,n])},zn=e=>{var y;const{interceptorManager:t}=e,r=((y=e.rule)==null?void 0:y.type)===u.CFRuleType.iconSet?e.rule:void 0,n=$.useDependency(w.LocaleService),[a,i]=V.useState({}),[d,S]=V.useState(()=>{const l=Object.keys(u.iconMap)[0];if(r&&r.config.length){const v=r.config[0].iconType;if(!r.config.some(g=>g.iconType!==v))return v}return l}),[h,C]=V.useState(()=>{if(r&&r.config.length)return w.Tools.deepClone(r==null?void 0:r.config);const l=u.iconMap[d]||[];return new Array(l.length).fill("").map((v,c,g)=>c===g.length-1?{operator:u.CFNumberOperator.lessThanOrEqual,value:{type:u.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:d,iconId:String(c)}:yr(d,c,g))}),[m,b]=V.useState(()=>r?!!r.isShowValue:!0),E=V.useMemo(()=>{const l=h.map(v=>mr(v.iconType,v.iconId));return R.jsx("div",{className:"univer-flex univer-items-center",children:l.map((v,c)=>v?R.jsx("img",{className:"univer-size-5",src:v},c):R.jsx(Be,{className:"univer-size-5"},c))})},[h]),I=l=>{if(l.reduce((c,g,P)=>c.preType&&!c.result||l.length-1===P?c:g.value.type===u.CFValueType.formula?{preType:u.CFValueType.formula,result:!1}:c.preType?{result:c.preType===g.value.type,preType:g.value.type}:{result:!0,preType:g.value.type},{result:!0,preType:""}).result&&[u.CFValueType.num,u.CFValueType.percent,u.CFValueType.percentile].includes(l[0].value.type)){const c={};return l.forEach((g,P,M)=>{if(P-1<0||P===M.length-1)return;const z=l[P-1],O=u.getOppositeOperator(z.operator);u.compareWithNumber({operator:O,value:z.value.value},g.value.value)||(c[P]=`${n.t(`sheet.cf.form.${O}`,String(z.value.value))} `)}),c}return{}},_=(l,v)=>{w.get(h,l)!==v&&(w.set(h,l,v),C([...h]),i(I(h)))},T=l=>{S(l);const v=u.iconMap[l]||[],c=new Array(v.length).fill("").map((g,P,M)=>yr(l,P,M));C(c),i(I(c))};V.useEffect(()=>{const l=t.intercept(t.getInterceptPoints().submit,{handler(){return{type:u.CFRuleType.iconSet,isShowValue:m,config:h}}});return()=>{l()}},[m,h,t]),V.useEffect(()=>{const l=t.intercept(t.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(a).length===0}});return()=>{l()}},[m,h,t,a]);const p=()=>{const l=h.map(v=>({...v}));h.forEach((v,c)=>{const g=h.length-1-c,P=l[g];v.iconId=P.iconId,v.iconType=P.iconType}),C([...h])},o=$.useDependency($.ILayoutService),[s,f]=V.useState();return $.useScrollYOverContainer(s,o.rootContainerElement),R.jsxs("div",{children:[R.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),R.jsx("div",{className:"univer-mt-3",children:R.jsx(J.Dropdown,{overlay:R.jsx("div",{className:"univer-rounded-lg univer-p-4",children:R.jsx(Ln,{ref:l=>{!s&&l&&f(l)},iconType:d,onClick:T})}),children:R.jsxs("div",{className:J.clsx(`
50
+ `,children:[s.jsx(D.Select,{className:"univer-flex-shrink-0",options:c,value:f.value.type,onChange:M=>{v(M,h)}}),s.jsx("div",{children:s.jsx(Dr,{id:h,type:f.value.type,error:S,value:f.value.value||"",onChange:M=>{p(M,h)}})})]})]})]},h)}),[u,n])},Fr=t=>{var M;const{interceptorManager:e}=t,u=((M=t.rule)==null?void 0:M.type)===r.CFRuleType.iconSet?t.rule:void 0,n=j.useDependency(i.LocaleService),[l,a]=m.useState({}),[c,p]=m.useState(()=>{const g=Object.keys(r.iconMap)[0];if(u&&u.config.length){const I=u.config[0].iconType;if(!u.config.some(C=>C.iconType!==I))return I}return g}),[o,v]=m.useState(()=>{if(u&&u.config.length)return i.Tools.deepClone(u==null?void 0:u.config);const g=r.iconMap[c]||[];return new Array(g.length).fill("").map((I,T,C)=>T===C.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:c,iconId:String(T)}:vr(c,T,C))}),[d,f]=m.useState(()=>u?!!u.isShowValue:!0),h=m.useMemo(()=>{const g=o.map(I=>dr(I.iconType,I.iconId));return s.jsx("div",{className:"univer-flex univer-items-center",children:g.map((I,T)=>I?s.jsx("img",{className:"univer-size-5",src:I},T):s.jsx(he,{className:"univer-size-5"},T))})},[o]),S=g=>{if(g.reduce((T,C,O)=>T.preType&&!T.result||g.length-1===O?T:C.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:T.preType?{result:T.preType===C.value.type,preType:C.value.type}:{result:!0,preType:C.value.type},{result:!0,preType:""}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(g[0].value.type)){const T={};return g.forEach((C,O,V)=>{if(O-1<0||O===V.length-1)return;const A=g[O-1],y=r.getOppositeOperator(A.operator);r.compareWithNumber({operator:y,value:A.value.value},C.value.value)||(T[O]=`${n.t(`sheet.cf.form.${y}`,String(A.value.value))} `)}),T}return{}},_=(g,I)=>{i.get(o,g)!==I&&(i.set(o,g,I),v([...o]),a(S(o)))},b=g=>{p(g);const I=r.iconMap[g]||[],T=new Array(I.length).fill("").map((C,O,V)=>vr(g,O,V));v(T),a(S(T))};m.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:d,config:o}}});return()=>{g()}},[d,o,e]),m.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(l).length===0}});return()=>{g()}},[d,o,e,l]);const x=()=>{const g=o.map(I=>({...I}));o.forEach((I,T)=>{const C=o.length-1-T,O=g[C];I.iconId=O.iconId,I.iconType=O.iconType}),v([...o])},N=j.useDependency(j.ILayoutService),[R,w]=m.useState();return j.useScrollYOverContainer(R,N.rootContainerElement),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:"univer-mt-3",children:s.jsx(D.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(jr,{ref:g=>{!R&&g&&w(g)},iconType:c,onClick:b})}),children:s.jsxs("div",{className:D.clsx(`
27
51
  univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center
28
52
  univer-justify-between univer-rounded-md univer-border univer-border-solid
29
53
  univer-border-gray-200 univer-bg-white univer-px-4 univer-py-2 univer-text-xs
30
54
  univer-text-gray-600 univer-transition-all
31
55
  hover:univer-border-primary-600
32
- `),children:[E,R.jsx(pt,{})]})})}),R.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[R.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[R.jsx(J.Checkbox,{onChange:p}),n.t("sheet.cf.iconSet.reverseIconOrder")]}),R.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[R.jsx(J.Checkbox,{checked:!m,onChange:l=>{b(!l)}}),n.t("sheet.cf.iconSet.onlyShowIcon")]})]}),R.jsx(Un,{errorMap:a,onChange:_,configList:h})]})},kn=e=>{var p;const{onChange:t,interceptorManager:r}=e,n=$.useDependency(w.LocaleService),a=((p=e.rule)==null?void 0:p.type)===u.CFRuleType.highlightCell?e.rule:void 0,i=[{label:n.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:n.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:n.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:n.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[d,S]=V.useState(()=>{const o=i[0].value,s=a==null?void 0:a.type;if(!a)return o;switch(s){case u.CFRuleType.highlightCell:switch(a.subType){case u.CFSubRuleType.average:return[u.CFNumberOperator.greaterThan,u.CFNumberOperator.greaterThanOrEqual].includes(a.operator)?"greaterThanAverage":[u.CFNumberOperator.lessThan,u.CFNumberOperator.lessThanOrEqual].includes(a.operator)?"lessThanAverage":o;case u.CFSubRuleType.rank:return a.isBottom?"isBottom":"isNotBottom"}}return o}),[h,C]=V.useState(()=>{const s=a==null?void 0:a.type;if(!a)return 10;switch(s){case u.CFRuleType.highlightCell:switch(a.subType){case u.CFSubRuleType.rank:return a.value||10}}return 10}),[m,b]=V.useState(()=>{const s=a==null?void 0:a.type;if(!a)return!1;switch(s){case u.CFRuleType.highlightCell:switch(a.subType){case u.CFSubRuleType.rank:return a.isPercent||!1}}return!1}),[E,I]=V.useState({}),_=o=>{const{type:s,isPercent:f,value:y,style:l}=o;if(s==="isNotBottom")return{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.rank,isPercent:f,isBottom:!1,value:y,style:l};if(s==="isBottom")return{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.rank,isPercent:f,isBottom:!0,value:y,style:l};if(s==="greaterThanAverage")return{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.average,operator:u.CFNumberOperator.greaterThan,style:l};if(s==="lessThanAverage")return{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.average,operator:u.CFNumberOperator.lessThan,style:l}};V.useEffect(()=>r.intercept(r.getInterceptPoints().submit,{handler(){return _({type:d,isPercent:m,value:h,style:E})}}),[d,m,h,E,r]);const T=o=>{t(_(o))};return R.jsxs("div",{children:[R.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),R.jsx(J.Select,{className:"univer-mt-3 univer-w-full",value:d,options:i,onChange:o=>{S(o),T({type:o,isPercent:m,value:h,style:E})}}),["isNotBottom","isBottom"].includes(d)&&R.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[R.jsx(J.InputNumber,{min:1,max:1e3,value:h,onChange:o=>{const s=o||0;C(s),T({type:d,isPercent:m,value:s,style:E})}}),R.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[R.jsx(J.Checkbox,{checked:m,onChange:o=>{b(!!o),T({type:d,isPercent:!!o,value:h,style:E})}}),n.t("sheet.cf.valueType.percent")]})]}),R.jsx("div",{className:Fe,children:R.jsx(Ne,{rule:_({type:d,isPercent:m,value:h,style:E})})}),R.jsx(qt,{style:a==null?void 0:a.style,className:"univer-mt-3",onChange:o=>{I(o),T({type:d,isPercent:m,value:h,style:o})}})]})},jn=w.createInterceptorKey("beforeSubmit"),An=w.createInterceptorKey("submit"),br=e=>e.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getUnitId(),Sr=e=>{var t;return(t=e.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId()},Hn=e=>{var c,g,P;const t=$.useDependency(w.LocaleService),r=$.useDependency(w.ICommandService),n=$.useDependency(w.IUniverInstanceService),a=$.useDependency(u.ConditionalFormattingRuleModel),i=$.useDependency(q.SheetsSelectionsService),d=br(n),S=Sr(n),[h,C]=V.useState(void 0),m=V.useRef((g=(c=e.rule)==null?void 0:c.ranges)!=null?g:[]),b=V.useMemo(()=>{var U,z,O;let M=(U=e.rule)==null?void 0:U.ranges;return M!=null&&M.length||(M=(O=(z=i.getCurrentSelections())==null?void 0:z.map(L=>L.range))!=null?O:[]),m.current=M,M!=null&&M.length?M.map(L=>{const W=Lt.serializeRange(L);return W==="NaN"?"":W}).filter(L=>!!L).join(","):""},[e.rule]),E=[{label:t.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:t.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:t.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:t.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:t.t("sheet.cf.ruleType.formula"),value:"5"},{label:t.t("sheet.cf.ruleType.iconSet"),value:"6"}],[I,_]=V.useState(()=>{var z,O;const M=(z=e.rule)==null?void 0:z.rule.type,U=E[0].value;if(!M)return U;switch(M){case u.CFRuleType.highlightCell:{switch((O=e.rule)==null?void 0:O.rule.subType){case u.CFSubRuleType.number:case u.CFSubRuleType.text:case u.CFSubRuleType.duplicateValues:case u.CFSubRuleType.uniqueValues:case u.CFSubRuleType.timePeriod:return"1";case u.CFSubRuleType.average:case u.CFSubRuleType.rank:return"2";case u.CFSubRuleType.formula:return"5"}break}case u.CFRuleType.dataBar:return"3";case u.CFRuleType.colorScale:return"4";case u.CFRuleType.iconSet:return"6"}return U}),T=V.useRef(void 0),p=V.useMemo(()=>new w.InterceptorManager({beforeSubmit:jn,submit:An}),[]),o=V.useMemo(()=>{switch(I){case"1":return gr;case"2":return kn;case"3":return Dn;case"4":return xn;case"5":return Pn;case"6":return zn;default:return gr}},[I]);V.useEffect(()=>{const M=r.onCommandExecuted(U=>{if(U.id===q.RemoveSheetMutation.id){const z=U.params;z.subUnitId===S&&z.unitId===d&&e.onCancel()}U.id===q.SetWorksheetActiveOperation.id&&e.onCancel()});return()=>M.dispose()},[]);const s=M=>{T.current=M},f=M=>{const U=M.split(",").filter(z=>!!z).map(Lt.deserializeRangeWithSheet).map(z=>z.range);m.current=U},y=()=>{if(h)return;const U=(()=>{const O=n.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!O)throw new Error("No active sheet found");return m.current.map(F=>q.setEndForRange(F,O.getRowCount(),O.getColumnCount())).filter(F=>!(Number.isNaN(F.startRow)||Number.isNaN(F.startColumn)))})();if(p.fetchThroughInterceptors(p.getInterceptPoints().beforeSubmit)(!0,null)){const O=p.fetchThroughInterceptors(p.getInterceptPoints().submit)(null,null);if(O){const L=br(n),W=Sr(n);if(!L||!W)throw new Error("No active sheet found");let F={};e.rule&&e.rule.cfId?(F={...e.rule,ranges:U,rule:O},r.executeCommand(u.SetCfCommand.id,{unitId:L,subUnitId:W,rule:F}),e.onCancel()):(F={cfId:a.createCfId(L,W),ranges:U,rule:O,stopIfTrue:!1},r.executeCommand(u.AddCfCommand.id,{unitId:L,subUnitId:W,rule:F}),e.onCancel())}}},l=()=>{e.onCancel()},v=(M,U)=>{M?U.length<1?C(t.t("sheet.cf.errorMessage.rangeError")):C(void 0):C(t.t("sheet.cf.errorMessage.rangeError"))};return R.jsxs("div",{children:[R.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:t.t("sheet.cf.panel.range")}),R.jsxs("div",{className:"univer-mt-4",children:[R.jsx(He.RangeSelector,{unitId:d,subUnitId:S,initialValue:b,onChange:(M,U)=>f(U),onVerify:v}),h&&R.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:h})]}),R.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:t.t("sheet.cf.panel.styleType")}),R.jsx(J.Select,{className:"univer-mt-4 univer-w-full",value:I,options:E,onChange:M=>_(M)}),R.jsx(o,{interceptorManager:p,rule:(P=e.rule)==null?void 0:P.rule,onChange:s}),R.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[R.jsx(J.Button,{onClick:l,children:t.t("sheet.cf.panel.cancel")}),R.jsx(J.Button,{className:"univer-ml-3",variant:"primary",onClick:y,children:t.t("sheet.cf.panel.submit")})]})]})};function Wn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Cr(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}),r}var Yt={exports:{}},Ge={},qe={exports:{}},Bn=qe.exports,Tr;function Xt(){return Tr||(Tr=1,function(e,t){(function(r,n){n(t)})(Bn,function(r){function n(H){return function(ie,x,D,N,k,B,A){return H(ie,x,A)}}function a(H){return function(ie,x,D,N){if(!ie||!x||typeof ie!="object"||typeof x!="object")return H(ie,x,D,N);var k=N.get(ie),B=N.get(x);if(k&&B)return k===x&&B===ie;N.set(ie,x),N.set(x,ie);var A=H(ie,x,D,N);return N.delete(ie),N.delete(x),A}}function i(H,K){var ie={};for(var x in H)ie[x]=H[x];for(var x in K)ie[x]=K[x];return ie}function d(H){return H.constructor===Object||H.constructor==null}function S(H){return typeof H.then=="function"}function h(H,K){return H===K||H!==H&&K!==K}var C="[object Arguments]",m="[object Boolean]",b="[object Date]",E="[object RegExp]",I="[object Map]",_="[object Number]",T="[object Object]",p="[object Set]",o="[object String]",s=Object.prototype.toString;function f(H){var K=H.areArraysEqual,ie=H.areDatesEqual,x=H.areMapsEqual,D=H.areObjectsEqual,N=H.areRegExpsEqual,k=H.areSetsEqual,B=H.createIsNestedEqual,A=B(Z);function Z(G,ee,ue){if(G===ee)return!0;if(!G||!ee||typeof G!="object"||typeof ee!="object")return G!==G&&ee!==ee;if(d(G)&&d(ee))return D(G,ee,A,ue);var De=Array.isArray(G),me=Array.isArray(ee);if(De||me)return De===me&&K(G,ee,A,ue);var he=s.call(G);return he!==s.call(ee)?!1:he===b?ie(G,ee,A,ue):he===E?N(G,ee,A,ue):he===I?x(G,ee,A,ue):he===p?k(G,ee,A,ue):he===T||he===C?S(G)||S(ee)?!1:D(G,ee,A,ue):he===m||he===_||he===o?h(G.valueOf(),ee.valueOf()):!1}return Z}function y(H,K,ie,x){var D=H.length;if(K.length!==D)return!1;for(;D-- >0;)if(!ie(H[D],K[D],D,D,H,K,x))return!1;return!0}var l=a(y);function v(H,K){return h(H.valueOf(),K.valueOf())}function c(H,K,ie,x){var D=H.size===K.size;if(!D)return!1;if(!H.size)return!0;var N={},k=0;return H.forEach(function(B,A){if(D){var Z=!1,G=0;K.forEach(function(ee,ue){!Z&&!N[G]&&(Z=ie(A,ue,k,G,H,K,x)&&ie(B,ee,A,ue,H,K,x))&&(N[G]=!0),G++}),k++,D=Z}}),D}var g=a(c),P="_owner",M=Object.prototype.hasOwnProperty;function U(H,K,ie,x){var D=Object.keys(H),N=D.length;if(Object.keys(K).length!==N)return!1;for(var k;N-- >0;){if(k=D[N],k===P){var B=!!H.$$typeof,A=!!K.$$typeof;if((B||A)&&B!==A)return!1}if(!M.call(K,k)||!ie(H[k],K[k],k,k,H,K,x))return!1}return!0}var z=a(U);function O(H,K){return H.source===K.source&&H.flags===K.flags}function L(H,K,ie,x){var D=H.size===K.size;if(!D)return!1;if(!H.size)return!0;var N={};return H.forEach(function(k,B){if(D){var A=!1,Z=0;K.forEach(function(G,ee){!A&&!N[Z]&&(A=ie(k,G,B,ee,H,K,x))&&(N[Z]=!0),Z++}),D=A}}),D}var W=a(L),F=Object.freeze({areArraysEqual:y,areDatesEqual:v,areMapsEqual:c,areObjectsEqual:U,areRegExpsEqual:O,areSetsEqual:L,createIsNestedEqual:n}),X=Object.freeze({areArraysEqual:l,areDatesEqual:v,areMapsEqual:g,areObjectsEqual:z,areRegExpsEqual:O,areSetsEqual:W,createIsNestedEqual:n}),ae=f(F);function ne(H,K){return ae(H,K,void 0)}var se=f(i(F,{createIsNestedEqual:function(){return h}}));function j(H,K){return se(H,K,void 0)}var Q=f(X);function te(H,K){return Q(H,K,new WeakMap)}var oe=f(i(X,{createIsNestedEqual:function(){return h}}));function ce(H,K){return oe(H,K,new WeakMap)}function pe(H){return f(i(F,H(F)))}function be(H){var K=f(i(X,H(X)));return function(ie,x,D){return D===void 0&&(D=new WeakMap),K(ie,x,D)}}r.circularDeepEqual=te,r.circularShallowEqual=ce,r.createCustomCircularEqual=be,r.createCustomEqual=pe,r.deepEqual=ne,r.sameValueZeroEqual=h,r.shallowEqual=j,Object.defineProperty(r,"__esModule",{value:!0})})}(qe,qe.exports)),qe.exports}var mt={exports:{}},wr;function Kt(){if(wr)return mt.exports;wr=1;function e(r){var n,a,i="";if(typeof r=="string"||typeof r=="number")i+=r;else if(typeof r=="object")if(Array.isArray(r)){var d=r.length;for(n=0;n<d;n++)r[n]&&(a=e(r[n]))&&(i&&(i+=" "),i+=a)}else for(a in r)r[a]&&(i&&(i+=" "),i+=a);return i}function t(){for(var r,n,a=0,i="",d=arguments.length;a<d;a++)(r=arguments[a])&&(n=e(r))&&(i&&(i+=" "),i+=n);return i}return mt.exports=t,mt.exports.clsx=t,mt.exports}var re={},Zt,_r;function Fn(){return _r||(_r=1,Zt=function(t,r,n){return t===r?!0:t.className===r.className&&n(t.style,r.style)&&t.width===r.width&&t.autoSize===r.autoSize&&t.cols===r.cols&&t.draggableCancel===r.draggableCancel&&t.draggableHandle===r.draggableHandle&&n(t.verticalCompact,r.verticalCompact)&&n(t.compactType,r.compactType)&&n(t.layout,r.layout)&&n(t.margin,r.margin)&&n(t.containerPadding,r.containerPadding)&&t.rowHeight===r.rowHeight&&t.maxRows===r.maxRows&&t.isBounded===r.isBounded&&t.isDraggable===r.isDraggable&&t.isResizable===r.isResizable&&t.allowOverlap===r.allowOverlap&&t.preventCollision===r.preventCollision&&t.useCSSTransforms===r.useCSSTransforms&&t.transformScale===r.transformScale&&t.isDroppable===r.isDroppable&&n(t.resizeHandles,r.resizeHandles)&&n(t.resizeHandle,r.resizeHandle)&&t.onLayoutChange===r.onLayoutChange&&t.onDragStart===r.onDragStart&&t.onDrag===r.onDrag&&t.onDragStop===r.onDragStop&&t.onResizeStart===r.onResizeStart&&t.onResize===r.onResize&&t.onResizeStop===r.onResizeStop&&t.onDrop===r.onDrop&&n(t.droppingItem,r.droppingItem)&&n(t.innerRef,r.innerRef)}),Zt}var Ir;function Ve(){if(Ir)return re;Ir=1,Object.defineProperty(re,"__esModule",{value:!0}),re.bottom=n,re.childrenEqual=h,re.cloneLayout=a,re.cloneLayoutItem=S,re.collides=m,re.compact=b,re.compactItem=_,re.compactType=H,re.correctBounds=T,re.fastPositionEqual=C,re.fastRGLPropsEqual=void 0,re.getAllCollisions=s,re.getFirstCollision=o,re.getLayoutItem=p,re.getStatics=f,re.modifyLayout=i,re.moveElement=y,re.moveElementAwayFromCollision=l,re.noop=void 0,re.perc=v,re.resizeItemInDirection=se,re.setTopLeft=Q,re.setTransform=j,re.sortLayoutItems=te,re.sortLayoutItemsByColRow=ce,re.sortLayoutItemsByRowCol=oe,re.synchronizeLayoutWithChildren=pe,re.validateLayout=be,re.withLayoutItem=d;var e=Xt(),t=r(V);function r(x){return x&&x.__esModule?x:{default:x}}function n(x){let D=0,N;for(let k=0,B=x.length;k<B;k++)N=x[k].y+x[k].h,N>D&&(D=N);return D}function a(x){const D=Array(x.length);for(let N=0,k=x.length;N<k;N++)D[N]=S(x[N]);return D}function i(x,D){const N=Array(x.length);for(let k=0,B=x.length;k<B;k++)D.i===x[k].i?N[k]=D:N[k]=x[k];return N}function d(x,D,N){let k=p(x,D);return k?(k=N(S(k)),x=i(x,k),[x,k]):[x,null]}function S(x){return{w:x.w,h:x.h,x:x.x,y:x.y,i:x.i,minW:x.minW,maxW:x.maxW,minH:x.minH,maxH:x.maxH,moved:!!x.moved,static:!!x.static,isDraggable:x.isDraggable,isResizable:x.isResizable,resizeHandles:x.resizeHandles,isBounded:x.isBounded}}function h(x,D){return(0,e.deepEqual)(t.default.Children.map(x,N=>N==null?void 0:N.key),t.default.Children.map(D,N=>N==null?void 0:N.key))&&(0,e.deepEqual)(t.default.Children.map(x,N=>N==null?void 0:N.props["data-grid"]),t.default.Children.map(D,N=>N==null?void 0:N.props["data-grid"]))}re.fastRGLPropsEqual=Fn();function C(x,D){return x.left===D.left&&x.top===D.top&&x.width===D.width&&x.height===D.height}function m(x,D){return!(x.i===D.i||x.x+x.w<=D.x||x.x>=D.x+D.w||x.y+x.h<=D.y||x.y>=D.y+D.h)}function b(x,D,N,k){const B=f(x),A=te(x,D),Z=Array(x.length);for(let G=0,ee=A.length;G<ee;G++){let ue=S(A[G]);ue.static||(ue=_(B,ue,D,N,A,k),B.push(ue)),Z[x.indexOf(A[G])]=ue,ue.moved=!1}return Z}const E={x:"w",y:"h"};function I(x,D,N,k){const B=E[k];D[k]+=1;const A=x.map(Z=>Z.i).indexOf(D.i);for(let Z=A+1;Z<x.length;Z++){const G=x[Z];if(!G.static){if(G.y>D.y+D.h)break;m(D,G)&&I(x,G,N+D[B],k)}}D[k]=N}function _(x,D,N,k,B,A){const Z=N==="vertical",G=N==="horizontal";if(Z)for(D.y=Math.min(n(x),D.y);D.y>0&&!o(x,D);)D.y--;else if(G)for(;D.x>0&&!o(x,D);)D.x--;let ee;for(;(ee=o(x,D))&&!(N===null&&A);)if(G?I(B,D,ee.x+ee.w,"x"):I(B,D,ee.y+ee.h,"y"),G&&D.x+D.w>k)for(D.x=k-D.w,D.y++;D.x>0&&!o(x,D);)D.x--;return D.y=Math.max(D.y,0),D.x=Math.max(D.x,0),D}function T(x,D){const N=f(x);for(let k=0,B=x.length;k<B;k++){const A=x[k];if(A.x+A.w>D.cols&&(A.x=D.cols-A.w),A.x<0&&(A.x=0,A.w=D.cols),!A.static)N.push(A);else for(;o(N,A);)A.y++}return x}function p(x,D){for(let N=0,k=x.length;N<k;N++)if(x[N].i===D)return x[N]}function o(x,D){for(let N=0,k=x.length;N<k;N++)if(m(x[N],D))return x[N]}function s(x,D){return x.filter(N=>m(N,D))}function f(x){return x.filter(D=>D.static)}function y(x,D,N,k,B,A,Z,G,ee){if(D.static&&D.isDraggable!==!0||D.y===k&&D.x===N)return x;`${D.i}${String(N)}${String(k)}${D.x}${D.y}`;const ue=D.x,De=D.y;typeof N=="number"&&(D.x=N),typeof k=="number"&&(D.y=k),D.moved=!0;let me=te(x,Z);(Z==="vertical"&&typeof k=="number"?De>=k:Z==="horizontal"&&typeof N=="number"?ue>=N:!1)&&(me=me.reverse());const Ae=s(me,D),Nt=Ae.length>0;if(Nt&&ee)return a(x);if(Nt&&A)return`${D.i}`,D.x=ue,D.y=De,D.moved=!1,x;for(let ur=0,ci=Ae.length;ur<ci;ur++){const Pe=Ae[ur];`${D.i}${D.x}${D.y}${Pe.i}${Pe.x}${Pe.y}`,!Pe.moved&&(Pe.static?x=l(x,Pe,D,B,Z):x=l(x,D,Pe,B,Z))}return x}function l(x,D,N,k,B,A){const Z=B==="horizontal",G=B==="vertical",ee=D.static;if(k){k=!1;const me={x:Z?Math.max(D.x-N.w,0):N.x,y:G?Math.max(D.y-N.h,0):N.y,w:N.w,h:N.h,i:"-1"},he=o(x,me),Ae=he&&he.y+he.h>D.y,Nt=he&&D.x+D.w>he.x;if(he){if(Ae&&G)return y(x,N,void 0,D.y+1,k,ee,B);if(Ae&&B==null)return D.y=N.y,N.y=N.y+N.h,x;if(Nt&&Z)return y(x,D,N.x,void 0,k,ee,B)}else return`${N.i}${me.x}${me.y}`,y(x,N,Z?me.x:void 0,G?me.y:void 0,k,ee,B)}const ue=Z?N.x+1:void 0,De=G?N.y+1:void 0;return ue==null&&De==null?x:y(x,N,Z?N.x+1:void 0,G?N.y+1:void 0,k,ee,B)}function v(x){return x*100+"%"}const c=(x,D,N,k)=>x+N>k?D:N,g=(x,D,N)=>x<0?D:N,P=x=>Math.max(0,x),M=x=>Math.max(0,x),U=(x,D,N)=>{let{left:k,height:B,width:A}=D;const Z=x.top-(B-x.height);return{left:k,width:A,height:g(Z,x.height,B),top:M(Z)}},z=(x,D,N)=>{let{top:k,left:B,height:A,width:Z}=D;return{top:k,height:A,width:c(x.left,x.width,Z,N),left:P(B)}},O=(x,D,N)=>{let{top:k,height:B,width:A}=D;const Z=x.left-(A-x.width);return{height:B,width:Z<0?x.width:c(x.left,x.width,A,N),top:M(k),left:P(Z)}},L=(x,D,N)=>{let{top:k,left:B,height:A,width:Z}=D;return{width:Z,left:B,height:g(k,x.height,A),top:M(k)}},ne={n:U,ne:function(){return U(arguments.length<=0?void 0:arguments[0],z(...arguments))},e:z,se:function(){return L(arguments.length<=0?void 0:arguments[0],z(...arguments))},s:L,sw:function(){return L(arguments.length<=0?void 0:arguments[0],O(...arguments))},w:O,nw:function(){return U(arguments.length<=0?void 0:arguments[0],O(...arguments))}};function se(x,D,N,k){const B=ne[x];return B?B(D,{...D,...N},k):N}function j(x){let{top:D,left:N,width:k,height:B}=x;const A=`translate(${N}px,${D}px)`;return{transform:A,WebkitTransform:A,MozTransform:A,msTransform:A,OTransform:A,width:`${k}px`,height:`${B}px`,position:"absolute"}}function Q(x){let{top:D,left:N,width:k,height:B}=x;return{top:`${D}px`,left:`${N}px`,width:`${k}px`,height:`${B}px`,position:"absolute"}}function te(x,D){return D==="horizontal"?ce(x):D==="vertical"?oe(x):x}function oe(x){return x.slice(0).sort(function(D,N){return D.y>N.y||D.y===N.y&&D.x>N.x?1:D.y===N.y&&D.x===N.x?0:-1})}function ce(x){return x.slice(0).sort(function(D,N){return D.x>N.x||D.x===N.x&&D.y>N.y?1:-1})}function pe(x,D,N,k,B){x=x||[];const A=[];t.default.Children.forEach(D,G=>{if((G==null?void 0:G.key)==null)return;const ee=p(x,String(G.key)),ue=G.props["data-grid"];ee&&ue==null?A.push(S(ee)):ue?A.push(S({...ue,i:G.key})):A.push(S({w:1,h:1,x:0,y:n(A),i:String(G.key)}))});const Z=T(A,{cols:N});return B?Z:b(Z,k,N)}function be(x){let D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const N=["x","y","w","h"];if(!Array.isArray(x))throw new Error(D+" must be an array!");for(let k=0,B=x.length;k<B;k++){const A=x[k];for(let Z=0;Z<N.length;Z++){const G=N[Z],ee=A[G];if(typeof ee!="number"||Number.isNaN(ee))throw new Error(`ReactGridLayout: ${D}[${k}].${G} must be a number! Received: ${ee} (${typeof ee})`)}if(typeof A.i<"u"&&typeof A.i!="string")throw new Error(`ReactGridLayout: ${D}[${k}].i must be a string! Received: ${A.i} (${typeof A.i})`)}}function H(x){const{verticalCompact:D,compactType:N}=x||{};return D===!1?null:N}function K(){}const ie=()=>{};return re.noop=ie,re}var Ce={},Rr;function Jt(){if(Rr)return Ce;Rr=1,Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.calcGridColWidth=e,Ce.calcGridItemPosition=r,Ce.calcGridItemWHPx=t,Ce.calcWH=a,Ce.calcXY=n,Ce.clamp=i;function e(d){const{margin:S,containerPadding:h,containerWidth:C,cols:m}=d;return(C-S[0]*(m-1)-h[0]*2)/m}function t(d,S,h){return Number.isFinite(d)?Math.round(S*d+Math.max(0,d-1)*h):d}function r(d,S,h,C,m,b){const{margin:E,containerPadding:I,rowHeight:_}=d,T=e(d),p={};return b&&b.resizing?(p.width=Math.round(b.resizing.width),p.height=Math.round(b.resizing.height)):(p.width=t(C,T,E[0]),p.height=t(m,_,E[1])),b&&b.dragging?(p.top=Math.round(b.dragging.top),p.left=Math.round(b.dragging.left)):b&&b.resizing&&typeof b.resizing.top=="number"&&typeof b.resizing.left=="number"?(p.top=Math.round(b.resizing.top),p.left=Math.round(b.resizing.left)):(p.top=Math.round((_+E[1])*h+I[1]),p.left=Math.round((T+E[0])*S+I[0])),p}function n(d,S,h,C,m){const{margin:b,containerPadding:E,cols:I,rowHeight:_,maxRows:T}=d,p=e(d);let o=Math.round((h-E[0])/(p+b[0])),s=Math.round((S-E[1])/(_+b[1]));return o=i(o,0,I-C),s=i(s,0,T-m),{x:o,y:s}}function a(d,S,h,C,m,b){const{margin:E,maxRows:I,cols:_,rowHeight:T}=d,p=e(d);let o=Math.round((S+E[0])/(p+E[0])),s=Math.round((h+E[1])/(T+E[1])),f=i(o,0,_-C),y=i(s,0,I-m);return["sw","w","nw"].indexOf(b)!==-1&&(f=i(o,0,_)),["nw","n","ne"].indexOf(b)!==-1&&(y=i(s,0,I)),{w:f,h:y}}function i(d,S,h){return Math.max(Math.min(d,h),S)}return Ce}var Ye={},Qt={exports:{}},$t,Er;function Gn(){if(Er)return $t;Er=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return $t=e,$t}var er,Or;function qn(){if(Or)return er;Or=1;var e=Gn();function t(){}function r(){}return r.resetWarningCache=t,er=function(){function n(d,S,h,C,m,b){if(b!==e){var E=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw E.name="Invariant Violation",E}}n.isRequired=n;function a(){return n}var i={array:n,bigint:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:a,element:n,elementType:n,instanceOf:a,node:n,objectOf:a,oneOf:a,oneOfType:a,shape:a,exact:a,checkPropTypes:r,resetWarningCache:t};return i.PropTypes=i,i},er}var xr;function we(){return xr||(xr=1,Qt.exports=qn()()),Qt.exports}var Xe={exports:{}},tr={};function Dr(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(r=Dr(e[t]))&&(n&&(n+=" "),n+=r);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function Pr(){for(var e,t,r=0,n="";r<arguments.length;)(e=arguments[r++])&&(t=Dr(e))&&(n&&(n+=" "),n+=t);return n}const Yn=Cr(Object.freeze(Object.defineProperty({__proto__:null,clsx:Pr,default:Pr},Symbol.toStringTag,{value:"Module"})));var fe={},_e={},Mr;function yt(){if(Mr)return _e;Mr=1,Object.defineProperty(_e,"__esModule",{value:!0}),_e.dontSetMe=a,_e.findInArray=e,_e.int=n,_e.isFunction=t,_e.isNum=r;function e(i,d){for(let S=0,h=i.length;S<h;S++)if(d.apply(d,[i[S],S,i]))return i[S]}function t(i){return typeof i=="function"||Object.prototype.toString.call(i)==="[object Function]"}function r(i){return typeof i=="number"&&!isNaN(i)}function n(i){return parseInt(i,10)}function a(i,d,S){if(i[d])return new Error("Invalid prop ".concat(d," passed to ").concat(S," - do not set this, set it on the child."))}return _e}var Ie={},Nr;function Xn(){if(Nr)return Ie;Nr=1,Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.browserPrefixToKey=r,Ie.browserPrefixToStyle=n,Ie.default=void 0,Ie.getPrefix=t;const e=["Moz","Webkit","O","ms"];function t(){var i;let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u")return"";const S=(i=window.document)===null||i===void 0||(i=i.documentElement)===null||i===void 0?void 0:i.style;if(!S||d in S)return"";for(let h=0;h<e.length;h++)if(r(d,e[h])in S)return e[h];return""}function r(i,d){return d?"".concat(d).concat(a(i)):i}function n(i,d){return d?"-".concat(d.toLowerCase(),"-").concat(i):i}function a(i){let d="",S=!0;for(let h=0;h<i.length;h++)S?(d+=i[h].toUpperCase(),S=!1):i[h]==="-"?S=!0:d+=i[h];return d}return Ie.default=t(),Ie}var Lr;function rr(){if(Lr)return fe;Lr=1,Object.defineProperty(fe,"__esModule",{value:!0}),fe.addClassName=l,fe.addEvent=S,fe.addUserSelectStyles=f,fe.createCSSTransform=_,fe.createSVGTransform=T,fe.getTouch=o,fe.getTouchIdentifier=s,fe.getTranslation=p,fe.innerHeight=b,fe.innerWidth=E,fe.matchesSelector=i,fe.matchesSelectorAndParentsTo=d,fe.offsetXYFromParent=I,fe.outerHeight=C,fe.outerWidth=m,fe.removeClassName=v,fe.removeEvent=h,fe.removeUserSelectStyles=y;var e=yt(),t=n(Xn());function r(c){if(typeof WeakMap!="function")return null;var g=new WeakMap,P=new WeakMap;return(r=function(M){return M?P:g})(c)}function n(c,g){if(c&&c.__esModule)return c;if(c===null||typeof c!="object"&&typeof c!="function")return{default:c};var P=r(g);if(P&&P.has(c))return P.get(c);var M={},U=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var z in c)if(z!=="default"&&Object.prototype.hasOwnProperty.call(c,z)){var O=U?Object.getOwnPropertyDescriptor(c,z):null;O&&(O.get||O.set)?Object.defineProperty(M,z,O):M[z]=c[z]}return M.default=c,P&&P.set(c,M),M}let a="";function i(c,g){return a||(a=(0,e.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(P){return(0,e.isFunction)(c[P])})),(0,e.isFunction)(c[a])?c[a](g):!1}function d(c,g,P){let M=c;do{if(i(M,g))return!0;if(M===P)return!1;M=M.parentNode}while(M);return!1}function S(c,g,P,M){if(!c)return;const U={capture:!0,...M};c.addEventListener?c.addEventListener(g,P,U):c.attachEvent?c.attachEvent("on"+g,P):c["on"+g]=P}function h(c,g,P,M){if(!c)return;const U={capture:!0,...M};c.removeEventListener?c.removeEventListener(g,P,U):c.detachEvent?c.detachEvent("on"+g,P):c["on"+g]=null}function C(c){let g=c.clientHeight;const P=c.ownerDocument.defaultView.getComputedStyle(c);return g+=(0,e.int)(P.borderTopWidth),g+=(0,e.int)(P.borderBottomWidth),g}function m(c){let g=c.clientWidth;const P=c.ownerDocument.defaultView.getComputedStyle(c);return g+=(0,e.int)(P.borderLeftWidth),g+=(0,e.int)(P.borderRightWidth),g}function b(c){let g=c.clientHeight;const P=c.ownerDocument.defaultView.getComputedStyle(c);return g-=(0,e.int)(P.paddingTop),g-=(0,e.int)(P.paddingBottom),g}function E(c){let g=c.clientWidth;const P=c.ownerDocument.defaultView.getComputedStyle(c);return g-=(0,e.int)(P.paddingLeft),g-=(0,e.int)(P.paddingRight),g}function I(c,g,P){const U=g===g.ownerDocument.body?{left:0,top:0}:g.getBoundingClientRect(),z=(c.clientX+g.scrollLeft-U.left)/P,O=(c.clientY+g.scrollTop-U.top)/P;return{x:z,y:O}}function _(c,g){const P=p(c,g,"px");return{[(0,t.browserPrefixToKey)("transform",t.default)]:P}}function T(c,g){return p(c,g,"")}function p(c,g,P){let{x:M,y:U}=c,z="translate(".concat(M).concat(P,",").concat(U).concat(P,")");if(g){const O="".concat(typeof g.x=="string"?g.x:g.x+P),L="".concat(typeof g.y=="string"?g.y:g.y+P);z="translate(".concat(O,", ").concat(L,")")+z}return z}function o(c,g){return c.targetTouches&&(0,e.findInArray)(c.targetTouches,P=>g===P.identifier)||c.changedTouches&&(0,e.findInArray)(c.changedTouches,P=>g===P.identifier)}function s(c){if(c.targetTouches&&c.targetTouches[0])return c.targetTouches[0].identifier;if(c.changedTouches&&c.changedTouches[0])return c.changedTouches[0].identifier}function f(c){if(!c)return;let g=c.getElementById("react-draggable-style-el");g||(g=c.createElement("style"),g.type="text/css",g.id="react-draggable-style-el",g.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
33
- `,g.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
34
- `,c.getElementsByTagName("head")[0].appendChild(g)),c.body&&l(c.body,"react-draggable-transparent-selection")}function y(c){if(c)try{if(c.body&&v(c.body,"react-draggable-transparent-selection"),c.selection)c.selection.empty();else{const g=(c.defaultView||window).getSelection();g&&g.type!=="Caret"&&g.removeAllRanges()}}catch{}}function l(c,g){c.classList?c.classList.add(g):c.className.match(new RegExp("(?:^|\\s)".concat(g,"(?!\\S)")))||(c.className+=" ".concat(g))}function v(c,g){c.classList?c.classList.remove(g):c.className=c.className.replace(new RegExp("(?:^|\\s)".concat(g,"(?!\\S)"),"g"),"")}return fe}var Se={},Vr;function Ur(){if(Vr)return Se;Vr=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.canDragX=a,Se.canDragY=i,Se.createCoreData=S,Se.createDraggableData=h,Se.getBoundPosition=r,Se.getControlPosition=d,Se.snapToGrid=n;var e=yt(),t=rr();function r(b,E,I){if(!b.props.bounds)return[E,I];let{bounds:_}=b.props;_=typeof _=="string"?_:C(_);const T=m(b);if(typeof _=="string"){const{ownerDocument:p}=T,o=p.defaultView;let s;if(_==="parent"?s=T.parentNode:s=p.querySelector(_),!(s instanceof o.HTMLElement))throw new Error('Bounds selector "'+_+'" could not find an element.');const f=s,y=o.getComputedStyle(T),l=o.getComputedStyle(f);_={left:-T.offsetLeft+(0,e.int)(l.paddingLeft)+(0,e.int)(y.marginLeft),top:-T.offsetTop+(0,e.int)(l.paddingTop)+(0,e.int)(y.marginTop),right:(0,t.innerWidth)(f)-(0,t.outerWidth)(T)-T.offsetLeft+(0,e.int)(l.paddingRight)-(0,e.int)(y.marginRight),bottom:(0,t.innerHeight)(f)-(0,t.outerHeight)(T)-T.offsetTop+(0,e.int)(l.paddingBottom)-(0,e.int)(y.marginBottom)}}return(0,e.isNum)(_.right)&&(E=Math.min(E,_.right)),(0,e.isNum)(_.bottom)&&(I=Math.min(I,_.bottom)),(0,e.isNum)(_.left)&&(E=Math.max(E,_.left)),(0,e.isNum)(_.top)&&(I=Math.max(I,_.top)),[E,I]}function n(b,E,I){const _=Math.round(E/b[0])*b[0],T=Math.round(I/b[1])*b[1];return[_,T]}function a(b){return b.props.axis==="both"||b.props.axis==="x"}function i(b){return b.props.axis==="both"||b.props.axis==="y"}function d(b,E,I){const _=typeof E=="number"?(0,t.getTouch)(b,E):null;if(typeof E=="number"&&!_)return null;const T=m(I),p=I.props.offsetParent||T.offsetParent||T.ownerDocument.body;return(0,t.offsetXYFromParent)(_||b,p,I.props.scale)}function S(b,E,I){const _=!(0,e.isNum)(b.lastX),T=m(b);return _?{node:T,deltaX:0,deltaY:0,lastX:E,lastY:I,x:E,y:I}:{node:T,deltaX:E-b.lastX,deltaY:I-b.lastY,lastX:b.lastX,lastY:b.lastY,x:E,y:I}}function h(b,E){const I=b.props.scale;return{node:E.node,x:b.state.x+E.deltaX/I,y:b.state.y+E.deltaY/I,deltaX:E.deltaX/I,deltaY:E.deltaY/I,lastX:b.state.x,lastY:b.state.y}}function C(b){return{left:b.left,top:b.top,right:b.right,bottom:b.bottom}}function m(b){const E=b.findDOMNode();if(!E)throw new Error("<DraggableCore>: Unmounted during event!");return E}return Se}var Ke={},bt={},zr;function kr(){if(zr)return bt;zr=1,Object.defineProperty(bt,"__esModule",{value:!0}),bt.default=e;function e(){}return bt}var jr;function Kn(){if(jr)return Ke;jr=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.default=void 0;var e=C(V),t=S(we()),r=S(Vt),n=rr(),a=Ur(),i=yt(),d=S(kr());function S(p){return p&&p.__esModule?p:{default:p}}function h(p){if(typeof WeakMap!="function")return null;var o=new WeakMap,s=new WeakMap;return(h=function(f){return f?s:o})(p)}function C(p,o){if(p&&p.__esModule)return p;if(p===null||typeof p!="object"&&typeof p!="function")return{default:p};var s=h(o);if(s&&s.has(p))return s.get(p);var f={},y=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in p)if(l!=="default"&&Object.prototype.hasOwnProperty.call(p,l)){var v=y?Object.getOwnPropertyDescriptor(p,l):null;v&&(v.get||v.set)?Object.defineProperty(f,l,v):f[l]=p[l]}return f.default=p,s&&s.set(p,f),f}function m(p,o,s){return o=b(o),o in p?Object.defineProperty(p,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):p[o]=s,p}function b(p){var o=E(p,"string");return typeof o=="symbol"?o:String(o)}function E(p,o){if(typeof p!="object"||p===null)return p;var s=p[Symbol.toPrimitive];if(s!==void 0){var f=s.call(p,o);if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(p)}const I={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}};let _=I.mouse,T=class extends e.Component{constructor(){super(...arguments),m(this,"dragging",!1),m(this,"lastX",NaN),m(this,"lastY",NaN),m(this,"touchIdentifier",null),m(this,"mounted",!1),m(this,"handleDragStart",o=>{if(this.props.onMouseDown(o),!this.props.allowAnyClick&&typeof o.button=="number"&&o.button!==0)return!1;const s=this.findDOMNode();if(!s||!s.ownerDocument||!s.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:f}=s;if(this.props.disabled||!(o.target instanceof f.defaultView.Node)||this.props.handle&&!(0,n.matchesSelectorAndParentsTo)(o.target,this.props.handle,s)||this.props.cancel&&(0,n.matchesSelectorAndParentsTo)(o.target,this.props.cancel,s))return;o.type==="touchstart"&&o.preventDefault();const y=(0,n.getTouchIdentifier)(o);this.touchIdentifier=y;const l=(0,a.getControlPosition)(o,y,this);if(l==null)return;const{x:v,y:c}=l,g=(0,a.createCoreData)(this,v,c);(0,d.default)("DraggableCore: handleDragStart: %j",g),(0,d.default)("calling",this.props.onStart),!(this.props.onStart(o,g)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,n.addUserSelectStyles)(f),this.dragging=!0,this.lastX=v,this.lastY=c,(0,n.addEvent)(f,_.move,this.handleDrag),(0,n.addEvent)(f,_.stop,this.handleDragStop))}),m(this,"handleDrag",o=>{const s=(0,a.getControlPosition)(o,this.touchIdentifier,this);if(s==null)return;let{x:f,y}=s;if(Array.isArray(this.props.grid)){let c=f-this.lastX,g=y-this.lastY;if([c,g]=(0,a.snapToGrid)(this.props.grid,c,g),!c&&!g)return;f=this.lastX+c,y=this.lastY+g}const l=(0,a.createCoreData)(this,f,y);if((0,d.default)("DraggableCore: handleDrag: %j",l),this.props.onDrag(o,l)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const g=document.createEvent("MouseEvents");g.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(g)}return}this.lastX=f,this.lastY=y}),m(this,"handleDragStop",o=>{if(!this.dragging)return;const s=(0,a.getControlPosition)(o,this.touchIdentifier,this);if(s==null)return;let{x:f,y}=s;if(Array.isArray(this.props.grid)){let g=f-this.lastX||0,P=y-this.lastY||0;[g,P]=(0,a.snapToGrid)(this.props.grid,g,P),f=this.lastX+g,y=this.lastY+P}const l=(0,a.createCoreData)(this,f,y);if(this.props.onStop(o,l)===!1||this.mounted===!1)return!1;const c=this.findDOMNode();c&&this.props.enableUserSelectHack&&(0,n.removeUserSelectStyles)(c.ownerDocument),(0,d.default)("DraggableCore: handleDragStop: %j",l),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,c&&((0,d.default)("DraggableCore: Removing handlers"),(0,n.removeEvent)(c.ownerDocument,_.move,this.handleDrag),(0,n.removeEvent)(c.ownerDocument,_.stop,this.handleDragStop))}),m(this,"onMouseDown",o=>(_=I.mouse,this.handleDragStart(o))),m(this,"onMouseUp",o=>(_=I.mouse,this.handleDragStop(o))),m(this,"onTouchStart",o=>(_=I.touch,this.handleDragStart(o))),m(this,"onTouchEnd",o=>(_=I.touch,this.handleDragStop(o)))}componentDidMount(){this.mounted=!0;const o=this.findDOMNode();o&&(0,n.addEvent)(o,I.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const o=this.findDOMNode();if(o){const{ownerDocument:s}=o;(0,n.removeEvent)(s,I.mouse.move,this.handleDrag),(0,n.removeEvent)(s,I.touch.move,this.handleDrag),(0,n.removeEvent)(s,I.mouse.stop,this.handleDragStop),(0,n.removeEvent)(s,I.touch.stop,this.handleDragStop),(0,n.removeEvent)(o,I.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,n.removeUserSelectStyles)(s)}}findDOMNode(){var o,s;return(o=this.props)!==null&&o!==void 0&&o.nodeRef?(s=this.props)===null||s===void 0||(s=s.nodeRef)===null||s===void 0?void 0:s.current:r.default.findDOMNode(this)}render(){return e.cloneElement(e.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};return Ke.default=T,m(T,"displayName","DraggableCore"),m(T,"propTypes",{allowAnyClick:t.default.bool,children:t.default.node.isRequired,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:function(p,o){if(p[o]&&p[o].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:t.default.arrayOf(t.default.number),handle:t.default.string,cancel:t.default.string,nodeRef:t.default.object,onStart:t.default.func,onDrag:t.default.func,onStop:t.default.func,onMouseDown:t.default.func,scale:t.default.number,className:i.dontSetMe,style:i.dontSetMe,transform:i.dontSetMe}),m(T,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),Ke}var Ar;function Zn(){return Ar||(Ar=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return h.default}}),e.default=void 0;var t=E(V),r=m(we()),n=m(Vt),a=m(Yn),i=rr(),d=Ur(),S=yt(),h=m(Kn()),C=m(kr());function m(s){return s&&s.__esModule?s:{default:s}}function b(s){if(typeof WeakMap!="function")return null;var f=new WeakMap,y=new WeakMap;return(b=function(l){return l?y:f})(s)}function E(s,f){if(s&&s.__esModule)return s;if(s===null||typeof s!="object"&&typeof s!="function")return{default:s};var y=b(f);if(y&&y.has(s))return y.get(s);var l={},v=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var c in s)if(c!=="default"&&Object.prototype.hasOwnProperty.call(s,c)){var g=v?Object.getOwnPropertyDescriptor(s,c):null;g&&(g.get||g.set)?Object.defineProperty(l,c,g):l[c]=s[c]}return l.default=s,y&&y.set(s,l),l}function I(){return I=Object.assign?Object.assign.bind():function(s){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var l in y)Object.prototype.hasOwnProperty.call(y,l)&&(s[l]=y[l])}return s},I.apply(this,arguments)}function _(s,f,y){return f=T(f),f in s?Object.defineProperty(s,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):s[f]=y,s}function T(s){var f=p(s,"string");return typeof f=="symbol"?f:String(f)}function p(s,f){if(typeof s!="object"||s===null)return s;var y=s[Symbol.toPrimitive];if(y!==void 0){var l=y.call(s,f);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(f==="string"?String:Number)(s)}class o extends t.Component{static getDerivedStateFromProps(f,y){let{position:l}=f,{prevPropsPosition:v}=y;return l&&(!v||l.x!==v.x||l.y!==v.y)?((0,C.default)("Draggable: getDerivedStateFromProps %j",{position:l,prevPropsPosition:v}),{x:l.x,y:l.y,prevPropsPosition:{...l}}):null}constructor(f){super(f),_(this,"onDragStart",(y,l)=>{if((0,C.default)("Draggable: onDragStart: %j",l),this.props.onStart(y,(0,d.createDraggableData)(this,l))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),_(this,"onDrag",(y,l)=>{if(!this.state.dragging)return!1;(0,C.default)("Draggable: onDrag: %j",l);const v=(0,d.createDraggableData)(this,l),c={x:v.x,y:v.y,slackX:0,slackY:0};if(this.props.bounds){const{x:P,y:M}=c;c.x+=this.state.slackX,c.y+=this.state.slackY;const[U,z]=(0,d.getBoundPosition)(this,c.x,c.y);c.x=U,c.y=z,c.slackX=this.state.slackX+(P-c.x),c.slackY=this.state.slackY+(M-c.y),v.x=c.x,v.y=c.y,v.deltaX=c.x-this.state.x,v.deltaY=c.y-this.state.y}if(this.props.onDrag(y,v)===!1)return!1;this.setState(c)}),_(this,"onDragStop",(y,l)=>{if(!this.state.dragging||this.props.onStop(y,(0,d.createDraggableData)(this,l))===!1)return!1;(0,C.default)("Draggable: onDragStop: %j",l);const c={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:P,y:M}=this.props.position;c.x=P,c.y=M}this.setState(c)}),this.state={dragging:!1,dragged:!1,x:f.position?f.position.x:f.defaultPosition.x,y:f.position?f.position.y:f.defaultPosition.y,prevPropsPosition:{...f.position},slackX:0,slackY:0,isElementSVG:!1},f.position&&!(f.onDrag||f.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var f,y;return(f=(y=this.props)===null||y===void 0||(y=y.nodeRef)===null||y===void 0?void 0:y.current)!==null&&f!==void 0?f:n.default.findDOMNode(this)}render(){const{axis:f,bounds:y,children:l,defaultPosition:v,defaultClassName:c,defaultClassNameDragging:g,defaultClassNameDragged:P,position:M,positionOffset:U,scale:z,...O}=this.props;let L={},W=null;const X=!!!M||this.state.dragging,ae=M||v,ne={x:(0,d.canDragX)(this)&&X?this.state.x:ae.x,y:(0,d.canDragY)(this)&&X?this.state.y:ae.y};this.state.isElementSVG?W=(0,i.createSVGTransform)(ne,U):L=(0,i.createCSSTransform)(ne,U);const se=(0,a.default)(l.props.className||"",c,{[g]:this.state.dragging,[P]:this.state.dragged});return t.createElement(h.default,I({},O,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(l),{className:se,style:{...l.props.style,...L},transform:W}))}}e.default=o,_(o,"displayName","Draggable"),_(o,"propTypes",{...h.default.propTypes,axis:r.default.oneOf(["both","x","y","none"]),bounds:r.default.oneOfType([r.default.shape({left:r.default.number,right:r.default.number,top:r.default.number,bottom:r.default.number}),r.default.string,r.default.oneOf([!1])]),defaultClassName:r.default.string,defaultClassNameDragging:r.default.string,defaultClassNameDragged:r.default.string,defaultPosition:r.default.shape({x:r.default.number,y:r.default.number}),positionOffset:r.default.shape({x:r.default.oneOfType([r.default.number,r.default.string]),y:r.default.oneOfType([r.default.number,r.default.string])}),position:r.default.shape({x:r.default.number,y:r.default.number}),className:S.dontSetMe,style:S.dontSetMe,transform:S.dontSetMe}),_(o,"defaultProps",{...h.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(tr)),tr}var Hr;function nr(){if(Hr)return Xe.exports;Hr=1;const{default:e,DraggableCore:t}=Zn();return Xe.exports=e,Xe.exports.default=e,Xe.exports.DraggableCore=t,Xe.exports}var Ze={exports:{}},Je={},St={},Wr;function Jn(){if(Wr)return St;Wr=1,St.__esModule=!0,St.cloneElement=S;var e=t(V);function t(h){return h&&h.__esModule?h:{default:h}}function r(h,C){var m=Object.keys(h);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(h);C&&(b=b.filter(function(E){return Object.getOwnPropertyDescriptor(h,E).enumerable})),m.push.apply(m,b)}return m}function n(h){for(var C=1;C<arguments.length;C++){var m=arguments[C]!=null?arguments[C]:{};C%2?r(Object(m),!0).forEach(function(b){a(h,b,m[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(m)):r(Object(m)).forEach(function(b){Object.defineProperty(h,b,Object.getOwnPropertyDescriptor(m,b))})}return h}function a(h,C,m){return C=i(C),C in h?Object.defineProperty(h,C,{value:m,enumerable:!0,configurable:!0,writable:!0}):h[C]=m,h}function i(h){var C=d(h,"string");return typeof C=="symbol"?C:String(C)}function d(h,C){if(typeof h!="object"||h===null)return h;var m=h[Symbol.toPrimitive];if(m!==void 0){var b=m.call(h,C);if(typeof b!="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return(C==="string"?String:Number)(h)}function S(h,C){return C.style&&h.props.style&&(C.style=n(n({},h.props.style),C.style)),C.className&&h.props.className&&(C.className=h.props.className+" "+C.className),e.default.cloneElement(h,C)}return St}var Qe={},Br;function Fr(){if(Br)return Qe;Br=1,Qe.__esModule=!0,Qe.resizableProps=void 0;var e=t(we());nr();function t(n){return n&&n.__esModule?n:{default:n}}var r={axis:e.default.oneOf(["both","x","y","none"]),className:e.default.string,children:e.default.element.isRequired,draggableOpts:e.default.shape({allowAnyClick:e.default.bool,cancel:e.default.string,children:e.default.node,disabled:e.default.bool,enableUserSelectHack:e.default.bool,offsetParent:e.default.node,grid:e.default.arrayOf(e.default.number),handle:e.default.string,nodeRef:e.default.object,onStart:e.default.func,onDrag:e.default.func,onStop:e.default.func,onMouseDown:e.default.func,scale:e.default.number}),height:function(){for(var a=arguments.length,i=new Array(a),d=0;d<a;d++)i[d]=arguments[d];var S=i[0];if(S.axis==="both"||S.axis==="y"){var h;return(h=e.default.number).isRequired.apply(h,i)}return e.default.number.apply(e.default,i)},handle:e.default.oneOfType([e.default.node,e.default.func]),handleSize:e.default.arrayOf(e.default.number),lockAspectRatio:e.default.bool,maxConstraints:e.default.arrayOf(e.default.number),minConstraints:e.default.arrayOf(e.default.number),onResizeStop:e.default.func,onResizeStart:e.default.func,onResize:e.default.func,resizeHandles:e.default.arrayOf(e.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),transformScale:e.default.number,width:function(){for(var a=arguments.length,i=new Array(a),d=0;d<a;d++)i[d]=arguments[d];var S=i[0];if(S.axis==="both"||S.axis==="x"){var h;return(h=e.default.number).isRequired.apply(h,i)}return e.default.number.apply(e.default,i)}};return Qe.resizableProps=r,Qe}var Gr;function qr(){if(Gr)return Je;Gr=1,Je.__esModule=!0,Je.default=void 0;var e=d(V),t=nr(),r=Jn(),n=Fr(),a=["children","className","draggableOpts","width","height","handle","handleSize","lockAspectRatio","axis","minConstraints","maxConstraints","onResize","onResizeStop","onResizeStart","resizeHandles","transformScale"];function i(o){if(typeof WeakMap!="function")return null;var s=new WeakMap,f=new WeakMap;return(i=function(l){return l?f:s})(o)}function d(o,s){if(o&&o.__esModule)return o;if(o===null||typeof o!="object"&&typeof o!="function")return{default:o};var f=i(s);if(f&&f.has(o))return f.get(o);var y={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var v in o)if(v!=="default"&&Object.prototype.hasOwnProperty.call(o,v)){var c=l?Object.getOwnPropertyDescriptor(o,v):null;c&&(c.get||c.set)?Object.defineProperty(y,v,c):y[v]=o[v]}return y.default=o,f&&f.set(o,y),y}function S(){return S=Object.assign?Object.assign.bind():function(o){for(var s=1;s<arguments.length;s++){var f=arguments[s];for(var y in f)Object.prototype.hasOwnProperty.call(f,y)&&(o[y]=f[y])}return o},S.apply(this,arguments)}function h(o,s){if(o==null)return{};var f={},y=Object.keys(o),l,v;for(v=0;v<y.length;v++)l=y[v],!(s.indexOf(l)>=0)&&(f[l]=o[l]);return f}function C(o,s){var f=Object.keys(o);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(o);s&&(y=y.filter(function(l){return Object.getOwnPropertyDescriptor(o,l).enumerable})),f.push.apply(f,y)}return f}function m(o){for(var s=1;s<arguments.length;s++){var f=arguments[s]!=null?arguments[s]:{};s%2?C(Object(f),!0).forEach(function(y){b(o,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(f)):C(Object(f)).forEach(function(y){Object.defineProperty(o,y,Object.getOwnPropertyDescriptor(f,y))})}return o}function b(o,s,f){return s=E(s),s in o?Object.defineProperty(o,s,{value:f,enumerable:!0,configurable:!0,writable:!0}):o[s]=f,o}function E(o){var s=I(o,"string");return typeof s=="symbol"?s:String(s)}function I(o,s){if(typeof o!="object"||o===null)return o;var f=o[Symbol.toPrimitive];if(f!==void 0){var y=f.call(o,s);if(typeof y!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(o)}function _(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,T(o,s)}function T(o,s){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,l){return y.__proto__=l,y},T(o,s)}var p=function(o){_(s,o);function s(){for(var y,l=arguments.length,v=new Array(l),c=0;c<l;c++)v[c]=arguments[c];return y=o.call.apply(o,[this].concat(v))||this,y.handleRefs={},y.lastHandleRect=null,y.slack=null,y}var f=s.prototype;return f.componentWillUnmount=function(){this.resetData()},f.resetData=function(){this.lastHandleRect=this.slack=null},f.runConstraints=function(l,v){var c=this.props,g=c.minConstraints,P=c.maxConstraints,M=c.lockAspectRatio;if(!g&&!P&&!M)return[l,v];if(M){var U=this.props.width/this.props.height,z=l-this.props.width,O=v-this.props.height;Math.abs(z)>Math.abs(O*U)?v=l/U:l=v*U}var L=l,W=v,F=this.slack||[0,0],X=F[0],ae=F[1];return l+=X,v+=ae,g&&(l=Math.max(g[0],l),v=Math.max(g[1],v)),P&&(l=Math.min(P[0],l),v=Math.min(P[1],v)),this.slack=[X+(L-l),ae+(W-v)],[l,v]},f.resizeHandler=function(l,v){var c=this;return function(g,P){var M=P.node,U=P.deltaX,z=P.deltaY;l==="onResizeStart"&&c.resetData();var O=(c.props.axis==="both"||c.props.axis==="x")&&v!=="n"&&v!=="s",L=(c.props.axis==="both"||c.props.axis==="y")&&v!=="e"&&v!=="w";if(!(!O&&!L)){var W=v[0],F=v[v.length-1],X=M.getBoundingClientRect();if(c.lastHandleRect!=null){if(F==="w"){var ae=X.left-c.lastHandleRect.left;U+=ae}if(W==="n"){var ne=X.top-c.lastHandleRect.top;z+=ne}}c.lastHandleRect=X,F==="w"&&(U=-U),W==="n"&&(z=-z);var se=c.props.width+(O?U/c.props.transformScale:0),j=c.props.height+(L?z/c.props.transformScale:0),Q=c.runConstraints(se,j);se=Q[0],j=Q[1];var te=se!==c.props.width||j!==c.props.height,oe=typeof c.props[l]=="function"?c.props[l]:null,ce=l==="onResize"&&!te;oe&&!ce&&(g.persist==null||g.persist(),oe(g,{node:M,size:{width:se,height:j},handle:v})),l==="onResizeStop"&&c.resetData()}}},f.renderResizeHandle=function(l,v){var c=this.props.handle;if(!c)return e.createElement("span",{className:"react-resizable-handle react-resizable-handle-"+l,ref:v});if(typeof c=="function")return c(l,v);var g=typeof c.type=="string",P=m({ref:v},g?{}:{handleAxis:l});return e.cloneElement(c,P)},f.render=function(){var l=this,v=this.props,c=v.children,g=v.className,P=v.draggableOpts;v.width,v.height,v.handle,v.handleSize,v.lockAspectRatio,v.axis,v.minConstraints,v.maxConstraints,v.onResize,v.onResizeStop,v.onResizeStart;var M=v.resizeHandles;v.transformScale;var U=h(v,a);return(0,r.cloneElement)(c,m(m({},U),{},{className:(g?g+" ":"")+"react-resizable",children:[].concat(c.props.children,M.map(function(z){var O,L=(O=l.handleRefs[z])!=null?O:l.handleRefs[z]=e.createRef();return e.createElement(t.DraggableCore,S({},P,{nodeRef:L,key:"resizableHandle-"+z,onStop:l.resizeHandler("onResizeStop",z),onStart:l.resizeHandler("onResizeStart",z),onDrag:l.resizeHandler("onResize",z)}),l.renderResizeHandle(z,L))}))}))},s}(e.Component);return Je.default=p,p.propTypes=n.resizableProps,p.defaultProps={axis:"both",handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:["se"],transformScale:1},Je}var $e={},Yr;function Qn(){if(Yr)return $e;Yr=1,$e.__esModule=!0,$e.default=void 0;var e=S(V),t=i(we()),r=i(qr()),n=Fr(),a=["handle","handleSize","onResize","onResizeStart","onResizeStop","draggableOpts","minConstraints","maxConstraints","lockAspectRatio","axis","width","height","resizeHandles","style","transformScale"];function i(s){return s&&s.__esModule?s:{default:s}}function d(s){if(typeof WeakMap!="function")return null;var f=new WeakMap,y=new WeakMap;return(d=function(v){return v?y:f})(s)}function S(s,f){if(s&&s.__esModule)return s;if(s===null||typeof s!="object"&&typeof s!="function")return{default:s};var y=d(f);if(y&&y.has(s))return y.get(s);var l={},v=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var c in s)if(c!=="default"&&Object.prototype.hasOwnProperty.call(s,c)){var g=v?Object.getOwnPropertyDescriptor(s,c):null;g&&(g.get||g.set)?Object.defineProperty(l,c,g):l[c]=s[c]}return l.default=s,y&&y.set(s,l),l}function h(){return h=Object.assign?Object.assign.bind():function(s){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var l in y)Object.prototype.hasOwnProperty.call(y,l)&&(s[l]=y[l])}return s},h.apply(this,arguments)}function C(s,f){var y=Object.keys(s);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(s);f&&(l=l.filter(function(v){return Object.getOwnPropertyDescriptor(s,v).enumerable})),y.push.apply(y,l)}return y}function m(s){for(var f=1;f<arguments.length;f++){var y=arguments[f]!=null?arguments[f]:{};f%2?C(Object(y),!0).forEach(function(l){b(s,l,y[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(y)):C(Object(y)).forEach(function(l){Object.defineProperty(s,l,Object.getOwnPropertyDescriptor(y,l))})}return s}function b(s,f,y){return f=E(f),f in s?Object.defineProperty(s,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):s[f]=y,s}function E(s){var f=I(s,"string");return typeof f=="symbol"?f:String(f)}function I(s,f){if(typeof s!="object"||s===null)return s;var y=s[Symbol.toPrimitive];if(y!==void 0){var l=y.call(s,f);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(f==="string"?String:Number)(s)}function _(s,f){if(s==null)return{};var y={},l=Object.keys(s),v,c;for(c=0;c<l.length;c++)v=l[c],!(f.indexOf(v)>=0)&&(y[v]=s[v]);return y}function T(s,f){s.prototype=Object.create(f.prototype),s.prototype.constructor=s,p(s,f)}function p(s,f){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,v){return l.__proto__=v,l},p(s,f)}var o=function(s){T(f,s);function f(){for(var l,v=arguments.length,c=new Array(v),g=0;g<v;g++)c[g]=arguments[g];return l=s.call.apply(s,[this].concat(c))||this,l.state={width:l.props.width,height:l.props.height,propsWidth:l.props.width,propsHeight:l.props.height},l.onResize=function(P,M){var U=M.size;l.props.onResize?(P.persist==null||P.persist(),l.setState(U,function(){return l.props.onResize&&l.props.onResize(P,M)})):l.setState(U)},l}f.getDerivedStateFromProps=function(v,c){return c.propsWidth!==v.width||c.propsHeight!==v.height?{width:v.width,height:v.height,propsWidth:v.width,propsHeight:v.height}:null};var y=f.prototype;return y.render=function(){var v=this.props,c=v.handle,g=v.handleSize;v.onResize;var P=v.onResizeStart,M=v.onResizeStop,U=v.draggableOpts,z=v.minConstraints,O=v.maxConstraints,L=v.lockAspectRatio,W=v.axis;v.width,v.height;var F=v.resizeHandles,X=v.style,ae=v.transformScale,ne=_(v,a);return e.createElement(r.default,{axis:W,draggableOpts:U,handle:c,handleSize:g,height:this.state.height,lockAspectRatio:L,maxConstraints:O,minConstraints:z,onResizeStart:P,onResize:this.onResize,onResizeStop:M,resizeHandles:F,transformScale:ae,width:this.state.width},e.createElement("div",h({},ne,{style:m(m({},X),{},{width:this.state.width+"px",height:this.state.height+"px"})})))},f}(e.Component);return $e.default=o,o.propTypes=m(m({},n.resizableProps),{},{children:t.default.element}),$e}var Xr;function $n(){return Xr||(Xr=1,Ze.exports=function(){throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable")},Ze.exports.Resizable=qr().default,Ze.exports.ResizableBox=Qn().default),Ze.exports}var Te={},Kr;function Zr(){if(Kr)return Te;Kr=1,Object.defineProperty(Te,"__esModule",{value:!0}),Te.resizeHandleType=Te.resizeHandleAxesType=Te.default=void 0;var e=r(we()),t=r(V);function r(i){return i&&i.__esModule?i:{default:i}}const n=Te.resizeHandleAxesType=e.default.arrayOf(e.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),a=Te.resizeHandleType=e.default.oneOfType([e.default.node,e.default.func]);return Te.default={className:e.default.string,style:e.default.object,width:e.default.number,autoSize:e.default.bool,cols:e.default.number,draggableCancel:e.default.string,draggableHandle:e.default.string,verticalCompact:function(i){i.verticalCompact},compactType:e.default.oneOf(["vertical","horizontal"]),layout:function(i){var d=i.layout;d!==void 0&&Ve().validateLayout(d,"layout")},margin:e.default.arrayOf(e.default.number),containerPadding:e.default.arrayOf(e.default.number),rowHeight:e.default.number,maxRows:e.default.number,isBounded:e.default.bool,isDraggable:e.default.bool,isResizable:e.default.bool,allowOverlap:e.default.bool,preventCollision:e.default.bool,useCSSTransforms:e.default.bool,transformScale:e.default.number,isDroppable:e.default.bool,resizeHandles:n,resizeHandle:a,onLayoutChange:e.default.func,onDragStart:e.default.func,onDrag:e.default.func,onDragStop:e.default.func,onResizeStart:e.default.func,onResize:e.default.func,onResizeStop:e.default.func,onDrop:e.default.func,droppingItem:e.default.shape({i:e.default.string.isRequired,w:e.default.number.isRequired,h:e.default.number.isRequired}),children:function(i,d){const S=i[d],h={};t.default.Children.forEach(S,function(C){if((C==null?void 0:C.key)!=null){if(h[C.key])throw new Error('Duplicate child key "'+C.key+'" found! This will cause problems in ReactGridLayout.');h[C.key]=!0}})},innerRef:e.default.any},Te}var Jr;function ea(){if(Jr)return Ye;Jr=1,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.default=void 0;var e=C(V),t=Vt,r=C(we()),n=nr(),a=$n(),i=Ve(),d=Jt(),S=Zr(),h=C(Kt());function C(_){return _&&_.__esModule?_:{default:_}}function m(_,T,p){return T=b(T),T in _?Object.defineProperty(_,T,{value:p,enumerable:!0,configurable:!0,writable:!0}):_[T]=p,_}function b(_){var T=E(_,"string");return typeof T=="symbol"?T:String(T)}function E(_,T){if(typeof _!="object"||_===null)return _;var p=_[Symbol.toPrimitive];if(p!==void 0){var o=p.call(_,T);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(T==="string"?String:Number)(_)}let I=class extends e.default.Component{constructor(){super(...arguments),m(this,"state",{resizing:null,dragging:null,className:""}),m(this,"elementRef",e.default.createRef()),m(this,"onDragStart",(T,p)=>{let{node:o}=p;const{onDragStart:s,transformScale:f}=this.props;if(!s)return;const y={top:0,left:0},{offsetParent:l}=o;if(!l)return;const v=l.getBoundingClientRect(),c=o.getBoundingClientRect(),g=c.left/f,P=v.left/f,M=c.top/f,U=v.top/f;y.left=g-P+l.scrollLeft,y.top=M-U+l.scrollTop,this.setState({dragging:y});const{x:z,y:O}=(0,d.calcXY)(this.getPositionParams(),y.top,y.left,this.props.w,this.props.h);return s.call(this,this.props.i,z,O,{e:T,node:o,newPosition:y})}),m(this,"onDrag",(T,p,o)=>{let{node:s,deltaX:f,deltaY:y}=p;const{onDrag:l}=this.props;if(!l)return;if(!this.state.dragging)throw new Error("onDrag called before onDragStart.");let v=this.state.dragging.top+y,c=this.state.dragging.left+f;const{isBounded:g,i:P,w:M,h:U,containerWidth:z}=this.props,O=this.getPositionParams();if(g){const{offsetParent:X}=s;if(X){const{margin:ae,rowHeight:ne,containerPadding:se}=this.props,j=X.clientHeight-(0,d.calcGridItemWHPx)(U,ne,ae[1]);v=(0,d.clamp)(v-se[1],0,j);const Q=(0,d.calcGridColWidth)(O),te=z-(0,d.calcGridItemWHPx)(M,Q,ae[0]);c=(0,d.clamp)(c-se[0],0,te)}}const L={top:v,left:c};o?this.setState({dragging:L}):(0,t.flushSync)(()=>{this.setState({dragging:L})});const{x:W,y:F}=(0,d.calcXY)(O,v,c,M,U);return l.call(this,P,W,F,{e:T,node:s,newPosition:L})}),m(this,"onDragStop",(T,p)=>{let{node:o}=p;const{onDragStop:s}=this.props;if(!s)return;if(!this.state.dragging)throw new Error("onDragEnd called before onDragStart.");const{w:f,h:y,i:l}=this.props,{left:v,top:c}=this.state.dragging,g={top:c,left:v};this.setState({dragging:null});const{x:P,y:M}=(0,d.calcXY)(this.getPositionParams(),c,v,f,y);return s.call(this,l,P,M,{e:T,node:o,newPosition:g})}),m(this,"onResizeStop",(T,p,o)=>this.onResizeHandler(T,p,o,"onResizeStop")),m(this,"onResizeStart",(T,p,o)=>this.onResizeHandler(T,p,o,"onResizeStart")),m(this,"onResize",(T,p,o)=>this.onResizeHandler(T,p,o,"onResize"))}shouldComponentUpdate(T,p){if(this.props.children!==T.children||this.props.droppingPosition!==T.droppingPosition)return!0;const o=(0,d.calcGridItemPosition)(this.getPositionParams(this.props),this.props.x,this.props.y,this.props.w,this.props.h,this.state),s=(0,d.calcGridItemPosition)(this.getPositionParams(T),T.x,T.y,T.w,T.h,p);return!(0,i.fastPositionEqual)(o,s)||this.props.useCSSTransforms!==T.useCSSTransforms}componentDidMount(){this.moveDroppingItem({})}componentDidUpdate(T){this.moveDroppingItem(T)}moveDroppingItem(T){const{droppingPosition:p}=this.props;if(!p)return;const o=this.elementRef.current;if(!o)return;const s=T.droppingPosition||{left:0,top:0},{dragging:f}=this.state,y=f&&p.left!==s.left||p.top!==s.top;if(!f)this.onDragStart(p.e,{node:o,deltaX:p.left,deltaY:p.top});else if(y){const l=p.left-f.left,v=p.top-f.top;this.onDrag(p.e,{node:o,deltaX:l,deltaY:v},!0)}}getPositionParams(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return{cols:T.cols,containerPadding:T.containerPadding,containerWidth:T.containerWidth,margin:T.margin,maxRows:T.maxRows,rowHeight:T.rowHeight}}createStyle(T){const{usePercentages:p,containerWidth:o,useCSSTransforms:s}=this.props;let f;return s?f=(0,i.setTransform)(T):(f=(0,i.setTopLeft)(T),p&&(f.left=(0,i.perc)(T.left/o),f.width=(0,i.perc)(T.width/o))),f}mixinDraggable(T,p){return e.default.createElement(n.DraggableCore,{disabled:!p,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,handle:this.props.handle,cancel:".react-resizable-handle"+(this.props.cancel?","+this.props.cancel:""),scale:this.props.transformScale,nodeRef:this.elementRef},T)}curryResizeHandler(T,p){return(o,s)=>p(o,s,T)}mixinResizable(T,p,o){const{cols:s,minW:f,minH:y,maxW:l,maxH:v,transformScale:c,resizeHandles:g,resizeHandle:P}=this.props,M=this.getPositionParams(),U=(0,d.calcGridItemPosition)(M,0,0,s,0).width,z=(0,d.calcGridItemPosition)(M,0,0,f,y),O=(0,d.calcGridItemPosition)(M,0,0,l,v),L=[z.width,z.height],W=[Math.min(O.width,U),Math.min(O.height,1/0)];return e.default.createElement(a.Resizable,{draggableOpts:{disabled:!o},className:o?void 0:"react-resizable-hide",width:p.width,height:p.height,minConstraints:L,maxConstraints:W,onResizeStop:this.curryResizeHandler(p,this.onResizeStop),onResizeStart:this.curryResizeHandler(p,this.onResizeStart),onResize:this.curryResizeHandler(p,this.onResize),transformScale:c,resizeHandles:g,handle:P},T)}onResizeHandler(T,p,o,s){let{node:f,size:y,handle:l}=p;const v=this.props[s];if(!v)return;const{x:c,y:g,i:P,maxH:M,minH:U,containerWidth:z}=this.props,{minW:O,maxW:L}=this.props;let W=y;f&&(W=(0,i.resizeItemInDirection)(l,o,y,z),(0,t.flushSync)(()=>{this.setState({resizing:s==="onResizeStop"?null:W})}));let{w:F,h:X}=(0,d.calcWH)(this.getPositionParams(),W.width,W.height,c,g,l);F=(0,d.clamp)(F,Math.max(O,1),L),X=(0,d.clamp)(X,U,M),v.call(this,P,F,X,{e:T,node:f,size:W,handle:l})}render(){const{x:T,y:p,w:o,h:s,isDraggable:f,isResizable:y,droppingPosition:l,useCSSTransforms:v}=this.props,c=(0,d.calcGridItemPosition)(this.getPositionParams(),T,p,o,s,this.state),g=e.default.Children.only(this.props.children);let P=e.default.cloneElement(g,{ref:this.elementRef,className:(0,h.default)("react-grid-item",g.props.className,this.props.className,{static:this.props.static,resizing:!!this.state.resizing,"react-draggable":f,"react-draggable-dragging":!!this.state.dragging,dropping:!!l,cssTransforms:v}),style:{...this.props.style,...g.props.style,...this.createStyle(c)}});return P=this.mixinResizable(P,c,y),P=this.mixinDraggable(P,f),P}};return Ye.default=I,m(I,"propTypes",{children:r.default.element,cols:r.default.number.isRequired,containerWidth:r.default.number.isRequired,rowHeight:r.default.number.isRequired,margin:r.default.array.isRequired,maxRows:r.default.number.isRequired,containerPadding:r.default.array.isRequired,x:r.default.number.isRequired,y:r.default.number.isRequired,w:r.default.number.isRequired,h:r.default.number.isRequired,minW:function(_,T){const p=_[T];if(typeof p!="number")return new Error("minWidth not Number");if(p>_.w||p>_.maxW)return new Error("minWidth larger than item width/maxWidth")},maxW:function(_,T){const p=_[T];if(typeof p!="number")return new Error("maxWidth not Number");if(p<_.w||p<_.minW)return new Error("maxWidth smaller than item width/minWidth")},minH:function(_,T){const p=_[T];if(typeof p!="number")return new Error("minHeight not Number");if(p>_.h||p>_.maxH)return new Error("minHeight larger than item height/maxHeight")},maxH:function(_,T){const p=_[T];if(typeof p!="number")return new Error("maxHeight not Number");if(p<_.h||p<_.minH)return new Error("maxHeight smaller than item height/minHeight")},i:r.default.string.isRequired,resizeHandles:S.resizeHandleAxesType,resizeHandle:S.resizeHandleType,onDragStop:r.default.func,onDragStart:r.default.func,onDrag:r.default.func,onResizeStop:r.default.func,onResizeStart:r.default.func,onResize:r.default.func,isDraggable:r.default.bool.isRequired,isResizable:r.default.bool.isRequired,isBounded:r.default.bool.isRequired,static:r.default.bool,useCSSTransforms:r.default.bool.isRequired,transformScale:r.default.number,className:r.default.string,handle:r.default.string,cancel:r.default.string,droppingPosition:r.default.shape({e:r.default.object.isRequired,left:r.default.number.isRequired,top:r.default.number.isRequired})}),m(I,"defaultProps",{className:"",cancel:"",handle:"",minH:1,minW:1,maxH:1/0,maxW:1/0,transformScale:1}),Ye}var Qr;function $r(){if(Qr)return Ge;Qr=1,Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.default=void 0;var e=C(V),t=Xt(),r=S(Kt()),n=Ve(),a=Jt(),i=S(ea()),d=S(Zr());function S(p){return p&&p.__esModule?p:{default:p}}function h(p){if(typeof WeakMap!="function")return null;var o=new WeakMap,s=new WeakMap;return(h=function(f){return f?s:o})(p)}function C(p,o){if(p&&p.__esModule)return p;if(p===null||typeof p!="object"&&typeof p!="function")return{default:p};var s=h(o);if(s&&s.has(p))return s.get(p);var f={__proto__:null},y=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in p)if(l!=="default"&&Object.prototype.hasOwnProperty.call(p,l)){var v=y?Object.getOwnPropertyDescriptor(p,l):null;v&&(v.get||v.set)?Object.defineProperty(f,l,v):f[l]=p[l]}return f.default=p,s&&s.set(p,f),f}function m(p,o,s){return o=b(o),o in p?Object.defineProperty(p,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):p[o]=s,p}function b(p){var o=E(p,"string");return typeof o=="symbol"?o:String(o)}function E(p,o){if(typeof p!="object"||p===null)return p;var s=p[Symbol.toPrimitive];if(s!==void 0){var f=s.call(p,o);if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(p)}const I="react-grid-layout";let _=!1;try{_=/firefox/i.test(navigator.userAgent)}catch{}let T=class extends e.Component{constructor(){super(...arguments),m(this,"state",{activeDrag:null,layout:(0,n.synchronizeLayoutWithChildren)(this.props.layout,this.props.children,this.props.cols,(0,n.compactType)(this.props),this.props.allowOverlap),mounted:!1,oldDragItem:null,oldLayout:null,oldResizeItem:null,resizing:!1,droppingDOMNode:null,children:[]}),m(this,"dragEnterCounter",0),m(this,"onDragStart",(o,s,f,y)=>{let{e:l,node:v}=y;const{layout:c}=this.state,g=(0,n.getLayoutItem)(c,o);if(!g)return;const P={w:g.w,h:g.h,x:g.x,y:g.y,placeholder:!0,i:o};return this.setState({oldDragItem:(0,n.cloneLayoutItem)(g),oldLayout:c,activeDrag:P}),this.props.onDragStart(c,g,g,null,l,v)}),m(this,"onDrag",(o,s,f,y)=>{let{e:l,node:v}=y;const{oldDragItem:c}=this.state;let{layout:g}=this.state;const{cols:P,allowOverlap:M,preventCollision:U}=this.props,z=(0,n.getLayoutItem)(g,o);if(!z)return;const O={w:z.w,h:z.h,x:z.x,y:z.y,placeholder:!0,i:o};g=(0,n.moveElement)(g,z,s,f,!0,U,(0,n.compactType)(this.props),P,M),this.props.onDrag(g,c,z,O,l,v),this.setState({layout:M?g:(0,n.compact)(g,(0,n.compactType)(this.props),P),activeDrag:O})}),m(this,"onDragStop",(o,s,f,y)=>{let{e:l,node:v}=y;if(!this.state.activeDrag)return;const{oldDragItem:c}=this.state;let{layout:g}=this.state;const{cols:P,preventCollision:M,allowOverlap:U}=this.props,z=(0,n.getLayoutItem)(g,o);if(!z)return;g=(0,n.moveElement)(g,z,s,f,!0,M,(0,n.compactType)(this.props),P,U);const L=U?g:(0,n.compact)(g,(0,n.compactType)(this.props),P);this.props.onDragStop(L,c,z,null,l,v);const{oldLayout:W}=this.state;this.setState({activeDrag:null,layout:L,oldDragItem:null,oldLayout:null}),this.onLayoutMaybeChanged(L,W)}),m(this,"onResizeStart",(o,s,f,y)=>{let{e:l,node:v}=y;const{layout:c}=this.state,g=(0,n.getLayoutItem)(c,o);g&&(this.setState({oldResizeItem:(0,n.cloneLayoutItem)(g),oldLayout:this.state.layout,resizing:!0}),this.props.onResizeStart(c,g,g,null,l,v))}),m(this,"onResize",(o,s,f,y)=>{let{e:l,node:v,size:c,handle:g}=y;const{oldResizeItem:P}=this.state,{layout:M}=this.state,{cols:U,preventCollision:z,allowOverlap:O}=this.props;let L=!1,W,F,X;const[ae,ne]=(0,n.withLayoutItem)(M,o,j=>{let Q;return F=j.x,X=j.y,["sw","w","nw","n","ne"].indexOf(g)!==-1&&(["sw","nw","w"].indexOf(g)!==-1&&(F=j.x+(j.w-s),s=j.x!==F&&F<0?j.w:s,F=F<0?0:F),["ne","n","nw"].indexOf(g)!==-1&&(X=j.y+(j.h-f),f=j.y!==X&&X<0?j.h:f,X=X<0?0:X),L=!0),z&&!O&&(Q=(0,n.getAllCollisions)(M,{...j,w:s,h:f,x:F,y:X}).filter(oe=>oe.i!==j.i).length>0,Q&&(X=j.y,f=j.h,F=j.x,s=j.w,L=!1)),j.w=s,j.h=f,j});if(!ne)return;W=ae,L&&(W=(0,n.moveElement)(ae,ne,F,X,!0,this.props.preventCollision,(0,n.compactType)(this.props),U,O));const se={w:ne.w,h:ne.h,x:ne.x,y:ne.y,static:!0,i:o};this.props.onResize(W,P,ne,se,l,v),this.setState({layout:O?W:(0,n.compact)(W,(0,n.compactType)(this.props),U),activeDrag:se})}),m(this,"onResizeStop",(o,s,f,y)=>{let{e:l,node:v}=y;const{layout:c,oldResizeItem:g}=this.state,{cols:P,allowOverlap:M}=this.props,U=(0,n.getLayoutItem)(c,o),z=M?c:(0,n.compact)(c,(0,n.compactType)(this.props),P);this.props.onResizeStop(z,g,U,null,l,v);const{oldLayout:O}=this.state;this.setState({activeDrag:null,layout:z,oldResizeItem:null,oldLayout:null,resizing:!1}),this.onLayoutMaybeChanged(z,O)}),m(this,"onDragOver",o=>{var ae;if(o.preventDefault(),o.stopPropagation(),_&&!((ae=o.nativeEvent.target)!=null&&ae.classList.contains(I)))return!1;const{droppingItem:s,onDropDragOver:f,margin:y,cols:l,rowHeight:v,maxRows:c,width:g,containerPadding:P,transformScale:M}=this.props,U=f==null?void 0:f(o);if(U===!1)return this.state.droppingDOMNode&&this.removeDroppingPlaceholder(),!1;const z={...s,...U},{layout:O}=this.state,L=o.currentTarget.getBoundingClientRect(),W=o.clientX-L.left,F=o.clientY-L.top,X={left:W/M,top:F/M,e:o};if(this.state.droppingDOMNode){if(this.state.droppingPosition){const{left:ne,top:se}=this.state.droppingPosition;(ne!=W||se!=F)&&this.setState({droppingPosition:X})}}else{const ne={cols:l,margin:y,maxRows:c,rowHeight:v,containerWidth:g,containerPadding:P||y},se=(0,a.calcXY)(ne,F,W,z.w,z.h);this.setState({droppingDOMNode:e.createElement("div",{key:z.i}),droppingPosition:X,layout:[...O,{...z,x:se.x,y:se.y,static:!1,isDraggable:!0}]})}}),m(this,"removeDroppingPlaceholder",()=>{const{droppingItem:o,cols:s}=this.props,{layout:f}=this.state,y=(0,n.compact)(f.filter(l=>l.i!==o.i),(0,n.compactType)(this.props),s,this.props.allowOverlap);this.setState({layout:y,droppingDOMNode:null,activeDrag:null,droppingPosition:void 0})}),m(this,"onDragLeave",o=>{o.preventDefault(),o.stopPropagation(),this.dragEnterCounter--,this.dragEnterCounter===0&&this.removeDroppingPlaceholder()}),m(this,"onDragEnter",o=>{o.preventDefault(),o.stopPropagation(),this.dragEnterCounter++}),m(this,"onDrop",o=>{o.preventDefault(),o.stopPropagation();const{droppingItem:s}=this.props,{layout:f}=this.state,y=f.find(l=>l.i===s.i);this.dragEnterCounter=0,this.removeDroppingPlaceholder(),this.props.onDrop(f,y,o)})}componentDidMount(){this.setState({mounted:!0}),this.onLayoutMaybeChanged(this.state.layout,this.props.layout)}static getDerivedStateFromProps(o,s){let f;return s.activeDrag?null:(!(0,t.deepEqual)(o.layout,s.propsLayout)||o.compactType!==s.compactType?f=o.layout:(0,n.childrenEqual)(o.children,s.children)||(f=s.layout),f?{layout:(0,n.synchronizeLayoutWithChildren)(f,o.children,o.cols,(0,n.compactType)(o),o.allowOverlap),compactType:o.compactType,children:o.children,propsLayout:o.layout}:null)}shouldComponentUpdate(o,s){return this.props.children!==o.children||!(0,n.fastRGLPropsEqual)(this.props,o,t.deepEqual)||this.state.activeDrag!==s.activeDrag||this.state.mounted!==s.mounted||this.state.droppingPosition!==s.droppingPosition}componentDidUpdate(o,s){if(!this.state.activeDrag){const f=this.state.layout,y=s.layout;this.onLayoutMaybeChanged(f,y)}}containerHeight(){if(!this.props.autoSize)return;const o=(0,n.bottom)(this.state.layout),s=this.props.containerPadding?this.props.containerPadding[1]:this.props.margin[1];return o*this.props.rowHeight+(o-1)*this.props.margin[1]+s*2+"px"}onLayoutMaybeChanged(o,s){s||(s=this.state.layout),(0,t.deepEqual)(s,o)||this.props.onLayoutChange(o)}placeholder(){const{activeDrag:o}=this.state;if(!o)return null;const{width:s,cols:f,margin:y,containerPadding:l,rowHeight:v,maxRows:c,useCSSTransforms:g,transformScale:P}=this.props;return e.createElement(i.default,{w:o.w,h:o.h,x:o.x,y:o.y,i:o.i,className:`react-grid-placeholder ${this.state.resizing?"placeholder-resizing":""}`,containerWidth:s,cols:f,margin:y,containerPadding:l||y,maxRows:c,rowHeight:v,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:g,transformScale:P},e.createElement("div",null))}processGridItem(o,s){if(!o||!o.key)return;const f=(0,n.getLayoutItem)(this.state.layout,String(o.key));if(!f)return null;const{width:y,cols:l,margin:v,containerPadding:c,rowHeight:g,maxRows:P,isDraggable:M,isResizable:U,isBounded:z,useCSSTransforms:O,transformScale:L,draggableCancel:W,draggableHandle:F,resizeHandles:X,resizeHandle:ae}=this.props,{mounted:ne,droppingPosition:se}=this.state,j=typeof f.isDraggable=="boolean"?f.isDraggable:!f.static&&M,Q=typeof f.isResizable=="boolean"?f.isResizable:!f.static&&U,te=f.resizeHandles||X,oe=j&&z&&f.isBounded!==!1;return e.createElement(i.default,{containerWidth:y,cols:l,margin:v,containerPadding:c||v,maxRows:P,rowHeight:g,cancel:W,handle:F,onDragStop:this.onDragStop,onDragStart:this.onDragStart,onDrag:this.onDrag,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,isDraggable:j,isResizable:Q,isBounded:oe,useCSSTransforms:O&&ne,usePercentages:!ne,transformScale:L,w:f.w,h:f.h,x:f.x,y:f.y,i:f.i,minH:f.minH,minW:f.minW,maxH:f.maxH,maxW:f.maxW,static:f.static,droppingPosition:s?se:void 0,resizeHandles:te,resizeHandle:ae},o)}render(){const{className:o,style:s,isDroppable:f,innerRef:y}=this.props,l=(0,r.default)(I,o),v={height:this.containerHeight(),...s};return e.createElement("div",{ref:y,className:l,style:v,onDrop:f?this.onDrop:n.noop,onDragLeave:f?this.onDragLeave:n.noop,onDragEnter:f?this.onDragEnter:n.noop,onDragOver:f?this.onDragOver:n.noop},e.Children.map(this.props.children,c=>this.processGridItem(c)),f&&this.state.droppingDOMNode&&this.processGridItem(this.state.droppingDOMNode,!0),this.placeholder())}};return Ge.default=T,m(T,"displayName","ReactGridLayout"),m(T,"propTypes",d.default),m(T,"defaultProps",{autoSize:!0,cols:12,className:"",style:{},draggableHandle:"",draggableCancel:"",containerPadding:null,rowHeight:150,maxRows:1/0,layout:[],margin:[10,10],isBounded:!1,isDraggable:!0,isResizable:!0,allowOverlap:!1,isDroppable:!1,useCSSTransforms:!0,transformScale:1,verticalCompact:!0,compactType:"vertical",preventCollision:!1,droppingItem:{i:"__dropping-elem__",h:1,w:1},resizeHandles:["se"],onLayoutChange:n.noop,onDragStart:n.noop,onDrag:n.noop,onDragStop:n.noop,onResizeStart:n.noop,onResize:n.noop,onResizeStop:n.noop,onDrop:n.noop,onDropDragOver:n.noop}),Ge}var et={},xe={},en;function tn(){if(en)return xe;en=1,Object.defineProperty(xe,"__esModule",{value:!0}),xe.findOrGenerateResponsiveLayout=n,xe.getBreakpointFromWidth=t,xe.getColsFromBreakpoint=r,xe.sortBreakpoints=a;var e=Ve();function t(i,d){const S=a(i);let h=S[0];for(let C=1,m=S.length;C<m;C++){const b=S[C];d>i[b]&&(h=b)}return h}function r(i,d){if(!d[i])throw new Error("ResponsiveReactGridLayout: `cols` entry for breakpoint "+i+" is missing!");return d[i]}function n(i,d,S,h,C,m){if(i[S])return(0,e.cloneLayout)(i[S]);let b=i[h];const E=a(d),I=E.slice(E.indexOf(S));for(let _=0,T=I.length;_<T;_++){const p=I[_];if(i[p]){b=i[p];break}}return b=(0,e.cloneLayout)(b||[]),(0,e.compact)((0,e.correctBounds)(b,{cols:C}),m,C)}function a(i){return Object.keys(i).sort(function(S,h){return i[S]-i[h]})}return xe}var rn;function ta(){if(rn)return et;rn=1,Object.defineProperty(et,"__esModule",{value:!0}),et.default=void 0;var e=h(V),t=d(we()),r=Xt(),n=Ve(),a=tn(),i=d($r());function d(p){return p&&p.__esModule?p:{default:p}}function S(p){if(typeof WeakMap!="function")return null;var o=new WeakMap,s=new WeakMap;return(S=function(f){return f?s:o})(p)}function h(p,o){if(p&&p.__esModule)return p;if(p===null||typeof p!="object"&&typeof p!="function")return{default:p};var s=S(o);if(s&&s.has(p))return s.get(p);var f={__proto__:null},y=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in p)if(l!=="default"&&Object.prototype.hasOwnProperty.call(p,l)){var v=y?Object.getOwnPropertyDescriptor(p,l):null;v&&(v.get||v.set)?Object.defineProperty(f,l,v):f[l]=p[l]}return f.default=p,s&&s.set(p,f),f}function C(){return C=Object.assign?Object.assign.bind():function(p){for(var o=1;o<arguments.length;o++){var s=arguments[o];for(var f in s)Object.prototype.hasOwnProperty.call(s,f)&&(p[f]=s[f])}return p},C.apply(this,arguments)}function m(p,o,s){return o=b(o),o in p?Object.defineProperty(p,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):p[o]=s,p}function b(p){var o=E(p,"string");return typeof o=="symbol"?o:String(o)}function E(p,o){if(typeof p!="object"||p===null)return p;var s=p[Symbol.toPrimitive];if(s!==void 0){var f=s.call(p,o);if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(p)}const I=p=>Object.prototype.toString.call(p);function _(p,o){return p==null?null:Array.isArray(p)?p:p[o]}let T=class extends e.Component{constructor(){super(...arguments),m(this,"state",this.generateInitialState()),m(this,"onLayoutChange",o=>{this.props.onLayoutChange(o,{...this.props.layouts,[this.state.breakpoint]:o})})}generateInitialState(){const{width:o,breakpoints:s,layouts:f,cols:y}=this.props,l=(0,a.getBreakpointFromWidth)(s,o),v=(0,a.getColsFromBreakpoint)(l,y),c=this.props.verticalCompact===!1?null:this.props.compactType;return{layout:(0,a.findOrGenerateResponsiveLayout)(f,s,l,l,v,c),breakpoint:l,cols:v}}static getDerivedStateFromProps(o,s){if(!(0,r.deepEqual)(o.layouts,s.layouts)){const{breakpoint:f,cols:y}=s;return{layout:(0,a.findOrGenerateResponsiveLayout)(o.layouts,o.breakpoints,f,f,y,o.compactType),layouts:o.layouts}}return null}componentDidUpdate(o){(this.props.width!=o.width||this.props.breakpoint!==o.breakpoint||!(0,r.deepEqual)(this.props.breakpoints,o.breakpoints)||!(0,r.deepEqual)(this.props.cols,o.cols))&&this.onWidthChange(o)}onWidthChange(o){const{breakpoints:s,cols:f,layouts:y,compactType:l}=this.props,v=this.props.breakpoint||(0,a.getBreakpointFromWidth)(this.props.breakpoints,this.props.width),c=this.state.breakpoint,g=(0,a.getColsFromBreakpoint)(v,f),P={...y};if(c!==v||o.breakpoints!==s||o.cols!==f){c in P||(P[c]=(0,n.cloneLayout)(this.state.layout));let z=(0,a.findOrGenerateResponsiveLayout)(P,s,v,c,g,l);z=(0,n.synchronizeLayoutWithChildren)(z,this.props.children,g,l,this.props.allowOverlap),P[v]=z,this.props.onBreakpointChange(v,g),this.props.onLayoutChange(z,P),this.setState({breakpoint:v,layout:z,cols:g})}const M=_(this.props.margin,v),U=_(this.props.containerPadding,v);this.props.onWidthChange(this.props.width,M,g,U)}render(){const{breakpoint:o,breakpoints:s,cols:f,layouts:y,margin:l,containerPadding:v,onBreakpointChange:c,onLayoutChange:g,onWidthChange:P,...M}=this.props;return e.createElement(i.default,C({},M,{margin:_(l,this.state.breakpoint),containerPadding:_(v,this.state.breakpoint),onLayoutChange:this.onLayoutChange,layout:this.state.layout,cols:this.state.cols}))}};return et.default=T,m(T,"propTypes",{breakpoint:t.default.string,breakpoints:t.default.object,allowOverlap:t.default.bool,cols:t.default.object,margin:t.default.oneOfType([t.default.array,t.default.object]),containerPadding:t.default.oneOfType([t.default.array,t.default.object]),layouts(p,o){if(I(p[o])!=="[object Object]")throw new Error("Layout property must be an object. Received: "+I(p[o]));Object.keys(p[o]).forEach(s=>{if(!(s in p.breakpoints))throw new Error("Each key in layouts must align with a key in breakpoints.");(0,n.validateLayout)(p.layouts[s],"layouts."+s)})},width:t.default.number.isRequired,onBreakpointChange:t.default.func,onLayoutChange:t.default.func,onWidthChange:t.default.func}),m(T,"defaultProps",{breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},containerPadding:{lg:null,md:null,sm:null,xs:null,xxs:null},layouts:{},margin:[10,10],allowOverlap:!1,onBreakpointChange:n.noop,onLayoutChange:n.noop,onWidthChange:n.noop}),et}var Ct={},nn=function(){if(typeof Map<"u")return Map;function e(t,r){var n=-1;return t.some(function(a,i){return a[0]===r?(n=i,!0):!1}),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(r){var n=e(this.__entries__,r),a=this.__entries__[n];return a&&a[1]},t.prototype.set=function(r,n){var a=e(this.__entries__,r);~a?this.__entries__[a][1]=n:this.__entries__.push([r,n])},t.prototype.delete=function(r){var n=this.__entries__,a=e(n,r);~a&&n.splice(a,1)},t.prototype.has=function(r){return!!~e(this.__entries__,r)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(r,n){n===void 0&&(n=null);for(var a=0,i=this.__entries__;a<i.length;a++){var d=i[a];r.call(n,d[1],d[0])}},t}()}(),ar=typeof window<"u"&&typeof document<"u"&&window.document===document,Tt=function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()}(),ra=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(Tt):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}}(),na=2;function aa(e,t){var r=!1,n=!1,a=0;function i(){r&&(r=!1,e()),n&&S()}function d(){ra(i)}function S(){var h=Date.now();if(r){if(h-a<na)return;n=!0}else r=!0,n=!1,setTimeout(d,t);a=h}return S}var ia=20,oa=["top","right","bottom","left","width","height","size","weight"],sa=typeof MutationObserver<"u",la=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=aa(this.refresh.bind(this),ia)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var r=this.observers_,n=r.indexOf(t);~n&&r.splice(n,1),!r.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var t=this.updateObservers_();t&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter(function(r){return r.gatherActive(),r.hasActive()});return t.forEach(function(r){return r.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!ar||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),sa?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!ar||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var r=t.propertyName,n=r===void 0?"":r,a=oa.some(function(i){return!!~n.indexOf(i)});a&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),an=function(e,t){for(var r=0,n=Object.keys(t);r<n.length;r++){var a=n[r];Object.defineProperty(e,a,{value:t[a],enumerable:!1,writable:!1,configurable:!0})}return e},Ue=function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||Tt},on=_t(0,0,0,0);function wt(e){return parseFloat(e)||0}function sn(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return t.reduce(function(n,a){var i=e["border-"+a+"-width"];return n+wt(i)},0)}function ua(e){for(var t=["top","right","bottom","left"],r={},n=0,a=t;n<a.length;n++){var i=a[n],d=e["padding-"+i];r[i]=wt(d)}return r}function ca(e){var t=e.getBBox();return _t(0,0,t.width,t.height)}function da(e){var t=e.clientWidth,r=e.clientHeight;if(!t&&!r)return on;var n=Ue(e).getComputedStyle(e),a=ua(n),i=a.left+a.right,d=a.top+a.bottom,S=wt(n.width),h=wt(n.height);if(n.boxSizing==="border-box"&&(Math.round(S+i)!==t&&(S-=sn(n,"left","right")+i),Math.round(h+d)!==r&&(h-=sn(n,"top","bottom")+d)),!pa(e)){var C=Math.round(S+i)-t,m=Math.round(h+d)-r;Math.abs(C)!==1&&(S-=C),Math.abs(m)!==1&&(h-=m)}return _t(a.left,a.top,S,h)}var fa=function(){return typeof SVGGraphicsElement<"u"?function(e){return e instanceof Ue(e).SVGGraphicsElement}:function(e){return e instanceof Ue(e).SVGElement&&typeof e.getBBox=="function"}}();function pa(e){return e===Ue(e).document.documentElement}function ha(e){return ar?fa(e)?ca(e):da(e):on}function va(e){var t=e.x,r=e.y,n=e.width,a=e.height,i=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,d=Object.create(i.prototype);return an(d,{x:t,y:r,width:n,height:a,top:r,right:t+n,bottom:a+r,left:t}),d}function _t(e,t,r,n){return{x:e,y:t,width:r,height:n}}var ga=function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=_t(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=ha(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},e}(),ma=function(){function e(t,r){var n=va(r);an(this,{target:t,contentRect:n})}return e}(),ya=function(){function e(t,r,n){if(this.activeObservations_=[],this.observations_=new nn,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=r,this.callbackCtx_=n}return e.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof Ue(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var r=this.observations_;r.has(t)||(r.set(t,new ga(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof Ue(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var r=this.observations_;r.has(t)&&(r.delete(t),r.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(r){r.isActive()&&t.activeObservations_.push(r)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,r=this.activeObservations_.map(function(n){return new ma(n.target,n.broadcastRect())});this.callback_.call(t,r,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),ln=typeof WeakMap<"u"?new WeakMap:new nn,un=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var r=la.getInstance(),n=new ya(t,r,this);ln.set(this,n)}return e}();["observe","unobserve","disconnect"].forEach(function(e){un.prototype[e]=function(){var t;return(t=ln.get(this))[e].apply(t,arguments)}});var ba=function(){return typeof Tt.ResizeObserver<"u"?Tt.ResizeObserver:un}();const Sa=Cr(Object.freeze(Object.defineProperty({__proto__:null,default:ba},Symbol.toStringTag,{value:"Module"})));var cn;function Ca(){if(cn)return Ct;cn=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.default=E;var e=d(V),t=a(we()),r=a(Sa),n=a(Kt());function a(I){return I&&I.__esModule?I:{default:I}}function i(I){if(typeof WeakMap!="function")return null;var _=new WeakMap,T=new WeakMap;return(i=function(p){return p?T:_})(I)}function d(I,_){if(I&&I.__esModule)return I;if(I===null||typeof I!="object"&&typeof I!="function")return{default:I};var T=i(_);if(T&&T.has(I))return T.get(I);var p={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in I)if(s!=="default"&&Object.prototype.hasOwnProperty.call(I,s)){var f=o?Object.getOwnPropertyDescriptor(I,s):null;f&&(f.get||f.set)?Object.defineProperty(p,s,f):p[s]=I[s]}return p.default=I,T&&T.set(I,p),p}function S(){return S=Object.assign?Object.assign.bind():function(I){for(var _=1;_<arguments.length;_++){var T=arguments[_];for(var p in T)Object.prototype.hasOwnProperty.call(T,p)&&(I[p]=T[p])}return I},S.apply(this,arguments)}function h(I,_,T){return _=C(_),_ in I?Object.defineProperty(I,_,{value:T,enumerable:!0,configurable:!0,writable:!0}):I[_]=T,I}function C(I){var _=m(I,"string");return typeof _=="symbol"?_:String(_)}function m(I,_){if(typeof I!="object"||I===null)return I;var T=I[Symbol.toPrimitive];if(T!==void 0){var p=T.call(I,_);if(typeof p!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(I)}const b="react-grid-layout";function E(I){var _;return _=class extends e.Component{constructor(){super(...arguments),h(this,"state",{width:1280}),h(this,"elementRef",e.createRef()),h(this,"mounted",!1),h(this,"resizeObserver",void 0)}componentDidMount(){this.mounted=!0,this.resizeObserver=new r.default(o=>{if(this.elementRef.current instanceof HTMLElement){const f=o[0].contentRect.width;this.setState({width:f})}});const p=this.elementRef.current;p instanceof HTMLElement&&this.resizeObserver.observe(p)}componentWillUnmount(){this.mounted=!1;const p=this.elementRef.current;p instanceof HTMLElement&&this.resizeObserver.unobserve(p),this.resizeObserver.disconnect()}render(){const{measureBeforeMount:p,...o}=this.props;return p&&!this.mounted?e.createElement("div",{className:(0,n.default)(this.props.className,b),style:this.props.style,ref:this.elementRef}):e.createElement(I,S({innerRef:this.elementRef},o,this.state))}},h(_,"defaultProps",{measureBeforeMount:!1}),h(_,"propTypes",{measureBeforeMount:t.default.bool}),_}return Ct}var dn;function Ta(){return dn||(dn=1,function(e){e.exports=$r().default,e.exports.utils=Ve(),e.exports.calculateUtils=Jt(),e.exports.Responsive=ta().default,e.exports.Responsive.utils=tn(),e.exports.WidthProvider=Ca().default}(Yt)),Yt.exports}var wa=Ta();const _a=Wn(wa);var Ia=Object.getOwnPropertyDescriptor,Ra=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ia(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},Ea=(e,t)=>(r,n)=>t(r,n,e);let ze=class extends w.Disposable{constructor(t){super();Re(this,"_initLocal",()=>{});Re(this,"_findReplaceIndex",t=>{const r=/\{([^}]+)?\}/g,n=[];let a=r.exec(t);for(;a;)n.push({startIndex:a.index,key:Number(a[1]),endIndex:a.index+a[0].length-1}),a=r.exec(t);return n});this._localeService=t,this._initLocal()}tWithReactNode(t,...r){const n=this._localeService.getLocales(),a=t.split("."),i=n&&this._localeService.resolveKeyPath(n,a);if(typeof i=="string"){const d=[];return this._findReplaceIndex(i).forEach((S,h,C)=>{const m=C[h-1]||{endIndex:-1};if(m.endIndex+1<S.startIndex){const b=i.slice(m.endIndex+1,S.startIndex);b&&d.push(b)}if(r[S.key]&&d.push(r[S.key]),h===C.length-1){const b=i.slice(S.endIndex+1);b&&d.push(b)}}),d}return[]}};ze=Ra([Ea(0,w.Inject(w.LocaleService))],ze);const Oa=(e,t)=>{const r=e.rule;switch(r.type){case u.CFRuleType.colorScale:return t.t("sheet.cf.ruleType.colorScale");case u.CFRuleType.dataBar:return t.t("sheet.cf.ruleType.dataBar");case u.CFRuleType.iconSet:return t.t("sheet.cf.ruleType.iconSet");case u.CFRuleType.highlightCell:switch(r.subType){case u.CFSubRuleType.average:{const n=r.operator;return t.t(`sheet.cf.preview.describe.${n}`,t.t("sheet.cf.subRuleType.average"))}case u.CFSubRuleType.duplicateValues:return t.t("sheet.cf.subRuleType.duplicateValues");case u.CFSubRuleType.uniqueValues:return t.t("sheet.cf.subRuleType.uniqueValues");case u.CFSubRuleType.number:{const n=r.operator;return t.t(`sheet.cf.preview.describe.${n}`,...Array.isArray(r.value)?r.value.map(a=>String(a)):[String(r.value||"")])}case u.CFSubRuleType.text:{const n=r.operator;return t.t(`sheet.cf.preview.describe.${n}`,r.value||"")}case u.CFSubRuleType.timePeriod:{const n=r.operator;return t.t(`sheet.cf.preview.describe.${n}`)}case u.CFSubRuleType.rank:return r.isPercent?r.isBottom?t.t("sheet.cf.preview.describe.bottomNPercent",String(r.value)):t.t("sheet.cf.preview.describe.topNPercent",String(r.value)):r.isBottom?t.t("sheet.cf.preview.describe.bottomN",String(r.value)):t.t("sheet.cf.preview.describe.topN",String(r.value));case u.CFSubRuleType.formula:return t.t("sheet.cf.ruleType.formula")}}};let fn=0;const xa=e=>{const{onClick:t}=e,r=$.useDependency(u.ConditionalFormattingRuleModel),n=$.useDependency(w.IUniverInstanceService),a=$.useDependency(q.SheetsSelectionsService),i=$.useDependency(w.ICommandService),d=$.useDependency(w.LocaleService),S=$.useDependency(w.Injector),h=$.useDependency($.ISidebarService),C=$.useDependency(ze),m=$.useObservable(()=>n.getCurrentTypeOfUnit$(w.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),b=m.getUnitId(),E=m.getActiveSheet();if(!E)throw new Error("No active sheet found");const I=E.getSheetId(),[_,T]=V.useState([]),[p,o]=V.useState("2"),[s,f]=V.useState(0),[y,l]=V.useState(-1),[v,c]=V.useState(fn),g=V.useRef(null),P=[{label:d.t("sheet.cf.panel.workSheet"),value:"2"},{label:d.t("sheet.cf.panel.selectedRange"),value:"1"}],M=()=>{const j=r.getSubunitRules(b,I);if(!j||!j.length)return[];if(p==="1"){const Q=a.getCurrentLastSelection();if(!Q)return[];const te=Q.range;return j.filter(ce=>ce.ranges.some(pe=>w.Rectangle.intersects(pe,te)))}else if(p==="2")return[...j];return[]},[U,z]=V.useState(M);de.useHighlightRange(_),V.useEffect(()=>{const j=i.onCommandExecuted(Q=>{Q.id===q.SetWorksheetActiveOperation.id&&f(Math.random())});return()=>j.dispose()}),V.useEffect(()=>{z(M)},[p,s,b,I]),V.useEffect(()=>{if(p==="2")return;const j=new ye.Observable(Q=>{const te=[q.SetSelectionsOperation.id,u.AddConditionalRuleMutation.id,u.SetConditionalRuleMutation.id,u.DeleteConditionalRuleMutation.id,u.MoveConditionalRuleMutation.id],oe=i.onCommandExecuted(ce=>{const{id:pe,params:be}=ce,H=n.getCurrentUnitOfType(w.UniverInstanceType.UNIVER_SHEET).getUnitId();te.includes(pe)&&be.unitId===H&&Q.next(null)});return()=>oe.dispose()}).pipe(ye.debounceTime(16)).subscribe(()=>{z(M)});return()=>{j.unsubscribe()}},[n,p,b,I]),V.useEffect(()=>{const j=r.$ruleChange.subscribe(()=>{f(Math.random())});return()=>j.unsubscribe()},[r]),V.useEffect(()=>{const j=()=>{var ce,pe;const oe=Math.max(0,((pe=(ce=g.current)==null?void 0:ce.getBoundingClientRect().width)!=null?pe:0)-8);return fn=oe,oe},te=new ye.Observable(oe=>{const ce=h.getContainer();if(ce){let pe=setTimeout(()=>{oe.next()},150);const be=()=>{pe&&clearTimeout(pe),pe=null},H=K=>{K.propertyName==="width"&&(be(),oe.next())};return ce.addEventListener("transitionend",H),()=>{be(),ce.removeEventListener("transitionend",H)}}}).pipe(ye.debounceTime(16)).subscribe(()=>{c(j())});return()=>{te.unsubscribe()}},[]);const O=j=>{var oe;const Q=n.getCurrentUnitOfType(w.UniverInstanceType.UNIVER_SHEET).getUnitId(),te=(oe=n.getCurrentUnitOfType(w.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:oe.getSheetId();if(!Q||!te)throw new Error("No active sheet found");i.executeCommand(u.DeleteCfCommand.id,{unitId:Q,subUnitId:te,cfId:j.cfId})},L=(j,Q)=>{l(Q.y)},W=(j,Q,te)=>{var K;l(-1);const oe=n.getCurrentUnitOfType(w.UniverInstanceType.UNIVER_SHEET).getUnitId(),ce=(K=n.getCurrentUnitOfType(w.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:K.getSheetId();if(!oe||!ce)throw new Error("No active sheet found");const pe=ie=>{const x=U.length;return Math.min(x-1,Math.max(0,ie))},be=U[pe(Q.y)].cfId,H=U[pe(te.y)].cfId;be!==H&&i.executeCommand(u.MoveCfCommand.id,{unitId:oe,subUnitId:ce,start:{id:be,type:"self"},end:{id:H,type:te.y>Q.y?"after":"before"}})},F=()=>{e.onCreate()},X=()=>{p==="2"?i.executeCommand(u.ClearWorksheetCfCommand.id):p==="1"&&U.map(Q=>({unitId:b,subUnitId:I,cfId:Q.cfId})).forEach(Q=>{i.executeCommand(u.DeleteCfCommand.id,Q)})},ae=V.useMemo(()=>{const j=n.getCurrentUnitOfType(w.UniverInstanceType.UNIVER_SHEET),Q=j.getActiveSheet();return U.filter(te=>{const oe=te.ranges;return q.checkRangesEditablePermission(S,j.getUnitId(),Q.getSheetId(),oe)})},[U]),ne=ae.map((j,Q)=>({i:j.cfId,x:0,w:12,y:Q,h:1,isResizable:!1})),se=V.useMemo(()=>{const j=n.getCurrentUnitOfType(w.UniverInstanceType.UNIVER_SHEET),Q=j.getActiveSheet();return U.every(te=>{const oe=te.ranges;return q.checkRangesEditablePermission(S,j.getUnitId(),Q.getSheetId(),oe)})},[U]);return R.jsxs("div",{children:[R.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[R.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:C.tWithReactNode("sheet.cf.panel.managerRuleSelect",R.jsx(J.Select,{className:"univer-w-36",options:P,value:p,onChange:j=>{o(j)}})).map((j,Q)=>R.jsx("span",{children:j},Q))}),R.jsxs("div",{className:"univer-flex univer-justify-end",children:[R.jsx(J.Tooltip,{title:d.t("sheet.cf.panel.createRule"),placement:"bottom",children:R.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:F,children:R.jsx(fr,{})})}),U.length&&se?R.jsx(J.Tooltip,{title:d.t("sheet.cf.panel.clear"),placement:"bottom",children:R.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:X,children:R.jsx(ft,{className:"univer-text-red-500"})})}):R.jsx("div",{children:R.jsx(ft,{className:"univer-text-gray-300"})})]})]}),R.jsx("div",{ref:g,children:v>0&&R.jsx(_a,{className:`
56
+ `),children:[h,s.jsx(Me,{})]})})}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[s.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[s.jsx(D.Checkbox,{onChange:x}),n.t("sheet.cf.iconSet.reverseIconOrder")]}),s.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[s.jsx(D.Checkbox,{checked:!d,onChange:g=>{f(!g)}}),n.t("sheet.cf.iconSet.onlyShowIcon")]})]}),s.jsx(Lr,{errorMap:l,onChange:_,configList:o})]})},$r=t=>{var x;const{onChange:e,interceptorManager:u}=t,n=j.useDependency(i.LocaleService),l=((x=t.rule)==null?void 0:x.type)===r.CFRuleType.highlightCell?t.rule:void 0,a=[{label:n.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:n.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:n.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:n.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[c,p]=m.useState(()=>{const N=a[0].value,R=l==null?void 0:l.type;if(!l)return N;switch(R){case r.CFRuleType.highlightCell:switch(l.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(l.operator)?"greaterThanAverage":[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(l.operator)?"lessThanAverage":N;case r.CFSubRuleType.rank:return l.isBottom?"isBottom":"isNotBottom"}}return N}),[o,v]=m.useState(()=>{const R=l==null?void 0:l.type;if(!l)return 10;switch(R){case r.CFRuleType.highlightCell:switch(l.subType){case r.CFSubRuleType.rank:return l.value||10}}return 10}),[d,f]=m.useState(()=>{const R=l==null?void 0:l.type;if(!l)return!1;switch(R){case r.CFRuleType.highlightCell:switch(l.subType){case r.CFSubRuleType.rank:return l.isPercent||!1}}return!1}),[h,S]=m.useState({}),_=N=>{const{type:R,isPercent:w,value:M,style:g}=N;if(R==="isNotBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:w,isBottom:!1,value:M,style:g};if(R==="isBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:w,isBottom:!0,value:M,style:g};if(R==="greaterThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:g};if(R==="lessThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:g}};m.useEffect(()=>u.intercept(u.getInterceptPoints().submit,{handler(){return _({type:c,isPercent:d,value:o,style:h})}}),[c,d,o,h,u]);const b=N=>{e(_(N))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),s.jsx(D.Select,{className:"univer-mt-3 univer-w-full",value:c,options:a,onChange:N=>{p(N),b({type:N,isPercent:d,value:o,style:h})}}),["isNotBottom","isBottom"].includes(c)&&s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(D.InputNumber,{min:1,max:1e3,value:o,onChange:N=>{const R=N||0;v(R),b({type:c,isPercent:d,value:R,style:h})}}),s.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[s.jsx(D.Checkbox,{checked:d,onChange:N=>{f(!!N),b({type:c,isPercent:!!N,value:o,style:h})}}),n.t("sheet.cf.valueType.percent")]})]}),s.jsx("div",{className:ge,children:s.jsx(ae,{rule:_({type:c,isPercent:d,value:o,style:h})})}),s.jsx(Qe,{style:l==null?void 0:l.style,className:"univer-mt-3",onChange:N=>{S(N),b({type:c,isPercent:d,value:o,style:N})}})]})},Br=i.createInterceptorKey("beforeSubmit"),Hr=i.createInterceptorKey("submit"),pr=t=>t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),fr=t=>{var e;return(e=t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},Wr=t=>{var T,C,O;const e=j.useDependency(i.LocaleService),u=j.useDependency(i.ICommandService),n=j.useDependency(i.IUniverInstanceService),l=j.useDependency(r.ConditionalFormattingRuleModel),a=j.useDependency(k.SheetsSelectionsService),c=pr(n),p=fr(n),[o,v]=m.useState(void 0),d=m.useRef((C=(T=t.rule)==null?void 0:T.ranges)!=null?C:[]),f=m.useMemo(()=>{var U,A,y;let V=(U=t.rule)==null?void 0:U.ranges;return V!=null&&V.length||(V=(y=(A=a.getCurrentSelections())==null?void 0:A.map(E=>E.range))!=null?y:[]),d.current=V,V!=null&&V.length?V.map(E=>{const F=Be.serializeRange(E);return F==="NaN"?"":F}).filter(E=>!!E).join(","):""},[t.rule]),h=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[S,_]=m.useState(()=>{var A,y;const V=(A=t.rule)==null?void 0:A.rule.type,U=h[0].value;if(!V)return U;switch(V){case r.CFRuleType.highlightCell:{switch((y=t.rule)==null?void 0:y.rule.subType){case r.CFSubRuleType.number:case r.CFSubRuleType.text:case r.CFSubRuleType.duplicateValues:case r.CFSubRuleType.uniqueValues:case r.CFSubRuleType.timePeriod:return"1";case r.CFSubRuleType.average:case r.CFSubRuleType.rank:return"2";case r.CFSubRuleType.formula:return"5"}break}case r.CFRuleType.dataBar:return"3";case r.CFRuleType.colorScale:return"4";case r.CFRuleType.iconSet:return"6"}return U}),b=m.useRef(void 0),x=m.useMemo(()=>new i.InterceptorManager({beforeSubmit:Br,submit:Hr}),[]),N=m.useMemo(()=>{switch(S){case"1":return or;case"2":return $r;case"3":return Ur;case"4":return Or;case"5":return kr;case"6":return Fr;default:return or}},[S]);m.useEffect(()=>{const V=u.onCommandExecuted(U=>{if(U.id===k.RemoveSheetMutation.id){const A=U.params;A.subUnitId===p&&A.unitId===c&&t.onCancel()}U.id===k.SetWorksheetActiveOperation.id&&t.onCancel()});return()=>V.dispose()},[]);const R=V=>{b.current=V},w=V=>{const U=V.split(",").filter(A=>!!A).map(Be.deserializeRangeWithSheet).map(A=>A.range);d.current=U},M=()=>{if(o)return;const U=(()=>{const y=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!y)throw new Error("No active sheet found");return d.current.map(G=>k.setEndForRange(G,y.getRowCount(),y.getColumnCount())).filter(G=>!(Number.isNaN(G.startRow)||Number.isNaN(G.startColumn)))})();if(x.fetchThroughInterceptors(x.getInterceptPoints().beforeSubmit)(!0,null)){const y=x.fetchThroughInterceptors(x.getInterceptPoints().submit)(null,null);if(y){const E=pr(n),F=fr(n);if(!E||!F)throw new Error("No active sheet found");let G={};t.rule&&t.rule.cfId?(G={...t.rule,ranges:U,rule:y},u.executeCommand(r.SetCfCommand.id,{unitId:E,subUnitId:F,rule:G}),t.onCancel()):(G={cfId:l.createCfId(E,F),ranges:U,rule:y,stopIfTrue:!1},u.executeCommand(r.AddCfCommand.id,{unitId:E,subUnitId:F,rule:G}),t.onCancel())}}},g=()=>{t.onCancel()},I=(V,U)=>{V?U.length<1?v(e.t("sheet.cf.errorMessage.rangeError")):v(void 0):v(e.t("sheet.cf.errorMessage.rangeError"))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:e.t("sheet.cf.panel.range")}),s.jsxs("div",{className:"univer-mt-4",children:[s.jsx(pe.RangeSelector,{unitId:c,subUnitId:p,initialValue:f,onChange:(V,U)=>w(U),onVerify:I}),o&&s.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:o})]}),s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:e.t("sheet.cf.panel.styleType")}),s.jsx(D.Select,{className:"univer-mt-4 univer-w-full",value:S,options:h,onChange:V=>_(V)}),s.jsx(N,{interceptorManager:x,rule:(O=t.rule)==null?void 0:O.rule,onChange:R}),s.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[s.jsx(D.Button,{onClick:g,children:e.t("sheet.cf.panel.cancel")}),s.jsx(D.Button,{className:"univer-ml-3",variant:"primary",onClick:M,children:e.t("sheet.cf.panel.submit")})]})]})};var qr=Object.getOwnPropertyDescriptor,Gr=(t,e,u,n)=>{for(var l=n>1?void 0:n?qr(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},zr=(t,e)=>(u,n)=>e(u,n,t);let se=class extends i.Disposable{constructor(e){super();ee(this,"_initLocal",()=>{});ee(this,"_findReplaceIndex",e=>{const u=/\{([^}]+)?\}/g,n=[];let l=u.exec(e);for(;l;)n.push({startIndex:l.index,key:Number(l[1]),endIndex:l.index+l[0].length-1}),l=u.exec(e);return n});this._localeService=e,this._initLocal()}tWithReactNode(e,...u){const n=this._localeService.getLocales(),l=e.split("."),a=n&&this._localeService.resolveKeyPath(n,l);if(typeof a=="string"){const c=[];return this._findReplaceIndex(a).forEach((p,o,v)=>{const d=v[o-1]||{endIndex:-1};if(d.endIndex+1<p.startIndex){const f=a.slice(d.endIndex+1,p.startIndex);f&&c.push(f)}if(u[p.key]&&c.push(u[p.key]),o===v.length-1){const f=a.slice(p.endIndex+1);f&&c.push(f)}}),c}return[]}};se=Gr([zr(0,i.Inject(i.LocaleService))],se);const Yr=(t,e)=>{const u=t.rule;switch(u.type){case r.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case r.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case r.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case r.CFRuleType.highlightCell:switch(u.subType){case r.CFSubRuleType.average:{const n=u.operator;return e.t(`sheet.cf.preview.describe.${n}`,e.t("sheet.cf.subRuleType.average"))}case r.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case r.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case r.CFSubRuleType.number:{const n=u.operator;return e.t(`sheet.cf.preview.describe.${n}`,...Array.isArray(u.value)?u.value.map(l=>String(l)):[String(u.value||"")])}case r.CFSubRuleType.text:{const n=u.operator;return e.t(`sheet.cf.preview.describe.${n}`,u.value||"")}case r.CFSubRuleType.timePeriod:{const n=u.operator;return e.t(`sheet.cf.preview.describe.${n}`)}case r.CFSubRuleType.rank:return u.isPercent?u.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(u.value)):e.t("sheet.cf.preview.describe.topNPercent",String(u.value)):u.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(u.value)):e.t("sheet.cf.preview.describe.topN",String(u.value));case r.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let hr=0;const Zr=t=>{const{onClick:e}=t,u=j.useDependency(r.ConditionalFormattingRuleModel),n=j.useDependency(i.IUniverInstanceService),l=j.useDependency(k.SheetsSelectionsService),a=j.useDependency(i.ICommandService),c=j.useDependency(i.LocaleService),p=j.useDependency(i.Injector),o=j.useDependency(j.ISidebarService),v=j.useDependency(se),d=j.useObservable(()=>n.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),f=d.getUnitId(),h=d.getActiveSheet();if(!h)throw new Error("No active sheet found");const S=h.getSheetId(),[_,b]=m.useState([]),[x,N]=m.useState("2"),[R,w]=m.useState(0),[M,g]=m.useState(-1),[I,T]=m.useState(hr),C=m.useRef(null),O=[{label:c.t("sheet.cf.panel.workSheet"),value:"2"},{label:c.t("sheet.cf.panel.selectedRange"),value:"1"}],V=()=>{const L=u.getSubunitRules(f,S);if(!L||!L.length)return[];if(x==="1"){const $=l.getCurrentLastSelection();if(!$)return[];const H=$.range;return L.filter(z=>z.ranges.some(Y=>i.Rectangle.intersects(Y,H)))}else if(x==="2")return[...L];return[]},[U,A]=m.useState(V);W.useHighlightRange(_),m.useEffect(()=>{const L=a.onCommandExecuted($=>{$.id===k.SetWorksheetActiveOperation.id&&w(Math.random())});return()=>L.dispose()}),m.useEffect(()=>{A(V)},[x,R,f,S]),m.useEffect(()=>{if(x==="2")return;const L=new X.Observable($=>{const H=[k.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],q=a.onCommandExecuted(z=>{const{id:Y,params:ne}=z,le=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();H.includes(Y)&&ne.unitId===le&&$.next(null)});return()=>q.dispose()}).pipe(X.debounceTime(16)).subscribe(()=>{A(V)});return()=>{L.unsubscribe()}},[n,x,f,S]),m.useEffect(()=>{const L=u.$ruleChange.subscribe(()=>{w(Math.random())});return()=>L.unsubscribe()},[u]),m.useEffect(()=>{const L=()=>{var z,Y;const q=Math.max(0,((Y=(z=C.current)==null?void 0:z.getBoundingClientRect().width)!=null?Y:0)-8);return hr=q,q},H=new X.Observable(q=>{const z=o.getContainer();if(z){let Y=setTimeout(()=>{q.next()},150);const ne=()=>{Y&&clearTimeout(Y),Y=null},le=$e=>{$e.propertyName==="width"&&(ne(),q.next())};return z.addEventListener("transitionend",le),()=>{ne(),z.removeEventListener("transitionend",le)}}}).pipe(X.debounceTime(16)).subscribe(()=>{T(L())});return()=>{H.unsubscribe()}},[]);const y=L=>{var q;const $=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),H=(q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:q.getSheetId();if(!$||!H)throw new Error("No active sheet found");a.executeCommand(r.DeleteCfCommand.id,{unitId:$,subUnitId:H,cfId:L.cfId})},E=(L,$)=>{g($.y)},F=(L,$,H)=>{var $e;g(-1);const q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),z=($e=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:$e.getSheetId();if(!q||!z)throw new Error("No active sheet found");const Y=wt=>{const Vt=U.length;return Math.min(Vt-1,Math.max(0,wt))},ne=U[Y($.y)].cfId,le=U[Y(H.y)].cfId;ne!==le&&a.executeCommand(r.MoveCfCommand.id,{unitId:q,subUnitId:z,start:{id:ne,type:"self"},end:{id:le,type:H.y>$.y?"after":"before"}})},G=()=>{t.onCreate()},J=()=>{x==="2"?a.executeCommand(r.ClearWorksheetCfCommand.id):x==="1"&&U.map($=>({unitId:f,subUnitId:S,cfId:$.cfId})).forEach($=>{a.executeCommand(r.DeleteCfCommand.id,$)})},Q=m.useMemo(()=>{const L=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),$=L.getActiveSheet();return U.filter(H=>{const q=H.ranges;return k.checkRangesEditablePermission(p,L.getUnitId(),$.getSheetId(),q)})},[U]),de=Q.map((L,$)=>({i:L.cfId,x:0,w:12,y:$,h:1,isResizable:!1})),ve=m.useMemo(()=>{const L=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),$=L.getActiveSheet();return U.every(H=>{const q=H.ranges;return k.checkRangesEditablePermission(p,L.getUnitId(),$.getSheetId(),q)})},[U]);return s.jsxs("div",{children:[s.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[s.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:v.tWithReactNode("sheet.cf.panel.managerRuleSelect",s.jsx(D.Select,{className:"univer-w-36",options:O,value:x,onChange:L=>{N(L)}})).map((L,$)=>s.jsx("span",{children:L},$))}),s.jsxs("div",{className:"univer-flex univer-justify-end",children:[s.jsx(D.Tooltip,{title:c.t("sheet.cf.panel.createRule"),placement:"bottom",children:s.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:G,children:s.jsx(ar,{})})}),U.length&&ve?s.jsx(D.Tooltip,{title:c.t("sheet.cf.panel.clear"),placement:"bottom",children:s.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:J,children:s.jsx(Re,{className:"univer-text-red-500"})})}):s.jsx("div",{children:s.jsx(Re,{className:"univer-text-gray-300"})})]})]}),s.jsx("div",{ref:C,children:I>0&&s.jsx(D.ReactGridLayout,{className:`
35
57
  [&_.react-grid-item]:univer-transition-none
36
58
  [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200
37
- `,draggableHandle:".draggableHandle",layout:ne,cols:12,rowHeight:60,width:v,margin:[0,10],onDragStop:W,onDragStart:L,children:ae==null?void 0:ae.map((j,Q)=>R.jsx("div",{children:R.jsxs("div",{className:J.clsx(`
59
+ `,draggableHandle:".draggableHandle",layout:de,cols:12,rowHeight:60,width:I,margin:[0,10],onDragStop:F,onDragStart:E,children:Q==null?void 0:Q.map((L,$)=>s.jsx("div",{children:s.jsxs("div",{className:D.clsx(`
38
60
  univer-group univer-relative univer-flex univer-items-center
39
61
  univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8
40
62
  hover:univer-bg-gray-100
41
- `,{"univer-bg-gray-100":y===Q}),onMouseMove:()=>{j.ranges!==_&&T(j.ranges)},onMouseLeave:()=>T([]),onClick:()=>{t(j)},children:[R.jsx("div",{className:J.clsx(`
63
+ `,{"univer-bg-gray-100":M===$}),onMouseMove:()=>{L.ranges!==_&&b(L.ranges)},onMouseLeave:()=>b([]),onClick:()=>{e(L)},children:[s.jsx("div",{className:D.clsx(`
42
64
  univer-absolute univer-left-0 univer-hidden univer-size-5
43
65
  univer-cursor-grab univer-items-center univer-justify-center
44
66
  univer-rounded
45
67
  group-hover:univer-flex
46
- `,"draggableHandle"),onClick:te=>te.stopPropagation(),children:R.jsx(pr,{})}),R.jsxs("div",{className:`
68
+ `,"draggableHandle"),onClick:H=>H.stopPropagation(),children:s.jsx(ir,{})}),s.jsxs("div",{className:`
47
69
  univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden
48
- `,children:[R.jsx("div",{className:"univer-text-sm univer-text-gray-900",children:Oa(j,d)}),R.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:j.ranges.map(te=>Lt.serializeRange(te)).join(",")})]}),R.jsx("div",{children:R.jsx(Ne,{rule:j.rule})}),R.jsx("div",{className:J.clsx(`
70
+ `,children:[s.jsx("div",{className:"univer-text-sm univer-text-gray-900",children:Yr(L,c)}),s.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:L.ranges.map(H=>Be.serializeRange(H)).join(",")})]}),s.jsx("div",{children:s.jsx(ae,{rule:L.rule})}),s.jsx("div",{className:D.clsx(`
49
71
  univer-absolute univer-right-1 univer-hidden univer-size-6
50
72
  univer-cursor-pointer univer-items-center univer-justify-center
51
73
  univer-rounded
52
74
  group-hover:univer-flex
53
75
  hover:univer-bg-gray-200
54
- `,{"univer-flex univer-items-center univer-justify-center":y===Q}),onClick:te=>{te.stopPropagation(),O(j),T([])},children:R.jsx(ft,{})})]})},`${j.cfId}`))})})]})},Da=e=>{const[t,r]=V.useState(e.rule),[n,a]=V.useState(!!e.rule),i=()=>{a(!0)},d=()=>{a(!1),r(void 0)},S=h=>{r(h),a(!0)};return R.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between",children:n?R.jsx(Hn,{onCancel:d,rule:t}):R.jsx(xa,{onClick:S,onCreate:i})})};var Pa=Object.getOwnPropertyDescriptor,Ma=(e,t,r,n)=>{for(var a=n>1?void 0:n?Pa(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},tt=(e,t)=>(r,n)=>t(r,n,e);const It="sheet.conditional.formatting.panel";let rt=class extends w.Disposable{constructor(t,r,n,a,i){super();Re(this,"_sidebarDisposable",null);this._univerInstanceService=t,this._injector=r,this._componentManager=n,this._sidebarService=a,this._localeService=i,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(w.UniverInstanceType.UNIVER_SHEET).subscribe(d=>{var S;d||(S=this._sidebarDisposable)==null||S.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(d=>{d.id===It&&(d.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(t){const r={id:It,header:{title:this._localeService.t("sheet.cf.title")},children:{label:It,rule:t,key:w.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(r)}_initPanel(){this._componentManager.register(It,Da)}};rt=Ma([tt(0,w.IUniverInstanceService),tt(1,w.Inject(w.Injector)),tt(2,w.Inject($.ComponentManager)),tt(3,w.Inject($.ISidebarService)),tt(4,w.Inject(w.LocaleService))],rt);var ve=(e=>(e[e.createRule=1]="createRule",e[e.viewRule=2]="viewRule",e[e.highlightCell=3]="highlightCell",e[e.rank=4]="rank",e[e.formula=5]="formula",e[e.colorScale=6]="colorScale",e[e.dataBar=7]="dataBar",e[e.icon=8]="icon",e[e.clearRangeRules=9]="clearRangeRules",e[e.clearWorkSheetRules=10]="clearWorkSheetRules",e))(ve||{});const nt={id:"sheet.operation.open.conditional.formatting.panel",type:w.CommandType.OPERATION,handler:(e,t)=>{var S;const r=e.get(rt),n=e.get(q.SheetsSelectionsService),a=e.get(w.ICommandService),i=((S=n.getCurrentSelections())==null?void 0:S.map(h=>h.range))||[];switch(t.value){case 3:{r.openPanel({...u.createDefaultRule(),ranges:i});break}case 4:{const h={...u.createDefaultRule,ranges:i,rule:{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.rank}};r.openPanel(h);break}case 5:{const h={...u.createDefaultRule,ranges:i,rule:{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.formula,value:"="}};r.openPanel(h);break}case 6:{const h={...u.createDefaultRule,ranges:i,rule:{type:u.CFRuleType.colorScale,config:[]}};r.openPanel(h);break}case 7:{const h={...u.createDefaultRule,ranges:i,rule:{type:u.CFRuleType.dataBar,isShowValue:!0}};r.openPanel(h);break}case 8:{const h={...u.createDefaultRule,ranges:i,rule:{type:u.CFRuleType.iconSet,config:[],isShowValue:!0}};r.openPanel(h);break}case 2:{r.openPanel();break}case 1:{r.openPanel({...u.createDefaultRule(),ranges:i});break}case 9:{a.executeCommand(u.ClearRangeCfCommand.id,{ranges:i});break}case 10:{a.executeCommand(u.ClearWorksheetCfCommand.id);break}}return!0}};var Na=Object.getOwnPropertyDescriptor,La=(e,t,r,n)=>{for(var a=n>1?void 0:n?Na(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},at=(e,t)=>(r,n)=>t(r,n,e);let it=class extends w.Disposable{constructor(t,r,n,a,i){super();Re(this,"_copyInfo");this._sheetClipboardService=t,this._conditionalFormattingRuleModel=r,this._injector=n,this._conditionalFormattingViewModel=a,this._univerInstanceService=i,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:u.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(t,r,n)=>this._collectConditionalRule(t,r,n),onPasteCells:(t,r,n,a)=>{const{copyType:i=de.COPY_TYPE.COPY,pasteType:d}=a,{range:S}=t||{},{range:h}=r;return this._generateConditionalFormattingMutations(h,{copyType:i,pasteType:d,copyRange:S})}}))}_collectConditionalRule(t,r,n){const a=new w.ObjectMatrix,i={};this._copyInfo={matrix:a,info:{unitId:t,subUnitId:r,cfMap:i}};const d=this._injector.invoke(m=>q.rangeToDiscreteRange(n,m,t,r));if(!d)return;const{rows:S,cols:h}=d,C=new Set;S.forEach((m,b)=>{h.forEach((E,I)=>{const _=this._conditionalFormattingViewModel.getCellCfs(t,r,m,E);_&&(_.forEach(T=>C.add(T.cfId)),a.setValue(b,I,_.map(T=>T.cfId)))})}),C.forEach(m=>{const b=this._conditionalFormattingRuleModel.getRule(t,r,m);b&&(i[m]=b.rule)})}_generateConditionalFormattingMutations(t,r){const n=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET),a=n.getActiveSheet(),i=n.getUnitId();if(!a)return{redos:[],undos:[]};const d=a.getSheetId();if(r.copyType===de.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!r.copyRange)return{redos:[],undos:[]};if(![de.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,de.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,de.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(r.pasteType))return{redos:[],undos:[]};const{ranges:[h,C],mapFunc:m}=de.virtualizeDiscreteRanges([r.copyRange,t]),b=de.getRepeatRange(h,C,!0),E={};w.Range.foreach(C,(l,v)=>{const{row:c,col:g}=m(l,v),P=this._conditionalFormattingViewModel.getCellCfs(i,d,c,g);P&&P.forEach(M=>{if(!E[M.cfId]){const U=new w.ObjectMatrix;E[M.cfId]=U;const z=this._conditionalFormattingRuleModel.getRule(i,d,M.cfId);z==null||z.ranges.forEach(O=>{w.Range.foreach(O,(L,W)=>{U.setValue(L,W,1)})})}E[M.cfId].realDeleteValue(c,g)})});const{matrix:I,info:_}=this._copyInfo,T=[];let p=this._conditionalFormattingRuleModel.createCfId(i,d);const o={},s=l=>{if(o[l])return o[l];const v=_==null?void 0:_.cfMap[l],c=[...this._conditionalFormattingRuleModel.getSubunitRules(i,d)||[],...T].find(g=>w.Tools.diffValue(g.rule,v));if(c)return o[l]=c,c;{const g={rule:v,cfId:p,ranges:[],stopIfTrue:!1};return o[l]=g,T.push(g),p=`${Number(p)+1}`,g}};b.forEach(l=>{I&&I.forValue((v,c,g)=>{const P=w.Rectangle.getPositionRange({startRow:v,endRow:v,startColumn:c,endColumn:c},l.startRange),{row:M,col:U}=m(P.startRow,P.startColumn);g.forEach(z=>{if(!E[z]){const O=s(z),L=new w.ObjectMatrix;E[z]=L,O.ranges.forEach(W=>{w.Range.foreach(W,(F,X)=>{L.setValue(F,X,1)})})}E[z].setValue(M,U,1)})})});const f=[],y=[];for(const l in E){const v=E[l],c=q.findAllRectangle(q.createTopMatrixFromMatrix(v));if(!c.length){const g={unitId:i,subUnitId:d,cfId:l};f.push({id:u.DeleteConditionalRuleMutation.id,params:g}),y.push(...u.DeleteConditionalRuleMutationUndoFactory(this._injector,g))}if(T.some(g=>g.cfId===l)){const g=s(l),P={unitId:i,subUnitId:d,rule:{...g,ranges:c}};f.push({id:u.AddConditionalRuleMutation.id,params:P}),y.push(u.AddConditionalRuleMutationUndoFactory(this._injector,P))}else{const g=this._conditionalFormattingRuleModel.getRule(i,d,l);if(!g)continue;const P={unitId:i,subUnitId:d,rule:{...g,ranges:c}};f.push({id:u.SetConditionalRuleMutation.id,params:P}),y.push(...u.setConditionalRuleMutationUndoFactory(this._injector,P))}}return{redos:f,undos:y}}};it=La([at(0,w.Inject(de.ISheetClipboardService)),at(1,w.Inject(u.ConditionalFormattingRuleModel)),at(2,w.Inject(w.Injector)),at(3,w.Inject(u.ConditionalFormattingViewModel)),at(4,w.Inject(w.IUniverInstanceService))],it);var Va=Object.getOwnPropertyDescriptor,Ua=(e,t,r,n)=>{for(var a=n>1?void 0:n?Va(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},ir=(e,t)=>(r,n)=>t(r,n,e);let ot=class extends w.Disposable{constructor(e,t,r){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=r,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===u.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[q.WorkbookEditablePermission],rangeTypes:[q.RangeProtectionPermissionEditPoint],worksheetTypes:[q.WorksheetEditPermission,q.WorksheetSetCellStylePermission]},e.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};ot=Ua([ir(0,w.Inject(w.LocaleService)),ir(1,w.ICommandService),ir(2,w.Inject(q.SheetPermissionCheckController))],ot);var za=Object.getOwnPropertyDescriptor,ka=(e,t,r,n)=>{for(var a=n>1?void 0:n?za(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},Rt=(e,t)=>(r,n)=>t(r,n,e);let st=class extends w.Disposable{constructor(e,t,r,n){super(),this._conditionalFormattingRuleModel=e,this._univerInstanceService=t,this._injector=r,this._refRangeService=n,this._initRefRange()}_initRefRange(){const e=new Map,t=(n,a,i)=>`${n}_${a}_${i}`,r=(n,a,i)=>{const d=h=>{const C=[...i.ranges],m=C.map(E=>q.handleDefaultRangeChangeWithEffectRefCommands(E,h)).filter(E=>!!E);if(u.isRangesEqual(m,C))return{redos:[],undos:[]};if(m.length){const E={unitId:n,subUnitId:a,rule:{...i,ranges:m}},I=[{id:u.SetConditionalRuleMutation.id,params:E}],_=u.setConditionalRuleMutationUndoFactory(this._injector,E);return{redos:I,undos:_}}else{const E={unitId:n,subUnitId:a,cfId:i.cfId},I=[{id:u.DeleteConditionalRuleMutation.id,params:E}],_=u.DeleteConditionalRuleMutationUndoFactory(this._injector,E);return{redos:I,undos:_}}},S=[];i.ranges.forEach(h=>{const C=this._refRangeService.registerRefRange(h,d);S.push(()=>C.dispose())}),e.set(t(n,a,i.cfId),()=>S.forEach(h=>h()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(n=>{const{unitId:a,subUnitId:i,rule:d}=n,S=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET),h=S.getActiveSheet();if(!(n.unitId!==S.getUnitId()||n.subUnitId!==(h==null?void 0:h.getSheetId())))switch(n.type){case"add":{r(n.unitId,n.subUnitId,n.rule);break}case"delete":{const C=e.get(t(a,i,d.cfId));C&&C();break}case"set":{const C=e.get(t(a,i,d.cfId));C&&C(),r(n.unitId,n.subUnitId,n.rule)}}})),this.disposeWithMe(w.toDisposable(()=>{e.forEach(n=>{n()}),e.clear()}))}};st=ka([Rt(0,w.Inject(u.ConditionalFormattingRuleModel)),Rt(1,w.Inject(w.IUniverInstanceService)),Rt(2,w.Inject(w.Injector)),Rt(3,w.Inject(q.RefRangeService))],st);var ja=Object.getOwnPropertyDescriptor,Aa=(e,t,r,n)=>{for(var a=n>1?void 0:n?ja(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},ke=(e,t)=>(r,n)=>t(r,n,e);let lt=class extends w.Disposable{constructor(t,r,n,a,i,d){super();Re(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=t,this._conditionalFormattingService=r,this._univerInstanceService=n,this._renderManagerService=a,this._conditionalFormattingViewModel=i,this._conditionalFormattingRuleModel=d,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var r,n,a;const t=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getUnitId();(r=this._renderManagerService.getRenderById(t))==null||r.with(de.SheetSkeletonManagerService).reCalculate(),(a=(n=this._renderManagerService.getRenderById(t))==null?void 0:n.mainComponent)==null||a.makeDirty()}_initSkeleton(){this.disposeWithMe(ye.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(We.bufferTime(16),We.filter(t=>!!t.length),We.filter(t=>{const r=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET);if(!r)return!1;const n=r.getActiveSheet();return n?t.filter(a=>a.unitId===r.getUnitId()&&a.subUnitId===n.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(q.INTERCEPTOR_POINT.CELL_CONTENT,{effect:w.InterceptorEffectEnum.Style,handler:(t,r,n)=>{const a=this._conditionalFormattingService.composeStyle(r.unitId,r.subUnitId,r.row,r.col);if(!a)return n(t);const i=r.workbook.getStyles(),S={...(typeof(t==null?void 0:t.s)=="string"?i.get(t==null?void 0:t.s):t==null?void 0:t.s)||{}},h={...t,s:S};return a.style&&Object.assign(S,a.style),h.fontRenderExtension||(h.fontRenderExtension={},a.isShowValue!==void 0&&(h.fontRenderExtension.isSkip=!a.isShowValue)),a.dataBar&&(h.dataBar=a.dataBar),a.iconSet&&(h.iconSet=a.iconSet,h.fontRenderExtension.leftOffset=u.DEFAULT_PADDING+u.DEFAULT_WIDTH),n(h)},priority:10}))}};lt=Aa([ke(0,w.Inject(q.SheetInterceptorService)),ke(1,w.Inject(u.ConditionalFormattingService)),ke(2,w.Inject(w.IUniverInstanceService)),ke(3,w.Inject(cr.IRenderManagerService)),ke(4,w.Inject(u.ConditionalFormattingViewModel)),ke(5,w.Inject(u.ConditionalFormattingRuleModel))],lt);const pn="sheets-conditional-formatting-ui.config",Et={};var Ha=Object.defineProperty,Wa=Object.getOwnPropertyDescriptor,Ba=(e,t,r)=>t in e?Ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fa=(e,t,r,n)=>{for(var a=n>1?void 0:n?Wa(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},or=(e,t)=>(r,n)=>t(r,n,e),hn=(e,t,r)=>Ba(e,typeof t!="symbol"?t+"":t,r);Y.UniverSheetsConditionalFormattingMobileUIPlugin=class extends w.Plugin{constructor(t=Et,r,n,a){super(),this._config=t,this._injector=r,this._commandService=n,this._configService=a;const{menu:i,...d}=w.merge({},Et,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(pn,d),this._initCommand(),this._injector.add([lt]),this._injector.add([st]),this._injector.add([it]),this._injector.add([ot]),this._injector.add([ze])}_initCommand(){[Ut,zt,kt,jt,At,Ht,Wt,Bt,Ft,nt].forEach(t=>{this._commandService.registerCommand(t)})}},hn(Y.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${u.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),hn(Y.UniverSheetsConditionalFormattingMobileUIPlugin,"type",w.UniverInstanceType.UNIVER_SHEET),Y.UniverSheetsConditionalFormattingMobileUIPlugin=Fa([w.DependentOn(u.UniverSheetsConditionalFormattingPlugin),or(1,w.Inject(w.Injector)),or(2,w.Inject(w.ICommandService)),or(3,w.IConfigService)],Y.UniverSheetsConditionalFormattingMobileUIPlugin);var Ga=Object.getOwnPropertyDescriptor,qa=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ga(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},ut=(e,t)=>(r,n)=>t(r,n,e);let Ot=class extends w.Disposable{constructor(e,t,r,n,a){super(),this._injector=e,this._univerInstanceService=t,this._autoFillService=r,this._conditionalFormattingRuleModel=n,this._conditionalFormattingViewModel=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,i,d,S,h)=>{var I;const C=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getUnitId(),m=(I=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:I.getSheetId();if(!C||!m)return;const b={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},E={startRow:i.row,startColumn:i.col,endColumn:i.col,endRow:i.row};w.Range.foreach(d,(_,T)=>{const p=w.Rectangle.getPositionRange({startRow:_,startColumn:T,endColumn:T,endRow:_},b),o=w.Rectangle.getPositionRange({startRow:_,startColumn:T,endColumn:T,endRow:_},E),{row:s,col:f}=h(p.startRow,p.startColumn),y=this._conditionalFormattingViewModel.getCellCfs(C,m,s,f),{row:l,col:v}=h(o.startRow,o.startColumn),c=this._conditionalFormattingViewModel.getCellCfs(C,m,l,v);c&&c.forEach(g=>{let P=S.get(g.cfId);if(!S.get(g.cfId)){const M=this._conditionalFormattingRuleModel.getRule(C,m,g.cfId);if(!M)return;P=new w.ObjectMatrix,M.ranges.forEach(U=>{w.Range.foreach(U,(z,O)=>{P.setValue(z,O,1)})}),S.set(g.cfId,P)}P.realDeleteValue(l,v)}),y&&y.forEach(g=>{let P=S.get(g.cfId);if(!S.get(g.cfId)){const M=this._conditionalFormattingRuleModel.getRule(C,m,g.cfId);if(!M)return;P=new w.ObjectMatrix,M.ranges.forEach(U=>{w.Range.foreach(U,(z,O)=>{P.setValue(z,O,1)})}),S.set(g.cfId,P)}P.setValue(l,v,1)})})},r=(a,i)=>{var o,s,f;const d=(o=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getUnitId(),S=(f=(s=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET))==null?void 0:s.getActiveSheet())==null?void 0:f.getSheetId(),h=new Map,C=[],m=[];if(!d||!S)return e();const b=de.virtualizeDiscreteRanges([a,i]),[E,I]=b.ranges,{mapFunc:_}=b,T={row:E.startRow,col:E.startColumn};return de.getAutoFillRepeatRange(E,I).forEach(y=>{t(T,y.repeatStartCell,y.relativeRange,h,_)}),h.forEach((y,l)=>{const v=this._conditionalFormattingRuleModel.getRule(d,S,l);if(!v)return;const c=q.findAllRectangle(q.createTopMatrixFromMatrix(y));if(c.length){const g={unitId:d,subUnitId:S,rule:{...v,ranges:c}};C.push({id:u.SetConditionalRuleMutation.id,params:g}),m.push(...u.setConditionalRuleMutationUndoFactory(this._injector,g))}else{const g={unitId:d,subUnitId:S,cfId:v.cfId};C.push({id:u.DeleteConditionalRuleMutation.id,params:g}),m.push(...u.DeleteConditionalRuleMutationUndoFactory(this._injector,g))}}),{undos:m,redos:C}},n={id:u.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(a,i,d)=>{if(d===de.APPLY_TYPE.COPY||d===de.APPLY_TYPE.ONLY_FORMAT||d===de.APPLY_TYPE.SERIES){const{source:S,target:h}=a;return r(S,h)}return e()}};this.disposeWithMe(this._autoFillService.addHook(n))}};Ot=qa([ut(0,w.Inject(w.Injector)),ut(1,w.Inject(w.IUniverInstanceService)),ut(2,w.Inject(de.IAutoFillService)),ut(3,w.Inject(u.ConditionalFormattingRuleModel)),ut(4,w.Inject(u.ConditionalFormattingViewModel))],Ot);var Ya=Object.getOwnPropertyDescriptor,Xa=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ya(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},ct=(e,t)=>(r,n)=>t(r,n,e);Y.ConditionalFormattingClearController=class extends w.Disposable{constructor(t,r,n,a,i){super(),this._injector=t,this._univerInstanceService=r,this._sheetInterceptorService=n,this._selectionManagerService=a,this._conditionalFormattingRuleModel=i,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{var i;const r=[],n=[],a={redos:r,undos:n};if([q.ClearSelectionFormatCommand.id,q.ClearSelectionAllCommand.id].includes(t.id)){const d=(i=this._selectionManagerService.getCurrentSelections())==null?void 0:i.map(_=>_.range);if(!d)return a;const S=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET),h=S.getActiveSheet();if(!h)return a;const C=S.getUnitId(),m=h.getSheetId(),b=this._conditionalFormattingRuleModel.getSubunitRules(C,m);if(!b||!b.length)return a;const{redos:E,undos:I}=vn(this._injector,b,d,C,m);r.push(...E),n.push(...I)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:t,subUnitId:r,ranges:n})=>{const a=[],i=[],d={redos:a,undos:i};if(!n||!n.length)return d;const S=this._conditionalFormattingRuleModel.getSubunitRules(t,r);if(!S||!S.length)return d;const{redos:h,undos:C}=vn(this._injector,S,n,t,r);return a.push(...h),i.push(...C),d}}))}},Y.ConditionalFormattingClearController=Xa([ct(0,w.Inject(w.Injector)),ct(1,w.Inject(w.IUniverInstanceService)),ct(2,w.Inject(q.SheetInterceptorService)),ct(3,w.Inject(q.SheetsSelectionsService)),ct(4,w.Inject(u.ConditionalFormattingRuleModel))],Y.ConditionalFormattingClearController);function vn(e,t,r,n,a){const i=[],d=[];return t.filter(S=>r.some(h=>S.ranges.some(C=>w.Rectangle.getIntersects(C,h)))).forEach(S=>{const C=new q.RangeMergeUtil().add(...S.ranges).subtract(...r).merge();if(C.length){const m={id:u.SetConditionalRuleMutation.id,params:{unitId:n,subUnitId:a,rule:{...S,ranges:C}}},b=u.setConditionalRuleMutationUndoFactory(e,m.params);i.push(m),d.push(...b)}else{const m={id:u.DeleteConditionalRuleMutation.id,params:{unitId:n,subUnitId:a,cfId:S.cfId}},b=u.DeleteConditionalRuleMutationUndoFactory(e,m.params);i.push(m),d.push(...b)}}),{redos:i,undos:d}}var Ka=Object.getOwnPropertyDescriptor,Za=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ka(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},gn=(e,t)=>(r,n)=>t(r,n,e);let xt=class extends w.Disposable{constructor(e,t){super(),this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(w.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(q.AFTER_CELL_EDIT,{handler:(e,t,r)=>{var d,S,h;e||r(e);const n=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col),a=(d=n==null?void 0:n.style)!=null?d:{},i=Object.keys(a);if(e!=null&&e.p)return(h=(S=e.p.body)==null?void 0:S.textRuns)==null||h.forEach(C=>{C.ts&&i.forEach(m=>{var b;(b=C.ts)==null||delete b[m]})}),r(e);{const C={...(typeof(e==null?void 0:e.s)=="string"?t.workbook.getStyles().get(e.s):e==null?void 0:e.s)||{}};i.forEach(b=>{delete C[b]});const m={...e,s:{...C}};return r(m)}}})))}};xt=Za([gn(0,w.Inject(q.SheetInterceptorService)),gn(1,w.Inject(u.ConditionalFormattingService))],xt);const mn=[q.SetWorksheetActiveOperation.id,u.AddConditionalRuleMutation.id,u.SetConditionalRuleMutation.id,u.DeleteConditionalRuleMutation.id,u.MoveConditionalRuleMutation.id],dt=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:ve.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:ve.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:ve.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:ve.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:ve.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:ve.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:ve.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:ve.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:ve.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:ve.clearWorkSheetRules}],Ja=e=>{const t=e.get(q.SheetsSelectionsService),r=e.get(w.ICommandService),n=e.get(w.IUniverInstanceService),a=e.get(u.ConditionalFormattingRuleModel),i=new ye.Observable(h=>ye.merge(t.selectionMoveEnd$,t.selectionSet$,new ye.Observable(C=>{const m=r.onCommandExecuted(b=>{var T;const{id:E,params:I}=b,_=(T=n.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET))==null?void 0:T.getUnitId();mn.includes(E)&&I.unitId===_&&C.next(null)});return()=>m.dispose()})).pipe(We.debounceTime(16)).subscribe(()=>{var T;const C=((T=t.getCurrentSelections())==null?void 0:T.map(p=>p.range))||[],m=n.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET);if(!m)return;const b=m.getActiveSheet();if(!b)return;const _=(a.getSubunitRules(m.getUnitId(),b.getSheetId())||[]).filter(p=>p.ranges.some(o=>C.some(s=>w.Rectangle.intersects(s,o)))).map(p=>p.ranges).every(p=>q.checkRangesEditablePermission(e,m.getUnitId(),b.getSheetId(),p));h.next(_)})),d=new ye.Observable(h=>new ye.Observable(C=>{const m=r.onCommandExecuted(b=>{var T;const{id:E,params:I}=b,_=(T=n.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET))==null?void 0:T.getUnitId();mn.includes(E)&&I.unitId===_&&C.next(null)});return()=>m.dispose()}).pipe(We.debounceTime(16)).subscribe(()=>{const C=n.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET);if(!C)return;const m=C.getActiveSheet();if(!m)return;const b=a.getSubunitRules(C.getUnitId(),m.getSheetId())||[];if(!b.length)return h.next(!1),!1;const E=b.map(I=>I.ranges).every(I=>q.checkRangesEditablePermission(e,C.getUnitId(),m.getSheetId(),I));h.next(E)})),S=new ye.Observable(h=>{i.subscribe(C=>{const m=dt.find(b=>b.value===ve.clearRangeRules);m&&(m.disabled=!C,h.next(dt))}),d.subscribe(C=>{const m=dt.find(b=>b.value===ve.clearWorkSheetRules);m&&(m.disabled=!C,h.next(dt))}),h.next(dt)});return{id:nt.id,type:$.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:S,hidden$:$.getMenuHiddenObservable(e,w.UniverInstanceType.UNIVER_SHEET),disabled$:de.getCurrentRangeDisable$(e,{workbookTypes:[q.WorkbookEditablePermission],worksheetTypes:[q.WorksheetSetCellStylePermission,q.WorksheetEditPermission],rangeTypes:[q.RangeProtectionPermissionEditPoint]})}},Qa={[$.RibbonStartGroup.FORMULAS_INSERT]:{[nt.id]:{order:0,menuItemFactory:Ja}}};var $a=Object.getOwnPropertyDescriptor,ei=(e,t,r,n)=>{for(var a=n>1?void 0:n?$a(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},yn=(e,t)=>(r,n)=>t(r,n,e);let Dt=class extends w.Disposable{constructor(t,r){super();Re(this,"_sidebarDisposable",null);this._injector=t,this._menuManagerService=r,this._menuManagerService.mergeMenu(Qa)}};Dt=ei([yn(0,w.Inject(w.Injector)),yn(1,$.IMenuManagerService)],Dt);var ti=Object.getOwnPropertyDescriptor,ri=(e,t,r,n)=>{for(var a=n>1?void 0:n?ti(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},je=(e,t)=>(r,n)=>t(r,n,e);const ni=(e,t)=>{const r=m=>m.endRow-m.startRow+1,n=m=>m.endColumn-m.startColumn+1,a=r(t)%r(e),i=n(t)%n(e),d=Math.floor(r(t)/r(e)),S=Math.floor(n(t)/n(e)),h=[],C={startRow:0,endRow:r(e)-1,startColumn:0,endColumn:n(e)-1};if(r(t)===1&&n(t)===1){const m={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};return h.push({repeatRelativeRange:C,startRange:m}),h}for(let m=0;m<d+(a?.1:0);m++)for(let b=0;b<S+(i?.1:0);b++){const E=r(e)*m,I=n(e)*b,_={startRow:E+t.startRow,endRow:E+t.startRow,startColumn:I+t.startColumn,endColumn:I+t.startColumn};let T=C;m===d&&a&&(T={...T},T.endRow=T.endRow-(r(e)-a)),b===S&&i&&(T={...T},T.endColumn=T.endColumn-(n(e)-i)),h.push({repeatRelativeRange:T,startRange:_})}return h};let Pt=class extends w.Disposable{constructor(t,r,n,a,i,d){super();Re(this,"_painterConfig",null);this._injector=t,this._univerInstanceService=r,this._formatPainterService=n,this._sheetsSelectionsService=a,this._conditionalFormattingRuleModel=i,this._conditionalFormattingViewModel=d,this._initFormattingPainter()}_initFormattingPainter(){const t=()=>({redos:[],undos:[]}),r=(i,d,S,h,C)=>{const{unitId:m,subUnitId:b}=this._painterConfig,{targetUnitId:E,targetSubUnitId:I}=C,_={startRow:i.row,startColumn:i.col,endColumn:i.col,endRow:i.row},T={startRow:d.row,startColumn:d.col,endColumn:d.col,endRow:d.row};w.Range.foreach(S,(p,o)=>{const s=w.Rectangle.getPositionRange({startRow:p,startColumn:o,endColumn:o,endRow:p},_),f=w.Rectangle.getPositionRange({startRow:p,startColumn:o,endColumn:o,endRow:p},T),y=this._conditionalFormattingViewModel.getCellCfs(m,b,s.startRow,s.startColumn),l=this._conditionalFormattingViewModel.getCellCfs(E,I,f.startRow,f.startColumn);l&&l.forEach(v=>{let c=h.get(v.cfId);if(!h.get(v.cfId)){const g=this._conditionalFormattingRuleModel.getRule(E,I,v.cfId);if(!g)return;c=new w.ObjectMatrix,g.ranges.forEach(P=>{w.Range.foreach(P,(M,U)=>{c.setValue(M,U,1)})}),h.set(v.cfId,c)}c.realDeleteValue(f.startRow,f.startColumn)}),y&&y.forEach(v=>{const c=h.get(v.cfId);c&&c.setValue(f.startRow,f.startColumn,1)})})},n=(i,d,S)=>{var s;const{range:h,unitId:C,subUnitId:m}=this._painterConfig,b=i!==C||m!==d,E=new Map,I=[],_=[];if(!i||!d||!C||!m)return t();const T=(s=this._conditionalFormattingRuleModel.getSubunitRules(C,m))!=null?s:[];T==null||T.forEach(f=>{const{ranges:y,cfId:l}=f;if(y.some(v=>w.Rectangle.intersects(h,v))){const v=new w.ObjectMatrix;b||y.forEach(c=>{w.Range.foreach(c,(g,P)=>{v.setValue(g,P,1)})}),E.set(l,v)}});const p={row:h.startRow,col:h.startColumn};return ni(h,S).forEach(f=>{r(p,{row:f.startRange.startRow,col:f.startRange.startColumn},f.repeatRelativeRange,E,{targetUnitId:i,targetSubUnitId:d})}),E.forEach((f,y)=>{if(b){const l=this._conditionalFormattingRuleModel.getRule(i,d,y),v=q.findAllRectangle(q.createTopMatrixFromMatrix(f));if(l)if(v.length){const c={unitId:i,subUnitId:d,rule:{...l,ranges:v}};I.push({id:u.SetConditionalRuleMutation.id,params:c}),_.push(...u.setConditionalRuleMutationUndoFactory(this._injector,c))}else{const c={unitId:i,subUnitId:d,cfId:l.cfId};I.push({id:u.DeleteConditionalRuleMutation.id,params:c}),_.push(...u.DeleteConditionalRuleMutationUndoFactory(this._injector,c))}else if(v.length){const c=this._conditionalFormattingRuleModel.getRule(C,m,y);if(c){const g={unitId:i,subUnitId:d,rule:{...w.Tools.deepClone(c),cfId:this._conditionalFormattingRuleModel.createCfId(i,d),ranges:v}};I.push({id:u.AddConditionalRuleMutation.id,params:g}),_.push(u.AddConditionalRuleMutationUndoFactory(this._injector,g))}}}else{const l=this._conditionalFormattingRuleModel.getRule(C,m,y);if(!l)return;const v=q.findAllRectangle(q.createTopMatrixFromMatrix(f));if(v.length){const c={unitId:C,subUnitId:m,rule:{...l,ranges:v}};I.push({id:u.SetConditionalRuleMutation.id,params:c}),_.push(...u.setConditionalRuleMutationUndoFactory(this._injector,c))}else{const c={unitId:C,subUnitId:m,cfId:l.cfId};I.push({id:u.DeleteConditionalRuleMutation.id,params:c}),_.push(...u.DeleteConditionalRuleMutationUndoFactory(this._injector,c))}}}),{undos:_,redos:I}},a={id:u.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:i=>{var d,S,h;switch(i){case de.FormatPainterStatus.INFINITE:case de.FormatPainterStatus.ONCE:{const C=(d=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET))==null?void 0:d.getUnitId(),m=(h=(S=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getActiveSheet())==null?void 0:h.getSheetId(),b=this._sheetsSelectionsService.getCurrentLastSelection(),E=b==null?void 0:b.range;C&&m&&E&&(this._painterConfig={unitId:C,subUnitId:m,range:E});break}case de.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(i,d,S)=>this._painterConfig?n(i,d,S):{redos:[],undos:[]}};this._formatPainterService.addHook(a)}};Pt=ri([je(0,w.Inject(w.Injector)),je(1,w.Inject(w.IUniverInstanceService)),je(2,w.Inject(de.IFormatPainterService)),je(3,w.Inject(q.SheetsSelectionsService)),je(4,w.Inject(u.ConditionalFormattingRuleModel)),je(5,w.Inject(u.ConditionalFormattingViewModel))],Pt);var ai=Object.getOwnPropertyDescriptor,ii=(e,t,r,n)=>{for(var a=n>1?void 0:n?ai(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},sr=(e,t)=>(r,n)=>t(r,n,e);let Mt=class extends w.Disposable{constructor(e,t,r){super(),this._conditionalFormattingViewModel=e,this._univerInstanceService=t,this._renderManagerService=r,this._init()}_init(){const e=this._univerInstanceService.getCurrentUnitForType(w.UniverInstanceType.UNIVER_SHEET),t=r=>{const n=r.getUnitId(),a=this._renderManagerService.getRenderById(n);if(!a)return;const i=a.with(de.SheetSkeletonManagerService);this.disposeWithMe(i.currentSkeleton$.subscribe(d=>{if(d){const S=d.skeleton.rowColumnSegment,h=S.endColumn-S.startColumn+1,m=(S.endRow-S.startRow+1)*h*9,b=Math.max(u.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,m);this._conditionalFormattingViewModel.setCacheLength(b)}}))};e&&t(e),this._univerInstanceService.getCurrentTypeOfUnit$(w.UniverInstanceType.UNIVER_SHEET).subscribe(r=>{r&&t(r)})}};Mt=ii([sr(0,w.Inject(u.ConditionalFormattingViewModel)),sr(1,w.IUniverInstanceService),sr(2,cr.IRenderManagerService)],Mt);var oi=Object.defineProperty,si=Object.getOwnPropertyDescriptor,li=(e,t,r)=>t in e?oi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ui=(e,t,r,n)=>{for(var a=n>1?void 0:n?si(t,r):t,i=e.length-1,d;i>=0;i--)(d=e[i])&&(a=d(a)||a);return a},lr=(e,t)=>(r,n)=>t(r,n,e),bn=(e,t,r)=>li(e,typeof t!="symbol"?t+"":t,r);Y.UniverSheetsConditionalFormattingUIPlugin=class extends w.Plugin{constructor(t=Et,r,n,a){super(),this._config=t,this._injector=r,this._commandService=n,this._configService=a;const{menu:i,...d}=w.merge({},Et,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(pn,d),this._initCommand()}onStarting(){w.registerDependencies(this._injector,[[lt],[st],[it],[Ot],[ot],[rt],[Dt],[ze],[xt],[Y.ConditionalFormattingClearController],[Pt],[Mt]]),w.touchDependencies(this._injector,[[lt]])}onReady(){w.touchDependencies(this._injector,[[Dt],[rt]])}onRendered(){w.touchDependencies(this._injector,[[Ot],[Y.ConditionalFormattingClearController],[it],[xt],[ze],[Pt],[ot],[st],[Mt]])}_initCommand(){[Ut,zt,kt,jt,At,Ht,Wt,Bt,Ft,nt].forEach(t=>{this._commandService.registerCommand(t)})}},bn(Y.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${u.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),bn(Y.UniverSheetsConditionalFormattingUIPlugin,"type",w.UniverInstanceType.UNIVER_SHEET),Y.UniverSheetsConditionalFormattingUIPlugin=ui([w.DependentOn(u.UniverSheetsConditionalFormattingPlugin),lr(1,w.Inject(w.Injector)),lr(2,w.Inject(w.ICommandService)),lr(3,w.IConfigService)],Y.UniverSheetsConditionalFormattingUIPlugin),Y.AddAverageCfCommand=Ut,Y.AddColorScaleConditionalRuleCommand=zt,Y.AddDataBarConditionalRuleCommand=kt,Y.AddDuplicateValuesCfCommand=jt,Y.AddNumberCfCommand=At,Y.AddRankCfCommand=Ht,Y.AddTextCfCommand=Wt,Y.AddTimePeriodCfCommand=Bt,Y.AddUniqueValuesCfCommand=Ft,Y.OpenConditionalFormattingOperator=nt,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
76
+ `,{"univer-flex univer-items-center univer-justify-center":M===$}),onClick:H=>{H.stopPropagation(),y(L),b([])},children:s.jsx(Re,{})})]})},`${L.cfId}`))})})]})},Kr=t=>{const[e,u]=m.useState(t.rule),[n,l]=m.useState(!!t.rule),a=()=>{l(!0)},c=()=>{l(!1),u(void 0)},p=o=>{u(o),l(!0)};return s.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between",children:n?s.jsx(Wr,{onCancel:c,rule:e}):s.jsx(Zr,{onClick:p,onCreate:a})})};var Xr=Object.getOwnPropertyDescriptor,Jr=(t,e,u,n)=>{for(var l=n>1?void 0:n?Xr(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},ye=(t,e)=>(u,n)=>e(u,n,t);const Ue="sheet.conditional.formatting.panel";let me=class extends i.Disposable{constructor(e,u,n,l,a){super();ee(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=u,this._componentManager=n,this._sidebarService=l,this._localeService=a,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(c=>{var p;c||(p=this._sidebarDisposable)==null||p.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(c=>{c.id===Ue&&(c.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const u={id:Ue,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ue,rule:e,key:i.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(u)}_initPanel(){this._componentManager.register(Ue,Kr)}};me=Jr([ye(0,i.IUniverInstanceService),ye(1,i.Inject(i.Injector)),ye(2,i.Inject(j.ComponentManager)),ye(3,i.Inject(j.ISidebarService)),ye(4,i.Inject(i.LocaleService))],me);var Z=(t=>(t[t.createRule=1]="createRule",t[t.viewRule=2]="viewRule",t[t.highlightCell=3]="highlightCell",t[t.rank=4]="rank",t[t.formula=5]="formula",t[t.colorScale=6]="colorScale",t[t.dataBar=7]="dataBar",t[t.icon=8]="icon",t[t.clearRangeRules=9]="clearRangeRules",t[t.clearWorkSheetRules=10]="clearWorkSheetRules",t))(Z||{});const Se={id:"sheet.operation.open.conditional.formatting.panel",type:i.CommandType.OPERATION,handler:(t,e)=>{var p;const u=t.get(me),n=t.get(k.SheetsSelectionsService),l=t.get(i.ICommandService),a=((p=n.getCurrentSelections())==null?void 0:p.map(o=>o.range))||[];switch(e.value){case 3:{u.openPanel({...r.createDefaultRule(),ranges:a});break}case 4:{const o={...r.createDefaultRule,ranges:a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};u.openPanel(o);break}case 5:{const o={...r.createDefaultRule,ranges:a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:"="}};u.openPanel(o);break}case 6:{const o={...r.createDefaultRule,ranges:a,rule:{type:r.CFRuleType.colorScale,config:[]}};u.openPanel(o);break}case 7:{const o={...r.createDefaultRule,ranges:a,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};u.openPanel(o);break}case 8:{const o={...r.createDefaultRule,ranges:a,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};u.openPanel(o);break}case 2:{u.openPanel();break}case 1:{u.openPanel({...r.createDefaultRule(),ranges:a});break}case 9:{l.executeCommand(r.ClearRangeCfCommand.id,{ranges:a});break}case 10:{l.executeCommand(r.ClearWorksheetCfCommand.id);break}}return!0}};var Qr=Object.getOwnPropertyDescriptor,et=(t,e,u,n)=>{for(var l=n>1?void 0:n?Qr(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},be=(t,e)=>(u,n)=>e(u,n,t);let Ie=class extends i.Disposable{constructor(e,u,n,l,a){super();ee(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=u,this._injector=n,this._conditionalFormattingViewModel=l,this._univerInstanceService=a,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,u,n)=>this._collectConditionalRule(e,u,n),onPasteCells:(e,u,n,l)=>{const{copyType:a=W.COPY_TYPE.COPY,pasteType:c}=l,{range:p}=e||{},{range:o}=u;return this._generateConditionalFormattingMutations(o,{copyType:a,pasteType:c,copyRange:p})}}))}_collectConditionalRule(e,u,n){const l=new i.ObjectMatrix,a={};this._copyInfo={matrix:l,info:{unitId:e,subUnitId:u,cfMap:a}};const c=this._injector.invoke(d=>k.rangeToDiscreteRange(n,d,e,u));if(!c)return;const{rows:p,cols:o}=c,v=new Set;p.forEach((d,f)=>{o.forEach((h,S)=>{const _=this._conditionalFormattingViewModel.getCellCfs(e,u,d,h);_&&(_.forEach(b=>v.add(b.cfId)),l.setValue(f,S,_.map(b=>b.cfId)))})}),v.forEach(d=>{const f=this._conditionalFormattingRuleModel.getRule(e,u,d);f&&(a[d]=f.rule)})}_generateConditionalFormattingMutations(e,u){const n=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),l=n.getActiveSheet(),a=n.getUnitId();if(!l)return{redos:[],undos:[]};const c=l.getSheetId();if(u.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!u.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(u.pasteType))return{redos:[],undos:[]};const{ranges:[o,v],mapFunc:d}=W.virtualizeDiscreteRanges([u.copyRange,e]),f=W.getRepeatRange(o,v,!0),h={};i.Range.foreach(v,(g,I)=>{const{row:T,col:C}=d(g,I),O=this._conditionalFormattingViewModel.getCellCfs(a,c,T,C);O&&O.forEach(V=>{if(!h[V.cfId]){const U=new i.ObjectMatrix;h[V.cfId]=U;const A=this._conditionalFormattingRuleModel.getRule(a,c,V.cfId);A==null||A.ranges.forEach(y=>{i.Range.foreach(y,(E,F)=>{U.setValue(E,F,1)})})}h[V.cfId].realDeleteValue(T,C)})});const{matrix:S,info:_}=this._copyInfo,b=[];let x=this._conditionalFormattingRuleModel.createCfId(a,c);const N={},R=g=>{if(N[g])return N[g];const I=_==null?void 0:_.cfMap[g],T=[...this._conditionalFormattingRuleModel.getSubunitRules(a,c)||[],...b].find(C=>i.Tools.diffValue(C.rule,I));if(T)return N[g]=T,T;{const C={rule:I,cfId:x,ranges:[],stopIfTrue:!1};return N[g]=C,b.push(C),x=`${Number(x)+1}`,C}};f.forEach(g=>{S&&S.forValue((I,T,C)=>{const O=i.Rectangle.getPositionRange({startRow:I,endRow:I,startColumn:T,endColumn:T},g.startRange),{row:V,col:U}=d(O.startRow,O.startColumn);C.forEach(A=>{if(!h[A]){const y=R(A),E=new i.ObjectMatrix;h[A]=E,y.ranges.forEach(F=>{i.Range.foreach(F,(G,J)=>{E.setValue(G,J,1)})})}h[A].setValue(V,U,1)})})});const w=[],M=[];for(const g in h){const I=h[g],T=k.findAllRectangle(k.createTopMatrixFromMatrix(I));if(!T.length){const C={unitId:a,subUnitId:c,cfId:g};w.push({id:r.DeleteConditionalRuleMutation.id,params:C}),M.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,C))}if(b.some(C=>C.cfId===g)){const C=R(g),O={unitId:a,subUnitId:c,rule:{...C,ranges:T}};w.push({id:r.AddConditionalRuleMutation.id,params:O}),M.push(r.AddConditionalRuleMutationUndoFactory(this._injector,O))}else{const C=this._conditionalFormattingRuleModel.getRule(a,c,g);if(!C)continue;const O={unitId:a,subUnitId:c,rule:{...C,ranges:T}};w.push({id:r.SetConditionalRuleMutation.id,params:O}),M.push(...r.setConditionalRuleMutationUndoFactory(this._injector,O))}}return{redos:w,undos:M}}};Ie=et([be(0,i.Inject(W.ISheetClipboardService)),be(1,i.Inject(r.ConditionalFormattingRuleModel)),be(2,i.Inject(i.Injector)),be(3,i.Inject(r.ConditionalFormattingViewModel)),be(4,i.Inject(i.IUniverInstanceService))],Ie);var rt=Object.getOwnPropertyDescriptor,tt=(t,e,u,n)=>{for(var l=n>1?void 0:n?rt(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},er=(t,e)=>(u,n)=>e(u,n,t);let Ce=class extends i.Disposable{constructor(t,e,u){super(),this._localeService=t,this._commandService=e,this._sheetPermissionCheckController=u,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===r.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[k.WorkbookEditablePermission],rangeTypes:[k.RangeProtectionPermissionEditPoint],worksheetTypes:[k.WorksheetEditPermission,k.WorksheetSetCellStylePermission]},t.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Ce=tt([er(0,i.Inject(i.LocaleService)),er(1,i.ICommandService),er(2,i.Inject(k.SheetPermissionCheckController))],Ce);var nt=Object.getOwnPropertyDescriptor,lt=(t,e,u,n)=>{for(var l=n>1?void 0:n?nt(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},ke=(t,e)=>(u,n)=>e(u,n,t);let Te=class extends i.Disposable{constructor(t,e,u,n){super(),this._conditionalFormattingRuleModel=t,this._univerInstanceService=e,this._injector=u,this._refRangeService=n,this._initRefRange()}_initRefRange(){const t=new Map,e=(n,l,a)=>`${n}_${l}_${a}`,u=(n,l,a)=>{const c=o=>{const v=[...a.ranges],d=v.map(h=>k.handleDefaultRangeChangeWithEffectRefCommands(h,o)).filter(h=>!!h);if(r.isRangesEqual(d,v))return{redos:[],undos:[]};if(d.length){const h={unitId:n,subUnitId:l,rule:{...a,ranges:d}},S=[{id:r.SetConditionalRuleMutation.id,params:h}],_=r.setConditionalRuleMutationUndoFactory(this._injector,h);return{redos:S,undos:_}}else{const h={unitId:n,subUnitId:l,cfId:a.cfId},S=[{id:r.DeleteConditionalRuleMutation.id,params:h}],_=r.DeleteConditionalRuleMutationUndoFactory(this._injector,h);return{redos:S,undos:_}}},p=[];a.ranges.forEach(o=>{const v=this._refRangeService.registerRefRange(o,c);p.push(()=>v.dispose())}),t.set(e(n,l,a.cfId),()=>p.forEach(o=>o()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(n=>{const{unitId:l,subUnitId:a,rule:c}=n,p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!(n.unitId!==p.getUnitId()||n.subUnitId!==(o==null?void 0:o.getSheetId())))switch(n.type){case"add":{u(n.unitId,n.subUnitId,n.rule);break}case"delete":{const v=t.get(e(l,a,c.cfId));v&&v();break}case"set":{const v=t.get(e(l,a,c.cfId));v&&v(),u(n.unitId,n.subUnitId,n.rule)}}})),this.disposeWithMe(i.toDisposable(()=>{t.forEach(n=>{n()}),t.clear()}))}};Te=lt([ke(0,i.Inject(r.ConditionalFormattingRuleModel)),ke(1,i.Inject(i.IUniverInstanceService)),ke(2,i.Inject(i.Injector)),ke(3,i.Inject(k.RefRangeService))],Te);var ut=Object.getOwnPropertyDescriptor,at=(t,e,u,n)=>{for(var l=n>1?void 0:n?ut(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},ce=(t,e)=>(u,n)=>e(u,n,t);let _e=class extends i.Disposable{constructor(e,u,n,l,a,c){super();ee(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=u,this._univerInstanceService=n,this._renderManagerService=l,this._conditionalFormattingViewModel=a,this._conditionalFormattingRuleModel=c,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var u,n,l;const e=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();(u=this._renderManagerService.getRenderById(e))==null||u.with(W.SheetSkeletonManagerService).reCalculate(),(l=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||l.makeDirty()}_initSkeleton(){this.disposeWithMe(X.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(fe.bufferTime(16),fe.filter(e=>!!e.length),fe.filter(e=>{const u=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!u)return!1;const n=u.getActiveSheet();return n?e.filter(l=>l.unitId===u.getUnitId()&&l.subUnitId===n.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(k.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,handler:(e,u,n)=>{const l=this._conditionalFormattingService.composeStyle(u.unitId,u.subUnitId,u.row,u.col);if(!l)return n(e);const a=u.workbook.getStyles(),p={...(typeof(e==null?void 0:e.s)=="string"?a.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}},o={...e,s:p};return l.style&&Object.assign(p,l.style),o.fontRenderExtension||(o.fontRenderExtension={},l.isShowValue!==void 0&&(o.fontRenderExtension.isSkip=!l.isShowValue)),l.dataBar&&(o.dataBar=l.dataBar),l.iconSet&&(o.iconSet=l.iconSet,o.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(o)},priority:10}))}};_e=at([ce(0,i.Inject(k.SheetInterceptorService)),ce(1,i.Inject(r.ConditionalFormattingService)),ce(2,i.Inject(i.IUniverInstanceService)),ce(3,i.Inject(lr.IRenderManagerService)),ce(4,i.Inject(r.ConditionalFormattingViewModel)),ce(5,i.Inject(r.ConditionalFormattingRuleModel))],_e);const gr="sheets-conditional-formatting-ui.config",Pe={};var it=Object.defineProperty,st=Object.getOwnPropertyDescriptor,ct=(t,e,u)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,ot=(t,e,u,n)=>{for(var l=n>1?void 0:n?st(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},rr=(t,e)=>(u,n)=>e(u,n,t),yr=(t,e,u)=>ct(t,typeof e!="symbol"?e+"":e,u);P.UniverSheetsConditionalFormattingMobileUIPlugin=class extends i.Plugin{constructor(e=Pe,u,n,l){super(),this._config=e,this._injector=u,this._commandService=n,this._configService=l;const{menu:a,...c}=i.merge({},Pe,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig(gr,c),this._initCommand(),this._injector.add([_e]),this._injector.add([Te]),this._injector.add([Ie]),this._injector.add([Ce]),this._injector.add([se])}_initCommand(){[He,We,qe,Ge,ze,Ye,Ze,Ke,Xe,Se].forEach(e=>{this._commandService.registerCommand(e)})}},yr(P.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),yr(P.UniverSheetsConditionalFormattingMobileUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),P.UniverSheetsConditionalFormattingMobileUIPlugin=ot([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin),rr(1,i.Inject(i.Injector)),rr(2,i.Inject(i.ICommandService)),rr(3,i.IConfigService)],P.UniverSheetsConditionalFormattingMobileUIPlugin);var dt=Object.getOwnPropertyDescriptor,vt=(t,e,u,n)=>{for(var l=n>1?void 0:n?dt(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},Ee=(t,e)=>(u,n)=>e(u,n,t);let De=class extends i.Disposable{constructor(t,e,u,n,l){super(),this._injector=t,this._univerInstanceService=e,this._autoFillService=u,this._conditionalFormattingRuleModel=n,this._conditionalFormattingViewModel=l,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),e=(l,a,c,p,o)=>{var S;const v=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(S=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId();if(!v||!d)return;const f={startRow:l.row,startColumn:l.col,endColumn:l.col,endRow:l.row},h={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row};i.Range.foreach(c,(_,b)=>{const x=i.Rectangle.getPositionRange({startRow:_,startColumn:b,endColumn:b,endRow:_},f),N=i.Rectangle.getPositionRange({startRow:_,startColumn:b,endColumn:b,endRow:_},h),{row:R,col:w}=o(x.startRow,x.startColumn),M=this._conditionalFormattingViewModel.getCellCfs(v,d,R,w),{row:g,col:I}=o(N.startRow,N.startColumn),T=this._conditionalFormattingViewModel.getCellCfs(v,d,g,I);T&&T.forEach(C=>{let O=p.get(C.cfId);if(!p.get(C.cfId)){const V=this._conditionalFormattingRuleModel.getRule(v,d,C.cfId);if(!V)return;O=new i.ObjectMatrix,V.ranges.forEach(U=>{i.Range.foreach(U,(A,y)=>{O.setValue(A,y,1)})}),p.set(C.cfId,O)}O.realDeleteValue(g,I)}),M&&M.forEach(C=>{let O=p.get(C.cfId);if(!p.get(C.cfId)){const V=this._conditionalFormattingRuleModel.getRule(v,d,C.cfId);if(!V)return;O=new i.ObjectMatrix,V.ranges.forEach(U=>{i.Range.foreach(U,(A,y)=>{O.setValue(A,y,1)})}),p.set(C.cfId,O)}O.setValue(g,I,1)})})},u=(l,a)=>{var N,R,w;const c=(N=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:N.getUnitId(),p=(w=(R=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:R.getActiveSheet())==null?void 0:w.getSheetId(),o=new Map,v=[],d=[];if(!c||!p)return t();const f=W.virtualizeDiscreteRanges([l,a]),[h,S]=f.ranges,{mapFunc:_}=f,b={row:h.startRow,col:h.startColumn};return W.getAutoFillRepeatRange(h,S).forEach(M=>{e(b,M.repeatStartCell,M.relativeRange,o,_)}),o.forEach((M,g)=>{const I=this._conditionalFormattingRuleModel.getRule(c,p,g);if(!I)return;const T=k.findAllRectangle(k.createTopMatrixFromMatrix(M));if(T.length){const C={unitId:c,subUnitId:p,rule:{...I,ranges:T}};v.push({id:r.SetConditionalRuleMutation.id,params:C}),d.push(...r.setConditionalRuleMutationUndoFactory(this._injector,C))}else{const C={unitId:c,subUnitId:p,cfId:I.cfId};v.push({id:r.DeleteConditionalRuleMutation.id,params:C}),d.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,C))}}),{undos:d,redos:v}},n={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(l,a,c)=>{if(c===W.APPLY_TYPE.COPY||c===W.APPLY_TYPE.ONLY_FORMAT||c===W.APPLY_TYPE.SERIES){const{source:p,target:o}=l;return u(p,o)}return t()}};this.disposeWithMe(this._autoFillService.addHook(n))}};De=vt([Ee(0,i.Inject(i.Injector)),Ee(1,i.Inject(i.IUniverInstanceService)),Ee(2,i.Inject(W.IAutoFillService)),Ee(3,i.Inject(r.ConditionalFormattingRuleModel)),Ee(4,i.Inject(r.ConditionalFormattingViewModel))],De);var pt=Object.getOwnPropertyDescriptor,ft=(t,e,u,n)=>{for(var l=n>1?void 0:n?pt(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},Ne=(t,e)=>(u,n)=>e(u,n,t);P.ConditionalFormattingClearController=class extends i.Disposable{constructor(e,u,n,l,a){super(),this._injector=e,this._univerInstanceService=u,this._sheetInterceptorService=n,this._selectionManagerService=l,this._conditionalFormattingRuleModel=a,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var a;const u=[],n=[],l={redos:u,undos:n};if([k.ClearSelectionFormatCommand.id,k.ClearSelectionAllCommand.id].includes(e.id)){const c=(a=this._selectionManagerService.getCurrentSelections())==null?void 0:a.map(_=>_.range);if(!c)return l;const p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!o)return l;const v=p.getUnitId(),d=o.getSheetId(),f=this._conditionalFormattingRuleModel.getSubunitRules(v,d);if(!f||!f.length)return l;const{redos:h,undos:S}=mr(this._injector,f,c,v,d);u.push(...h),n.push(...S)}return l}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:u,ranges:n})=>{const l=[],a=[],c={redos:l,undos:a};if(!n||!n.length)return c;const p=this._conditionalFormattingRuleModel.getSubunitRules(e,u);if(!p||!p.length)return c;const{redos:o,undos:v}=mr(this._injector,p,n,e,u);return l.push(...o),a.push(...v),c}}))}},P.ConditionalFormattingClearController=ft([Ne(0,i.Inject(i.Injector)),Ne(1,i.Inject(i.IUniverInstanceService)),Ne(2,i.Inject(k.SheetInterceptorService)),Ne(3,i.Inject(k.SheetsSelectionsService)),Ne(4,i.Inject(r.ConditionalFormattingRuleModel))],P.ConditionalFormattingClearController);function mr(t,e,u,n,l){const a=[],c=[];return e.filter(p=>u.some(o=>p.ranges.some(v=>i.Rectangle.getIntersects(v,o)))).forEach(p=>{const v=new k.RangeMergeUtil().add(...p.ranges).subtract(...u).merge();if(v.length){const d={id:r.SetConditionalRuleMutation.id,params:{unitId:n,subUnitId:l,rule:{...p,ranges:v}}},f=r.setConditionalRuleMutationUndoFactory(t,d.params);a.push(d),c.push(...f)}else{const d={id:r.DeleteConditionalRuleMutation.id,params:{unitId:n,subUnitId:l,cfId:p.cfId}},f=r.DeleteConditionalRuleMutationUndoFactory(t,d.params);a.push(d),c.push(...f)}}),{redos:a,undos:c}}var ht=Object.getOwnPropertyDescriptor,gt=(t,e,u,n)=>{for(var l=n>1?void 0:n?ht(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},Sr=(t,e)=>(u,n)=>e(u,n,t);let je=class extends i.Disposable{constructor(t,e){super(),this._sheetInterceptorService=t,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(i.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(k.AFTER_CELL_EDIT,{handler:(t,e,u)=>{var c,p,o;t||u(t);const n=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),l=(c=n==null?void 0:n.style)!=null?c:{},a=Object.keys(l);if(t!=null&&t.p)return(o=(p=t.p.body)==null?void 0:p.textRuns)==null||o.forEach(v=>{v.ts&&a.forEach(d=>{var f;(f=v.ts)==null||delete f[d]})}),u(t);{const v={...(typeof(t==null?void 0:t.s)=="string"?e.workbook.getStyles().get(t.s):t==null?void 0:t.s)||{}};a.forEach(f=>{delete v[f]});const d={...t,s:{...v}};return u(d)}}})))}};je=gt([Sr(0,i.Inject(k.SheetInterceptorService)),Sr(1,i.Inject(r.ConditionalFormattingService))],je);const br=[k.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],xe=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:Z.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:Z.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:Z.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:Z.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:Z.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:Z.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:Z.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:Z.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:Z.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:Z.clearWorkSheetRules}],yt=t=>{const e=t.get(k.SheetsSelectionsService),u=t.get(i.ICommandService),n=t.get(i.IUniverInstanceService),l=t.get(r.ConditionalFormattingRuleModel),a=new X.Observable(o=>X.merge(e.selectionMoveEnd$,e.selectionSet$,new X.Observable(v=>{const d=u.onCommandExecuted(f=>{var b;const{id:h,params:S}=f,_=(b=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:b.getUnitId();br.includes(h)&&S.unitId===_&&v.next(null)});return()=>d.dispose()})).pipe(fe.debounceTime(16)).subscribe(()=>{var b;const v=((b=e.getCurrentSelections())==null?void 0:b.map(x=>x.range))||[],d=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!d)return;const f=d.getActiveSheet();if(!f)return;const _=(l.getSubunitRules(d.getUnitId(),f.getSheetId())||[]).filter(x=>x.ranges.some(N=>v.some(R=>i.Rectangle.intersects(R,N)))).map(x=>x.ranges).every(x=>k.checkRangesEditablePermission(t,d.getUnitId(),f.getSheetId(),x));o.next(_)})),c=new X.Observable(o=>new X.Observable(v=>{const d=u.onCommandExecuted(f=>{var b;const{id:h,params:S}=f,_=(b=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:b.getUnitId();br.includes(h)&&S.unitId===_&&v.next(null)});return()=>d.dispose()}).pipe(fe.debounceTime(16)).subscribe(()=>{const v=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!v)return;const d=v.getActiveSheet();if(!d)return;const f=l.getSubunitRules(v.getUnitId(),d.getSheetId())||[];if(!f.length)return o.next(!1),!1;const h=f.map(S=>S.ranges).every(S=>k.checkRangesEditablePermission(t,v.getUnitId(),d.getSheetId(),S));o.next(h)})),p=new X.Observable(o=>{a.subscribe(v=>{const d=xe.find(f=>f.value===Z.clearRangeRules);d&&(d.disabled=!v,o.next(xe))}),c.subscribe(v=>{const d=xe.find(f=>f.value===Z.clearWorkSheetRules);d&&(d.disabled=!v,o.next(xe))}),o.next(xe)});return{id:Se.id,type:j.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:p,hidden$:j.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(t,{workbookTypes:[k.WorkbookEditablePermission],worksheetTypes:[k.WorksheetSetCellStylePermission,k.WorksheetEditPermission],rangeTypes:[k.RangeProtectionPermissionEditPoint]})}},mt={[j.RibbonStartGroup.FORMULAS_INSERT]:{[Se.id]:{order:0,menuItemFactory:yt}}};var St=Object.getOwnPropertyDescriptor,bt=(t,e,u,n)=>{for(var l=n>1?void 0:n?St(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},Ir=(t,e)=>(u,n)=>e(u,n,t);let Ae=class extends i.Disposable{constructor(e,u){super();ee(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=u,this._menuManagerService.mergeMenu(mt)}};Ae=bt([Ir(0,i.Inject(i.Injector)),Ir(1,j.IMenuManagerService)],Ae);var It=Object.getOwnPropertyDescriptor,Ct=(t,e,u,n)=>{for(var l=n>1?void 0:n?It(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},oe=(t,e)=>(u,n)=>e(u,n,t);const Tt=(t,e)=>{const u=d=>d.endRow-d.startRow+1,n=d=>d.endColumn-d.startColumn+1,l=u(e)%u(t),a=n(e)%n(t),c=Math.floor(u(e)/u(t)),p=Math.floor(n(e)/n(t)),o=[],v={startRow:0,endRow:u(t)-1,startColumn:0,endColumn:n(t)-1};if(u(e)===1&&n(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return o.push({repeatRelativeRange:v,startRange:d}),o}for(let d=0;d<c+(l?.1:0);d++)for(let f=0;f<p+(a?.1:0);f++){const h=u(t)*d,S=n(t)*f,_={startRow:h+e.startRow,endRow:h+e.startRow,startColumn:S+e.startColumn,endColumn:S+e.startColumn};let b=v;d===c&&l&&(b={...b},b.endRow=b.endRow-(u(t)-l)),f===p&&a&&(b={...b},b.endColumn=b.endColumn-(n(t)-a)),o.push({repeatRelativeRange:b,startRange:_})}return o};let Le=class extends i.Disposable{constructor(e,u,n,l,a,c){super();ee(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=u,this._formatPainterService=n,this._sheetsSelectionsService=l,this._conditionalFormattingRuleModel=a,this._conditionalFormattingViewModel=c,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),u=(a,c,p,o,v)=>{const{unitId:d,subUnitId:f}=this._painterConfig,{targetUnitId:h,targetSubUnitId:S}=v,_={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},b={startRow:c.row,startColumn:c.col,endColumn:c.col,endRow:c.row};i.Range.foreach(p,(x,N)=>{const R=i.Rectangle.getPositionRange({startRow:x,startColumn:N,endColumn:N,endRow:x},_),w=i.Rectangle.getPositionRange({startRow:x,startColumn:N,endColumn:N,endRow:x},b),M=this._conditionalFormattingViewModel.getCellCfs(d,f,R.startRow,R.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(h,S,w.startRow,w.startColumn);g&&g.forEach(I=>{let T=o.get(I.cfId);if(!o.get(I.cfId)){const C=this._conditionalFormattingRuleModel.getRule(h,S,I.cfId);if(!C)return;T=new i.ObjectMatrix,C.ranges.forEach(O=>{i.Range.foreach(O,(V,U)=>{T.setValue(V,U,1)})}),o.set(I.cfId,T)}T.realDeleteValue(w.startRow,w.startColumn)}),M&&M.forEach(I=>{const T=o.get(I.cfId);T&&T.setValue(w.startRow,w.startColumn,1)})})},n=(a,c,p)=>{var R;const{range:o,unitId:v,subUnitId:d}=this._painterConfig,f=a!==v||d!==c,h=new Map,S=[],_=[];if(!a||!c||!v||!d)return e();const b=(R=this._conditionalFormattingRuleModel.getSubunitRules(v,d))!=null?R:[];b==null||b.forEach(w=>{const{ranges:M,cfId:g}=w;if(M.some(I=>i.Rectangle.intersects(o,I))){const I=new i.ObjectMatrix;f||M.forEach(T=>{i.Range.foreach(T,(C,O)=>{I.setValue(C,O,1)})}),h.set(g,I)}});const x={row:o.startRow,col:o.startColumn};return Tt(o,p).forEach(w=>{u(x,{row:w.startRange.startRow,col:w.startRange.startColumn},w.repeatRelativeRange,h,{targetUnitId:a,targetSubUnitId:c})}),h.forEach((w,M)=>{if(f){const g=this._conditionalFormattingRuleModel.getRule(a,c,M),I=k.findAllRectangle(k.createTopMatrixFromMatrix(w));if(g)if(I.length){const T={unitId:a,subUnitId:c,rule:{...g,ranges:I}};S.push({id:r.SetConditionalRuleMutation.id,params:T}),_.push(...r.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:a,subUnitId:c,cfId:g.cfId};S.push({id:r.DeleteConditionalRuleMutation.id,params:T}),_.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}else if(I.length){const T=this._conditionalFormattingRuleModel.getRule(v,d,M);if(T){const C={unitId:a,subUnitId:c,rule:{...i.Tools.deepClone(T),cfId:this._conditionalFormattingRuleModel.createCfId(a,c),ranges:I}};S.push({id:r.AddConditionalRuleMutation.id,params:C}),_.push(r.AddConditionalRuleMutationUndoFactory(this._injector,C))}}}else{const g=this._conditionalFormattingRuleModel.getRule(v,d,M);if(!g)return;const I=k.findAllRectangle(k.createTopMatrixFromMatrix(w));if(I.length){const T={unitId:v,subUnitId:d,rule:{...g,ranges:I}};S.push({id:r.SetConditionalRuleMutation.id,params:T}),_.push(...r.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:v,subUnitId:d,cfId:g.cfId};S.push({id:r.DeleteConditionalRuleMutation.id,params:T}),_.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}}}),{undos:_,redos:S}},l={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:a=>{var c,p,o;switch(a){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const v=(c=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:c.getUnitId(),d=(o=(p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getActiveSheet())==null?void 0:o.getSheetId(),f=this._sheetsSelectionsService.getCurrentLastSelection(),h=f==null?void 0:f.range;v&&d&&h&&(this._painterConfig={unitId:v,subUnitId:d,range:h});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(a,c,p)=>this._painterConfig?n(a,c,p):{redos:[],undos:[]}};this._formatPainterService.addHook(l)}};Le=Ct([oe(0,i.Inject(i.Injector)),oe(1,i.Inject(i.IUniverInstanceService)),oe(2,i.Inject(W.IFormatPainterService)),oe(3,i.Inject(k.SheetsSelectionsService)),oe(4,i.Inject(r.ConditionalFormattingRuleModel)),oe(5,i.Inject(r.ConditionalFormattingViewModel))],Le);var _t=Object.getOwnPropertyDescriptor,Et=(t,e,u,n)=>{for(var l=n>1?void 0:n?_t(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},tr=(t,e)=>(u,n)=>e(u,n,t);let Fe=class extends i.Disposable{constructor(t,e,u){super(),this._conditionalFormattingViewModel=t,this._univerInstanceService=e,this._renderManagerService=u,this._init()}_init(){const t=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),e=u=>{const n=u.getUnitId(),l=this._renderManagerService.getRenderById(n);if(!l)return;const a=l.with(W.SheetSkeletonManagerService);this.disposeWithMe(a.currentSkeleton$.subscribe(c=>{if(c){const p=c.skeleton.rowColumnSegment,o=p.endColumn-p.startColumn+1,d=(p.endRow-p.startRow+1)*o*9,f=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(f)}}))};t&&e(t),this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(u=>{u&&e(u)})}};Fe=Et([tr(0,i.Inject(r.ConditionalFormattingViewModel)),tr(1,i.IUniverInstanceService),tr(2,lr.IRenderManagerService)],Fe);var Nt=Object.defineProperty,xt=Object.getOwnPropertyDescriptor,Rt=(t,e,u)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,Mt=(t,e,u,n)=>{for(var l=n>1?void 0:n?xt(e,u):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=c(l)||l);return l},nr=(t,e)=>(u,n)=>e(u,n,t),Cr=(t,e,u)=>Rt(t,typeof e!="symbol"?e+"":e,u);P.UniverSheetsConditionalFormattingUIPlugin=class extends i.Plugin{constructor(e=Pe,u,n,l){super(),this._config=e,this._injector=u,this._commandService=n,this._configService=l;const{menu:a,...c}=i.merge({},Pe,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig(gr,c),this._initCommand()}onStarting(){i.registerDependencies(this._injector,[[_e],[Te],[Ie],[De],[Ce],[me],[Ae],[se],[je],[P.ConditionalFormattingClearController],[Le],[Fe]]),i.touchDependencies(this._injector,[[_e]])}onReady(){i.touchDependencies(this._injector,[[Ae],[me]])}onRendered(){i.touchDependencies(this._injector,[[De],[P.ConditionalFormattingClearController],[Ie],[je],[se],[Le],[Ce],[Te],[Fe]])}_initCommand(){[He,We,qe,Ge,ze,Ye,Ze,Ke,Xe,Se].forEach(e=>{this._commandService.registerCommand(e)})}},Cr(P.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Cr(P.UniverSheetsConditionalFormattingUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),P.UniverSheetsConditionalFormattingUIPlugin=Mt([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin),nr(1,i.Inject(i.Injector)),nr(2,i.Inject(i.ICommandService)),nr(3,i.IConfigService)],P.UniverSheetsConditionalFormattingUIPlugin),P.AddAverageCfCommand=He,P.AddColorScaleConditionalRuleCommand=We,P.AddDataBarConditionalRuleCommand=qe,P.AddDuplicateValuesCfCommand=Ge,P.AddNumberCfCommand=ze,P.AddRankCfCommand=Ye,P.AddTextCfCommand=Ze,P.AddTimePeriodCfCommand=Ke,P.AddUniqueValuesCfCommand=Xe,P.OpenConditionalFormattingOperator=Se,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});