@univerjs/sheets-conditional-formatting-ui 0.7.0-nightly.202505051607 → 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/cjs/index.js CHANGED
@@ -1,54 +1,76 @@
1
- "use strict";var br=Object.defineProperty;var Sr=(e,t,n)=>t in e?br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Re=(e,t,n)=>Sr(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("@univerjs/core"),c=require("@univerjs/sheets-conditional-formatting"),$=require("@univerjs/sheets"),J=require("@univerjs/ui"),_=require("react/jsx-runtime"),j=require("react"),K=require("@univerjs/design"),Bt=require("@univerjs/engine-formula"),at=require("@univerjs/sheets-formula-ui"),ce=require("@univerjs/sheets-ui"),Gt=require("react-dom"),ye=require("rxjs"),Zn=require("@univerjs/engine-render"),tt=require("rxjs/operators"),Yt={type:T.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:n,style:r,stopIfTrue:i,operator:o}=t,d=e.get(c.ConditionalFormattingRuleModel),b=e.get(T.ICommandService),h=e.get(T.IUniverInstanceService),S=$.getSheetCommandTarget(h);if(!S)return!1;const{unitId:v,subUnitId:C}=S,I=d.createCfId(v,C),w={ranges:n,cfId:I,stopIfTrue:!!i,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.average,operator:o,style:r}};return b.executeCommand(c.AddConditionalRuleMutation.id,{unitId:v,subUnitId:C,rule:w})}},Xt={type:T.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:n,config:r,stopIfTrue:i}=t,o=e.get(c.ConditionalFormattingRuleModel),d=e.get(T.ICommandService),b=e.get(T.IUniverInstanceService),h=$.getSheetCommandTarget(b);if(!h)return!1;const{unitId:S,subUnitId:v}=h,C=o.createCfId(S,v),I={ranges:n,cfId:C,stopIfTrue:!!i,rule:{type:c.CFRuleType.colorScale,config:r}};return d.executeCommand(c.AddConditionalRuleMutation.id,{unitId:S,subUnitId:v,rule:I})}},Kt={type:T.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:n,min:r,max:i,nativeColor:o,positiveColor:d,isGradient:b,stopIfTrue:h,isShowValue:S}=t,v=e.get(c.ConditionalFormattingRuleModel),C=e.get(T.IUniverInstanceService),I=$.getSheetCommandTarget(C);if(!I)return!1;const{unitId:w,subUnitId:x}=I,R=e.get(T.ICommandService),p=v.createCfId(w,x),s={ranges:n,cfId:p,stopIfTrue:!!h,rule:{type:c.CFRuleType.dataBar,isShowValue:S,config:{min:r,max:i,nativeColor:o,positiveColor:d,isGradient:b}}};return R.executeCommand(c.AddConditionalRuleMutation.id,{unitId:w,subUnitId:x,rule:s})}},Zt={type:T.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:n,style:r,stopIfTrue:i}=t,o=e.get(c.ConditionalFormattingRuleModel),d=e.get(T.ICommandService),b=e.get(T.IUniverInstanceService),h=$.getSheetCommandTarget(b);if(!h)return!1;const{unitId:S,subUnitId:v}=h,C=o.createCfId(S,v),I={ranges:n,cfId:C,stopIfTrue:!!i,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.duplicateValues,style:r}};return d.executeCommand(c.AddConditionalRuleMutation.id,{unitId:S,subUnitId:v,rule:I})}},Jt={type:T.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:n,style:r,stopIfTrue:i,operator:o,value:d}=t,b=e.get(c.ConditionalFormattingRuleModel),h=e.get(T.ICommandService),S=e.get(T.IUniverInstanceService),v=$.getSheetCommandTarget(S);if(!v)return!1;const{unitId:C,subUnitId:I}=v,w=b.createCfId(C,I);let x;if([c.CFNumberOperator.between,c.CFNumberOperator.notBetween].includes(o)){const R=d;if(R.length!==2||!Array.isArray(R))return!1;x={ranges:n,cfId:w,stopIfTrue:!!i,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.number,operator:o,style:r,value:R}}}else{const R=d;if(typeof R!="number")return!1;x={ranges:n,cfId:w,stopIfTrue:!!i,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.number,operator:o,style:r,value:R}}}return h.executeCommand(c.AddConditionalRuleMutation.id,{unitId:C,subUnitId:I,rule:x})}},Qt={type:T.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:n,style:r,stopIfTrue:i,isPercent:o,isBottom:d,value:b}=t,h=e.get(c.ConditionalFormattingRuleModel),S=e.get(T.IUniverInstanceService),v=e.get(T.ICommandService),C=$.getSheetCommandTarget(S);if(!C)return!1;const{unitId:I,subUnitId:w}=C,x=h.createCfId(I,w),R={ranges:n,cfId:x,stopIfTrue:!!i,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.rank,isPercent:o,isBottom:d,style:r,value:b}};return v.executeCommand(c.AddConditionalRuleMutation.id,{unitId:I,subUnitId:w,rule:R})}},en={type:T.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:n,style:r,stopIfTrue:i,operator:o,value:d}=t,b=e.get(c.ConditionalFormattingRuleModel),h=e.get(T.IUniverInstanceService),S=$.getSheetCommandTarget(h);if(!S)return!1;const{unitId:v,subUnitId:C}=S,I=e.get(T.ICommandService),w=b.createCfId(v,C),x={ranges:n,cfId:w,stopIfTrue:!!i,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.text,operator:o,style:r,value:d}};return I.executeCommand(c.AddConditionalRuleMutation.id,{unitId:v,subUnitId:C,rule:x})}},tn={type:T.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:n,style:r,stopIfTrue:i,operator:o}=t,d=e.get(c.ConditionalFormattingRuleModel),b=e.get(T.IUniverInstanceService),h=e.get(T.ICommandService),S=$.getSheetCommandTarget(b);if(!S)return!1;const{unitId:v,subUnitId:C}=S,I=d.createCfId(v,C),w={ranges:n,cfId:I,stopIfTrue:!!i,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.timePeriod,operator:o,style:r}};return h.executeCommand(c.AddConditionalRuleMutation.id,{unitId:v,subUnitId:C,rule:w})}},nn={type:T.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(e,t){if(!t)return!1;const{ranges:n,style:r,stopIfTrue:i}=t,o=e.get(c.ConditionalFormattingRuleModel),d=e.get(T.IUniverInstanceService),b=e.get(T.ICommandService),h=$.getSheetCommandTarget(d);if(!h)return!1;const{unitId:S,subUnitId:v}=h,C=o.createCfId(S,v),I={ranges:n,cfId:C,stopIfTrue:!!i,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.uniqueValues,style:r}};return b.executeCommand(c.AddConditionalRuleMutation.id,{unitId:S,subUnitId:v,rule:I})}};var me=function(){return me=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},me.apply(this,arguments)},Rr=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},Ue=j.forwardRef(function(e,t){var n=e.icon,r=e.id,i=e.className,o=e.extend,d=Rr(e,["icon","id","className","extend"]),b="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),h=j.useRef("_".concat(wr()));return Jn(n,"".concat(r),{defIds:n.defIds,idSuffix:h.current},me({ref:t,className:b},d),o)});function Jn(e,t,n,r,i){return j.createElement(e.tag,me(me({key:t},xr(e,n,i)),r),(Tr(e,n).children||[]).map(function(o,d){return Jn(o,"".concat(t,"-").concat(e.tag,"-").concat(d),n,void 0,i)}))}function xr(e,t,n){var r=me({},e.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+t.idSuffix),Object.entries(r).forEach(function(o){var d=o[0],b=o[1];d==="mask"&&typeof b=="string"&&(r[d]=b.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(o){var d=o[0],b=o[1];typeof b=="string"&&(r[d]=b.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function Tr(e,t){var n,r=t.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?me(me({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?me(me({},i),{attrs:me(me({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function wr(){return Math.random().toString(36).substring(2,8)}Ue.displayName="UniverIcon";var _r={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},St=j.forwardRef(function(e,t){return j.createElement(Ue,Object.assign({},e,{id:"delete-single",ref:t,icon:_r}))});St.displayName="DeleteSingle";var Ir={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"}}]},Qn=j.forwardRef(function(e,t){return j.createElement(Ue,Object.assign({},e,{id:"increase-single",ref:t,icon:Ir}))});Qn.displayName="IncreaseSingle";var Er={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"}}]},Dt=j.forwardRef(function(e,t){return j.createElement(Ue,Object.assign({},e,{id:"more-down-single",ref:t,icon:Er}))});Dt.displayName="MoreDownSingle";var Or={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"}}]}]},er=j.forwardRef(function(e,t){return j.createElement(Ue,Object.assign({},e,{id:"sequence-single",ref:t,icon:Or}))});er.displayName="SequenceSingle";var Dr={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"}}]}]},lt=j.forwardRef(function(e,t){return j.createElement(Ue,Object.assign({},e,{id:"slash-single",ref:t,icon:Dr}))});lt.displayName="SlashSingle";const De=e=>{const{color:t,onChange:n,disable:r=!1,iconId:i="PaintBucket",className:o,isNeedDropdownIcon:d=!0}=e,b=J.useDependency(J.ComponentManager),h=j.useMemo(()=>new T.ColorKit(t),[t]),S=b.get(i);return S?r?_.jsx(S,{className:K.clsx("univer-fill-primary-600",o),extend:{colorChannel1:h.isValid?t:""}}):_.jsx(K.Dropdown,{overlay:_.jsx("div",{className:"univer-rounded-lg univer-p-4",children:_.jsx(K.ColorPicker,{value:t,onChange:n})}),children:_.jsxs("span",{className:K.clsx(`
1
+ "use strict";var xt=Object.defineProperty;var Rt=(n,e,i)=>e in n?xt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var Q=(n,e,i)=>Rt(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),t=require("@univerjs/sheets-conditional-formatting"),O=require("@univerjs/sheets"),k=require("@univerjs/ui"),l=require("react/jsx-runtime"),C=require("react"),U=require("@univerjs/design"),Ge=require("@univerjs/engine-formula"),Te=require("@univerjs/sheets-formula-ui"),H=require("@univerjs/sheets-ui"),K=require("rxjs"),ht=require("@univerjs/engine-render"),fe=require("rxjs/operators"),ze={type:a.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o}=e,u=n.get(t.ConditionalFormattingRuleModel),v=n.get(a.ICommandService),c=n.get(a.IUniverInstanceService),m=O.getSheetCommandTarget(c);if(!m)return!1;const{unitId:d,subUnitId:h}=m,p=u.createCfId(d,h),y={ranges:i,cfId:p,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:o,style:r}};return v.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:h,rule:y})}},Ye={type:a.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,config:r,stopIfTrue:s}=e,o=n.get(t.ConditionalFormattingRuleModel),u=n.get(a.ICommandService),v=n.get(a.IUniverInstanceService),c=O.getSheetCommandTarget(v);if(!c)return!1;const{unitId:m,subUnitId:d}=c,h=o.createCfId(m,d),p={ranges:i,cfId:h,stopIfTrue:!!s,rule:{type:t.CFRuleType.colorScale,config:r}};return u.executeCommand(t.AddConditionalRuleMutation.id,{unitId:m,subUnitId:d,rule:p})}},Ze={type:a.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,min:r,max:s,nativeColor:o,positiveColor:u,isGradient:v,stopIfTrue:c,isShowValue:m}=e,d=n.get(t.ConditionalFormattingRuleModel),h=n.get(a.IUniverInstanceService),p=O.getSheetCommandTarget(h);if(!p)return!1;const{unitId:y,subUnitId:x}=p,S=n.get(a.ICommandService),_=d.createCfId(y,x),F={ranges:i,cfId:_,stopIfTrue:!!c,rule:{type:t.CFRuleType.dataBar,isShowValue:m,config:{min:r,max:s,nativeColor:o,positiveColor:u,isGradient:v}}};return S.executeCommand(t.AddConditionalRuleMutation.id,{unitId:y,subUnitId:x,rule:F})}},Ke={type:a.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s}=e,o=n.get(t.ConditionalFormattingRuleModel),u=n.get(a.ICommandService),v=n.get(a.IUniverInstanceService),c=O.getSheetCommandTarget(v);if(!c)return!1;const{unitId:m,subUnitId:d}=c,h=o.createCfId(m,d),p={ranges:i,cfId:h,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.duplicateValues,style:r}};return u.executeCommand(t.AddConditionalRuleMutation.id,{unitId:m,subUnitId:d,rule:p})}},Xe={type:a.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o,value:u}=e,v=n.get(t.ConditionalFormattingRuleModel),c=n.get(a.ICommandService),m=n.get(a.IUniverInstanceService),d=O.getSheetCommandTarget(m);if(!d)return!1;const{unitId:h,subUnitId:p}=d,y=v.createCfId(h,p);let x;if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(o)){const S=u;if(S.length!==2||!Array.isArray(S))return!1;x={ranges:i,cfId:y,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:o,style:r,value:S}}}else{const S=u;if(typeof S!="number")return!1;x={ranges:i,cfId:y,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:o,style:r,value:S}}}return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:p,rule:x})}},Je={type:a.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,isPercent:o,isBottom:u,value:v}=e,c=n.get(t.ConditionalFormattingRuleModel),m=n.get(a.IUniverInstanceService),d=n.get(a.ICommandService),h=O.getSheetCommandTarget(m);if(!h)return!1;const{unitId:p,subUnitId:y}=h,x=c.createCfId(p,y),S={ranges:i,cfId:x,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:o,isBottom:u,style:r,value:v}};return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:p,subUnitId:y,rule:S})}},Qe={type:a.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o,value:u}=e,v=n.get(t.ConditionalFormattingRuleModel),c=n.get(a.IUniverInstanceService),m=O.getSheetCommandTarget(c);if(!m)return!1;const{unitId:d,subUnitId:h}=m,p=n.get(a.ICommandService),y=v.createCfId(d,h),x={ranges:i,cfId:y,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.text,operator:o,style:r,value:u}};return p.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:h,rule:x})}},et={type:a.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o}=e,u=n.get(t.ConditionalFormattingRuleModel),v=n.get(a.IUniverInstanceService),c=n.get(a.ICommandService),m=O.getSheetCommandTarget(v);if(!m)return!1;const{unitId:d,subUnitId:h}=m,p=u.createCfId(d,h),y={ranges:i,cfId:p,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.timePeriod,operator:o,style:r}};return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:h,rule:y})}},tt={type:a.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s}=e,o=n.get(t.ConditionalFormattingRuleModel),u=n.get(a.IUniverInstanceService),v=n.get(a.ICommandService),c=O.getSheetCommandTarget(u);if(!c)return!1;const{unitId:m,subUnitId:d}=c,h=o.createCfId(m,d),p={ranges:i,cfId:h,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.uniqueValues,style:r}};return v.executeCommand(t.AddConditionalRuleMutation.id,{unitId:m,subUnitId:d,rule:p})}};var Z=function(){return Z=Object.assign||function(n){for(var e,i=1,r=arguments.length;i<r;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},Z.apply(this,arguments)},Ft=function(n,e){var i={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(i[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(i[r[s]]=n[r[s]]);return i},ce=C.forwardRef(function(n,e){var i=n.icon,r=n.id,s=n.className,o=n.extend,u=Ft(n,["icon","id","className","extend"]),v="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),c=C.useRef("_".concat(Et()));return pt(i,"".concat(r),{defIds:i.defIds,idSuffix:c.current},Z({ref:e,className:v},u),o)});function pt(n,e,i,r,s){return C.createElement(n.tag,Z(Z({key:e},_t(n,i,s)),r),(jt(n,i).children||[]).map(function(o,u){return pt(o,"".concat(e,"-").concat(n.tag,"-").concat(u),i,void 0,s)}))}function _t(n,e,i){var r=Z({},n.attrs);i!=null&&i.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=i.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(o){var u=o[0],v=o[1];u==="mask"&&typeof v=="string"&&(r[u]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var s=e.defIds;return!s||s.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(o){var u=o[0],v=o[1];typeof v=="string"&&(r[u]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function jt(n,e){var i,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?Z(Z({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?Z(Z({},s),{attrs:Z(Z({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function Et(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var Nt={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"}}]},Ve=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"delete-single",ref:e,icon:Nt}))});Ve.displayName="DeleteSingle";var Mt={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"}}]},gt=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"increase-single",ref:e,icon:Mt}))});gt.displayName="IncreaseSingle";var wt={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"}}]},Le=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"more-down-single",ref:e,icon:wt}))});Le.displayName="MoreDownSingle";var Vt={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"}}]}]},ft=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"sequence-single",ref:e,icon:Vt}))});ft.displayName="SequenceSingle";var Ot={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"}}]}]},xe=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"slash-single",ref:e,icon:Ot}))});xe.displayName="SlashSingle";const re=n=>{const{color:e,onChange:i,disable:r=!1,iconId:s="PaintBucket",className:o,isNeedDropdownIcon:u=!0}=n,v=k.useDependency(k.ComponentManager),c=C.useMemo(()=>new a.ColorKit(e),[e]),m=v.get(s);return m?r?l.jsx(m,{className:U.clsx("univer-fill-primary-600",o),extend:{colorChannel1:c.isValid?e:""}}):l.jsx(U.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx(U.ColorPicker,{value:e,onChange:i})}),children:l.jsxs("span",{className:U.clsx(`
2
2
  univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1
3
3
  hover:univer-bg-gray-100
4
- `,o),children:[_.jsx(S,{className:"univer-fill-primary-600",extend:{colorChannel1:h.isValid?t:""}}),d&&_.jsx(Dt,{className:"univer-ml-1.5 univer-text-[10px] univer-text-gray-400"})]})}):null},Ve=e=>{var o,d,b;const t=e.rule;if(!t)return null;const n=j.useMemo(()=>{if(t.type===c.CFRuleType.colorScale){const h=t.config.map((C,I)=>({color:new T.ColorKit(C.color),value:I})),S=h.length-1;return new Array(5).fill("").map((C,I,w)=>I*S/(w.length-1)).map(C=>c.getColorScaleFromValue(h,C))}return null},[t]),r=j.useMemo(()=>{if(t.type===c.CFRuleType.iconSet)return t.config.map(h=>{const S=c.iconMap[h.iconType];return S&&S[Number(h.iconId)]})},[t]),i=`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 c.CFRuleType.dataBar:{const{isGradient:h}=t.config,S=h?`linear-gradient(to right, ${t.config.positiveColor||c.defaultDataBarPositiveColor}, rgb(255 255 255))`:t.config.positiveColor,v=h?`linear-gradient(to right, rgb(255 255 255),${t.config.nativeColor||c.defaultDataBarNativeColor})`:t.config.nativeColor;return _.jsxs("div",{className:i,children:[_.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:v,border:`1px solid ${t.config.nativeColor||c.defaultDataBarNativeColor}`}}),_.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:S,border:`1px solid ${t.config.positiveColor||c.defaultDataBarPositiveColor}`}})]})}case c.CFRuleType.colorScale:return n&&_.jsx("div",{className:i,children:n.map((h,S)=>_.jsx("div",{className:"univer-h-full",style:{width:`${100/n.length}%`,background:h}},S))});case c.CFRuleType.iconSet:return r&&_.jsx("div",{className:i,children:r.map((h,S)=>h?_.jsx("img",{className:"univer-h-full",src:h,draggable:!1},S):_.jsx(lt,{},S))});case c.CFRuleType.highlightCell:{const{ul:h,st:S,it:v,bl:C,bg:I,cl:w}=t.style,x=(h==null?void 0:h.s)===T.BooleanNumber.TRUE,R=(S==null?void 0:S.s)===T.BooleanNumber.TRUE,p=v===T.BooleanNumber.TRUE,s=C===T.BooleanNumber.TRUE,a=(o=I==null?void 0:I.rgb)!=null?o:c.DEFAULT_BG_COLOR,f=(d=w==null?void 0:w.rgb)!=null?d:c.DEFAULT_FONT_COLOR,y={textDecoration:(b=`${x?"underline":""} ${R?"line-through":""}`.replace(/^ /,""))!=null?b:void 0,backgroundColor:a,color:f};return _.jsx("div",{className:K.clsx(i,{"univer-font-bold":s,"univer-italic":p}),style:y,children:"123"})}}},ut="univer-mt-5 univer-px-1 univer-py-2 univer-border univer-border-solid univer-border-gray-200 univer-rounded",Ee=(e,t)=>({label:t.t(`sheet.cf.valueType.${e}`),value:e}),Nt=e=>{var x;const{type:t,className:n,onChange:r,id:i,value:o}=e,d=J.useDependency(T.IUniverInstanceService),b=d.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getUnitId(),h=(x=d.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:x.getSheetId(),S=j.useMemo(()=>String(o).startsWith("=")?String(o):"=",[o]),v=j.useMemo(()=>[c.CFValueType.max,c.CFValueType.min,"none"].includes(t)?{disabled:!0}:[c.CFValueType.percent,c.CFValueType.percentile].includes(t)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[t]),C=j.useRef(null),[I,w]=j.useState(!1);return J.useSidebarClick(R=>{var s;((s=C.current)==null?void 0:s.isClickOutSide(R))&&w(!1)}),t===c.CFValueType.formula?_.jsx("div",{className:"univer-ml-1 univer-w-full",children:_.jsx(at.FormulaEditor,{initValue:S,unitId:b,subUnitId:h,isFocus:I,onChange:(R="")=>{r(R||"")},onFocus:()=>w(!0),ref:C})}):_.jsx(K.InputNumber,{className:n,value:Number(e.value)||0,onChange:R=>e.onChange(R||0),...v})},Fr=e=>{var U;const{interceptorManager:t}=e,n=J.useDependency(T.LocaleService),r=((U=e.rule)==null?void 0:U.type)===c.CFRuleType.colorScale?e.rule:void 0,i=[Ee(c.CFValueType.num,n),Ee(c.CFValueType.percent,n),Ee(c.CFValueType.percentile,n),Ee(c.CFValueType.formula,n)],o=[Ee(c.CFValueType.min,n),...i],d=[Ee("none",n),...i],b=[Ee(c.CFValueType.max,n),...i],[h,S]=j.useState(()=>{var N;const E=c.CFValueType.min;return r&&((N=r.config[0])==null?void 0:N.value.type)||E}),[v,C]=j.useState(()=>{var N;const E="none";return!r||r.config.length!==3?E:((N=r.config[1])==null?void 0:N.value.type)||E}),[I,w]=j.useState(()=>{var N;const E=c.CFValueType.max;return r&&((N=r.config[r.config.length-1])==null?void 0:N.value.type)||E}),[x,R]=j.useState(()=>{if(!r)return 10;const N=r.config[0];return(N==null?void 0:N.value.value)===void 0?10:N==null?void 0:N.value.value}),[p,s]=j.useState(()=>{var A;if(!r||r.config.length!==3)return 50;const N=(A=r.config[1])==null?void 0:A.value.value;return N===void 0?50:N}),[a,f]=j.useState(()=>{var A;if(!r)return 90;const N=(A=r.config[r.config.length-1])==null?void 0:A.value.value;return N===void 0?90:N}),[y,l]=j.useState(()=>{var N;const E="#d0d9fb";return r&&((N=r.config[0])==null?void 0:N.color)||E}),[g,u]=j.useState(()=>{var N;const E="#7790f3";return!r||r.config.length!==3?E:((N=r.config[1])==null?void 0:N.color)||E}),[m,F]=j.useState(()=>{var N;const E="#2e55ef";return r&&((N=r.config[r.config.length-1])==null?void 0:N.color)||E}),P=j.useMemo(()=>E=>{const{minType:N,medianType:A,maxType:W,minValue:G,medianValue:re,maxValue:te,minColor:se,medianColor:z,maxColor:Z}=E,ee=[];return ee.push({color:se,value:{type:N,value:G}}),A!=="none"&&ee.push({color:z,value:{type:A,value:re}}),ee.push({color:Z,value:{type:W,value:te}}),{config:ee.map((ue,fe)=>({...ue,index:fe})),type:c.CFRuleType.colorScale}},[]);j.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return P({minType:h,medianType:v,maxType:I,minValue:x,medianValue:p,maxValue:a,minColor:y,medianColor:g,maxColor:m})}}),[P,h,v,I,x,p,a,y,g,m,t]);const L=E=>{e.onChange(P(E))};return _.jsxs("div",{children:[_.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),_.jsx("div",{className:ut,children:_.jsx(Ve,{rule:P({minType:h,medianType:v,maxType:I,minValue:x,medianValue:p,maxValue:a,minColor:y,medianColor:g,maxColor:m})})}),_.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:n.t("sheet.cf.valueType.min")}),_.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[_.jsx(K.Select,{className:"univer-flex-shrink-0",options:o,value:h,onChange:E=>{S(E);const N=c.createDefaultValueByValueType(E,10);R(N),L({minType:E,medianType:v,maxType:I,minValue:N,medianValue:p,maxValue:a,minColor:y,medianColor:g,maxColor:m})}}),_.jsx(Nt,{id:"min",className:"univer-ml-1",value:x,type:h,onChange:E=>{R(E),L({minType:h,medianType:v,maxType:I,minValue:E,medianValue:p,maxValue:a,minColor:y,medianColor:g,maxColor:m})}}),_.jsx(De,{className:"univer-ml-1",color:y,onChange:E=>{l(E),L({minType:h,medianType:v,maxType:I,minValue:x,medianValue:p,maxValue:a,minColor:E,medianColor:g,maxColor:m})}})]}),_.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:n.t("sheet.cf.panel.medianValue")}),_.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[_.jsx(K.Select,{className:"univer-flex-shrink-0",options:d,value:v,onChange:E=>{C(E);const N=c.createDefaultValueByValueType(E,50);s(N),L({minType:h,medianType:E,maxType:I,minValue:x,medianValue:N,maxValue:a,minColor:y,medianColor:g,maxColor:m})}}),_.jsx(Nt,{id:"median",className:"univer-ml-1",value:p,type:v,onChange:E=>{s(E),L({minType:h,medianType:v,maxType:I,minValue:x,medianValue:E,maxValue:a,minColor:y,medianColor:g,maxColor:m})}}),v!=="none"&&_.jsx(De,{className:"univer-ml-1",color:g,onChange:E=>{u(E),L({minType:h,medianType:v,maxType:I,minValue:x,medianValue:p,maxValue:a,minColor:y,medianColor:E,maxColor:m})}})]}),_.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:n.t("sheet.cf.valueType.max")}),_.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[_.jsx(K.Select,{className:"univer-flex-shrink-0",options:b,value:I,onChange:E=>{w(E);const N=c.createDefaultValueByValueType(E,90);f(N),L({minType:h,medianType:v,maxType:E,minValue:x,medianValue:p,maxValue:N,minColor:y,medianColor:g,maxColor:m})}}),_.jsx(Nt,{id:"max",className:"univer-ml-1",value:a,type:I,onChange:E=>{f(E),L({minType:h,medianType:v,maxType:I,minValue:x,medianValue:p,maxValue:E,minColor:y,medianColor:g,maxColor:m})}}),_.jsx(De,{className:"univer-ml-1",color:m,onChange:E=>{F(E),L({minType:h,medianType:v,maxType:I,minValue:x,medianValue:p,maxValue:a,minColor:y,medianColor:g,maxColor:E})}})]})]})},Pe=(e,t)=>({label:t.t(`sheet.cf.valueType.${e}`),value:e}),cn=e=>{var R;const{onChange:t,className:n,value:r,type:i,id:o,disabled:d=!1}=e,b=J.useDependency(T.IUniverInstanceService),h=b.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getUnitId(),S=(R=b.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:R.getSheetId(),v=j.useRef(null),[C,I]=j.useState(!1);J.useSidebarClick(p=>{var a;((a=v.current)==null?void 0:a.isClickOutSide(p))&&I(!1)});const w=j.useRef(r),x=j.useMemo(()=>[c.CFValueType.percentile,c.CFValueType.percent].includes(i)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[i]);if(i===c.CFValueType.formula){const p=String(w.current).startsWith("=")?String(w.current)||"":"=";return _.jsx("div",{className:"univer-ml-3 univer-w-full",children:_.jsx(at.FormulaEditor,{initValue:p,unitId:h,subUnitId:S,isFocus:C,onChange:(s="")=>{t(s||"")},onFocus:()=>I(!0),ref:v})})}return _.jsx(K.InputNumber,{className:n,value:Number(r)||0,disabled:d,onChange:p=>{t(p||0)},...x})},Pr=e=>{var U;const{interceptorManager:t}=e,n=J.useDependency(T.LocaleService),r=((U=e.rule)==null?void 0:U.type)===c.CFRuleType.dataBar?e.rule:void 0,[i,o]=j.useState(()=>{var N;const E="0";return r?(N=r.config)!=null&&N.isGradient?"1":"0":E}),[d,b]=j.useState(()=>{var E;return r&&((E=r.config)==null?void 0:E.positiveColor)||c.defaultDataBarPositiveColor}),[h,S]=j.useState(()=>{var E;return r&&((E=r.config)==null?void 0:E.nativeColor)||c.defaultDataBarNativeColor}),v=[Pe(c.CFValueType.num,n),Pe(c.CFValueType.percent,n),Pe(c.CFValueType.percentile,n),Pe(c.CFValueType.formula,n)],C=[Pe(c.CFValueType.min,n),...v],I=[Pe(c.CFValueType.max,n),...v],[w,x]=j.useState(()=>{var N;const E=C[0].value;return r&&((N=r.config)==null?void 0:N.min.type)||E}),[R,p]=j.useState(()=>{var N;const E=I[0].value;return r&&((N=r.config)==null?void 0:N.max.type)||E}),[s,a]=j.useState(()=>{var A;if(!r)return 0;const N=((A=r.config)==null?void 0:A.min)||{};return N.type===c.CFValueType.formula?N.value||"=":N.value||0}),[f,y]=j.useState(()=>{var A;if(!r)return 100;const N=((A=r.config)==null?void 0:A.max)||{};return N.type===c.CFValueType.formula?N.value||"=":N.value===void 0?100:N.value}),[l,g]=j.useState(()=>r?r.isShowValue===void 0?!0:!!r.isShowValue:!0),u=E=>({config:{min:{type:E.minValueType,value:E.minValue},max:{type:E.maxValueType,value:E.maxValue},isGradient:E.isGradient==="1",positiveColor:E.positiveColor||c.defaultDataBarPositiveColor,nativeColor:E.nativeColor||c.defaultDataBarNativeColor},type:c.CFRuleType.dataBar,isShowValue:E.isShowValue});j.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return u({isGradient:i,minValue:s,minValueType:w,maxValue:f,maxValueType:R,positiveColor:d,nativeColor:h,isShowValue:l})}}),[i,s,w,f,R,d,h,t,l]);const m=E=>{e.onChange(u(E))},F=E=>{b(E),m({isGradient:i,minValue:s,minValueType:w,maxValue:f,maxValueType:R,positiveColor:E,nativeColor:h,isShowValue:l})},P=E=>{S(E),m({isGradient:i,minValue:s,minValueType:w,maxValue:f,maxValueType:R,positiveColor:d,nativeColor:E,isShowValue:l})},L=E=>v.map(N=>N.value).includes(E);return _.jsxs("div",{children:[_.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),_.jsx("div",{className:ut,children:_.jsx(Ve,{rule:u({isGradient:i,minValue:s,minValueType:w,maxValue:f,maxValueType:R,positiveColor:d,nativeColor:h,isShowValue:l})})}),_.jsxs("div",{children:[_.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.fillType")}),_.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[_.jsxs(K.RadioGroup,{value:i,onChange:E=>{o(E),m({isGradient:E,minValue:s,minValueType:w,maxValue:f,maxValueType:R,positiveColor:d,nativeColor:h,isShowValue:l})},children:[_.jsx(K.Radio,{value:"0",children:_.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.pureColor")})}),_.jsx(K.Radio,{value:"1",children:_.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.gradient")})})]}),_.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[_.jsx(K.Checkbox,{checked:!l,onChange:E=>{g(!E),m({isGradient:E,minValue:s,minValueType:w,maxValue:f,maxValueType:R,positiveColor:d,nativeColor:h,isShowValue:!E})}}),n.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),_.jsxs("div",{children:[_.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.colorSet")}),_.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[_.jsxs("div",{className:"univer-flex univer-items-center",children:[_.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.native")}),_.jsx(De,{color:h,onChange:P})]}),_.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[_.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.positive")}),_.jsx(De,{color:d,onChange:F})]})]})]}),_.jsxs("div",{children:[_.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.valueType.min")}),_.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[_.jsx(K.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:C,value:w,onChange:E=>{x(E);const N=c.createDefaultValueByValueType(E,10);a(N),m({isGradient:i,minValue:N,minValueType:E,maxValue:f,maxValueType:R,positiveColor:d,nativeColor:h,isShowValue:l})}}),_.jsx(cn,{id:"min",className:"univer-ml-3",disabled:!L(w),type:w,value:s,onChange:E=>{a(E||0),m({isGradient:i,minValue:E||0,minValueType:w,maxValue:f,maxValueType:R,positiveColor:d,nativeColor:h,isShowValue:l})}})]}),_.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.valueType.max")}),_.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[_.jsx(K.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:I,value:R,onChange:E=>{p(E);const N=c.createDefaultValueByValueType(E,90);y(N),m({isGradient:i,minValue:s,minValueType:w,maxValue:N,maxValueType:E,positiveColor:d,nativeColor:h,isShowValue:l})}}),_.jsx(cn,{className:"univer-ml-3",disabled:!L(R),id:"max",type:R,value:f,onChange:E=>{y(E||0),m({isGradient:i,minValue:s,minValueType:w,maxValue:E||0,maxValueType:R,positiveColor:d,nativeColor:h,isShowValue:l})}})]})]})]})},ft=e=>[T.BooleanNumber.FALSE,void 0].includes(e)?T.BooleanNumber.TRUE:T.BooleanNumber.FALSE,pt=e=>e!==T.BooleanNumber.FALSE,rn=e=>{const{style:t,onChange:n,className:r}=e,i=J.useDependency(J.ComponentManager),[o,d]=j.useState(()=>{if(t!=null&&t.bl)return t.bl}),[b,h]=j.useState(()=>{if(t!=null&&t.it)return t.it}),[S,v]=j.useState(()=>{if(t!=null&&t.ul)return t.ul.s}),[C,I]=j.useState(()=>{if(t!=null&&t.st)return t.st.s}),[w,x]=j.useState(()=>{var u;const g="#2f56ef";return(u=t==null?void 0:t.cl)!=null&&u.rgb?t.cl.rgb:g}),[R,p]=j.useState(()=>{var u;const g="#e8ecfc";return(u=t==null?void 0:t.bg)!=null&&u.rgb?t.bg.rgb:g}),s=i.get("BoldSingle"),a=i.get("ItalicSingle"),f=i.get("UnderlineSingle"),y=i.get("StrikethroughSingle");j.useEffect(()=>{const g={bl:o,it:b};w!==void 0&&(g.cl={rgb:w}),R!==void 0&&(g.bg={rgb:R}),C!==void 0&&(g.st={s:C}),S!==void 0&&(g.ul={s:S}),n(c.removeUndefinedAttr(g))},[o,b,S,C,w,R]);const l="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return _.jsxs("div",{className:K.clsx("univer-my-2.5 univer-flex univer-justify-between",r),children:[s&&_.jsx("div",{className:K.clsx(l,{"univer-bg-gray-100":pt(o||T.BooleanNumber.FALSE)}),onClick:()=>d(ft(o)),children:_.jsx(s,{})}),a&&_.jsx("div",{className:K.clsx(l,{"univer-bg-gray-100":pt(b||T.BooleanNumber.FALSE)}),onClick:()=>h(ft(b)),children:_.jsx(a,{})}),f&&_.jsx("div",{className:K.clsx(l,{"univer-bg-gray-100":pt(S||T.BooleanNumber.FALSE)}),onClick:()=>v(ft(S)),children:_.jsx(f,{})}),y&&_.jsx("div",{className:K.clsx(l,{"univer-bg-gray-100":pt(C||T.BooleanNumber.FALSE)}),onClick:()=>I(ft(C)),children:_.jsx(y,{})}),_.jsx(De,{color:w,onChange:x,iconId:"FontColor"}),_.jsx(De,{color:R,onChange:p,iconId:"PaintBucket"})]})},Mr=e=>{var y;const{onChange:t,interceptorManager:n}=e,r=J.useDependency(T.LocaleService),o=J.useDependency(T.IUniverInstanceService).getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET),d=o.getActiveSheet(),b=((y=e.rule)==null?void 0:y.type)===c.CFRuleType.highlightCell?e.rule:void 0,h=j.useRef(null),[S,v]=j.useState(!1),C=j.useRef(null),[I,w]=j.useState({}),[x,R]=j.useState(()=>(b==null?void 0:b.subType)===c.CFSubRuleType.formula?b.value:"="),[p,s]=j.useState(void 0),a=l=>({style:l.style,value:x,type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.formula});j.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return a({style:I})}}),[I,x,n]),j.useEffect(()=>n.intercept(n.getInterceptPoints().beforeSubmit,{handler:(g,u,m)=>p||x.length===1||!x.startsWith("=")?(s(r.t("sheet.cf.errorMessage.formulaError")),!1):m(g)}),[p,x]);const f=l=>{t(a(l))};return J.useSidebarClick(l=>{var u;((u=C.current)==null?void 0:u.isClickOutSide(l))&&v(!1)}),_.jsxs("div",{ref:h,children:[_.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),_.jsx("div",{className:"univer-mt-3",children:_.jsx(at.FormulaEditor,{onChange:l=>{R(l),f({style:I})},onVerify:(l,g)=>{!l||g.length===1?s(r.t("sheet.cf.errorMessage.formulaError")):s(void 0)},errorText:p,onFocus:()=>{v(!0)},isFocus:S,initValue:x,unitId:o.getUnitId(),subUnitId:d==null?void 0:d.getSheetId(),ref:C})}),_.jsx("div",{className:ut,children:_.jsx(Ve,{rule:a({style:I})})}),_.jsx(rn,{style:b==null?void 0:b.style,className:"univer-mt-3",onChange:l=>{w(l),f({style:l})}})]})},ht=e=>_.jsxs("div",{style:{position:"relative"},children:[_.jsx("div",{style:{position:"absolute",zIndex:999,bottom:"-13px",fontSize:"10px",color:"red"},children:e.errorText}),e.children]}),ae=(e,t)=>({label:t.t(`sheet.cf.operator.${e}`),value:e}),Nr=e=>{const{type:t,operator:n,onChange:r,value:i,interceptorManager:o}=e,d=J.useDependency(T.LocaleService),[b,h]=j.useState(()=>typeof i=="number"?i:0),[S,v]=j.useState(""),[C,I]=j.useState(()=>typeof i=="string"?i:""),[w,x]=j.useState(""),[R,p]=j.useState(()=>Array.isArray(i)?i[0]===void 0?0:i[0]:0),[s,a]=j.useState(""),[f,y]=j.useState(()=>Array.isArray(i)?i[1]===void 0?100:i[1]:100),[l,g]=j.useState("");switch(j.useEffect(()=>{switch(t){case c.CFSubRuleType.text:{[c.CFTextOperator.beginsWith,c.CFTextOperator.endsWith,c.CFTextOperator.containsText,c.CFTextOperator.notContainsText,c.CFTextOperator.equal,c.CFTextOperator.notEqual].includes(n)&&r(C);break}case c.CFSubRuleType.number:{[c.CFNumberOperator.equal,c.CFNumberOperator.notEqual,c.CFNumberOperator.greaterThan,c.CFNumberOperator.greaterThanOrEqual,c.CFNumberOperator.lessThan,c.CFNumberOperator.lessThanOrEqual].includes(n)&&r(b),[c.CFNumberOperator.between,c.CFNumberOperator.notBetween].includes(n)&&r([R,f]);break}}},[t]),j.useEffect(()=>{const u=o.intercept(o.getInterceptPoints().beforeSubmit,{handler:(m,F,P)=>{switch(t){case c.CFSubRuleType.text:if([c.CFTextOperator.beginsWith,c.CFTextOperator.containsText,c.CFTextOperator.endsWith,c.CFTextOperator.notEqual,c.CFTextOperator.notContainsText,c.CFTextOperator.equal].includes(n))return C?P(m):(x(d.t("sheet.cf.errorMessage.notBlank")),!1)}return P(m)}});return()=>{u()}},[t,b,C,n]),t){case c.CFSubRuleType.text:{if([c.CFTextOperator.beginsWith,c.CFTextOperator.endsWith,c.CFTextOperator.containsText,c.CFTextOperator.notContainsText,c.CFTextOperator.equal,c.CFTextOperator.notEqual].includes(n)){const u=m=>{I(m),r(m)};return _.jsx("div",{className:"univer-mt-3",children:_.jsx(ht,{errorText:w,children:_.jsx(K.Input,{value:C,onChange:m=>{x(""),u(m)}})})})}break}case c.CFSubRuleType.number:{if([c.CFNumberOperator.equal,c.CFNumberOperator.notEqual,c.CFNumberOperator.greaterThan,c.CFNumberOperator.greaterThanOrEqual,c.CFNumberOperator.lessThan,c.CFNumberOperator.lessThanOrEqual].includes(n)){const u=m=>{h(m||0),r(m||0),v("")};return _.jsx("div",{className:"univer-mt-3",children:_.jsx(ht,{errorText:S,children:_.jsx(K.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:b,onChange:u})})})}if([c.CFNumberOperator.between,c.CFNumberOperator.notBetween].includes(n)){const u=F=>{p(F||0),r([F||0,f]),a("")},m=F=>{y(F||0),r([R,F||0]),g("")};return _.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[_.jsx(ht,{errorText:s,children:_.jsx(K.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:R,onChange:u})}),_.jsx(ht,{errorText:l,children:_.jsx(K.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:f,onChange:m})})]})}}}return null},dn=(e,t)=>{switch(e){case c.CFSubRuleType.text:return[ae(c.CFTextOperator.containsText,t),ae(c.CFTextOperator.notContainsText,t),ae(c.CFTextOperator.beginsWith,t),ae(c.CFTextOperator.endsWith,t),ae(c.CFTextOperator.equal,t),ae(c.CFTextOperator.notEqual,t),ae(c.CFTextOperator.containsBlanks,t),ae(c.CFTextOperator.notContainsBlanks,t),ae(c.CFTextOperator.containsErrors,t),ae(c.CFTextOperator.notContainsErrors,t)];case c.CFSubRuleType.number:return[ae(c.CFNumberOperator.between,t),ae(c.CFNumberOperator.notBetween,t),ae(c.CFNumberOperator.equal,t),ae(c.CFNumberOperator.notEqual,t),ae(c.CFNumberOperator.greaterThan,t),ae(c.CFNumberOperator.greaterThanOrEqual,t),ae(c.CFNumberOperator.lessThan,t),ae(c.CFNumberOperator.lessThanOrEqual,t)];case c.CFSubRuleType.timePeriod:return[ae(c.CFTimePeriodOperator.yesterday,t),ae(c.CFTimePeriodOperator.today,t),ae(c.CFTimePeriodOperator.tomorrow,t),ae(c.CFTimePeriodOperator.last7Days,t),ae(c.CFTimePeriodOperator.lastWeek,t),ae(c.CFTimePeriodOperator.thisWeek,t),ae(c.CFTimePeriodOperator.nextWeek,t),ae(c.CFTimePeriodOperator.lastMonth,t),ae(c.CFTimePeriodOperator.thisMonth,t),ae(c.CFTimePeriodOperator.nextMonth,t)]}},fn=e=>{var y;const{interceptorManager:t,onChange:n}=e,r=J.useDependency(T.LocaleService),i=((y=e.rule)==null?void 0:y.type)===c.CFRuleType.highlightCell?e.rule:void 0,[o,d]=j.useState(()=>{const l=c.CFSubRuleType.text;return i&&i.subType||l}),b=[{value:c.CFSubRuleType.text,label:r.t("sheet.cf.subRuleType.text")},{value:c.CFSubRuleType.number,label:r.t("sheet.cf.subRuleType.number")},{value:c.CFSubRuleType.timePeriod,label:r.t("sheet.cf.subRuleType.timePeriod")},{value:c.CFSubRuleType.duplicateValues,label:r.t("sheet.cf.subRuleType.duplicateValues")},{value:c.CFSubRuleType.uniqueValues,label:r.t("sheet.cf.subRuleType.uniqueValues")}],h=j.useMemo(()=>dn(o,r),[o]),[S,v]=j.useState(()=>{const l=h?h[0].value:void 0;return i&&i.operator||l}),[C,I]=j.useState(()=>{var u;const l="";return i?(u=i.value)!=null?u:c.createDefaultValue(i.subType,i.operator):l}),[w,x]=j.useState({}),R=j.useMemo(()=>l=>{var g,u,m,F,P,L,U,E,N,A,W,G,re,te,se;switch(l.subType||o){case c.CFSubRuleType.text:{if([c.CFTextOperator.beginsWith,c.CFTextOperator.endsWith,c.CFTextOperator.containsText,c.CFTextOperator.notContainsText,c.CFTextOperator.equal,c.CFTextOperator.notEqual].includes(S))return{type:c.CFRuleType.highlightCell,subType:(g=l.subType)!=null?g:o,operator:(u=l.operator)!=null?u:S,style:(m=l.style)!=null?m:w,value:(F=l.value)!=null?F:C};break}case c.CFSubRuleType.number:{if([c.CFNumberOperator.equal,c.CFNumberOperator.notEqual,c.CFNumberOperator.greaterThan,c.CFNumberOperator.greaterThanOrEqual,c.CFNumberOperator.lessThan,c.CFNumberOperator.lessThanOrEqual].includes(S))return{type:c.CFRuleType.highlightCell,subType:(P=l.subType)!=null?P:o,operator:(L=l.operator)!=null?L:S,style:(U=l.style)!=null?U:w,value:(E=l.value)!=null?E:C};if([c.CFNumberOperator.between,c.CFNumberOperator.notBetween].includes(S))return{type:c.CFRuleType.highlightCell,subType:(N=l.subType)!=null?N:o,operator:(A=l.operator)!=null?A:S,style:(W=l.style)!=null?W:w,value:(G=l.value)!=null?G:C};break}}return{type:c.CFRuleType.highlightCell,subType:(re=l.subType)!=null?re:o,operator:(te=l.operator)!=null?te:S,style:(se=l.style)!=null?se:w}},[o,S,C,w]);j.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return R({})}}),[R,t]),j.useEffect(()=>{b.some(l=>l.value===o)||d(b[0].value)},[b]);const p=l=>{const g=l,u=dn(g,r),m=u&&u[0].value;d(g),v(m),m&&I(c.createDefaultValue(g,m)),n(R({subType:g,operator:m}))},s=l=>{const g=l;v(g),n(R({operator:g}))},a=l=>{I(l),n(R({value:l}))},f=j.useMemo(()=>`${o}_${S}_${Math.random()}`,[o,S]);return _.jsxs("div",{children:[_.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),_.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[_.jsx(K.Select,{className:"univer-mt-3 univer-w-full",onChange:p,value:o,options:b}),(h==null?void 0:h.length)&&_.jsx(K.Select,{className:"univer-mt-3 univer-w-full",onChange:s,value:S||"",options:h})]}),_.jsx(Nr,{value:C,interceptorManager:t,type:o,operator:S,rule:i,onChange:a},f),_.jsx("div",{className:ut,children:_.jsx(Ve,{rule:R({})})}),_.jsx(rn,{style:i==null?void 0:i.style,className:"univer-ml-1",onChange:l=>{x(l),n(R({style:l}))}})]})},tr=(e,t)=>(c.iconMap[e]||[])[Number(t)]||"",jr=e=>{var v;const{error:t,type:n,onChange:r}=e,i=J.useDependency(T.IUniverInstanceService),o=i.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(v=i.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:v.getSheetId(),b=j.useRef(null),[h,S]=j.useState(!1);return J.useSidebarClick(C=>{var w;((w=b.current)==null?void 0:w.isClickOutSide(C))&&S(!1)}),_.jsx("div",{className:"univer-relative",children:n!==c.CFValueType.formula?_.jsxs(_.Fragment,{children:[_.jsx(K.InputNumber,{className:K.clsx({"univer-border-red-500":t}),value:Number(e.value)||0,onChange:C=>r(C!=null?C:0)}),t&&_.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:t})]}):_.jsx("div",{className:"univer-w-full",children:_.jsx(at.FormulaEditor,{ref:b,initValue:String(e.value),unitId:o,subUnitId:d,isFocus:h,onChange:(C="")=>{r(C||"")},onFocus:()=>S(!0)})})})},pn=(e,t,n)=>({operator:c.CFNumberOperator.greaterThan,value:{type:c.CFValueType.num,value:(n.length-1-t)*10},iconType:e,iconId:String(t)}),Lr=j.forwardRef((e,t)=>{const{onClick:n}=e,r=J.useDependency(T.LocaleService),i=o=>{n(o)};return _.jsx("div",{ref:t,className:"univer-w-80",children:c.iconGroup.map((o,d)=>_.jsxs("div",{className:"univer-mb-3",children:[_.jsx("div",{className:"univer-mb-1 univer-text-sm",children:r.t(o.title)}),_.jsx("div",{className:"univer-flex univer-flex-wrap",children:o.group.map(b=>_.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{i(b.name)},children:_.jsx("a",{className:`
4
+ `,o),children:[l.jsx(m,{className:"univer-fill-primary-600",extend:{colorChannel1:c.isValid?e:""}}),u&&l.jsx(Le,{className:"univer-ml-1.5 univer-text-[10px] univer-text-gray-400"})]})}):null},de=n=>{var o,u,v;const e=n.rule;if(!e)return null;const i=C.useMemo(()=>{if(e.type===t.CFRuleType.colorScale){const c=e.config.map((h,p)=>({color:new a.ColorKit(h.color),value:p})),m=c.length-1;return new Array(5).fill("").map((h,p,y)=>p*m/(y.length-1)).map(h=>t.getColorScaleFromValue(c,h))}return null},[e]),r=C.useMemo(()=>{if(e.type===t.CFRuleType.iconSet)return e.config.map(c=>{const m=t.iconMap[c.iconType];return m&&m[Number(c.iconId)]})},[e]),s=`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 t.CFRuleType.dataBar:{const{isGradient:c}=e.config,m=c?`linear-gradient(to right, ${e.config.positiveColor||t.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,d=c?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||t.defaultDataBarNativeColor})`:e.config.nativeColor;return l.jsxs("div",{className:s,children:[l.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:d,border:`1px solid ${e.config.nativeColor||t.defaultDataBarNativeColor}`}}),l.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:m,border:`1px solid ${e.config.positiveColor||t.defaultDataBarPositiveColor}`}})]})}case t.CFRuleType.colorScale:return i&&l.jsx("div",{className:s,children:i.map((c,m)=>l.jsx("div",{className:"univer-h-full",style:{width:`${100/i.length}%`,background:c}},m))});case t.CFRuleType.iconSet:return r&&l.jsx("div",{className:s,children:r.map((c,m)=>c?l.jsx("img",{className:"univer-h-full",src:c,draggable:!1},m):l.jsx(xe,{},m))});case t.CFRuleType.highlightCell:{const{ul:c,st:m,it:d,bl:h,bg:p,cl:y}=e.style,x=(c==null?void 0:c.s)===a.BooleanNumber.TRUE,S=(m==null?void 0:m.s)===a.BooleanNumber.TRUE,_=d===a.BooleanNumber.TRUE,F=h===a.BooleanNumber.TRUE,j=(o=p==null?void 0:p.rgb)!=null?o:t.DEFAULT_BG_COLOR,N=(u=y==null?void 0:y.rgb)!=null?u:t.DEFAULT_FONT_COLOR,E={textDecoration:(v=`${x?"underline":""} ${S?"line-through":""}`.replace(/^ /,""))!=null?v:void 0,backgroundColor:j,color:N};return l.jsx("div",{className:U.clsx(s,{"univer-font-bold":F,"univer-italic":_}),style:E,children:"123"})}}},Re="univer-mt-5 univer-px-1 univer-py-2 univer-border univer-border-solid univer-border-gray-200 univer-rounded",ne=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),$e=n=>{var x;const{type:e,className:i,onChange:r,id:s,value:o}=n,u=k.useDependency(a.IUniverInstanceService),v=u.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(x=u.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:x.getSheetId(),m=C.useMemo(()=>String(o).startsWith("=")?String(o):"=",[o]),d=C.useMemo(()=>[t.CFValueType.max,t.CFValueType.min,"none"].includes(e)?{disabled:!0}:[t.CFValueType.percent,t.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),h=C.useRef(null),[p,y]=C.useState(!1);return k.useSidebarClick(S=>{var F;((F=h.current)==null?void 0:F.isClickOutSide(S))&&y(!1)}),e===t.CFValueType.formula?l.jsx("div",{className:"univer-ml-1 univer-w-full",children:l.jsx(Te.FormulaEditor,{ref:h,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:m,unitId:v,subUnitId:c,isFocus:p,onChange:(S="")=>{r(S||"")},onFocus:()=>y(!0)})}):l.jsx(U.InputNumber,{className:i,value:Number(n.value)||0,onChange:S=>n.onChange(S||0),...d})},Ut=n=>{var P;const{interceptorManager:e}=n,i=k.useDependency(a.LocaleService),r=((P=n.rule)==null?void 0:P.type)===t.CFRuleType.colorScale?n.rule:void 0,s=[ne(t.CFValueType.num,i),ne(t.CFValueType.percent,i),ne(t.CFValueType.percentile,i),ne(t.CFValueType.formula,i)],o=[ne(t.CFValueType.min,i),...s],u=[ne("none",i),...s],v=[ne(t.CFValueType.max,i),...s],[c,m]=C.useState(()=>{var R;const f=t.CFValueType.min;return r&&((R=r.config[0])==null?void 0:R.value.type)||f}),[d,h]=C.useState(()=>{var R;const f="none";return!r||r.config.length!==3?f:((R=r.config[1])==null?void 0:R.value.type)||f}),[p,y]=C.useState(()=>{var R;const f=t.CFValueType.max;return r&&((R=r.config[r.config.length-1])==null?void 0:R.value.type)||f}),[x,S]=C.useState(()=>{if(!r)return 10;const R=r.config[0];return(R==null?void 0:R.value.value)===void 0?10:R==null?void 0:R.value.value}),[_,F]=C.useState(()=>{var A;if(!r||r.config.length!==3)return 50;const R=(A=r.config[1])==null?void 0:A.value.value;return R===void 0?50:R}),[j,N]=C.useState(()=>{var A;if(!r)return 90;const R=(A=r.config[r.config.length-1])==null?void 0:A.value.value;return R===void 0?90:R}),[E,g]=C.useState(()=>{var R;const f="#d0d9fb";return r&&((R=r.config[0])==null?void 0:R.color)||f}),[b,T]=C.useState(()=>{var R;const f="#7790f3";return!r||r.config.length!==3?f:((R=r.config[1])==null?void 0:R.color)||f}),[I,w]=C.useState(()=>{var R;const f="#2e55ef";return r&&((R=r.config[r.config.length-1])==null?void 0:R.color)||f}),M=C.useMemo(()=>f=>{const{minType:R,medianType:A,maxType:q,minValue:X,medianValue:J,maxValue:ie,minColor:se,medianColor:D,maxColor:L}=f,B=[];return B.push({color:se,value:{type:R,value:X}}),A!=="none"&&B.push({color:D,value:{type:A,value:J}}),B.push({color:L,value:{type:q,value:ie}}),{config:B.map((G,z)=>({...G,index:z})),type:t.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return M({minType:c,medianType:d,maxType:p,minValue:x,medianValue:_,maxValue:j,minColor:E,medianColor:b,maxColor:I})}}),[M,c,d,p,x,_,j,E,b,I,e]);const V=f=>{n.onChange(M(f))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:i.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:M({minType:c,medianType:d,maxType:p,minValue:x,medianValue:_,maxValue:j,minColor:E,medianColor:b,maxColor:I})})}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:i.t("sheet.cf.valueType.min")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[l.jsx(U.Select,{className:"univer-flex-shrink-0",options:o,value:c,onChange:f=>{m(f);const R=t.createDefaultValueByValueType(f,10);S(R),V({minType:f,medianType:d,maxType:p,minValue:R,medianValue:_,maxValue:j,minColor:E,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"min",className:"univer-ml-1",value:x,type:c,onChange:f=>{S(f),V({minType:c,medianType:d,maxType:p,minValue:f,medianValue:_,maxValue:j,minColor:E,medianColor:b,maxColor:I})}}),l.jsx(re,{className:"univer-ml-1",color:E,onChange:f=>{g(f),V({minType:c,medianType:d,maxType:p,minValue:x,medianValue:_,maxValue:j,minColor:f,medianColor:b,maxColor:I})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:i.t("sheet.cf.panel.medianValue")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[l.jsx(U.Select,{className:"univer-flex-shrink-0",options:u,value:d,onChange:f=>{h(f);const R=t.createDefaultValueByValueType(f,50);F(R),V({minType:c,medianType:f,maxType:p,minValue:x,medianValue:R,maxValue:j,minColor:E,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"median",className:"univer-ml-1",value:_,type:d,onChange:f=>{F(f),V({minType:c,medianType:d,maxType:p,minValue:x,medianValue:f,maxValue:j,minColor:E,medianColor:b,maxColor:I})}}),d!=="none"&&l.jsx(re,{className:"univer-ml-1",color:b,onChange:f=>{T(f),V({minType:c,medianType:d,maxType:p,minValue:x,medianValue:_,maxValue:j,minColor:E,medianColor:f,maxColor:I})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600",children:i.t("sheet.cf.valueType.max")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[l.jsx(U.Select,{className:"univer-flex-shrink-0",options:v,value:p,onChange:f=>{y(f);const R=t.createDefaultValueByValueType(f,90);N(R),V({minType:c,medianType:d,maxType:f,minValue:x,medianValue:_,maxValue:R,minColor:E,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"max",className:"univer-ml-1",value:j,type:p,onChange:f=>{N(f),V({minType:c,medianType:d,maxType:p,minValue:x,medianValue:_,maxValue:f,minColor:E,medianColor:b,maxColor:I})}}),l.jsx(re,{className:"univer-ml-1",color:I,onChange:f=>{w(f),V({minType:c,medianType:d,maxType:p,minValue:x,medianValue:_,maxValue:j,minColor:E,medianColor:b,maxColor:f})}})]})]})},oe=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),rt=n=>{var S;const{onChange:e,className:i,value:r,type:s,id:o,disabled:u=!1}=n,v=k.useDependency(a.IUniverInstanceService),c=v.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),m=(S=v.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId(),d=C.useRef(null),[h,p]=C.useState(!1);k.useSidebarClick(_=>{var j;((j=d.current)==null?void 0:j.isClickOutSide(_))&&p(!1)});const y=C.useRef(r),x=C.useMemo(()=>[t.CFValueType.percentile,t.CFValueType.percent].includes(s)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[s]);if(s===t.CFValueType.formula){const _=String(y.current).startsWith("=")?String(y.current)||"":"=";return l.jsx("div",{className:"univer-ml-3 univer-w-full",children:l.jsx(Te.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:_,unitId:c,subUnitId:m,isFocus:h,onChange:(F="")=>{e(F||"")},onFocus:()=>p(!0)})})}return l.jsx(U.InputNumber,{className:i,value:Number(r)||0,disabled:u,onChange:_=>{e(_||0)},...x})},kt=n=>{var P;const{interceptorManager:e}=n,i=k.useDependency(a.LocaleService),r=((P=n.rule)==null?void 0:P.type)===t.CFRuleType.dataBar?n.rule:void 0,[s,o]=C.useState(()=>{var R;const f="0";return r?(R=r.config)!=null&&R.isGradient?"1":"0":f}),[u,v]=C.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.positiveColor)||t.defaultDataBarPositiveColor}),[c,m]=C.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.nativeColor)||t.defaultDataBarNativeColor}),d=[oe(t.CFValueType.num,i),oe(t.CFValueType.percent,i),oe(t.CFValueType.percentile,i),oe(t.CFValueType.formula,i)],h=[oe(t.CFValueType.min,i),...d],p=[oe(t.CFValueType.max,i),...d],[y,x]=C.useState(()=>{var R;const f=h[0].value;return r&&((R=r.config)==null?void 0:R.min.type)||f}),[S,_]=C.useState(()=>{var R;const f=p[0].value;return r&&((R=r.config)==null?void 0:R.max.type)||f}),[F,j]=C.useState(()=>{var A;if(!r)return 0;const R=((A=r.config)==null?void 0:A.min)||{};return R.type===t.CFValueType.formula?R.value||"=":R.value||0}),[N,E]=C.useState(()=>{var A;if(!r)return 100;const R=((A=r.config)==null?void 0:A.max)||{};return R.type===t.CFValueType.formula?R.value||"=":R.value===void 0?100:R.value}),[g,b]=C.useState(()=>r?r.isShowValue===void 0?!0:!!r.isShowValue:!0),T=f=>({config:{min:{type:f.minValueType,value:f.minValue},max:{type:f.maxValueType,value:f.maxValue},isGradient:f.isGradient==="1",positiveColor:f.positiveColor||t.defaultDataBarPositiveColor,nativeColor:f.nativeColor||t.defaultDataBarNativeColor},type:t.CFRuleType.dataBar,isShowValue:f.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return T({isGradient:s,minValue:F,minValueType:y,maxValue:N,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}}),[s,F,y,N,S,u,c,e,g]);const I=f=>{n.onChange(T(f))},w=f=>{v(f),I({isGradient:s,minValue:F,minValueType:y,maxValue:N,maxValueType:S,positiveColor:f,nativeColor:c,isShowValue:g})},M=f=>{m(f),I({isGradient:s,minValue:F,minValueType:y,maxValue:N,maxValueType:S,positiveColor:u,nativeColor:f,isShowValue:g})},V=f=>d.map(R=>R.value).includes(f);return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:i.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:T({isGradient:s,minValue:F,minValueType:y,maxValue:N,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})})}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:i.t("sheet.cf.panel.fillType")}),l.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[l.jsxs(U.RadioGroup,{value:s,onChange:f=>{o(f),I({isGradient:f,minValue:F,minValueType:y,maxValue:N,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})},children:[l.jsx(U.Radio,{value:"0",children:l.jsx("span",{className:"univer-text-xs",children:i.t("sheet.cf.panel.pureColor")})}),l.jsx(U.Radio,{value:"1",children:l.jsx("span",{className:"univer-text-xs",children:i.t("sheet.cf.panel.gradient")})})]}),l.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[l.jsx(U.Checkbox,{checked:!g,onChange:f=>{b(!f),I({isGradient:f,minValue:F,minValueType:y,maxValue:N,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:!f})}}),i.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:i.t("sheet.cf.panel.colorSet")}),l.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[l.jsxs("div",{className:"univer-flex univer-items-center",children:[l.jsx("div",{className:"univer-text-xs",children:i.t("sheet.cf.panel.native")}),l.jsx(re,{color:c,onChange:M})]}),l.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[l.jsx("div",{className:"univer-text-xs",children:i.t("sheet.cf.panel.positive")}),l.jsx(re,{color:u,onChange:w})]})]})]}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:i.t("sheet.cf.valueType.min")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(U.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:y,onChange:f=>{x(f);const R=t.createDefaultValueByValueType(f,10);j(R),I({isGradient:s,minValue:R,minValueType:f,maxValue:N,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}}),l.jsx(rt,{id:"min",className:"univer-ml-3",disabled:!V(y),type:y,value:F,onChange:f=>{j(f||0),I({isGradient:s,minValue:f||0,minValueType:y,maxValue:N,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600",children:i.t("sheet.cf.valueType.max")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(U.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:p,value:S,onChange:f=>{_(f);const R=t.createDefaultValueByValueType(f,90);E(R),I({isGradient:s,minValue:F,minValueType:y,maxValue:R,maxValueType:f,positiveColor:u,nativeColor:c,isShowValue:g})}}),l.jsx(rt,{className:"univer-ml-3",disabled:!V(S),id:"max",type:S,value:N,onChange:f=>{E(f||0),I({isGradient:s,minValue:F,minValueType:y,maxValue:f||0,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}})]})]})]})},je=n=>[a.BooleanNumber.FALSE,void 0].includes(n)?a.BooleanNumber.TRUE:a.BooleanNumber.FALSE,Ee=n=>n!==a.BooleanNumber.FALSE,nt=n=>{const{style:e,onChange:i,className:r}=n,s=k.useDependency(k.ComponentManager),[o,u]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[v,c]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[m,d]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[h,p]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[y,x]=C.useState(()=>{var T;const b="#2f56ef";return(T=e==null?void 0:e.cl)!=null&&T.rgb?e.cl.rgb:b}),[S,_]=C.useState(()=>{var T;const b="#e8ecfc";return(T=e==null?void 0:e.bg)!=null&&T.rgb?e.bg.rgb:b}),F=s.get("BoldSingle"),j=s.get("ItalicSingle"),N=s.get("UnderlineSingle"),E=s.get("StrikethroughSingle");C.useEffect(()=>{const b={bl:o,it:v};y!==void 0&&(b.cl={rgb:y}),S!==void 0&&(b.bg={rgb:S}),h!==void 0&&(b.st={s:h}),m!==void 0&&(b.ul={s:m}),i(t.removeUndefinedAttr(b))},[o,v,m,h,y,S]);const g="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return l.jsxs("div",{className:U.clsx("univer-my-2.5 univer-flex univer-justify-between",r),children:[F&&l.jsx("div",{className:U.clsx(g,{"univer-bg-gray-100":Ee(o||a.BooleanNumber.FALSE)}),onClick:()=>u(je(o)),children:l.jsx(F,{})}),j&&l.jsx("div",{className:U.clsx(g,{"univer-bg-gray-100":Ee(v||a.BooleanNumber.FALSE)}),onClick:()=>c(je(v)),children:l.jsx(j,{})}),N&&l.jsx("div",{className:U.clsx(g,{"univer-bg-gray-100":Ee(m||a.BooleanNumber.FALSE)}),onClick:()=>d(je(m)),children:l.jsx(N,{})}),E&&l.jsx("div",{className:U.clsx(g,{"univer-bg-gray-100":Ee(h||a.BooleanNumber.FALSE)}),onClick:()=>p(je(h)),children:l.jsx(E,{})}),l.jsx(re,{color:y,onChange:x,iconId:"FontColor"}),l.jsx(re,{color:S,onChange:_,iconId:"PaintBucket"})]})},Pt=n=>{var E;const{onChange:e,interceptorManager:i}=n,r=k.useDependency(a.LocaleService),o=k.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),u=o.getActiveSheet(),v=((E=n.rule)==null?void 0:E.type)===t.CFRuleType.highlightCell?n.rule:void 0,c=C.useRef(null),[m,d]=C.useState(!1),h=C.useRef(null),[p,y]=C.useState({}),[x,S]=C.useState(()=>(v==null?void 0:v.subType)===t.CFSubRuleType.formula?v.value:"="),[_,F]=C.useState(void 0),j=g=>({style:g.style,value:x,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});C.useEffect(()=>i.intercept(i.getInterceptPoints().submit,{handler(){return j({style:p})}}),[p,x,i]),C.useEffect(()=>i.intercept(i.getInterceptPoints().beforeSubmit,{handler:(b,T,I)=>_||x.length===1||!x.startsWith("=")?(F(r.t("sheet.cf.errorMessage.formulaError")),!1):I(b)}),[_,x]);const N=g=>{e(j(g))};return k.useSidebarClick(g=>{var T;((T=h.current)==null?void 0:T.isClickOutSide(g))&&d(!1)}),l.jsxs("div",{ref:c,children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:"univer-mt-3",children:l.jsx(Te.FormulaEditor,{ref:h,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:_,isFocus:m,initValue:x,unitId:o.getUnitId(),subUnitId:u==null?void 0:u.getSheetId(),onFocus:()=>{d(!0)},onChange:g=>{S(g),N({style:p})},onVerify:(g,b)=>{!g||b.length===1?F(r.t("sheet.cf.errorMessage.formulaError")):F(void 0)}})}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:j({style:p})})}),l.jsx(nt,{style:v==null?void 0:v.style,className:"univer-mt-3",onChange:g=>{y(g),N({style:g})}})]})},Ne=n=>l.jsxs("div",{style:{position:"relative"},children:[l.jsx("div",{style:{position:"absolute",zIndex:999,bottom:"-13px",fontSize:"10px",color:"red"},children:n.errorText}),n.children]}),$=(n,e)=>({label:e.t(`sheet.cf.operator.${n}`),value:n}),Dt=n=>{const{type:e,operator:i,onChange:r,value:s,interceptorManager:o}=n,u=k.useDependency(a.LocaleService),[v,c]=C.useState(()=>typeof s=="number"?s:0),[m,d]=C.useState(""),[h,p]=C.useState(()=>typeof s=="string"?s:""),[y,x]=C.useState(""),[S,_]=C.useState(()=>Array.isArray(s)?s[0]===void 0?0:s[0]:0),[F,j]=C.useState(""),[N,E]=C.useState(()=>Array.isArray(s)?s[1]===void 0?100:s[1]:100),[g,b]=C.useState("");switch(C.useEffect(()=>{switch(e){case t.CFSubRuleType.text:{[t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(i)&&r(h);break}case t.CFSubRuleType.number:{[t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(i)&&r(v),[t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(i)&&r([S,N]);break}}},[e]),C.useEffect(()=>{const T=o.intercept(o.getInterceptPoints().beforeSubmit,{handler:(I,w,M)=>{switch(e){case t.CFSubRuleType.text:if([t.CFTextOperator.beginsWith,t.CFTextOperator.containsText,t.CFTextOperator.endsWith,t.CFTextOperator.notEqual,t.CFTextOperator.notContainsText,t.CFTextOperator.equal].includes(i))return h?M(I):(x(u.t("sheet.cf.errorMessage.notBlank")),!1)}return M(I)}});return()=>{T()}},[e,v,h,i]),e){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(i)){const T=I=>{p(I),r(I)};return l.jsx("div",{className:"univer-mt-3",children:l.jsx(Ne,{errorText:y,children:l.jsx(U.Input,{value:h,onChange:I=>{x(""),T(I)}})})})}break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(i)){const T=I=>{c(I||0),r(I||0),d("")};return l.jsx("div",{className:"univer-mt-3",children:l.jsx(Ne,{errorText:m,children:l.jsx(U.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:v,onChange:T})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(i)){const T=w=>{_(w||0),r([w||0,N]),j("")},I=w=>{E(w||0),r([S,w||0]),b("")};return l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(Ne,{errorText:F,children:l.jsx(U.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:S,onChange:T})}),l.jsx(Ne,{errorText:g,children:l.jsx(U.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:N,onChange:I})})]})}}}return null},it=(n,e)=>{switch(n){case t.CFSubRuleType.text:return[$(t.CFTextOperator.containsText,e),$(t.CFTextOperator.notContainsText,e),$(t.CFTextOperator.beginsWith,e),$(t.CFTextOperator.endsWith,e),$(t.CFTextOperator.equal,e),$(t.CFTextOperator.notEqual,e),$(t.CFTextOperator.containsBlanks,e),$(t.CFTextOperator.notContainsBlanks,e),$(t.CFTextOperator.containsErrors,e),$(t.CFTextOperator.notContainsErrors,e)];case t.CFSubRuleType.number:return[$(t.CFNumberOperator.between,e),$(t.CFNumberOperator.notBetween,e),$(t.CFNumberOperator.equal,e),$(t.CFNumberOperator.notEqual,e),$(t.CFNumberOperator.greaterThan,e),$(t.CFNumberOperator.greaterThanOrEqual,e),$(t.CFNumberOperator.lessThan,e),$(t.CFNumberOperator.lessThanOrEqual,e)];case t.CFSubRuleType.timePeriod:return[$(t.CFTimePeriodOperator.yesterday,e),$(t.CFTimePeriodOperator.today,e),$(t.CFTimePeriodOperator.tomorrow,e),$(t.CFTimePeriodOperator.last7Days,e),$(t.CFTimePeriodOperator.lastWeek,e),$(t.CFTimePeriodOperator.thisWeek,e),$(t.CFTimePeriodOperator.nextWeek,e),$(t.CFTimePeriodOperator.lastMonth,e),$(t.CFTimePeriodOperator.thisMonth,e),$(t.CFTimePeriodOperator.nextMonth,e)]}},st=n=>{var E;const{interceptorManager:e,onChange:i}=n,r=k.useDependency(a.LocaleService),s=((E=n.rule)==null?void 0:E.type)===t.CFRuleType.highlightCell?n.rule:void 0,[o,u]=C.useState(()=>{const g=t.CFSubRuleType.text;return s&&s.subType||g}),v=[{value:t.CFSubRuleType.text,label:r.t("sheet.cf.subRuleType.text")},{value:t.CFSubRuleType.number,label:r.t("sheet.cf.subRuleType.number")},{value:t.CFSubRuleType.timePeriod,label:r.t("sheet.cf.subRuleType.timePeriod")},{value:t.CFSubRuleType.duplicateValues,label:r.t("sheet.cf.subRuleType.duplicateValues")},{value:t.CFSubRuleType.uniqueValues,label:r.t("sheet.cf.subRuleType.uniqueValues")}],c=C.useMemo(()=>it(o,r),[o]),[m,d]=C.useState(()=>{const g=c?c[0].value:void 0;return s&&s.operator||g}),[h,p]=C.useState(()=>{var T;const g="";return s?(T=s.value)!=null?T:t.createDefaultValue(s.subType,s.operator):g}),[y,x]=C.useState({}),S=C.useMemo(()=>g=>{var b,T,I,w,M,V,P,f,R,A,q,X,J,ie,se;switch(g.subType||o){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(m))return{type:t.CFRuleType.highlightCell,subType:(b=g.subType)!=null?b:o,operator:(T=g.operator)!=null?T:m,style:(I=g.style)!=null?I:y,value:(w=g.value)!=null?w:h};break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(m))return{type:t.CFRuleType.highlightCell,subType:(M=g.subType)!=null?M:o,operator:(V=g.operator)!=null?V:m,style:(P=g.style)!=null?P:y,value:(f=g.value)!=null?f:h};if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(m))return{type:t.CFRuleType.highlightCell,subType:(R=g.subType)!=null?R:o,operator:(A=g.operator)!=null?A:m,style:(q=g.style)!=null?q:y,value:(X=g.value)!=null?X:h};break}}return{type:t.CFRuleType.highlightCell,subType:(J=g.subType)!=null?J:o,operator:(ie=g.operator)!=null?ie:m,style:(se=g.style)!=null?se:y}},[o,m,h,y]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return S({})}}),[S,e]),C.useEffect(()=>{v.some(g=>g.value===o)||u(v[0].value)},[v]);const _=g=>{const b=g,T=it(b,r),I=T&&T[0].value;u(b),d(I),I&&p(t.createDefaultValue(b,I)),i(S({subType:b,operator:I}))},F=g=>{const b=g;d(b),i(S({operator:b}))},j=g=>{p(g),i(S({value:g}))},N=C.useMemo(()=>`${o}_${m}_${Math.random()}`,[o,m]);return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),l.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[l.jsx(U.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:o,options:v}),(c==null?void 0:c.length)&&l.jsx(U.Select,{className:"univer-mt-3 univer-w-full",onChange:F,value:m||"",options:c})]}),l.jsx(Dt,{value:h,interceptorManager:e,type:o,operator:m,rule:s,onChange:j},N),l.jsx("div",{className:Re,children:l.jsx(de,{rule:S({})})}),l.jsx(nt,{style:s==null?void 0:s.style,className:"univer-ml-1",onChange:g=>{x(g),i(S({style:g}))}})]})},Ct=(n,e)=>(t.iconMap[n]||[])[Number(e)]||"",At=n=>{var d;const{error:e,type:i,onChange:r}=n,s=k.useDependency(a.IUniverInstanceService),o=s.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),u=(d=s.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),v=C.useRef(null),[c,m]=C.useState(!1);return k.useSidebarClick(h=>{var y;((y=v.current)==null?void 0:y.isClickOutSide(h))&&m(!1)}),l.jsx("div",{className:"univer-relative",children:i!==t.CFValueType.formula?l.jsxs(l.Fragment,{children:[l.jsx(U.InputNumber,{className:U.clsx({"univer-border-red-500":e}),value:Number(n.value)||0,onChange:h=>r(h!=null?h:0)}),e&&l.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):l.jsx("div",{className:"univer-w-full",children:l.jsx(Te.FormulaEditor,{ref:v,initValue:String(n.value),unitId:o,subUnitId:u,isFocus:c,onChange:(h="")=>{r(h||"")},onFocus:()=>m(!0)})})})},ot=(n,e,i)=>({operator:t.CFNumberOperator.greaterThan,value:{type:t.CFValueType.num,value:(i.length-1-e)*10},iconType:n,iconId:String(e)}),Lt=C.forwardRef((n,e)=>{const{onClick:i}=n,r=k.useDependency(a.LocaleService),s=o=>{i(o)};return l.jsx("div",{ref:e,className:"univer-w-80",children:t.iconGroup.map((o,u)=>l.jsxs("div",{className:"univer-mb-3",children:[l.jsx("div",{className:"univer-mb-1 univer-text-sm",children:r.t(o.title)}),l.jsx("div",{className:"univer-flex univer-flex-wrap",children:o.group.map(v=>l.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{s(v.name)},children:l.jsx("a",{className:`
6
30
  univer-cursor-pointer univer-rounded
7
31
  hover:univer-bg-gray-100
8
- `,children:b.list.map((h,S)=>_.jsx("img",{className:"univer-size-5",src:h,draggable:!1},S))})},b.name))})]},d))})}),Ur=e=>{const{onClick:t}=e,n=j.useMemo(()=>{const i=[];for(const o in c.iconMap){const d=c.iconMap[o],b=o;d.forEach((h,S)=>{i.push({iconType:b,base64:h,iconId:String(S)})})}return i},[]),r=i=>{t(i.iconType,i.iconId)};return _.jsxs("div",{children:[_.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>r({iconType:c.EMPTY_ICON_TYPE,iconId:""}),children:[_.jsx(lt,{className:"univer-size-5"}),_.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),_.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:n.map(i=>_.jsx("div",{className:`
32
+ `,children:v.list.map((c,m)=>l.jsx("img",{className:"univer-size-5",src:c,draggable:!1},m))})},v.name))})]},u))})}),$t=n=>{const{onClick:e}=n,i=C.useMemo(()=>{const s=[];for(const o in t.iconMap){const u=t.iconMap[o],v=o;u.forEach((c,m)=>{s.push({iconType:v,base64:c,iconId:String(m)})})}return s},[]),r=s=>{e(s.iconType,s.iconId)};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>r({iconType:t.EMPTY_ICON_TYPE,iconId:""}),children:[l.jsx(xe,{className:"univer-size-5"}),l.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),l.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:i.map(s=>l.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:_.jsx("img",{className:"univer-size-5",src:i.base64,draggable:!1,onClick:()=>r(i)})},`${i.iconType}_${i.iconId}`))})]})},Vr=e=>{const{onChange:t,configList:n,errorMap:r={}}=e,i=J.useDependency(T.LocaleService),o=[{label:i.t(`sheet.cf.symbol.${c.CFNumberOperator.greaterThan}`),value:c.CFNumberOperator.greaterThan},{label:i.t(`sheet.cf.symbol.${c.CFNumberOperator.greaterThanOrEqual}`),value:c.CFNumberOperator.greaterThanOrEqual}],d=[{label:i.t(`sheet.cf.valueType.${c.CFValueType.num}`),value:c.CFValueType.num},{label:i.t(`sheet.cf.valueType.${c.CFValueType.percent}`),value:c.CFValueType.percent},{label:i.t(`sheet.cf.valueType.${c.CFValueType.percentile}`),value:c.CFValueType.percentile},{label:i.t(`sheet.cf.valueType.${c.CFValueType.formula}`),value:c.CFValueType.formula}],b=(C,I)=>{t([String(I),"value","value"],C)},h=(C,I)=>{t([String(I),"operator"],C);const w=c.createDefaultValue(c.CFSubRuleType.number,C);b(w,I)},S=(C,I)=>{t([String(I),"value","type"],C);const w=n[I],x=c.createDefaultValue(c.CFSubRuleType.number,w.operator);b(x,I)};return j.useMemo(()=>n.map((C,I)=>{const w=r[I],x=tr(C.iconType,C.iconId),R=I===n.length-1,p=I===0,s=n[I-1],a=(s==null?void 0:s.value.type)===c.CFValueType.formula?i.t("sheet.cf.valueType.formula"):s==null?void 0:s.value.value,f=(y,l)=>{const g={...C,iconId:l,iconType:y};t([String(I)],g)};return _.jsxs("div",{className:I?"univer-mt-6":"univer-mt-3",children:[_.jsxs("div",{className:`
36
+ `,children:l.jsx("img",{className:"univer-size-5",src:s.base64,draggable:!1,onClick:()=>r(s)})},`${s.iconType}_${s.iconId}`))})]})},Bt=n=>{const{onChange:e,configList:i,errorMap:r={}}=n,s=k.useDependency(a.LocaleService),o=[{label:s.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThan}`),value:t.CFNumberOperator.greaterThan},{label:s.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThanOrEqual}`),value:t.CFNumberOperator.greaterThanOrEqual}],u=[{label:s.t(`sheet.cf.valueType.${t.CFValueType.num}`),value:t.CFValueType.num},{label:s.t(`sheet.cf.valueType.${t.CFValueType.percent}`),value:t.CFValueType.percent},{label:s.t(`sheet.cf.valueType.${t.CFValueType.percentile}`),value:t.CFValueType.percentile},{label:s.t(`sheet.cf.valueType.${t.CFValueType.formula}`),value:t.CFValueType.formula}],v=(h,p)=>{e([String(p),"value","value"],h)},c=(h,p)=>{e([String(p),"operator"],h);const y=t.createDefaultValue(t.CFSubRuleType.number,h);v(y,p)},m=(h,p)=>{e([String(p),"value","type"],h);const y=i[p],x=t.createDefaultValue(t.CFSubRuleType.number,y.operator);v(x,p)};return C.useMemo(()=>i.map((h,p)=>{const y=r[p],x=Ct(h.iconType,h.iconId),S=p===i.length-1,_=p===0,F=i[p-1],j=(F==null?void 0:F.value.type)===t.CFValueType.formula?s.t("sheet.cf.valueType.formula"):F==null?void 0:F.value.value,N=(E,g)=>{const b={...h,iconId:g,iconType:E};e([String(p)],b)};return l.jsxs("div",{className:p?"univer-mt-6":"univer-mt-3",children:[l.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:[_.jsxs("div",{className:"univer-w-[45%]",children:[i.t("sheet.cf.iconSet.icon"),I+1]}),_.jsx("div",{className:"univer-w-[45%]",children:_.jsxs(_.Fragment,{children:[!p&&!R&&i.t("sheet.cf.iconSet.rule"),!p&&!R&&_.jsxs("span",{className:"univer-font-medium univer-text-gray-600",children:["(",i.t("sheet.cf.iconSet.when"),i.t(`sheet.cf.symbol.${c.getOppositeOperator(s.operator)}`),a,R?"":` ${i.t("sheet.cf.iconSet.and")} `,")"]})]})})]}),_.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[_.jsx("div",{className:"univer-flex univer-items-center",children:_.jsx(K.Dropdown,{overlay:_.jsx("div",{className:"univer-rounded-lg univer-p-4",children:_.jsx(Ur,{onClick:f,iconId:C.iconId,iconType:C.iconType})}),children:_.jsxs("div",{className:`
39
+ `,children:[l.jsxs("div",{className:"univer-w-[45%]",children:[s.t("sheet.cf.iconSet.icon"),p+1]}),l.jsx("div",{className:"univer-w-[45%]",children:l.jsxs(l.Fragment,{children:[!_&&!S&&s.t("sheet.cf.iconSet.rule"),!_&&!S&&l.jsxs("span",{className:"univer-font-medium univer-text-gray-600",children:["(",s.t("sheet.cf.iconSet.when"),s.t(`sheet.cf.symbol.${t.getOppositeOperator(F.operator)}`),j,S?"":` ${s.t("sheet.cf.iconSet.and")} `,")"]})]})})]}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[l.jsx("div",{className:"univer-flex univer-items-center",children:l.jsx(U.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx($t,{onClick:N,iconId:h.iconId,iconType:h.iconType})}),children:l.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:[x?_.jsx("img",{src:x,className:"univer-size-4",draggable:!1}):_.jsx(lt,{className:"univer-size-4"}),_.jsx(Dt,{})]})})}),R?_.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600",children:[i.t("sheet.cf.iconSet.rule"),_.jsxs("span",{className:"univer-font-medium univer-text-gray-600",children:[i.t("sheet.cf.iconSet.when"),i.t(`sheet.cf.symbol.${c.getOppositeOperator(s.operator)}`),a,R?"":` ${i.t("sheet.cf.iconSet.and")} `]})]}):_.jsx(K.Select,{options:o,value:C.operator,onChange:y=>{h(y,I)}})]}),R?_.jsx("div",{}):_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:`
45
+ `,children:[x?l.jsx("img",{src:x,className:"univer-size-4",draggable:!1}):l.jsx(xe,{className:"univer-size-4"}),l.jsx(Le,{})]})})}),S?l.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600",children:[s.t("sheet.cf.iconSet.rule"),l.jsxs("span",{className:"univer-font-medium univer-text-gray-600",children:[s.t("sheet.cf.iconSet.when"),s.t(`sheet.cf.symbol.${t.getOppositeOperator(F.operator)}`),j,S?"":` ${s.t("sheet.cf.iconSet.and")} `]})]}):l.jsx(U.Select,{options:o,value:h.operator,onChange:E=>{c(E,p)}})]}),S?l.jsx("div",{}):l.jsxs(l.Fragment,{children:[l.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:[_.jsx("div",{children:i.t("sheet.cf.iconSet.type")}),_.jsx("div",{children:i.t("sheet.cf.iconSet.value")})]}),_.jsxs("div",{className:`
48
+ `,children:[l.jsx("div",{children:s.t("sheet.cf.iconSet.type")}),l.jsx("div",{children:s.t("sheet.cf.iconSet.value")})]}),l.jsxs("div",{className:`
25
49
  univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4
26
- `,children:[_.jsx(K.Select,{className:"univer-flex-shrink-0",options:d,value:C.value.type,onChange:y=>{S(y,I)}}),_.jsx("div",{children:_.jsx(jr,{id:I,type:C.value.type,error:w,value:C.value.value||"",onChange:y=>{b(y,I)}})})]})]})]},I)}),[n,r])},zr=e=>{var y;const{interceptorManager:t}=e,n=((y=e.rule)==null?void 0:y.type)===c.CFRuleType.iconSet?e.rule:void 0,r=J.useDependency(T.LocaleService),[i,o]=j.useState({}),[d,b]=j.useState(()=>{const l=Object.keys(c.iconMap)[0];if(n&&n.config.length){const g=n.config[0].iconType;if(!n.config.some(m=>m.iconType!==g))return g}return l}),[h,S]=j.useState(()=>{if(n&&n.config.length)return T.Tools.deepClone(n==null?void 0:n.config);const l=c.iconMap[d]||[];return new Array(l.length).fill("").map((g,u,m)=>u===m.length-1?{operator:c.CFNumberOperator.lessThanOrEqual,value:{type:c.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:d,iconId:String(u)}:pn(d,u,m))}),[v,C]=j.useState(()=>n?!!n.isShowValue:!0),I=j.useMemo(()=>{const l=h.map(g=>tr(g.iconType,g.iconId));return _.jsx("div",{className:"univer-flex univer-items-center",children:l.map((g,u)=>g?_.jsx("img",{className:"univer-size-5",src:g},u):_.jsx(lt,{className:"univer-size-5"},u))})},[h]),w=l=>{if(l.reduce((u,m,F)=>u.preType&&!u.result||l.length-1===F?u:m.value.type===c.CFValueType.formula?{preType:c.CFValueType.formula,result:!1}:u.preType?{result:u.preType===m.value.type,preType:m.value.type}:{result:!0,preType:m.value.type},{result:!0,preType:""}).result&&[c.CFValueType.num,c.CFValueType.percent,c.CFValueType.percentile].includes(l[0].value.type)){const u={};return l.forEach((m,F,P)=>{if(F-1<0||F===P.length-1)return;const U=l[F-1],E=c.getOppositeOperator(U.operator);c.compareWithNumber({operator:E,value:U.value.value},m.value.value)||(u[F]=`${r.t(`sheet.cf.form.${E}`,String(U.value.value))} `)}),u}return{}},x=(l,g)=>{T.get(h,l)!==g&&(T.set(h,l,g),S([...h]),o(w(h)))},R=l=>{b(l);const g=c.iconMap[l]||[],u=new Array(g.length).fill("").map((m,F,P)=>pn(l,F,P));S(u),o(w(u))};j.useEffect(()=>{const l=t.intercept(t.getInterceptPoints().submit,{handler(){return{type:c.CFRuleType.iconSet,isShowValue:v,config:h}}});return()=>{l()}},[v,h,t]),j.useEffect(()=>{const l=t.intercept(t.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(i).length===0}});return()=>{l()}},[v,h,t,i]);const p=()=>{const l=h.map(g=>({...g}));h.forEach((g,u)=>{const m=h.length-1-u,F=l[m];g.iconId=F.iconId,g.iconType=F.iconType}),S([...h])},s=J.useDependency(J.ILayoutService),[a,f]=j.useState();return J.useScrollYOverContainer(a,s.rootContainerElement),_.jsxs("div",{children:[_.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),_.jsx("div",{className:"univer-mt-3",children:_.jsx(K.Dropdown,{overlay:_.jsx("div",{className:"univer-rounded-lg univer-p-4",children:_.jsx(Lr,{ref:l=>{!a&&l&&f(l)},iconType:d,onClick:R})}),children:_.jsxs("div",{className:K.clsx(`
50
+ `,children:[l.jsx(U.Select,{className:"univer-flex-shrink-0",options:u,value:h.value.type,onChange:E=>{m(E,p)}}),l.jsx("div",{children:l.jsx(At,{id:p,type:h.value.type,error:y,value:h.value.value||"",onChange:E=>{v(E,p)}})})]})]})]},p)}),[i,r])},Ht=n=>{var E;const{interceptorManager:e}=n,i=((E=n.rule)==null?void 0:E.type)===t.CFRuleType.iconSet?n.rule:void 0,r=k.useDependency(a.LocaleService),[s,o]=C.useState({}),[u,v]=C.useState(()=>{const g=Object.keys(t.iconMap)[0];if(i&&i.config.length){const b=i.config[0].iconType;if(!i.config.some(I=>I.iconType!==b))return b}return g}),[c,m]=C.useState(()=>{if(i&&i.config.length)return a.Tools.deepClone(i==null?void 0:i.config);const g=t.iconMap[u]||[];return new Array(g.length).fill("").map((b,T,I)=>T===I.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:u,iconId:String(T)}:ot(u,T,I))}),[d,h]=C.useState(()=>i?!!i.isShowValue:!0),p=C.useMemo(()=>{const g=c.map(b=>Ct(b.iconType,b.iconId));return l.jsx("div",{className:"univer-flex univer-items-center",children:g.map((b,T)=>b?l.jsx("img",{className:"univer-size-5",src:b},T):l.jsx(xe,{className:"univer-size-5"},T))})},[c]),y=g=>{if(g.reduce((T,I,w)=>T.preType&&!T.result||g.length-1===w?T:I.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:T.preType?{result:T.preType===I.value.type,preType:I.value.type}:{result:!0,preType:I.value.type},{result:!0,preType:""}).result&&[t.CFValueType.num,t.CFValueType.percent,t.CFValueType.percentile].includes(g[0].value.type)){const T={};return g.forEach((I,w,M)=>{if(w-1<0||w===M.length-1)return;const P=g[w-1],f=t.getOppositeOperator(P.operator);t.compareWithNumber({operator:f,value:P.value.value},I.value.value)||(T[w]=`${r.t(`sheet.cf.form.${f}`,String(P.value.value))} `)}),T}return{}},x=(g,b)=>{a.get(c,g)!==b&&(a.set(c,g,b),m([...c]),o(y(c)))},S=g=>{v(g);const b=t.iconMap[g]||[],T=new Array(b.length).fill("").map((I,w,M)=>ot(g,w,M));m(T),o(y(T))};C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:t.CFRuleType.iconSet,isShowValue:d,config:c}}});return()=>{g()}},[d,c,e]),C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(s).length===0}});return()=>{g()}},[d,c,e,s]);const _=()=>{const g=c.map(b=>({...b}));c.forEach((b,T)=>{const I=c.length-1-T,w=g[I];b.iconId=w.iconId,b.iconType=w.iconType}),m([...c])},F=k.useDependency(k.ILayoutService),[j,N]=C.useState();return k.useScrollYOverContainer(j,F.rootContainerElement),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:"univer-mt-3",children:l.jsx(U.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx(Lt,{ref:g=>{!j&&g&&N(g)},iconType:u,onClick:S})}),children:l.jsxs("div",{className:U.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:[I,_.jsx(Dt,{})]})})}),_.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[_.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[_.jsx(K.Checkbox,{onChange:p}),r.t("sheet.cf.iconSet.reverseIconOrder")]}),_.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[_.jsx(K.Checkbox,{checked:!v,onChange:l=>{C(!l)}}),r.t("sheet.cf.iconSet.onlyShowIcon")]})]}),_.jsx(Vr,{errorMap:i,onChange:x,configList:h})]})},kr=e=>{var p;const{onChange:t,interceptorManager:n}=e,r=J.useDependency(T.LocaleService),i=((p=e.rule)==null?void 0:p.type)===c.CFRuleType.highlightCell?e.rule:void 0,o=[{label:r.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:r.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:r.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:r.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[d,b]=j.useState(()=>{const s=o[0].value,a=i==null?void 0:i.type;if(!i)return s;switch(a){case c.CFRuleType.highlightCell:switch(i.subType){case c.CFSubRuleType.average:return[c.CFNumberOperator.greaterThan,c.CFNumberOperator.greaterThanOrEqual].includes(i.operator)?"greaterThanAverage":[c.CFNumberOperator.lessThan,c.CFNumberOperator.lessThanOrEqual].includes(i.operator)?"lessThanAverage":s;case c.CFSubRuleType.rank:return i.isBottom?"isBottom":"isNotBottom"}}return s}),[h,S]=j.useState(()=>{const a=i==null?void 0:i.type;if(!i)return 10;switch(a){case c.CFRuleType.highlightCell:switch(i.subType){case c.CFSubRuleType.rank:return i.value||10}}return 10}),[v,C]=j.useState(()=>{const a=i==null?void 0:i.type;if(!i)return!1;switch(a){case c.CFRuleType.highlightCell:switch(i.subType){case c.CFSubRuleType.rank:return i.isPercent||!1}}return!1}),[I,w]=j.useState({}),x=s=>{const{type:a,isPercent:f,value:y,style:l}=s;if(a==="isNotBottom")return{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.rank,isPercent:f,isBottom:!1,value:y,style:l};if(a==="isBottom")return{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.rank,isPercent:f,isBottom:!0,value:y,style:l};if(a==="greaterThanAverage")return{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.average,operator:c.CFNumberOperator.greaterThan,style:l};if(a==="lessThanAverage")return{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.average,operator:c.CFNumberOperator.lessThan,style:l}};j.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return x({type:d,isPercent:v,value:h,style:I})}}),[d,v,h,I,n]);const R=s=>{t(x(s))};return _.jsxs("div",{children:[_.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),_.jsx(K.Select,{className:"univer-mt-3 univer-w-full",value:d,options:o,onChange:s=>{b(s),R({type:s,isPercent:v,value:h,style:I})}}),["isNotBottom","isBottom"].includes(d)&&_.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[_.jsx(K.InputNumber,{min:1,max:1e3,value:h,onChange:s=>{const a=s||0;S(a),R({type:d,isPercent:v,value:a,style:I})}}),_.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[_.jsx(K.Checkbox,{checked:v,onChange:s=>{C(!!s),R({type:d,isPercent:!!s,value:h,style:I})}}),r.t("sheet.cf.valueType.percent")]})]}),_.jsx("div",{className:ut,children:_.jsx(Ve,{rule:x({type:d,isPercent:v,value:h,style:I})})}),_.jsx(rn,{style:i==null?void 0:i.style,className:"univer-mt-3",onChange:s=>{w(s),R({type:d,isPercent:v,value:h,style:s})}})]})},qr=T.createInterceptorKey("beforeSubmit"),Ar=T.createInterceptorKey("submit"),hn=e=>e.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getUnitId(),gn=e=>{var t;return(t=e.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId()},Hr=e=>{var u,m,F;const t=J.useDependency(T.LocaleService),n=J.useDependency(T.ICommandService),r=J.useDependency(T.IUniverInstanceService),i=J.useDependency(c.ConditionalFormattingRuleModel),o=J.useDependency($.SheetsSelectionsService),d=hn(r),b=gn(r),[h,S]=j.useState(void 0),v=j.useRef((m=(u=e.rule)==null?void 0:u.ranges)!=null?m:[]),C=j.useMemo(()=>{var L,U,E;let P=(L=e.rule)==null?void 0:L.ranges;return P!=null&&P.length||(P=(E=(U=o.getCurrentSelections())==null?void 0:U.map(N=>N.range))!=null?E:[]),v.current=P,P!=null&&P.length?P.map(N=>{const A=Bt.serializeRange(N);return A==="NaN"?"":A}).filter(N=>!!N).join(","):""},[e.rule]),I=[{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"}],[w,x]=j.useState(()=>{var U,E;const P=(U=e.rule)==null?void 0:U.rule.type,L=I[0].value;if(!P)return L;switch(P){case c.CFRuleType.highlightCell:{switch((E=e.rule)==null?void 0:E.rule.subType){case c.CFSubRuleType.number:case c.CFSubRuleType.text:case c.CFSubRuleType.duplicateValues:case c.CFSubRuleType.uniqueValues:case c.CFSubRuleType.timePeriod:return"1";case c.CFSubRuleType.average:case c.CFSubRuleType.rank:return"2";case c.CFSubRuleType.formula:return"5"}break}case c.CFRuleType.dataBar:return"3";case c.CFRuleType.colorScale:return"4";case c.CFRuleType.iconSet:return"6"}return L}),R=j.useRef(void 0),p=j.useMemo(()=>new T.InterceptorManager({beforeSubmit:qr,submit:Ar}),[]),s=j.useMemo(()=>{switch(w){case"1":return fn;case"2":return kr;case"3":return Pr;case"4":return Fr;case"5":return Mr;case"6":return zr;default:return fn}},[w]);j.useEffect(()=>{const P=n.onCommandExecuted(L=>{if(L.id===$.RemoveSheetMutation.id){const U=L.params;U.subUnitId===b&&U.unitId===d&&e.onCancel()}L.id===$.SetWorksheetActiveOperation.id&&e.onCancel()});return()=>P.dispose()},[]);const a=P=>{R.current=P},f=P=>{const L=P.split(",").filter(U=>!!U).map(Bt.deserializeRangeWithSheet).map(U=>U.range);v.current=L},y=()=>{if(h)return;const L=(()=>{const E=r.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!E)throw new Error("No active sheet found");return v.current.map(W=>$.setEndForRange(W,E.getRowCount(),E.getColumnCount())).filter(W=>!(Number.isNaN(W.startRow)||Number.isNaN(W.startColumn)))})();if(p.fetchThroughInterceptors(p.getInterceptPoints().beforeSubmit)(!0,null)){const E=p.fetchThroughInterceptors(p.getInterceptPoints().submit)(null,null);if(E){const N=hn(r),A=gn(r);if(!N||!A)throw new Error("No active sheet found");let W={};e.rule&&e.rule.cfId?(W={...e.rule,ranges:L,rule:E},n.executeCommand(c.SetCfCommand.id,{unitId:N,subUnitId:A,rule:W}),e.onCancel()):(W={cfId:i.createCfId(N,A),ranges:L,rule:E,stopIfTrue:!1},n.executeCommand(c.AddCfCommand.id,{unitId:N,subUnitId:A,rule:W}),e.onCancel())}}},l=()=>{e.onCancel()},g=(P,L)=>{P?L.length<1?S(t.t("sheet.cf.errorMessage.rangeError")):S(void 0):S(t.t("sheet.cf.errorMessage.rangeError"))};return _.jsxs("div",{children:[_.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:t.t("sheet.cf.panel.range")}),_.jsxs("div",{className:"univer-mt-4",children:[_.jsx(at.RangeSelector,{unitId:d,subUnitId:b,initialValue:C,onChange:(P,L)=>f(L),onVerify:g}),h&&_.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:h})]}),_.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:t.t("sheet.cf.panel.styleType")}),_.jsx(K.Select,{className:"univer-mt-4 univer-w-full",value:w,options:I,onChange:P=>x(P)}),_.jsx(s,{interceptorManager:p,rule:(F=e.rule)==null?void 0:F.rule,onChange:a}),_.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[_.jsx(K.Button,{onClick:l,children:t.t("sheet.cf.panel.cancel")}),_.jsx(K.Button,{className:"univer-ml-3",variant:"primary",onClick:y,children:t.t("sheet.cf.panel.submit")})]})]})};function Wr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function nr(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),n}var jt={exports:{}},ke={},et={exports:{}},Br=et.exports,mn;function on(){return mn||(mn=1,function(e,t){(function(n,r){r(t)})(Br,function(n){function r(q){return function(ie,O,D,M,V,H,k){return q(ie,O,k)}}function i(q){return function(ie,O,D,M){if(!ie||!O||typeof ie!="object"||typeof O!="object")return q(ie,O,D,M);var V=M.get(ie),H=M.get(O);if(V&&H)return V===O&&H===ie;M.set(ie,O),M.set(O,ie);var k=q(ie,O,D,M);return M.delete(ie),M.delete(O),k}}function o(q,Y){var ie={};for(var O in q)ie[O]=q[O];for(var O in Y)ie[O]=Y[O];return ie}function d(q){return q.constructor===Object||q.constructor==null}function b(q){return typeof q.then=="function"}function h(q,Y){return q===Y||q!==q&&Y!==Y}var S="[object Arguments]",v="[object Boolean]",C="[object Date]",I="[object RegExp]",w="[object Map]",x="[object Number]",R="[object Object]",p="[object Set]",s="[object String]",a=Object.prototype.toString;function f(q){var Y=q.areArraysEqual,ie=q.areDatesEqual,O=q.areMapsEqual,D=q.areObjectsEqual,M=q.areRegExpsEqual,V=q.areSetsEqual,H=q.createIsNestedEqual,k=H(X);function X(B,Q,le){if(B===Q)return!0;if(!B||!Q||typeof B!="object"||typeof Q!="object")return B!==B&&Q!==Q;if(d(B)&&d(Q))return D(B,Q,k,le);var _e=Array.isArray(B),ge=Array.isArray(Q);if(_e||ge)return _e===ge&&Y(B,Q,k,le);var pe=a.call(B);return pe!==a.call(Q)?!1:pe===C?ie(B,Q,k,le):pe===I?M(B,Q,k,le):pe===w?O(B,Q,k,le):pe===p?V(B,Q,k,le):pe===R||pe===S?b(B)||b(Q)?!1:D(B,Q,k,le):pe===v||pe===x||pe===s?h(B.valueOf(),Q.valueOf()):!1}return X}function y(q,Y,ie,O){var D=q.length;if(Y.length!==D)return!1;for(;D-- >0;)if(!ie(q[D],Y[D],D,D,q,Y,O))return!1;return!0}var l=i(y);function g(q,Y){return h(q.valueOf(),Y.valueOf())}function u(q,Y,ie,O){var D=q.size===Y.size;if(!D)return!1;if(!q.size)return!0;var M={},V=0;return q.forEach(function(H,k){if(D){var X=!1,B=0;Y.forEach(function(Q,le){!X&&!M[B]&&(X=ie(k,le,V,B,q,Y,O)&&ie(H,Q,k,le,q,Y,O))&&(M[B]=!0),B++}),V++,D=X}}),D}var m=i(u),F="_owner",P=Object.prototype.hasOwnProperty;function L(q,Y,ie,O){var D=Object.keys(q),M=D.length;if(Object.keys(Y).length!==M)return!1;for(var V;M-- >0;){if(V=D[M],V===F){var H=!!q.$$typeof,k=!!Y.$$typeof;if((H||k)&&H!==k)return!1}if(!P.call(Y,V)||!ie(q[V],Y[V],V,V,q,Y,O))return!1}return!0}var U=i(L);function E(q,Y){return q.source===Y.source&&q.flags===Y.flags}function N(q,Y,ie,O){var D=q.size===Y.size;if(!D)return!1;if(!q.size)return!0;var M={};return q.forEach(function(V,H){if(D){var k=!1,X=0;Y.forEach(function(B,Q){!k&&!M[X]&&(k=ie(V,B,H,Q,q,Y,O))&&(M[X]=!0),X++}),D=k}}),D}var A=i(N),W=Object.freeze({areArraysEqual:y,areDatesEqual:g,areMapsEqual:u,areObjectsEqual:L,areRegExpsEqual:E,areSetsEqual:N,createIsNestedEqual:r}),G=Object.freeze({areArraysEqual:l,areDatesEqual:g,areMapsEqual:m,areObjectsEqual:U,areRegExpsEqual:E,areSetsEqual:A,createIsNestedEqual:r}),re=f(W);function te(q,Y){return re(q,Y,void 0)}var se=f(o(W,{createIsNestedEqual:function(){return h}}));function z(q,Y){return se(q,Y,void 0)}var Z=f(G);function ee(q,Y){return Z(q,Y,new WeakMap)}var oe=f(o(G,{createIsNestedEqual:function(){return h}}));function ue(q,Y){return oe(q,Y,new WeakMap)}function fe(q){return f(o(W,q(W)))}function ve(q){var Y=f(o(G,q(G)));return function(ie,O,D){return D===void 0&&(D=new WeakMap),Y(ie,O,D)}}n.circularDeepEqual=ee,n.circularShallowEqual=ue,n.createCustomCircularEqual=ve,n.createCustomEqual=fe,n.deepEqual=te,n.sameValueZeroEqual=h,n.shallowEqual=z,Object.defineProperty(n,"__esModule",{value:!0})})}(et,et.exports)),et.exports}var gt={exports:{}},vn;function sn(){if(vn)return gt.exports;vn=1;function e(n){var r,i,o="";if(typeof n=="string"||typeof n=="number")o+=n;else if(typeof n=="object")if(Array.isArray(n)){var d=n.length;for(r=0;r<d;r++)n[r]&&(i=e(n[r]))&&(o&&(o+=" "),o+=i)}else for(i in n)n[i]&&(o&&(o+=" "),o+=i);return o}function t(){for(var n,r,i=0,o="",d=arguments.length;i<d;i++)(n=arguments[i])&&(r=e(n))&&(o&&(o+=" "),o+=r);return o}return gt.exports=t,gt.exports.clsx=t,gt.exports}var ne={},Lt,yn;function $r(){return yn||(yn=1,Lt=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)}),Lt}var Cn;function ze(){if(Cn)return ne;Cn=1,Object.defineProperty(ne,"__esModule",{value:!0}),ne.bottom=r,ne.childrenEqual=h,ne.cloneLayout=i,ne.cloneLayoutItem=b,ne.collides=v,ne.compact=C,ne.compactItem=x,ne.compactType=q,ne.correctBounds=R,ne.fastPositionEqual=S,ne.fastRGLPropsEqual=void 0,ne.getAllCollisions=a,ne.getFirstCollision=s,ne.getLayoutItem=p,ne.getStatics=f,ne.modifyLayout=o,ne.moveElement=y,ne.moveElementAwayFromCollision=l,ne.noop=void 0,ne.perc=g,ne.resizeItemInDirection=se,ne.setTopLeft=Z,ne.setTransform=z,ne.sortLayoutItems=ee,ne.sortLayoutItemsByColRow=ue,ne.sortLayoutItemsByRowCol=oe,ne.synchronizeLayoutWithChildren=fe,ne.validateLayout=ve,ne.withLayoutItem=d;var e=on(),t=n(j);function n(O){return O&&O.__esModule?O:{default:O}}function r(O){let D=0,M;for(let V=0,H=O.length;V<H;V++)M=O[V].y+O[V].h,M>D&&(D=M);return D}function i(O){const D=Array(O.length);for(let M=0,V=O.length;M<V;M++)D[M]=b(O[M]);return D}function o(O,D){const M=Array(O.length);for(let V=0,H=O.length;V<H;V++)D.i===O[V].i?M[V]=D:M[V]=O[V];return M}function d(O,D,M){let V=p(O,D);return V?(V=M(b(V)),O=o(O,V),[O,V]):[O,null]}function b(O){return{w:O.w,h:O.h,x:O.x,y:O.y,i:O.i,minW:O.minW,maxW:O.maxW,minH:O.minH,maxH:O.maxH,moved:!!O.moved,static:!!O.static,isDraggable:O.isDraggable,isResizable:O.isResizable,resizeHandles:O.resizeHandles,isBounded:O.isBounded}}function h(O,D){return(0,e.deepEqual)(t.default.Children.map(O,M=>M==null?void 0:M.key),t.default.Children.map(D,M=>M==null?void 0:M.key))&&(0,e.deepEqual)(t.default.Children.map(O,M=>M==null?void 0:M.props["data-grid"]),t.default.Children.map(D,M=>M==null?void 0:M.props["data-grid"]))}ne.fastRGLPropsEqual=$r();function S(O,D){return O.left===D.left&&O.top===D.top&&O.width===D.width&&O.height===D.height}function v(O,D){return!(O.i===D.i||O.x+O.w<=D.x||O.x>=D.x+D.w||O.y+O.h<=D.y||O.y>=D.y+D.h)}function C(O,D,M,V){const H=f(O),k=ee(O,D),X=Array(O.length);for(let B=0,Q=k.length;B<Q;B++){let le=b(k[B]);le.static||(le=x(H,le,D,M,k,V),H.push(le)),X[O.indexOf(k[B])]=le,le.moved=!1}return X}const I={x:"w",y:"h"};function w(O,D,M,V){const H=I[V];D[V]+=1;const k=O.map(X=>X.i).indexOf(D.i);for(let X=k+1;X<O.length;X++){const B=O[X];if(!B.static){if(B.y>D.y+D.h)break;v(D,B)&&w(O,B,M+D[H],V)}}D[V]=M}function x(O,D,M,V,H,k){const X=M==="vertical",B=M==="horizontal";if(X)for(D.y=Math.min(r(O),D.y);D.y>0&&!s(O,D);)D.y--;else if(B)for(;D.x>0&&!s(O,D);)D.x--;let Q;for(;(Q=s(O,D))&&!(M===null&&k);)if(B?w(H,D,Q.x+Q.w,"x"):w(H,D,Q.y+Q.h,"y"),B&&D.x+D.w>V)for(D.x=V-D.w,D.y++;D.x>0&&!s(O,D);)D.x--;return D.y=Math.max(D.y,0),D.x=Math.max(D.x,0),D}function R(O,D){const M=f(O);for(let V=0,H=O.length;V<H;V++){const k=O[V];if(k.x+k.w>D.cols&&(k.x=D.cols-k.w),k.x<0&&(k.x=0,k.w=D.cols),!k.static)M.push(k);else for(;s(M,k);)k.y++}return O}function p(O,D){for(let M=0,V=O.length;M<V;M++)if(O[M].i===D)return O[M]}function s(O,D){for(let M=0,V=O.length;M<V;M++)if(v(O[M],D))return O[M]}function a(O,D){return O.filter(M=>v(M,D))}function f(O){return O.filter(D=>D.static)}function y(O,D,M,V,H,k,X,B,Q){if(D.static&&D.isDraggable!==!0||D.y===V&&D.x===M)return O;`${D.i}${String(M)}${String(V)}${D.x}${D.y}`;const le=D.x,_e=D.y;typeof M=="number"&&(D.x=M),typeof V=="number"&&(D.y=V),D.moved=!0;let ge=ee(O,X);(X==="vertical"&&typeof V=="number"?_e>=V:X==="horizontal"&&typeof M=="number"?le>=M:!1)&&(ge=ge.reverse());const Fe=a(ge,D),dt=Fe.length>0;if(dt&&Q)return i(O);if(dt&&k)return`${D.i}`,D.x=le,D.y=_e,D.moved=!1,O;for(let Mt=0,Cr=Fe.length;Mt<Cr;Mt++){const Ie=Fe[Mt];`${D.i}${D.x}${D.y}${Ie.i}${Ie.x}${Ie.y}`,!Ie.moved&&(Ie.static?O=l(O,Ie,D,H,X):O=l(O,D,Ie,H,X))}return O}function l(O,D,M,V,H,k){const X=H==="horizontal",B=H==="vertical",Q=D.static;if(V){V=!1;const ge={x:X?Math.max(D.x-M.w,0):M.x,y:B?Math.max(D.y-M.h,0):M.y,w:M.w,h:M.h,i:"-1"},pe=s(O,ge),Fe=pe&&pe.y+pe.h>D.y,dt=pe&&D.x+D.w>pe.x;if(pe){if(Fe&&B)return y(O,M,void 0,D.y+1,V,Q,H);if(Fe&&H==null)return D.y=M.y,M.y=M.y+M.h,O;if(dt&&X)return y(O,D,M.x,void 0,V,Q,H)}else return`${M.i}${ge.x}${ge.y}`,y(O,M,X?ge.x:void 0,B?ge.y:void 0,V,Q,H)}const le=X?M.x+1:void 0,_e=B?M.y+1:void 0;return le==null&&_e==null?O:y(O,M,X?M.x+1:void 0,B?M.y+1:void 0,V,Q,H)}function g(O){return O*100+"%"}const u=(O,D,M,V)=>O+M>V?D:M,m=(O,D,M)=>O<0?D:M,F=O=>Math.max(0,O),P=O=>Math.max(0,O),L=(O,D,M)=>{let{left:V,height:H,width:k}=D;const X=O.top-(H-O.height);return{left:V,width:k,height:m(X,O.height,H),top:P(X)}},U=(O,D,M)=>{let{top:V,left:H,height:k,width:X}=D;return{top:V,height:k,width:u(O.left,O.width,X,M),left:F(H)}},E=(O,D,M)=>{let{top:V,height:H,width:k}=D;const X=O.left-(k-O.width);return{height:H,width:X<0?O.width:u(O.left,O.width,k,M),top:P(V),left:F(X)}},N=(O,D,M)=>{let{top:V,left:H,height:k,width:X}=D;return{width:X,left:H,height:m(V,O.height,k),top:P(V)}},te={n:L,ne:function(){return L(arguments.length<=0?void 0:arguments[0],U(...arguments))},e:U,se:function(){return N(arguments.length<=0?void 0:arguments[0],U(...arguments))},s:N,sw:function(){return N(arguments.length<=0?void 0:arguments[0],E(...arguments))},w:E,nw:function(){return L(arguments.length<=0?void 0:arguments[0],E(...arguments))}};function se(O,D,M,V){const H=te[O];return H?H(D,{...D,...M},V):M}function z(O){let{top:D,left:M,width:V,height:H}=O;const k=`translate(${M}px,${D}px)`;return{transform:k,WebkitTransform:k,MozTransform:k,msTransform:k,OTransform:k,width:`${V}px`,height:`${H}px`,position:"absolute"}}function Z(O){let{top:D,left:M,width:V,height:H}=O;return{top:`${D}px`,left:`${M}px`,width:`${V}px`,height:`${H}px`,position:"absolute"}}function ee(O,D){return D==="horizontal"?ue(O):D==="vertical"?oe(O):O}function oe(O){return O.slice(0).sort(function(D,M){return D.y>M.y||D.y===M.y&&D.x>M.x?1:D.y===M.y&&D.x===M.x?0:-1})}function ue(O){return O.slice(0).sort(function(D,M){return D.x>M.x||D.x===M.x&&D.y>M.y?1:-1})}function fe(O,D,M,V,H){O=O||[];const k=[];t.default.Children.forEach(D,B=>{if((B==null?void 0:B.key)==null)return;const Q=p(O,String(B.key)),le=B.props["data-grid"];Q&&le==null?k.push(b(Q)):le?k.push(b({...le,i:B.key})):k.push(b({w:1,h:1,x:0,y:r(k),i:String(B.key)}))});const X=R(k,{cols:M});return H?X:C(X,V,M)}function ve(O){let D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const M=["x","y","w","h"];if(!Array.isArray(O))throw new Error(D+" must be an array!");for(let V=0,H=O.length;V<H;V++){const k=O[V];for(let X=0;X<M.length;X++){const B=M[X],Q=k[B];if(typeof Q!="number"||Number.isNaN(Q))throw new Error(`ReactGridLayout: ${D}[${V}].${B} must be a number! Received: ${Q} (${typeof Q})`)}if(typeof k.i<"u"&&typeof k.i!="string")throw new Error(`ReactGridLayout: ${D}[${V}].i must be a string! Received: ${k.i} (${typeof k.i})`)}}function q(O){const{verticalCompact:D,compactType:M}=O||{};return D===!1?null:M}function Y(){}const ie=()=>{};return ne.noop=ie,ne}var be={},bn;function an(){if(bn)return be;bn=1,Object.defineProperty(be,"__esModule",{value:!0}),be.calcGridColWidth=e,be.calcGridItemPosition=n,be.calcGridItemWHPx=t,be.calcWH=i,be.calcXY=r,be.clamp=o;function e(d){const{margin:b,containerPadding:h,containerWidth:S,cols:v}=d;return(S-b[0]*(v-1)-h[0]*2)/v}function t(d,b,h){return Number.isFinite(d)?Math.round(b*d+Math.max(0,d-1)*h):d}function n(d,b,h,S,v,C){const{margin:I,containerPadding:w,rowHeight:x}=d,R=e(d),p={};return C&&C.resizing?(p.width=Math.round(C.resizing.width),p.height=Math.round(C.resizing.height)):(p.width=t(S,R,I[0]),p.height=t(v,x,I[1])),C&&C.dragging?(p.top=Math.round(C.dragging.top),p.left=Math.round(C.dragging.left)):C&&C.resizing&&typeof C.resizing.top=="number"&&typeof C.resizing.left=="number"?(p.top=Math.round(C.resizing.top),p.left=Math.round(C.resizing.left)):(p.top=Math.round((x+I[1])*h+w[1]),p.left=Math.round((R+I[0])*b+w[0])),p}function r(d,b,h,S,v){const{margin:C,containerPadding:I,cols:w,rowHeight:x,maxRows:R}=d,p=e(d);let s=Math.round((h-I[0])/(p+C[0])),a=Math.round((b-I[1])/(x+C[1]));return s=o(s,0,w-S),a=o(a,0,R-v),{x:s,y:a}}function i(d,b,h,S,v,C){const{margin:I,maxRows:w,cols:x,rowHeight:R}=d,p=e(d);let s=Math.round((b+I[0])/(p+I[0])),a=Math.round((h+I[1])/(R+I[1])),f=o(s,0,x-S),y=o(a,0,w-v);return["sw","w","nw"].indexOf(C)!==-1&&(f=o(s,0,x)),["nw","n","ne"].indexOf(C)!==-1&&(y=o(a,0,w)),{w:f,h:y}}function o(d,b,h){return Math.max(Math.min(d,h),b)}return be}var qe={},Ut={exports:{}},Vt,Sn;function Gr(){if(Sn)return Vt;Sn=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Vt=e,Vt}var zt,Rn;function Yr(){if(Rn)return zt;Rn=1;var e=Gr();function t(){}function n(){}return n.resetWarningCache=t,zt=function(){function r(d,b,h,S,v,C){if(C!==e){var I=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 I.name="Invariant Violation",I}}r.isRequired=r;function i(){return r}var o={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:t};return o.PropTypes=o,o},zt}var xn;function we(){return xn||(xn=1,Ut.exports=Yr()()),Ut.exports}var Ae={exports:{}},kt={};function rr(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=rr(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function Tn(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=rr(e))&&(r&&(r+=" "),r+=t);return r}const Xr=Object.freeze(Object.defineProperty({__proto__:null,clsx:Tn,default:Tn},Symbol.toStringTag,{value:"Module"})),Kr=nr(Xr);var de={},xe={},wn;function Ft(){if(wn)return xe;wn=1,Object.defineProperty(xe,"__esModule",{value:!0}),xe.dontSetMe=i,xe.findInArray=e,xe.int=r,xe.isFunction=t,xe.isNum=n;function e(o,d){for(let b=0,h=o.length;b<h;b++)if(d.apply(d,[o[b],b,o]))return o[b]}function t(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Function]"}function n(o){return typeof o=="number"&&!isNaN(o)}function r(o){return parseInt(o,10)}function i(o,d,b){if(o[d])return new Error("Invalid prop ".concat(d," passed to ").concat(b," - do not set this, set it on the child."))}return xe}var Te={},_n;function Zr(){if(_n)return Te;_n=1,Object.defineProperty(Te,"__esModule",{value:!0}),Te.browserPrefixToKey=n,Te.browserPrefixToStyle=r,Te.default=void 0,Te.getPrefix=t;const e=["Moz","Webkit","O","ms"];function t(){var o;let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u")return"";const b=(o=window.document)===null||o===void 0||(o=o.documentElement)===null||o===void 0?void 0:o.style;if(!b||d in b)return"";for(let h=0;h<e.length;h++)if(n(d,e[h])in b)return e[h];return""}function n(o,d){return d?"".concat(d).concat(i(o)):o}function r(o,d){return d?"-".concat(d.toLowerCase(),"-").concat(o):o}function i(o){let d="",b=!0;for(let h=0;h<o.length;h++)b?(d+=o[h].toUpperCase(),b=!1):o[h]==="-"?b=!0:d+=o[h];return d}return Te.default=t(),Te}var In;function ln(){if(In)return de;In=1,Object.defineProperty(de,"__esModule",{value:!0}),de.addClassName=l,de.addEvent=b,de.addUserSelectStyles=f,de.createCSSTransform=x,de.createSVGTransform=R,de.getTouch=s,de.getTouchIdentifier=a,de.getTranslation=p,de.innerHeight=C,de.innerWidth=I,de.matchesSelector=o,de.matchesSelectorAndParentsTo=d,de.offsetXYFromParent=w,de.outerHeight=S,de.outerWidth=v,de.removeClassName=g,de.removeEvent=h,de.removeUserSelectStyles=y;var e=Ft(),t=r(Zr());function n(u){if(typeof WeakMap!="function")return null;var m=new WeakMap,F=new WeakMap;return(n=function(P){return P?F:m})(u)}function r(u,m){if(u&&u.__esModule)return u;if(u===null||typeof u!="object"&&typeof u!="function")return{default:u};var F=n(m);if(F&&F.has(u))return F.get(u);var P={},L=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var U in u)if(U!=="default"&&Object.prototype.hasOwnProperty.call(u,U)){var E=L?Object.getOwnPropertyDescriptor(u,U):null;E&&(E.get||E.set)?Object.defineProperty(P,U,E):P[U]=u[U]}return P.default=u,F&&F.set(u,P),P}let i="";function o(u,m){return i||(i=(0,e.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(F){return(0,e.isFunction)(u[F])})),(0,e.isFunction)(u[i])?u[i](m):!1}function d(u,m,F){let P=u;do{if(o(P,m))return!0;if(P===F)return!1;P=P.parentNode}while(P);return!1}function b(u,m,F,P){if(!u)return;const L={capture:!0,...P};u.addEventListener?u.addEventListener(m,F,L):u.attachEvent?u.attachEvent("on"+m,F):u["on"+m]=F}function h(u,m,F,P){if(!u)return;const L={capture:!0,...P};u.removeEventListener?u.removeEventListener(m,F,L):u.detachEvent?u.detachEvent("on"+m,F):u["on"+m]=null}function S(u){let m=u.clientHeight;const F=u.ownerDocument.defaultView.getComputedStyle(u);return m+=(0,e.int)(F.borderTopWidth),m+=(0,e.int)(F.borderBottomWidth),m}function v(u){let m=u.clientWidth;const F=u.ownerDocument.defaultView.getComputedStyle(u);return m+=(0,e.int)(F.borderLeftWidth),m+=(0,e.int)(F.borderRightWidth),m}function C(u){let m=u.clientHeight;const F=u.ownerDocument.defaultView.getComputedStyle(u);return m-=(0,e.int)(F.paddingTop),m-=(0,e.int)(F.paddingBottom),m}function I(u){let m=u.clientWidth;const F=u.ownerDocument.defaultView.getComputedStyle(u);return m-=(0,e.int)(F.paddingLeft),m-=(0,e.int)(F.paddingRight),m}function w(u,m,F){const L=m===m.ownerDocument.body?{left:0,top:0}:m.getBoundingClientRect(),U=(u.clientX+m.scrollLeft-L.left)/F,E=(u.clientY+m.scrollTop-L.top)/F;return{x:U,y:E}}function x(u,m){const F=p(u,m,"px");return{[(0,t.browserPrefixToKey)("transform",t.default)]:F}}function R(u,m){return p(u,m,"")}function p(u,m,F){let{x:P,y:L}=u,U="translate(".concat(P).concat(F,",").concat(L).concat(F,")");if(m){const E="".concat(typeof m.x=="string"?m.x:m.x+F),N="".concat(typeof m.y=="string"?m.y:m.y+F);U="translate(".concat(E,", ").concat(N,")")+U}return U}function s(u,m){return u.targetTouches&&(0,e.findInArray)(u.targetTouches,F=>m===F.identifier)||u.changedTouches&&(0,e.findInArray)(u.changedTouches,F=>m===F.identifier)}function a(u){if(u.targetTouches&&u.targetTouches[0])return u.targetTouches[0].identifier;if(u.changedTouches&&u.changedTouches[0])return u.changedTouches[0].identifier}function f(u){if(!u)return;let m=u.getElementById("react-draggable-style-el");m||(m=u.createElement("style"),m.type="text/css",m.id="react-draggable-style-el",m.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
33
- `,m.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
34
- `,u.getElementsByTagName("head")[0].appendChild(m)),u.body&&l(u.body,"react-draggable-transparent-selection")}function y(u){if(u)try{if(u.body&&g(u.body,"react-draggable-transparent-selection"),u.selection)u.selection.empty();else{const m=(u.defaultView||window).getSelection();m&&m.type!=="Caret"&&m.removeAllRanges()}}catch{}}function l(u,m){u.classList?u.classList.add(m):u.className.match(new RegExp("(?:^|\\s)".concat(m,"(?!\\S)")))||(u.className+=" ".concat(m))}function g(u,m){u.classList?u.classList.remove(m):u.className=u.className.replace(new RegExp("(?:^|\\s)".concat(m,"(?!\\S)"),"g"),"")}return de}var Ce={},En;function ir(){if(En)return Ce;En=1,Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.canDragX=i,Ce.canDragY=o,Ce.createCoreData=b,Ce.createDraggableData=h,Ce.getBoundPosition=n,Ce.getControlPosition=d,Ce.snapToGrid=r;var e=Ft(),t=ln();function n(C,I,w){if(!C.props.bounds)return[I,w];let{bounds:x}=C.props;x=typeof x=="string"?x:S(x);const R=v(C);if(typeof x=="string"){const{ownerDocument:p}=R,s=p.defaultView;let a;if(x==="parent"?a=R.parentNode:a=p.querySelector(x),!(a instanceof s.HTMLElement))throw new Error('Bounds selector "'+x+'" could not find an element.');const f=a,y=s.getComputedStyle(R),l=s.getComputedStyle(f);x={left:-R.offsetLeft+(0,e.int)(l.paddingLeft)+(0,e.int)(y.marginLeft),top:-R.offsetTop+(0,e.int)(l.paddingTop)+(0,e.int)(y.marginTop),right:(0,t.innerWidth)(f)-(0,t.outerWidth)(R)-R.offsetLeft+(0,e.int)(l.paddingRight)-(0,e.int)(y.marginRight),bottom:(0,t.innerHeight)(f)-(0,t.outerHeight)(R)-R.offsetTop+(0,e.int)(l.paddingBottom)-(0,e.int)(y.marginBottom)}}return(0,e.isNum)(x.right)&&(I=Math.min(I,x.right)),(0,e.isNum)(x.bottom)&&(w=Math.min(w,x.bottom)),(0,e.isNum)(x.left)&&(I=Math.max(I,x.left)),(0,e.isNum)(x.top)&&(w=Math.max(w,x.top)),[I,w]}function r(C,I,w){const x=Math.round(I/C[0])*C[0],R=Math.round(w/C[1])*C[1];return[x,R]}function i(C){return C.props.axis==="both"||C.props.axis==="x"}function o(C){return C.props.axis==="both"||C.props.axis==="y"}function d(C,I,w){const x=typeof I=="number"?(0,t.getTouch)(C,I):null;if(typeof I=="number"&&!x)return null;const R=v(w),p=w.props.offsetParent||R.offsetParent||R.ownerDocument.body;return(0,t.offsetXYFromParent)(x||C,p,w.props.scale)}function b(C,I,w){const x=!(0,e.isNum)(C.lastX),R=v(C);return x?{node:R,deltaX:0,deltaY:0,lastX:I,lastY:w,x:I,y:w}:{node:R,deltaX:I-C.lastX,deltaY:w-C.lastY,lastX:C.lastX,lastY:C.lastY,x:I,y:w}}function h(C,I){const w=C.props.scale;return{node:I.node,x:C.state.x+I.deltaX/w,y:C.state.y+I.deltaY/w,deltaX:I.deltaX/w,deltaY:I.deltaY/w,lastX:C.state.x,lastY:C.state.y}}function S(C){return{left:C.left,top:C.top,right:C.right,bottom:C.bottom}}function v(C){const I=C.findDOMNode();if(!I)throw new Error("<DraggableCore>: Unmounted during event!");return I}return Ce}var He={},mt={},On;function or(){if(On)return mt;On=1,Object.defineProperty(mt,"__esModule",{value:!0}),mt.default=e;function e(){}return mt}var Dn;function Jr(){if(Dn)return He;Dn=1,Object.defineProperty(He,"__esModule",{value:!0}),He.default=void 0;var e=S(j),t=b(we()),n=b(Gt),r=ln(),i=ir(),o=Ft(),d=b(or());function b(p){return p&&p.__esModule?p:{default:p}}function h(p){if(typeof WeakMap!="function")return null;var s=new WeakMap,a=new WeakMap;return(h=function(f){return f?a:s})(p)}function S(p,s){if(p&&p.__esModule)return p;if(p===null||typeof p!="object"&&typeof p!="function")return{default:p};var a=h(s);if(a&&a.has(p))return a.get(p);var f={},y=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in p)if(l!=="default"&&Object.prototype.hasOwnProperty.call(p,l)){var g=y?Object.getOwnPropertyDescriptor(p,l):null;g&&(g.get||g.set)?Object.defineProperty(f,l,g):f[l]=p[l]}return f.default=p,a&&a.set(p,f),f}function v(p,s,a){return s=C(s),s in p?Object.defineProperty(p,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):p[s]=a,p}function C(p){var s=I(p,"string");return typeof s=="symbol"?s:String(s)}function I(p,s){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var f=a.call(p,s);if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(p)}const w={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}};let x=w.mouse,R=class extends e.Component{constructor(){super(...arguments),v(this,"dragging",!1),v(this,"lastX",NaN),v(this,"lastY",NaN),v(this,"touchIdentifier",null),v(this,"mounted",!1),v(this,"handleDragStart",s=>{if(this.props.onMouseDown(s),!this.props.allowAnyClick&&typeof s.button=="number"&&s.button!==0)return!1;const a=this.findDOMNode();if(!a||!a.ownerDocument||!a.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:f}=a;if(this.props.disabled||!(s.target instanceof f.defaultView.Node)||this.props.handle&&!(0,r.matchesSelectorAndParentsTo)(s.target,this.props.handle,a)||this.props.cancel&&(0,r.matchesSelectorAndParentsTo)(s.target,this.props.cancel,a))return;s.type==="touchstart"&&s.preventDefault();const y=(0,r.getTouchIdentifier)(s);this.touchIdentifier=y;const l=(0,i.getControlPosition)(s,y,this);if(l==null)return;const{x:g,y:u}=l,m=(0,i.createCoreData)(this,g,u);(0,d.default)("DraggableCore: handleDragStart: %j",m),(0,d.default)("calling",this.props.onStart),!(this.props.onStart(s,m)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,r.addUserSelectStyles)(f),this.dragging=!0,this.lastX=g,this.lastY=u,(0,r.addEvent)(f,x.move,this.handleDrag),(0,r.addEvent)(f,x.stop,this.handleDragStop))}),v(this,"handleDrag",s=>{const a=(0,i.getControlPosition)(s,this.touchIdentifier,this);if(a==null)return;let{x:f,y}=a;if(Array.isArray(this.props.grid)){let u=f-this.lastX,m=y-this.lastY;if([u,m]=(0,i.snapToGrid)(this.props.grid,u,m),!u&&!m)return;f=this.lastX+u,y=this.lastY+m}const l=(0,i.createCoreData)(this,f,y);if((0,d.default)("DraggableCore: handleDrag: %j",l),this.props.onDrag(s,l)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const m=document.createEvent("MouseEvents");m.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(m)}return}this.lastX=f,this.lastY=y}),v(this,"handleDragStop",s=>{if(!this.dragging)return;const a=(0,i.getControlPosition)(s,this.touchIdentifier,this);if(a==null)return;let{x:f,y}=a;if(Array.isArray(this.props.grid)){let m=f-this.lastX||0,F=y-this.lastY||0;[m,F]=(0,i.snapToGrid)(this.props.grid,m,F),f=this.lastX+m,y=this.lastY+F}const l=(0,i.createCoreData)(this,f,y);if(this.props.onStop(s,l)===!1||this.mounted===!1)return!1;const u=this.findDOMNode();u&&this.props.enableUserSelectHack&&(0,r.removeUserSelectStyles)(u.ownerDocument),(0,d.default)("DraggableCore: handleDragStop: %j",l),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,u&&((0,d.default)("DraggableCore: Removing handlers"),(0,r.removeEvent)(u.ownerDocument,x.move,this.handleDrag),(0,r.removeEvent)(u.ownerDocument,x.stop,this.handleDragStop))}),v(this,"onMouseDown",s=>(x=w.mouse,this.handleDragStart(s))),v(this,"onMouseUp",s=>(x=w.mouse,this.handleDragStop(s))),v(this,"onTouchStart",s=>(x=w.touch,this.handleDragStart(s))),v(this,"onTouchEnd",s=>(x=w.touch,this.handleDragStop(s)))}componentDidMount(){this.mounted=!0;const s=this.findDOMNode();s&&(0,r.addEvent)(s,w.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const s=this.findDOMNode();if(s){const{ownerDocument:a}=s;(0,r.removeEvent)(a,w.mouse.move,this.handleDrag),(0,r.removeEvent)(a,w.touch.move,this.handleDrag),(0,r.removeEvent)(a,w.mouse.stop,this.handleDragStop),(0,r.removeEvent)(a,w.touch.stop,this.handleDragStop),(0,r.removeEvent)(s,w.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,r.removeUserSelectStyles)(a)}}findDOMNode(){var s,a;return(s=this.props)!==null&&s!==void 0&&s.nodeRef?(a=this.props)===null||a===void 0||(a=a.nodeRef)===null||a===void 0?void 0:a.current:n.default.findDOMNode(this)}render(){return e.cloneElement(e.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};return He.default=R,v(R,"displayName","DraggableCore"),v(R,"propTypes",{allowAnyClick:t.default.bool,children:t.default.node.isRequired,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:function(p,s){if(p[s]&&p[s].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:o.dontSetMe,style:o.dontSetMe,transform:o.dontSetMe}),v(R,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),He}var Fn;function Qr(){return Fn||(Fn=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=I(j),n=v(we()),r=v(Gt),i=v(Kr),o=ln(),d=ir(),b=Ft(),h=v(Jr()),S=v(or());function v(a){return a&&a.__esModule?a:{default:a}}function C(a){if(typeof WeakMap!="function")return null;var f=new WeakMap,y=new WeakMap;return(C=function(l){return l?y:f})(a)}function I(a,f){if(a&&a.__esModule)return a;if(a===null||typeof a!="object"&&typeof a!="function")return{default:a};var y=C(f);if(y&&y.has(a))return y.get(a);var l={},g=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in a)if(u!=="default"&&Object.prototype.hasOwnProperty.call(a,u)){var m=g?Object.getOwnPropertyDescriptor(a,u):null;m&&(m.get||m.set)?Object.defineProperty(l,u,m):l[u]=a[u]}return l.default=a,y&&y.set(a,l),l}function w(){return w=Object.assign?Object.assign.bind():function(a){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var l in y)Object.prototype.hasOwnProperty.call(y,l)&&(a[l]=y[l])}return a},w.apply(this,arguments)}function x(a,f,y){return f=R(f),f in a?Object.defineProperty(a,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):a[f]=y,a}function R(a){var f=p(a,"string");return typeof f=="symbol"?f:String(f)}function p(a,f){if(typeof a!="object"||a===null)return a;var y=a[Symbol.toPrimitive];if(y!==void 0){var l=y.call(a,f);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(f==="string"?String:Number)(a)}class s extends t.Component{static getDerivedStateFromProps(f,y){let{position:l}=f,{prevPropsPosition:g}=y;return l&&(!g||l.x!==g.x||l.y!==g.y)?((0,S.default)("Draggable: getDerivedStateFromProps %j",{position:l,prevPropsPosition:g}),{x:l.x,y:l.y,prevPropsPosition:{...l}}):null}constructor(f){super(f),x(this,"onDragStart",(y,l)=>{if((0,S.default)("Draggable: onDragStart: %j",l),this.props.onStart(y,(0,d.createDraggableData)(this,l))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),x(this,"onDrag",(y,l)=>{if(!this.state.dragging)return!1;(0,S.default)("Draggable: onDrag: %j",l);const g=(0,d.createDraggableData)(this,l),u={x:g.x,y:g.y,slackX:0,slackY:0};if(this.props.bounds){const{x:F,y:P}=u;u.x+=this.state.slackX,u.y+=this.state.slackY;const[L,U]=(0,d.getBoundPosition)(this,u.x,u.y);u.x=L,u.y=U,u.slackX=this.state.slackX+(F-u.x),u.slackY=this.state.slackY+(P-u.y),g.x=u.x,g.y=u.y,g.deltaX=u.x-this.state.x,g.deltaY=u.y-this.state.y}if(this.props.onDrag(y,g)===!1)return!1;this.setState(u)}),x(this,"onDragStop",(y,l)=>{if(!this.state.dragging||this.props.onStop(y,(0,d.createDraggableData)(this,l))===!1)return!1;(0,S.default)("Draggable: onDragStop: %j",l);const u={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:F,y:P}=this.props.position;u.x=F,u.y=P}this.setState(u)}),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:r.default.findDOMNode(this)}render(){const{axis:f,bounds:y,children:l,defaultPosition:g,defaultClassName:u,defaultClassNameDragging:m,defaultClassNameDragged:F,position:P,positionOffset:L,scale:U,...E}=this.props;let N={},A=null;const G=!!!P||this.state.dragging,re=P||g,te={x:(0,d.canDragX)(this)&&G?this.state.x:re.x,y:(0,d.canDragY)(this)&&G?this.state.y:re.y};this.state.isElementSVG?A=(0,o.createSVGTransform)(te,L):N=(0,o.createCSSTransform)(te,L);const se=(0,i.default)(l.props.className||"",u,{[m]:this.state.dragging,[F]:this.state.dragged});return t.createElement(h.default,w({},E,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(l),{className:se,style:{...l.props.style,...N},transform:A}))}}e.default=s,x(s,"displayName","Draggable"),x(s,"propTypes",{...h.default.propTypes,axis:n.default.oneOf(["both","x","y","none"]),bounds:n.default.oneOfType([n.default.shape({left:n.default.number,right:n.default.number,top:n.default.number,bottom:n.default.number}),n.default.string,n.default.oneOf([!1])]),defaultClassName:n.default.string,defaultClassNameDragging:n.default.string,defaultClassNameDragged:n.default.string,defaultPosition:n.default.shape({x:n.default.number,y:n.default.number}),positionOffset:n.default.shape({x:n.default.oneOfType([n.default.number,n.default.string]),y:n.default.oneOfType([n.default.number,n.default.string])}),position:n.default.shape({x:n.default.number,y:n.default.number}),className:b.dontSetMe,style:b.dontSetMe,transform:b.dontSetMe}),x(s,"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})}(kt)),kt}var Pn;function un(){if(Pn)return Ae.exports;Pn=1;const{default:e,DraggableCore:t}=Qr();return Ae.exports=e,Ae.exports.default=e,Ae.exports.DraggableCore=t,Ae.exports}var We={exports:{}},Be={},vt={},Mn;function ei(){if(Mn)return vt;Mn=1,vt.__esModule=!0,vt.cloneElement=b;var e=t(j);function t(h){return h&&h.__esModule?h:{default:h}}function n(h,S){var v=Object.keys(h);if(Object.getOwnPropertySymbols){var C=Object.getOwnPropertySymbols(h);S&&(C=C.filter(function(I){return Object.getOwnPropertyDescriptor(h,I).enumerable})),v.push.apply(v,C)}return v}function r(h){for(var S=1;S<arguments.length;S++){var v=arguments[S]!=null?arguments[S]:{};S%2?n(Object(v),!0).forEach(function(C){i(h,C,v[C])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(v)):n(Object(v)).forEach(function(C){Object.defineProperty(h,C,Object.getOwnPropertyDescriptor(v,C))})}return h}function i(h,S,v){return S=o(S),S in h?Object.defineProperty(h,S,{value:v,enumerable:!0,configurable:!0,writable:!0}):h[S]=v,h}function o(h){var S=d(h,"string");return typeof S=="symbol"?S:String(S)}function d(h,S){if(typeof h!="object"||h===null)return h;var v=h[Symbol.toPrimitive];if(v!==void 0){var C=v.call(h,S);if(typeof C!="object")return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return(S==="string"?String:Number)(h)}function b(h,S){return S.style&&h.props.style&&(S.style=r(r({},h.props.style),S.style)),S.className&&h.props.className&&(S.className=h.props.className+" "+S.className),e.default.cloneElement(h,S)}return vt}var $e={},Nn;function sr(){if(Nn)return $e;Nn=1,$e.__esModule=!0,$e.resizableProps=void 0;var e=t(we());un();function t(r){return r&&r.__esModule?r:{default:r}}var n={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 i=arguments.length,o=new Array(i),d=0;d<i;d++)o[d]=arguments[d];var b=o[0];if(b.axis==="both"||b.axis==="y"){var h;return(h=e.default.number).isRequired.apply(h,o)}return e.default.number.apply(e.default,o)},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 i=arguments.length,o=new Array(i),d=0;d<i;d++)o[d]=arguments[d];var b=o[0];if(b.axis==="both"||b.axis==="x"){var h;return(h=e.default.number).isRequired.apply(h,o)}return e.default.number.apply(e.default,o)}};return $e.resizableProps=n,$e}var jn;function ar(){if(jn)return Be;jn=1,Be.__esModule=!0,Be.default=void 0;var e=d(j),t=un(),n=ei(),r=sr(),i=["children","className","draggableOpts","width","height","handle","handleSize","lockAspectRatio","axis","minConstraints","maxConstraints","onResize","onResizeStop","onResizeStart","resizeHandles","transformScale"];function o(s){if(typeof WeakMap!="function")return null;var a=new WeakMap,f=new WeakMap;return(o=function(l){return l?f:a})(s)}function d(s,a){if(s&&s.__esModule)return s;if(s===null||typeof s!="object"&&typeof s!="function")return{default:s};var f=o(a);if(f&&f.has(s))return f.get(s);var y={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var g in s)if(g!=="default"&&Object.prototype.hasOwnProperty.call(s,g)){var u=l?Object.getOwnPropertyDescriptor(s,g):null;u&&(u.get||u.set)?Object.defineProperty(y,g,u):y[g]=s[g]}return y.default=s,f&&f.set(s,y),y}function b(){return b=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var f=arguments[a];for(var y in f)Object.prototype.hasOwnProperty.call(f,y)&&(s[y]=f[y])}return s},b.apply(this,arguments)}function h(s,a){if(s==null)return{};var f={},y=Object.keys(s),l,g;for(g=0;g<y.length;g++)l=y[g],!(a.indexOf(l)>=0)&&(f[l]=s[l]);return f}function S(s,a){var f=Object.keys(s);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(s);a&&(y=y.filter(function(l){return Object.getOwnPropertyDescriptor(s,l).enumerable})),f.push.apply(f,y)}return f}function v(s){for(var a=1;a<arguments.length;a++){var f=arguments[a]!=null?arguments[a]:{};a%2?S(Object(f),!0).forEach(function(y){C(s,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(f)):S(Object(f)).forEach(function(y){Object.defineProperty(s,y,Object.getOwnPropertyDescriptor(f,y))})}return s}function C(s,a,f){return a=I(a),a in s?Object.defineProperty(s,a,{value:f,enumerable:!0,configurable:!0,writable:!0}):s[a]=f,s}function I(s){var a=w(s,"string");return typeof a=="symbol"?a:String(a)}function w(s,a){if(typeof s!="object"||s===null)return s;var f=s[Symbol.toPrimitive];if(f!==void 0){var y=f.call(s,a);if(typeof y!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(s)}function x(s,a){s.prototype=Object.create(a.prototype),s.prototype.constructor=s,R(s,a)}function R(s,a){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,l){return y.__proto__=l,y},R(s,a)}var p=function(s){x(a,s);function a(){for(var y,l=arguments.length,g=new Array(l),u=0;u<l;u++)g[u]=arguments[u];return y=s.call.apply(s,[this].concat(g))||this,y.handleRefs={},y.lastHandleRect=null,y.slack=null,y}var f=a.prototype;return f.componentWillUnmount=function(){this.resetData()},f.resetData=function(){this.lastHandleRect=this.slack=null},f.runConstraints=function(l,g){var u=this.props,m=u.minConstraints,F=u.maxConstraints,P=u.lockAspectRatio;if(!m&&!F&&!P)return[l,g];if(P){var L=this.props.width/this.props.height,U=l-this.props.width,E=g-this.props.height;Math.abs(U)>Math.abs(E*L)?g=l/L:l=g*L}var N=l,A=g,W=this.slack||[0,0],G=W[0],re=W[1];return l+=G,g+=re,m&&(l=Math.max(m[0],l),g=Math.max(m[1],g)),F&&(l=Math.min(F[0],l),g=Math.min(F[1],g)),this.slack=[G+(N-l),re+(A-g)],[l,g]},f.resizeHandler=function(l,g){var u=this;return function(m,F){var P=F.node,L=F.deltaX,U=F.deltaY;l==="onResizeStart"&&u.resetData();var E=(u.props.axis==="both"||u.props.axis==="x")&&g!=="n"&&g!=="s",N=(u.props.axis==="both"||u.props.axis==="y")&&g!=="e"&&g!=="w";if(!(!E&&!N)){var A=g[0],W=g[g.length-1],G=P.getBoundingClientRect();if(u.lastHandleRect!=null){if(W==="w"){var re=G.left-u.lastHandleRect.left;L+=re}if(A==="n"){var te=G.top-u.lastHandleRect.top;U+=te}}u.lastHandleRect=G,W==="w"&&(L=-L),A==="n"&&(U=-U);var se=u.props.width+(E?L/u.props.transformScale:0),z=u.props.height+(N?U/u.props.transformScale:0),Z=u.runConstraints(se,z);se=Z[0],z=Z[1];var ee=se!==u.props.width||z!==u.props.height,oe=typeof u.props[l]=="function"?u.props[l]:null,ue=l==="onResize"&&!ee;oe&&!ue&&(m.persist==null||m.persist(),oe(m,{node:P,size:{width:se,height:z},handle:g})),l==="onResizeStop"&&u.resetData()}}},f.renderResizeHandle=function(l,g){var u=this.props.handle;if(!u)return e.createElement("span",{className:"react-resizable-handle react-resizable-handle-"+l,ref:g});if(typeof u=="function")return u(l,g);var m=typeof u.type=="string",F=v({ref:g},m?{}:{handleAxis:l});return e.cloneElement(u,F)},f.render=function(){var l=this,g=this.props,u=g.children,m=g.className,F=g.draggableOpts;g.width,g.height,g.handle,g.handleSize,g.lockAspectRatio,g.axis,g.minConstraints,g.maxConstraints,g.onResize,g.onResizeStop,g.onResizeStart;var P=g.resizeHandles;g.transformScale;var L=h(g,i);return(0,n.cloneElement)(u,v(v({},L),{},{className:(m?m+" ":"")+"react-resizable",children:[].concat(u.props.children,P.map(function(U){var E,N=(E=l.handleRefs[U])!=null?E:l.handleRefs[U]=e.createRef();return e.createElement(t.DraggableCore,b({},F,{nodeRef:N,key:"resizableHandle-"+U,onStop:l.resizeHandler("onResizeStop",U),onStart:l.resizeHandler("onResizeStart",U),onDrag:l.resizeHandler("onResize",U)}),l.renderResizeHandle(U,N))}))}))},a}(e.Component);return Be.default=p,p.propTypes=r.resizableProps,p.defaultProps={axis:"both",handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:["se"],transformScale:1},Be}var Ge={},Ln;function ti(){if(Ln)return Ge;Ln=1,Ge.__esModule=!0,Ge.default=void 0;var e=b(j),t=o(we()),n=o(ar()),r=sr(),i=["handle","handleSize","onResize","onResizeStart","onResizeStop","draggableOpts","minConstraints","maxConstraints","lockAspectRatio","axis","width","height","resizeHandles","style","transformScale"];function o(a){return a&&a.__esModule?a:{default:a}}function d(a){if(typeof WeakMap!="function")return null;var f=new WeakMap,y=new WeakMap;return(d=function(g){return g?y:f})(a)}function b(a,f){if(a&&a.__esModule)return a;if(a===null||typeof a!="object"&&typeof a!="function")return{default:a};var y=d(f);if(y&&y.has(a))return y.get(a);var l={},g=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in a)if(u!=="default"&&Object.prototype.hasOwnProperty.call(a,u)){var m=g?Object.getOwnPropertyDescriptor(a,u):null;m&&(m.get||m.set)?Object.defineProperty(l,u,m):l[u]=a[u]}return l.default=a,y&&y.set(a,l),l}function h(){return h=Object.assign?Object.assign.bind():function(a){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var l in y)Object.prototype.hasOwnProperty.call(y,l)&&(a[l]=y[l])}return a},h.apply(this,arguments)}function S(a,f){var y=Object.keys(a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(a);f&&(l=l.filter(function(g){return Object.getOwnPropertyDescriptor(a,g).enumerable})),y.push.apply(y,l)}return y}function v(a){for(var f=1;f<arguments.length;f++){var y=arguments[f]!=null?arguments[f]:{};f%2?S(Object(y),!0).forEach(function(l){C(a,l,y[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(y)):S(Object(y)).forEach(function(l){Object.defineProperty(a,l,Object.getOwnPropertyDescriptor(y,l))})}return a}function C(a,f,y){return f=I(f),f in a?Object.defineProperty(a,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):a[f]=y,a}function I(a){var f=w(a,"string");return typeof f=="symbol"?f:String(f)}function w(a,f){if(typeof a!="object"||a===null)return a;var y=a[Symbol.toPrimitive];if(y!==void 0){var l=y.call(a,f);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(f==="string"?String:Number)(a)}function x(a,f){if(a==null)return{};var y={},l=Object.keys(a),g,u;for(u=0;u<l.length;u++)g=l[u],!(f.indexOf(g)>=0)&&(y[g]=a[g]);return y}function R(a,f){a.prototype=Object.create(f.prototype),a.prototype.constructor=a,p(a,f)}function p(a,f){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,g){return l.__proto__=g,l},p(a,f)}var s=function(a){R(f,a);function f(){for(var l,g=arguments.length,u=new Array(g),m=0;m<g;m++)u[m]=arguments[m];return l=a.call.apply(a,[this].concat(u))||this,l.state={width:l.props.width,height:l.props.height,propsWidth:l.props.width,propsHeight:l.props.height},l.onResize=function(F,P){var L=P.size;l.props.onResize?(F.persist==null||F.persist(),l.setState(L,function(){return l.props.onResize&&l.props.onResize(F,P)})):l.setState(L)},l}f.getDerivedStateFromProps=function(g,u){return u.propsWidth!==g.width||u.propsHeight!==g.height?{width:g.width,height:g.height,propsWidth:g.width,propsHeight:g.height}:null};var y=f.prototype;return y.render=function(){var g=this.props,u=g.handle,m=g.handleSize;g.onResize;var F=g.onResizeStart,P=g.onResizeStop,L=g.draggableOpts,U=g.minConstraints,E=g.maxConstraints,N=g.lockAspectRatio,A=g.axis;g.width,g.height;var W=g.resizeHandles,G=g.style,re=g.transformScale,te=x(g,i);return e.createElement(n.default,{axis:A,draggableOpts:L,handle:u,handleSize:m,height:this.state.height,lockAspectRatio:N,maxConstraints:E,minConstraints:U,onResizeStart:F,onResize:this.onResize,onResizeStop:P,resizeHandles:W,transformScale:re,width:this.state.width},e.createElement("div",h({},te,{style:v(v({},G),{},{width:this.state.width+"px",height:this.state.height+"px"})})))},f}(e.Component);return Ge.default=s,s.propTypes=v(v({},r.resizableProps),{},{children:t.default.element}),Ge}var Un;function ni(){return Un||(Un=1,We.exports=function(){throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable")},We.exports.Resizable=ar().default,We.exports.ResizableBox=ti().default),We.exports}var Se={},Vn;function lr(){if(Vn)return Se;Vn=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.resizeHandleType=Se.resizeHandleAxesType=Se.default=void 0;var e=n(we()),t=n(j);function n(o){return o&&o.__esModule?o:{default:o}}const r=Se.resizeHandleAxesType=e.default.arrayOf(e.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),i=Se.resizeHandleType=e.default.oneOfType([e.default.node,e.default.func]);return Se.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(o){o.verticalCompact},compactType:e.default.oneOf(["vertical","horizontal"]),layout:function(o){var d=o.layout;d!==void 0&&ze().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:r,resizeHandle:i,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(o,d){const b=o[d],h={};t.default.Children.forEach(b,function(S){if((S==null?void 0:S.key)!=null){if(h[S.key])throw new Error('Duplicate child key "'+S.key+'" found! This will cause problems in ReactGridLayout.');h[S.key]=!0}})},innerRef:e.default.any},Se}var zn;function ri(){if(zn)return qe;zn=1,Object.defineProperty(qe,"__esModule",{value:!0}),qe.default=void 0;var e=S(j),t=Gt,n=S(we()),r=un(),i=ni(),o=ze(),d=an(),b=lr(),h=S(sn());function S(x){return x&&x.__esModule?x:{default:x}}function v(x,R,p){return R=C(R),R in x?Object.defineProperty(x,R,{value:p,enumerable:!0,configurable:!0,writable:!0}):x[R]=p,x}function C(x){var R=I(x,"string");return typeof R=="symbol"?R:String(R)}function I(x,R){if(typeof x!="object"||x===null)return x;var p=x[Symbol.toPrimitive];if(p!==void 0){var s=p.call(x,R);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(R==="string"?String:Number)(x)}let w=class extends e.default.Component{constructor(){super(...arguments),v(this,"state",{resizing:null,dragging:null,className:""}),v(this,"elementRef",e.default.createRef()),v(this,"onDragStart",(R,p)=>{let{node:s}=p;const{onDragStart:a,transformScale:f}=this.props;if(!a)return;const y={top:0,left:0},{offsetParent:l}=s;if(!l)return;const g=l.getBoundingClientRect(),u=s.getBoundingClientRect(),m=u.left/f,F=g.left/f,P=u.top/f,L=g.top/f;y.left=m-F+l.scrollLeft,y.top=P-L+l.scrollTop,this.setState({dragging:y});const{x:U,y:E}=(0,d.calcXY)(this.getPositionParams(),y.top,y.left,this.props.w,this.props.h);return a.call(this,this.props.i,U,E,{e:R,node:s,newPosition:y})}),v(this,"onDrag",(R,p,s)=>{let{node:a,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 g=this.state.dragging.top+y,u=this.state.dragging.left+f;const{isBounded:m,i:F,w:P,h:L,containerWidth:U}=this.props,E=this.getPositionParams();if(m){const{offsetParent:G}=a;if(G){const{margin:re,rowHeight:te,containerPadding:se}=this.props,z=G.clientHeight-(0,d.calcGridItemWHPx)(L,te,re[1]);g=(0,d.clamp)(g-se[1],0,z);const Z=(0,d.calcGridColWidth)(E),ee=U-(0,d.calcGridItemWHPx)(P,Z,re[0]);u=(0,d.clamp)(u-se[0],0,ee)}}const N={top:g,left:u};s?this.setState({dragging:N}):(0,t.flushSync)(()=>{this.setState({dragging:N})});const{x:A,y:W}=(0,d.calcXY)(E,g,u,P,L);return l.call(this,F,A,W,{e:R,node:a,newPosition:N})}),v(this,"onDragStop",(R,p)=>{let{node:s}=p;const{onDragStop:a}=this.props;if(!a)return;if(!this.state.dragging)throw new Error("onDragEnd called before onDragStart.");const{w:f,h:y,i:l}=this.props,{left:g,top:u}=this.state.dragging,m={top:u,left:g};this.setState({dragging:null});const{x:F,y:P}=(0,d.calcXY)(this.getPositionParams(),u,g,f,y);return a.call(this,l,F,P,{e:R,node:s,newPosition:m})}),v(this,"onResizeStop",(R,p,s)=>this.onResizeHandler(R,p,s,"onResizeStop")),v(this,"onResizeStart",(R,p,s)=>this.onResizeHandler(R,p,s,"onResizeStart")),v(this,"onResize",(R,p,s)=>this.onResizeHandler(R,p,s,"onResize"))}shouldComponentUpdate(R,p){if(this.props.children!==R.children||this.props.droppingPosition!==R.droppingPosition)return!0;const s=(0,d.calcGridItemPosition)(this.getPositionParams(this.props),this.props.x,this.props.y,this.props.w,this.props.h,this.state),a=(0,d.calcGridItemPosition)(this.getPositionParams(R),R.x,R.y,R.w,R.h,p);return!(0,o.fastPositionEqual)(s,a)||this.props.useCSSTransforms!==R.useCSSTransforms}componentDidMount(){this.moveDroppingItem({})}componentDidUpdate(R){this.moveDroppingItem(R)}moveDroppingItem(R){const{droppingPosition:p}=this.props;if(!p)return;const s=this.elementRef.current;if(!s)return;const a=R.droppingPosition||{left:0,top:0},{dragging:f}=this.state,y=f&&p.left!==a.left||p.top!==a.top;if(!f)this.onDragStart(p.e,{node:s,deltaX:p.left,deltaY:p.top});else if(y){const l=p.left-f.left,g=p.top-f.top;this.onDrag(p.e,{node:s,deltaX:l,deltaY:g},!0)}}getPositionParams(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return{cols:R.cols,containerPadding:R.containerPadding,containerWidth:R.containerWidth,margin:R.margin,maxRows:R.maxRows,rowHeight:R.rowHeight}}createStyle(R){const{usePercentages:p,containerWidth:s,useCSSTransforms:a}=this.props;let f;return a?f=(0,o.setTransform)(R):(f=(0,o.setTopLeft)(R),p&&(f.left=(0,o.perc)(R.left/s),f.width=(0,o.perc)(R.width/s))),f}mixinDraggable(R,p){return e.default.createElement(r.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},R)}curryResizeHandler(R,p){return(s,a)=>p(s,a,R)}mixinResizable(R,p,s){const{cols:a,minW:f,minH:y,maxW:l,maxH:g,transformScale:u,resizeHandles:m,resizeHandle:F}=this.props,P=this.getPositionParams(),L=(0,d.calcGridItemPosition)(P,0,0,a,0).width,U=(0,d.calcGridItemPosition)(P,0,0,f,y),E=(0,d.calcGridItemPosition)(P,0,0,l,g),N=[U.width,U.height],A=[Math.min(E.width,L),Math.min(E.height,1/0)];return e.default.createElement(i.Resizable,{draggableOpts:{disabled:!s},className:s?void 0:"react-resizable-hide",width:p.width,height:p.height,minConstraints:N,maxConstraints:A,onResizeStop:this.curryResizeHandler(p,this.onResizeStop),onResizeStart:this.curryResizeHandler(p,this.onResizeStart),onResize:this.curryResizeHandler(p,this.onResize),transformScale:u,resizeHandles:m,handle:F},R)}onResizeHandler(R,p,s,a){let{node:f,size:y,handle:l}=p;const g=this.props[a];if(!g)return;const{x:u,y:m,i:F,maxH:P,minH:L,containerWidth:U}=this.props,{minW:E,maxW:N}=this.props;let A=y;f&&(A=(0,o.resizeItemInDirection)(l,s,y,U),(0,t.flushSync)(()=>{this.setState({resizing:a==="onResizeStop"?null:A})}));let{w:W,h:G}=(0,d.calcWH)(this.getPositionParams(),A.width,A.height,u,m,l);W=(0,d.clamp)(W,Math.max(E,1),N),G=(0,d.clamp)(G,L,P),g.call(this,F,W,G,{e:R,node:f,size:A,handle:l})}render(){const{x:R,y:p,w:s,h:a,isDraggable:f,isResizable:y,droppingPosition:l,useCSSTransforms:g}=this.props,u=(0,d.calcGridItemPosition)(this.getPositionParams(),R,p,s,a,this.state),m=e.default.Children.only(this.props.children);let F=e.default.cloneElement(m,{ref:this.elementRef,className:(0,h.default)("react-grid-item",m.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:g}),style:{...this.props.style,...m.props.style,...this.createStyle(u)}});return F=this.mixinResizable(F,u,y),F=this.mixinDraggable(F,f),F}};return qe.default=w,v(w,"propTypes",{children:n.default.element,cols:n.default.number.isRequired,containerWidth:n.default.number.isRequired,rowHeight:n.default.number.isRequired,margin:n.default.array.isRequired,maxRows:n.default.number.isRequired,containerPadding:n.default.array.isRequired,x:n.default.number.isRequired,y:n.default.number.isRequired,w:n.default.number.isRequired,h:n.default.number.isRequired,minW:function(x,R){const p=x[R];if(typeof p!="number")return new Error("minWidth not Number");if(p>x.w||p>x.maxW)return new Error("minWidth larger than item width/maxWidth")},maxW:function(x,R){const p=x[R];if(typeof p!="number")return new Error("maxWidth not Number");if(p<x.w||p<x.minW)return new Error("maxWidth smaller than item width/minWidth")},minH:function(x,R){const p=x[R];if(typeof p!="number")return new Error("minHeight not Number");if(p>x.h||p>x.maxH)return new Error("minHeight larger than item height/maxHeight")},maxH:function(x,R){const p=x[R];if(typeof p!="number")return new Error("maxHeight not Number");if(p<x.h||p<x.minH)return new Error("maxHeight smaller than item height/minHeight")},i:n.default.string.isRequired,resizeHandles:b.resizeHandleAxesType,resizeHandle:b.resizeHandleType,onDragStop:n.default.func,onDragStart:n.default.func,onDrag:n.default.func,onResizeStop:n.default.func,onResizeStart:n.default.func,onResize:n.default.func,isDraggable:n.default.bool.isRequired,isResizable:n.default.bool.isRequired,isBounded:n.default.bool.isRequired,static:n.default.bool,useCSSTransforms:n.default.bool.isRequired,transformScale:n.default.number,className:n.default.string,handle:n.default.string,cancel:n.default.string,droppingPosition:n.default.shape({e:n.default.object.isRequired,left:n.default.number.isRequired,top:n.default.number.isRequired})}),v(w,"defaultProps",{className:"",cancel:"",handle:"",minH:1,minW:1,maxH:1/0,maxW:1/0,transformScale:1}),qe}var kn;function ur(){if(kn)return ke;kn=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.default=void 0;var e=S(j),t=on(),n=b(sn()),r=ze(),i=an(),o=b(ri()),d=b(lr());function b(p){return p&&p.__esModule?p:{default:p}}function h(p){if(typeof WeakMap!="function")return null;var s=new WeakMap,a=new WeakMap;return(h=function(f){return f?a:s})(p)}function S(p,s){if(p&&p.__esModule)return p;if(p===null||typeof p!="object"&&typeof p!="function")return{default:p};var a=h(s);if(a&&a.has(p))return a.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 g=y?Object.getOwnPropertyDescriptor(p,l):null;g&&(g.get||g.set)?Object.defineProperty(f,l,g):f[l]=p[l]}return f.default=p,a&&a.set(p,f),f}function v(p,s,a){return s=C(s),s in p?Object.defineProperty(p,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):p[s]=a,p}function C(p){var s=I(p,"string");return typeof s=="symbol"?s:String(s)}function I(p,s){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var f=a.call(p,s);if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(p)}const w="react-grid-layout";let x=!1;try{x=/firefox/i.test(navigator.userAgent)}catch{}let R=class extends e.Component{constructor(){super(...arguments),v(this,"state",{activeDrag:null,layout:(0,r.synchronizeLayoutWithChildren)(this.props.layout,this.props.children,this.props.cols,(0,r.compactType)(this.props),this.props.allowOverlap),mounted:!1,oldDragItem:null,oldLayout:null,oldResizeItem:null,resizing:!1,droppingDOMNode:null,children:[]}),v(this,"dragEnterCounter",0),v(this,"onDragStart",(s,a,f,y)=>{let{e:l,node:g}=y;const{layout:u}=this.state,m=(0,r.getLayoutItem)(u,s);if(!m)return;const F={w:m.w,h:m.h,x:m.x,y:m.y,placeholder:!0,i:s};return this.setState({oldDragItem:(0,r.cloneLayoutItem)(m),oldLayout:u,activeDrag:F}),this.props.onDragStart(u,m,m,null,l,g)}),v(this,"onDrag",(s,a,f,y)=>{let{e:l,node:g}=y;const{oldDragItem:u}=this.state;let{layout:m}=this.state;const{cols:F,allowOverlap:P,preventCollision:L}=this.props,U=(0,r.getLayoutItem)(m,s);if(!U)return;const E={w:U.w,h:U.h,x:U.x,y:U.y,placeholder:!0,i:s};m=(0,r.moveElement)(m,U,a,f,!0,L,(0,r.compactType)(this.props),F,P),this.props.onDrag(m,u,U,E,l,g),this.setState({layout:P?m:(0,r.compact)(m,(0,r.compactType)(this.props),F),activeDrag:E})}),v(this,"onDragStop",(s,a,f,y)=>{let{e:l,node:g}=y;if(!this.state.activeDrag)return;const{oldDragItem:u}=this.state;let{layout:m}=this.state;const{cols:F,preventCollision:P,allowOverlap:L}=this.props,U=(0,r.getLayoutItem)(m,s);if(!U)return;m=(0,r.moveElement)(m,U,a,f,!0,P,(0,r.compactType)(this.props),F,L);const N=L?m:(0,r.compact)(m,(0,r.compactType)(this.props),F);this.props.onDragStop(N,u,U,null,l,g);const{oldLayout:A}=this.state;this.setState({activeDrag:null,layout:N,oldDragItem:null,oldLayout:null}),this.onLayoutMaybeChanged(N,A)}),v(this,"onResizeStart",(s,a,f,y)=>{let{e:l,node:g}=y;const{layout:u}=this.state,m=(0,r.getLayoutItem)(u,s);m&&(this.setState({oldResizeItem:(0,r.cloneLayoutItem)(m),oldLayout:this.state.layout,resizing:!0}),this.props.onResizeStart(u,m,m,null,l,g))}),v(this,"onResize",(s,a,f,y)=>{let{e:l,node:g,size:u,handle:m}=y;const{oldResizeItem:F}=this.state,{layout:P}=this.state,{cols:L,preventCollision:U,allowOverlap:E}=this.props;let N=!1,A,W,G;const[re,te]=(0,r.withLayoutItem)(P,s,z=>{let Z;return W=z.x,G=z.y,["sw","w","nw","n","ne"].indexOf(m)!==-1&&(["sw","nw","w"].indexOf(m)!==-1&&(W=z.x+(z.w-a),a=z.x!==W&&W<0?z.w:a,W=W<0?0:W),["ne","n","nw"].indexOf(m)!==-1&&(G=z.y+(z.h-f),f=z.y!==G&&G<0?z.h:f,G=G<0?0:G),N=!0),U&&!E&&(Z=(0,r.getAllCollisions)(P,{...z,w:a,h:f,x:W,y:G}).filter(oe=>oe.i!==z.i).length>0,Z&&(G=z.y,f=z.h,W=z.x,a=z.w,N=!1)),z.w=a,z.h=f,z});if(!te)return;A=re,N&&(A=(0,r.moveElement)(re,te,W,G,!0,this.props.preventCollision,(0,r.compactType)(this.props),L,E));const se={w:te.w,h:te.h,x:te.x,y:te.y,static:!0,i:s};this.props.onResize(A,F,te,se,l,g),this.setState({layout:E?A:(0,r.compact)(A,(0,r.compactType)(this.props),L),activeDrag:se})}),v(this,"onResizeStop",(s,a,f,y)=>{let{e:l,node:g}=y;const{layout:u,oldResizeItem:m}=this.state,{cols:F,allowOverlap:P}=this.props,L=(0,r.getLayoutItem)(u,s),U=P?u:(0,r.compact)(u,(0,r.compactType)(this.props),F);this.props.onResizeStop(U,m,L,null,l,g);const{oldLayout:E}=this.state;this.setState({activeDrag:null,layout:U,oldResizeItem:null,oldLayout:null,resizing:!1}),this.onLayoutMaybeChanged(U,E)}),v(this,"onDragOver",s=>{var re;if(s.preventDefault(),s.stopPropagation(),x&&!((re=s.nativeEvent.target)!=null&&re.classList.contains(w)))return!1;const{droppingItem:a,onDropDragOver:f,margin:y,cols:l,rowHeight:g,maxRows:u,width:m,containerPadding:F,transformScale:P}=this.props,L=f==null?void 0:f(s);if(L===!1)return this.state.droppingDOMNode&&this.removeDroppingPlaceholder(),!1;const U={...a,...L},{layout:E}=this.state,N=s.currentTarget.getBoundingClientRect(),A=s.clientX-N.left,W=s.clientY-N.top,G={left:A/P,top:W/P,e:s};if(this.state.droppingDOMNode){if(this.state.droppingPosition){const{left:te,top:se}=this.state.droppingPosition;(te!=A||se!=W)&&this.setState({droppingPosition:G})}}else{const te={cols:l,margin:y,maxRows:u,rowHeight:g,containerWidth:m,containerPadding:F||y},se=(0,i.calcXY)(te,W,A,U.w,U.h);this.setState({droppingDOMNode:e.createElement("div",{key:U.i}),droppingPosition:G,layout:[...E,{...U,x:se.x,y:se.y,static:!1,isDraggable:!0}]})}}),v(this,"removeDroppingPlaceholder",()=>{const{droppingItem:s,cols:a}=this.props,{layout:f}=this.state,y=(0,r.compact)(f.filter(l=>l.i!==s.i),(0,r.compactType)(this.props),a,this.props.allowOverlap);this.setState({layout:y,droppingDOMNode:null,activeDrag:null,droppingPosition:void 0})}),v(this,"onDragLeave",s=>{s.preventDefault(),s.stopPropagation(),this.dragEnterCounter--,this.dragEnterCounter===0&&this.removeDroppingPlaceholder()}),v(this,"onDragEnter",s=>{s.preventDefault(),s.stopPropagation(),this.dragEnterCounter++}),v(this,"onDrop",s=>{s.preventDefault(),s.stopPropagation();const{droppingItem:a}=this.props,{layout:f}=this.state,y=f.find(l=>l.i===a.i);this.dragEnterCounter=0,this.removeDroppingPlaceholder(),this.props.onDrop(f,y,s)})}componentDidMount(){this.setState({mounted:!0}),this.onLayoutMaybeChanged(this.state.layout,this.props.layout)}static getDerivedStateFromProps(s,a){let f;return a.activeDrag?null:(!(0,t.deepEqual)(s.layout,a.propsLayout)||s.compactType!==a.compactType?f=s.layout:(0,r.childrenEqual)(s.children,a.children)||(f=a.layout),f?{layout:(0,r.synchronizeLayoutWithChildren)(f,s.children,s.cols,(0,r.compactType)(s),s.allowOverlap),compactType:s.compactType,children:s.children,propsLayout:s.layout}:null)}shouldComponentUpdate(s,a){return this.props.children!==s.children||!(0,r.fastRGLPropsEqual)(this.props,s,t.deepEqual)||this.state.activeDrag!==a.activeDrag||this.state.mounted!==a.mounted||this.state.droppingPosition!==a.droppingPosition}componentDidUpdate(s,a){if(!this.state.activeDrag){const f=this.state.layout,y=a.layout;this.onLayoutMaybeChanged(f,y)}}containerHeight(){if(!this.props.autoSize)return;const s=(0,r.bottom)(this.state.layout),a=this.props.containerPadding?this.props.containerPadding[1]:this.props.margin[1];return s*this.props.rowHeight+(s-1)*this.props.margin[1]+a*2+"px"}onLayoutMaybeChanged(s,a){a||(a=this.state.layout),(0,t.deepEqual)(a,s)||this.props.onLayoutChange(s)}placeholder(){const{activeDrag:s}=this.state;if(!s)return null;const{width:a,cols:f,margin:y,containerPadding:l,rowHeight:g,maxRows:u,useCSSTransforms:m,transformScale:F}=this.props;return e.createElement(o.default,{w:s.w,h:s.h,x:s.x,y:s.y,i:s.i,className:`react-grid-placeholder ${this.state.resizing?"placeholder-resizing":""}`,containerWidth:a,cols:f,margin:y,containerPadding:l||y,maxRows:u,rowHeight:g,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:m,transformScale:F},e.createElement("div",null))}processGridItem(s,a){if(!s||!s.key)return;const f=(0,r.getLayoutItem)(this.state.layout,String(s.key));if(!f)return null;const{width:y,cols:l,margin:g,containerPadding:u,rowHeight:m,maxRows:F,isDraggable:P,isResizable:L,isBounded:U,useCSSTransforms:E,transformScale:N,draggableCancel:A,draggableHandle:W,resizeHandles:G,resizeHandle:re}=this.props,{mounted:te,droppingPosition:se}=this.state,z=typeof f.isDraggable=="boolean"?f.isDraggable:!f.static&&P,Z=typeof f.isResizable=="boolean"?f.isResizable:!f.static&&L,ee=f.resizeHandles||G,oe=z&&U&&f.isBounded!==!1;return e.createElement(o.default,{containerWidth:y,cols:l,margin:g,containerPadding:u||g,maxRows:F,rowHeight:m,cancel:A,handle:W,onDragStop:this.onDragStop,onDragStart:this.onDragStart,onDrag:this.onDrag,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,isDraggable:z,isResizable:Z,isBounded:oe,useCSSTransforms:E&&te,usePercentages:!te,transformScale:N,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:a?se:void 0,resizeHandles:ee,resizeHandle:re},s)}render(){const{className:s,style:a,isDroppable:f,innerRef:y}=this.props,l=(0,n.default)(w,s),g={height:this.containerHeight(),...a};return e.createElement("div",{ref:y,className:l,style:g,onDrop:f?this.onDrop:r.noop,onDragLeave:f?this.onDragLeave:r.noop,onDragEnter:f?this.onDragEnter:r.noop,onDragOver:f?this.onDragOver:r.noop},e.Children.map(this.props.children,u=>this.processGridItem(u)),f&&this.state.droppingDOMNode&&this.processGridItem(this.state.droppingDOMNode,!0),this.placeholder())}};return ke.default=R,v(R,"displayName","ReactGridLayout"),v(R,"propTypes",d.default),v(R,"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:r.noop,onDragStart:r.noop,onDrag:r.noop,onDragStop:r.noop,onResizeStart:r.noop,onResize:r.noop,onResizeStop:r.noop,onDrop:r.noop,onDropDragOver:r.noop}),ke}var Ye={},Oe={},qn;function cr(){if(qn)return Oe;qn=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.findOrGenerateResponsiveLayout=r,Oe.getBreakpointFromWidth=t,Oe.getColsFromBreakpoint=n,Oe.sortBreakpoints=i;var e=ze();function t(o,d){const b=i(o);let h=b[0];for(let S=1,v=b.length;S<v;S++){const C=b[S];d>o[C]&&(h=C)}return h}function n(o,d){if(!d[o])throw new Error("ResponsiveReactGridLayout: `cols` entry for breakpoint "+o+" is missing!");return d[o]}function r(o,d,b,h,S,v){if(o[b])return(0,e.cloneLayout)(o[b]);let C=o[h];const I=i(d),w=I.slice(I.indexOf(b));for(let x=0,R=w.length;x<R;x++){const p=w[x];if(o[p]){C=o[p];break}}return C=(0,e.cloneLayout)(C||[]),(0,e.compact)((0,e.correctBounds)(C,{cols:S}),v,S)}function i(o){return Object.keys(o).sort(function(b,h){return o[b]-o[h]})}return Oe}var An;function ii(){if(An)return Ye;An=1,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.default=void 0;var e=h(j),t=d(we()),n=on(),r=ze(),i=cr(),o=d(ur());function d(p){return p&&p.__esModule?p:{default:p}}function b(p){if(typeof WeakMap!="function")return null;var s=new WeakMap,a=new WeakMap;return(b=function(f){return f?a:s})(p)}function h(p,s){if(p&&p.__esModule)return p;if(p===null||typeof p!="object"&&typeof p!="function")return{default:p};var a=b(s);if(a&&a.has(p))return a.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 g=y?Object.getOwnPropertyDescriptor(p,l):null;g&&(g.get||g.set)?Object.defineProperty(f,l,g):f[l]=p[l]}return f.default=p,a&&a.set(p,f),f}function S(){return S=Object.assign?Object.assign.bind():function(p){for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var f in a)Object.prototype.hasOwnProperty.call(a,f)&&(p[f]=a[f])}return p},S.apply(this,arguments)}function v(p,s,a){return s=C(s),s in p?Object.defineProperty(p,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):p[s]=a,p}function C(p){var s=I(p,"string");return typeof s=="symbol"?s:String(s)}function I(p,s){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var f=a.call(p,s);if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(p)}const w=p=>Object.prototype.toString.call(p);function x(p,s){return p==null?null:Array.isArray(p)?p:p[s]}let R=class extends e.Component{constructor(){super(...arguments),v(this,"state",this.generateInitialState()),v(this,"onLayoutChange",s=>{this.props.onLayoutChange(s,{...this.props.layouts,[this.state.breakpoint]:s})})}generateInitialState(){const{width:s,breakpoints:a,layouts:f,cols:y}=this.props,l=(0,i.getBreakpointFromWidth)(a,s),g=(0,i.getColsFromBreakpoint)(l,y),u=this.props.verticalCompact===!1?null:this.props.compactType;return{layout:(0,i.findOrGenerateResponsiveLayout)(f,a,l,l,g,u),breakpoint:l,cols:g}}static getDerivedStateFromProps(s,a){if(!(0,n.deepEqual)(s.layouts,a.layouts)){const{breakpoint:f,cols:y}=a;return{layout:(0,i.findOrGenerateResponsiveLayout)(s.layouts,s.breakpoints,f,f,y,s.compactType),layouts:s.layouts}}return null}componentDidUpdate(s){(this.props.width!=s.width||this.props.breakpoint!==s.breakpoint||!(0,n.deepEqual)(this.props.breakpoints,s.breakpoints)||!(0,n.deepEqual)(this.props.cols,s.cols))&&this.onWidthChange(s)}onWidthChange(s){const{breakpoints:a,cols:f,layouts:y,compactType:l}=this.props,g=this.props.breakpoint||(0,i.getBreakpointFromWidth)(this.props.breakpoints,this.props.width),u=this.state.breakpoint,m=(0,i.getColsFromBreakpoint)(g,f),F={...y};if(u!==g||s.breakpoints!==a||s.cols!==f){u in F||(F[u]=(0,r.cloneLayout)(this.state.layout));let U=(0,i.findOrGenerateResponsiveLayout)(F,a,g,u,m,l);U=(0,r.synchronizeLayoutWithChildren)(U,this.props.children,m,l,this.props.allowOverlap),F[g]=U,this.props.onBreakpointChange(g,m),this.props.onLayoutChange(U,F),this.setState({breakpoint:g,layout:U,cols:m})}const P=x(this.props.margin,g),L=x(this.props.containerPadding,g);this.props.onWidthChange(this.props.width,P,m,L)}render(){const{breakpoint:s,breakpoints:a,cols:f,layouts:y,margin:l,containerPadding:g,onBreakpointChange:u,onLayoutChange:m,onWidthChange:F,...P}=this.props;return e.createElement(o.default,S({},P,{margin:x(l,this.state.breakpoint),containerPadding:x(g,this.state.breakpoint),onLayoutChange:this.onLayoutChange,layout:this.state.layout,cols:this.state.cols}))}};return Ye.default=R,v(R,"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,s){if(w(p[s])!=="[object Object]")throw new Error("Layout property must be an object. Received: "+w(p[s]));Object.keys(p[s]).forEach(a=>{if(!(a in p.breakpoints))throw new Error("Each key in layouts must align with a key in breakpoints.");(0,r.validateLayout)(p.layouts[a],"layouts."+a)})},width:t.default.number.isRequired,onBreakpointChange:t.default.func,onLayoutChange:t.default.func,onWidthChange:t.default.func}),v(R,"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:r.noop,onLayoutChange:r.noop,onWidthChange:r.noop}),Ye}var yt={},dr=function(){if(typeof Map<"u")return Map;function e(t,n){var r=-1;return t.some(function(i,o){return i[0]===n?(r=o,!0):!1}),r}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(n){var r=e(this.__entries__,n),i=this.__entries__[r];return i&&i[1]},t.prototype.set=function(n,r){var i=e(this.__entries__,n);~i?this.__entries__[i][1]=r:this.__entries__.push([n,r])},t.prototype.delete=function(n){var r=this.__entries__,i=e(r,n);~i&&r.splice(i,1)},t.prototype.has=function(n){return!!~e(this.__entries__,n)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(n,r){r===void 0&&(r=null);for(var i=0,o=this.__entries__;i<o.length;i++){var d=o[i];n.call(r,d[1],d[0])}},t}()}(),$t=typeof window<"u"&&typeof document<"u"&&window.document===document,Rt=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")()}(),oi=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(Rt):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}}(),si=2;function ai(e,t){var n=!1,r=!1,i=0;function o(){n&&(n=!1,e()),r&&b()}function d(){oi(o)}function b(){var h=Date.now();if(n){if(h-i<si)return;r=!0}else n=!0,r=!1,setTimeout(d,t);i=h}return b}var li=20,ui=["top","right","bottom","left","width","height","size","weight"],ci=typeof MutationObserver<"u",di=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=ai(this.refresh.bind(this),li)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var n=this.observers_,r=n.indexOf(t);~r&&n.splice(r,1),!n.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(n){return n.gatherActive(),n.hasActive()});return t.forEach(function(n){return n.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!$t||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),ci?(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(){!$t||!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 n=t.propertyName,r=n===void 0?"":n,i=ui.some(function(o){return!!~r.indexOf(o)});i&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),fr=function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];Object.defineProperty(e,i,{value:t[i],enumerable:!1,writable:!1,configurable:!0})}return e},je=function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||Rt},pr=Pt(0,0,0,0);function xt(e){return parseFloat(e)||0}function Hn(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(r,i){var o=e["border-"+i+"-width"];return r+xt(o)},0)}function fi(e){for(var t=["top","right","bottom","left"],n={},r=0,i=t;r<i.length;r++){var o=i[r],d=e["padding-"+o];n[o]=xt(d)}return n}function pi(e){var t=e.getBBox();return Pt(0,0,t.width,t.height)}function hi(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return pr;var r=je(e).getComputedStyle(e),i=fi(r),o=i.left+i.right,d=i.top+i.bottom,b=xt(r.width),h=xt(r.height);if(r.boxSizing==="border-box"&&(Math.round(b+o)!==t&&(b-=Hn(r,"left","right")+o),Math.round(h+d)!==n&&(h-=Hn(r,"top","bottom")+d)),!mi(e)){var S=Math.round(b+o)-t,v=Math.round(h+d)-n;Math.abs(S)!==1&&(b-=S),Math.abs(v)!==1&&(h-=v)}return Pt(i.left,i.top,b,h)}var gi=function(){return typeof SVGGraphicsElement<"u"?function(e){return e instanceof je(e).SVGGraphicsElement}:function(e){return e instanceof je(e).SVGElement&&typeof e.getBBox=="function"}}();function mi(e){return e===je(e).document.documentElement}function vi(e){return $t?gi(e)?pi(e):hi(e):pr}function yi(e){var t=e.x,n=e.y,r=e.width,i=e.height,o=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,d=Object.create(o.prototype);return fr(d,{x:t,y:n,width:r,height:i,top:n,right:t+r,bottom:i+n,left:t}),d}function Pt(e,t,n,r){return{x:e,y:t,width:n,height:r}}var Ci=function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=Pt(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=vi(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}(),bi=function(){function e(t,n){var r=yi(n);fr(this,{target:t,contentRect:r})}return e}(),Si=function(){function e(t,n,r){if(this.activeObservations_=[],this.observations_=new dr,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=n,this.callbackCtx_=r}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 je(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)||(n.set(t,new Ci(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 je(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)&&(n.delete(t),n.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(n){n.isActive()&&t.activeObservations_.push(n)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,n=this.activeObservations_.map(function(r){return new bi(r.target,r.broadcastRect())});this.callback_.call(t,n,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),hr=typeof WeakMap<"u"?new WeakMap:new dr,gr=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 n=di.getInstance(),r=new Si(t,n,this);hr.set(this,r)}return e}();["observe","unobserve","disconnect"].forEach(function(e){gr.prototype[e]=function(){var t;return(t=hr.get(this))[e].apply(t,arguments)}});var Ri=function(){return typeof Rt.ResizeObserver<"u"?Rt.ResizeObserver:gr}();const xi=Object.freeze(Object.defineProperty({__proto__:null,default:Ri},Symbol.toStringTag,{value:"Module"})),Ti=nr(xi);var Wn;function wi(){if(Wn)return yt;Wn=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.default=I;var e=d(j),t=i(we()),n=i(Ti),r=i(sn());function i(w){return w&&w.__esModule?w:{default:w}}function o(w){if(typeof WeakMap!="function")return null;var x=new WeakMap,R=new WeakMap;return(o=function(p){return p?R:x})(w)}function d(w,x){if(w&&w.__esModule)return w;if(w===null||typeof w!="object"&&typeof w!="function")return{default:w};var R=o(x);if(R&&R.has(w))return R.get(w);var p={__proto__:null},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in w)if(a!=="default"&&Object.prototype.hasOwnProperty.call(w,a)){var f=s?Object.getOwnPropertyDescriptor(w,a):null;f&&(f.get||f.set)?Object.defineProperty(p,a,f):p[a]=w[a]}return p.default=w,R&&R.set(w,p),p}function b(){return b=Object.assign?Object.assign.bind():function(w){for(var x=1;x<arguments.length;x++){var R=arguments[x];for(var p in R)Object.prototype.hasOwnProperty.call(R,p)&&(w[p]=R[p])}return w},b.apply(this,arguments)}function h(w,x,R){return x=S(x),x in w?Object.defineProperty(w,x,{value:R,enumerable:!0,configurable:!0,writable:!0}):w[x]=R,w}function S(w){var x=v(w,"string");return typeof x=="symbol"?x:String(x)}function v(w,x){if(typeof w!="object"||w===null)return w;var R=w[Symbol.toPrimitive];if(R!==void 0){var p=R.call(w,x);if(typeof p!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return(x==="string"?String:Number)(w)}const C="react-grid-layout";function I(w){var x;return x=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 n.default(s=>{if(this.elementRef.current instanceof HTMLElement){const f=s[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,...s}=this.props;return p&&!this.mounted?e.createElement("div",{className:(0,r.default)(this.props.className,C),style:this.props.style,ref:this.elementRef}):e.createElement(w,b({innerRef:this.elementRef},s,this.state))}},h(x,"defaultProps",{measureBeforeMount:!1}),h(x,"propTypes",{measureBeforeMount:t.default.bool}),x}return yt}var Bn;function _i(){return Bn||(Bn=1,function(e){e.exports=ur().default,e.exports.utils=ze(),e.exports.calculateUtils=an(),e.exports.Responsive=ii().default,e.exports.Responsive.utils=cr(),e.exports.WidthProvider=wi().default}(jt)),jt.exports}var Ii=_i();const Ei=Wr(Ii);var Oi=Object.getOwnPropertyDescriptor,Di=(e,t,n,r)=>{for(var i=r>1?void 0:r?Oi(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Fi=(e,t)=>(n,r)=>t(n,r,e);let Le=class extends T.Disposable{constructor(t){super();Re(this,"_initLocal",()=>{});Re(this,"_findReplaceIndex",t=>{const n=/\{([^}]+)?\}/g,r=[];let i=n.exec(t);for(;i;)r.push({startIndex:i.index,key:Number(i[1]),endIndex:i.index+i[0].length-1}),i=n.exec(t);return r});this._localeService=t,this._initLocal()}tWithReactNode(t,...n){const r=this._localeService.getLocales(),i=t.split("."),o=r&&this._localeService.resolveKeyPath(r,i);if(typeof o=="string"){const d=[];return this._findReplaceIndex(o).forEach((b,h,S)=>{const v=S[h-1]||{endIndex:-1};if(v.endIndex+1<b.startIndex){const C=o.slice(v.endIndex+1,b.startIndex);C&&d.push(C)}if(n[b.key]&&d.push(n[b.key]),h===S.length-1){const C=o.slice(b.endIndex+1);C&&d.push(C)}}),d}return[]}};Le=Di([Fi(0,T.Inject(T.LocaleService))],Le);const Pi=(e,t)=>{const n=e.rule;switch(n.type){case c.CFRuleType.colorScale:return t.t("sheet.cf.ruleType.colorScale");case c.CFRuleType.dataBar:return t.t("sheet.cf.ruleType.dataBar");case c.CFRuleType.iconSet:return t.t("sheet.cf.ruleType.iconSet");case c.CFRuleType.highlightCell:switch(n.subType){case c.CFSubRuleType.average:{const r=n.operator;return t.t(`sheet.cf.preview.describe.${r}`,t.t("sheet.cf.subRuleType.average"))}case c.CFSubRuleType.duplicateValues:return t.t("sheet.cf.subRuleType.duplicateValues");case c.CFSubRuleType.uniqueValues:return t.t("sheet.cf.subRuleType.uniqueValues");case c.CFSubRuleType.number:{const r=n.operator;return t.t(`sheet.cf.preview.describe.${r}`,...Array.isArray(n.value)?n.value.map(i=>String(i)):[String(n.value||"")])}case c.CFSubRuleType.text:{const r=n.operator;return t.t(`sheet.cf.preview.describe.${r}`,n.value||"")}case c.CFSubRuleType.timePeriod:{const r=n.operator;return t.t(`sheet.cf.preview.describe.${r}`)}case c.CFSubRuleType.rank:return n.isPercent?n.isBottom?t.t("sheet.cf.preview.describe.bottomNPercent",String(n.value)):t.t("sheet.cf.preview.describe.topNPercent",String(n.value)):n.isBottom?t.t("sheet.cf.preview.describe.bottomN",String(n.value)):t.t("sheet.cf.preview.describe.topN",String(n.value));case c.CFSubRuleType.formula:return t.t("sheet.cf.ruleType.formula")}}};let $n=0;const Mi=e=>{const{onClick:t}=e,n=J.useDependency(c.ConditionalFormattingRuleModel),r=J.useDependency(T.IUniverInstanceService),i=J.useDependency($.SheetsSelectionsService),o=J.useDependency(T.ICommandService),d=J.useDependency(T.LocaleService),b=J.useDependency(T.Injector),h=J.useDependency(J.ISidebarService),S=J.useDependency(Le),v=J.useObservable(()=>r.getCurrentTypeOfUnit$(T.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),C=v.getUnitId(),I=v.getActiveSheet();if(!I)throw new Error("No active sheet found");const w=I.getSheetId(),[x,R]=j.useState([]),[p,s]=j.useState("2"),[a,f]=j.useState(0),[y,l]=j.useState(-1),[g,u]=j.useState($n),m=j.useRef(null),F=[{label:d.t("sheet.cf.panel.workSheet"),value:"2"},{label:d.t("sheet.cf.panel.selectedRange"),value:"1"}],P=()=>{const z=n.getSubunitRules(C,w);if(!z||!z.length)return[];if(p==="1"){const Z=i.getCurrentLastSelection();if(!Z)return[];const ee=Z.range;return z.filter(ue=>ue.ranges.some(fe=>T.Rectangle.intersects(fe,ee)))}else if(p==="2")return[...z];return[]},[L,U]=j.useState(P);ce.useHighlightRange(x),j.useEffect(()=>{const z=o.onCommandExecuted(Z=>{Z.id===$.SetWorksheetActiveOperation.id&&f(Math.random())});return()=>z.dispose()}),j.useEffect(()=>{U(P)},[p,a,C,w]),j.useEffect(()=>{if(p==="2")return;const z=new ye.Observable(Z=>{const ee=[$.SetSelectionsOperation.id,c.AddConditionalRuleMutation.id,c.SetConditionalRuleMutation.id,c.DeleteConditionalRuleMutation.id,c.MoveConditionalRuleMutation.id],oe=o.onCommandExecuted(ue=>{const{id:fe,params:ve}=ue,q=r.getCurrentUnitOfType(T.UniverInstanceType.UNIVER_SHEET).getUnitId();ee.includes(fe)&&ve.unitId===q&&Z.next(null)});return()=>oe.dispose()}).pipe(ye.debounceTime(16)).subscribe(()=>{U(P)});return()=>{z.unsubscribe()}},[r,p,C,w]),j.useEffect(()=>{const z=n.$ruleChange.subscribe(()=>{f(Math.random())});return()=>z.unsubscribe()},[n]),j.useEffect(()=>{const z=()=>{var ue,fe;const oe=Math.max(0,((fe=(ue=m.current)==null?void 0:ue.getBoundingClientRect().width)!=null?fe:0)-8);return $n=oe,oe},ee=new ye.Observable(oe=>{const ue=h.getContainer();if(ue){let fe=setTimeout(()=>{oe.next()},150);const ve=()=>{fe&&clearTimeout(fe),fe=null},q=Y=>{Y.propertyName==="width"&&(ve(),oe.next())};return ue.addEventListener("transitionend",q),()=>{ve(),ue.removeEventListener("transitionend",q)}}}).pipe(ye.debounceTime(16)).subscribe(()=>{u(z())});return()=>{ee.unsubscribe()}},[]);const E=z=>{var oe;const Z=r.getCurrentUnitOfType(T.UniverInstanceType.UNIVER_SHEET).getUnitId(),ee=(oe=r.getCurrentUnitOfType(T.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:oe.getSheetId();if(!Z||!ee)throw new Error("No active sheet found");o.executeCommand(c.DeleteCfCommand.id,{unitId:Z,subUnitId:ee,cfId:z.cfId})},N=(z,Z)=>{l(Z.y)},A=(z,Z,ee)=>{var Y;l(-1);const oe=r.getCurrentUnitOfType(T.UniverInstanceType.UNIVER_SHEET).getUnitId(),ue=(Y=r.getCurrentUnitOfType(T.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:Y.getSheetId();if(!oe||!ue)throw new Error("No active sheet found");const fe=ie=>{const O=L.length;return Math.min(O-1,Math.max(0,ie))},ve=L[fe(Z.y)].cfId,q=L[fe(ee.y)].cfId;ve!==q&&o.executeCommand(c.MoveCfCommand.id,{unitId:oe,subUnitId:ue,start:{id:ve,type:"self"},end:{id:q,type:ee.y>Z.y?"after":"before"}})},W=()=>{e.onCreate()},G=()=>{p==="2"?o.executeCommand(c.ClearWorksheetCfCommand.id):p==="1"&&L.map(Z=>({unitId:C,subUnitId:w,cfId:Z.cfId})).forEach(Z=>{o.executeCommand(c.DeleteCfCommand.id,Z)})},re=j.useMemo(()=>{const z=r.getCurrentUnitOfType(T.UniverInstanceType.UNIVER_SHEET),Z=z.getActiveSheet();return L.filter(ee=>{const oe=ee.ranges;return $.checkRangesEditablePermission(b,z.getUnitId(),Z.getSheetId(),oe)})},[L]),te=re.map((z,Z)=>({i:z.cfId,x:0,w:12,y:Z,h:1,isResizable:!1})),se=j.useMemo(()=>{const z=r.getCurrentUnitOfType(T.UniverInstanceType.UNIVER_SHEET),Z=z.getActiveSheet();return L.every(ee=>{const oe=ee.ranges;return $.checkRangesEditablePermission(b,z.getUnitId(),Z.getSheetId(),oe)})},[L]);return _.jsxs("div",{children:[_.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[_.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:S.tWithReactNode("sheet.cf.panel.managerRuleSelect",_.jsx(K.Select,{className:"univer-w-36",options:F,value:p,onChange:z=>{s(z)}})).map((z,Z)=>_.jsx("span",{children:z},Z))}),_.jsxs("div",{className:"univer-flex univer-justify-end",children:[_.jsx(K.Tooltip,{title:d.t("sheet.cf.panel.createRule"),placement:"bottom",children:_.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:W,children:_.jsx(Qn,{})})}),L.length&&se?_.jsx(K.Tooltip,{title:d.t("sheet.cf.panel.clear"),placement:"bottom",children:_.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:G,children:_.jsx(St,{className:"univer-text-red-500"})})}):_.jsx("div",{children:_.jsx(St,{className:"univer-text-gray-300"})})]})]}),_.jsx("div",{ref:m,children:g>0&&_.jsx(Ei,{className:`
56
+ `),children:[p,l.jsx(Le,{})]})})}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[l.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[l.jsx(U.Checkbox,{onChange:_}),r.t("sheet.cf.iconSet.reverseIconOrder")]}),l.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[l.jsx(U.Checkbox,{checked:!d,onChange:g=>{h(!g)}}),r.t("sheet.cf.iconSet.onlyShowIcon")]})]}),l.jsx(Bt,{errorMap:s,onChange:x,configList:c})]})},Wt=n=>{var _;const{onChange:e,interceptorManager:i}=n,r=k.useDependency(a.LocaleService),s=((_=n.rule)==null?void 0:_.type)===t.CFRuleType.highlightCell?n.rule:void 0,o=[{label:r.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:r.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:r.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:r.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[u,v]=C.useState(()=>{const F=o[0].value,j=s==null?void 0:s.type;if(!s)return F;switch(j){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.average:return[t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual].includes(s.operator)?"greaterThanAverage":[t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(s.operator)?"lessThanAverage":F;case t.CFSubRuleType.rank:return s.isBottom?"isBottom":"isNotBottom"}}return F}),[c,m]=C.useState(()=>{const j=s==null?void 0:s.type;if(!s)return 10;switch(j){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.rank:return s.value||10}}return 10}),[d,h]=C.useState(()=>{const j=s==null?void 0:s.type;if(!s)return!1;switch(j){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.rank:return s.isPercent||!1}}return!1}),[p,y]=C.useState({}),x=F=>{const{type:j,isPercent:N,value:E,style:g}=F;if(j==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:N,isBottom:!1,value:E,style:g};if(j==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:N,isBottom:!0,value:E,style:g};if(j==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:g};if(j==="lessThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.lessThan,style:g}};C.useEffect(()=>i.intercept(i.getInterceptPoints().submit,{handler(){return x({type:u,isPercent:d,value:c,style:p})}}),[u,d,c,p,i]);const S=F=>{e(x(F))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),l.jsx(U.Select,{className:"univer-mt-3 univer-w-full",value:u,options:o,onChange:F=>{v(F),S({type:F,isPercent:d,value:c,style:p})}}),["isNotBottom","isBottom"].includes(u)&&l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(U.InputNumber,{min:1,max:1e3,value:c,onChange:F=>{const j=F||0;m(j),S({type:u,isPercent:d,value:j,style:p})}}),l.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[l.jsx(U.Checkbox,{checked:d,onChange:F=>{h(!!F),S({type:u,isPercent:!!F,value:c,style:p})}}),r.t("sheet.cf.valueType.percent")]})]}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:x({type:u,isPercent:d,value:c,style:p})})}),l.jsx(nt,{style:s==null?void 0:s.style,className:"univer-mt-3",onChange:F=>{y(F),S({type:u,isPercent:d,value:c,style:F})}})]})},qt=a.createInterceptorKey("beforeSubmit"),Gt=a.createInterceptorKey("submit"),at=n=>n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),lt=n=>{var e;return(e=n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},zt=n=>{var T,I,w;const e=k.useDependency(a.LocaleService),i=k.useDependency(a.ICommandService),r=k.useDependency(a.IUniverInstanceService),s=k.useDependency(t.ConditionalFormattingRuleModel),o=k.useDependency(O.SheetsSelectionsService),u=at(r),v=lt(r),[c,m]=C.useState(void 0),d=C.useRef((I=(T=n.rule)==null?void 0:T.ranges)!=null?I:[]),h=C.useMemo(()=>{var V,P,f;let M=(V=n.rule)==null?void 0:V.ranges;return M!=null&&M.length||(M=(f=(P=o.getCurrentSelections())==null?void 0:P.map(R=>R.range))!=null?f:[]),d.current=M,M!=null&&M.length?M.map(R=>{const A=Ge.serializeRange(R);return A==="NaN"?"":A}).filter(R=>!!R).join(","):""},[n.rule]),p=[{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"}],[y,x]=C.useState(()=>{var P,f;const M=(P=n.rule)==null?void 0:P.rule.type,V=p[0].value;if(!M)return V;switch(M){case t.CFRuleType.highlightCell:{switch((f=n.rule)==null?void 0:f.rule.subType){case t.CFSubRuleType.number:case t.CFSubRuleType.text:case t.CFSubRuleType.duplicateValues:case t.CFSubRuleType.uniqueValues:case t.CFSubRuleType.timePeriod:return"1";case t.CFSubRuleType.average:case t.CFSubRuleType.rank:return"2";case t.CFSubRuleType.formula:return"5"}break}case t.CFRuleType.dataBar:return"3";case t.CFRuleType.colorScale:return"4";case t.CFRuleType.iconSet:return"6"}return V}),S=C.useRef(void 0),_=C.useMemo(()=>new a.InterceptorManager({beforeSubmit:qt,submit:Gt}),[]),F=C.useMemo(()=>{switch(y){case"1":return st;case"2":return Wt;case"3":return kt;case"4":return Ut;case"5":return Pt;case"6":return Ht;default:return st}},[y]);C.useEffect(()=>{const M=i.onCommandExecuted(V=>{if(V.id===O.RemoveSheetMutation.id){const P=V.params;P.subUnitId===v&&P.unitId===u&&n.onCancel()}V.id===O.SetWorksheetActiveOperation.id&&n.onCancel()});return()=>M.dispose()},[]);const j=M=>{S.current=M},N=M=>{const V=M.split(",").filter(P=>!!P).map(Ge.deserializeRangeWithSheet).map(P=>P.range);d.current=V},E=()=>{if(c)return;const V=(()=>{const f=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!f)throw new Error("No active sheet found");return d.current.map(q=>O.setEndForRange(q,f.getRowCount(),f.getColumnCount())).filter(q=>!(Number.isNaN(q.startRow)||Number.isNaN(q.startColumn)))})();if(_.fetchThroughInterceptors(_.getInterceptPoints().beforeSubmit)(!0,null)){const f=_.fetchThroughInterceptors(_.getInterceptPoints().submit)(null,null);if(f){const R=at(r),A=lt(r);if(!R||!A)throw new Error("No active sheet found");let q={};n.rule&&n.rule.cfId?(q={...n.rule,ranges:V,rule:f},i.executeCommand(t.SetCfCommand.id,{unitId:R,subUnitId:A,rule:q}),n.onCancel()):(q={cfId:s.createCfId(R,A),ranges:V,rule:f,stopIfTrue:!1},i.executeCommand(t.AddCfCommand.id,{unitId:R,subUnitId:A,rule:q}),n.onCancel())}}},g=()=>{n.onCancel()},b=(M,V)=>{M?V.length<1?m(e.t("sheet.cf.errorMessage.rangeError")):m(void 0):m(e.t("sheet.cf.errorMessage.rangeError"))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:e.t("sheet.cf.panel.range")}),l.jsxs("div",{className:"univer-mt-4",children:[l.jsx(Te.RangeSelector,{unitId:u,subUnitId:v,initialValue:h,onChange:(M,V)=>N(V),onVerify:b}),c&&l.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:c})]}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:e.t("sheet.cf.panel.styleType")}),l.jsx(U.Select,{className:"univer-mt-4 univer-w-full",value:y,options:p,onChange:M=>x(M)}),l.jsx(F,{interceptorManager:_,rule:(w=n.rule)==null?void 0:w.rule,onChange:j}),l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[l.jsx(U.Button,{onClick:g,children:e.t("sheet.cf.panel.cancel")}),l.jsx(U.Button,{className:"univer-ml-3",variant:"primary",onClick:E,children:e.t("sheet.cf.panel.submit")})]})]})};var Yt=Object.getOwnPropertyDescriptor,Zt=(n,e,i,r)=>{for(var s=r>1?void 0:r?Yt(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},Kt=(n,e)=>(i,r)=>e(i,r,n);let ue=class extends a.Disposable{constructor(e){super();Q(this,"_initLocal",()=>{});Q(this,"_findReplaceIndex",e=>{const i=/\{([^}]+)?\}/g,r=[];let s=i.exec(e);for(;s;)r.push({startIndex:s.index,key:Number(s[1]),endIndex:s.index+s[0].length-1}),s=i.exec(e);return r});this._localeService=e,this._initLocal()}tWithReactNode(e,...i){const r=this._localeService.getLocales(),s=e.split("."),o=r&&this._localeService.resolveKeyPath(r,s);if(typeof o=="string"){const u=[];return this._findReplaceIndex(o).forEach((v,c,m)=>{const d=m[c-1]||{endIndex:-1};if(d.endIndex+1<v.startIndex){const h=o.slice(d.endIndex+1,v.startIndex);h&&u.push(h)}if(i[v.key]&&u.push(i[v.key]),c===m.length-1){const h=o.slice(v.endIndex+1);h&&u.push(h)}}),u}return[]}};ue=Zt([Kt(0,a.Inject(a.LocaleService))],ue);const Xt=(n,e)=>{const i=n.rule;switch(i.type){case t.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case t.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case t.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case t.CFRuleType.highlightCell:switch(i.subType){case t.CFSubRuleType.average:{const r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`,e.t("sheet.cf.subRuleType.average"))}case t.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case t.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case t.CFSubRuleType.number:{const r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`,...Array.isArray(i.value)?i.value.map(s=>String(s)):[String(i.value||"")])}case t.CFSubRuleType.text:{const r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`,i.value||"")}case t.CFSubRuleType.timePeriod:{const r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`)}case t.CFSubRuleType.rank:return i.isPercent?i.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(i.value)):e.t("sheet.cf.preview.describe.topNPercent",String(i.value)):i.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(i.value)):e.t("sheet.cf.preview.describe.topN",String(i.value));case t.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let ut=0;const Jt=n=>{const{onClick:e}=n,i=k.useDependency(t.ConditionalFormattingRuleModel),r=k.useDependency(a.IUniverInstanceService),s=k.useDependency(O.SheetsSelectionsService),o=k.useDependency(a.ICommandService),u=k.useDependency(a.LocaleService),v=k.useDependency(a.Injector),c=k.useDependency(k.ISidebarService),m=k.useDependency(ue),d=k.useObservable(()=>r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),h=d.getUnitId(),p=d.getActiveSheet();if(!p)throw new Error("No active sheet found");const y=p.getSheetId(),[x,S]=C.useState([]),[_,F]=C.useState("2"),[j,N]=C.useState(0),[E,g]=C.useState(-1),[b,T]=C.useState(ut),I=C.useRef(null),w=[{label:u.t("sheet.cf.panel.workSheet"),value:"2"},{label:u.t("sheet.cf.panel.selectedRange"),value:"1"}],M=()=>{const D=i.getSubunitRules(h,y);if(!D||!D.length)return[];if(_==="1"){const L=s.getCurrentLastSelection();if(!L)return[];const B=L.range;return D.filter(G=>G.ranges.some(z=>a.Rectangle.intersects(z,B)))}else if(_==="2")return[...D];return[]},[V,P]=C.useState(M);H.useHighlightRange(x),C.useEffect(()=>{const D=o.onCommandExecuted(L=>{L.id===O.SetWorksheetActiveOperation.id&&N(Math.random())});return()=>D.dispose()}),C.useEffect(()=>{P(M)},[_,j,h,y]),C.useEffect(()=>{if(_==="2")return;const D=new K.Observable(L=>{const B=[O.SetSelectionsOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],W=o.onCommandExecuted(G=>{const{id:z,params:ee}=G,te=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId();B.includes(z)&&ee.unitId===te&&L.next(null)});return()=>W.dispose()}).pipe(K.debounceTime(16)).subscribe(()=>{P(M)});return()=>{D.unsubscribe()}},[r,_,h,y]),C.useEffect(()=>{const D=i.$ruleChange.subscribe(()=>{N(Math.random())});return()=>D.unsubscribe()},[i]),C.useEffect(()=>{const D=()=>{var G,z;const W=Math.max(0,((z=(G=I.current)==null?void 0:G.getBoundingClientRect().width)!=null?z:0)-8);return ut=W,W},B=new K.Observable(W=>{const G=c.getContainer();if(G){let z=setTimeout(()=>{W.next()},150);const ee=()=>{z&&clearTimeout(z),z=null},te=_e=>{_e.propertyName==="width"&&(ee(),W.next())};return G.addEventListener("transitionend",te),()=>{ee(),G.removeEventListener("transitionend",te)}}}).pipe(K.debounceTime(16)).subscribe(()=>{T(D())});return()=>{B.unsubscribe()}},[]);const f=D=>{var W;const L=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),B=(W=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:W.getSheetId();if(!L||!B)throw new Error("No active sheet found");o.executeCommand(t.DeleteCfCommand.id,{unitId:L,subUnitId:B,cfId:D.cfId})},R=(D,L)=>{g(L.y)},A=(D,L,B)=>{var _e;g(-1);const W=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),G=(_e=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:_e.getSheetId();if(!W||!G)throw new Error("No active sheet found");const z=It=>{const Tt=V.length;return Math.min(Tt-1,Math.max(0,It))},ee=V[z(L.y)].cfId,te=V[z(B.y)].cfId;ee!==te&&o.executeCommand(t.MoveCfCommand.id,{unitId:W,subUnitId:G,start:{id:ee,type:"self"},end:{id:te,type:B.y>L.y?"after":"before"}})},q=()=>{n.onCreate()},X=()=>{_==="2"?o.executeCommand(t.ClearWorksheetCfCommand.id):_==="1"&&V.map(L=>({unitId:h,subUnitId:y,cfId:L.cfId})).forEach(L=>{o.executeCommand(t.DeleteCfCommand.id,L)})},J=C.useMemo(()=>{const D=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),L=D.getActiveSheet();return V.filter(B=>{const W=B.ranges;return O.checkRangesEditablePermission(v,D.getUnitId(),L.getSheetId(),W)})},[V]),ie=J.map((D,L)=>({i:D.cfId,x:0,w:12,y:L,h:1,isResizable:!1})),se=C.useMemo(()=>{const D=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),L=D.getActiveSheet();return V.every(B=>{const W=B.ranges;return O.checkRangesEditablePermission(v,D.getUnitId(),L.getSheetId(),W)})},[V]);return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:m.tWithReactNode("sheet.cf.panel.managerRuleSelect",l.jsx(U.Select,{className:"univer-w-36",options:w,value:_,onChange:D=>{F(D)}})).map((D,L)=>l.jsx("span",{children:D},L))}),l.jsxs("div",{className:"univer-flex univer-justify-end",children:[l.jsx(U.Tooltip,{title:u.t("sheet.cf.panel.createRule"),placement:"bottom",children:l.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:q,children:l.jsx(gt,{})})}),V.length&&se?l.jsx(U.Tooltip,{title:u.t("sheet.cf.panel.clear"),placement:"bottom",children:l.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:X,children:l.jsx(Ve,{className:"univer-text-red-500"})})}):l.jsx("div",{children:l.jsx(Ve,{className:"univer-text-gray-300"})})]})]}),l.jsx("div",{ref:I,children:b>0&&l.jsx(U.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:te,cols:12,rowHeight:60,width:g,margin:[0,10],onDragStop:A,onDragStart:N,children:re==null?void 0:re.map((z,Z)=>_.jsx("div",{children:_.jsxs("div",{className:K.clsx(`
59
+ `,draggableHandle:".draggableHandle",layout:ie,cols:12,rowHeight:60,width:b,margin:[0,10],onDragStop:A,onDragStart:R,children:J==null?void 0:J.map((D,L)=>l.jsx("div",{children:l.jsxs("div",{className:U.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===Z}),onMouseMove:()=>{z.ranges!==x&&R(z.ranges)},onMouseLeave:()=>R([]),onClick:()=>{t(z)},children:[_.jsx("div",{className:K.clsx(`
63
+ `,{"univer-bg-gray-100":E===L}),onMouseMove:()=>{D.ranges!==x&&S(D.ranges)},onMouseLeave:()=>S([]),onClick:()=>{e(D)},children:[l.jsx("div",{className:U.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:ee=>ee.stopPropagation(),children:_.jsx(er,{})}),_.jsxs("div",{className:`
68
+ `,"draggableHandle"),onClick:B=>B.stopPropagation(),children:l.jsx(ft,{})}),l.jsxs("div",{className:`
47
69
  univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden
48
- `,children:[_.jsx("div",{className:"univer-text-sm univer-text-gray-900",children:Pi(z,d)}),_.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:z.ranges.map(ee=>Bt.serializeRange(ee)).join(",")})]}),_.jsx("div",{children:_.jsx(Ve,{rule:z.rule})}),_.jsx("div",{className:K.clsx(`
70
+ `,children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-900",children:Xt(D,u)}),l.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:D.ranges.map(B=>Ge.serializeRange(B)).join(",")})]}),l.jsx("div",{children:l.jsx(de,{rule:D.rule})}),l.jsx("div",{className:U.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===Z}),onClick:ee=>{ee.stopPropagation(),E(z),R([])},children:_.jsx(St,{})})]})},`${z.cfId}`))})})]})},Ni=e=>{const[t,n]=j.useState(e.rule),[r,i]=j.useState(!!e.rule),o=()=>{i(!0)},d=()=>{i(!1),n(void 0)},b=h=>{n(h),i(!0)};return _.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between",children:r?_.jsx(Hr,{onCancel:d,rule:t}):_.jsx(Mi,{onClick:b,onCreate:o})})};var ji=Object.getOwnPropertyDescriptor,Li=(e,t,n,r)=>{for(var i=r>1?void 0:r?ji(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Xe=(e,t)=>(n,r)=>t(n,r,e);const Ct="sheet.conditional.formatting.panel";let nt=class extends T.Disposable{constructor(t,n,r,i,o){super();Re(this,"_sidebarDisposable",null);this._univerInstanceService=t,this._injector=n,this._componentManager=r,this._sidebarService=i,this._localeService=o,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(T.UniverInstanceType.UNIVER_SHEET).subscribe(d=>{var b;d||(b=this._sidebarDisposable)==null||b.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(d=>{d.id===Ct&&(d.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(t){const n={id:Ct,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ct,rule:t,key:T.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this._componentManager.register(Ct,Ni)}};nt=Li([Xe(0,T.IUniverInstanceService),Xe(1,T.Inject(T.Injector)),Xe(2,T.Inject(J.ComponentManager)),Xe(3,T.Inject(J.ISidebarService)),Xe(4,T.Inject(T.LocaleService))],nt);var he=(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))(he||{});const ct={id:"sheet.operation.open.conditional.formatting.panel",type:T.CommandType.OPERATION,handler:(e,t)=>{var b;const n=e.get(nt),r=e.get($.SheetsSelectionsService),i=e.get(T.ICommandService),o=((b=r.getCurrentSelections())==null?void 0:b.map(h=>h.range))||[];switch(t.value){case 3:{n.openPanel({...c.createDefaultRule(),ranges:o});break}case 4:{const h={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.rank}};n.openPanel(h);break}case 5:{const h={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.formula,value:"="}};n.openPanel(h);break}case 6:{const h={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.colorScale,config:[]}};n.openPanel(h);break}case 7:{const h={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.dataBar,isShowValue:!0}};n.openPanel(h);break}case 8:{const h={...c.createDefaultRule,ranges:o,rule:{type:c.CFRuleType.iconSet,config:[],isShowValue:!0}};n.openPanel(h);break}case 2:{n.openPanel();break}case 1:{n.openPanel({...c.createDefaultRule(),ranges:o});break}case 9:{i.executeCommand(c.ClearRangeCfCommand.id,{ranges:o});break}case 10:{i.executeCommand(c.ClearWorksheetCfCommand.id);break}}return!0}};var Ui=Object.getOwnPropertyDescriptor,Vi=(e,t,n,r)=>{for(var i=r>1?void 0:r?Ui(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Ke=(e,t)=>(n,r)=>t(n,r,e);let rt=class extends T.Disposable{constructor(t,n,r,i,o){super();Re(this,"_copyInfo");this._sheetClipboardService=t,this._conditionalFormattingRuleModel=n,this._injector=r,this._conditionalFormattingViewModel=i,this._univerInstanceService=o,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:c.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(t,n,r)=>this._collectConditionalRule(t,n,r),onPasteCells:(t,n,r,i)=>{const{copyType:o=ce.COPY_TYPE.COPY,pasteType:d}=i,{range:b}=t||{},{range:h}=n;return this._generateConditionalFormattingMutations(h,{copyType:o,pasteType:d,copyRange:b})}}))}_collectConditionalRule(t,n,r){const i=new T.ObjectMatrix,o={};this._copyInfo={matrix:i,info:{unitId:t,subUnitId:n,cfMap:o}};const d=this._injector.invoke(v=>$.rangeToDiscreteRange(r,v,t,n));if(!d)return;const{rows:b,cols:h}=d,S=new Set;b.forEach((v,C)=>{h.forEach((I,w)=>{const x=this._conditionalFormattingViewModel.getCellCfs(t,n,v,I);x&&(x.forEach(R=>S.add(R.cfId)),i.setValue(C,w,x.map(R=>R.cfId)))})}),S.forEach(v=>{const C=this._conditionalFormattingRuleModel.getRule(t,n,v);C&&(o[v]=C.rule)})}_generateConditionalFormattingMutations(t,n){const r=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET),i=r.getActiveSheet(),o=r.getUnitId();if(!i)return{redos:[],undos:[]};const d=i.getSheetId();if(n.copyType===ce.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!n.copyRange)return{redos:[],undos:[]};if(![ce.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,ce.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,ce.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(n.pasteType))return{redos:[],undos:[]};const{ranges:[h,S],mapFunc:v}=ce.virtualizeDiscreteRanges([n.copyRange,t]),C=ce.getRepeatRange(h,S,!0),I={};T.Range.foreach(S,(l,g)=>{const{row:u,col:m}=v(l,g),F=this._conditionalFormattingViewModel.getCellCfs(o,d,u,m);F&&F.forEach(P=>{if(!I[P.cfId]){const L=new T.ObjectMatrix;I[P.cfId]=L;const U=this._conditionalFormattingRuleModel.getRule(o,d,P.cfId);U==null||U.ranges.forEach(E=>{T.Range.foreach(E,(N,A)=>{L.setValue(N,A,1)})})}I[P.cfId].realDeleteValue(u,m)})});const{matrix:w,info:x}=this._copyInfo,R=[];let p=this._conditionalFormattingRuleModel.createCfId(o,d);const s={},a=l=>{if(s[l])return s[l];const g=x==null?void 0:x.cfMap[l],u=[...this._conditionalFormattingRuleModel.getSubunitRules(o,d)||[],...R].find(m=>T.Tools.diffValue(m.rule,g));if(u)return s[l]=u,u;{const m={rule:g,cfId:p,ranges:[],stopIfTrue:!1};return s[l]=m,R.push(m),p=`${Number(p)+1}`,m}};C.forEach(l=>{w&&w.forValue((g,u,m)=>{const F=T.Rectangle.getPositionRange({startRow:g,endRow:g,startColumn:u,endColumn:u},l.startRange),{row:P,col:L}=v(F.startRow,F.startColumn);m.forEach(U=>{if(!I[U]){const E=a(U),N=new T.ObjectMatrix;I[U]=N,E.ranges.forEach(A=>{T.Range.foreach(A,(W,G)=>{N.setValue(W,G,1)})})}I[U].setValue(P,L,1)})})});const f=[],y=[];for(const l in I){const g=I[l],u=$.findAllRectangle($.createTopMatrixFromMatrix(g));if(!u.length){const m={unitId:o,subUnitId:d,cfId:l};f.push({id:c.DeleteConditionalRuleMutation.id,params:m}),y.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,m))}if(R.some(m=>m.cfId===l)){const m=a(l),F={unitId:o,subUnitId:d,rule:{...m,ranges:u}};f.push({id:c.AddConditionalRuleMutation.id,params:F}),y.push(c.AddConditionalRuleMutationUndoFactory(this._injector,F))}else{const m=this._conditionalFormattingRuleModel.getRule(o,d,l);if(!m)continue;const F={unitId:o,subUnitId:d,rule:{...m,ranges:u}};f.push({id:c.SetConditionalRuleMutation.id,params:F}),y.push(...c.setConditionalRuleMutationUndoFactory(this._injector,F))}}return{redos:f,undos:y}}};rt=Vi([Ke(0,T.Inject(ce.ISheetClipboardService)),Ke(1,T.Inject(c.ConditionalFormattingRuleModel)),Ke(2,T.Inject(T.Injector)),Ke(3,T.Inject(c.ConditionalFormattingViewModel)),Ke(4,T.Inject(T.IUniverInstanceService))],rt);var zi=Object.getOwnPropertyDescriptor,ki=(e,t,n,r)=>{for(var i=r>1?void 0:r?zi(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},qt=(e,t)=>(n,r)=>t(n,r,e);let it=class extends T.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===c.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]},e.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};it=ki([qt(0,T.Inject(T.LocaleService)),qt(1,T.ICommandService),qt(2,T.Inject($.SheetPermissionCheckController))],it);var qi=Object.getOwnPropertyDescriptor,Ai=(e,t,n,r)=>{for(var i=r>1?void 0:r?qi(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},bt=(e,t)=>(n,r)=>t(n,r,e);let ot=class extends T.Disposable{constructor(e,t,n,r){super(),this._conditionalFormattingRuleModel=e,this._univerInstanceService=t,this._injector=n,this._refRangeService=r,this._initRefRange()}_initRefRange(){const e=new Map,t=(r,i,o)=>`${r}_${i}_${o}`,n=(r,i,o)=>{const d=h=>{const S=[...o.ranges],v=S.map(I=>$.handleDefaultRangeChangeWithEffectRefCommands(I,h)).filter(I=>!!I);if(c.isRangesEqual(v,S))return{redos:[],undos:[]};if(v.length){const I={unitId:r,subUnitId:i,rule:{...o,ranges:v}},w=[{id:c.SetConditionalRuleMutation.id,params:I}],x=c.setConditionalRuleMutationUndoFactory(this._injector,I);return{redos:w,undos:x}}else{const I={unitId:r,subUnitId:i,cfId:o.cfId},w=[{id:c.DeleteConditionalRuleMutation.id,params:I}],x=c.DeleteConditionalRuleMutationUndoFactory(this._injector,I);return{redos:w,undos:x}}},b=[];o.ranges.forEach(h=>{const S=this._refRangeService.registerRefRange(h,d);b.push(()=>S.dispose())}),e.set(t(r,i,o.cfId),()=>b.forEach(h=>h()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(r=>{const{unitId:i,subUnitId:o,rule:d}=r,b=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET),h=b.getActiveSheet();if(!(r.unitId!==b.getUnitId()||r.subUnitId!==(h==null?void 0:h.getSheetId())))switch(r.type){case"add":{n(r.unitId,r.subUnitId,r.rule);break}case"delete":{const S=e.get(t(i,o,d.cfId));S&&S();break}case"set":{const S=e.get(t(i,o,d.cfId));S&&S(),n(r.unitId,r.subUnitId,r.rule)}}})),this.disposeWithMe(T.toDisposable(()=>{e.forEach(r=>{r()}),e.clear()}))}};ot=Ai([bt(0,T.Inject(c.ConditionalFormattingRuleModel)),bt(1,T.Inject(T.IUniverInstanceService)),bt(2,T.Inject(T.Injector)),bt(3,T.Inject($.RefRangeService))],ot);var Hi=Object.getOwnPropertyDescriptor,Wi=(e,t,n,r)=>{for(var i=r>1?void 0:r?Hi(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Me=(e,t)=>(n,r)=>t(n,r,e);let st=class extends T.Disposable{constructor(t,n,r,i,o,d){super();Re(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=t,this._conditionalFormattingService=n,this._univerInstanceService=r,this._renderManagerService=i,this._conditionalFormattingViewModel=o,this._conditionalFormattingRuleModel=d,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var n,r,i;const t=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getUnitId();(n=this._renderManagerService.getRenderById(t))==null||n.with(ce.SheetSkeletonManagerService).reCalculate(),(i=(r=this._renderManagerService.getRenderById(t))==null?void 0:r.mainComponent)==null||i.makeDirty()}_initSkeleton(){this.disposeWithMe(ye.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(tt.bufferTime(16),tt.filter(t=>!!t.length),tt.filter(t=>{const n=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();return r?t.filter(i=>i.unitId===n.getUnitId()&&i.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:T.InterceptorEffectEnum.Style,handler:(t,n,r)=>{const i=this._conditionalFormattingService.composeStyle(n.unitId,n.subUnitId,n.row,n.col);if(!i)return r(t);const o=n.workbook.getStyles(),b={...(typeof(t==null?void 0:t.s)=="string"?o.get(t==null?void 0:t.s):t==null?void 0:t.s)||{}},h={...t,s:b};return i.style&&Object.assign(b,i.style),h.fontRenderExtension||(h.fontRenderExtension={},i.isShowValue!==void 0&&(h.fontRenderExtension.isSkip=!i.isShowValue)),i.dataBar&&(h.dataBar=i.dataBar),i.iconSet&&(h.iconSet=i.iconSet,h.fontRenderExtension.leftOffset=c.DEFAULT_PADDING+c.DEFAULT_WIDTH),r(h)},priority:10}))}};st=Wi([Me(0,T.Inject($.SheetInterceptorService)),Me(1,T.Inject(c.ConditionalFormattingService)),Me(2,T.Inject(T.IUniverInstanceService)),Me(3,T.Inject(Zn.IRenderManagerService)),Me(4,T.Inject(c.ConditionalFormattingViewModel)),Me(5,T.Inject(c.ConditionalFormattingRuleModel))],st);const mr="sheets-conditional-formatting-ui.config",Tt={};var Bi=Object.defineProperty,$i=Object.getOwnPropertyDescriptor,Gi=(e,t,n)=>t in e?Bi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yi=(e,t,n,r)=>{for(var i=r>1?void 0:r?$i(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},At=(e,t)=>(n,r)=>t(n,r,e),vr=(e,t,n)=>Gi(e,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsConditionalFormattingMobileUIPlugin=class extends T.Plugin{constructor(t=Tt,n,r,i){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=i;const{menu:o,...d}=T.merge({},Tt,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(mr,d),this._initCommand(),this._injector.add([st]),this._injector.add([ot]),this._injector.add([rt]),this._injector.add([it]),this._injector.add([Le])}_initCommand(){[Yt,Xt,Kt,Zt,Jt,Qt,en,tn,nn,ct].forEach(t=>{this._commandService.registerCommand(t)})}};vr(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${c.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`);vr(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"type",T.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingMobileUIPlugin=Yi([T.DependentOn(c.UniverSheetsConditionalFormattingPlugin),At(1,T.Inject(T.Injector)),At(2,T.Inject(T.ICommandService)),At(3,T.IConfigService)],exports.UniverSheetsConditionalFormattingMobileUIPlugin);var Xi=Object.getOwnPropertyDescriptor,Ki=(e,t,n,r)=>{for(var i=r>1?void 0:r?Xi(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Ze=(e,t)=>(n,r)=>t(n,r,e);let wt=class extends T.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._univerInstanceService=t,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=i,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(i,o,d,b,h)=>{var w;const S=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getUnitId(),v=(w=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:w.getSheetId();if(!S||!v)return;const C={startRow:i.row,startColumn:i.col,endColumn:i.col,endRow:i.row},I={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row};T.Range.foreach(d,(x,R)=>{const p=T.Rectangle.getPositionRange({startRow:x,startColumn:R,endColumn:R,endRow:x},C),s=T.Rectangle.getPositionRange({startRow:x,startColumn:R,endColumn:R,endRow:x},I),{row:a,col:f}=h(p.startRow,p.startColumn),y=this._conditionalFormattingViewModel.getCellCfs(S,v,a,f),{row:l,col:g}=h(s.startRow,s.startColumn),u=this._conditionalFormattingViewModel.getCellCfs(S,v,l,g);u&&u.forEach(m=>{let F=b.get(m.cfId);if(!b.get(m.cfId)){const P=this._conditionalFormattingRuleModel.getRule(S,v,m.cfId);if(!P)return;F=new T.ObjectMatrix,P.ranges.forEach(L=>{T.Range.foreach(L,(U,E)=>{F.setValue(U,E,1)})}),b.set(m.cfId,F)}F.realDeleteValue(l,g)}),y&&y.forEach(m=>{let F=b.get(m.cfId);if(!b.get(m.cfId)){const P=this._conditionalFormattingRuleModel.getRule(S,v,m.cfId);if(!P)return;F=new T.ObjectMatrix,P.ranges.forEach(L=>{T.Range.foreach(L,(U,E)=>{F.setValue(U,E,1)})}),b.set(m.cfId,F)}F.setValue(l,g,1)})})},n=(i,o)=>{var s,a,f;const d=(s=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET))==null?void 0:s.getUnitId(),b=(f=(a=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.getActiveSheet())==null?void 0:f.getSheetId(),h=new Map,S=[],v=[];if(!d||!b)return e();const C=ce.virtualizeDiscreteRanges([i,o]),[I,w]=C.ranges,{mapFunc:x}=C,R={row:I.startRow,col:I.startColumn};return ce.getAutoFillRepeatRange(I,w).forEach(y=>{t(R,y.repeatStartCell,y.relativeRange,h,x)}),h.forEach((y,l)=>{const g=this._conditionalFormattingRuleModel.getRule(d,b,l);if(!g)return;const u=$.findAllRectangle($.createTopMatrixFromMatrix(y));if(u.length){const m={unitId:d,subUnitId:b,rule:{...g,ranges:u}};S.push({id:c.SetConditionalRuleMutation.id,params:m}),v.push(...c.setConditionalRuleMutationUndoFactory(this._injector,m))}else{const m={unitId:d,subUnitId:b,cfId:g.cfId};S.push({id:c.DeleteConditionalRuleMutation.id,params:m}),v.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,m))}}),{undos:v,redos:S}},r={id:c.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(i,o,d)=>{if(d===ce.APPLY_TYPE.COPY||d===ce.APPLY_TYPE.ONLY_FORMAT||d===ce.APPLY_TYPE.SERIES){const{source:b,target:h}=i;return n(b,h)}return e()}};this.disposeWithMe(this._autoFillService.addHook(r))}};wt=Ki([Ze(0,T.Inject(T.Injector)),Ze(1,T.Inject(T.IUniverInstanceService)),Ze(2,T.Inject(ce.IAutoFillService)),Ze(3,T.Inject(c.ConditionalFormattingRuleModel)),Ze(4,T.Inject(c.ConditionalFormattingViewModel))],wt);var Zi=Object.getOwnPropertyDescriptor,Ji=(e,t,n,r)=>{for(var i=r>1?void 0:r?Zi(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Je=(e,t)=>(n,r)=>t(n,r,e);exports.ConditionalFormattingClearController=class extends T.Disposable{constructor(t,n,r,i,o){super(),this._injector=t,this._univerInstanceService=n,this._sheetInterceptorService=r,this._selectionManagerService=i,this._conditionalFormattingRuleModel=o,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{var o;const n=[],r=[],i={redos:n,undos:r};if([$.ClearSelectionFormatCommand.id,$.ClearSelectionAllCommand.id].includes(t.id)){const d=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(x=>x.range);if(!d)return i;const b=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET),h=b.getActiveSheet();if(!h)return i;const S=b.getUnitId(),v=h.getSheetId(),C=this._conditionalFormattingRuleModel.getSubunitRules(S,v);if(!C||!C.length)return i;const{redos:I,undos:w}=Gn(this._injector,C,d,S,v);n.push(...I),r.push(...w)}return i}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:t,subUnitId:n,ranges:r})=>{const i=[],o=[],d={redos:i,undos:o};if(!r||!r.length)return d;const b=this._conditionalFormattingRuleModel.getSubunitRules(t,n);if(!b||!b.length)return d;const{redos:h,undos:S}=Gn(this._injector,b,r,t,n);return i.push(...h),o.push(...S),d}}))}};exports.ConditionalFormattingClearController=Ji([Je(0,T.Inject(T.Injector)),Je(1,T.Inject(T.IUniverInstanceService)),Je(2,T.Inject($.SheetInterceptorService)),Je(3,T.Inject($.SheetsSelectionsService)),Je(4,T.Inject(c.ConditionalFormattingRuleModel))],exports.ConditionalFormattingClearController);function Gn(e,t,n,r,i){const o=[],d=[];return t.filter(b=>n.some(h=>b.ranges.some(S=>T.Rectangle.getIntersects(S,h)))).forEach(b=>{const S=new $.RangeMergeUtil().add(...b.ranges).subtract(...n).merge();if(S.length){const v={id:c.SetConditionalRuleMutation.id,params:{unitId:r,subUnitId:i,rule:{...b,ranges:S}}},C=c.setConditionalRuleMutationUndoFactory(e,v.params);o.push(v),d.push(...C)}else{const v={id:c.DeleteConditionalRuleMutation.id,params:{unitId:r,subUnitId:i,cfId:b.cfId}},C=c.DeleteConditionalRuleMutationUndoFactory(e,v.params);o.push(v),d.push(...C)}}),{redos:o,undos:d}}var Qi=Object.getOwnPropertyDescriptor,eo=(e,t,n,r)=>{for(var i=r>1?void 0:r?Qi(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Yn=(e,t)=>(n,r)=>t(n,r,e);let _t=class extends T.Disposable{constructor(e,t){super(),this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(T.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept($.AFTER_CELL_EDIT,{handler:(e,t,n)=>{var d,b,h;e||n(e);const r=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col),i=(d=r==null?void 0:r.style)!=null?d:{},o=Object.keys(i);if(e!=null&&e.p)return(h=(b=e.p.body)==null?void 0:b.textRuns)==null||h.forEach(S=>{S.ts&&o.forEach(v=>{var C;(C=S.ts)==null||delete C[v]})}),n(e);{const S={...(typeof(e==null?void 0:e.s)=="string"?t.workbook.getStyles().get(e.s):e==null?void 0:e.s)||{}};o.forEach(C=>{delete S[C]});const v={...e,s:{...S}};return n(v)}}})))}};_t=eo([Yn(0,T.Inject($.SheetInterceptorService)),Yn(1,T.Inject(c.ConditionalFormattingService))],_t);const Xn=[$.SetWorksheetActiveOperation.id,c.AddConditionalRuleMutation.id,c.SetConditionalRuleMutation.id,c.DeleteConditionalRuleMutation.id,c.MoveConditionalRuleMutation.id],Qe=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:he.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:he.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:he.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:he.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:he.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:he.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:he.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:he.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:he.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:he.clearWorkSheetRules}],to=e=>{const t=e.get($.SheetsSelectionsService),n=e.get(T.ICommandService),r=e.get(T.IUniverInstanceService),i=e.get(c.ConditionalFormattingRuleModel),o=new ye.Observable(h=>ye.merge(t.selectionMoveEnd$,t.selectionSet$,new ye.Observable(S=>{const v=n.onCommandExecuted(C=>{var R;const{id:I,params:w}=C,x=(R=r.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET))==null?void 0:R.getUnitId();Xn.includes(I)&&w.unitId===x&&S.next(null)});return()=>v.dispose()})).pipe(tt.debounceTime(16)).subscribe(()=>{var R;const S=((R=t.getCurrentSelections())==null?void 0:R.map(p=>p.range))||[],v=r.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET);if(!v)return;const C=v.getActiveSheet();if(!C)return;const x=(i.getSubunitRules(v.getUnitId(),C.getSheetId())||[]).filter(p=>p.ranges.some(s=>S.some(a=>T.Rectangle.intersects(a,s)))).map(p=>p.ranges).every(p=>$.checkRangesEditablePermission(e,v.getUnitId(),C.getSheetId(),p));h.next(x)})),d=new ye.Observable(h=>new ye.Observable(S=>{const v=n.onCommandExecuted(C=>{var R;const{id:I,params:w}=C,x=(R=r.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET))==null?void 0:R.getUnitId();Xn.includes(I)&&w.unitId===x&&S.next(null)});return()=>v.dispose()}).pipe(tt.debounceTime(16)).subscribe(()=>{const S=r.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET);if(!S)return;const v=S.getActiveSheet();if(!v)return;const C=i.getSubunitRules(S.getUnitId(),v.getSheetId())||[];if(!C.length)return h.next(!1),!1;const I=C.map(w=>w.ranges).every(w=>$.checkRangesEditablePermission(e,S.getUnitId(),v.getSheetId(),w));h.next(I)})),b=new ye.Observable(h=>{o.subscribe(S=>{const v=Qe.find(C=>C.value===he.clearRangeRules);v&&(v.disabled=!S,h.next(Qe))}),d.subscribe(S=>{const v=Qe.find(C=>C.value===he.clearWorkSheetRules);v&&(v.disabled=!S,h.next(Qe))}),h.next(Qe)});return{id:ct.id,type:J.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:b,hidden$:J.getMenuHiddenObservable(e,T.UniverInstanceType.UNIVER_SHEET),disabled$:ce.getCurrentRangeDisable$(e,{workbookTypes:[$.WorkbookEditablePermission],worksheetTypes:[$.WorksheetSetCellStylePermission,$.WorksheetEditPermission],rangeTypes:[$.RangeProtectionPermissionEditPoint]})}},no={[J.RibbonStartGroup.FORMULAS_INSERT]:{[ct.id]:{order:0,menuItemFactory:to}}};var ro=Object.getOwnPropertyDescriptor,io=(e,t,n,r)=>{for(var i=r>1?void 0:r?ro(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Kn=(e,t)=>(n,r)=>t(n,r,e);let It=class extends T.Disposable{constructor(t,n){super();Re(this,"_sidebarDisposable",null);this._injector=t,this._menuManagerService=n,this._menuManagerService.mergeMenu(no)}};It=io([Kn(0,T.Inject(T.Injector)),Kn(1,J.IMenuManagerService)],It);var oo=Object.getOwnPropertyDescriptor,so=(e,t,n,r)=>{for(var i=r>1?void 0:r?oo(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Ne=(e,t)=>(n,r)=>t(n,r,e);const ao=(e,t)=>{const n=v=>v.endRow-v.startRow+1,r=v=>v.endColumn-v.startColumn+1,i=n(t)%n(e),o=r(t)%r(e),d=Math.floor(n(t)/n(e)),b=Math.floor(r(t)/r(e)),h=[],S={startRow:0,endRow:n(e)-1,startColumn:0,endColumn:r(e)-1};if(n(t)===1&&r(t)===1){const v={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};return h.push({repeatRelativeRange:S,startRange:v}),h}for(let v=0;v<d+(i?.1:0);v++)for(let C=0;C<b+(o?.1:0);C++){const I=n(e)*v,w=r(e)*C,x={startRow:I+t.startRow,endRow:I+t.startRow,startColumn:w+t.startColumn,endColumn:w+t.startColumn};let R=S;v===d&&i&&(R={...R},R.endRow=R.endRow-(n(e)-i)),C===b&&o&&(R={...R},R.endColumn=R.endColumn-(r(e)-o)),h.push({repeatRelativeRange:R,startRange:x})}return h};let Et=class extends T.Disposable{constructor(t,n,r,i,o,d){super();Re(this,"_painterConfig",null);this._injector=t,this._univerInstanceService=n,this._formatPainterService=r,this._sheetsSelectionsService=i,this._conditionalFormattingRuleModel=o,this._conditionalFormattingViewModel=d,this._initFormattingPainter()}_initFormattingPainter(){const t=()=>({redos:[],undos:[]}),n=(o,d,b,h,S)=>{const{unitId:v,subUnitId:C}=this._painterConfig,{targetUnitId:I,targetSubUnitId:w}=S,x={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},R={startRow:d.row,startColumn:d.col,endColumn:d.col,endRow:d.row};T.Range.foreach(b,(p,s)=>{const a=T.Rectangle.getPositionRange({startRow:p,startColumn:s,endColumn:s,endRow:p},x),f=T.Rectangle.getPositionRange({startRow:p,startColumn:s,endColumn:s,endRow:p},R),y=this._conditionalFormattingViewModel.getCellCfs(v,C,a.startRow,a.startColumn),l=this._conditionalFormattingViewModel.getCellCfs(I,w,f.startRow,f.startColumn);l&&l.forEach(g=>{let u=h.get(g.cfId);if(!h.get(g.cfId)){const m=this._conditionalFormattingRuleModel.getRule(I,w,g.cfId);if(!m)return;u=new T.ObjectMatrix,m.ranges.forEach(F=>{T.Range.foreach(F,(P,L)=>{u.setValue(P,L,1)})}),h.set(g.cfId,u)}u.realDeleteValue(f.startRow,f.startColumn)}),y&&y.forEach(g=>{const u=h.get(g.cfId);u&&u.setValue(f.startRow,f.startColumn,1)})})},r=(o,d,b)=>{var a;const{range:h,unitId:S,subUnitId:v}=this._painterConfig,C=o!==S||v!==d,I=new Map,w=[],x=[];if(!o||!d||!S||!v)return t();const R=(a=this._conditionalFormattingRuleModel.getSubunitRules(S,v))!=null?a:[];R==null||R.forEach(f=>{const{ranges:y,cfId:l}=f;if(y.some(g=>T.Rectangle.intersects(h,g))){const g=new T.ObjectMatrix;C||y.forEach(u=>{T.Range.foreach(u,(m,F)=>{g.setValue(m,F,1)})}),I.set(l,g)}});const p={row:h.startRow,col:h.startColumn};return ao(h,b).forEach(f=>{n(p,{row:f.startRange.startRow,col:f.startRange.startColumn},f.repeatRelativeRange,I,{targetUnitId:o,targetSubUnitId:d})}),I.forEach((f,y)=>{if(C){const l=this._conditionalFormattingRuleModel.getRule(o,d,y),g=$.findAllRectangle($.createTopMatrixFromMatrix(f));if(l)if(g.length){const u={unitId:o,subUnitId:d,rule:{...l,ranges:g}};w.push({id:c.SetConditionalRuleMutation.id,params:u}),x.push(...c.setConditionalRuleMutationUndoFactory(this._injector,u))}else{const u={unitId:o,subUnitId:d,cfId:l.cfId};w.push({id:c.DeleteConditionalRuleMutation.id,params:u}),x.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,u))}else if(g.length){const u=this._conditionalFormattingRuleModel.getRule(S,v,y);if(u){const m={unitId:o,subUnitId:d,rule:{...T.Tools.deepClone(u),cfId:this._conditionalFormattingRuleModel.createCfId(o,d),ranges:g}};w.push({id:c.AddConditionalRuleMutation.id,params:m}),x.push(c.AddConditionalRuleMutationUndoFactory(this._injector,m))}}}else{const l=this._conditionalFormattingRuleModel.getRule(S,v,y);if(!l)return;const g=$.findAllRectangle($.createTopMatrixFromMatrix(f));if(g.length){const u={unitId:S,subUnitId:v,rule:{...l,ranges:g}};w.push({id:c.SetConditionalRuleMutation.id,params:u}),x.push(...c.setConditionalRuleMutationUndoFactory(this._injector,u))}else{const u={unitId:S,subUnitId:v,cfId:l.cfId};w.push({id:c.DeleteConditionalRuleMutation.id,params:u}),x.push(...c.DeleteConditionalRuleMutationUndoFactory(this._injector,u))}}}),{undos:x,redos:w}},i={id:c.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:o=>{var d,b,h;switch(o){case ce.FormatPainterStatus.INFINITE:case ce.FormatPainterStatus.ONCE:{const S=(d=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET))==null?void 0:d.getUnitId(),v=(h=(b=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET))==null?void 0:b.getActiveSheet())==null?void 0:h.getSheetId(),C=this._sheetsSelectionsService.getCurrentLastSelection(),I=C==null?void 0:C.range;S&&v&&I&&(this._painterConfig={unitId:S,subUnitId:v,range:I});break}case ce.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(o,d,b)=>this._painterConfig?r(o,d,b):{redos:[],undos:[]}};this._formatPainterService.addHook(i)}};Et=so([Ne(0,T.Inject(T.Injector)),Ne(1,T.Inject(T.IUniverInstanceService)),Ne(2,T.Inject(ce.IFormatPainterService)),Ne(3,T.Inject($.SheetsSelectionsService)),Ne(4,T.Inject(c.ConditionalFormattingRuleModel)),Ne(5,T.Inject(c.ConditionalFormattingViewModel))],Et);var lo=Object.getOwnPropertyDescriptor,uo=(e,t,n,r)=>{for(var i=r>1?void 0:r?lo(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Ht=(e,t)=>(n,r)=>t(n,r,e);let Ot=class extends T.Disposable{constructor(e,t,n){super(),this._conditionalFormattingViewModel=e,this._univerInstanceService=t,this._renderManagerService=n,this._init()}_init(){const e=this._univerInstanceService.getCurrentUnitForType(T.UniverInstanceType.UNIVER_SHEET),t=n=>{const r=n.getUnitId(),i=this._renderManagerService.getRenderById(r);if(!i)return;const o=i.with(ce.SheetSkeletonManagerService);this.disposeWithMe(o.currentSkeleton$.subscribe(d=>{if(d){const b=d.skeleton.rowColumnSegment,h=b.endColumn-b.startColumn+1,v=(b.endRow-b.startRow+1)*h*9,C=Math.max(c.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,v);this._conditionalFormattingViewModel.setCacheLength(C)}}))};e&&t(e),this._univerInstanceService.getCurrentTypeOfUnit$(T.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{n&&t(n)})}};Ot=uo([Ht(0,T.Inject(c.ConditionalFormattingViewModel)),Ht(1,T.IUniverInstanceService),Ht(2,Zn.IRenderManagerService)],Ot);var co=Object.defineProperty,fo=Object.getOwnPropertyDescriptor,po=(e,t,n)=>t in e?co(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ho=(e,t,n,r)=>{for(var i=r>1?void 0:r?fo(t,n):t,o=e.length-1,d;o>=0;o--)(d=e[o])&&(i=d(i)||i);return i},Wt=(e,t)=>(n,r)=>t(n,r,e),yr=(e,t,n)=>po(e,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsConditionalFormattingUIPlugin=class extends T.Plugin{constructor(t=Tt,n,r,i){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=i;const{menu:o,...d}=T.merge({},Tt,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(mr,d),this._initCommand()}onStarting(){T.registerDependencies(this._injector,[[st],[ot],[rt],[wt],[it],[nt],[It],[Le],[_t],[exports.ConditionalFormattingClearController],[Et],[Ot]]),T.touchDependencies(this._injector,[[st]])}onReady(){T.touchDependencies(this._injector,[[It],[nt]])}onRendered(){T.touchDependencies(this._injector,[[wt],[exports.ConditionalFormattingClearController],[rt],[_t],[Le],[Et],[it],[ot],[Ot]])}_initCommand(){[Yt,Xt,Kt,Zt,Jt,Qt,en,tn,nn,ct].forEach(t=>{this._commandService.registerCommand(t)})}};yr(exports.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${c.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`);yr(exports.UniverSheetsConditionalFormattingUIPlugin,"type",T.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingUIPlugin=ho([T.DependentOn(c.UniverSheetsConditionalFormattingPlugin),Wt(1,T.Inject(T.Injector)),Wt(2,T.Inject(T.ICommandService)),Wt(3,T.IConfigService)],exports.UniverSheetsConditionalFormattingUIPlugin);exports.AddAverageCfCommand=Yt;exports.AddColorScaleConditionalRuleCommand=Xt;exports.AddDataBarConditionalRuleCommand=Kt;exports.AddDuplicateValuesCfCommand=Zt;exports.AddNumberCfCommand=Jt;exports.AddRankCfCommand=Qt;exports.AddTextCfCommand=en;exports.AddTimePeriodCfCommand=tn;exports.AddUniqueValuesCfCommand=nn;exports.OpenConditionalFormattingOperator=ct;
76
+ `,{"univer-flex univer-items-center univer-justify-center":E===L}),onClick:B=>{B.stopPropagation(),f(D),S([])},children:l.jsx(Ve,{})})]})},`${D.cfId}`))})})]})},Qt=n=>{const[e,i]=C.useState(n.rule),[r,s]=C.useState(!!n.rule),o=()=>{s(!0)},u=()=>{s(!1),i(void 0)},v=c=>{i(c),s(!0)};return l.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between",children:r?l.jsx(zt,{onCancel:u,rule:e}):l.jsx(Jt,{onClick:v,onCreate:o})})};var en=Object.getOwnPropertyDescriptor,tn=(n,e,i,r)=>{for(var s=r>1?void 0:r?en(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},me=(n,e)=>(i,r)=>e(i,r,n);const Me="sheet.conditional.formatting.panel";let Ce=class extends a.Disposable{constructor(e,i,r,s,o){super();Q(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=i,this._componentManager=r,this._sidebarService=s,this._localeService=o,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(u=>{var v;u||(v=this._sidebarDisposable)==null||v.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(u=>{u.id===Me&&(u.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const i={id:Me,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Me,rule:e,key:a.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(i)}_initPanel(){this._componentManager.register(Me,Qt)}};Ce=tn([me(0,a.IUniverInstanceService),me(1,a.Inject(a.Injector)),me(2,a.Inject(k.ComponentManager)),me(3,a.Inject(k.ISidebarService)),me(4,a.Inject(a.LocaleService))],Ce);var Y=(n=>(n[n.createRule=1]="createRule",n[n.viewRule=2]="viewRule",n[n.highlightCell=3]="highlightCell",n[n.rank=4]="rank",n[n.formula=5]="formula",n[n.colorScale=6]="colorScale",n[n.dataBar=7]="dataBar",n[n.icon=8]="icon",n[n.clearRangeRules=9]="clearRangeRules",n[n.clearWorkSheetRules=10]="clearWorkSheetRules",n))(Y||{});const Fe={id:"sheet.operation.open.conditional.formatting.panel",type:a.CommandType.OPERATION,handler:(n,e)=>{var v;const i=n.get(Ce),r=n.get(O.SheetsSelectionsService),s=n.get(a.ICommandService),o=((v=r.getCurrentSelections())==null?void 0:v.map(c=>c.range))||[];switch(e.value){case 3:{i.openPanel({...t.createDefaultRule(),ranges:o});break}case 4:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank}};i.openPanel(c);break}case 5:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula,value:"="}};i.openPanel(c);break}case 6:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.colorScale,config:[]}};i.openPanel(c);break}case 7:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.dataBar,isShowValue:!0}};i.openPanel(c);break}case 8:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.iconSet,config:[],isShowValue:!0}};i.openPanel(c);break}case 2:{i.openPanel();break}case 1:{i.openPanel({...t.createDefaultRule(),ranges:o});break}case 9:{s.executeCommand(t.ClearRangeCfCommand.id,{ranges:o});break}case 10:{s.executeCommand(t.ClearWorksheetCfCommand.id);break}}return!0}};var nn=Object.getOwnPropertyDescriptor,rn=(n,e,i,r)=>{for(var s=r>1?void 0:r?nn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},ve=(n,e)=>(i,r)=>e(i,r,n);let ye=class extends a.Disposable{constructor(e,i,r,s,o){super();Q(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=i,this._injector=r,this._conditionalFormattingViewModel=s,this._univerInstanceService=o,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,i,r)=>this._collectConditionalRule(e,i,r),onPasteCells:(e,i,r,s)=>{const{copyType:o=H.COPY_TYPE.COPY,pasteType:u}=s,{range:v}=e||{},{range:c}=i;return this._generateConditionalFormattingMutations(c,{copyType:o,pasteType:u,copyRange:v})}}))}_collectConditionalRule(e,i,r){const s=new a.ObjectMatrix,o={};this._copyInfo={matrix:s,info:{unitId:e,subUnitId:i,cfMap:o}};const u=this._injector.invoke(d=>O.rangeToDiscreteRange(r,d,e,i));if(!u)return;const{rows:v,cols:c}=u,m=new Set;v.forEach((d,h)=>{c.forEach((p,y)=>{const x=this._conditionalFormattingViewModel.getCellCfs(e,i,d,p);x&&(x.forEach(S=>m.add(S.cfId)),s.setValue(h,y,x.map(S=>S.cfId)))})}),m.forEach(d=>{const h=this._conditionalFormattingRuleModel.getRule(e,i,d);h&&(o[d]=h.rule)})}_generateConditionalFormattingMutations(e,i){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet(),o=r.getUnitId();if(!s)return{redos:[],undos:[]};const u=s.getSheetId();if(i.copyType===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!i.copyRange)return{redos:[],undos:[]};if(![H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,H.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(i.pasteType))return{redos:[],undos:[]};const{ranges:[c,m],mapFunc:d}=H.virtualizeDiscreteRanges([i.copyRange,e]),h=H.getRepeatRange(c,m,!0),p={};a.Range.foreach(m,(g,b)=>{const{row:T,col:I}=d(g,b),w=this._conditionalFormattingViewModel.getCellCfs(o,u,T,I);w&&w.forEach(M=>{if(!p[M.cfId]){const V=new a.ObjectMatrix;p[M.cfId]=V;const P=this._conditionalFormattingRuleModel.getRule(o,u,M.cfId);P==null||P.ranges.forEach(f=>{a.Range.foreach(f,(R,A)=>{V.setValue(R,A,1)})})}p[M.cfId].realDeleteValue(T,I)})});const{matrix:y,info:x}=this._copyInfo,S=[];let _=this._conditionalFormattingRuleModel.createCfId(o,u);const F={},j=g=>{if(F[g])return F[g];const b=x==null?void 0:x.cfMap[g],T=[...this._conditionalFormattingRuleModel.getSubunitRules(o,u)||[],...S].find(I=>a.Tools.diffValue(I.rule,b));if(T)return F[g]=T,T;{const I={rule:b,cfId:_,ranges:[],stopIfTrue:!1};return F[g]=I,S.push(I),_=`${Number(_)+1}`,I}};h.forEach(g=>{y&&y.forValue((b,T,I)=>{const w=a.Rectangle.getPositionRange({startRow:b,endRow:b,startColumn:T,endColumn:T},g.startRange),{row:M,col:V}=d(w.startRow,w.startColumn);I.forEach(P=>{if(!p[P]){const f=j(P),R=new a.ObjectMatrix;p[P]=R,f.ranges.forEach(A=>{a.Range.foreach(A,(q,X)=>{R.setValue(q,X,1)})})}p[P].setValue(M,V,1)})})});const N=[],E=[];for(const g in p){const b=p[g],T=O.findAllRectangle(O.createTopMatrixFromMatrix(b));if(!T.length){const I={unitId:o,subUnitId:u,cfId:g};N.push({id:t.DeleteConditionalRuleMutation.id,params:I}),E.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(S.some(I=>I.cfId===g)){const I=j(g),w={unitId:o,subUnitId:u,rule:{...I,ranges:T}};N.push({id:t.AddConditionalRuleMutation.id,params:w}),E.push(t.AddConditionalRuleMutationUndoFactory(this._injector,w))}else{const I=this._conditionalFormattingRuleModel.getRule(o,u,g);if(!I)continue;const w={unitId:o,subUnitId:u,rule:{...I,ranges:T}};N.push({id:t.SetConditionalRuleMutation.id,params:w}),E.push(...t.setConditionalRuleMutationUndoFactory(this._injector,w))}}return{redos:N,undos:E}}};ye=rn([ve(0,a.Inject(H.ISheetClipboardService)),ve(1,a.Inject(t.ConditionalFormattingRuleModel)),ve(2,a.Inject(a.Injector)),ve(3,a.Inject(t.ConditionalFormattingViewModel)),ve(4,a.Inject(a.IUniverInstanceService))],ye);var sn=Object.getOwnPropertyDescriptor,on=(n,e,i,r)=>{for(var s=r>1?void 0:r?sn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},Be=(n,e)=>(i,r)=>e(i,r,n);let Se=class extends a.Disposable{constructor(n,e,i){super(),this._localeService=n,this._commandService=e,this._sheetPermissionCheckController=i,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{n.id===t.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[O.WorkbookEditablePermission],rangeTypes:[O.RangeProtectionPermissionEditPoint],worksheetTypes:[O.WorksheetEditPermission,O.WorksheetSetCellStylePermission]},n.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Se=on([Be(0,a.Inject(a.LocaleService)),Be(1,a.ICommandService),Be(2,a.Inject(O.SheetPermissionCheckController))],Se);var an=Object.getOwnPropertyDescriptor,ln=(n,e,i,r)=>{for(var s=r>1?void 0:r?an(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},we=(n,e)=>(i,r)=>e(i,r,n);let be=class extends a.Disposable{constructor(n,e,i,r){super(),this._conditionalFormattingRuleModel=n,this._univerInstanceService=e,this._injector=i,this._refRangeService=r,this._initRefRange()}_initRefRange(){const n=new Map,e=(r,s,o)=>`${r}_${s}_${o}`,i=(r,s,o)=>{const u=c=>{const m=[...o.ranges],d=m.map(p=>O.handleDefaultRangeChangeWithEffectRefCommands(p,c)).filter(p=>!!p);if(t.isRangesEqual(d,m))return{redos:[],undos:[]};if(d.length){const p={unitId:r,subUnitId:s,rule:{...o,ranges:d}},y=[{id:t.SetConditionalRuleMutation.id,params:p}],x=t.setConditionalRuleMutationUndoFactory(this._injector,p);return{redos:y,undos:x}}else{const p={unitId:r,subUnitId:s,cfId:o.cfId},y=[{id:t.DeleteConditionalRuleMutation.id,params:p}],x=t.DeleteConditionalRuleMutationUndoFactory(this._injector,p);return{redos:y,undos:x}}},v=[];o.ranges.forEach(c=>{const m=this._refRangeService.registerRefRange(c,u);v.push(()=>m.dispose())}),n.set(e(r,s,o.cfId),()=>v.forEach(c=>c()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(r=>{const{unitId:s,subUnitId:o,rule:u}=r,v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=v.getActiveSheet();if(!(r.unitId!==v.getUnitId()||r.subUnitId!==(c==null?void 0:c.getSheetId())))switch(r.type){case"add":{i(r.unitId,r.subUnitId,r.rule);break}case"delete":{const m=n.get(e(s,o,u.cfId));m&&m();break}case"set":{const m=n.get(e(s,o,u.cfId));m&&m(),i(r.unitId,r.subUnitId,r.rule)}}})),this.disposeWithMe(a.toDisposable(()=>{n.forEach(r=>{r()}),n.clear()}))}};be=ln([we(0,a.Inject(t.ConditionalFormattingRuleModel)),we(1,a.Inject(a.IUniverInstanceService)),we(2,a.Inject(a.Injector)),we(3,a.Inject(O.RefRangeService))],be);var un=Object.getOwnPropertyDescriptor,cn=(n,e,i,r)=>{for(var s=r>1?void 0:r?un(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},ae=(n,e)=>(i,r)=>e(i,r,n);let Ie=class extends a.Disposable{constructor(e,i,r,s,o,u){super();Q(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=i,this._univerInstanceService=r,this._renderManagerService=s,this._conditionalFormattingViewModel=o,this._conditionalFormattingRuleModel=u,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var i,r,s;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId();(i=this._renderManagerService.getRenderById(e))==null||i.with(H.SheetSkeletonManagerService).reCalculate(),(s=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.mainComponent)==null||s.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(fe.bufferTime(16),fe.filter(e=>!!e.length),fe.filter(e=>{const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;const r=i.getActiveSheet();return r?e.filter(s=>s.unitId===i.getUnitId()&&s.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(e,i,r)=>{const s=this._conditionalFormattingService.composeStyle(i.unitId,i.subUnitId,i.row,i.col);if(!s)return r(e);const o=i.workbook.getStyles(),v={...(typeof(e==null?void 0:e.s)=="string"?o.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}},c={...e,s:v};return s.style&&Object.assign(v,s.style),c.fontRenderExtension||(c.fontRenderExtension={},s.isShowValue!==void 0&&(c.fontRenderExtension.isSkip=!s.isShowValue)),s.dataBar&&(c.dataBar=s.dataBar),s.iconSet&&(c.iconSet=s.iconSet,c.fontRenderExtension.leftOffset=t.DEFAULT_PADDING+t.DEFAULT_WIDTH),r(c)},priority:10}))}};Ie=cn([ae(0,a.Inject(O.SheetInterceptorService)),ae(1,a.Inject(t.ConditionalFormattingService)),ae(2,a.Inject(a.IUniverInstanceService)),ae(3,a.Inject(ht.IRenderManagerService)),ae(4,a.Inject(t.ConditionalFormattingViewModel)),ae(5,a.Inject(t.ConditionalFormattingRuleModel))],Ie);const yt="sheets-conditional-formatting-ui.config",Oe={};var dn=Object.defineProperty,mn=Object.getOwnPropertyDescriptor,vn=(n,e,i)=>e in n?dn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,hn=(n,e,i,r)=>{for(var s=r>1?void 0:r?mn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},He=(n,e)=>(i,r)=>e(i,r,n),St=(n,e,i)=>vn(n,typeof e!="symbol"?e+"":e,i);exports.UniverSheetsConditionalFormattingMobileUIPlugin=class extends a.Plugin{constructor(e=Oe,i,r,s){super(),this._config=e,this._injector=i,this._commandService=r,this._configService=s;const{menu:o,...u}=a.merge({},Oe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(yt,u),this._initCommand(),this._injector.add([Ie]),this._injector.add([be]),this._injector.add([ye]),this._injector.add([Se]),this._injector.add([ue])}_initCommand(){[ze,Ye,Ze,Ke,Xe,Je,Qe,et,tt,Fe].forEach(e=>{this._commandService.registerCommand(e)})}};St(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`);St(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingMobileUIPlugin=hn([a.DependentOn(t.UniverSheetsConditionalFormattingPlugin),He(1,a.Inject(a.Injector)),He(2,a.Inject(a.ICommandService)),He(3,a.IConfigService)],exports.UniverSheetsConditionalFormattingMobileUIPlugin);var pn=Object.getOwnPropertyDescriptor,gn=(n,e,i,r)=>{for(var s=r>1?void 0:r?pn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},he=(n,e)=>(i,r)=>e(i,r,n);let Ue=class extends a.Disposable{constructor(n,e,i,r,s){super(),this._injector=n,this._univerInstanceService=e,this._autoFillService=i,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=s,this._initAutoFill()}_initAutoFill(){const n=()=>({redos:[],undos:[]}),e=(s,o,u,v,c)=>{var y;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(y=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:y.getSheetId();if(!m||!d)return;const h={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},p={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row};a.Range.foreach(u,(x,S)=>{const _=a.Rectangle.getPositionRange({startRow:x,startColumn:S,endColumn:S,endRow:x},h),F=a.Rectangle.getPositionRange({startRow:x,startColumn:S,endColumn:S,endRow:x},p),{row:j,col:N}=c(_.startRow,_.startColumn),E=this._conditionalFormattingViewModel.getCellCfs(m,d,j,N),{row:g,col:b}=c(F.startRow,F.startColumn),T=this._conditionalFormattingViewModel.getCellCfs(m,d,g,b);T&&T.forEach(I=>{let w=v.get(I.cfId);if(!v.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(m,d,I.cfId);if(!M)return;w=new a.ObjectMatrix,M.ranges.forEach(V=>{a.Range.foreach(V,(P,f)=>{w.setValue(P,f,1)})}),v.set(I.cfId,w)}w.realDeleteValue(g,b)}),E&&E.forEach(I=>{let w=v.get(I.cfId);if(!v.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(m,d,I.cfId);if(!M)return;w=new a.ObjectMatrix,M.ranges.forEach(V=>{a.Range.foreach(V,(P,f)=>{w.setValue(P,f,1)})}),v.set(I.cfId,w)}w.setValue(g,b,1)})})},i=(s,o)=>{var F,j,N;const u=(F=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:F.getUnitId(),v=(N=(j=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:j.getActiveSheet())==null?void 0:N.getSheetId(),c=new Map,m=[],d=[];if(!u||!v)return n();const h=H.virtualizeDiscreteRanges([s,o]),[p,y]=h.ranges,{mapFunc:x}=h,S={row:p.startRow,col:p.startColumn};return H.getAutoFillRepeatRange(p,y).forEach(E=>{e(S,E.repeatStartCell,E.relativeRange,c,x)}),c.forEach((E,g)=>{const b=this._conditionalFormattingRuleModel.getRule(u,v,g);if(!b)return;const T=O.findAllRectangle(O.createTopMatrixFromMatrix(E));if(T.length){const I={unitId:u,subUnitId:v,rule:{...b,ranges:T}};m.push({id:t.SetConditionalRuleMutation.id,params:I}),d.push(...t.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:u,subUnitId:v,cfId:b.cfId};m.push({id:t.DeleteConditionalRuleMutation.id,params:I}),d.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:d,redos:m}},r={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(s,o,u)=>{if(u===H.APPLY_TYPE.COPY||u===H.APPLY_TYPE.ONLY_FORMAT||u===H.APPLY_TYPE.SERIES){const{source:v,target:c}=s;return i(v,c)}return n()}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ue=gn([he(0,a.Inject(a.Injector)),he(1,a.Inject(a.IUniverInstanceService)),he(2,a.Inject(H.IAutoFillService)),he(3,a.Inject(t.ConditionalFormattingRuleModel)),he(4,a.Inject(t.ConditionalFormattingViewModel))],Ue);var fn=Object.getOwnPropertyDescriptor,Cn=(n,e,i,r)=>{for(var s=r>1?void 0:r?fn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},pe=(n,e)=>(i,r)=>e(i,r,n);exports.ConditionalFormattingClearController=class extends a.Disposable{constructor(e,i,r,s,o){super(),this._injector=e,this._univerInstanceService=i,this._sheetInterceptorService=r,this._selectionManagerService=s,this._conditionalFormattingRuleModel=o,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var o;const i=[],r=[],s={redos:i,undos:r};if([O.ClearSelectionFormatCommand.id,O.ClearSelectionAllCommand.id].includes(e.id)){const u=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(x=>x.range);if(!u)return s;const v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=v.getActiveSheet();if(!c)return s;const m=v.getUnitId(),d=c.getSheetId(),h=this._conditionalFormattingRuleModel.getSubunitRules(m,d);if(!h||!h.length)return s;const{redos:p,undos:y}=ct(this._injector,h,u,m,d);i.push(...p),r.push(...y)}return s}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:i,ranges:r})=>{const s=[],o=[],u={redos:s,undos:o};if(!r||!r.length)return u;const v=this._conditionalFormattingRuleModel.getSubunitRules(e,i);if(!v||!v.length)return u;const{redos:c,undos:m}=ct(this._injector,v,r,e,i);return s.push(...c),o.push(...m),u}}))}};exports.ConditionalFormattingClearController=Cn([pe(0,a.Inject(a.Injector)),pe(1,a.Inject(a.IUniverInstanceService)),pe(2,a.Inject(O.SheetInterceptorService)),pe(3,a.Inject(O.SheetsSelectionsService)),pe(4,a.Inject(t.ConditionalFormattingRuleModel))],exports.ConditionalFormattingClearController);function ct(n,e,i,r,s){const o=[],u=[];return e.filter(v=>i.some(c=>v.ranges.some(m=>a.Rectangle.getIntersects(m,c)))).forEach(v=>{const m=new O.RangeMergeUtil().add(...v.ranges).subtract(...i).merge();if(m.length){const d={id:t.SetConditionalRuleMutation.id,params:{unitId:r,subUnitId:s,rule:{...v,ranges:m}}},h=t.setConditionalRuleMutationUndoFactory(n,d.params);o.push(d),u.push(...h)}else{const d={id:t.DeleteConditionalRuleMutation.id,params:{unitId:r,subUnitId:s,cfId:v.cfId}},h=t.DeleteConditionalRuleMutationUndoFactory(n,d.params);o.push(d),u.push(...h)}}),{redos:o,undos:u}}var yn=Object.getOwnPropertyDescriptor,Sn=(n,e,i,r)=>{for(var s=r>1?void 0:r?yn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},dt=(n,e)=>(i,r)=>e(i,r,n);let ke=class extends a.Disposable{constructor(n,e){super(),this._sheetInterceptorService=n,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(a.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(O.AFTER_CELL_EDIT,{handler:(n,e,i)=>{var u,v,c;n||i(n);const r=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),s=(u=r==null?void 0:r.style)!=null?u:{},o=Object.keys(s);if(n!=null&&n.p)return(c=(v=n.p.body)==null?void 0:v.textRuns)==null||c.forEach(m=>{m.ts&&o.forEach(d=>{var h;(h=m.ts)==null||delete h[d]})}),i(n);{const m={...(typeof(n==null?void 0:n.s)=="string"?e.workbook.getStyles().get(n.s):n==null?void 0:n.s)||{}};o.forEach(h=>{delete m[h]});const d={...n,s:{...m}};return i(d)}}})))}};ke=Sn([dt(0,a.Inject(O.SheetInterceptorService)),dt(1,a.Inject(t.ConditionalFormattingService))],ke);const mt=[O.SetWorksheetActiveOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],ge=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:Y.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:Y.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:Y.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:Y.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:Y.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:Y.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:Y.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:Y.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:Y.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:Y.clearWorkSheetRules}],bn=n=>{const e=n.get(O.SheetsSelectionsService),i=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),s=n.get(t.ConditionalFormattingRuleModel),o=new K.Observable(c=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(m=>{const d=i.onCommandExecuted(h=>{var S;const{id:p,params:y}=h,x=(S=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getUnitId();mt.includes(p)&&y.unitId===x&&m.next(null)});return()=>d.dispose()})).pipe(fe.debounceTime(16)).subscribe(()=>{var S;const m=((S=e.getCurrentSelections())==null?void 0:S.map(_=>_.range))||[],d=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d)return;const h=d.getActiveSheet();if(!h)return;const x=(s.getSubunitRules(d.getUnitId(),h.getSheetId())||[]).filter(_=>_.ranges.some(F=>m.some(j=>a.Rectangle.intersects(j,F)))).map(_=>_.ranges).every(_=>O.checkRangesEditablePermission(n,d.getUnitId(),h.getSheetId(),_));c.next(x)})),u=new K.Observable(c=>new K.Observable(m=>{const d=i.onCommandExecuted(h=>{var S;const{id:p,params:y}=h,x=(S=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getUnitId();mt.includes(p)&&y.unitId===x&&m.next(null)});return()=>d.dispose()}).pipe(fe.debounceTime(16)).subscribe(()=>{const m=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m)return;const d=m.getActiveSheet();if(!d)return;const h=s.getSubunitRules(m.getUnitId(),d.getSheetId())||[];if(!h.length)return c.next(!1),!1;const p=h.map(y=>y.ranges).every(y=>O.checkRangesEditablePermission(n,m.getUnitId(),d.getSheetId(),y));c.next(p)})),v=new K.Observable(c=>{o.subscribe(m=>{const d=ge.find(h=>h.value===Y.clearRangeRules);d&&(d.disabled=!m,c.next(ge))}),u.subscribe(m=>{const d=ge.find(h=>h.value===Y.clearWorkSheetRules);d&&(d.disabled=!m,c.next(ge))}),c.next(ge)});return{id:Fe.id,type:k.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:v,hidden$:k.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(n,{workbookTypes:[O.WorkbookEditablePermission],worksheetTypes:[O.WorksheetSetCellStylePermission,O.WorksheetEditPermission],rangeTypes:[O.RangeProtectionPermissionEditPoint]})}},In={[k.RibbonStartGroup.FORMULAS_INSERT]:{[Fe.id]:{order:0,menuItemFactory:bn}}};var Tn=Object.getOwnPropertyDescriptor,xn=(n,e,i,r)=>{for(var s=r>1?void 0:r?Tn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},vt=(n,e)=>(i,r)=>e(i,r,n);let Pe=class extends a.Disposable{constructor(e,i){super();Q(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=i,this._menuManagerService.mergeMenu(In)}};Pe=xn([vt(0,a.Inject(a.Injector)),vt(1,k.IMenuManagerService)],Pe);var Rn=Object.getOwnPropertyDescriptor,Fn=(n,e,i,r)=>{for(var s=r>1?void 0:r?Rn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},le=(n,e)=>(i,r)=>e(i,r,n);const _n=(n,e)=>{const i=d=>d.endRow-d.startRow+1,r=d=>d.endColumn-d.startColumn+1,s=i(e)%i(n),o=r(e)%r(n),u=Math.floor(i(e)/i(n)),v=Math.floor(r(e)/r(n)),c=[],m={startRow:0,endRow:i(n)-1,startColumn:0,endColumn:r(n)-1};if(i(e)===1&&r(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return c.push({repeatRelativeRange:m,startRange:d}),c}for(let d=0;d<u+(s?.1:0);d++)for(let h=0;h<v+(o?.1:0);h++){const p=i(n)*d,y=r(n)*h,x={startRow:p+e.startRow,endRow:p+e.startRow,startColumn:y+e.startColumn,endColumn:y+e.startColumn};let S=m;d===u&&s&&(S={...S},S.endRow=S.endRow-(i(n)-s)),h===v&&o&&(S={...S},S.endColumn=S.endColumn-(r(n)-o)),c.push({repeatRelativeRange:S,startRange:x})}return c};let De=class extends a.Disposable{constructor(e,i,r,s,o,u){super();Q(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=i,this._formatPainterService=r,this._sheetsSelectionsService=s,this._conditionalFormattingRuleModel=o,this._conditionalFormattingViewModel=u,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),i=(o,u,v,c,m)=>{const{unitId:d,subUnitId:h}=this._painterConfig,{targetUnitId:p,targetSubUnitId:y}=m,x={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},S={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};a.Range.foreach(v,(_,F)=>{const j=a.Rectangle.getPositionRange({startRow:_,startColumn:F,endColumn:F,endRow:_},x),N=a.Rectangle.getPositionRange({startRow:_,startColumn:F,endColumn:F,endRow:_},S),E=this._conditionalFormattingViewModel.getCellCfs(d,h,j.startRow,j.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(p,y,N.startRow,N.startColumn);g&&g.forEach(b=>{let T=c.get(b.cfId);if(!c.get(b.cfId)){const I=this._conditionalFormattingRuleModel.getRule(p,y,b.cfId);if(!I)return;T=new a.ObjectMatrix,I.ranges.forEach(w=>{a.Range.foreach(w,(M,V)=>{T.setValue(M,V,1)})}),c.set(b.cfId,T)}T.realDeleteValue(N.startRow,N.startColumn)}),E&&E.forEach(b=>{const T=c.get(b.cfId);T&&T.setValue(N.startRow,N.startColumn,1)})})},r=(o,u,v)=>{var j;const{range:c,unitId:m,subUnitId:d}=this._painterConfig,h=o!==m||d!==u,p=new Map,y=[],x=[];if(!o||!u||!m||!d)return e();const S=(j=this._conditionalFormattingRuleModel.getSubunitRules(m,d))!=null?j:[];S==null||S.forEach(N=>{const{ranges:E,cfId:g}=N;if(E.some(b=>a.Rectangle.intersects(c,b))){const b=new a.ObjectMatrix;h||E.forEach(T=>{a.Range.foreach(T,(I,w)=>{b.setValue(I,w,1)})}),p.set(g,b)}});const _={row:c.startRow,col:c.startColumn};return _n(c,v).forEach(N=>{i(_,{row:N.startRange.startRow,col:N.startRange.startColumn},N.repeatRelativeRange,p,{targetUnitId:o,targetSubUnitId:u})}),p.forEach((N,E)=>{if(h){const g=this._conditionalFormattingRuleModel.getRule(o,u,E),b=O.findAllRectangle(O.createTopMatrixFromMatrix(N));if(g)if(b.length){const T={unitId:o,subUnitId:u,rule:{...g,ranges:b}};y.push({id:t.SetConditionalRuleMutation.id,params:T}),x.push(...t.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:o,subUnitId:u,cfId:g.cfId};y.push({id:t.DeleteConditionalRuleMutation.id,params:T}),x.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}else if(b.length){const T=this._conditionalFormattingRuleModel.getRule(m,d,E);if(T){const I={unitId:o,subUnitId:u,rule:{...a.Tools.deepClone(T),cfId:this._conditionalFormattingRuleModel.createCfId(o,u),ranges:b}};y.push({id:t.AddConditionalRuleMutation.id,params:I}),x.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const g=this._conditionalFormattingRuleModel.getRule(m,d,E);if(!g)return;const b=O.findAllRectangle(O.createTopMatrixFromMatrix(N));if(b.length){const T={unitId:m,subUnitId:d,rule:{...g,ranges:b}};y.push({id:t.SetConditionalRuleMutation.id,params:T}),x.push(...t.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:m,subUnitId:d,cfId:g.cfId};y.push({id:t.DeleteConditionalRuleMutation.id,params:T}),x.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}}}),{undos:x,redos:y}},s={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:o=>{var u,v,c;switch(o){case H.FormatPainterStatus.INFINITE:case H.FormatPainterStatus.ONCE:{const m=(u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:u.getUnitId(),d=(c=(v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getActiveSheet())==null?void 0:c.getSheetId(),h=this._sheetsSelectionsService.getCurrentLastSelection(),p=h==null?void 0:h.range;m&&d&&p&&(this._painterConfig={unitId:m,subUnitId:d,range:p});break}case H.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(o,u,v)=>this._painterConfig?r(o,u,v):{redos:[],undos:[]}};this._formatPainterService.addHook(s)}};De=Fn([le(0,a.Inject(a.Injector)),le(1,a.Inject(a.IUniverInstanceService)),le(2,a.Inject(H.IFormatPainterService)),le(3,a.Inject(O.SheetsSelectionsService)),le(4,a.Inject(t.ConditionalFormattingRuleModel)),le(5,a.Inject(t.ConditionalFormattingViewModel))],De);var jn=Object.getOwnPropertyDescriptor,En=(n,e,i,r)=>{for(var s=r>1?void 0:r?jn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},We=(n,e)=>(i,r)=>e(i,r,n);let Ae=class extends a.Disposable{constructor(n,e,i){super(),this._conditionalFormattingViewModel=n,this._univerInstanceService=e,this._renderManagerService=i,this._init()}_init(){const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),e=i=>{const r=i.getUnitId(),s=this._renderManagerService.getRenderById(r);if(!s)return;const o=s.with(H.SheetSkeletonManagerService);this.disposeWithMe(o.currentSkeleton$.subscribe(u=>{if(u){const v=u.skeleton.rowColumnSegment,c=v.endColumn-v.startColumn+1,d=(v.endRow-v.startRow+1)*c*9,h=Math.max(t.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(h)}}))};n&&e(n),this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(i=>{i&&e(i)})}};Ae=En([We(0,a.Inject(t.ConditionalFormattingViewModel)),We(1,a.IUniverInstanceService),We(2,ht.IRenderManagerService)],Ae);var Nn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,wn=(n,e,i)=>e in n?Nn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,Vn=(n,e,i,r)=>{for(var s=r>1?void 0:r?Mn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},qe=(n,e)=>(i,r)=>e(i,r,n),bt=(n,e,i)=>wn(n,typeof e!="symbol"?e+"":e,i);exports.UniverSheetsConditionalFormattingUIPlugin=class extends a.Plugin{constructor(e=Oe,i,r,s){super(),this._config=e,this._injector=i,this._commandService=r,this._configService=s;const{menu:o,...u}=a.merge({},Oe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(yt,u),this._initCommand()}onStarting(){a.registerDependencies(this._injector,[[Ie],[be],[ye],[Ue],[Se],[Ce],[Pe],[ue],[ke],[exports.ConditionalFormattingClearController],[De],[Ae]]),a.touchDependencies(this._injector,[[Ie]])}onReady(){a.touchDependencies(this._injector,[[Pe],[Ce]])}onRendered(){a.touchDependencies(this._injector,[[Ue],[exports.ConditionalFormattingClearController],[ye],[ke],[ue],[De],[Se],[be],[Ae]])}_initCommand(){[ze,Ye,Ze,Ke,Xe,Je,Qe,et,tt,Fe].forEach(e=>{this._commandService.registerCommand(e)})}};bt(exports.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`);bt(exports.UniverSheetsConditionalFormattingUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingUIPlugin=Vn([a.DependentOn(t.UniverSheetsConditionalFormattingPlugin),qe(1,a.Inject(a.Injector)),qe(2,a.Inject(a.ICommandService)),qe(3,a.IConfigService)],exports.UniverSheetsConditionalFormattingUIPlugin);exports.AddAverageCfCommand=ze;exports.AddColorScaleConditionalRuleCommand=Ye;exports.AddDataBarConditionalRuleCommand=Ze;exports.AddDuplicateValuesCfCommand=Ke;exports.AddNumberCfCommand=Xe;exports.AddRankCfCommand=Je;exports.AddTextCfCommand=Qe;exports.AddTimePeriodCfCommand=et;exports.AddUniqueValuesCfCommand=tt;exports.OpenConditionalFormattingOperator=Fe;