@univerjs/sheets-conditional-formatting-ui 0.7.0-nightly.202505201607 → 0.7.0-nightly.202505221607
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 +1 -1
- package/lib/es/index.js +3 -1
- package/lib/index.js +3 -1
- package/lib/umd/index.js +2 -2
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";var Tt=Object.defineProperty;var Rt=(n,e,i)=>e in n?Tt(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"),U=require("@univerjs/sheets"),k=require("@univerjs/ui"),l=require("react/jsx-runtime"),C=require("react"),w=require("@univerjs/design"),Ge=require("@univerjs/engine-formula"),xe=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=U.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=U.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=U.getSheetCommandTarget(h);if(!p)return!1;const{unitId:y,subUnitId:T}=p,S=n.get(a.ICommandService),_=d.createCfId(y,T),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:T,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=U.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=U.getSheetCommandTarget(m);if(!d)return!1;const{unitId:h,subUnitId:p}=d,y=v.createCfId(h,p);let T;if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(o)){const S=u;if(S.length!==2||!Array.isArray(S))return!1;T={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;T={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:T})}},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=U.getSheetCommandTarget(m);if(!h)return!1;const{unitId:p,subUnitId:y}=h,T=c.createCfId(p,y),S={ranges:i,cfId:T,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=U.getSheetCommandTarget(c);if(!m)return!1;const{unitId:d,subUnitId:h}=m,p=n.get(a.ICommandService),y=v.createCfId(d,h),T={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:T})}},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=U.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=U.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(jt()));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),(Nt(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 Nt(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 jt(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var Et={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:Et}))});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"}}]},Ae=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"more-down-single",ref:e,icon:wt}))});Ae.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"}}]}]},Te=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"slash-single",ref:e,icon:Ot}))});Te.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:w.clsx("univer-fill-primary-600",o),extend:{colorChannel1:c.isValid?e:""}}):l.jsx(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx(w.ColorPicker,{value:e,onChange:i})}),children:l.jsxs("span",{className:w.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",o),children:[l.jsx(m,{className:"univer-fill-primary-600",extend:{colorChannel1:c.isValid?e:""}}),u&&l.jsx(Ae,{className:"univer-ml-1.5 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
|
|
2
|
-
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(Te,{},m))});case t.CFRuleType.highlightCell:{const{ul:c,st:m,it:d,bl:h,bg:p,cl:y}=e.style,T=(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,N=(o=p==null?void 0:p.rgb)!=null?o:t.DEFAULT_BG_COLOR,E=(u=y==null?void 0:y.rgb)!=null?u:t.DEFAULT_FONT_COLOR,j={textDecoration:(v=`${T?"underline":""} ${S?"line-through":""}`.replace(/^ /,""))!=null?v:void 0,backgroundColor:N,color:E};return l.jsx("div",{className:w.clsx(s,{"univer-font-bold":F,"univer-italic":_}),style:j,children:"123"})}}},Re=w.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",w.borderClassName),ne=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),$e=n=>{var T;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=(T=u.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:T.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(xe.FormulaEditor,{ref:h,className:w.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",w.borderClassName),initValue:m,unitId:v,subUnitId:c,isFocus:p,onChange:(S="")=>{r(S||"")},onFocus:()=>y(!0)})}):l.jsx(w.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}),[T,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 L;if(!r||r.config.length!==3)return 50;const R=(L=r.config[1])==null?void 0:L.value.value;return R===void 0?50:R}),[N,E]=C.useState(()=>{var L;if(!r)return 90;const R=(L=r.config[r.config.length-1])==null?void 0:L.value.value;return R===void 0?90:R}),[j,g]=C.useState(()=>{var R;const f="#d0d9fb";return r&&((R=r.config[0])==null?void 0:R.color)||f}),[b,x]=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,V]=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:L,maxType:q,minValue:X,medianValue:J,maxValue:ie,minColor:se,medianColor:D,maxColor:A}=f,B=[];return B.push({color:se,value:{type:R,value:X}}),L!=="none"&&B.push({color:D,value:{type:L,value:J}}),B.push({color:A,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:T,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),[M,c,d,p,T,_,N,j,b,I,e]);const O=f=>{n.onChange(M(f))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",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:T,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})})}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",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(w.Select,{className:"univer-flex-shrink-0",options:o,value:c,onChange:f=>{m(f);const R=t.createDefaultValueByValueType(f,10);S(R),O({minType:f,medianType:d,maxType:p,minValue:R,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"min",className:"univer-ml-1",value:T,type:c,onChange:f=>{S(f),O({minType:c,medianType:d,maxType:p,minValue:f,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx(re,{className:"univer-ml-1",color:j,onChange:f=>{g(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:f,medianColor:b,maxColor:I})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600dark:!univer-text-gray-200",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(w.Select,{className:"univer-flex-shrink-0",options:u,value:d,onChange:f=>{h(f);const R=t.createDefaultValueByValueType(f,50);F(R),O({minType:c,medianType:f,maxType:p,minValue:T,medianValue:R,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"median",className:"univer-ml-1",value:_,type:d,onChange:f=>{F(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:f,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),d!=="none"&&l.jsx(re,{className:"univer-ml-1",color:b,onChange:f=>{x(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:j,medianColor:f,maxColor:I})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",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(w.Select,{className:"univer-flex-shrink-0",options:v,value:p,onChange:f=>{y(f);const R=t.createDefaultValueByValueType(f,90);E(R),O({minType:c,medianType:d,maxType:f,minValue:T,medianValue:_,maxValue:R,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"max",className:"univer-ml-1",value:N,type:p,onChange:f=>{E(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:f,minColor:j,medianColor:b,maxColor:I})}}),l.jsx(re,{className:"univer-ml-1",color:I,onChange:f=>{V(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:j,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 N;((N=d.current)==null?void 0:N.isClickOutSide(_))&&p(!1)});const y=C.useRef(r),T=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(xe.FormulaEditor,{ref:d,className:w.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",w.borderClassName),initValue:_,unitId:c,subUnitId:m,isFocus:h,onChange:(F="")=>{e(F||"")},onFocus:()=>p(!0)})})}return l.jsx(w.InputNumber,{className:i,value:Number(r)||0,disabled:u,onChange:_=>{e(_||0)},...T})},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,T]=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,N]=C.useState(()=>{var L;if(!r)return 0;const R=((L=r.config)==null?void 0:L.min)||{};return R.type===t.CFValueType.formula?R.value||"=":R.value||0}),[E,j]=C.useState(()=>{var L;if(!r)return 100;const R=((L=r.config)==null?void 0:L.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),x=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 x({isGradient:s,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}}),[s,F,y,E,S,u,c,e,g]);const I=f=>{n.onChange(x(f))},V=f=>{v(f),I({isGradient:s,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:f,nativeColor:c,isShowValue:g})},M=f=>{m(f),I({isGradient:s,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:f,isShowValue:g})},O=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 dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:x({isGradient:s,minValue:F,minValueType:y,maxValue:E,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 dark:!univer-text-gray-200",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(w.RadioGroup,{value:s,onChange:f=>{o(f),I({isGradient:f,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})},children:[l.jsx(w.Radio,{value:"0",children:l.jsx("span",{className:"univer-text-xs",children:i.t("sheet.cf.panel.pureColor")})}),l.jsx(w.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(w.Checkbox,{checked:!g,onChange:f=>{b(!f),I({isGradient:f,minValue:F,minValueType:y,maxValue:E,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 dark:!univer-text-gray-200",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:V})]})]})]}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.valueType.min")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(w.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:y,onChange:f=>{T(f);const R=t.createDefaultValueByValueType(f,10);N(R),I({isGradient:s,minValue:R,minValueType:f,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}}),l.jsx(rt,{id:"min",className:"univer-ml-3",disabled:!O(y),type:y,value:F,onChange:f=>{N(f||0),I({isGradient:s,minValue:f||0,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.valueType.max")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(w.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:p,value:S,onChange:f=>{_(f);const R=t.createDefaultValueByValueType(f,90);j(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:!O(S),id:"max",type:S,value:E,onChange:f=>{j(f||0),I({isGradient:s,minValue:F,minValueType:y,maxValue:f||0,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}})]})]})]})},Ne=n=>[a.BooleanNumber.FALSE,void 0].includes(n)?a.BooleanNumber.TRUE:a.BooleanNumber.FALSE,je=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,T]=C.useState(()=>{var x;const b="#2f56ef";return(x=e==null?void 0:e.cl)!=null&&x.rgb?e.cl.rgb:b}),[S,_]=C.useState(()=>{var x;const b="#e8ecfc";return(x=e==null?void 0:e.bg)!=null&&x.rgb?e.bg.rgb:b}),F=s.get("BoldSingle"),N=s.get("ItalicSingle"),E=s.get("UnderlineSingle"),j=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:w.clsx("univer-my-2.5 univer-flex univer-justify-between",r),children:[F&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(o||a.BooleanNumber.FALSE)}),onClick:()=>u(Ne(o)),children:l.jsx(F,{})}),N&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(v||a.BooleanNumber.FALSE)}),onClick:()=>c(Ne(v)),children:l.jsx(N,{})}),E&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(m||a.BooleanNumber.FALSE)}),onClick:()=>d(Ne(m)),children:l.jsx(E,{})}),j&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(h||a.BooleanNumber.FALSE)}),onClick:()=>p(Ne(h)),children:l.jsx(j,{})}),l.jsx(re,{color:y,onChange:T,iconId:"FontColor"}),l.jsx(re,{color:S,onChange:_,iconId:"PaintBucket"})]})},Pt=n=>{var j;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=((j=n.rule)==null?void 0:j.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({}),[T,S]=C.useState(()=>(v==null?void 0:v.subType)===t.CFSubRuleType.formula?v.value:"="),[_,F]=C.useState(void 0),N=g=>({style:g.style,value:T,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});C.useEffect(()=>i.intercept(i.getInterceptPoints().submit,{handler(){return N({style:p})}}),[p,T,i]),C.useEffect(()=>i.intercept(i.getInterceptPoints().beforeSubmit,{handler:(b,x,I)=>_||T.length===1||!T.startsWith("=")?(F(r.t("sheet.cf.errorMessage.formulaError")),!1):I(b)}),[_,T]);const E=g=>{e(N(g))};return k.useSidebarClick(g=>{var x;((x=h.current)==null?void 0:x.isClickOutSide(g))&&d(!1)}),l.jsxs("div",{ref:c,children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:"univer-mt-3",children:l.jsx(xe.FormulaEditor,{ref:h,className:w.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",w.borderClassName),errorText:_,isFocus:m,initValue:T,unitId:o.getUnitId(),subUnitId:u==null?void 0:u.getSheetId(),onFocus:()=>{d(!0)},onChange:g=>{S(g),E({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:N({style:p})})}),l.jsx(nt,{style:v==null?void 0:v.style,className:"univer-mt-3",onChange:g=>{y(g),E({style:g})}})]})},Ee=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,T]=C.useState(""),[S,_]=C.useState(()=>Array.isArray(s)?s[0]===void 0?0:s[0]:0),[F,N]=C.useState(""),[E,j]=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,E]);break}}},[e]),C.useEffect(()=>{const x=o.intercept(o.getInterceptPoints().beforeSubmit,{handler:(I,V,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):(T(u.t("sheet.cf.errorMessage.notBlank")),!1)}return M(I)}});return()=>{x()}},[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 x=I=>{p(I),r(I)};return l.jsx("div",{className:"univer-mt-3",children:l.jsx(Ee,{errorText:y,children:l.jsx(w.Input,{value:h,onChange:I=>{T(""),x(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 x=I=>{c(I||0),r(I||0),d("")};return l.jsx("div",{className:"univer-mt-3",children:l.jsx(Ee,{errorText:m,children:l.jsx(w.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:v,onChange:x})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(i)){const x=V=>{_(V||0),r([V||0,E]),N("")},I=V=>{j(V||0),r([S,V||0]),b("")};return l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(Ee,{errorText:F,children:l.jsx(w.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:S,onChange:x})}),l.jsx(Ee,{errorText:g,children:l.jsx(w.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:E,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 j;const{interceptorManager:e,onChange:i}=n,r=k.useDependency(a.LocaleService),s=((j=n.rule)==null?void 0:j.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 x;const g="";return s?(x=s.value)!=null?x:t.createDefaultValue(s.subType,s.operator):g}),[y,T]=C.useState({}),S=C.useMemo(()=>g=>{var b,x,I,V,M,O,P,f,R,L,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:(x=g.operator)!=null?x:m,style:(I=g.style)!=null?I:y,value:(V=g.value)!=null?V: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:(O=g.operator)!=null?O: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:(L=g.operator)!=null?L: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,x=it(b,r),I=x&&x[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}))},N=g=>{p(g),i(S({value:g}))},E=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 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[l.jsx(w.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:o,options:v}),(c==null?void 0:c.length)&&l.jsx(w.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:N},E),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=>{T(g),i(S({style:g}))}})]})},Ct=(n,e)=>(t.iconMap[n]||[])[Number(e)]||"",Lt=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(w.InputNumber,{className:w.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(xe.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)}),At=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:"univer-cursor-pointer univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",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(Te,{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:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",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],T=t.createDefaultValue(t.CFSubRuleType.number,y.operator);v(T,p)};return C.useMemo(()=>i.map((h,p)=>{const y=r[p],T=Ct(h.iconType,h.iconId),S=p===i.length-1,_=p===0,F=i[p-1],N=(F==null?void 0:F.value.type)===t.CFValueType.formula?s.t("sheet.cf.valueType.formula"):F==null?void 0:F.value.value,E=(j,g)=>{const b={...h,iconId:g,iconType:j};e([String(p)],b)};return l.jsxs("div",{className:p?"univer-mt-6":"univer-mt-3",children:[l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",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 dark:!univer-text-gray-200",children:["(",s.t("sheet.cf.iconSet.when"),s.t(`sheet.cf.symbol.${t.getOppositeOperator(F.operator)}`),N,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(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx($t,{onClick:E,iconId:h.iconId,iconType:h.iconType})}),children:l.jsxs("div",{className:w.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all dark:!univer-text-gray-200 hover:univer-border-primary-600",w.borderClassName),children:[T?l.jsx("img",{src:T,className:"univer-size-4",draggable:!1}):l.jsx(Te,{className:"univer-size-4"}),l.jsx(Ae,{})]})})}),S?l.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[s.t("sheet.cf.iconSet.rule"),l.jsxs("span",{className:"univer-font-medium",children:[s.t("sheet.cf.iconSet.when"),s.t(`sheet.cf.symbol.${t.getOppositeOperator(F.operator)}`),N,S?"":` ${s.t("sheet.cf.iconSet.and")} `]})]}):l.jsx(w.Select,{options:o,value:h.operator,onChange:j=>{c(j,p)}})]}),S?l.jsx("div",{}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",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:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[l.jsx(w.Select,{className:"univer-flex-shrink-0",options:u,value:h.value.type,onChange:j=>{m(j,p)}}),l.jsx("div",{children:l.jsx(Lt,{id:p,type:h.value.type,error:y,value:h.value.value||"",onChange:j=>{v(j,p)}})})]})]})]},p)}),[i,r])},Ht=n=>{var j;const{interceptorManager:e}=n,i=((j=n.rule)==null?void 0:j.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,x,I)=>x===I.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:u,iconId:String(x)}:ot(u,x,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,x)=>b?l.jsx("img",{className:"univer-size-5",src:b},x):l.jsx(Te,{className:"univer-size-5"},x))})},[c]),y=g=>{if(g.reduce((x,I,V)=>x.preType&&!x.result||g.length-1===V?x:I.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:x.preType?{result:x.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 x={};return g.forEach((I,V,M)=>{if(V-1<0||V===M.length-1)return;const P=g[V-1],f=t.getOppositeOperator(P.operator);t.compareWithNumber({operator:f,value:P.value.value},I.value.value)||(x[V]=`${r.t(`sheet.cf.form.${f}`,String(P.value.value))} `)}),x}return{}},T=(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]||[],x=new Array(b.length).fill("").map((I,V,M)=>ot(g,V,M));m(x),o(y(x))};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,x)=>{const I=c.length-1-x,V=g[I];b.iconId=V.iconId,b.iconType=V.iconType}),m([...c])},F=k.useDependency(k.ILayoutService),[N,E]=C.useState();return k.useScrollYOverContainer(N,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(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx(At,{ref:g=>{!N&&g&&E(g)},iconType:u,onClick:S})}),children:l.jsxs("div",{className:w.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",w.borderClassName),children:[p,l.jsx(Ae,{})]})})}),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(w.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(w.Checkbox,{checked:!d,onChange:g=>{h(!g)}}),r.t("sheet.cf.iconSet.onlyShowIcon")]})]}),l.jsx(Bt,{errorMap:s,onChange:T,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,N=s==null?void 0:s.type;if(!s)return F;switch(N){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 N=s==null?void 0:s.type;if(!s)return 10;switch(N){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.rank:return s.value||10}}return 10}),[d,h]=C.useState(()=>{const N=s==null?void 0:s.type;if(!s)return!1;switch(N){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.rank:return s.isPercent||!1}}return!1}),[p,y]=C.useState({}),T=F=>{const{type:N,isPercent:E,value:j,style:g}=F;if(N==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!1,value:j,style:g};if(N==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!0,value:j,style:g};if(N==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:g};if(N==="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 T({type:u,isPercent:d,value:c,style:p})}}),[u,d,c,p,i]);const S=F=>{e(T(F))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsx(w.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(w.InputNumber,{min:1,max:1e3,value:c,onChange:F=>{const N=F||0;m(N),S({type:u,isPercent:d,value:N,style:p})}}),l.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[l.jsx(w.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:T({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 x,I,V;const e=k.useDependency(a.LocaleService),i=k.useDependency(a.ICommandService),r=k.useDependency(a.IUniverInstanceService),s=k.useDependency(t.ConditionalFormattingRuleModel),o=k.useDependency(U.SheetsSelectionsService),u=at(r),v=lt(r),[c,m]=C.useState(void 0),d=C.useRef((I=(x=n.rule)==null?void 0:x.ranges)!=null?I:[]),h=C.useMemo(()=>{var O,P,f;let M=(O=n.rule)==null?void 0:O.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 L=Ge.serializeRange(R);return L==="NaN"?"":L}).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,T]=C.useState(()=>{var P,f;const M=(P=n.rule)==null?void 0:P.rule.type,O=p[0].value;if(!M)return O;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 O}),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(O=>{if(O.id===U.RemoveSheetMutation.id){const P=O.params;P.subUnitId===v&&P.unitId===u&&n.onCancel()}O.id===U.SetWorksheetActiveOperation.id&&n.onCancel()});return()=>M.dispose()},[]);const N=M=>{S.current=M},E=M=>{const O=M.split(",").filter(P=>!!P).map(Ge.deserializeRangeWithSheet).map(P=>P.range);d.current=O},j=()=>{if(c)return;const O=(()=>{const f=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!f)throw new Error("No active sheet found");return d.current.map(q=>U.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),L=lt(r);if(!R||!L)throw new Error("No active sheet found");let q={};n.rule&&n.rule.cfId?(q={...n.rule,ranges:O,rule:f},i.executeCommand(t.SetCfCommand.id,{unitId:R,subUnitId:L,rule:q}),n.onCancel()):(q={cfId:s.createCfId(R,L),ranges:O,rule:f,stopIfTrue:!1},i.executeCommand(t.AddCfCommand.id,{unitId:R,subUnitId:L,rule:q}),n.onCancel())}}},g=()=>{n.onCancel()},b=(M,O)=>{M?O.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 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),l.jsxs("div",{className:"univer-mt-4",children:[l.jsx(xe.RangeSelector,{unitId:u,subUnitId:v,initialValue:h,onChange:(M,O)=>E(O),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 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),l.jsx(w.Select,{className:"univer-mt-4 univer-w-full",value:y,options:p,onChange:M=>T(M)}),l.jsx(F,{interceptorManager:_,rule:(V=n.rule)==null?void 0:V.rule,onChange:N}),l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[l.jsx(w.Button,{onClick:g,children:e.t("sheet.cf.panel.cancel")}),l.jsx(w.Button,{className:"univer-ml-3",variant:"primary",onClick:j,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(U.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(),[T,S]=C.useState([]),[_,F]=C.useState("2"),[N,E]=C.useState(0),[j,g]=C.useState(-1),[b,x]=C.useState(ut),I=C.useRef(null),V=[{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 A=s.getCurrentLastSelection();if(!A)return[];const B=A.range;return D.filter(G=>G.ranges.some(z=>a.Rectangle.intersects(z,B)))}else if(_==="2")return[...D];return[]},[O,P]=C.useState(M);H.useHighlightRange(T),C.useEffect(()=>{const D=o.onCommandExecuted(A=>{A.id===U.SetWorksheetActiveOperation.id&&E(Math.random())});return()=>D.dispose()}),C.useEffect(()=>{P(M)},[_,N,h,y]),C.useEffect(()=>{if(_==="2")return;const D=new K.Observable(A=>{const B=[U.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&&A.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(()=>{E(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(void 0)},150);const ee=()=>{z&&clearTimeout(z),z=null},te=_e=>{_e.propertyName==="width"&&(ee(),W.next(void 0))};return G.addEventListener("transitionend",te),()=>{ee(),G.removeEventListener("transitionend",te)}}}).pipe(K.debounceTime(16)).subscribe(()=>{x(D())});return()=>{B.unsubscribe()}},[]);const f=D=>{var W;const A=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),B=(W=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:W.getSheetId();if(!A||!B)throw new Error("No active sheet found");o.executeCommand(t.DeleteCfCommand.id,{unitId:A,subUnitId:B,cfId:D.cfId})},R=(D,A)=>{g(A.y)},L=(D,A,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 xt=O.length;return Math.min(xt-1,Math.max(0,It))},ee=O[z(A.y)].cfId,te=O[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>A.y?"after":"before"}})},q=()=>{n.onCreate()},X=()=>{_==="2"?o.executeCommand(t.ClearWorksheetCfCommand.id):_==="1"&&O.map(A=>({unitId:h,subUnitId:y,cfId:A.cfId})).forEach(A=>{o.executeCommand(t.DeleteCfCommand.id,A)})},J=C.useMemo(()=>{const D=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet();return O.filter(B=>{const W=B.ranges;return U.checkRangesEditablePermission(v,D.getUnitId(),A.getSheetId(),W)})},[O]),ie=J.map((D,A)=>({i:D.cfId,x:0,w:12,y:A,h:1,isResizable:!1})),se=C.useMemo(()=>{const D=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet();return O.every(B=>{const W=B.ranges;return U.checkRangesEditablePermission(v,D.getUnitId(),A.getSheetId(),W)})},[O]);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(w.Select,{className:"univer-w-36",options:V,value:_,onChange:D=>{F(D)}})).map((D,A)=>l.jsx("span",{children:D},A))}),l.jsxs("div",{className:"univer-flex univer-justify-end",children:[l.jsx(w.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,{})})}),O.length&&se?l.jsx(w.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(w.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:ie,cols:12,rowHeight:60,width:b,margin:[0,10],onDragStop:L,onDragStart:R,children:J==null?void 0:J.map((D,A)=>l.jsx("div",{children:l.jsxs("div",{className:w.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-bg-gray-100 dark:!univer-bg-gray-700":j===A}),onMouseMove:()=>{D.ranges!==T&&S(D.ranges)},onMouseLeave:()=>S([]),onClick:()=>{e(D)},children:[l.jsx("div",{className:w.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:B=>B.stopPropagation(),children:l.jsx(ft,{})}),l.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",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:w.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":j===A}),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(U.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=>U.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 T=this._conditionalFormattingViewModel.getCellCfs(e,i,d,p);T&&(T.forEach(S=>m.add(S.cfId)),s.setValue(h,y,T.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:x,col:I}=d(g,b),V=this._conditionalFormattingViewModel.getCellCfs(o,u,x,I);V&&V.forEach(M=>{if(!p[M.cfId]){const O=new a.ObjectMatrix;p[M.cfId]=O;const P=this._conditionalFormattingRuleModel.getRule(o,u,M.cfId);P==null||P.ranges.forEach(f=>{a.Range.foreach(f,(R,L)=>{O.setValue(R,L,1)})})}p[M.cfId].realDeleteValue(x,I)})});const{matrix:y,info:T}=this._copyInfo,S=[];let _=this._conditionalFormattingRuleModel.createCfId(o,u);const F={},N=g=>{if(F[g])return F[g];const b=T==null?void 0:T.cfMap[g],x=[...this._conditionalFormattingRuleModel.getSubunitRules(o,u)||[],...S].find(I=>a.Tools.diffValue(I.rule,b));if(x)return F[g]=x,x;{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,x,I)=>{const V=a.Rectangle.getPositionRange({startRow:b,endRow:b,startColumn:x,endColumn:x},g.startRange),{row:M,col:O}=d(V.startRow,V.startColumn);I.forEach(P=>{if(!p[P]){const f=N(P),R=new a.ObjectMatrix;p[P]=R,f.ranges.forEach(L=>{a.Range.foreach(L,(q,X)=>{R.setValue(q,X,1)})})}p[P].setValue(M,O,1)})})});const E=[],j=[];for(const g in p){const b=p[g],x=U.findAllRectangle(U.createTopMatrixFromMatrix(b));if(!x.length){const I={unitId:o,subUnitId:u,cfId:g};E.push({id:t.DeleteConditionalRuleMutation.id,params:I}),j.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(S.some(I=>I.cfId===g)){const I=N(g),V={unitId:o,subUnitId:u,rule:{...I,ranges:x}};E.push({id:t.AddConditionalRuleMutation.id,params:V}),j.push(t.AddConditionalRuleMutationUndoFactory(this._injector,V))}else{const I=this._conditionalFormattingRuleModel.getRule(o,u,g);if(!I)continue;const V={unitId:o,subUnitId:u,rule:{...I,ranges:x}};E.push({id:t.SetConditionalRuleMutation.id,params:V}),j.push(...t.setConditionalRuleMutationUndoFactory(this._injector,V))}}return{redos:E,undos:j}}};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:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.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(U.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=>U.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}],T=t.setConditionalRuleMutationUndoFactory(this._injector,p);return{redos:y,undos:T}}else{const p={unitId:r,subUnitId:s,cfId:o.cfId},y=[{id:t.DeleteConditionalRuleMutation.id,params:p}],T=t.DeleteConditionalRuleMutationUndoFactory(this._injector,p);return{redos:y,undos:T}}},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(U.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(U.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(U.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,(T,S)=>{const _=a.Rectangle.getPositionRange({startRow:T,startColumn:S,endColumn:S,endRow:T},h),F=a.Rectangle.getPositionRange({startRow:T,startColumn:S,endColumn:S,endRow:T},p),{row:N,col:E}=c(_.startRow,_.startColumn),j=this._conditionalFormattingViewModel.getCellCfs(m,d,N,E),{row:g,col:b}=c(F.startRow,F.startColumn),x=this._conditionalFormattingViewModel.getCellCfs(m,d,g,b);x&&x.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(m,d,I.cfId);if(!M)return;V=new a.ObjectMatrix,M.ranges.forEach(O=>{a.Range.foreach(O,(P,f)=>{V.setValue(P,f,1)})}),v.set(I.cfId,V)}V.realDeleteValue(g,b)}),j&&j.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(m,d,I.cfId);if(!M)return;V=new a.ObjectMatrix,M.ranges.forEach(O=>{a.Range.foreach(O,(P,f)=>{V.setValue(P,f,1)})}),v.set(I.cfId,V)}V.setValue(g,b,1)})})},i=(s,o)=>{var F,N,E;const u=(F=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:F.getUnitId(),v=(E=(N=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:N.getActiveSheet())==null?void 0:E.getSheetId(),c=new Map,m=[],d=[];if(!u||!v)return n();const h=H.virtualizeDiscreteRanges([s,o]),[p,y]=h.ranges,{mapFunc:T}=h,S={row:p.startRow,col:p.startColumn};return H.getAutoFillRepeatRange(p,y).forEach(j=>{e(S,j.repeatStartCell,j.relativeRange,c,T)}),c.forEach((j,g)=>{const b=this._conditionalFormattingRuleModel.getRule(u,v,g);if(!b)return;const x=U.findAllRectangle(U.createTopMatrixFromMatrix(j));if(x.length){const I={unitId:u,subUnitId:v,rule:{...b,ranges:x}};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([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const u=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(T=>T.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(U.SheetInterceptorService)),pe(3,a.Inject(U.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 U.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(U.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(U.SheetInterceptorService)),dt(1,a.Inject(t.ConditionalFormattingService))],ke);const mt=[U.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(U.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,T=(S=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getUnitId();mt.includes(p)&&y.unitId===T&&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 T=(s.getSubunitRules(d.getUnitId(),h.getSheetId())||[]).filter(_=>_.ranges.some(F=>m.some(N=>a.Rectangle.intersects(N,F)))).map(_=>_.ranges).every(_=>U.checkRangesEditablePermission(n,d.getUnitId(),h.getSheetId(),_));c.next(T)})),u=new K.Observable(c=>new K.Observable(m=>{const d=i.onCommandExecuted(h=>{var S;const{id:p,params:y}=h,T=(S=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getUnitId();mt.includes(p)&&y.unitId===T&&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=>U.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:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},In={[k.RibbonDataGroup.RULES]:{[Fe.id]:{order:1,menuItemFactory:bn}}};var xn=Object.getOwnPropertyDescriptor,Tn=(n,e,i,r)=>{for(var s=r>1?void 0:r?xn(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=Tn([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,T={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:T})}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,T={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 N=a.Rectangle.getPositionRange({startRow:_,startColumn:F,endColumn:F,endRow:_},T),E=a.Rectangle.getPositionRange({startRow:_,startColumn:F,endColumn:F,endRow:_},S),j=this._conditionalFormattingViewModel.getCellCfs(d,h,N.startRow,N.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(p,y,E.startRow,E.startColumn);g&&g.forEach(b=>{let x=c.get(b.cfId);if(!c.get(b.cfId)){const I=this._conditionalFormattingRuleModel.getRule(p,y,b.cfId);if(!I)return;x=new a.ObjectMatrix,I.ranges.forEach(V=>{a.Range.foreach(V,(M,O)=>{x.setValue(M,O,1)})}),c.set(b.cfId,x)}x.realDeleteValue(E.startRow,E.startColumn)}),j&&j.forEach(b=>{const x=c.get(b.cfId);x&&x.setValue(E.startRow,E.startColumn,1)})})},r=(o,u,v)=>{var N;const{range:c,unitId:m,subUnitId:d}=this._painterConfig,h=o!==m||d!==u,p=new Map,y=[],T=[];if(!o||!u||!m||!d)return e();const S=(N=this._conditionalFormattingRuleModel.getSubunitRules(m,d))!=null?N:[];S==null||S.forEach(E=>{const{ranges:j,cfId:g}=E;if(j.some(b=>a.Rectangle.intersects(c,b))){const b=new a.ObjectMatrix;h||j.forEach(x=>{a.Range.foreach(x,(I,V)=>{b.setValue(I,V,1)})}),p.set(g,b)}});const _={row:c.startRow,col:c.startColumn};return _n(c,v).forEach(E=>{i(_,{row:E.startRange.startRow,col:E.startRange.startColumn},E.repeatRelativeRange,p,{targetUnitId:o,targetSubUnitId:u})}),p.forEach((E,j)=>{if(h){const g=this._conditionalFormattingRuleModel.getRule(o,u,j),b=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(g)if(b.length){const x={unitId:o,subUnitId:u,rule:{...g,ranges:b}};y.push({id:t.SetConditionalRuleMutation.id,params:x}),T.push(...t.setConditionalRuleMutationUndoFactory(this._injector,x))}else{const x={unitId:o,subUnitId:u,cfId:g.cfId};y.push({id:t.DeleteConditionalRuleMutation.id,params:x}),T.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,x))}else if(b.length){const x=this._conditionalFormattingRuleModel.getRule(m,d,j);if(x){const I={unitId:o,subUnitId:u,rule:{...a.Tools.deepClone(x),cfId:this._conditionalFormattingRuleModel.createCfId(o,u),ranges:b}};y.push({id:t.AddConditionalRuleMutation.id,params:I}),T.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const g=this._conditionalFormattingRuleModel.getRule(m,d,j);if(!g)return;const b=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(b.length){const x={unitId:m,subUnitId:d,rule:{...g,ranges:b}};y.push({id:t.SetConditionalRuleMutation.id,params:x}),T.push(...t.setConditionalRuleMutationUndoFactory(this._injector,x))}else{const x={unitId:m,subUnitId:d,cfId:g.cfId};y.push({id:t.DeleteConditionalRuleMutation.id,params:x}),T.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,x))}}}),{undos:T,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(U.SheetsSelectionsService)),le(4,a.Inject(t.ConditionalFormattingRuleModel)),le(5,a.Inject(t.ConditionalFormattingViewModel))],De);var Nn=Object.getOwnPropertyDescriptor,jn=(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},We=(n,e)=>(i,r)=>e(i,r,n);let Le=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)})}};Le=jn([We(0,a.Inject(t.ConditionalFormattingViewModel)),We(1,a.IUniverInstanceService),We(2,ht.IRenderManagerService)],Le);var En=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,wn=(n,e,i)=>e in n?En(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],[Le]]),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],[Le]])}_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;
|
|
2
|
+
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(Te,{},m))});case t.CFRuleType.highlightCell:{const{ul:c,st:m,it:d,bl:h,bg:p,cl:y}=e.style,T=(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,N=(o=p==null?void 0:p.rgb)!=null?o:t.DEFAULT_BG_COLOR,E=(u=y==null?void 0:y.rgb)!=null?u:t.DEFAULT_FONT_COLOR,j={textDecoration:(v=`${T?"underline":""} ${S?"line-through":""}`.replace(/^ /,""))!=null?v:void 0,backgroundColor:N,color:E};return l.jsx("div",{className:w.clsx(s,{"univer-font-bold":F,"univer-italic":_}),style:j,children:"123"})}}},Re=w.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",w.borderClassName),ne=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),$e=n=>{var T;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=(T=u.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:T.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(xe.FormulaEditor,{ref:h,className:w.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",w.borderClassName),initValue:m,unitId:v,subUnitId:c,isFocus:p,onChange:(S="")=>{r(S||"")},onFocus:()=>y(!0)})}):l.jsx(w.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}),[T,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 L;if(!r||r.config.length!==3)return 50;const R=(L=r.config[1])==null?void 0:L.value.value;return R===void 0?50:R}),[N,E]=C.useState(()=>{var L;if(!r)return 90;const R=(L=r.config[r.config.length-1])==null?void 0:L.value.value;return R===void 0?90:R}),[j,g]=C.useState(()=>{var R;const f="#d0d9fb";return r&&((R=r.config[0])==null?void 0:R.color)||f}),[b,x]=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,V]=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:L,maxType:q,minValue:X,medianValue:J,maxValue:ie,minColor:se,medianColor:D,maxColor:A}=f,B=[];return B.push({color:se,value:{type:R,value:X}}),L!=="none"&&B.push({color:D,value:{type:L,value:J}}),B.push({color:A,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:T,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),[M,c,d,p,T,_,N,j,b,I,e]);const O=f=>{n.onChange(M(f))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",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:T,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})})}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",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(w.Select,{className:"univer-flex-shrink-0",options:o,value:c,onChange:f=>{m(f);const R=t.createDefaultValueByValueType(f,10);S(R),O({minType:f,medianType:d,maxType:p,minValue:R,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"min",className:"univer-ml-1",value:T,type:c,onChange:f=>{S(f),O({minType:c,medianType:d,maxType:p,minValue:f,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx(re,{className:"univer-ml-1",color:j,onChange:f=>{g(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:f,medianColor:b,maxColor:I})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600dark:!univer-text-gray-200",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(w.Select,{className:"univer-flex-shrink-0",options:u,value:d,onChange:f=>{h(f);const R=t.createDefaultValueByValueType(f,50);F(R),O({minType:c,medianType:f,maxType:p,minValue:T,medianValue:R,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"median",className:"univer-ml-1",value:_,type:d,onChange:f=>{F(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:f,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),d!=="none"&&l.jsx(re,{className:"univer-ml-1",color:b,onChange:f=>{x(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:j,medianColor:f,maxColor:I})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",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(w.Select,{className:"univer-flex-shrink-0",options:v,value:p,onChange:f=>{y(f);const R=t.createDefaultValueByValueType(f,90);E(R),O({minType:c,medianType:d,maxType:f,minValue:T,medianValue:_,maxValue:R,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"max",className:"univer-ml-1",value:N,type:p,onChange:f=>{E(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:f,minColor:j,medianColor:b,maxColor:I})}}),l.jsx(re,{className:"univer-ml-1",color:I,onChange:f=>{V(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:j,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 N;((N=d.current)==null?void 0:N.isClickOutSide(_))&&p(!1)});const y=C.useRef(r),T=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(xe.FormulaEditor,{ref:d,className:w.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",w.borderClassName),initValue:_,unitId:c,subUnitId:m,isFocus:h,onChange:(F="")=>{e(F||"")},onFocus:()=>p(!0)})})}return l.jsx(w.InputNumber,{className:i,value:Number(r)||0,disabled:u,onChange:_=>{e(_||0)},...T})},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,T]=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,N]=C.useState(()=>{var L;if(!r)return 0;const R=((L=r.config)==null?void 0:L.min)||{};return R.type===t.CFValueType.formula?R.value||"=":R.value||0}),[E,j]=C.useState(()=>{var L;if(!r)return 100;const R=((L=r.config)==null?void 0:L.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),x=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 x({isGradient:s,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}}),[s,F,y,E,S,u,c,e,g]);const I=f=>{n.onChange(x(f))},V=f=>{v(f),I({isGradient:s,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:f,nativeColor:c,isShowValue:g})},M=f=>{m(f),I({isGradient:s,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:f,isShowValue:g})},O=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 dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:x({isGradient:s,minValue:F,minValueType:y,maxValue:E,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 dark:!univer-text-gray-200",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(w.RadioGroup,{value:s,onChange:f=>{o(f),I({isGradient:f,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})},children:[l.jsx(w.Radio,{value:"0",children:l.jsx("span",{className:"univer-text-xs",children:i.t("sheet.cf.panel.pureColor")})}),l.jsx(w.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(w.Checkbox,{checked:!g,onChange:f=>{b(!f),I({isGradient:f,minValue:F,minValueType:y,maxValue:E,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 dark:!univer-text-gray-200",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:V})]})]})]}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.valueType.min")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(w.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:y,onChange:f=>{T(f);const R=t.createDefaultValueByValueType(f,10);N(R),I({isGradient:s,minValue:R,minValueType:f,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}}),l.jsx(rt,{id:"min",className:"univer-ml-3",disabled:!O(y),type:y,value:F,onChange:f=>{N(f||0),I({isGradient:s,minValue:f||0,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.valueType.max")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(w.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:p,value:S,onChange:f=>{_(f);const R=t.createDefaultValueByValueType(f,90);j(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:!O(S),id:"max",type:S,value:E,onChange:f=>{j(f||0),I({isGradient:s,minValue:F,minValueType:y,maxValue:f||0,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}})]})]})]})},Ne=n=>[a.BooleanNumber.FALSE,void 0].includes(n)?a.BooleanNumber.TRUE:a.BooleanNumber.FALSE,je=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,T]=C.useState(()=>{var x;const b="#2f56ef";return(x=e==null?void 0:e.cl)!=null&&x.rgb?e.cl.rgb:b}),[S,_]=C.useState(()=>{var x;const b="#e8ecfc";return(x=e==null?void 0:e.bg)!=null&&x.rgb?e.bg.rgb:b}),F=s.get("BoldSingle"),N=s.get("ItalicSingle"),E=s.get("UnderlineSingle"),j=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:w.clsx("univer-my-2.5 univer-flex univer-justify-between",r),children:[F&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(o||a.BooleanNumber.FALSE)}),onClick:()=>u(Ne(o)),children:l.jsx(F,{})}),N&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(v||a.BooleanNumber.FALSE)}),onClick:()=>c(Ne(v)),children:l.jsx(N,{})}),E&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(m||a.BooleanNumber.FALSE)}),onClick:()=>d(Ne(m)),children:l.jsx(E,{})}),j&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(h||a.BooleanNumber.FALSE)}),onClick:()=>p(Ne(h)),children:l.jsx(j,{})}),l.jsx(re,{color:y,onChange:T,iconId:"FontColor"}),l.jsx(re,{color:S,onChange:_,iconId:"PaintBucket"})]})},Pt=n=>{var j;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=((j=n.rule)==null?void 0:j.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({}),[T,S]=C.useState(()=>(v==null?void 0:v.subType)===t.CFSubRuleType.formula?v.value:"="),[_,F]=C.useState(void 0),N=g=>({style:g.style,value:T,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});C.useEffect(()=>i.intercept(i.getInterceptPoints().submit,{handler(){return N({style:p})}}),[p,T,i]),C.useEffect(()=>i.intercept(i.getInterceptPoints().beforeSubmit,{handler:(b,x,I)=>_||T.length===1||!T.startsWith("=")?(F(r.t("sheet.cf.errorMessage.formulaError")),!1):I(b)}),[_,T]);const E=g=>{e(N(g))};return k.useSidebarClick(g=>{var x;((x=h.current)==null?void 0:x.isClickOutSide(g))&&d(!1)}),l.jsxs("div",{ref:c,children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:"univer-mt-3",children:l.jsx(xe.FormulaEditor,{ref:h,className:w.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",w.borderClassName),errorText:_,isFocus:m,initValue:T,unitId:o.getUnitId(),subUnitId:u==null?void 0:u.getSheetId(),onFocus:()=>{d(!0)},onChange:g=>{S(g),E({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:N({style:p})})}),l.jsx(nt,{style:v==null?void 0:v.style,className:"univer-mt-3",onChange:g=>{y(g),E({style:g})}})]})},Ee=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,T]=C.useState(""),[S,_]=C.useState(()=>Array.isArray(s)?s[0]===void 0?0:s[0]:0),[F,N]=C.useState(""),[E,j]=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,E]);break}}},[e]),C.useEffect(()=>{const x=o.intercept(o.getInterceptPoints().beforeSubmit,{handler:(I,V,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):(T(u.t("sheet.cf.errorMessage.notBlank")),!1)}return M(I)}});return()=>{x()}},[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 x=I=>{p(I),r(I)};return l.jsx("div",{className:"univer-mt-3",children:l.jsx(Ee,{errorText:y,children:l.jsx(w.Input,{value:h,onChange:I=>{T(""),x(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 x=I=>{c(I||0),r(I||0),d("")};return l.jsx("div",{className:"univer-mt-3",children:l.jsx(Ee,{errorText:m,children:l.jsx(w.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:v,onChange:x})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(i)){const x=V=>{_(V||0),r([V||0,E]),N("")},I=V=>{j(V||0),r([S,V||0]),b("")};return l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(Ee,{errorText:F,children:l.jsx(w.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:S,onChange:x})}),l.jsx(Ee,{errorText:g,children:l.jsx(w.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:E,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 j;const{interceptorManager:e,onChange:i}=n,r=k.useDependency(a.LocaleService),s=((j=n.rule)==null?void 0:j.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 x;const g="";return s?(x=s.value)!=null?x:t.createDefaultValue(s.subType,s.operator):g}),[y,T]=C.useState({}),S=C.useMemo(()=>g=>{var b,x,I,V,M,O,P,f,R,L,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:(x=g.operator)!=null?x:m,style:(I=g.style)!=null?I:y,value:(V=g.value)!=null?V: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:(O=g.operator)!=null?O: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:(L=g.operator)!=null?L: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,x=it(b,r),I=x&&x[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}))},N=g=>{p(g),i(S({value:g}))},E=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 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[l.jsx(w.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:o,options:v}),(c==null?void 0:c.length)&&l.jsx(w.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:N},E),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=>{T(g),i(S({style:g}))}})]})},Ct=(n,e)=>(t.iconMap[n]||[])[Number(e)]||"",Lt=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(w.InputNumber,{className:w.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(xe.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)}),At=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:"univer-cursor-pointer univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",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(Te,{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:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",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],T=t.createDefaultValue(t.CFSubRuleType.number,y.operator);v(T,p)};return C.useMemo(()=>i.map((h,p)=>{const y=r[p],T=Ct(h.iconType,h.iconId),S=p===i.length-1,_=p===0,F=i[p-1],N=(F==null?void 0:F.value.type)===t.CFValueType.formula?s.t("sheet.cf.valueType.formula"):F==null?void 0:F.value.value,E=(j,g)=>{const b={...h,iconId:g,iconType:j};e([String(p)],b)};return l.jsxs("div",{className:p?"univer-mt-6":"univer-mt-3",children:[l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",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 dark:!univer-text-gray-200",children:["(",s.t("sheet.cf.iconSet.when"),s.t(`sheet.cf.symbol.${t.getOppositeOperator(F.operator)}`),N,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(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx($t,{onClick:E,iconId:h.iconId,iconType:h.iconType})}),children:l.jsxs("div",{className:w.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all dark:!univer-text-gray-200 hover:univer-border-primary-600",w.borderClassName),children:[T?l.jsx("img",{src:T,className:"univer-size-4",draggable:!1}):l.jsx(Te,{className:"univer-size-4"}),l.jsx(Ae,{})]})})}),S?l.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[s.t("sheet.cf.iconSet.rule"),l.jsxs("span",{className:"univer-font-medium",children:[s.t("sheet.cf.iconSet.when"),s.t(`sheet.cf.symbol.${t.getOppositeOperator(F.operator)}`),N,S?"":` ${s.t("sheet.cf.iconSet.and")} `]})]}):l.jsx(w.Select,{options:o,value:h.operator,onChange:j=>{c(j,p)}})]}),S?l.jsx("div",{}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",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:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[l.jsx(w.Select,{className:"univer-flex-shrink-0",options:u,value:h.value.type,onChange:j=>{m(j,p)}}),l.jsx("div",{children:l.jsx(Lt,{id:p,type:h.value.type,error:y,value:h.value.value||"",onChange:j=>{v(j,p)}})})]})]})]},p)}),[i,r])},Ht=n=>{var j;const{interceptorManager:e}=n,i=((j=n.rule)==null?void 0:j.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,x,I)=>x===I.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:u,iconId:String(x)}:ot(u,x,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,x)=>b?l.jsx("img",{className:"univer-size-5",src:b},x):l.jsx(Te,{className:"univer-size-5"},x))})},[c]),y=g=>{if(g.reduce((x,I,V)=>x.preType&&!x.result||g.length-1===V?x:I.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:x.preType?{result:x.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 x={};return g.forEach((I,V,M)=>{if(V-1<0||V===M.length-1)return;const P=g[V-1],f=t.getOppositeOperator(P.operator);t.compareWithNumber({operator:f,value:P.value.value},I.value.value)||(x[V]=`${r.t(`sheet.cf.form.${f}`,String(P.value.value))} `)}),x}return{}},T=(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]||[],x=new Array(b.length).fill("").map((I,V,M)=>ot(g,V,M));m(x),o(y(x))};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,x)=>{const I=c.length-1-x,V=g[I];b.iconId=V.iconId,b.iconType=V.iconType}),m([...c])},F=k.useDependency(k.ILayoutService),[N,E]=C.useState();return k.useScrollYOverContainer(N,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(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx(At,{ref:g=>{!N&&g&&E(g)},iconType:u,onClick:S})}),children:l.jsxs("div",{className:w.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",w.borderClassName),children:[p,l.jsx(Ae,{})]})})}),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(w.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(w.Checkbox,{checked:!d,onChange:g=>{h(!g)}}),r.t("sheet.cf.iconSet.onlyShowIcon")]})]}),l.jsx(Bt,{errorMap:s,onChange:T,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,N=s==null?void 0:s.type;if(!s)return F;switch(N){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 N=s==null?void 0:s.type;if(!s)return 10;switch(N){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.rank:return s.value||10}}return 10}),[d,h]=C.useState(()=>{const N=s==null?void 0:s.type;if(!s)return!1;switch(N){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.rank:return s.isPercent||!1}}return!1}),[p,y]=C.useState({}),T=F=>{const{type:N,isPercent:E,value:j,style:g}=F;if(N==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!1,value:j,style:g};if(N==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!0,value:j,style:g};if(N==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:g};if(N==="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 T({type:u,isPercent:d,value:c,style:p})}}),[u,d,c,p,i]);const S=F=>{e(T(F))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsx(w.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(w.InputNumber,{min:1,max:1e3,value:c,onChange:F=>{const N=F||0;m(N),S({type:u,isPercent:d,value:N,style:p})}}),l.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[l.jsx(w.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:T({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 x,I,V;const e=k.useDependency(a.LocaleService),i=k.useDependency(a.ICommandService),r=k.useDependency(a.IUniverInstanceService),s=k.useDependency(t.ConditionalFormattingRuleModel),o=k.useDependency(U.SheetsSelectionsService),u=at(r),v=lt(r),[c,m]=C.useState(void 0),d=C.useRef((I=(x=n.rule)==null?void 0:x.ranges)!=null?I:[]),h=C.useMemo(()=>{var O,P,f;let M=(O=n.rule)==null?void 0:O.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 L=Ge.serializeRange(R);return L==="NaN"?"":L}).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,T]=C.useState(()=>{var P,f;const M=(P=n.rule)==null?void 0:P.rule.type,O=p[0].value;if(!M)return O;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 O}),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(O=>{if(O.id===U.RemoveSheetMutation.id){const P=O.params;P.subUnitId===v&&P.unitId===u&&n.onCancel()}O.id===U.SetWorksheetActiveOperation.id&&n.onCancel()});return()=>M.dispose()},[]);const N=M=>{S.current=M},E=M=>{const O=M.split(",").filter(P=>!!P).map(Ge.deserializeRangeWithSheet).map(P=>P.range);d.current=O},j=()=>{if(c)return;const O=(()=>{const f=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!f)throw new Error("No active sheet found");return d.current.map(q=>U.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),L=lt(r);if(!R||!L)throw new Error("No active sheet found");let q={};n.rule&&n.rule.cfId?(q={...n.rule,ranges:O,rule:f},i.executeCommand(t.SetCfCommand.id,{unitId:R,subUnitId:L,rule:q}),n.onCancel()):(q={cfId:s.createCfId(R,L),ranges:O,rule:f,stopIfTrue:!1},i.executeCommand(t.AddCfCommand.id,{unitId:R,subUnitId:L,rule:q}),n.onCancel())}}},g=()=>{n.onCancel()},b=(M,O)=>{M?O.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 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),l.jsxs("div",{className:"univer-mt-4",children:[l.jsx(xe.RangeSelector,{unitId:u,subUnitId:v,initialValue:h,onChange:(M,O)=>E(O),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 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),l.jsx(w.Select,{className:"univer-mt-4 univer-w-full",value:y,options:p,onChange:M=>T(M)}),l.jsx(F,{interceptorManager:_,rule:(V=n.rule)==null?void 0:V.rule,onChange:N}),l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[l.jsx(w.Button,{onClick:g,children:e.t("sheet.cf.panel.cancel")}),l.jsx(w.Button,{className:"univer-ml-3",variant:"primary",onClick:j,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(U.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(),[T,S]=C.useState([]),[_,F]=C.useState("2"),[N,E]=C.useState(0),[j,g]=C.useState(-1),[b,x]=C.useState(ut),I=C.useRef(null),V=[{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 A=s.getCurrentLastSelection();if(!A)return[];const B=A.range;return D.filter(G=>G.ranges.some(z=>a.Rectangle.intersects(z,B)))}else if(_==="2")return[...D];return[]},[O,P]=C.useState(M);H.useHighlightRange(T),C.useEffect(()=>{const D=o.onCommandExecuted(A=>{A.id===U.SetWorksheetActiveOperation.id&&E(Math.random())});return()=>D.dispose()}),C.useEffect(()=>{P(M)},[_,N,h,y]),C.useEffect(()=>{if(_==="2")return;const D=new K.Observable(A=>{const B=[U.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&&A.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(()=>{E(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(void 0)},150);const ee=()=>{z&&clearTimeout(z),z=null},te=_e=>{_e.propertyName==="width"&&(ee(),W.next(void 0))};return G.addEventListener("transitionend",te),()=>{ee(),G.removeEventListener("transitionend",te)}}}).pipe(K.debounceTime(16)).subscribe(()=>{x(D())});return()=>{B.unsubscribe()}},[]);const f=D=>{var W;const A=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),B=(W=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:W.getSheetId();if(!A||!B)throw new Error("No active sheet found");o.executeCommand(t.DeleteCfCommand.id,{unitId:A,subUnitId:B,cfId:D.cfId})},R=(D,A)=>{g(A.y)},L=(D,A,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 xt=O.length;return Math.min(xt-1,Math.max(0,It))},ee=O[z(A.y)].cfId,te=O[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>A.y?"after":"before"}})},q=()=>{n.onCreate()},X=()=>{_==="2"?o.executeCommand(t.ClearWorksheetCfCommand.id):_==="1"&&O.map(A=>({unitId:h,subUnitId:y,cfId:A.cfId})).forEach(A=>{o.executeCommand(t.DeleteCfCommand.id,A)})},J=C.useMemo(()=>{const D=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet();return O.filter(B=>{const W=B.ranges;return U.checkRangesEditablePermission(v,D.getUnitId(),A.getSheetId(),W)})},[O]),ie=J.map((D,A)=>({i:D.cfId,x:0,w:12,y:A,h:1,isResizable:!1})),se=C.useMemo(()=>{const D=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet();return O.every(B=>{const W=B.ranges;return U.checkRangesEditablePermission(v,D.getUnitId(),A.getSheetId(),W)})},[O]);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(w.Select,{className:"univer-w-36",options:V,value:_,onChange:D=>{F(D)}})).map((D,A)=>l.jsx("span",{children:D},A))}),l.jsxs("div",{className:"univer-flex univer-justify-end",children:[l.jsx(w.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,{})})}),O.length&&se?l.jsx(w.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(w.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:ie,cols:12,rowHeight:60,width:b,margin:[0,10],onDragStop:L,onDragStart:R,children:J==null?void 0:J.map((D,A)=>l.jsx("div",{children:l.jsxs("div",{className:w.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-bg-gray-100 dark:!univer-bg-gray-700":j===A}),onMouseMove:()=>{D.ranges!==T&&S(D.ranges)},onMouseLeave:()=>S([]),onClick:()=>{e(D)},children:[l.jsx("div",{className:w.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:B=>B.stopPropagation(),children:l.jsx(ft,{})}),l.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",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:w.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":j===A}),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.disposeWithMe(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(U.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=>U.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 T=this._conditionalFormattingViewModel.getCellCfs(e,i,d,p);T&&(T.forEach(S=>m.add(S.cfId)),s.setValue(h,y,T.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:x,col:I}=d(g,b),V=this._conditionalFormattingViewModel.getCellCfs(o,u,x,I);V&&V.forEach(M=>{if(!p[M.cfId]){const O=new a.ObjectMatrix;p[M.cfId]=O;const P=this._conditionalFormattingRuleModel.getRule(o,u,M.cfId);P==null||P.ranges.forEach(f=>{a.Range.foreach(f,(R,L)=>{O.setValue(R,L,1)})})}p[M.cfId].realDeleteValue(x,I)})});const{matrix:y,info:T}=this._copyInfo,S=[];let _=this._conditionalFormattingRuleModel.createCfId(o,u);const F={},N=g=>{if(F[g])return F[g];const b=T==null?void 0:T.cfMap[g],x=[...this._conditionalFormattingRuleModel.getSubunitRules(o,u)||[],...S].find(I=>a.Tools.diffValue(I.rule,b));if(x)return F[g]=x,x;{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,x,I)=>{const V=a.Rectangle.getPositionRange({startRow:b,endRow:b,startColumn:x,endColumn:x},g.startRange),{row:M,col:O}=d(V.startRow,V.startColumn);I.forEach(P=>{if(!p[P]){const f=N(P),R=new a.ObjectMatrix;p[P]=R,f.ranges.forEach(L=>{a.Range.foreach(L,(q,X)=>{R.setValue(q,X,1)})})}p[P].setValue(M,O,1)})})});const E=[],j=[];for(const g in p){const b=p[g],x=U.findAllRectangle(U.createTopMatrixFromMatrix(b));if(!x.length){const I={unitId:o,subUnitId:u,cfId:g};E.push({id:t.DeleteConditionalRuleMutation.id,params:I}),j.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(S.some(I=>I.cfId===g)){const I=N(g),V={unitId:o,subUnitId:u,rule:{...I,ranges:x}};E.push({id:t.AddConditionalRuleMutation.id,params:V}),j.push(t.AddConditionalRuleMutationUndoFactory(this._injector,V))}else{const I=this._conditionalFormattingRuleModel.getRule(o,u,g);if(!I)continue;const V={unitId:o,subUnitId:u,rule:{...I,ranges:x}};E.push({id:t.SetConditionalRuleMutation.id,params:V}),j.push(...t.setConditionalRuleMutationUndoFactory(this._injector,V))}}return{redos:E,undos:j}}};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:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.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(U.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=>U.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}],T=t.setConditionalRuleMutationUndoFactory(this._injector,p);return{redos:y,undos:T}}else{const p={unitId:r,subUnitId:s,cfId:o.cfId},y=[{id:t.DeleteConditionalRuleMutation.id,params:p}],T=t.DeleteConditionalRuleMutationUndoFactory(this._injector,p);return{redos:y,undos:T}}},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(U.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(U.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(U.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,(T,S)=>{const _=a.Rectangle.getPositionRange({startRow:T,startColumn:S,endColumn:S,endRow:T},h),F=a.Rectangle.getPositionRange({startRow:T,startColumn:S,endColumn:S,endRow:T},p),{row:N,col:E}=c(_.startRow,_.startColumn),j=this._conditionalFormattingViewModel.getCellCfs(m,d,N,E),{row:g,col:b}=c(F.startRow,F.startColumn),x=this._conditionalFormattingViewModel.getCellCfs(m,d,g,b);x&&x.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(m,d,I.cfId);if(!M)return;V=new a.ObjectMatrix,M.ranges.forEach(O=>{a.Range.foreach(O,(P,f)=>{V.setValue(P,f,1)})}),v.set(I.cfId,V)}V.realDeleteValue(g,b)}),j&&j.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(m,d,I.cfId);if(!M)return;V=new a.ObjectMatrix,M.ranges.forEach(O=>{a.Range.foreach(O,(P,f)=>{V.setValue(P,f,1)})}),v.set(I.cfId,V)}V.setValue(g,b,1)})})},i=(s,o)=>{var F,N,E;const u=(F=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:F.getUnitId(),v=(E=(N=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:N.getActiveSheet())==null?void 0:E.getSheetId(),c=new Map,m=[],d=[];if(!u||!v)return n();const h=H.virtualizeDiscreteRanges([s,o]),[p,y]=h.ranges,{mapFunc:T}=h,S={row:p.startRow,col:p.startColumn};return H.getAutoFillRepeatRange(p,y).forEach(j=>{e(S,j.repeatStartCell,j.relativeRange,c,T)}),c.forEach((j,g)=>{const b=this._conditionalFormattingRuleModel.getRule(u,v,g);if(!b)return;const x=U.findAllRectangle(U.createTopMatrixFromMatrix(j));if(x.length){const I={unitId:u,subUnitId:v,rule:{...b,ranges:x}};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([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const u=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(T=>T.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(U.SheetInterceptorService)),pe(3,a.Inject(U.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 U.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(U.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(U.SheetInterceptorService)),dt(1,a.Inject(t.ConditionalFormattingService))],ke);const mt=[U.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(U.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,T=(S=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getUnitId();mt.includes(p)&&y.unitId===T&&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 T=(s.getSubunitRules(d.getUnitId(),h.getSheetId())||[]).filter(_=>_.ranges.some(F=>m.some(N=>a.Rectangle.intersects(N,F)))).map(_=>_.ranges).every(_=>U.checkRangesEditablePermission(n,d.getUnitId(),h.getSheetId(),_));c.next(T)})),u=new K.Observable(c=>new K.Observable(m=>{const d=i.onCommandExecuted(h=>{var S;const{id:p,params:y}=h,T=(S=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getUnitId();mt.includes(p)&&y.unitId===T&&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=>U.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:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},In={[k.RibbonDataGroup.RULES]:{[Fe.id]:{order:1,menuItemFactory:bn}}};var xn=Object.getOwnPropertyDescriptor,Tn=(n,e,i,r)=>{for(var s=r>1?void 0:r?xn(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=Tn([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,T={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:T})}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,T={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 N=a.Rectangle.getPositionRange({startRow:_,startColumn:F,endColumn:F,endRow:_},T),E=a.Rectangle.getPositionRange({startRow:_,startColumn:F,endColumn:F,endRow:_},S),j=this._conditionalFormattingViewModel.getCellCfs(d,h,N.startRow,N.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(p,y,E.startRow,E.startColumn);g&&g.forEach(b=>{let x=c.get(b.cfId);if(!c.get(b.cfId)){const I=this._conditionalFormattingRuleModel.getRule(p,y,b.cfId);if(!I)return;x=new a.ObjectMatrix,I.ranges.forEach(V=>{a.Range.foreach(V,(M,O)=>{x.setValue(M,O,1)})}),c.set(b.cfId,x)}x.realDeleteValue(E.startRow,E.startColumn)}),j&&j.forEach(b=>{const x=c.get(b.cfId);x&&x.setValue(E.startRow,E.startColumn,1)})})},r=(o,u,v)=>{var N;const{range:c,unitId:m,subUnitId:d}=this._painterConfig,h=o!==m||d!==u,p=new Map,y=[],T=[];if(!o||!u||!m||!d)return e();const S=(N=this._conditionalFormattingRuleModel.getSubunitRules(m,d))!=null?N:[];S==null||S.forEach(E=>{const{ranges:j,cfId:g}=E;if(j.some(b=>a.Rectangle.intersects(c,b))){const b=new a.ObjectMatrix;h||j.forEach(x=>{a.Range.foreach(x,(I,V)=>{b.setValue(I,V,1)})}),p.set(g,b)}});const _={row:c.startRow,col:c.startColumn};return _n(c,v).forEach(E=>{i(_,{row:E.startRange.startRow,col:E.startRange.startColumn},E.repeatRelativeRange,p,{targetUnitId:o,targetSubUnitId:u})}),p.forEach((E,j)=>{if(h){const g=this._conditionalFormattingRuleModel.getRule(o,u,j),b=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(g)if(b.length){const x={unitId:o,subUnitId:u,rule:{...g,ranges:b}};y.push({id:t.SetConditionalRuleMutation.id,params:x}),T.push(...t.setConditionalRuleMutationUndoFactory(this._injector,x))}else{const x={unitId:o,subUnitId:u,cfId:g.cfId};y.push({id:t.DeleteConditionalRuleMutation.id,params:x}),T.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,x))}else if(b.length){const x=this._conditionalFormattingRuleModel.getRule(m,d,j);if(x){const I={unitId:o,subUnitId:u,rule:{...a.Tools.deepClone(x),cfId:this._conditionalFormattingRuleModel.createCfId(o,u),ranges:b}};y.push({id:t.AddConditionalRuleMutation.id,params:I}),T.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const g=this._conditionalFormattingRuleModel.getRule(m,d,j);if(!g)return;const b=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(b.length){const x={unitId:m,subUnitId:d,rule:{...g,ranges:b}};y.push({id:t.SetConditionalRuleMutation.id,params:x}),T.push(...t.setConditionalRuleMutationUndoFactory(this._injector,x))}else{const x={unitId:m,subUnitId:d,cfId:g.cfId};y.push({id:t.DeleteConditionalRuleMutation.id,params:x}),T.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,x))}}}),{undos:T,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(U.SheetsSelectionsService)),le(4,a.Inject(t.ConditionalFormattingRuleModel)),le(5,a.Inject(t.ConditionalFormattingViewModel))],De);var Nn=Object.getOwnPropertyDescriptor,jn=(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},We=(n,e)=>(i,r)=>e(i,r,n);let Le=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)})}};Le=jn([We(0,a.Inject(t.ConditionalFormattingViewModel)),We(1,a.IUniverInstanceService),We(2,ht.IRenderManagerService)],Le);var En=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,wn=(n,e,i)=>e in n?En(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],[Le]]),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],[Le]])}_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;
|
package/lib/es/index.js
CHANGED
|
@@ -2484,7 +2484,9 @@ let Qe = class extends ce {
|
|
|
2484
2484
|
this._sidebarDisposable = this._sidebarService.open(r);
|
|
2485
2485
|
}
|
|
2486
2486
|
_initPanel() {
|
|
2487
|
-
this.
|
|
2487
|
+
this.disposeWithMe(
|
|
2488
|
+
this._componentManager.register(ht, Vi)
|
|
2489
|
+
);
|
|
2488
2490
|
}
|
|
2489
2491
|
};
|
|
2490
2492
|
Qe = Fi([
|
package/lib/index.js
CHANGED
|
@@ -2484,7 +2484,9 @@ let Qe = class extends ce {
|
|
|
2484
2484
|
this._sidebarDisposable = this._sidebarService.open(r);
|
|
2485
2485
|
}
|
|
2486
2486
|
_initPanel() {
|
|
2487
|
-
this.
|
|
2487
|
+
this.disposeWithMe(
|
|
2488
|
+
this._componentManager.register(ht, Vi)
|
|
2489
|
+
);
|
|
2488
2490
|
}
|
|
2489
2491
|
};
|
|
2490
2492
|
Qe = Fi([
|
package/lib/umd/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(D,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","rxjs","@univerjs/engine-render","rxjs/operators"],i):(D=typeof globalThis<"u"?globalThis:D||self,i(D.UniverSheetsConditionalFormattingUi={},D.UniverCore,D.UniverSheetsConditionalFormatting,D.UniverSheets,D.UniverUi,D.React,D.React,D.UniverDesign,D.UniverEngineFormula,D.UniverSheetsFormulaUi,D.UniverSheetsUi,D.rxjs,D.UniverEngineRender,D.rxjs.operators))})(this,function(D,i,r,P,j,s,m,O,Be,pe,W,X,ar,fe){"use strict";var Ot=Object.defineProperty;var Ut=(D,i,r)=>i in D?Ot(D,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):D[i]=r;var ee=(D,i,r)=>Ut(D,typeof i!="symbol"?i+"":i,r);const He={type:i.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u}=e,c=t.get(r.ConditionalFormattingRuleModel),p=t.get(i.ICommandService),o=t.get(i.IUniverInstanceService),v=P.getSheetCommandTarget(o);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=c.createCfId(d,f),S={ranges:l,cfId:h,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:u,style:n}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:S})}},We={type:i.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,config:n,stopIfTrue:a}=e,u=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.ICommandService),p=t.get(i.IUniverInstanceService),o=P.getSheetCommandTarget(p);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=u.createCfId(v,d),h={ranges:l,cfId:f,stopIfTrue:!!a,rule:{type:r.CFRuleType.colorScale,config:n}};return c.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}},qe={type:i.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,min:n,max:a,nativeColor:u,positiveColor:c,isGradient:p,stopIfTrue:o,isShowValue:v}=e,d=t.get(r.ConditionalFormattingRuleModel),f=t.get(i.IUniverInstanceService),h=P.getSheetCommandTarget(f);if(!h)return!1;const{unitId:S,subUnitId:_}=h,b=t.get(i.ICommandService),E=d.createCfId(S,_),N={ranges:l,cfId:E,stopIfTrue:!!o,rule:{type:r.CFRuleType.dataBar,isShowValue:v,config:{min:n,max:a,nativeColor:u,positiveColor:c,isGradient:p}}};return b.executeCommand(r.AddConditionalRuleMutation.id,{unitId:S,subUnitId:_,rule:N})}},Ge={type:i.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a}=e,u=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.ICommandService),p=t.get(i.IUniverInstanceService),o=P.getSheetCommandTarget(p);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=u.createCfId(v,d),h={ranges:l,cfId:f,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:n}};return c.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}},ze={type:i.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u,value:c}=e,p=t.get(r.ConditionalFormattingRuleModel),o=t.get(i.ICommandService),v=t.get(i.IUniverInstanceService),d=P.getSheetCommandTarget(v);if(!d)return!1;const{unitId:f,subUnitId:h}=d,S=p.createCfId(f,h);let _;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)){const b=c;if(b.length!==2||!Array.isArray(b))return!1;_={ranges:l,cfId:S,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:n,value:b}}}else{const b=c;if(typeof b!="number")return!1;_={ranges:l,cfId:S,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:n,value:b}}}return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:h,rule:_})}},Ye={type:i.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,isPercent:u,isBottom:c,value:p}=e,o=t.get(r.ConditionalFormattingRuleModel),v=t.get(i.IUniverInstanceService),d=t.get(i.ICommandService),f=P.getSheetCommandTarget(v);if(!f)return!1;const{unitId:h,subUnitId:S}=f,_=o.createCfId(h,S),b={ranges:l,cfId:_,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:u,isBottom:c,style:n,value:p}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:S,rule:b})}},Ze={type:i.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u,value:c}=e,p=t.get(r.ConditionalFormattingRuleModel),o=t.get(i.IUniverInstanceService),v=P.getSheetCommandTarget(o);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=t.get(i.ICommandService),S=p.createCfId(d,f),_={ranges:l,cfId:S,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:u,style:n,value:c}};return h.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:_})}},Ke={type:i.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u}=e,c=t.get(r.ConditionalFormattingRuleModel),p=t.get(i.IUniverInstanceService),o=t.get(i.ICommandService),v=P.getSheetCommandTarget(p);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=c.createCfId(d,f),S={ranges:l,cfId:h,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:u,style:n}};return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:S})}},Xe={type:i.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a}=e,u=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.IUniverInstanceService),p=t.get(i.ICommandService),o=P.getSheetCommandTarget(c);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=u.createCfId(v,d),h={ranges:l,cfId:f,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:n}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}};var K=function(){return K=Object.assign||function(t){for(var e,l=1,n=arguments.length;l<n;l++){e=arguments[l];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},K.apply(this,arguments)},Tr=function(t,e){var l={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(l[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a<n.length;a++)e.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(t,n[a])&&(l[n[a]]=t[n[a]]);return l},le=m.forwardRef(function(t,e){var l=t.icon,n=t.id,a=t.className,u=t.extend,c=Tr(t,["icon","id","className","extend"]),p="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),o=m.useRef("_".concat(Nr()));return lr(l,"".concat(n),{defIds:l.defIds,idSuffix:o.current},K({ref:e,className:p},c),u)});function lr(t,e,l,n,a){return m.createElement(t.tag,K(K({key:e},_r(t,l,a)),n),(xr(t,l).children||[]).map(function(u,c){return lr(u,"".concat(e,"-").concat(t.tag,"-").concat(c),l,void 0,a)}))}function _r(t,e,l){var n=K({},t.attrs);l!=null&&l.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=l.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(u){var c=u[0],p=u[1];c==="mask"&&typeof p=="string"&&(n[c]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var a=e.defIds;return!a||a.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(u){var c=u[0],p=u[1];typeof p=="string"&&(n[c]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function xr(t,e){var l,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((l=t.children)===null||l===void 0)&&l.length)?K(K({},t),{children:t.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.indexOf(a.attrs.id)>-1?K(K({},a),{attrs:K(K({},a.attrs),{id:a.attrs.id+e.idSuffix})}):a})}):t}function Nr(){return Math.random().toString(36).substring(2,8)}le.displayName="UniverIcon";var Er={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Re=m.forwardRef(function(t,e){return m.createElement(le,Object.assign({},t,{id:"delete-single",ref:e,icon:Er}))});Re.displayName="DeleteSingle";var Rr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},ur=m.forwardRef(function(t,e){return m.createElement(le,Object.assign({},t,{id:"increase-single",ref:e,icon:Rr}))});ur.displayName="IncreaseSingle";var Mr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Me=m.forwardRef(function(t,e){return m.createElement(le,Object.assign({},t,{id:"more-down-single",ref:e,icon:Mr}))});Me.displayName="MoreDownSingle";var wr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},ir=m.forwardRef(function(t,e){return m.createElement(le,Object.assign({},t,{id:"sequence-single",ref:e,icon:wr}))});ir.displayName="SequenceSingle";var Vr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_436_41",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.35 0.48H16.35V16.48H0.35z"}}]},{tag:"g",attrs:{mask:"url(#mask0_436_41)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z"}},{tag:"path",attrs:{fill:"#E5E5E5",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z"}}]}]},he=m.forwardRef(function(t,e){return m.createElement(le,Object.assign({},t,{id:"slash-single",ref:e,icon:Vr}))});he.displayName="SlashSingle";const re=t=>{const{color:e,onChange:l,disable:n=!1,iconId:a="PaintBucket",className:u,isNeedDropdownIcon:c=!0}=t,p=j.useDependency(j.ComponentManager),o=m.useMemo(()=>new i.ColorKit(e),[e]),v=p.get(a);return v?n?s.jsx(v,{className:O.clsx("univer-fill-primary-600",u),extend:{colorChannel1:o.isValid?e:""}}):s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(O.ColorPicker,{value:e,onChange:l})}),children:s.jsxs("span",{className:O.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",u),children:[s.jsx(v,{className:"univer-fill-primary-600",extend:{colorChannel1:o.isValid?e:""}}),c&&s.jsx(Me,{className:"univer-ml-1.5 univer-text-gray-400"})]})}):null},ue=t=>{var u,c,p;const e=t.rule;if(!e)return null;const l=m.useMemo(()=>{if(e.type===r.CFRuleType.colorScale){const o=e.config.map((f,h)=>({color:new i.ColorKit(f.color),value:h})),v=o.length-1;return new Array(5).fill("").map((f,h,S)=>h*v/(S.length-1)).map(f=>r.getColorScaleFromValue(o,f))}return null},[e]),n=m.useMemo(()=>{if(e.type===r.CFRuleType.iconSet)return e.config.map(o=>{const v=r.iconMap[o.iconType];return v&&v[Number(o.iconId)]})},[e]),a=`univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center
|
|
2
|
-
univer-justify-center univer-text-xs`;switch(e.type){case r.CFRuleType.dataBar:{const{isGradient:o}=e.config,v=o?`linear-gradient(to right, ${e.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,d=o?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||r.defaultDataBarNativeColor})`:e.config.nativeColor;return s.jsxs("div",{className:a,children:[s.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:d,border:`1px solid ${e.config.nativeColor||r.defaultDataBarNativeColor}`}}),s.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:v,border:`1px solid ${e.config.positiveColor||r.defaultDataBarPositiveColor}`}})]})}case r.CFRuleType.colorScale:return l&&s.jsx("div",{className:a,children:l.map((o,v)=>s.jsx("div",{className:"univer-h-full",style:{width:`${100/l.length}%`,background:o}},v))});case r.CFRuleType.iconSet:return n&&s.jsx("div",{className:a,children:n.map((o,v)=>o?s.jsx("img",{className:"univer-h-full",src:o,draggable:!1},v):s.jsx(he,{},v))});case r.CFRuleType.highlightCell:{const{ul:o,st:v,it:d,bl:f,bg:h,cl:S}=e.style,_=(o==null?void 0:o.s)===i.BooleanNumber.TRUE,b=(v==null?void 0:v.s)===i.BooleanNumber.TRUE,E=d===i.BooleanNumber.TRUE,N=f===i.BooleanNumber.TRUE,R=(u=h==null?void 0:h.rgb)!=null?u:r.DEFAULT_BG_COLOR,w=(c=S==null?void 0:S.rgb)!=null?c:r.DEFAULT_FONT_COLOR,M={textDecoration:(p=`${_?"underline":""} ${b?"line-through":""}`.replace(/^ /,""))!=null?p:void 0,backgroundColor:R,color:w};return s.jsx("div",{className:O.clsx(a,{"univer-font-bold":N,"univer-italic":E}),style:M,children:"123"})}}},ye=O.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",O.borderClassName),te=(t,e)=>({label:e.t(`sheet.cf.valueType.${t}`),value:t}),Je=t=>{var _;const{type:e,className:l,onChange:n,id:a,value:u}=t,c=j.useDependency(i.IUniverInstanceService),p=c.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(_=c.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:_.getSheetId(),v=m.useMemo(()=>String(u).startsWith("=")?String(u):"=",[u]),d=m.useMemo(()=>[r.CFValueType.max,r.CFValueType.min,"none"].includes(e)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),f=m.useRef(null),[h,S]=m.useState(!1);return j.useSidebarClick(b=>{var N;((N=f.current)==null?void 0:N.isClickOutSide(b))&&S(!1)}),e===r.CFValueType.formula?s.jsx("div",{className:"univer-ml-1 univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:f,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",O.borderClassName),initValue:v,unitId:p,subUnitId:o,isFocus:h,onChange:(b="")=>{n(b||"")},onFocus:()=>S(!0)})}):s.jsx(O.InputNumber,{className:l,value:Number(t.value)||0,onChange:b=>t.onChange(b||0),...d})},Or=t=>{var L;const{interceptorManager:e}=t,l=j.useDependency(i.LocaleService),n=((L=t.rule)==null?void 0:L.type)===r.CFRuleType.colorScale?t.rule:void 0,a=[te(r.CFValueType.num,l),te(r.CFValueType.percent,l),te(r.CFValueType.percentile,l),te(r.CFValueType.formula,l)],u=[te(r.CFValueType.min,l),...a],c=[te("none",l),...a],p=[te(r.CFValueType.max,l),...a],[o,v]=m.useState(()=>{var x;const g=r.CFValueType.min;return n&&((x=n.config[0])==null?void 0:x.value.type)||g}),[d,f]=m.useState(()=>{var x;const g="none";return!n||n.config.length!==3?g:((x=n.config[1])==null?void 0:x.value.type)||g}),[h,S]=m.useState(()=>{var x;const g=r.CFValueType.max;return n&&((x=n.config[n.config.length-1])==null?void 0:x.value.type)||g}),[_,b]=m.useState(()=>{if(!n)return 10;const x=n.config[0];return(x==null?void 0:x.value.value)===void 0?10:x==null?void 0:x.value.value}),[E,N]=m.useState(()=>{var F;if(!n||n.config.length!==3)return 50;const x=(F=n.config[1])==null?void 0:F.value.value;return x===void 0?50:x}),[R,w]=m.useState(()=>{var F;if(!n)return 90;const x=(F=n.config[n.config.length-1])==null?void 0:F.value.value;return x===void 0?90:x}),[M,y]=m.useState(()=>{var x;const g="#d0d9fb";return n&&((x=n.config[0])==null?void 0:x.color)||g}),[I,T]=m.useState(()=>{var x;const g="#7790f3";return!n||n.config.length!==3?g:((x=n.config[1])==null?void 0:x.color)||g}),[C,U]=m.useState(()=>{var x;const g="#2e55ef";return n&&((x=n.config[n.config.length-1])==null?void 0:x.color)||g}),V=m.useMemo(()=>g=>{const{minType:x,medianType:F,maxType:G,minValue:J,medianValue:Q,maxValue:de,minColor:ve,medianColor:A,maxColor:$}=g,H=[];return H.push({color:ve,value:{type:x,value:J}}),F!=="none"&&H.push({color:A,value:{type:F,value:Q}}),H.push({color:$,value:{type:G,value:de}}),{config:H.map((z,Y)=>({...z,index:Y})),type:r.CFRuleType.colorScale}},[]);m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return V({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),[V,o,d,h,_,E,R,M,I,C,e]);const k=g=>{t.onChange(V(g))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:V({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:C})})}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.valueType.min")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:u,value:o,onChange:g=>{v(g);const x=r.createDefaultValueByValueType(g,10);b(x),k({minType:g,medianType:d,maxType:h,minValue:x,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"min",className:"univer-ml-1",value:_,type:o,onChange:g=>{b(g),k({minType:o,medianType:d,maxType:h,minValue:g,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(re,{className:"univer-ml-1",color:M,onChange:g=>{y(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:g,medianColor:I,maxColor:C})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.medianValue")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:c,value:d,onChange:g=>{f(g);const x=r.createDefaultValueByValueType(g,50);N(x),k({minType:o,medianType:g,maxType:h,minValue:_,medianValue:x,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"median",className:"univer-ml-1",value:E,type:d,onChange:g=>{N(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:g,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),d!=="none"&&s.jsx(re,{className:"univer-ml-1",color:I,onChange:g=>{T(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:M,medianColor:g,maxColor:C})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.valueType.max")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:p,value:h,onChange:g=>{S(g);const x=r.createDefaultValueByValueType(g,90);w(x),k({minType:o,medianType:d,maxType:g,minValue:_,medianValue:E,maxValue:x,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"max",className:"univer-ml-1",value:R,type:h,onChange:g=>{w(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:g,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(re,{className:"univer-ml-1",color:C,onChange:g=>{U(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:g})}})]})]})},ie=(t,e)=>({label:e.t(`sheet.cf.valueType.${t}`),value:t}),sr=t=>{var b;const{onChange:e,className:l,value:n,type:a,id:u,disabled:c=!1}=t,p=j.useDependency(i.IUniverInstanceService),o=p.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),v=(b=p.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId(),d=m.useRef(null),[f,h]=m.useState(!1);j.useSidebarClick(E=>{var R;((R=d.current)==null?void 0:R.isClickOutSide(E))&&h(!1)});const S=m.useRef(n),_=m.useMemo(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(a)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[a]);if(a===r.CFValueType.formula){const E=String(S.current).startsWith("=")?String(S.current)||"":"=";return s.jsx("div",{className:"univer-ml-3 univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:d,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",O.borderClassName),initValue:E,unitId:o,subUnitId:v,isFocus:f,onChange:(N="")=>{e(N||"")},onFocus:()=>h(!0)})})}return s.jsx(O.InputNumber,{className:l,value:Number(n)||0,disabled:c,onChange:E=>{e(E||0)},..._})},Ur=t=>{var L;const{interceptorManager:e}=t,l=j.useDependency(i.LocaleService),n=((L=t.rule)==null?void 0:L.type)===r.CFRuleType.dataBar?t.rule:void 0,[a,u]=m.useState(()=>{var x;const g="0";return n?(x=n.config)!=null&&x.isGradient?"1":"0":g}),[c,p]=m.useState(()=>{var g;return n&&((g=n.config)==null?void 0:g.positiveColor)||r.defaultDataBarPositiveColor}),[o,v]=m.useState(()=>{var g;return n&&((g=n.config)==null?void 0:g.nativeColor)||r.defaultDataBarNativeColor}),d=[ie(r.CFValueType.num,l),ie(r.CFValueType.percent,l),ie(r.CFValueType.percentile,l),ie(r.CFValueType.formula,l)],f=[ie(r.CFValueType.min,l),...d],h=[ie(r.CFValueType.max,l),...d],[S,_]=m.useState(()=>{var x;const g=f[0].value;return n&&((x=n.config)==null?void 0:x.min.type)||g}),[b,E]=m.useState(()=>{var x;const g=h[0].value;return n&&((x=n.config)==null?void 0:x.max.type)||g}),[N,R]=m.useState(()=>{var F;if(!n)return 0;const x=((F=n.config)==null?void 0:F.min)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value||0}),[w,M]=m.useState(()=>{var F;if(!n)return 100;const x=((F=n.config)==null?void 0:F.max)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value===void 0?100:x.value}),[y,I]=m.useState(()=>n?n.isShowValue===void 0?!0:!!n.isShowValue:!0),T=g=>({config:{min:{type:g.minValueType,value:g.minValue},max:{type:g.maxValueType,value:g.maxValue},isGradient:g.isGradient==="1",positiveColor:g.positiveColor||r.defaultDataBarPositiveColor,nativeColor:g.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:g.isShowValue});m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return T({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}}),[a,N,S,w,b,c,o,e,y]);const C=g=>{t.onChange(T(g))},U=g=>{p(g),C({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:g,nativeColor:o,isShowValue:y})},V=g=>{v(g),C({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:g,isShowValue:y})},k=g=>d.map(x=>x.value).includes(g);return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:T({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})})}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.fillType")}),s.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[s.jsxs(O.RadioGroup,{value:a,onChange:g=>{u(g),C({isGradient:g,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})},children:[s.jsx(O.Radio,{value:"0",children:s.jsx("span",{className:"univer-text-xs",children:l.t("sheet.cf.panel.pureColor")})}),s.jsx(O.Radio,{value:"1",children:s.jsx("span",{className:"univer-text-xs",children:l.t("sheet.cf.panel.gradient")})})]}),s.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:!y,onChange:g=>{I(!g),C({isGradient:g,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:!g})}}),l.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.colorSet")}),s.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[s.jsxs("div",{className:"univer-flex univer-items-center",children:[s.jsx("div",{className:"univer-text-xs",children:l.t("sheet.cf.panel.native")}),s.jsx(re,{color:o,onChange:V})]}),s.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[s.jsx("div",{className:"univer-text-xs",children:l.t("sheet.cf.panel.positive")}),s.jsx(re,{color:c,onChange:U})]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.valueType.min")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:f,value:S,onChange:g=>{_(g);const x=r.createDefaultValueByValueType(g,10);R(x),C({isGradient:a,minValue:x,minValueType:g,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}}),s.jsx(sr,{id:"min",className:"univer-ml-3",disabled:!k(S),type:S,value:N,onChange:g=>{R(g||0),C({isGradient:a,minValue:g||0,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.valueType.max")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:b,onChange:g=>{E(g);const x=r.createDefaultValueByValueType(g,90);M(x),C({isGradient:a,minValue:N,minValueType:S,maxValue:x,maxValueType:g,positiveColor:c,nativeColor:o,isShowValue:y})}}),s.jsx(sr,{className:"univer-ml-3",disabled:!k(b),id:"max",type:b,value:w,onChange:g=>{M(g||0),C({isGradient:a,minValue:N,minValueType:S,maxValue:g||0,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}})]})]})]})},we=t=>[i.BooleanNumber.FALSE,void 0].includes(t)?i.BooleanNumber.TRUE:i.BooleanNumber.FALSE,Ve=t=>t!==i.BooleanNumber.FALSE,Qe=t=>{const{style:e,onChange:l,className:n}=t,a=j.useDependency(j.ComponentManager),[u,c]=m.useState(()=>{if(e!=null&&e.bl)return e.bl}),[p,o]=m.useState(()=>{if(e!=null&&e.it)return e.it}),[v,d]=m.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[f,h]=m.useState(()=>{if(e!=null&&e.st)return e.st.s}),[S,_]=m.useState(()=>{var T;const I="#2f56ef";return(T=e==null?void 0:e.cl)!=null&&T.rgb?e.cl.rgb:I}),[b,E]=m.useState(()=>{var T;const I="#e8ecfc";return(T=e==null?void 0:e.bg)!=null&&T.rgb?e.bg.rgb:I}),N=a.get("BoldSingle"),R=a.get("ItalicSingle"),w=a.get("UnderlineSingle"),M=a.get("StrikethroughSingle");m.useEffect(()=>{const I={bl:u,it:p};S!==void 0&&(I.cl={rgb:S}),b!==void 0&&(I.bg={rgb:b}),f!==void 0&&(I.st={s:f}),v!==void 0&&(I.ul={s:v}),l(r.removeUndefinedAttr(I))},[u,p,v,f,S,b]);const y="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return s.jsxs("div",{className:O.clsx("univer-my-2.5 univer-flex univer-justify-between",n),children:[N&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(u||i.BooleanNumber.FALSE)}),onClick:()=>c(we(u)),children:s.jsx(N,{})}),R&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(p||i.BooleanNumber.FALSE)}),onClick:()=>o(we(p)),children:s.jsx(R,{})}),w&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(v||i.BooleanNumber.FALSE)}),onClick:()=>d(we(v)),children:s.jsx(w,{})}),M&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(f||i.BooleanNumber.FALSE)}),onClick:()=>h(we(f)),children:s.jsx(M,{})}),s.jsx(re,{color:S,onChange:_,iconId:"FontColor"}),s.jsx(re,{color:b,onChange:E,iconId:"PaintBucket"})]})},kr=t=>{var M;const{onChange:e,interceptorManager:l}=t,n=j.useDependency(i.LocaleService),u=j.useDependency(i.IUniverInstanceService).getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),c=u.getActiveSheet(),p=((M=t.rule)==null?void 0:M.type)===r.CFRuleType.highlightCell?t.rule:void 0,o=m.useRef(null),[v,d]=m.useState(!1),f=m.useRef(null),[h,S]=m.useState({}),[_,b]=m.useState(()=>(p==null?void 0:p.subType)===r.CFSubRuleType.formula?p.value:"="),[E,N]=m.useState(void 0),R=y=>({style:y.style,value:_,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});m.useEffect(()=>l.intercept(l.getInterceptPoints().submit,{handler(){return R({style:h})}}),[h,_,l]),m.useEffect(()=>l.intercept(l.getInterceptPoints().beforeSubmit,{handler:(I,T,C)=>E||_.length===1||!_.startsWith("=")?(N(n.t("sheet.cf.errorMessage.formulaError")),!1):C(I)}),[E,_]);const w=y=>{e(R(y))};return j.useSidebarClick(y=>{var T;((T=f.current)==null?void 0:T.isClickOutSide(y))&&d(!1)}),s.jsxs("div",{ref:o,children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:"univer-mt-3",children:s.jsx(pe.FormulaEditor,{ref:f,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",O.borderClassName),errorText:E,isFocus:v,initValue:_,unitId:u.getUnitId(),subUnitId:c==null?void 0:c.getSheetId(),onFocus:()=>{d(!0)},onChange:y=>{b(y),w({style:h})},onVerify:(y,I)=>{!y||I.length===1?N(n.t("sheet.cf.errorMessage.formulaError")):N(void 0)}})}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:R({style:h})})}),s.jsx(Qe,{style:p==null?void 0:p.style,className:"univer-mt-3",onChange:y=>{S(y),w({style:y})}})]})},Oe=t=>s.jsxs("div",{style:{position:"relative"},children:[s.jsx("div",{style:{position:"absolute",zIndex:999,bottom:"-13px",fontSize:"10px",color:"red"},children:t.errorText}),t.children]}),B=(t,e)=>({label:e.t(`sheet.cf.operator.${t}`),value:t}),Pr=t=>{const{type:e,operator:l,onChange:n,value:a,interceptorManager:u}=t,c=j.useDependency(i.LocaleService),[p,o]=m.useState(()=>typeof a=="number"?a:0),[v,d]=m.useState(""),[f,h]=m.useState(()=>typeof a=="string"?a:""),[S,_]=m.useState(""),[b,E]=m.useState(()=>Array.isArray(a)?a[0]===void 0?0:a[0]:0),[N,R]=m.useState(""),[w,M]=m.useState(()=>Array.isArray(a)?a[1]===void 0?100:a[1]:100),[y,I]=m.useState("");switch(m.useEffect(()=>{switch(e){case r.CFSubRuleType.text:{[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(l)&&n(f);break}case r.CFSubRuleType.number:{[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(l)&&n(p),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(l)&&n([b,w]);break}}},[e]),m.useEffect(()=>{const T=u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(C,U,V)=>{switch(e){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(l))return f?V(C):(_(c.t("sheet.cf.errorMessage.notBlank")),!1)}return V(C)}});return()=>{T()}},[e,p,f,l]),e){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(l)){const T=C=>{h(C),n(C)};return s.jsx("div",{className:"univer-mt-3",children:s.jsx(Oe,{errorText:S,children:s.jsx(O.Input,{value:f,onChange:C=>{_(""),T(C)}})})})}break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(l)){const T=C=>{o(C||0),n(C||0),d("")};return s.jsx("div",{className:"univer-mt-3",children:s.jsx(Oe,{errorText:v,children:s.jsx(O.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:p,onChange:T})})})}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(l)){const T=U=>{E(U||0),n([U||0,w]),R("")},C=U=>{M(U||0),n([b,U||0]),I("")};return s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(Oe,{errorText:N,children:s.jsx(O.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:b,onChange:T})}),s.jsx(Oe,{errorText:y,children:s.jsx(O.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:w,onChange:C})})]})}}}return null},cr=(t,e)=>{switch(t){case r.CFSubRuleType.text:return[B(r.CFTextOperator.containsText,e),B(r.CFTextOperator.notContainsText,e),B(r.CFTextOperator.beginsWith,e),B(r.CFTextOperator.endsWith,e),B(r.CFTextOperator.equal,e),B(r.CFTextOperator.notEqual,e),B(r.CFTextOperator.containsBlanks,e),B(r.CFTextOperator.notContainsBlanks,e),B(r.CFTextOperator.containsErrors,e),B(r.CFTextOperator.notContainsErrors,e)];case r.CFSubRuleType.number:return[B(r.CFNumberOperator.between,e),B(r.CFNumberOperator.notBetween,e),B(r.CFNumberOperator.equal,e),B(r.CFNumberOperator.notEqual,e),B(r.CFNumberOperator.greaterThan,e),B(r.CFNumberOperator.greaterThanOrEqual,e),B(r.CFNumberOperator.lessThan,e),B(r.CFNumberOperator.lessThanOrEqual,e)];case r.CFSubRuleType.timePeriod:return[B(r.CFTimePeriodOperator.yesterday,e),B(r.CFTimePeriodOperator.today,e),B(r.CFTimePeriodOperator.tomorrow,e),B(r.CFTimePeriodOperator.last7Days,e),B(r.CFTimePeriodOperator.lastWeek,e),B(r.CFTimePeriodOperator.thisWeek,e),B(r.CFTimePeriodOperator.nextWeek,e),B(r.CFTimePeriodOperator.lastMonth,e),B(r.CFTimePeriodOperator.thisMonth,e),B(r.CFTimePeriodOperator.nextMonth,e)]}},or=t=>{var M;const{interceptorManager:e,onChange:l}=t,n=j.useDependency(i.LocaleService),a=((M=t.rule)==null?void 0:M.type)===r.CFRuleType.highlightCell?t.rule:void 0,[u,c]=m.useState(()=>{const y=r.CFSubRuleType.text;return a&&a.subType||y}),p=[{value:r.CFSubRuleType.text,label:n.t("sheet.cf.subRuleType.text")},{value:r.CFSubRuleType.number,label:n.t("sheet.cf.subRuleType.number")},{value:r.CFSubRuleType.timePeriod,label:n.t("sheet.cf.subRuleType.timePeriod")},{value:r.CFSubRuleType.duplicateValues,label:n.t("sheet.cf.subRuleType.duplicateValues")},{value:r.CFSubRuleType.uniqueValues,label:n.t("sheet.cf.subRuleType.uniqueValues")}],o=m.useMemo(()=>cr(u,n),[u]),[v,d]=m.useState(()=>{const y=o?o[0].value:void 0;return a&&a.operator||y}),[f,h]=m.useState(()=>{var T;const y="";return a?(T=a.value)!=null?T:r.createDefaultValue(a.subType,a.operator):y}),[S,_]=m.useState({}),b=m.useMemo(()=>y=>{var I,T,C,U,V,k,L,g,x,F,G,J,Q,de,ve;switch(y.subType||u){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(v))return{type:r.CFRuleType.highlightCell,subType:(I=y.subType)!=null?I:u,operator:(T=y.operator)!=null?T:v,style:(C=y.style)!=null?C:S,value:(U=y.value)!=null?U:f};break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(v))return{type:r.CFRuleType.highlightCell,subType:(V=y.subType)!=null?V:u,operator:(k=y.operator)!=null?k:v,style:(L=y.style)!=null?L:S,value:(g=y.value)!=null?g:f};if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(v))return{type:r.CFRuleType.highlightCell,subType:(x=y.subType)!=null?x:u,operator:(F=y.operator)!=null?F:v,style:(G=y.style)!=null?G:S,value:(J=y.value)!=null?J:f};break}}return{type:r.CFRuleType.highlightCell,subType:(Q=y.subType)!=null?Q:u,operator:(de=y.operator)!=null?de:v,style:(ve=y.style)!=null?ve:S}},[u,v,f,S]);m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return b({})}}),[b,e]),m.useEffect(()=>{p.some(y=>y.value===u)||c(p[0].value)},[p]);const E=y=>{const I=y,T=cr(I,n),C=T&&T[0].value;c(I),d(C),C&&h(r.createDefaultValue(I,C)),l(b({subType:I,operator:C}))},N=y=>{const I=y;d(I),l(b({operator:I}))},R=y=>{h(y),l(b({value:y}))},w=m.useMemo(()=>`${u}_${v}_${Math.random()}`,[u,v]);return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:E,value:u,options:p}),(o==null?void 0:o.length)&&s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:N,value:v||"",options:o})]}),s.jsx(Pr,{value:f,interceptorManager:e,type:u,operator:v,rule:a,onChange:R},w),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:b({})})}),s.jsx(Qe,{style:a==null?void 0:a.style,className:"univer-ml-1",onChange:y=>{_(y),l(b({style:y}))}})]})},dr=(t,e)=>(r.iconMap[t]||[])[Number(e)]||"",Dr=t=>{var d;const{error:e,type:l,onChange:n}=t,a=j.useDependency(i.IUniverInstanceService),u=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(d=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),p=m.useRef(null),[o,v]=m.useState(!1);return j.useSidebarClick(f=>{var S;((S=p.current)==null?void 0:S.isClickOutSide(f))&&v(!1)}),s.jsx("div",{className:"univer-relative",children:l!==r.CFValueType.formula?s.jsxs(s.Fragment,{children:[s.jsx(O.InputNumber,{className:O.clsx({"univer-border-red-500":e}),value:Number(t.value)||0,onChange:f=>n(f!=null?f:0)}),e&&s.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):s.jsx("div",{className:"univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:p,initValue:String(t.value),unitId:u,subUnitId:c,isFocus:o,onChange:(f="")=>{n(f||"")},onFocus:()=>v(!0)})})})},vr=(t,e,l)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(l.length-1-e)*10},iconType:t,iconId:String(e)}),jr=m.forwardRef((t,e)=>{const{onClick:l}=t,n=j.useDependency(i.LocaleService),a=u=>{l(u)};return s.jsx("div",{ref:e,className:"univer-w-80",children:r.iconGroup.map((u,c)=>s.jsxs("div",{className:"univer-mb-3",children:[s.jsx("div",{className:"univer-mb-1 univer-text-sm",children:n.t(u.title)}),s.jsx("div",{className:"univer-flex univer-flex-wrap",children:u.group.map(p=>s.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{a(p.name)},children:s.jsx("a",{className:"univer-cursor-pointer univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",children:p.list.map((o,v)=>s.jsx("img",{className:"univer-size-5",src:o,draggable:!1},v))})},p.name))})]},c))})}),Lr=t=>{const{onClick:e}=t,l=m.useMemo(()=>{const a=[];for(const u in r.iconMap){const c=r.iconMap[u],p=u;c.forEach((o,v)=>{a.push({iconType:p,base64:o,iconId:String(v)})})}return a},[]),n=a=>{e(a.iconType,a.iconId)};return s.jsxs("div",{children:[s.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>n({iconType:r.EMPTY_ICON_TYPE,iconId:""}),children:[s.jsx(he,{className:"univer-size-5"}),s.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),s.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:l.map(a=>s.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",children:s.jsx("img",{className:"univer-size-5",src:a.base64,draggable:!1,onClick:()=>n(a)})},`${a.iconType}_${a.iconId}`))})]})},Ar=t=>{const{onChange:e,configList:l,errorMap:n={}}=t,a=j.useDependency(i.LocaleService),u=[{label:a.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:a.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],c=[{label:a.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:a.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:a.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:a.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],p=(f,h)=>{e([String(h),"value","value"],f)},o=(f,h)=>{e([String(h),"operator"],f);const S=r.createDefaultValue(r.CFSubRuleType.number,f);p(S,h)},v=(f,h)=>{e([String(h),"value","type"],f);const S=l[h],_=r.createDefaultValue(r.CFSubRuleType.number,S.operator);p(_,h)};return m.useMemo(()=>l.map((f,h)=>{const S=n[h],_=dr(f.iconType,f.iconId),b=h===l.length-1,E=h===0,N=l[h-1],R=(N==null?void 0:N.value.type)===r.CFValueType.formula?a.t("sheet.cf.valueType.formula"):N==null?void 0:N.value.value,w=(M,y)=>{const I={...f,iconId:y,iconType:M};e([String(h)],I)};return s.jsxs("div",{className:h?"univer-mt-6":"univer-mt-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[s.jsxs("div",{className:"univer-w-[45%]",children:[a.t("sheet.cf.iconSet.icon"),h+1]}),s.jsx("div",{className:"univer-w-[45%]",children:s.jsxs(s.Fragment,{children:[!E&&!b&&a.t("sheet.cf.iconSet.rule"),!E&&!b&&s.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:["(",a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${r.getOppositeOperator(N.operator)}`),R,b?"":` ${a.t("sheet.cf.iconSet.and")} `,")"]})]})})]}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[s.jsx("div",{className:"univer-flex univer-items-center",children:s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(Lr,{onClick:w,iconId:f.iconId,iconType:f.iconType})}),children:s.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all dark:!univer-text-gray-200 hover:univer-border-primary-600",O.borderClassName),children:[_?s.jsx("img",{src:_,className:"univer-size-4",draggable:!1}):s.jsx(he,{className:"univer-size-4"}),s.jsx(Me,{})]})})}),b?s.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[a.t("sheet.cf.iconSet.rule"),s.jsxs("span",{className:"univer-font-medium",children:[a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${r.getOppositeOperator(N.operator)}`),R,b?"":` ${a.t("sheet.cf.iconSet.and")} `]})]}):s.jsx(O.Select,{options:u,value:f.operator,onChange:M=>{o(M,h)}})]}),b?s.jsx("div",{}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[s.jsx("div",{children:a.t("sheet.cf.iconSet.type")}),s.jsx("div",{children:a.t("sheet.cf.iconSet.value")})]}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:c,value:f.value.type,onChange:M=>{v(M,h)}}),s.jsx("div",{children:s.jsx(Dr,{id:h,type:f.value.type,error:S,value:f.value.value||"",onChange:M=>{p(M,h)}})})]})]})]},h)}),[l,n])},Fr=t=>{var M;const{interceptorManager:e}=t,l=((M=t.rule)==null?void 0:M.type)===r.CFRuleType.iconSet?t.rule:void 0,n=j.useDependency(i.LocaleService),[a,u]=m.useState({}),[c,p]=m.useState(()=>{const y=Object.keys(r.iconMap)[0];if(l&&l.config.length){const I=l.config[0].iconType;if(!l.config.some(C=>C.iconType!==I))return I}return y}),[o,v]=m.useState(()=>{if(l&&l.config.length)return i.Tools.deepClone(l==null?void 0:l.config);const y=r.iconMap[c]||[];return new Array(y.length).fill("").map((I,T,C)=>T===C.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:c,iconId:String(T)}:vr(c,T,C))}),[d,f]=m.useState(()=>l?!!l.isShowValue:!0),h=m.useMemo(()=>{const y=o.map(I=>dr(I.iconType,I.iconId));return s.jsx("div",{className:"univer-flex univer-items-center",children:y.map((I,T)=>I?s.jsx("img",{className:"univer-size-5",src:I},T):s.jsx(he,{className:"univer-size-5"},T))})},[o]),S=y=>{if(y.reduce((T,C,U)=>T.preType&&!T.result||y.length-1===U?T:C.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:T.preType?{result:T.preType===C.value.type,preType:C.value.type}:{result:!0,preType:C.value.type},{result:!0,preType:""}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(y[0].value.type)){const T={};return y.forEach((C,U,V)=>{if(U-1<0||U===V.length-1)return;const L=y[U-1],g=r.getOppositeOperator(L.operator);r.compareWithNumber({operator:g,value:L.value.value},C.value.value)||(T[U]=`${n.t(`sheet.cf.form.${g}`,String(L.value.value))} `)}),T}return{}},_=(y,I)=>{i.get(o,y)!==I&&(i.set(o,y,I),v([...o]),u(S(o)))},b=y=>{p(y);const I=r.iconMap[y]||[],T=new Array(I.length).fill("").map((C,U,V)=>vr(y,U,V));v(T),u(S(T))};m.useEffect(()=>{const y=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:d,config:o}}});return()=>{y()}},[d,o,e]),m.useEffect(()=>{const y=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(a).length===0}});return()=>{y()}},[d,o,e,a]);const E=()=>{const y=o.map(I=>({...I}));o.forEach((I,T)=>{const C=o.length-1-T,U=y[C];I.iconId=U.iconId,I.iconType=U.iconType}),v([...o])},N=j.useDependency(j.ILayoutService),[R,w]=m.useState();return j.useScrollYOverContainer(R,N.rootContainerElement),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:"univer-mt-3",children:s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(jr,{ref:y=>{!R&&y&&w(y)},iconType:c,onClick:b})}),children:s.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",O.borderClassName),children:[h,s.jsx(Me,{})]})})}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[s.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{onChange:E}),n.t("sheet.cf.iconSet.reverseIconOrder")]}),s.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:!d,onChange:y=>{f(!y)}}),n.t("sheet.cf.iconSet.onlyShowIcon")]})]}),s.jsx(Ar,{errorMap:a,onChange:_,configList:o})]})},$r=t=>{var E;const{onChange:e,interceptorManager:l}=t,n=j.useDependency(i.LocaleService),a=((E=t.rule)==null?void 0:E.type)===r.CFRuleType.highlightCell?t.rule:void 0,u=[{label:n.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:n.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:n.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:n.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[c,p]=m.useState(()=>{const N=u[0].value,R=a==null?void 0:a.type;if(!a)return N;switch(R){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(a.operator)?"greaterThanAverage":[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(a.operator)?"lessThanAverage":N;case r.CFSubRuleType.rank:return a.isBottom?"isBottom":"isNotBottom"}}return N}),[o,v]=m.useState(()=>{const R=a==null?void 0:a.type;if(!a)return 10;switch(R){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.rank:return a.value||10}}return 10}),[d,f]=m.useState(()=>{const R=a==null?void 0:a.type;if(!a)return!1;switch(R){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.rank:return a.isPercent||!1}}return!1}),[h,S]=m.useState({}),_=N=>{const{type:R,isPercent:w,value:M,style:y}=N;if(R==="isNotBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:w,isBottom:!1,value:M,style:y};if(R==="isBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:w,isBottom:!0,value:M,style:y};if(R==="greaterThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:y};if(R==="lessThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:y}};m.useEffect(()=>l.intercept(l.getInterceptPoints().submit,{handler(){return _({type:c,isPercent:d,value:o,style:h})}}),[c,d,o,h,l]);const b=N=>{e(_(N))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",value:c,options:u,onChange:N=>{p(N),b({type:N,isPercent:d,value:o,style:h})}}),["isNotBottom","isBottom"].includes(c)&&s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.InputNumber,{min:1,max:1e3,value:o,onChange:N=>{const R=N||0;v(R),b({type:c,isPercent:d,value:R,style:h})}}),s.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:d,onChange:N=>{f(!!N),b({type:c,isPercent:!!N,value:o,style:h})}}),n.t("sheet.cf.valueType.percent")]})]}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:_({type:c,isPercent:d,value:o,style:h})})}),s.jsx(Qe,{style:a==null?void 0:a.style,className:"univer-mt-3",onChange:N=>{S(N),b({type:c,isPercent:d,value:o,style:N})}})]})},Br=i.createInterceptorKey("beforeSubmit"),Hr=i.createInterceptorKey("submit"),pr=t=>t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),fr=t=>{var e;return(e=t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},Wr=t=>{var T,C,U;const e=j.useDependency(i.LocaleService),l=j.useDependency(i.ICommandService),n=j.useDependency(i.IUniverInstanceService),a=j.useDependency(r.ConditionalFormattingRuleModel),u=j.useDependency(P.SheetsSelectionsService),c=pr(n),p=fr(n),[o,v]=m.useState(void 0),d=m.useRef((C=(T=t.rule)==null?void 0:T.ranges)!=null?C:[]),f=m.useMemo(()=>{var k,L,g;let V=(k=t.rule)==null?void 0:k.ranges;return V!=null&&V.length||(V=(g=(L=u.getCurrentSelections())==null?void 0:L.map(x=>x.range))!=null?g:[]),d.current=V,V!=null&&V.length?V.map(x=>{const F=Be.serializeRange(x);return F==="NaN"?"":F}).filter(x=>!!x).join(","):""},[t.rule]),h=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[S,_]=m.useState(()=>{var L,g;const V=(L=t.rule)==null?void 0:L.rule.type,k=h[0].value;if(!V)return k;switch(V){case r.CFRuleType.highlightCell:{switch((g=t.rule)==null?void 0:g.rule.subType){case r.CFSubRuleType.number:case r.CFSubRuleType.text:case r.CFSubRuleType.duplicateValues:case r.CFSubRuleType.uniqueValues:case r.CFSubRuleType.timePeriod:return"1";case r.CFSubRuleType.average:case r.CFSubRuleType.rank:return"2";case r.CFSubRuleType.formula:return"5"}break}case r.CFRuleType.dataBar:return"3";case r.CFRuleType.colorScale:return"4";case r.CFRuleType.iconSet:return"6"}return k}),b=m.useRef(void 0),E=m.useMemo(()=>new i.InterceptorManager({beforeSubmit:Br,submit:Hr}),[]),N=m.useMemo(()=>{switch(S){case"1":return or;case"2":return $r;case"3":return Ur;case"4":return Or;case"5":return kr;case"6":return Fr;default:return or}},[S]);m.useEffect(()=>{const V=l.onCommandExecuted(k=>{if(k.id===P.RemoveSheetMutation.id){const L=k.params;L.subUnitId===p&&L.unitId===c&&t.onCancel()}k.id===P.SetWorksheetActiveOperation.id&&t.onCancel()});return()=>V.dispose()},[]);const R=V=>{b.current=V},w=V=>{const k=V.split(",").filter(L=>!!L).map(Be.deserializeRangeWithSheet).map(L=>L.range);d.current=k},M=()=>{if(o)return;const k=(()=>{const g=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!g)throw new Error("No active sheet found");return d.current.map(G=>P.setEndForRange(G,g.getRowCount(),g.getColumnCount())).filter(G=>!(Number.isNaN(G.startRow)||Number.isNaN(G.startColumn)))})();if(E.fetchThroughInterceptors(E.getInterceptPoints().beforeSubmit)(!0,null)){const g=E.fetchThroughInterceptors(E.getInterceptPoints().submit)(null,null);if(g){const x=pr(n),F=fr(n);if(!x||!F)throw new Error("No active sheet found");let G={};t.rule&&t.rule.cfId?(G={...t.rule,ranges:k,rule:g},l.executeCommand(r.SetCfCommand.id,{unitId:x,subUnitId:F,rule:G}),t.onCancel()):(G={cfId:a.createCfId(x,F),ranges:k,rule:g,stopIfTrue:!1},l.executeCommand(r.AddCfCommand.id,{unitId:x,subUnitId:F,rule:G}),t.onCancel())}}},y=()=>{t.onCancel()},I=(V,k)=>{V?k.length<1?v(e.t("sheet.cf.errorMessage.rangeError")):v(void 0):v(e.t("sheet.cf.errorMessage.rangeError"))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),s.jsxs("div",{className:"univer-mt-4",children:[s.jsx(pe.RangeSelector,{unitId:c,subUnitId:p,initialValue:f,onChange:(V,k)=>w(k),onVerify:I}),o&&s.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:o})]}),s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),s.jsx(O.Select,{className:"univer-mt-4 univer-w-full",value:S,options:h,onChange:V=>_(V)}),s.jsx(N,{interceptorManager:E,rule:(U=t.rule)==null?void 0:U.rule,onChange:R}),s.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[s.jsx(O.Button,{onClick:y,children:e.t("sheet.cf.panel.cancel")}),s.jsx(O.Button,{className:"univer-ml-3",variant:"primary",onClick:M,children:e.t("sheet.cf.panel.submit")})]})]})};var qr=Object.getOwnPropertyDescriptor,Gr=(t,e,l,n)=>{for(var a=n>1?void 0:n?qr(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},zr=(t,e)=>(l,n)=>e(l,n,t);let se=class extends i.Disposable{constructor(e){super();ee(this,"_initLocal",()=>{});ee(this,"_findReplaceIndex",e=>{const l=/\{([^}]+)?\}/g,n=[];let a=l.exec(e);for(;a;)n.push({startIndex:a.index,key:Number(a[1]),endIndex:a.index+a[0].length-1}),a=l.exec(e);return n});this._localeService=e,this._initLocal()}tWithReactNode(e,...l){const n=this._localeService.getLocales(),a=e.split("."),u=n&&this._localeService.resolveKeyPath(n,a);if(typeof u=="string"){const c=[];return this._findReplaceIndex(u).forEach((p,o,v)=>{const d=v[o-1]||{endIndex:-1};if(d.endIndex+1<p.startIndex){const f=u.slice(d.endIndex+1,p.startIndex);f&&c.push(f)}if(l[p.key]&&c.push(l[p.key]),o===v.length-1){const f=u.slice(p.endIndex+1);f&&c.push(f)}}),c}return[]}};se=Gr([zr(0,i.Inject(i.LocaleService))],se);const Yr=(t,e)=>{const l=t.rule;switch(l.type){case r.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case r.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case r.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case r.CFRuleType.highlightCell:switch(l.subType){case r.CFSubRuleType.average:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`,e.t("sheet.cf.subRuleType.average"))}case r.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case r.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case r.CFSubRuleType.number:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`,...Array.isArray(l.value)?l.value.map(a=>String(a)):[String(l.value||"")])}case r.CFSubRuleType.text:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`,l.value||"")}case r.CFSubRuleType.timePeriod:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`)}case r.CFSubRuleType.rank:return l.isPercent?l.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(l.value)):e.t("sheet.cf.preview.describe.topNPercent",String(l.value)):l.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(l.value)):e.t("sheet.cf.preview.describe.topN",String(l.value));case r.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let hr=0;const Zr=t=>{const{onClick:e}=t,l=j.useDependency(r.ConditionalFormattingRuleModel),n=j.useDependency(i.IUniverInstanceService),a=j.useDependency(P.SheetsSelectionsService),u=j.useDependency(i.ICommandService),c=j.useDependency(i.LocaleService),p=j.useDependency(i.Injector),o=j.useDependency(j.ISidebarService),v=j.useDependency(se),d=j.useObservable(()=>n.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),f=d.getUnitId(),h=d.getActiveSheet();if(!h)throw new Error("No active sheet found");const S=h.getSheetId(),[_,b]=m.useState([]),[E,N]=m.useState("2"),[R,w]=m.useState(0),[M,y]=m.useState(-1),[I,T]=m.useState(hr),C=m.useRef(null),U=[{label:c.t("sheet.cf.panel.workSheet"),value:"2"},{label:c.t("sheet.cf.panel.selectedRange"),value:"1"}],V=()=>{const A=l.getSubunitRules(f,S);if(!A||!A.length)return[];if(E==="1"){const $=a.getCurrentLastSelection();if(!$)return[];const H=$.range;return A.filter(z=>z.ranges.some(Y=>i.Rectangle.intersects(Y,H)))}else if(E==="2")return[...A];return[]},[k,L]=m.useState(V);W.useHighlightRange(_),m.useEffect(()=>{const A=u.onCommandExecuted($=>{$.id===P.SetWorksheetActiveOperation.id&&w(Math.random())});return()=>A.dispose()}),m.useEffect(()=>{L(V)},[E,R,f,S]),m.useEffect(()=>{if(E==="2")return;const A=new X.Observable($=>{const H=[P.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],q=u.onCommandExecuted(z=>{const{id:Y,params:ne}=z,ae=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();H.includes(Y)&&ne.unitId===ae&&$.next(null)});return()=>q.dispose()}).pipe(X.debounceTime(16)).subscribe(()=>{L(V)});return()=>{A.unsubscribe()}},[n,E,f,S]),m.useEffect(()=>{const A=l.$ruleChange.subscribe(()=>{w(Math.random())});return()=>A.unsubscribe()},[l]),m.useEffect(()=>{const A=()=>{var z,Y;const q=Math.max(0,((Y=(z=C.current)==null?void 0:z.getBoundingClientRect().width)!=null?Y:0)-8);return hr=q,q},H=new X.Observable(q=>{const z=o.getContainer();if(z){let Y=setTimeout(()=>{q.next(void 0)},150);const ne=()=>{Y&&clearTimeout(Y),Y=null},ae=$e=>{$e.propertyName==="width"&&(ne(),q.next(void 0))};return z.addEventListener("transitionend",ae),()=>{ne(),z.removeEventListener("transitionend",ae)}}}).pipe(X.debounceTime(16)).subscribe(()=>{T(A())});return()=>{H.unsubscribe()}},[]);const g=A=>{var q;const $=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),H=(q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:q.getSheetId();if(!$||!H)throw new Error("No active sheet found");u.executeCommand(r.DeleteCfCommand.id,{unitId:$,subUnitId:H,cfId:A.cfId})},x=(A,$)=>{y($.y)},F=(A,$,H)=>{var $e;y(-1);const q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),z=($e=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:$e.getSheetId();if(!q||!z)throw new Error("No active sheet found");const Y=wt=>{const Vt=k.length;return Math.min(Vt-1,Math.max(0,wt))},ne=k[Y($.y)].cfId,ae=k[Y(H.y)].cfId;ne!==ae&&u.executeCommand(r.MoveCfCommand.id,{unitId:q,subUnitId:z,start:{id:ne,type:"self"},end:{id:ae,type:H.y>$.y?"after":"before"}})},G=()=>{t.onCreate()},J=()=>{E==="2"?u.executeCommand(r.ClearWorksheetCfCommand.id):E==="1"&&k.map($=>({unitId:f,subUnitId:S,cfId:$.cfId})).forEach($=>{u.executeCommand(r.DeleteCfCommand.id,$)})},Q=m.useMemo(()=>{const A=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),$=A.getActiveSheet();return k.filter(H=>{const q=H.ranges;return P.checkRangesEditablePermission(p,A.getUnitId(),$.getSheetId(),q)})},[k]),de=Q.map((A,$)=>({i:A.cfId,x:0,w:12,y:$,h:1,isResizable:!1})),ve=m.useMemo(()=>{const A=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),$=A.getActiveSheet();return k.every(H=>{const q=H.ranges;return P.checkRangesEditablePermission(p,A.getUnitId(),$.getSheetId(),q)})},[k]);return s.jsxs("div",{children:[s.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[s.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:v.tWithReactNode("sheet.cf.panel.managerRuleSelect",s.jsx(O.Select,{className:"univer-w-36",options:U,value:E,onChange:A=>{N(A)}})).map((A,$)=>s.jsx("span",{children:A},$))}),s.jsxs("div",{className:"univer-flex univer-justify-end",children:[s.jsx(O.Tooltip,{title:c.t("sheet.cf.panel.createRule"),placement:"bottom",children:s.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:G,children:s.jsx(ur,{})})}),k.length&&ve?s.jsx(O.Tooltip,{title:c.t("sheet.cf.panel.clear"),placement:"bottom",children:s.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:J,children:s.jsx(Re,{className:"univer-text-red-500"})})}):s.jsx("div",{children:s.jsx(Re,{className:"univer-text-gray-300"})})]})]}),s.jsx("div",{ref:C,children:I>0&&s.jsx(O.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:de,cols:12,rowHeight:60,width:I,margin:[0,10],onDragStop:F,onDragStart:x,children:Q==null?void 0:Q.map((A,$)=>s.jsx("div",{children:s.jsxs("div",{className:O.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-bg-gray-100 dark:!univer-bg-gray-700":M===$}),onMouseMove:()=>{A.ranges!==_&&b(A.ranges)},onMouseLeave:()=>b([]),onClick:()=>{e(A)},children:[s.jsx("div",{className:O.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:H=>H.stopPropagation(),children:s.jsx(ir,{})}),s.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:Yr(A,c)}),s.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:A.ranges.map(H=>Be.serializeRange(H)).join(",")})]}),s.jsx("div",{children:s.jsx(ue,{rule:A.rule})}),s.jsx("div",{className:O.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":M===$}),onClick:H=>{H.stopPropagation(),g(A),b([])},children:s.jsx(Re,{})})]})},`${A.cfId}`))})})]})},Kr=t=>{const[e,l]=m.useState(t.rule),[n,a]=m.useState(!!t.rule),u=()=>{a(!0)},c=()=>{a(!1),l(void 0)},p=o=>{l(o),a(!0)};return s.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between",children:n?s.jsx(Wr,{onCancel:c,rule:e}):s.jsx(Zr,{onClick:p,onCreate:u})})};var Xr=Object.getOwnPropertyDescriptor,Jr=(t,e,l,n)=>{for(var a=n>1?void 0:n?Xr(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},ge=(t,e)=>(l,n)=>e(l,n,t);const Ue="sheet.conditional.formatting.panel";let me=class extends i.Disposable{constructor(e,l,n,a,u){super();ee(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=l,this._componentManager=n,this._sidebarService=a,this._localeService=u,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(c=>{var p;c||(p=this._sidebarDisposable)==null||p.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(c=>{c.id===Ue&&(c.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const l={id:Ue,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ue,rule:e,key:i.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(l)}_initPanel(){this._componentManager.register(Ue,Kr)}};me=Jr([ge(0,i.IUniverInstanceService),ge(1,i.Inject(i.Injector)),ge(2,i.Inject(j.ComponentManager)),ge(3,i.Inject(j.ISidebarService)),ge(4,i.Inject(i.LocaleService))],me);var Z=(t=>(t[t.createRule=1]="createRule",t[t.viewRule=2]="viewRule",t[t.highlightCell=3]="highlightCell",t[t.rank=4]="rank",t[t.formula=5]="formula",t[t.colorScale=6]="colorScale",t[t.dataBar=7]="dataBar",t[t.icon=8]="icon",t[t.clearRangeRules=9]="clearRangeRules",t[t.clearWorkSheetRules=10]="clearWorkSheetRules",t))(Z||{});const Se={id:"sheet.operation.open.conditional.formatting.panel",type:i.CommandType.OPERATION,handler:(t,e)=>{var p;const l=t.get(me),n=t.get(P.SheetsSelectionsService),a=t.get(i.ICommandService),u=((p=n.getCurrentSelections())==null?void 0:p.map(o=>o.range))||[];switch(e.value){case 3:{l.openPanel({...r.createDefaultRule(),ranges:u});break}case 4:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};l.openPanel(o);break}case 5:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:"="}};l.openPanel(o);break}case 6:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.colorScale,config:[]}};l.openPanel(o);break}case 7:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};l.openPanel(o);break}case 8:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};l.openPanel(o);break}case 2:{l.openPanel();break}case 1:{l.openPanel({...r.createDefaultRule(),ranges:u});break}case 9:{a.executeCommand(r.ClearRangeCfCommand.id,{ranges:u});break}case 10:{a.executeCommand(r.ClearWorksheetCfCommand.id);break}}return!0}};var Qr=Object.getOwnPropertyDescriptor,et=(t,e,l,n)=>{for(var a=n>1?void 0:n?Qr(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},be=(t,e)=>(l,n)=>e(l,n,t);let Ie=class extends i.Disposable{constructor(e,l,n,a,u){super();ee(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=l,this._injector=n,this._conditionalFormattingViewModel=a,this._univerInstanceService=u,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,l,n)=>this._collectConditionalRule(e,l,n),onPasteCells:(e,l,n,a)=>{const{copyType:u=W.COPY_TYPE.COPY,pasteType:c}=a,{range:p}=e||{},{range:o}=l;return this._generateConditionalFormattingMutations(o,{copyType:u,pasteType:c,copyRange:p})}}))}_collectConditionalRule(e,l,n){const a=new i.ObjectMatrix,u={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:l,cfMap:u}};const c=this._injector.invoke(d=>P.rangeToDiscreteRange(n,d,e,l));if(!c)return;const{rows:p,cols:o}=c,v=new Set;p.forEach((d,f)=>{o.forEach((h,S)=>{const _=this._conditionalFormattingViewModel.getCellCfs(e,l,d,h);_&&(_.forEach(b=>v.add(b.cfId)),a.setValue(f,S,_.map(b=>b.cfId)))})}),v.forEach(d=>{const f=this._conditionalFormattingRuleModel.getRule(e,l,d);f&&(u[d]=f.rule)})}_generateConditionalFormattingMutations(e,l){const n=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),a=n.getActiveSheet(),u=n.getUnitId();if(!a)return{redos:[],undos:[]};const c=a.getSheetId();if(l.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!l.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(l.pasteType))return{redos:[],undos:[]};const{ranges:[o,v],mapFunc:d}=W.virtualizeDiscreteRanges([l.copyRange,e]),f=W.getRepeatRange(o,v,!0),h={};i.Range.foreach(v,(y,I)=>{const{row:T,col:C}=d(y,I),U=this._conditionalFormattingViewModel.getCellCfs(u,c,T,C);U&&U.forEach(V=>{if(!h[V.cfId]){const k=new i.ObjectMatrix;h[V.cfId]=k;const L=this._conditionalFormattingRuleModel.getRule(u,c,V.cfId);L==null||L.ranges.forEach(g=>{i.Range.foreach(g,(x,F)=>{k.setValue(x,F,1)})})}h[V.cfId].realDeleteValue(T,C)})});const{matrix:S,info:_}=this._copyInfo,b=[];let E=this._conditionalFormattingRuleModel.createCfId(u,c);const N={},R=y=>{if(N[y])return N[y];const I=_==null?void 0:_.cfMap[y],T=[...this._conditionalFormattingRuleModel.getSubunitRules(u,c)||[],...b].find(C=>i.Tools.diffValue(C.rule,I));if(T)return N[y]=T,T;{const C={rule:I,cfId:E,ranges:[],stopIfTrue:!1};return N[y]=C,b.push(C),E=`${Number(E)+1}`,C}};f.forEach(y=>{S&&S.forValue((I,T,C)=>{const U=i.Rectangle.getPositionRange({startRow:I,endRow:I,startColumn:T,endColumn:T},y.startRange),{row:V,col:k}=d(U.startRow,U.startColumn);C.forEach(L=>{if(!h[L]){const g=R(L),x=new i.ObjectMatrix;h[L]=x,g.ranges.forEach(F=>{i.Range.foreach(F,(G,J)=>{x.setValue(G,J,1)})})}h[L].setValue(V,k,1)})})});const w=[],M=[];for(const y in h){const I=h[y],T=P.findAllRectangle(P.createTopMatrixFromMatrix(I));if(!T.length){const C={unitId:u,subUnitId:c,cfId:y};w.push({id:r.DeleteConditionalRuleMutation.id,params:C}),M.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,C))}if(b.some(C=>C.cfId===y)){const C=R(y),U={unitId:u,subUnitId:c,rule:{...C,ranges:T}};w.push({id:r.AddConditionalRuleMutation.id,params:U}),M.push(r.AddConditionalRuleMutationUndoFactory(this._injector,U))}else{const C=this._conditionalFormattingRuleModel.getRule(u,c,y);if(!C)continue;const U={unitId:u,subUnitId:c,rule:{...C,ranges:T}};w.push({id:r.SetConditionalRuleMutation.id,params:U}),M.push(...r.setConditionalRuleMutationUndoFactory(this._injector,U))}}return{redos:w,undos:M}}};Ie=et([be(0,i.Inject(W.ISheetClipboardService)),be(1,i.Inject(r.ConditionalFormattingRuleModel)),be(2,i.Inject(i.Injector)),be(3,i.Inject(r.ConditionalFormattingViewModel)),be(4,i.Inject(i.IUniverInstanceService))],Ie);var rt=Object.getOwnPropertyDescriptor,tt=(t,e,l,n)=>{for(var a=n>1?void 0:n?rt(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},er=(t,e)=>(l,n)=>e(l,n,t);let Ce=class extends i.Disposable{constructor(t,e,l){super(),this._localeService=t,this._commandService=e,this._sheetPermissionCheckController=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===r.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[P.WorkbookEditablePermission],rangeTypes:[P.RangeProtectionPermissionEditPoint],worksheetTypes:[P.WorksheetEditPermission,P.WorksheetSetCellStylePermission]},t.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Ce=tt([er(0,i.Inject(i.LocaleService)),er(1,i.ICommandService),er(2,i.Inject(P.SheetPermissionCheckController))],Ce);var nt=Object.getOwnPropertyDescriptor,at=(t,e,l,n)=>{for(var a=n>1?void 0:n?nt(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},ke=(t,e)=>(l,n)=>e(l,n,t);let Te=class extends i.Disposable{constructor(t,e,l,n){super(),this._conditionalFormattingRuleModel=t,this._univerInstanceService=e,this._injector=l,this._refRangeService=n,this._initRefRange()}_initRefRange(){const t=new Map,e=(n,a,u)=>`${n}_${a}_${u}`,l=(n,a,u)=>{const c=o=>{const v=[...u.ranges],d=v.map(h=>P.handleDefaultRangeChangeWithEffectRefCommands(h,o)).filter(h=>!!h);if(r.isRangesEqual(d,v))return{redos:[],undos:[]};if(d.length){const h={unitId:n,subUnitId:a,rule:{...u,ranges:d}},S=[{id:r.SetConditionalRuleMutation.id,params:h}],_=r.setConditionalRuleMutationUndoFactory(this._injector,h);return{redos:S,undos:_}}else{const h={unitId:n,subUnitId:a,cfId:u.cfId},S=[{id:r.DeleteConditionalRuleMutation.id,params:h}],_=r.DeleteConditionalRuleMutationUndoFactory(this._injector,h);return{redos:S,undos:_}}},p=[];u.ranges.forEach(o=>{const v=this._refRangeService.registerRefRange(o,c);p.push(()=>v.dispose())}),t.set(e(n,a,u.cfId),()=>p.forEach(o=>o()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(n=>{const{unitId:a,subUnitId:u,rule:c}=n,p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!(n.unitId!==p.getUnitId()||n.subUnitId!==(o==null?void 0:o.getSheetId())))switch(n.type){case"add":{l(n.unitId,n.subUnitId,n.rule);break}case"delete":{const v=t.get(e(a,u,c.cfId));v&&v();break}case"set":{const v=t.get(e(a,u,c.cfId));v&&v(),l(n.unitId,n.subUnitId,n.rule)}}})),this.disposeWithMe(i.toDisposable(()=>{t.forEach(n=>{n()}),t.clear()}))}};Te=at([ke(0,i.Inject(r.ConditionalFormattingRuleModel)),ke(1,i.Inject(i.IUniverInstanceService)),ke(2,i.Inject(i.Injector)),ke(3,i.Inject(P.RefRangeService))],Te);var lt=Object.getOwnPropertyDescriptor,ut=(t,e,l,n)=>{for(var a=n>1?void 0:n?lt(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},ce=(t,e)=>(l,n)=>e(l,n,t);let _e=class extends i.Disposable{constructor(e,l,n,a,u,c){super();ee(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=l,this._univerInstanceService=n,this._renderManagerService=a,this._conditionalFormattingViewModel=u,this._conditionalFormattingRuleModel=c,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var l,n,a;const e=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();(l=this._renderManagerService.getRenderById(e))==null||l.with(W.SheetSkeletonManagerService).reCalculate(),(a=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||a.makeDirty()}_initSkeleton(){this.disposeWithMe(X.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(fe.bufferTime(16),fe.filter(e=>!!e.length),fe.filter(e=>{const l=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!l)return!1;const n=l.getActiveSheet();return n?e.filter(a=>a.unitId===l.getUnitId()&&a.subUnitId===n.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(P.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,handler:(e,l,n)=>{const a=this._conditionalFormattingService.composeStyle(l.unitId,l.subUnitId,l.row,l.col);if(!a)return n(e);const u=l.workbook.getStyles(),p={...(typeof(e==null?void 0:e.s)=="string"?u.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}},o={...e,s:p};return a.style&&Object.assign(p,a.style),o.fontRenderExtension||(o.fontRenderExtension={},a.isShowValue!==void 0&&(o.fontRenderExtension.isSkip=!a.isShowValue)),a.dataBar&&(o.dataBar=a.dataBar),a.iconSet&&(o.iconSet=a.iconSet,o.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(o)},priority:10}))}};_e=ut([ce(0,i.Inject(P.SheetInterceptorService)),ce(1,i.Inject(r.ConditionalFormattingService)),ce(2,i.Inject(i.IUniverInstanceService)),ce(3,i.Inject(ar.IRenderManagerService)),ce(4,i.Inject(r.ConditionalFormattingViewModel)),ce(5,i.Inject(r.ConditionalFormattingRuleModel))],_e);const yr="sheets-conditional-formatting-ui.config",Pe={};var it=Object.defineProperty,st=Object.getOwnPropertyDescriptor,ct=(t,e,l)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[e]=l,ot=(t,e,l,n)=>{for(var a=n>1?void 0:n?st(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},rr=(t,e)=>(l,n)=>e(l,n,t),gr=(t,e,l)=>ct(t,typeof e!="symbol"?e+"":e,l);D.UniverSheetsConditionalFormattingMobileUIPlugin=class extends i.Plugin{constructor(e=Pe,l,n,a){super(),this._config=e,this._injector=l,this._commandService=n,this._configService=a;const{menu:u,...c}=i.merge({},Pe,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(yr,c),this._initCommand(),this._injector.add([_e]),this._injector.add([Te]),this._injector.add([Ie]),this._injector.add([Ce]),this._injector.add([se])}_initCommand(){[He,We,qe,Ge,ze,Ye,Ze,Ke,Xe,Se].forEach(e=>{this._commandService.registerCommand(e)})}},gr(D.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),gr(D.UniverSheetsConditionalFormattingMobileUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingMobileUIPlugin=ot([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin),rr(1,i.Inject(i.Injector)),rr(2,i.Inject(i.ICommandService)),rr(3,i.IConfigService)],D.UniverSheetsConditionalFormattingMobileUIPlugin);var dt=Object.getOwnPropertyDescriptor,vt=(t,e,l,n)=>{for(var a=n>1?void 0:n?dt(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},xe=(t,e)=>(l,n)=>e(l,n,t);let De=class extends i.Disposable{constructor(t,e,l,n,a){super(),this._injector=t,this._univerInstanceService=e,this._autoFillService=l,this._conditionalFormattingRuleModel=n,this._conditionalFormattingViewModel=a,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),e=(a,u,c,p,o)=>{var S;const v=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(S=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId();if(!v||!d)return;const f={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},h={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};i.Range.foreach(c,(_,b)=>{const E=i.Rectangle.getPositionRange({startRow:_,startColumn:b,endColumn:b,endRow:_},f),N=i.Rectangle.getPositionRange({startRow:_,startColumn:b,endColumn:b,endRow:_},h),{row:R,col:w}=o(E.startRow,E.startColumn),M=this._conditionalFormattingViewModel.getCellCfs(v,d,R,w),{row:y,col:I}=o(N.startRow,N.startColumn),T=this._conditionalFormattingViewModel.getCellCfs(v,d,y,I);T&&T.forEach(C=>{let U=p.get(C.cfId);if(!p.get(C.cfId)){const V=this._conditionalFormattingRuleModel.getRule(v,d,C.cfId);if(!V)return;U=new i.ObjectMatrix,V.ranges.forEach(k=>{i.Range.foreach(k,(L,g)=>{U.setValue(L,g,1)})}),p.set(C.cfId,U)}U.realDeleteValue(y,I)}),M&&M.forEach(C=>{let U=p.get(C.cfId);if(!p.get(C.cfId)){const V=this._conditionalFormattingRuleModel.getRule(v,d,C.cfId);if(!V)return;U=new i.ObjectMatrix,V.ranges.forEach(k=>{i.Range.foreach(k,(L,g)=>{U.setValue(L,g,1)})}),p.set(C.cfId,U)}U.setValue(y,I,1)})})},l=(a,u)=>{var N,R,w;const c=(N=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:N.getUnitId(),p=(w=(R=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:R.getActiveSheet())==null?void 0:w.getSheetId(),o=new Map,v=[],d=[];if(!c||!p)return t();const f=W.virtualizeDiscreteRanges([a,u]),[h,S]=f.ranges,{mapFunc:_}=f,b={row:h.startRow,col:h.startColumn};return W.getAutoFillRepeatRange(h,S).forEach(M=>{e(b,M.repeatStartCell,M.relativeRange,o,_)}),o.forEach((M,y)=>{const I=this._conditionalFormattingRuleModel.getRule(c,p,y);if(!I)return;const T=P.findAllRectangle(P.createTopMatrixFromMatrix(M));if(T.length){const C={unitId:c,subUnitId:p,rule:{...I,ranges:T}};v.push({id:r.SetConditionalRuleMutation.id,params:C}),d.push(...r.setConditionalRuleMutationUndoFactory(this._injector,C))}else{const C={unitId:c,subUnitId:p,cfId:I.cfId};v.push({id:r.DeleteConditionalRuleMutation.id,params:C}),d.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,C))}}),{undos:d,redos:v}},n={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(a,u,c)=>{if(c===W.APPLY_TYPE.COPY||c===W.APPLY_TYPE.ONLY_FORMAT||c===W.APPLY_TYPE.SERIES){const{source:p,target:o}=a;return l(p,o)}return t()}};this.disposeWithMe(this._autoFillService.addHook(n))}};De=vt([xe(0,i.Inject(i.Injector)),xe(1,i.Inject(i.IUniverInstanceService)),xe(2,i.Inject(W.IAutoFillService)),xe(3,i.Inject(r.ConditionalFormattingRuleModel)),xe(4,i.Inject(r.ConditionalFormattingViewModel))],De);var pt=Object.getOwnPropertyDescriptor,ft=(t,e,l,n)=>{for(var a=n>1?void 0:n?pt(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},Ne=(t,e)=>(l,n)=>e(l,n,t);D.ConditionalFormattingClearController=class extends i.Disposable{constructor(e,l,n,a,u){super(),this._injector=e,this._univerInstanceService=l,this._sheetInterceptorService=n,this._selectionManagerService=a,this._conditionalFormattingRuleModel=u,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var u;const l=[],n=[],a={redos:l,undos:n};if([P.ClearSelectionFormatCommand.id,P.ClearSelectionAllCommand.id].includes(e.id)){const c=(u=this._selectionManagerService.getCurrentSelections())==null?void 0:u.map(_=>_.range);if(!c)return a;const p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!o)return a;const v=p.getUnitId(),d=o.getSheetId(),f=this._conditionalFormattingRuleModel.getSubunitRules(v,d);if(!f||!f.length)return a;const{redos:h,undos:S}=mr(this._injector,f,c,v,d);l.push(...h),n.push(...S)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:l,ranges:n})=>{const a=[],u=[],c={redos:a,undos:u};if(!n||!n.length)return c;const p=this._conditionalFormattingRuleModel.getSubunitRules(e,l);if(!p||!p.length)return c;const{redos:o,undos:v}=mr(this._injector,p,n,e,l);return a.push(...o),u.push(...v),c}}))}},D.ConditionalFormattingClearController=ft([Ne(0,i.Inject(i.Injector)),Ne(1,i.Inject(i.IUniverInstanceService)),Ne(2,i.Inject(P.SheetInterceptorService)),Ne(3,i.Inject(P.SheetsSelectionsService)),Ne(4,i.Inject(r.ConditionalFormattingRuleModel))],D.ConditionalFormattingClearController);function mr(t,e,l,n,a){const u=[],c=[];return e.filter(p=>l.some(o=>p.ranges.some(v=>i.Rectangle.getIntersects(v,o)))).forEach(p=>{const v=new P.RangeMergeUtil().add(...p.ranges).subtract(...l).merge();if(v.length){const d={id:r.SetConditionalRuleMutation.id,params:{unitId:n,subUnitId:a,rule:{...p,ranges:v}}},f=r.setConditionalRuleMutationUndoFactory(t,d.params);u.push(d),c.push(...f)}else{const d={id:r.DeleteConditionalRuleMutation.id,params:{unitId:n,subUnitId:a,cfId:p.cfId}},f=r.DeleteConditionalRuleMutationUndoFactory(t,d.params);u.push(d),c.push(...f)}}),{redos:u,undos:c}}var ht=Object.getOwnPropertyDescriptor,yt=(t,e,l,n)=>{for(var a=n>1?void 0:n?ht(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},Sr=(t,e)=>(l,n)=>e(l,n,t);let je=class extends i.Disposable{constructor(t,e){super(),this._sheetInterceptorService=t,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(i.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(P.AFTER_CELL_EDIT,{handler:(t,e,l)=>{var c,p,o;t||l(t);const n=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),a=(c=n==null?void 0:n.style)!=null?c:{},u=Object.keys(a);if(t!=null&&t.p)return(o=(p=t.p.body)==null?void 0:p.textRuns)==null||o.forEach(v=>{v.ts&&u.forEach(d=>{var f;(f=v.ts)==null||delete f[d]})}),l(t);{const v={...(typeof(t==null?void 0:t.s)=="string"?e.workbook.getStyles().get(t.s):t==null?void 0:t.s)||{}};u.forEach(f=>{delete v[f]});const d={...t,s:{...v}};return l(d)}}})))}};je=yt([Sr(0,i.Inject(P.SheetInterceptorService)),Sr(1,i.Inject(r.ConditionalFormattingService))],je);const br=[P.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],Ee=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:Z.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:Z.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:Z.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:Z.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:Z.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:Z.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:Z.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:Z.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:Z.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:Z.clearWorkSheetRules}],gt=t=>{const e=t.get(P.SheetsSelectionsService),l=t.get(i.ICommandService),n=t.get(i.IUniverInstanceService),a=t.get(r.ConditionalFormattingRuleModel),u=new X.Observable(o=>X.merge(e.selectionMoveEnd$,e.selectionSet$,new X.Observable(v=>{const d=l.onCommandExecuted(f=>{var b;const{id:h,params:S}=f,_=(b=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:b.getUnitId();br.includes(h)&&S.unitId===_&&v.next(null)});return()=>d.dispose()})).pipe(fe.debounceTime(16)).subscribe(()=>{var b;const v=((b=e.getCurrentSelections())==null?void 0:b.map(E=>E.range))||[],d=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!d)return;const f=d.getActiveSheet();if(!f)return;const _=(a.getSubunitRules(d.getUnitId(),f.getSheetId())||[]).filter(E=>E.ranges.some(N=>v.some(R=>i.Rectangle.intersects(R,N)))).map(E=>E.ranges).every(E=>P.checkRangesEditablePermission(t,d.getUnitId(),f.getSheetId(),E));o.next(_)})),c=new X.Observable(o=>new X.Observable(v=>{const d=l.onCommandExecuted(f=>{var b;const{id:h,params:S}=f,_=(b=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:b.getUnitId();br.includes(h)&&S.unitId===_&&v.next(null)});return()=>d.dispose()}).pipe(fe.debounceTime(16)).subscribe(()=>{const v=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!v)return;const d=v.getActiveSheet();if(!d)return;const f=a.getSubunitRules(v.getUnitId(),d.getSheetId())||[];if(!f.length)return o.next(!1),!1;const h=f.map(S=>S.ranges).every(S=>P.checkRangesEditablePermission(t,v.getUnitId(),d.getSheetId(),S));o.next(h)})),p=new X.Observable(o=>{u.subscribe(v=>{const d=Ee.find(f=>f.value===Z.clearRangeRules);d&&(d.disabled=!v,o.next(Ee))}),c.subscribe(v=>{const d=Ee.find(f=>f.value===Z.clearWorkSheetRules);d&&(d.disabled=!v,o.next(Ee))}),o.next(Ee)});return{id:Se.id,type:j.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:p,hidden$:j.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(t,{workbookTypes:[P.WorkbookEditablePermission],worksheetTypes:[P.WorksheetSetCellStylePermission,P.WorksheetEditPermission],rangeTypes:[P.RangeProtectionPermissionEditPoint]})}},mt={[j.RibbonDataGroup.RULES]:{[Se.id]:{order:1,menuItemFactory:gt}}};var St=Object.getOwnPropertyDescriptor,bt=(t,e,l,n)=>{for(var a=n>1?void 0:n?St(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},Ir=(t,e)=>(l,n)=>e(l,n,t);let Le=class extends i.Disposable{constructor(e,l){super();ee(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=l,this._menuManagerService.mergeMenu(mt)}};Le=bt([Ir(0,i.Inject(i.Injector)),Ir(1,j.IMenuManagerService)],Le);var It=Object.getOwnPropertyDescriptor,Ct=(t,e,l,n)=>{for(var a=n>1?void 0:n?It(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},oe=(t,e)=>(l,n)=>e(l,n,t);const Tt=(t,e)=>{const l=d=>d.endRow-d.startRow+1,n=d=>d.endColumn-d.startColumn+1,a=l(e)%l(t),u=n(e)%n(t),c=Math.floor(l(e)/l(t)),p=Math.floor(n(e)/n(t)),o=[],v={startRow:0,endRow:l(t)-1,startColumn:0,endColumn:n(t)-1};if(l(e)===1&&n(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return o.push({repeatRelativeRange:v,startRange:d}),o}for(let d=0;d<c+(a?.1:0);d++)for(let f=0;f<p+(u?.1:0);f++){const h=l(t)*d,S=n(t)*f,_={startRow:h+e.startRow,endRow:h+e.startRow,startColumn:S+e.startColumn,endColumn:S+e.startColumn};let b=v;d===c&&a&&(b={...b},b.endRow=b.endRow-(l(t)-a)),f===p&&u&&(b={...b},b.endColumn=b.endColumn-(n(t)-u)),o.push({repeatRelativeRange:b,startRange:_})}return o};let Ae=class extends i.Disposable{constructor(e,l,n,a,u,c){super();ee(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=l,this._formatPainterService=n,this._sheetsSelectionsService=a,this._conditionalFormattingRuleModel=u,this._conditionalFormattingViewModel=c,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),l=(u,c,p,o,v)=>{const{unitId:d,subUnitId:f}=this._painterConfig,{targetUnitId:h,targetSubUnitId:S}=v,_={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row},b={startRow:c.row,startColumn:c.col,endColumn:c.col,endRow:c.row};i.Range.foreach(p,(E,N)=>{const R=i.Rectangle.getPositionRange({startRow:E,startColumn:N,endColumn:N,endRow:E},_),w=i.Rectangle.getPositionRange({startRow:E,startColumn:N,endColumn:N,endRow:E},b),M=this._conditionalFormattingViewModel.getCellCfs(d,f,R.startRow,R.startColumn),y=this._conditionalFormattingViewModel.getCellCfs(h,S,w.startRow,w.startColumn);y&&y.forEach(I=>{let T=o.get(I.cfId);if(!o.get(I.cfId)){const C=this._conditionalFormattingRuleModel.getRule(h,S,I.cfId);if(!C)return;T=new i.ObjectMatrix,C.ranges.forEach(U=>{i.Range.foreach(U,(V,k)=>{T.setValue(V,k,1)})}),o.set(I.cfId,T)}T.realDeleteValue(w.startRow,w.startColumn)}),M&&M.forEach(I=>{const T=o.get(I.cfId);T&&T.setValue(w.startRow,w.startColumn,1)})})},n=(u,c,p)=>{var R;const{range:o,unitId:v,subUnitId:d}=this._painterConfig,f=u!==v||d!==c,h=new Map,S=[],_=[];if(!u||!c||!v||!d)return e();const b=(R=this._conditionalFormattingRuleModel.getSubunitRules(v,d))!=null?R:[];b==null||b.forEach(w=>{const{ranges:M,cfId:y}=w;if(M.some(I=>i.Rectangle.intersects(o,I))){const I=new i.ObjectMatrix;f||M.forEach(T=>{i.Range.foreach(T,(C,U)=>{I.setValue(C,U,1)})}),h.set(y,I)}});const E={row:o.startRow,col:o.startColumn};return Tt(o,p).forEach(w=>{l(E,{row:w.startRange.startRow,col:w.startRange.startColumn},w.repeatRelativeRange,h,{targetUnitId:u,targetSubUnitId:c})}),h.forEach((w,M)=>{if(f){const y=this._conditionalFormattingRuleModel.getRule(u,c,M),I=P.findAllRectangle(P.createTopMatrixFromMatrix(w));if(y)if(I.length){const T={unitId:u,subUnitId:c,rule:{...y,ranges:I}};S.push({id:r.SetConditionalRuleMutation.id,params:T}),_.push(...r.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:u,subUnitId:c,cfId:y.cfId};S.push({id:r.DeleteConditionalRuleMutation.id,params:T}),_.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}else if(I.length){const T=this._conditionalFormattingRuleModel.getRule(v,d,M);if(T){const C={unitId:u,subUnitId:c,rule:{...i.Tools.deepClone(T),cfId:this._conditionalFormattingRuleModel.createCfId(u,c),ranges:I}};S.push({id:r.AddConditionalRuleMutation.id,params:C}),_.push(r.AddConditionalRuleMutationUndoFactory(this._injector,C))}}}else{const y=this._conditionalFormattingRuleModel.getRule(v,d,M);if(!y)return;const I=P.findAllRectangle(P.createTopMatrixFromMatrix(w));if(I.length){const T={unitId:v,subUnitId:d,rule:{...y,ranges:I}};S.push({id:r.SetConditionalRuleMutation.id,params:T}),_.push(...r.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:v,subUnitId:d,cfId:y.cfId};S.push({id:r.DeleteConditionalRuleMutation.id,params:T}),_.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}}}),{undos:_,redos:S}},a={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:u=>{var c,p,o;switch(u){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const v=(c=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:c.getUnitId(),d=(o=(p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getActiveSheet())==null?void 0:o.getSheetId(),f=this._sheetsSelectionsService.getCurrentLastSelection(),h=f==null?void 0:f.range;v&&d&&h&&(this._painterConfig={unitId:v,subUnitId:d,range:h});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(u,c,p)=>this._painterConfig?n(u,c,p):{redos:[],undos:[]}};this._formatPainterService.addHook(a)}};Ae=Ct([oe(0,i.Inject(i.Injector)),oe(1,i.Inject(i.IUniverInstanceService)),oe(2,i.Inject(W.IFormatPainterService)),oe(3,i.Inject(P.SheetsSelectionsService)),oe(4,i.Inject(r.ConditionalFormattingRuleModel)),oe(5,i.Inject(r.ConditionalFormattingViewModel))],Ae);var _t=Object.getOwnPropertyDescriptor,xt=(t,e,l,n)=>{for(var a=n>1?void 0:n?_t(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},tr=(t,e)=>(l,n)=>e(l,n,t);let Fe=class extends i.Disposable{constructor(t,e,l){super(),this._conditionalFormattingViewModel=t,this._univerInstanceService=e,this._renderManagerService=l,this._init()}_init(){const t=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),e=l=>{const n=l.getUnitId(),a=this._renderManagerService.getRenderById(n);if(!a)return;const u=a.with(W.SheetSkeletonManagerService);this.disposeWithMe(u.currentSkeleton$.subscribe(c=>{if(c){const p=c.skeleton.rowColumnSegment,o=p.endColumn-p.startColumn+1,d=(p.endRow-p.startRow+1)*o*9,f=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(f)}}))};t&&e(t),this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(l=>{l&&e(l)})}};Fe=xt([tr(0,i.Inject(r.ConditionalFormattingViewModel)),tr(1,i.IUniverInstanceService),tr(2,ar.IRenderManagerService)],Fe);var Nt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Rt=(t,e,l)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[e]=l,Mt=(t,e,l,n)=>{for(var a=n>1?void 0:n?Et(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},nr=(t,e)=>(l,n)=>e(l,n,t),Cr=(t,e,l)=>Rt(t,typeof e!="symbol"?e+"":e,l);D.UniverSheetsConditionalFormattingUIPlugin=class extends i.Plugin{constructor(e=Pe,l,n,a){super(),this._config=e,this._injector=l,this._commandService=n,this._configService=a;const{menu:u,...c}=i.merge({},Pe,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(yr,c),this._initCommand()}onStarting(){i.registerDependencies(this._injector,[[_e],[Te],[Ie],[De],[Ce],[me],[Le],[se],[je],[D.ConditionalFormattingClearController],[Ae],[Fe]]),i.touchDependencies(this._injector,[[_e]])}onReady(){i.touchDependencies(this._injector,[[Le],[me]])}onRendered(){i.touchDependencies(this._injector,[[De],[D.ConditionalFormattingClearController],[Ie],[je],[se],[Ae],[Ce],[Te],[Fe]])}_initCommand(){[He,We,qe,Ge,ze,Ye,Ze,Ke,Xe,Se].forEach(e=>{this._commandService.registerCommand(e)})}},Cr(D.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Cr(D.UniverSheetsConditionalFormattingUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingUIPlugin=Mt([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin),nr(1,i.Inject(i.Injector)),nr(2,i.Inject(i.ICommandService)),nr(3,i.IConfigService)],D.UniverSheetsConditionalFormattingUIPlugin),D.AddAverageCfCommand=He,D.AddColorScaleConditionalRuleCommand=We,D.AddDataBarConditionalRuleCommand=qe,D.AddDuplicateValuesCfCommand=Ge,D.AddNumberCfCommand=ze,D.AddRankCfCommand=Ye,D.AddTextCfCommand=Ze,D.AddTimePeriodCfCommand=Ke,D.AddUniqueValuesCfCommand=Xe,D.OpenConditionalFormattingOperator=Se,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(D,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","rxjs","@univerjs/engine-render","rxjs/operators"],i):(D=typeof globalThis<"u"?globalThis:D||self,i(D.UniverSheetsConditionalFormattingUi={},D.UniverCore,D.UniverSheetsConditionalFormatting,D.UniverSheets,D.UniverUi,D.React,D.React,D.UniverDesign,D.UniverEngineFormula,D.UniverSheetsFormulaUi,D.UniverSheetsUi,D.rxjs,D.UniverEngineRender,D.rxjs.operators))})(this,function(D,i,r,P,j,s,m,O,Be,pe,W,X,ar,fe){"use strict";var Ot=Object.defineProperty;var Ut=(D,i,r)=>i in D?Ot(D,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):D[i]=r;var ee=(D,i,r)=>Ut(D,typeof i!="symbol"?i+"":i,r);const He={type:i.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u}=e,c=t.get(r.ConditionalFormattingRuleModel),p=t.get(i.ICommandService),o=t.get(i.IUniverInstanceService),v=P.getSheetCommandTarget(o);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=c.createCfId(d,f),S={ranges:l,cfId:h,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:u,style:n}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:S})}},We={type:i.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,config:n,stopIfTrue:a}=e,u=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.ICommandService),p=t.get(i.IUniverInstanceService),o=P.getSheetCommandTarget(p);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=u.createCfId(v,d),h={ranges:l,cfId:f,stopIfTrue:!!a,rule:{type:r.CFRuleType.colorScale,config:n}};return c.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}},qe={type:i.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,min:n,max:a,nativeColor:u,positiveColor:c,isGradient:p,stopIfTrue:o,isShowValue:v}=e,d=t.get(r.ConditionalFormattingRuleModel),f=t.get(i.IUniverInstanceService),h=P.getSheetCommandTarget(f);if(!h)return!1;const{unitId:S,subUnitId:_}=h,b=t.get(i.ICommandService),E=d.createCfId(S,_),N={ranges:l,cfId:E,stopIfTrue:!!o,rule:{type:r.CFRuleType.dataBar,isShowValue:v,config:{min:n,max:a,nativeColor:u,positiveColor:c,isGradient:p}}};return b.executeCommand(r.AddConditionalRuleMutation.id,{unitId:S,subUnitId:_,rule:N})}},Ge={type:i.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a}=e,u=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.ICommandService),p=t.get(i.IUniverInstanceService),o=P.getSheetCommandTarget(p);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=u.createCfId(v,d),h={ranges:l,cfId:f,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:n}};return c.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}},ze={type:i.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u,value:c}=e,p=t.get(r.ConditionalFormattingRuleModel),o=t.get(i.ICommandService),v=t.get(i.IUniverInstanceService),d=P.getSheetCommandTarget(v);if(!d)return!1;const{unitId:f,subUnitId:h}=d,S=p.createCfId(f,h);let _;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)){const b=c;if(b.length!==2||!Array.isArray(b))return!1;_={ranges:l,cfId:S,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:n,value:b}}}else{const b=c;if(typeof b!="number")return!1;_={ranges:l,cfId:S,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:n,value:b}}}return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:h,rule:_})}},Ye={type:i.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,isPercent:u,isBottom:c,value:p}=e,o=t.get(r.ConditionalFormattingRuleModel),v=t.get(i.IUniverInstanceService),d=t.get(i.ICommandService),f=P.getSheetCommandTarget(v);if(!f)return!1;const{unitId:h,subUnitId:S}=f,_=o.createCfId(h,S),b={ranges:l,cfId:_,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:u,isBottom:c,style:n,value:p}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:S,rule:b})}},Ze={type:i.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u,value:c}=e,p=t.get(r.ConditionalFormattingRuleModel),o=t.get(i.IUniverInstanceService),v=P.getSheetCommandTarget(o);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=t.get(i.ICommandService),S=p.createCfId(d,f),_={ranges:l,cfId:S,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:u,style:n,value:c}};return h.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:_})}},Ke={type:i.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u}=e,c=t.get(r.ConditionalFormattingRuleModel),p=t.get(i.IUniverInstanceService),o=t.get(i.ICommandService),v=P.getSheetCommandTarget(p);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=c.createCfId(d,f),S={ranges:l,cfId:h,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:u,style:n}};return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:S})}},Xe={type:i.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a}=e,u=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.IUniverInstanceService),p=t.get(i.ICommandService),o=P.getSheetCommandTarget(c);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=u.createCfId(v,d),h={ranges:l,cfId:f,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:n}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}};var K=function(){return K=Object.assign||function(t){for(var e,l=1,n=arguments.length;l<n;l++){e=arguments[l];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},K.apply(this,arguments)},Tr=function(t,e){var l={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(l[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a<n.length;a++)e.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(t,n[a])&&(l[n[a]]=t[n[a]]);return l},le=m.forwardRef(function(t,e){var l=t.icon,n=t.id,a=t.className,u=t.extend,c=Tr(t,["icon","id","className","extend"]),p="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),o=m.useRef("_".concat(Nr()));return lr(l,"".concat(n),{defIds:l.defIds,idSuffix:o.current},K({ref:e,className:p},c),u)});function lr(t,e,l,n,a){return m.createElement(t.tag,K(K({key:e},_r(t,l,a)),n),(xr(t,l).children||[]).map(function(u,c){return lr(u,"".concat(e,"-").concat(t.tag,"-").concat(c),l,void 0,a)}))}function _r(t,e,l){var n=K({},t.attrs);l!=null&&l.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=l.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(u){var c=u[0],p=u[1];c==="mask"&&typeof p=="string"&&(n[c]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var a=e.defIds;return!a||a.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(u){var c=u[0],p=u[1];typeof p=="string"&&(n[c]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function xr(t,e){var l,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((l=t.children)===null||l===void 0)&&l.length)?K(K({},t),{children:t.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.indexOf(a.attrs.id)>-1?K(K({},a),{attrs:K(K({},a.attrs),{id:a.attrs.id+e.idSuffix})}):a})}):t}function Nr(){return Math.random().toString(36).substring(2,8)}le.displayName="UniverIcon";var Er={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"}}]},Me=m.forwardRef(function(t,e){return m.createElement(le,Object.assign({},t,{id:"delete-single",ref:e,icon:Er}))});Me.displayName="DeleteSingle";var Mr={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"}}]},ur=m.forwardRef(function(t,e){return m.createElement(le,Object.assign({},t,{id:"increase-single",ref:e,icon:Mr}))});ur.displayName="IncreaseSingle";var Rr={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"}}]},Re=m.forwardRef(function(t,e){return m.createElement(le,Object.assign({},t,{id:"more-down-single",ref:e,icon:Rr}))});Re.displayName="MoreDownSingle";var wr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},ir=m.forwardRef(function(t,e){return m.createElement(le,Object.assign({},t,{id:"sequence-single",ref:e,icon:wr}))});ir.displayName="SequenceSingle";var Vr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_436_41",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.35 0.48H16.35V16.48H0.35z"}}]},{tag:"g",attrs:{mask:"url(#mask0_436_41)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z"}},{tag:"path",attrs:{fill:"#E5E5E5",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z"}}]}]},he=m.forwardRef(function(t,e){return m.createElement(le,Object.assign({},t,{id:"slash-single",ref:e,icon:Vr}))});he.displayName="SlashSingle";const re=t=>{const{color:e,onChange:l,disable:n=!1,iconId:a="PaintBucket",className:u,isNeedDropdownIcon:c=!0}=t,p=j.useDependency(j.ComponentManager),o=m.useMemo(()=>new i.ColorKit(e),[e]),v=p.get(a);return v?n?s.jsx(v,{className:O.clsx("univer-fill-primary-600",u),extend:{colorChannel1:o.isValid?e:""}}):s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(O.ColorPicker,{value:e,onChange:l})}),children:s.jsxs("span",{className:O.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",u),children:[s.jsx(v,{className:"univer-fill-primary-600",extend:{colorChannel1:o.isValid?e:""}}),c&&s.jsx(Re,{className:"univer-ml-1.5 univer-text-gray-400"})]})}):null},ue=t=>{var u,c,p;const e=t.rule;if(!e)return null;const l=m.useMemo(()=>{if(e.type===r.CFRuleType.colorScale){const o=e.config.map((f,h)=>({color:new i.ColorKit(f.color),value:h})),v=o.length-1;return new Array(5).fill("").map((f,h,S)=>h*v/(S.length-1)).map(f=>r.getColorScaleFromValue(o,f))}return null},[e]),n=m.useMemo(()=>{if(e.type===r.CFRuleType.iconSet)return e.config.map(o=>{const v=r.iconMap[o.iconType];return v&&v[Number(o.iconId)]})},[e]),a=`univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center
|
|
2
|
+
univer-justify-center univer-text-xs`;switch(e.type){case r.CFRuleType.dataBar:{const{isGradient:o}=e.config,v=o?`linear-gradient(to right, ${e.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,d=o?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||r.defaultDataBarNativeColor})`:e.config.nativeColor;return s.jsxs("div",{className:a,children:[s.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:d,border:`1px solid ${e.config.nativeColor||r.defaultDataBarNativeColor}`}}),s.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:v,border:`1px solid ${e.config.positiveColor||r.defaultDataBarPositiveColor}`}})]})}case r.CFRuleType.colorScale:return l&&s.jsx("div",{className:a,children:l.map((o,v)=>s.jsx("div",{className:"univer-h-full",style:{width:`${100/l.length}%`,background:o}},v))});case r.CFRuleType.iconSet:return n&&s.jsx("div",{className:a,children:n.map((o,v)=>o?s.jsx("img",{className:"univer-h-full",src:o,draggable:!1},v):s.jsx(he,{},v))});case r.CFRuleType.highlightCell:{const{ul:o,st:v,it:d,bl:f,bg:h,cl:S}=e.style,_=(o==null?void 0:o.s)===i.BooleanNumber.TRUE,b=(v==null?void 0:v.s)===i.BooleanNumber.TRUE,E=d===i.BooleanNumber.TRUE,N=f===i.BooleanNumber.TRUE,M=(u=h==null?void 0:h.rgb)!=null?u:r.DEFAULT_BG_COLOR,w=(c=S==null?void 0:S.rgb)!=null?c:r.DEFAULT_FONT_COLOR,R={textDecoration:(p=`${_?"underline":""} ${b?"line-through":""}`.replace(/^ /,""))!=null?p:void 0,backgroundColor:M,color:w};return s.jsx("div",{className:O.clsx(a,{"univer-font-bold":N,"univer-italic":E}),style:R,children:"123"})}}},ye=O.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",O.borderClassName),te=(t,e)=>({label:e.t(`sheet.cf.valueType.${t}`),value:t}),Je=t=>{var _;const{type:e,className:l,onChange:n,id:a,value:u}=t,c=j.useDependency(i.IUniverInstanceService),p=c.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(_=c.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:_.getSheetId(),v=m.useMemo(()=>String(u).startsWith("=")?String(u):"=",[u]),d=m.useMemo(()=>[r.CFValueType.max,r.CFValueType.min,"none"].includes(e)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),f=m.useRef(null),[h,S]=m.useState(!1);return j.useSidebarClick(b=>{var N;((N=f.current)==null?void 0:N.isClickOutSide(b))&&S(!1)}),e===r.CFValueType.formula?s.jsx("div",{className:"univer-ml-1 univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:f,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",O.borderClassName),initValue:v,unitId:p,subUnitId:o,isFocus:h,onChange:(b="")=>{n(b||"")},onFocus:()=>S(!0)})}):s.jsx(O.InputNumber,{className:l,value:Number(t.value)||0,onChange:b=>t.onChange(b||0),...d})},Or=t=>{var L;const{interceptorManager:e}=t,l=j.useDependency(i.LocaleService),n=((L=t.rule)==null?void 0:L.type)===r.CFRuleType.colorScale?t.rule:void 0,a=[te(r.CFValueType.num,l),te(r.CFValueType.percent,l),te(r.CFValueType.percentile,l),te(r.CFValueType.formula,l)],u=[te(r.CFValueType.min,l),...a],c=[te("none",l),...a],p=[te(r.CFValueType.max,l),...a],[o,v]=m.useState(()=>{var x;const g=r.CFValueType.min;return n&&((x=n.config[0])==null?void 0:x.value.type)||g}),[d,f]=m.useState(()=>{var x;const g="none";return!n||n.config.length!==3?g:((x=n.config[1])==null?void 0:x.value.type)||g}),[h,S]=m.useState(()=>{var x;const g=r.CFValueType.max;return n&&((x=n.config[n.config.length-1])==null?void 0:x.value.type)||g}),[_,b]=m.useState(()=>{if(!n)return 10;const x=n.config[0];return(x==null?void 0:x.value.value)===void 0?10:x==null?void 0:x.value.value}),[E,N]=m.useState(()=>{var F;if(!n||n.config.length!==3)return 50;const x=(F=n.config[1])==null?void 0:F.value.value;return x===void 0?50:x}),[M,w]=m.useState(()=>{var F;if(!n)return 90;const x=(F=n.config[n.config.length-1])==null?void 0:F.value.value;return x===void 0?90:x}),[R,y]=m.useState(()=>{var x;const g="#d0d9fb";return n&&((x=n.config[0])==null?void 0:x.color)||g}),[I,T]=m.useState(()=>{var x;const g="#7790f3";return!n||n.config.length!==3?g:((x=n.config[1])==null?void 0:x.color)||g}),[C,U]=m.useState(()=>{var x;const g="#2e55ef";return n&&((x=n.config[n.config.length-1])==null?void 0:x.color)||g}),V=m.useMemo(()=>g=>{const{minType:x,medianType:F,maxType:G,minValue:J,medianValue:Q,maxValue:de,minColor:ve,medianColor:A,maxColor:$}=g,H=[];return H.push({color:ve,value:{type:x,value:J}}),F!=="none"&&H.push({color:A,value:{type:F,value:Q}}),H.push({color:$,value:{type:G,value:de}}),{config:H.map((z,Y)=>({...z,index:Y})),type:r.CFRuleType.colorScale}},[]);m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return V({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:M,minColor:R,medianColor:I,maxColor:C})}}),[V,o,d,h,_,E,M,R,I,C,e]);const k=g=>{t.onChange(V(g))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:V({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:M,minColor:R,medianColor:I,maxColor:C})})}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.valueType.min")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:u,value:o,onChange:g=>{v(g);const x=r.createDefaultValueByValueType(g,10);b(x),k({minType:g,medianType:d,maxType:h,minValue:x,medianValue:E,maxValue:M,minColor:R,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"min",className:"univer-ml-1",value:_,type:o,onChange:g=>{b(g),k({minType:o,medianType:d,maxType:h,minValue:g,medianValue:E,maxValue:M,minColor:R,medianColor:I,maxColor:C})}}),s.jsx(re,{className:"univer-ml-1",color:R,onChange:g=>{y(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:M,minColor:g,medianColor:I,maxColor:C})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.medianValue")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:c,value:d,onChange:g=>{f(g);const x=r.createDefaultValueByValueType(g,50);N(x),k({minType:o,medianType:g,maxType:h,minValue:_,medianValue:x,maxValue:M,minColor:R,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"median",className:"univer-ml-1",value:E,type:d,onChange:g=>{N(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:g,maxValue:M,minColor:R,medianColor:I,maxColor:C})}}),d!=="none"&&s.jsx(re,{className:"univer-ml-1",color:I,onChange:g=>{T(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:M,minColor:R,medianColor:g,maxColor:C})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.valueType.max")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:p,value:h,onChange:g=>{S(g);const x=r.createDefaultValueByValueType(g,90);w(x),k({minType:o,medianType:d,maxType:g,minValue:_,medianValue:E,maxValue:x,minColor:R,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"max",className:"univer-ml-1",value:M,type:h,onChange:g=>{w(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:g,minColor:R,medianColor:I,maxColor:C})}}),s.jsx(re,{className:"univer-ml-1",color:C,onChange:g=>{U(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:M,minColor:R,medianColor:I,maxColor:g})}})]})]})},ie=(t,e)=>({label:e.t(`sheet.cf.valueType.${t}`),value:t}),sr=t=>{var b;const{onChange:e,className:l,value:n,type:a,id:u,disabled:c=!1}=t,p=j.useDependency(i.IUniverInstanceService),o=p.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),v=(b=p.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId(),d=m.useRef(null),[f,h]=m.useState(!1);j.useSidebarClick(E=>{var M;((M=d.current)==null?void 0:M.isClickOutSide(E))&&h(!1)});const S=m.useRef(n),_=m.useMemo(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(a)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[a]);if(a===r.CFValueType.formula){const E=String(S.current).startsWith("=")?String(S.current)||"":"=";return s.jsx("div",{className:"univer-ml-3 univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:d,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",O.borderClassName),initValue:E,unitId:o,subUnitId:v,isFocus:f,onChange:(N="")=>{e(N||"")},onFocus:()=>h(!0)})})}return s.jsx(O.InputNumber,{className:l,value:Number(n)||0,disabled:c,onChange:E=>{e(E||0)},..._})},Ur=t=>{var L;const{interceptorManager:e}=t,l=j.useDependency(i.LocaleService),n=((L=t.rule)==null?void 0:L.type)===r.CFRuleType.dataBar?t.rule:void 0,[a,u]=m.useState(()=>{var x;const g="0";return n?(x=n.config)!=null&&x.isGradient?"1":"0":g}),[c,p]=m.useState(()=>{var g;return n&&((g=n.config)==null?void 0:g.positiveColor)||r.defaultDataBarPositiveColor}),[o,v]=m.useState(()=>{var g;return n&&((g=n.config)==null?void 0:g.nativeColor)||r.defaultDataBarNativeColor}),d=[ie(r.CFValueType.num,l),ie(r.CFValueType.percent,l),ie(r.CFValueType.percentile,l),ie(r.CFValueType.formula,l)],f=[ie(r.CFValueType.min,l),...d],h=[ie(r.CFValueType.max,l),...d],[S,_]=m.useState(()=>{var x;const g=f[0].value;return n&&((x=n.config)==null?void 0:x.min.type)||g}),[b,E]=m.useState(()=>{var x;const g=h[0].value;return n&&((x=n.config)==null?void 0:x.max.type)||g}),[N,M]=m.useState(()=>{var F;if(!n)return 0;const x=((F=n.config)==null?void 0:F.min)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value||0}),[w,R]=m.useState(()=>{var F;if(!n)return 100;const x=((F=n.config)==null?void 0:F.max)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value===void 0?100:x.value}),[y,I]=m.useState(()=>n?n.isShowValue===void 0?!0:!!n.isShowValue:!0),T=g=>({config:{min:{type:g.minValueType,value:g.minValue},max:{type:g.maxValueType,value:g.maxValue},isGradient:g.isGradient==="1",positiveColor:g.positiveColor||r.defaultDataBarPositiveColor,nativeColor:g.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:g.isShowValue});m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return T({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}}),[a,N,S,w,b,c,o,e,y]);const C=g=>{t.onChange(T(g))},U=g=>{p(g),C({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:g,nativeColor:o,isShowValue:y})},V=g=>{v(g),C({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:g,isShowValue:y})},k=g=>d.map(x=>x.value).includes(g);return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:T({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})})}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.fillType")}),s.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[s.jsxs(O.RadioGroup,{value:a,onChange:g=>{u(g),C({isGradient:g,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})},children:[s.jsx(O.Radio,{value:"0",children:s.jsx("span",{className:"univer-text-xs",children:l.t("sheet.cf.panel.pureColor")})}),s.jsx(O.Radio,{value:"1",children:s.jsx("span",{className:"univer-text-xs",children:l.t("sheet.cf.panel.gradient")})})]}),s.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:!y,onChange:g=>{I(!g),C({isGradient:g,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:!g})}}),l.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.colorSet")}),s.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[s.jsxs("div",{className:"univer-flex univer-items-center",children:[s.jsx("div",{className:"univer-text-xs",children:l.t("sheet.cf.panel.native")}),s.jsx(re,{color:o,onChange:V})]}),s.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[s.jsx("div",{className:"univer-text-xs",children:l.t("sheet.cf.panel.positive")}),s.jsx(re,{color:c,onChange:U})]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.valueType.min")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:f,value:S,onChange:g=>{_(g);const x=r.createDefaultValueByValueType(g,10);M(x),C({isGradient:a,minValue:x,minValueType:g,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}}),s.jsx(sr,{id:"min",className:"univer-ml-3",disabled:!k(S),type:S,value:N,onChange:g=>{M(g||0),C({isGradient:a,minValue:g||0,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.valueType.max")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:b,onChange:g=>{E(g);const x=r.createDefaultValueByValueType(g,90);R(x),C({isGradient:a,minValue:N,minValueType:S,maxValue:x,maxValueType:g,positiveColor:c,nativeColor:o,isShowValue:y})}}),s.jsx(sr,{className:"univer-ml-3",disabled:!k(b),id:"max",type:b,value:w,onChange:g=>{R(g||0),C({isGradient:a,minValue:N,minValueType:S,maxValue:g||0,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}})]})]})]})},we=t=>[i.BooleanNumber.FALSE,void 0].includes(t)?i.BooleanNumber.TRUE:i.BooleanNumber.FALSE,Ve=t=>t!==i.BooleanNumber.FALSE,Qe=t=>{const{style:e,onChange:l,className:n}=t,a=j.useDependency(j.ComponentManager),[u,c]=m.useState(()=>{if(e!=null&&e.bl)return e.bl}),[p,o]=m.useState(()=>{if(e!=null&&e.it)return e.it}),[v,d]=m.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[f,h]=m.useState(()=>{if(e!=null&&e.st)return e.st.s}),[S,_]=m.useState(()=>{var T;const I="#2f56ef";return(T=e==null?void 0:e.cl)!=null&&T.rgb?e.cl.rgb:I}),[b,E]=m.useState(()=>{var T;const I="#e8ecfc";return(T=e==null?void 0:e.bg)!=null&&T.rgb?e.bg.rgb:I}),N=a.get("BoldSingle"),M=a.get("ItalicSingle"),w=a.get("UnderlineSingle"),R=a.get("StrikethroughSingle");m.useEffect(()=>{const I={bl:u,it:p};S!==void 0&&(I.cl={rgb:S}),b!==void 0&&(I.bg={rgb:b}),f!==void 0&&(I.st={s:f}),v!==void 0&&(I.ul={s:v}),l(r.removeUndefinedAttr(I))},[u,p,v,f,S,b]);const y="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return s.jsxs("div",{className:O.clsx("univer-my-2.5 univer-flex univer-justify-between",n),children:[N&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(u||i.BooleanNumber.FALSE)}),onClick:()=>c(we(u)),children:s.jsx(N,{})}),M&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(p||i.BooleanNumber.FALSE)}),onClick:()=>o(we(p)),children:s.jsx(M,{})}),w&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(v||i.BooleanNumber.FALSE)}),onClick:()=>d(we(v)),children:s.jsx(w,{})}),R&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(f||i.BooleanNumber.FALSE)}),onClick:()=>h(we(f)),children:s.jsx(R,{})}),s.jsx(re,{color:S,onChange:_,iconId:"FontColor"}),s.jsx(re,{color:b,onChange:E,iconId:"PaintBucket"})]})},kr=t=>{var R;const{onChange:e,interceptorManager:l}=t,n=j.useDependency(i.LocaleService),u=j.useDependency(i.IUniverInstanceService).getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),c=u.getActiveSheet(),p=((R=t.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?t.rule:void 0,o=m.useRef(null),[v,d]=m.useState(!1),f=m.useRef(null),[h,S]=m.useState({}),[_,b]=m.useState(()=>(p==null?void 0:p.subType)===r.CFSubRuleType.formula?p.value:"="),[E,N]=m.useState(void 0),M=y=>({style:y.style,value:_,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});m.useEffect(()=>l.intercept(l.getInterceptPoints().submit,{handler(){return M({style:h})}}),[h,_,l]),m.useEffect(()=>l.intercept(l.getInterceptPoints().beforeSubmit,{handler:(I,T,C)=>E||_.length===1||!_.startsWith("=")?(N(n.t("sheet.cf.errorMessage.formulaError")),!1):C(I)}),[E,_]);const w=y=>{e(M(y))};return j.useSidebarClick(y=>{var T;((T=f.current)==null?void 0:T.isClickOutSide(y))&&d(!1)}),s.jsxs("div",{ref:o,children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:"univer-mt-3",children:s.jsx(pe.FormulaEditor,{ref:f,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",O.borderClassName),errorText:E,isFocus:v,initValue:_,unitId:u.getUnitId(),subUnitId:c==null?void 0:c.getSheetId(),onFocus:()=>{d(!0)},onChange:y=>{b(y),w({style:h})},onVerify:(y,I)=>{!y||I.length===1?N(n.t("sheet.cf.errorMessage.formulaError")):N(void 0)}})}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:M({style:h})})}),s.jsx(Qe,{style:p==null?void 0:p.style,className:"univer-mt-3",onChange:y=>{S(y),w({style:y})}})]})},Oe=t=>s.jsxs("div",{style:{position:"relative"},children:[s.jsx("div",{style:{position:"absolute",zIndex:999,bottom:"-13px",fontSize:"10px",color:"red"},children:t.errorText}),t.children]}),B=(t,e)=>({label:e.t(`sheet.cf.operator.${t}`),value:t}),Pr=t=>{const{type:e,operator:l,onChange:n,value:a,interceptorManager:u}=t,c=j.useDependency(i.LocaleService),[p,o]=m.useState(()=>typeof a=="number"?a:0),[v,d]=m.useState(""),[f,h]=m.useState(()=>typeof a=="string"?a:""),[S,_]=m.useState(""),[b,E]=m.useState(()=>Array.isArray(a)?a[0]===void 0?0:a[0]:0),[N,M]=m.useState(""),[w,R]=m.useState(()=>Array.isArray(a)?a[1]===void 0?100:a[1]:100),[y,I]=m.useState("");switch(m.useEffect(()=>{switch(e){case r.CFSubRuleType.text:{[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(l)&&n(f);break}case r.CFSubRuleType.number:{[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(l)&&n(p),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(l)&&n([b,w]);break}}},[e]),m.useEffect(()=>{const T=u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(C,U,V)=>{switch(e){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(l))return f?V(C):(_(c.t("sheet.cf.errorMessage.notBlank")),!1)}return V(C)}});return()=>{T()}},[e,p,f,l]),e){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(l)){const T=C=>{h(C),n(C)};return s.jsx("div",{className:"univer-mt-3",children:s.jsx(Oe,{errorText:S,children:s.jsx(O.Input,{value:f,onChange:C=>{_(""),T(C)}})})})}break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(l)){const T=C=>{o(C||0),n(C||0),d("")};return s.jsx("div",{className:"univer-mt-3",children:s.jsx(Oe,{errorText:v,children:s.jsx(O.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:p,onChange:T})})})}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(l)){const T=U=>{E(U||0),n([U||0,w]),M("")},C=U=>{R(U||0),n([b,U||0]),I("")};return s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(Oe,{errorText:N,children:s.jsx(O.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:b,onChange:T})}),s.jsx(Oe,{errorText:y,children:s.jsx(O.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:w,onChange:C})})]})}}}return null},cr=(t,e)=>{switch(t){case r.CFSubRuleType.text:return[B(r.CFTextOperator.containsText,e),B(r.CFTextOperator.notContainsText,e),B(r.CFTextOperator.beginsWith,e),B(r.CFTextOperator.endsWith,e),B(r.CFTextOperator.equal,e),B(r.CFTextOperator.notEqual,e),B(r.CFTextOperator.containsBlanks,e),B(r.CFTextOperator.notContainsBlanks,e),B(r.CFTextOperator.containsErrors,e),B(r.CFTextOperator.notContainsErrors,e)];case r.CFSubRuleType.number:return[B(r.CFNumberOperator.between,e),B(r.CFNumberOperator.notBetween,e),B(r.CFNumberOperator.equal,e),B(r.CFNumberOperator.notEqual,e),B(r.CFNumberOperator.greaterThan,e),B(r.CFNumberOperator.greaterThanOrEqual,e),B(r.CFNumberOperator.lessThan,e),B(r.CFNumberOperator.lessThanOrEqual,e)];case r.CFSubRuleType.timePeriod:return[B(r.CFTimePeriodOperator.yesterday,e),B(r.CFTimePeriodOperator.today,e),B(r.CFTimePeriodOperator.tomorrow,e),B(r.CFTimePeriodOperator.last7Days,e),B(r.CFTimePeriodOperator.lastWeek,e),B(r.CFTimePeriodOperator.thisWeek,e),B(r.CFTimePeriodOperator.nextWeek,e),B(r.CFTimePeriodOperator.lastMonth,e),B(r.CFTimePeriodOperator.thisMonth,e),B(r.CFTimePeriodOperator.nextMonth,e)]}},or=t=>{var R;const{interceptorManager:e,onChange:l}=t,n=j.useDependency(i.LocaleService),a=((R=t.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?t.rule:void 0,[u,c]=m.useState(()=>{const y=r.CFSubRuleType.text;return a&&a.subType||y}),p=[{value:r.CFSubRuleType.text,label:n.t("sheet.cf.subRuleType.text")},{value:r.CFSubRuleType.number,label:n.t("sheet.cf.subRuleType.number")},{value:r.CFSubRuleType.timePeriod,label:n.t("sheet.cf.subRuleType.timePeriod")},{value:r.CFSubRuleType.duplicateValues,label:n.t("sheet.cf.subRuleType.duplicateValues")},{value:r.CFSubRuleType.uniqueValues,label:n.t("sheet.cf.subRuleType.uniqueValues")}],o=m.useMemo(()=>cr(u,n),[u]),[v,d]=m.useState(()=>{const y=o?o[0].value:void 0;return a&&a.operator||y}),[f,h]=m.useState(()=>{var T;const y="";return a?(T=a.value)!=null?T:r.createDefaultValue(a.subType,a.operator):y}),[S,_]=m.useState({}),b=m.useMemo(()=>y=>{var I,T,C,U,V,k,L,g,x,F,G,J,Q,de,ve;switch(y.subType||u){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(v))return{type:r.CFRuleType.highlightCell,subType:(I=y.subType)!=null?I:u,operator:(T=y.operator)!=null?T:v,style:(C=y.style)!=null?C:S,value:(U=y.value)!=null?U:f};break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(v))return{type:r.CFRuleType.highlightCell,subType:(V=y.subType)!=null?V:u,operator:(k=y.operator)!=null?k:v,style:(L=y.style)!=null?L:S,value:(g=y.value)!=null?g:f};if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(v))return{type:r.CFRuleType.highlightCell,subType:(x=y.subType)!=null?x:u,operator:(F=y.operator)!=null?F:v,style:(G=y.style)!=null?G:S,value:(J=y.value)!=null?J:f};break}}return{type:r.CFRuleType.highlightCell,subType:(Q=y.subType)!=null?Q:u,operator:(de=y.operator)!=null?de:v,style:(ve=y.style)!=null?ve:S}},[u,v,f,S]);m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return b({})}}),[b,e]),m.useEffect(()=>{p.some(y=>y.value===u)||c(p[0].value)},[p]);const E=y=>{const I=y,T=cr(I,n),C=T&&T[0].value;c(I),d(C),C&&h(r.createDefaultValue(I,C)),l(b({subType:I,operator:C}))},N=y=>{const I=y;d(I),l(b({operator:I}))},M=y=>{h(y),l(b({value:y}))},w=m.useMemo(()=>`${u}_${v}_${Math.random()}`,[u,v]);return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:E,value:u,options:p}),(o==null?void 0:o.length)&&s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:N,value:v||"",options:o})]}),s.jsx(Pr,{value:f,interceptorManager:e,type:u,operator:v,rule:a,onChange:M},w),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:b({})})}),s.jsx(Qe,{style:a==null?void 0:a.style,className:"univer-ml-1",onChange:y=>{_(y),l(b({style:y}))}})]})},dr=(t,e)=>(r.iconMap[t]||[])[Number(e)]||"",Dr=t=>{var d;const{error:e,type:l,onChange:n}=t,a=j.useDependency(i.IUniverInstanceService),u=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(d=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),p=m.useRef(null),[o,v]=m.useState(!1);return j.useSidebarClick(f=>{var S;((S=p.current)==null?void 0:S.isClickOutSide(f))&&v(!1)}),s.jsx("div",{className:"univer-relative",children:l!==r.CFValueType.formula?s.jsxs(s.Fragment,{children:[s.jsx(O.InputNumber,{className:O.clsx({"univer-border-red-500":e}),value:Number(t.value)||0,onChange:f=>n(f!=null?f:0)}),e&&s.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):s.jsx("div",{className:"univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:p,initValue:String(t.value),unitId:u,subUnitId:c,isFocus:o,onChange:(f="")=>{n(f||"")},onFocus:()=>v(!0)})})})},vr=(t,e,l)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(l.length-1-e)*10},iconType:t,iconId:String(e)}),jr=m.forwardRef((t,e)=>{const{onClick:l}=t,n=j.useDependency(i.LocaleService),a=u=>{l(u)};return s.jsx("div",{ref:e,className:"univer-w-80",children:r.iconGroup.map((u,c)=>s.jsxs("div",{className:"univer-mb-3",children:[s.jsx("div",{className:"univer-mb-1 univer-text-sm",children:n.t(u.title)}),s.jsx("div",{className:"univer-flex univer-flex-wrap",children:u.group.map(p=>s.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{a(p.name)},children:s.jsx("a",{className:"univer-cursor-pointer univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",children:p.list.map((o,v)=>s.jsx("img",{className:"univer-size-5",src:o,draggable:!1},v))})},p.name))})]},c))})}),Lr=t=>{const{onClick:e}=t,l=m.useMemo(()=>{const a=[];for(const u in r.iconMap){const c=r.iconMap[u],p=u;c.forEach((o,v)=>{a.push({iconType:p,base64:o,iconId:String(v)})})}return a},[]),n=a=>{e(a.iconType,a.iconId)};return s.jsxs("div",{children:[s.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>n({iconType:r.EMPTY_ICON_TYPE,iconId:""}),children:[s.jsx(he,{className:"univer-size-5"}),s.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),s.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:l.map(a=>s.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",children:s.jsx("img",{className:"univer-size-5",src:a.base64,draggable:!1,onClick:()=>n(a)})},`${a.iconType}_${a.iconId}`))})]})},Ar=t=>{const{onChange:e,configList:l,errorMap:n={}}=t,a=j.useDependency(i.LocaleService),u=[{label:a.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:a.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],c=[{label:a.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:a.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:a.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:a.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],p=(f,h)=>{e([String(h),"value","value"],f)},o=(f,h)=>{e([String(h),"operator"],f);const S=r.createDefaultValue(r.CFSubRuleType.number,f);p(S,h)},v=(f,h)=>{e([String(h),"value","type"],f);const S=l[h],_=r.createDefaultValue(r.CFSubRuleType.number,S.operator);p(_,h)};return m.useMemo(()=>l.map((f,h)=>{const S=n[h],_=dr(f.iconType,f.iconId),b=h===l.length-1,E=h===0,N=l[h-1],M=(N==null?void 0:N.value.type)===r.CFValueType.formula?a.t("sheet.cf.valueType.formula"):N==null?void 0:N.value.value,w=(R,y)=>{const I={...f,iconId:y,iconType:R};e([String(h)],I)};return s.jsxs("div",{className:h?"univer-mt-6":"univer-mt-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[s.jsxs("div",{className:"univer-w-[45%]",children:[a.t("sheet.cf.iconSet.icon"),h+1]}),s.jsx("div",{className:"univer-w-[45%]",children:s.jsxs(s.Fragment,{children:[!E&&!b&&a.t("sheet.cf.iconSet.rule"),!E&&!b&&s.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:["(",a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${r.getOppositeOperator(N.operator)}`),M,b?"":` ${a.t("sheet.cf.iconSet.and")} `,")"]})]})})]}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[s.jsx("div",{className:"univer-flex univer-items-center",children:s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(Lr,{onClick:w,iconId:f.iconId,iconType:f.iconType})}),children:s.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all dark:!univer-text-gray-200 hover:univer-border-primary-600",O.borderClassName),children:[_?s.jsx("img",{src:_,className:"univer-size-4",draggable:!1}):s.jsx(he,{className:"univer-size-4"}),s.jsx(Re,{})]})})}),b?s.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[a.t("sheet.cf.iconSet.rule"),s.jsxs("span",{className:"univer-font-medium",children:[a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${r.getOppositeOperator(N.operator)}`),M,b?"":` ${a.t("sheet.cf.iconSet.and")} `]})]}):s.jsx(O.Select,{options:u,value:f.operator,onChange:R=>{o(R,h)}})]}),b?s.jsx("div",{}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[s.jsx("div",{children:a.t("sheet.cf.iconSet.type")}),s.jsx("div",{children:a.t("sheet.cf.iconSet.value")})]}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:c,value:f.value.type,onChange:R=>{v(R,h)}}),s.jsx("div",{children:s.jsx(Dr,{id:h,type:f.value.type,error:S,value:f.value.value||"",onChange:R=>{p(R,h)}})})]})]})]},h)}),[l,n])},Fr=t=>{var R;const{interceptorManager:e}=t,l=((R=t.rule)==null?void 0:R.type)===r.CFRuleType.iconSet?t.rule:void 0,n=j.useDependency(i.LocaleService),[a,u]=m.useState({}),[c,p]=m.useState(()=>{const y=Object.keys(r.iconMap)[0];if(l&&l.config.length){const I=l.config[0].iconType;if(!l.config.some(C=>C.iconType!==I))return I}return y}),[o,v]=m.useState(()=>{if(l&&l.config.length)return i.Tools.deepClone(l==null?void 0:l.config);const y=r.iconMap[c]||[];return new Array(y.length).fill("").map((I,T,C)=>T===C.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:c,iconId:String(T)}:vr(c,T,C))}),[d,f]=m.useState(()=>l?!!l.isShowValue:!0),h=m.useMemo(()=>{const y=o.map(I=>dr(I.iconType,I.iconId));return s.jsx("div",{className:"univer-flex univer-items-center",children:y.map((I,T)=>I?s.jsx("img",{className:"univer-size-5",src:I},T):s.jsx(he,{className:"univer-size-5"},T))})},[o]),S=y=>{if(y.reduce((T,C,U)=>T.preType&&!T.result||y.length-1===U?T:C.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:T.preType?{result:T.preType===C.value.type,preType:C.value.type}:{result:!0,preType:C.value.type},{result:!0,preType:""}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(y[0].value.type)){const T={};return y.forEach((C,U,V)=>{if(U-1<0||U===V.length-1)return;const L=y[U-1],g=r.getOppositeOperator(L.operator);r.compareWithNumber({operator:g,value:L.value.value},C.value.value)||(T[U]=`${n.t(`sheet.cf.form.${g}`,String(L.value.value))} `)}),T}return{}},_=(y,I)=>{i.get(o,y)!==I&&(i.set(o,y,I),v([...o]),u(S(o)))},b=y=>{p(y);const I=r.iconMap[y]||[],T=new Array(I.length).fill("").map((C,U,V)=>vr(y,U,V));v(T),u(S(T))};m.useEffect(()=>{const y=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:d,config:o}}});return()=>{y()}},[d,o,e]),m.useEffect(()=>{const y=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(a).length===0}});return()=>{y()}},[d,o,e,a]);const E=()=>{const y=o.map(I=>({...I}));o.forEach((I,T)=>{const C=o.length-1-T,U=y[C];I.iconId=U.iconId,I.iconType=U.iconType}),v([...o])},N=j.useDependency(j.ILayoutService),[M,w]=m.useState();return j.useScrollYOverContainer(M,N.rootContainerElement),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:"univer-mt-3",children:s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(jr,{ref:y=>{!M&&y&&w(y)},iconType:c,onClick:b})}),children:s.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",O.borderClassName),children:[h,s.jsx(Re,{})]})})}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[s.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{onChange:E}),n.t("sheet.cf.iconSet.reverseIconOrder")]}),s.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:!d,onChange:y=>{f(!y)}}),n.t("sheet.cf.iconSet.onlyShowIcon")]})]}),s.jsx(Ar,{errorMap:a,onChange:_,configList:o})]})},$r=t=>{var E;const{onChange:e,interceptorManager:l}=t,n=j.useDependency(i.LocaleService),a=((E=t.rule)==null?void 0:E.type)===r.CFRuleType.highlightCell?t.rule:void 0,u=[{label:n.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:n.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:n.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:n.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[c,p]=m.useState(()=>{const N=u[0].value,M=a==null?void 0:a.type;if(!a)return N;switch(M){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(a.operator)?"greaterThanAverage":[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(a.operator)?"lessThanAverage":N;case r.CFSubRuleType.rank:return a.isBottom?"isBottom":"isNotBottom"}}return N}),[o,v]=m.useState(()=>{const M=a==null?void 0:a.type;if(!a)return 10;switch(M){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.rank:return a.value||10}}return 10}),[d,f]=m.useState(()=>{const M=a==null?void 0:a.type;if(!a)return!1;switch(M){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.rank:return a.isPercent||!1}}return!1}),[h,S]=m.useState({}),_=N=>{const{type:M,isPercent:w,value:R,style:y}=N;if(M==="isNotBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:w,isBottom:!1,value:R,style:y};if(M==="isBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:w,isBottom:!0,value:R,style:y};if(M==="greaterThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:y};if(M==="lessThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:y}};m.useEffect(()=>l.intercept(l.getInterceptPoints().submit,{handler(){return _({type:c,isPercent:d,value:o,style:h})}}),[c,d,o,h,l]);const b=N=>{e(_(N))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",value:c,options:u,onChange:N=>{p(N),b({type:N,isPercent:d,value:o,style:h})}}),["isNotBottom","isBottom"].includes(c)&&s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.InputNumber,{min:1,max:1e3,value:o,onChange:N=>{const M=N||0;v(M),b({type:c,isPercent:d,value:M,style:h})}}),s.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:d,onChange:N=>{f(!!N),b({type:c,isPercent:!!N,value:o,style:h})}}),n.t("sheet.cf.valueType.percent")]})]}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:_({type:c,isPercent:d,value:o,style:h})})}),s.jsx(Qe,{style:a==null?void 0:a.style,className:"univer-mt-3",onChange:N=>{S(N),b({type:c,isPercent:d,value:o,style:N})}})]})},Br=i.createInterceptorKey("beforeSubmit"),Hr=i.createInterceptorKey("submit"),pr=t=>t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),fr=t=>{var e;return(e=t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},Wr=t=>{var T,C,U;const e=j.useDependency(i.LocaleService),l=j.useDependency(i.ICommandService),n=j.useDependency(i.IUniverInstanceService),a=j.useDependency(r.ConditionalFormattingRuleModel),u=j.useDependency(P.SheetsSelectionsService),c=pr(n),p=fr(n),[o,v]=m.useState(void 0),d=m.useRef((C=(T=t.rule)==null?void 0:T.ranges)!=null?C:[]),f=m.useMemo(()=>{var k,L,g;let V=(k=t.rule)==null?void 0:k.ranges;return V!=null&&V.length||(V=(g=(L=u.getCurrentSelections())==null?void 0:L.map(x=>x.range))!=null?g:[]),d.current=V,V!=null&&V.length?V.map(x=>{const F=Be.serializeRange(x);return F==="NaN"?"":F}).filter(x=>!!x).join(","):""},[t.rule]),h=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[S,_]=m.useState(()=>{var L,g;const V=(L=t.rule)==null?void 0:L.rule.type,k=h[0].value;if(!V)return k;switch(V){case r.CFRuleType.highlightCell:{switch((g=t.rule)==null?void 0:g.rule.subType){case r.CFSubRuleType.number:case r.CFSubRuleType.text:case r.CFSubRuleType.duplicateValues:case r.CFSubRuleType.uniqueValues:case r.CFSubRuleType.timePeriod:return"1";case r.CFSubRuleType.average:case r.CFSubRuleType.rank:return"2";case r.CFSubRuleType.formula:return"5"}break}case r.CFRuleType.dataBar:return"3";case r.CFRuleType.colorScale:return"4";case r.CFRuleType.iconSet:return"6"}return k}),b=m.useRef(void 0),E=m.useMemo(()=>new i.InterceptorManager({beforeSubmit:Br,submit:Hr}),[]),N=m.useMemo(()=>{switch(S){case"1":return or;case"2":return $r;case"3":return Ur;case"4":return Or;case"5":return kr;case"6":return Fr;default:return or}},[S]);m.useEffect(()=>{const V=l.onCommandExecuted(k=>{if(k.id===P.RemoveSheetMutation.id){const L=k.params;L.subUnitId===p&&L.unitId===c&&t.onCancel()}k.id===P.SetWorksheetActiveOperation.id&&t.onCancel()});return()=>V.dispose()},[]);const M=V=>{b.current=V},w=V=>{const k=V.split(",").filter(L=>!!L).map(Be.deserializeRangeWithSheet).map(L=>L.range);d.current=k},R=()=>{if(o)return;const k=(()=>{const g=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!g)throw new Error("No active sheet found");return d.current.map(G=>P.setEndForRange(G,g.getRowCount(),g.getColumnCount())).filter(G=>!(Number.isNaN(G.startRow)||Number.isNaN(G.startColumn)))})();if(E.fetchThroughInterceptors(E.getInterceptPoints().beforeSubmit)(!0,null)){const g=E.fetchThroughInterceptors(E.getInterceptPoints().submit)(null,null);if(g){const x=pr(n),F=fr(n);if(!x||!F)throw new Error("No active sheet found");let G={};t.rule&&t.rule.cfId?(G={...t.rule,ranges:k,rule:g},l.executeCommand(r.SetCfCommand.id,{unitId:x,subUnitId:F,rule:G}),t.onCancel()):(G={cfId:a.createCfId(x,F),ranges:k,rule:g,stopIfTrue:!1},l.executeCommand(r.AddCfCommand.id,{unitId:x,subUnitId:F,rule:G}),t.onCancel())}}},y=()=>{t.onCancel()},I=(V,k)=>{V?k.length<1?v(e.t("sheet.cf.errorMessage.rangeError")):v(void 0):v(e.t("sheet.cf.errorMessage.rangeError"))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),s.jsxs("div",{className:"univer-mt-4",children:[s.jsx(pe.RangeSelector,{unitId:c,subUnitId:p,initialValue:f,onChange:(V,k)=>w(k),onVerify:I}),o&&s.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:o})]}),s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),s.jsx(O.Select,{className:"univer-mt-4 univer-w-full",value:S,options:h,onChange:V=>_(V)}),s.jsx(N,{interceptorManager:E,rule:(U=t.rule)==null?void 0:U.rule,onChange:M}),s.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[s.jsx(O.Button,{onClick:y,children:e.t("sheet.cf.panel.cancel")}),s.jsx(O.Button,{className:"univer-ml-3",variant:"primary",onClick:R,children:e.t("sheet.cf.panel.submit")})]})]})};var qr=Object.getOwnPropertyDescriptor,Gr=(t,e,l,n)=>{for(var a=n>1?void 0:n?qr(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},zr=(t,e)=>(l,n)=>e(l,n,t);let se=class extends i.Disposable{constructor(e){super();ee(this,"_initLocal",()=>{});ee(this,"_findReplaceIndex",e=>{const l=/\{([^}]+)?\}/g,n=[];let a=l.exec(e);for(;a;)n.push({startIndex:a.index,key:Number(a[1]),endIndex:a.index+a[0].length-1}),a=l.exec(e);return n});this._localeService=e,this._initLocal()}tWithReactNode(e,...l){const n=this._localeService.getLocales(),a=e.split("."),u=n&&this._localeService.resolveKeyPath(n,a);if(typeof u=="string"){const c=[];return this._findReplaceIndex(u).forEach((p,o,v)=>{const d=v[o-1]||{endIndex:-1};if(d.endIndex+1<p.startIndex){const f=u.slice(d.endIndex+1,p.startIndex);f&&c.push(f)}if(l[p.key]&&c.push(l[p.key]),o===v.length-1){const f=u.slice(p.endIndex+1);f&&c.push(f)}}),c}return[]}};se=Gr([zr(0,i.Inject(i.LocaleService))],se);const Yr=(t,e)=>{const l=t.rule;switch(l.type){case r.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case r.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case r.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case r.CFRuleType.highlightCell:switch(l.subType){case r.CFSubRuleType.average:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`,e.t("sheet.cf.subRuleType.average"))}case r.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case r.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case r.CFSubRuleType.number:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`,...Array.isArray(l.value)?l.value.map(a=>String(a)):[String(l.value||"")])}case r.CFSubRuleType.text:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`,l.value||"")}case r.CFSubRuleType.timePeriod:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`)}case r.CFSubRuleType.rank:return l.isPercent?l.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(l.value)):e.t("sheet.cf.preview.describe.topNPercent",String(l.value)):l.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(l.value)):e.t("sheet.cf.preview.describe.topN",String(l.value));case r.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let hr=0;const Zr=t=>{const{onClick:e}=t,l=j.useDependency(r.ConditionalFormattingRuleModel),n=j.useDependency(i.IUniverInstanceService),a=j.useDependency(P.SheetsSelectionsService),u=j.useDependency(i.ICommandService),c=j.useDependency(i.LocaleService),p=j.useDependency(i.Injector),o=j.useDependency(j.ISidebarService),v=j.useDependency(se),d=j.useObservable(()=>n.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),f=d.getUnitId(),h=d.getActiveSheet();if(!h)throw new Error("No active sheet found");const S=h.getSheetId(),[_,b]=m.useState([]),[E,N]=m.useState("2"),[M,w]=m.useState(0),[R,y]=m.useState(-1),[I,T]=m.useState(hr),C=m.useRef(null),U=[{label:c.t("sheet.cf.panel.workSheet"),value:"2"},{label:c.t("sheet.cf.panel.selectedRange"),value:"1"}],V=()=>{const A=l.getSubunitRules(f,S);if(!A||!A.length)return[];if(E==="1"){const $=a.getCurrentLastSelection();if(!$)return[];const H=$.range;return A.filter(z=>z.ranges.some(Y=>i.Rectangle.intersects(Y,H)))}else if(E==="2")return[...A];return[]},[k,L]=m.useState(V);W.useHighlightRange(_),m.useEffect(()=>{const A=u.onCommandExecuted($=>{$.id===P.SetWorksheetActiveOperation.id&&w(Math.random())});return()=>A.dispose()}),m.useEffect(()=>{L(V)},[E,M,f,S]),m.useEffect(()=>{if(E==="2")return;const A=new X.Observable($=>{const H=[P.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],q=u.onCommandExecuted(z=>{const{id:Y,params:ne}=z,ae=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();H.includes(Y)&&ne.unitId===ae&&$.next(null)});return()=>q.dispose()}).pipe(X.debounceTime(16)).subscribe(()=>{L(V)});return()=>{A.unsubscribe()}},[n,E,f,S]),m.useEffect(()=>{const A=l.$ruleChange.subscribe(()=>{w(Math.random())});return()=>A.unsubscribe()},[l]),m.useEffect(()=>{const A=()=>{var z,Y;const q=Math.max(0,((Y=(z=C.current)==null?void 0:z.getBoundingClientRect().width)!=null?Y:0)-8);return hr=q,q},H=new X.Observable(q=>{const z=o.getContainer();if(z){let Y=setTimeout(()=>{q.next(void 0)},150);const ne=()=>{Y&&clearTimeout(Y),Y=null},ae=$e=>{$e.propertyName==="width"&&(ne(),q.next(void 0))};return z.addEventListener("transitionend",ae),()=>{ne(),z.removeEventListener("transitionend",ae)}}}).pipe(X.debounceTime(16)).subscribe(()=>{T(A())});return()=>{H.unsubscribe()}},[]);const g=A=>{var q;const $=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),H=(q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:q.getSheetId();if(!$||!H)throw new Error("No active sheet found");u.executeCommand(r.DeleteCfCommand.id,{unitId:$,subUnitId:H,cfId:A.cfId})},x=(A,$)=>{y($.y)},F=(A,$,H)=>{var $e;y(-1);const q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),z=($e=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:$e.getSheetId();if(!q||!z)throw new Error("No active sheet found");const Y=wt=>{const Vt=k.length;return Math.min(Vt-1,Math.max(0,wt))},ne=k[Y($.y)].cfId,ae=k[Y(H.y)].cfId;ne!==ae&&u.executeCommand(r.MoveCfCommand.id,{unitId:q,subUnitId:z,start:{id:ne,type:"self"},end:{id:ae,type:H.y>$.y?"after":"before"}})},G=()=>{t.onCreate()},J=()=>{E==="2"?u.executeCommand(r.ClearWorksheetCfCommand.id):E==="1"&&k.map($=>({unitId:f,subUnitId:S,cfId:$.cfId})).forEach($=>{u.executeCommand(r.DeleteCfCommand.id,$)})},Q=m.useMemo(()=>{const A=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),$=A.getActiveSheet();return k.filter(H=>{const q=H.ranges;return P.checkRangesEditablePermission(p,A.getUnitId(),$.getSheetId(),q)})},[k]),de=Q.map((A,$)=>({i:A.cfId,x:0,w:12,y:$,h:1,isResizable:!1})),ve=m.useMemo(()=>{const A=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),$=A.getActiveSheet();return k.every(H=>{const q=H.ranges;return P.checkRangesEditablePermission(p,A.getUnitId(),$.getSheetId(),q)})},[k]);return s.jsxs("div",{children:[s.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[s.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:v.tWithReactNode("sheet.cf.panel.managerRuleSelect",s.jsx(O.Select,{className:"univer-w-36",options:U,value:E,onChange:A=>{N(A)}})).map((A,$)=>s.jsx("span",{children:A},$))}),s.jsxs("div",{className:"univer-flex univer-justify-end",children:[s.jsx(O.Tooltip,{title:c.t("sheet.cf.panel.createRule"),placement:"bottom",children:s.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:G,children:s.jsx(ur,{})})}),k.length&&ve?s.jsx(O.Tooltip,{title:c.t("sheet.cf.panel.clear"),placement:"bottom",children:s.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:J,children:s.jsx(Me,{className:"univer-text-red-500"})})}):s.jsx("div",{children:s.jsx(Me,{className:"univer-text-gray-300"})})]})]}),s.jsx("div",{ref:C,children:I>0&&s.jsx(O.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:de,cols:12,rowHeight:60,width:I,margin:[0,10],onDragStop:F,onDragStart:x,children:Q==null?void 0:Q.map((A,$)=>s.jsx("div",{children:s.jsxs("div",{className:O.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-bg-gray-100 dark:!univer-bg-gray-700":R===$}),onMouseMove:()=>{A.ranges!==_&&b(A.ranges)},onMouseLeave:()=>b([]),onClick:()=>{e(A)},children:[s.jsx("div",{className:O.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:H=>H.stopPropagation(),children:s.jsx(ir,{})}),s.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:Yr(A,c)}),s.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:A.ranges.map(H=>Be.serializeRange(H)).join(",")})]}),s.jsx("div",{children:s.jsx(ue,{rule:A.rule})}),s.jsx("div",{className:O.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":R===$}),onClick:H=>{H.stopPropagation(),g(A),b([])},children:s.jsx(Me,{})})]})},`${A.cfId}`))})})]})},Kr=t=>{const[e,l]=m.useState(t.rule),[n,a]=m.useState(!!t.rule),u=()=>{a(!0)},c=()=>{a(!1),l(void 0)},p=o=>{l(o),a(!0)};return s.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between",children:n?s.jsx(Wr,{onCancel:c,rule:e}):s.jsx(Zr,{onClick:p,onCreate:u})})};var Xr=Object.getOwnPropertyDescriptor,Jr=(t,e,l,n)=>{for(var a=n>1?void 0:n?Xr(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},ge=(t,e)=>(l,n)=>e(l,n,t);const Ue="sheet.conditional.formatting.panel";let me=class extends i.Disposable{constructor(e,l,n,a,u){super();ee(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=l,this._componentManager=n,this._sidebarService=a,this._localeService=u,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(c=>{var p;c||(p=this._sidebarDisposable)==null||p.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(c=>{c.id===Ue&&(c.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const l={id:Ue,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ue,rule:e,key:i.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(l)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ue,Kr))}};me=Jr([ge(0,i.IUniverInstanceService),ge(1,i.Inject(i.Injector)),ge(2,i.Inject(j.ComponentManager)),ge(3,i.Inject(j.ISidebarService)),ge(4,i.Inject(i.LocaleService))],me);var Z=(t=>(t[t.createRule=1]="createRule",t[t.viewRule=2]="viewRule",t[t.highlightCell=3]="highlightCell",t[t.rank=4]="rank",t[t.formula=5]="formula",t[t.colorScale=6]="colorScale",t[t.dataBar=7]="dataBar",t[t.icon=8]="icon",t[t.clearRangeRules=9]="clearRangeRules",t[t.clearWorkSheetRules=10]="clearWorkSheetRules",t))(Z||{});const Se={id:"sheet.operation.open.conditional.formatting.panel",type:i.CommandType.OPERATION,handler:(t,e)=>{var p;const l=t.get(me),n=t.get(P.SheetsSelectionsService),a=t.get(i.ICommandService),u=((p=n.getCurrentSelections())==null?void 0:p.map(o=>o.range))||[];switch(e.value){case 3:{l.openPanel({...r.createDefaultRule(),ranges:u});break}case 4:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};l.openPanel(o);break}case 5:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:"="}};l.openPanel(o);break}case 6:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.colorScale,config:[]}};l.openPanel(o);break}case 7:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};l.openPanel(o);break}case 8:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};l.openPanel(o);break}case 2:{l.openPanel();break}case 1:{l.openPanel({...r.createDefaultRule(),ranges:u});break}case 9:{a.executeCommand(r.ClearRangeCfCommand.id,{ranges:u});break}case 10:{a.executeCommand(r.ClearWorksheetCfCommand.id);break}}return!0}};var Qr=Object.getOwnPropertyDescriptor,et=(t,e,l,n)=>{for(var a=n>1?void 0:n?Qr(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},be=(t,e)=>(l,n)=>e(l,n,t);let Ie=class extends i.Disposable{constructor(e,l,n,a,u){super();ee(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=l,this._injector=n,this._conditionalFormattingViewModel=a,this._univerInstanceService=u,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,l,n)=>this._collectConditionalRule(e,l,n),onPasteCells:(e,l,n,a)=>{const{copyType:u=W.COPY_TYPE.COPY,pasteType:c}=a,{range:p}=e||{},{range:o}=l;return this._generateConditionalFormattingMutations(o,{copyType:u,pasteType:c,copyRange:p})}}))}_collectConditionalRule(e,l,n){const a=new i.ObjectMatrix,u={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:l,cfMap:u}};const c=this._injector.invoke(d=>P.rangeToDiscreteRange(n,d,e,l));if(!c)return;const{rows:p,cols:o}=c,v=new Set;p.forEach((d,f)=>{o.forEach((h,S)=>{const _=this._conditionalFormattingViewModel.getCellCfs(e,l,d,h);_&&(_.forEach(b=>v.add(b.cfId)),a.setValue(f,S,_.map(b=>b.cfId)))})}),v.forEach(d=>{const f=this._conditionalFormattingRuleModel.getRule(e,l,d);f&&(u[d]=f.rule)})}_generateConditionalFormattingMutations(e,l){const n=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),a=n.getActiveSheet(),u=n.getUnitId();if(!a)return{redos:[],undos:[]};const c=a.getSheetId();if(l.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!l.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(l.pasteType))return{redos:[],undos:[]};const{ranges:[o,v],mapFunc:d}=W.virtualizeDiscreteRanges([l.copyRange,e]),f=W.getRepeatRange(o,v,!0),h={};i.Range.foreach(v,(y,I)=>{const{row:T,col:C}=d(y,I),U=this._conditionalFormattingViewModel.getCellCfs(u,c,T,C);U&&U.forEach(V=>{if(!h[V.cfId]){const k=new i.ObjectMatrix;h[V.cfId]=k;const L=this._conditionalFormattingRuleModel.getRule(u,c,V.cfId);L==null||L.ranges.forEach(g=>{i.Range.foreach(g,(x,F)=>{k.setValue(x,F,1)})})}h[V.cfId].realDeleteValue(T,C)})});const{matrix:S,info:_}=this._copyInfo,b=[];let E=this._conditionalFormattingRuleModel.createCfId(u,c);const N={},M=y=>{if(N[y])return N[y];const I=_==null?void 0:_.cfMap[y],T=[...this._conditionalFormattingRuleModel.getSubunitRules(u,c)||[],...b].find(C=>i.Tools.diffValue(C.rule,I));if(T)return N[y]=T,T;{const C={rule:I,cfId:E,ranges:[],stopIfTrue:!1};return N[y]=C,b.push(C),E=`${Number(E)+1}`,C}};f.forEach(y=>{S&&S.forValue((I,T,C)=>{const U=i.Rectangle.getPositionRange({startRow:I,endRow:I,startColumn:T,endColumn:T},y.startRange),{row:V,col:k}=d(U.startRow,U.startColumn);C.forEach(L=>{if(!h[L]){const g=M(L),x=new i.ObjectMatrix;h[L]=x,g.ranges.forEach(F=>{i.Range.foreach(F,(G,J)=>{x.setValue(G,J,1)})})}h[L].setValue(V,k,1)})})});const w=[],R=[];for(const y in h){const I=h[y],T=P.findAllRectangle(P.createTopMatrixFromMatrix(I));if(!T.length){const C={unitId:u,subUnitId:c,cfId:y};w.push({id:r.DeleteConditionalRuleMutation.id,params:C}),R.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,C))}if(b.some(C=>C.cfId===y)){const C=M(y),U={unitId:u,subUnitId:c,rule:{...C,ranges:T}};w.push({id:r.AddConditionalRuleMutation.id,params:U}),R.push(r.AddConditionalRuleMutationUndoFactory(this._injector,U))}else{const C=this._conditionalFormattingRuleModel.getRule(u,c,y);if(!C)continue;const U={unitId:u,subUnitId:c,rule:{...C,ranges:T}};w.push({id:r.SetConditionalRuleMutation.id,params:U}),R.push(...r.setConditionalRuleMutationUndoFactory(this._injector,U))}}return{redos:w,undos:R}}};Ie=et([be(0,i.Inject(W.ISheetClipboardService)),be(1,i.Inject(r.ConditionalFormattingRuleModel)),be(2,i.Inject(i.Injector)),be(3,i.Inject(r.ConditionalFormattingViewModel)),be(4,i.Inject(i.IUniverInstanceService))],Ie);var rt=Object.getOwnPropertyDescriptor,tt=(t,e,l,n)=>{for(var a=n>1?void 0:n?rt(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},er=(t,e)=>(l,n)=>e(l,n,t);let Ce=class extends i.Disposable{constructor(t,e,l){super(),this._localeService=t,this._commandService=e,this._sheetPermissionCheckController=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===r.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[P.WorkbookEditablePermission],rangeTypes:[P.RangeProtectionPermissionEditPoint],worksheetTypes:[P.WorksheetEditPermission,P.WorksheetSetCellStylePermission]},t.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Ce=tt([er(0,i.Inject(i.LocaleService)),er(1,i.ICommandService),er(2,i.Inject(P.SheetPermissionCheckController))],Ce);var nt=Object.getOwnPropertyDescriptor,at=(t,e,l,n)=>{for(var a=n>1?void 0:n?nt(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},ke=(t,e)=>(l,n)=>e(l,n,t);let Te=class extends i.Disposable{constructor(t,e,l,n){super(),this._conditionalFormattingRuleModel=t,this._univerInstanceService=e,this._injector=l,this._refRangeService=n,this._initRefRange()}_initRefRange(){const t=new Map,e=(n,a,u)=>`${n}_${a}_${u}`,l=(n,a,u)=>{const c=o=>{const v=[...u.ranges],d=v.map(h=>P.handleDefaultRangeChangeWithEffectRefCommands(h,o)).filter(h=>!!h);if(r.isRangesEqual(d,v))return{redos:[],undos:[]};if(d.length){const h={unitId:n,subUnitId:a,rule:{...u,ranges:d}},S=[{id:r.SetConditionalRuleMutation.id,params:h}],_=r.setConditionalRuleMutationUndoFactory(this._injector,h);return{redos:S,undos:_}}else{const h={unitId:n,subUnitId:a,cfId:u.cfId},S=[{id:r.DeleteConditionalRuleMutation.id,params:h}],_=r.DeleteConditionalRuleMutationUndoFactory(this._injector,h);return{redos:S,undos:_}}},p=[];u.ranges.forEach(o=>{const v=this._refRangeService.registerRefRange(o,c);p.push(()=>v.dispose())}),t.set(e(n,a,u.cfId),()=>p.forEach(o=>o()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(n=>{const{unitId:a,subUnitId:u,rule:c}=n,p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!(n.unitId!==p.getUnitId()||n.subUnitId!==(o==null?void 0:o.getSheetId())))switch(n.type){case"add":{l(n.unitId,n.subUnitId,n.rule);break}case"delete":{const v=t.get(e(a,u,c.cfId));v&&v();break}case"set":{const v=t.get(e(a,u,c.cfId));v&&v(),l(n.unitId,n.subUnitId,n.rule)}}})),this.disposeWithMe(i.toDisposable(()=>{t.forEach(n=>{n()}),t.clear()}))}};Te=at([ke(0,i.Inject(r.ConditionalFormattingRuleModel)),ke(1,i.Inject(i.IUniverInstanceService)),ke(2,i.Inject(i.Injector)),ke(3,i.Inject(P.RefRangeService))],Te);var lt=Object.getOwnPropertyDescriptor,ut=(t,e,l,n)=>{for(var a=n>1?void 0:n?lt(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},ce=(t,e)=>(l,n)=>e(l,n,t);let _e=class extends i.Disposable{constructor(e,l,n,a,u,c){super();ee(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=l,this._univerInstanceService=n,this._renderManagerService=a,this._conditionalFormattingViewModel=u,this._conditionalFormattingRuleModel=c,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var l,n,a;const e=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();(l=this._renderManagerService.getRenderById(e))==null||l.with(W.SheetSkeletonManagerService).reCalculate(),(a=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||a.makeDirty()}_initSkeleton(){this.disposeWithMe(X.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(fe.bufferTime(16),fe.filter(e=>!!e.length),fe.filter(e=>{const l=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!l)return!1;const n=l.getActiveSheet();return n?e.filter(a=>a.unitId===l.getUnitId()&&a.subUnitId===n.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(P.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,handler:(e,l,n)=>{const a=this._conditionalFormattingService.composeStyle(l.unitId,l.subUnitId,l.row,l.col);if(!a)return n(e);const u=l.workbook.getStyles(),p={...(typeof(e==null?void 0:e.s)=="string"?u.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}},o={...e,s:p};return a.style&&Object.assign(p,a.style),o.fontRenderExtension||(o.fontRenderExtension={},a.isShowValue!==void 0&&(o.fontRenderExtension.isSkip=!a.isShowValue)),a.dataBar&&(o.dataBar=a.dataBar),a.iconSet&&(o.iconSet=a.iconSet,o.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(o)},priority:10}))}};_e=ut([ce(0,i.Inject(P.SheetInterceptorService)),ce(1,i.Inject(r.ConditionalFormattingService)),ce(2,i.Inject(i.IUniverInstanceService)),ce(3,i.Inject(ar.IRenderManagerService)),ce(4,i.Inject(r.ConditionalFormattingViewModel)),ce(5,i.Inject(r.ConditionalFormattingRuleModel))],_e);const yr="sheets-conditional-formatting-ui.config",Pe={};var it=Object.defineProperty,st=Object.getOwnPropertyDescriptor,ct=(t,e,l)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[e]=l,ot=(t,e,l,n)=>{for(var a=n>1?void 0:n?st(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},rr=(t,e)=>(l,n)=>e(l,n,t),gr=(t,e,l)=>ct(t,typeof e!="symbol"?e+"":e,l);D.UniverSheetsConditionalFormattingMobileUIPlugin=class extends i.Plugin{constructor(e=Pe,l,n,a){super(),this._config=e,this._injector=l,this._commandService=n,this._configService=a;const{menu:u,...c}=i.merge({},Pe,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(yr,c),this._initCommand(),this._injector.add([_e]),this._injector.add([Te]),this._injector.add([Ie]),this._injector.add([Ce]),this._injector.add([se])}_initCommand(){[He,We,qe,Ge,ze,Ye,Ze,Ke,Xe,Se].forEach(e=>{this._commandService.registerCommand(e)})}},gr(D.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),gr(D.UniverSheetsConditionalFormattingMobileUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingMobileUIPlugin=ot([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin),rr(1,i.Inject(i.Injector)),rr(2,i.Inject(i.ICommandService)),rr(3,i.IConfigService)],D.UniverSheetsConditionalFormattingMobileUIPlugin);var dt=Object.getOwnPropertyDescriptor,vt=(t,e,l,n)=>{for(var a=n>1?void 0:n?dt(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},xe=(t,e)=>(l,n)=>e(l,n,t);let De=class extends i.Disposable{constructor(t,e,l,n,a){super(),this._injector=t,this._univerInstanceService=e,this._autoFillService=l,this._conditionalFormattingRuleModel=n,this._conditionalFormattingViewModel=a,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),e=(a,u,c,p,o)=>{var S;const v=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(S=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId();if(!v||!d)return;const f={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},h={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};i.Range.foreach(c,(_,b)=>{const E=i.Rectangle.getPositionRange({startRow:_,startColumn:b,endColumn:b,endRow:_},f),N=i.Rectangle.getPositionRange({startRow:_,startColumn:b,endColumn:b,endRow:_},h),{row:M,col:w}=o(E.startRow,E.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(v,d,M,w),{row:y,col:I}=o(N.startRow,N.startColumn),T=this._conditionalFormattingViewModel.getCellCfs(v,d,y,I);T&&T.forEach(C=>{let U=p.get(C.cfId);if(!p.get(C.cfId)){const V=this._conditionalFormattingRuleModel.getRule(v,d,C.cfId);if(!V)return;U=new i.ObjectMatrix,V.ranges.forEach(k=>{i.Range.foreach(k,(L,g)=>{U.setValue(L,g,1)})}),p.set(C.cfId,U)}U.realDeleteValue(y,I)}),R&&R.forEach(C=>{let U=p.get(C.cfId);if(!p.get(C.cfId)){const V=this._conditionalFormattingRuleModel.getRule(v,d,C.cfId);if(!V)return;U=new i.ObjectMatrix,V.ranges.forEach(k=>{i.Range.foreach(k,(L,g)=>{U.setValue(L,g,1)})}),p.set(C.cfId,U)}U.setValue(y,I,1)})})},l=(a,u)=>{var N,M,w;const c=(N=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:N.getUnitId(),p=(w=(M=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:M.getActiveSheet())==null?void 0:w.getSheetId(),o=new Map,v=[],d=[];if(!c||!p)return t();const f=W.virtualizeDiscreteRanges([a,u]),[h,S]=f.ranges,{mapFunc:_}=f,b={row:h.startRow,col:h.startColumn};return W.getAutoFillRepeatRange(h,S).forEach(R=>{e(b,R.repeatStartCell,R.relativeRange,o,_)}),o.forEach((R,y)=>{const I=this._conditionalFormattingRuleModel.getRule(c,p,y);if(!I)return;const T=P.findAllRectangle(P.createTopMatrixFromMatrix(R));if(T.length){const C={unitId:c,subUnitId:p,rule:{...I,ranges:T}};v.push({id:r.SetConditionalRuleMutation.id,params:C}),d.push(...r.setConditionalRuleMutationUndoFactory(this._injector,C))}else{const C={unitId:c,subUnitId:p,cfId:I.cfId};v.push({id:r.DeleteConditionalRuleMutation.id,params:C}),d.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,C))}}),{undos:d,redos:v}},n={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(a,u,c)=>{if(c===W.APPLY_TYPE.COPY||c===W.APPLY_TYPE.ONLY_FORMAT||c===W.APPLY_TYPE.SERIES){const{source:p,target:o}=a;return l(p,o)}return t()}};this.disposeWithMe(this._autoFillService.addHook(n))}};De=vt([xe(0,i.Inject(i.Injector)),xe(1,i.Inject(i.IUniverInstanceService)),xe(2,i.Inject(W.IAutoFillService)),xe(3,i.Inject(r.ConditionalFormattingRuleModel)),xe(4,i.Inject(r.ConditionalFormattingViewModel))],De);var pt=Object.getOwnPropertyDescriptor,ft=(t,e,l,n)=>{for(var a=n>1?void 0:n?pt(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},Ne=(t,e)=>(l,n)=>e(l,n,t);D.ConditionalFormattingClearController=class extends i.Disposable{constructor(e,l,n,a,u){super(),this._injector=e,this._univerInstanceService=l,this._sheetInterceptorService=n,this._selectionManagerService=a,this._conditionalFormattingRuleModel=u,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var u;const l=[],n=[],a={redos:l,undos:n};if([P.ClearSelectionFormatCommand.id,P.ClearSelectionAllCommand.id].includes(e.id)){const c=(u=this._selectionManagerService.getCurrentSelections())==null?void 0:u.map(_=>_.range);if(!c)return a;const p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!o)return a;const v=p.getUnitId(),d=o.getSheetId(),f=this._conditionalFormattingRuleModel.getSubunitRules(v,d);if(!f||!f.length)return a;const{redos:h,undos:S}=mr(this._injector,f,c,v,d);l.push(...h),n.push(...S)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:l,ranges:n})=>{const a=[],u=[],c={redos:a,undos:u};if(!n||!n.length)return c;const p=this._conditionalFormattingRuleModel.getSubunitRules(e,l);if(!p||!p.length)return c;const{redos:o,undos:v}=mr(this._injector,p,n,e,l);return a.push(...o),u.push(...v),c}}))}},D.ConditionalFormattingClearController=ft([Ne(0,i.Inject(i.Injector)),Ne(1,i.Inject(i.IUniverInstanceService)),Ne(2,i.Inject(P.SheetInterceptorService)),Ne(3,i.Inject(P.SheetsSelectionsService)),Ne(4,i.Inject(r.ConditionalFormattingRuleModel))],D.ConditionalFormattingClearController);function mr(t,e,l,n,a){const u=[],c=[];return e.filter(p=>l.some(o=>p.ranges.some(v=>i.Rectangle.getIntersects(v,o)))).forEach(p=>{const v=new P.RangeMergeUtil().add(...p.ranges).subtract(...l).merge();if(v.length){const d={id:r.SetConditionalRuleMutation.id,params:{unitId:n,subUnitId:a,rule:{...p,ranges:v}}},f=r.setConditionalRuleMutationUndoFactory(t,d.params);u.push(d),c.push(...f)}else{const d={id:r.DeleteConditionalRuleMutation.id,params:{unitId:n,subUnitId:a,cfId:p.cfId}},f=r.DeleteConditionalRuleMutationUndoFactory(t,d.params);u.push(d),c.push(...f)}}),{redos:u,undos:c}}var ht=Object.getOwnPropertyDescriptor,yt=(t,e,l,n)=>{for(var a=n>1?void 0:n?ht(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},Sr=(t,e)=>(l,n)=>e(l,n,t);let je=class extends i.Disposable{constructor(t,e){super(),this._sheetInterceptorService=t,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(i.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(P.AFTER_CELL_EDIT,{handler:(t,e,l)=>{var c,p,o;t||l(t);const n=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),a=(c=n==null?void 0:n.style)!=null?c:{},u=Object.keys(a);if(t!=null&&t.p)return(o=(p=t.p.body)==null?void 0:p.textRuns)==null||o.forEach(v=>{v.ts&&u.forEach(d=>{var f;(f=v.ts)==null||delete f[d]})}),l(t);{const v={...(typeof(t==null?void 0:t.s)=="string"?e.workbook.getStyles().get(t.s):t==null?void 0:t.s)||{}};u.forEach(f=>{delete v[f]});const d={...t,s:{...v}};return l(d)}}})))}};je=yt([Sr(0,i.Inject(P.SheetInterceptorService)),Sr(1,i.Inject(r.ConditionalFormattingService))],je);const br=[P.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],Ee=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:Z.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:Z.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:Z.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:Z.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:Z.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:Z.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:Z.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:Z.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:Z.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:Z.clearWorkSheetRules}],gt=t=>{const e=t.get(P.SheetsSelectionsService),l=t.get(i.ICommandService),n=t.get(i.IUniverInstanceService),a=t.get(r.ConditionalFormattingRuleModel),u=new X.Observable(o=>X.merge(e.selectionMoveEnd$,e.selectionSet$,new X.Observable(v=>{const d=l.onCommandExecuted(f=>{var b;const{id:h,params:S}=f,_=(b=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:b.getUnitId();br.includes(h)&&S.unitId===_&&v.next(null)});return()=>d.dispose()})).pipe(fe.debounceTime(16)).subscribe(()=>{var b;const v=((b=e.getCurrentSelections())==null?void 0:b.map(E=>E.range))||[],d=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!d)return;const f=d.getActiveSheet();if(!f)return;const _=(a.getSubunitRules(d.getUnitId(),f.getSheetId())||[]).filter(E=>E.ranges.some(N=>v.some(M=>i.Rectangle.intersects(M,N)))).map(E=>E.ranges).every(E=>P.checkRangesEditablePermission(t,d.getUnitId(),f.getSheetId(),E));o.next(_)})),c=new X.Observable(o=>new X.Observable(v=>{const d=l.onCommandExecuted(f=>{var b;const{id:h,params:S}=f,_=(b=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:b.getUnitId();br.includes(h)&&S.unitId===_&&v.next(null)});return()=>d.dispose()}).pipe(fe.debounceTime(16)).subscribe(()=>{const v=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!v)return;const d=v.getActiveSheet();if(!d)return;const f=a.getSubunitRules(v.getUnitId(),d.getSheetId())||[];if(!f.length)return o.next(!1),!1;const h=f.map(S=>S.ranges).every(S=>P.checkRangesEditablePermission(t,v.getUnitId(),d.getSheetId(),S));o.next(h)})),p=new X.Observable(o=>{u.subscribe(v=>{const d=Ee.find(f=>f.value===Z.clearRangeRules);d&&(d.disabled=!v,o.next(Ee))}),c.subscribe(v=>{const d=Ee.find(f=>f.value===Z.clearWorkSheetRules);d&&(d.disabled=!v,o.next(Ee))}),o.next(Ee)});return{id:Se.id,type:j.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:p,hidden$:j.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(t,{workbookTypes:[P.WorkbookEditablePermission],worksheetTypes:[P.WorksheetSetCellStylePermission,P.WorksheetEditPermission],rangeTypes:[P.RangeProtectionPermissionEditPoint]})}},mt={[j.RibbonDataGroup.RULES]:{[Se.id]:{order:1,menuItemFactory:gt}}};var St=Object.getOwnPropertyDescriptor,bt=(t,e,l,n)=>{for(var a=n>1?void 0:n?St(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},Ir=(t,e)=>(l,n)=>e(l,n,t);let Le=class extends i.Disposable{constructor(e,l){super();ee(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=l,this._menuManagerService.mergeMenu(mt)}};Le=bt([Ir(0,i.Inject(i.Injector)),Ir(1,j.IMenuManagerService)],Le);var It=Object.getOwnPropertyDescriptor,Ct=(t,e,l,n)=>{for(var a=n>1?void 0:n?It(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},oe=(t,e)=>(l,n)=>e(l,n,t);const Tt=(t,e)=>{const l=d=>d.endRow-d.startRow+1,n=d=>d.endColumn-d.startColumn+1,a=l(e)%l(t),u=n(e)%n(t),c=Math.floor(l(e)/l(t)),p=Math.floor(n(e)/n(t)),o=[],v={startRow:0,endRow:l(t)-1,startColumn:0,endColumn:n(t)-1};if(l(e)===1&&n(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return o.push({repeatRelativeRange:v,startRange:d}),o}for(let d=0;d<c+(a?.1:0);d++)for(let f=0;f<p+(u?.1:0);f++){const h=l(t)*d,S=n(t)*f,_={startRow:h+e.startRow,endRow:h+e.startRow,startColumn:S+e.startColumn,endColumn:S+e.startColumn};let b=v;d===c&&a&&(b={...b},b.endRow=b.endRow-(l(t)-a)),f===p&&u&&(b={...b},b.endColumn=b.endColumn-(n(t)-u)),o.push({repeatRelativeRange:b,startRange:_})}return o};let Ae=class extends i.Disposable{constructor(e,l,n,a,u,c){super();ee(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=l,this._formatPainterService=n,this._sheetsSelectionsService=a,this._conditionalFormattingRuleModel=u,this._conditionalFormattingViewModel=c,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),l=(u,c,p,o,v)=>{const{unitId:d,subUnitId:f}=this._painterConfig,{targetUnitId:h,targetSubUnitId:S}=v,_={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row},b={startRow:c.row,startColumn:c.col,endColumn:c.col,endRow:c.row};i.Range.foreach(p,(E,N)=>{const M=i.Rectangle.getPositionRange({startRow:E,startColumn:N,endColumn:N,endRow:E},_),w=i.Rectangle.getPositionRange({startRow:E,startColumn:N,endColumn:N,endRow:E},b),R=this._conditionalFormattingViewModel.getCellCfs(d,f,M.startRow,M.startColumn),y=this._conditionalFormattingViewModel.getCellCfs(h,S,w.startRow,w.startColumn);y&&y.forEach(I=>{let T=o.get(I.cfId);if(!o.get(I.cfId)){const C=this._conditionalFormattingRuleModel.getRule(h,S,I.cfId);if(!C)return;T=new i.ObjectMatrix,C.ranges.forEach(U=>{i.Range.foreach(U,(V,k)=>{T.setValue(V,k,1)})}),o.set(I.cfId,T)}T.realDeleteValue(w.startRow,w.startColumn)}),R&&R.forEach(I=>{const T=o.get(I.cfId);T&&T.setValue(w.startRow,w.startColumn,1)})})},n=(u,c,p)=>{var M;const{range:o,unitId:v,subUnitId:d}=this._painterConfig,f=u!==v||d!==c,h=new Map,S=[],_=[];if(!u||!c||!v||!d)return e();const b=(M=this._conditionalFormattingRuleModel.getSubunitRules(v,d))!=null?M:[];b==null||b.forEach(w=>{const{ranges:R,cfId:y}=w;if(R.some(I=>i.Rectangle.intersects(o,I))){const I=new i.ObjectMatrix;f||R.forEach(T=>{i.Range.foreach(T,(C,U)=>{I.setValue(C,U,1)})}),h.set(y,I)}});const E={row:o.startRow,col:o.startColumn};return Tt(o,p).forEach(w=>{l(E,{row:w.startRange.startRow,col:w.startRange.startColumn},w.repeatRelativeRange,h,{targetUnitId:u,targetSubUnitId:c})}),h.forEach((w,R)=>{if(f){const y=this._conditionalFormattingRuleModel.getRule(u,c,R),I=P.findAllRectangle(P.createTopMatrixFromMatrix(w));if(y)if(I.length){const T={unitId:u,subUnitId:c,rule:{...y,ranges:I}};S.push({id:r.SetConditionalRuleMutation.id,params:T}),_.push(...r.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:u,subUnitId:c,cfId:y.cfId};S.push({id:r.DeleteConditionalRuleMutation.id,params:T}),_.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}else if(I.length){const T=this._conditionalFormattingRuleModel.getRule(v,d,R);if(T){const C={unitId:u,subUnitId:c,rule:{...i.Tools.deepClone(T),cfId:this._conditionalFormattingRuleModel.createCfId(u,c),ranges:I}};S.push({id:r.AddConditionalRuleMutation.id,params:C}),_.push(r.AddConditionalRuleMutationUndoFactory(this._injector,C))}}}else{const y=this._conditionalFormattingRuleModel.getRule(v,d,R);if(!y)return;const I=P.findAllRectangle(P.createTopMatrixFromMatrix(w));if(I.length){const T={unitId:v,subUnitId:d,rule:{...y,ranges:I}};S.push({id:r.SetConditionalRuleMutation.id,params:T}),_.push(...r.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:v,subUnitId:d,cfId:y.cfId};S.push({id:r.DeleteConditionalRuleMutation.id,params:T}),_.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}}}),{undos:_,redos:S}},a={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:u=>{var c,p,o;switch(u){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const v=(c=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:c.getUnitId(),d=(o=(p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getActiveSheet())==null?void 0:o.getSheetId(),f=this._sheetsSelectionsService.getCurrentLastSelection(),h=f==null?void 0:f.range;v&&d&&h&&(this._painterConfig={unitId:v,subUnitId:d,range:h});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(u,c,p)=>this._painterConfig?n(u,c,p):{redos:[],undos:[]}};this._formatPainterService.addHook(a)}};Ae=Ct([oe(0,i.Inject(i.Injector)),oe(1,i.Inject(i.IUniverInstanceService)),oe(2,i.Inject(W.IFormatPainterService)),oe(3,i.Inject(P.SheetsSelectionsService)),oe(4,i.Inject(r.ConditionalFormattingRuleModel)),oe(5,i.Inject(r.ConditionalFormattingViewModel))],Ae);var _t=Object.getOwnPropertyDescriptor,xt=(t,e,l,n)=>{for(var a=n>1?void 0:n?_t(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},tr=(t,e)=>(l,n)=>e(l,n,t);let Fe=class extends i.Disposable{constructor(t,e,l){super(),this._conditionalFormattingViewModel=t,this._univerInstanceService=e,this._renderManagerService=l,this._init()}_init(){const t=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),e=l=>{const n=l.getUnitId(),a=this._renderManagerService.getRenderById(n);if(!a)return;const u=a.with(W.SheetSkeletonManagerService);this.disposeWithMe(u.currentSkeleton$.subscribe(c=>{if(c){const p=c.skeleton.rowColumnSegment,o=p.endColumn-p.startColumn+1,d=(p.endRow-p.startRow+1)*o*9,f=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(f)}}))};t&&e(t),this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(l=>{l&&e(l)})}};Fe=xt([tr(0,i.Inject(r.ConditionalFormattingViewModel)),tr(1,i.IUniverInstanceService),tr(2,ar.IRenderManagerService)],Fe);var Nt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Mt=(t,e,l)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[e]=l,Rt=(t,e,l,n)=>{for(var a=n>1?void 0:n?Et(e,l):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(a=c(a)||a);return a},nr=(t,e)=>(l,n)=>e(l,n,t),Cr=(t,e,l)=>Mt(t,typeof e!="symbol"?e+"":e,l);D.UniverSheetsConditionalFormattingUIPlugin=class extends i.Plugin{constructor(e=Pe,l,n,a){super(),this._config=e,this._injector=l,this._commandService=n,this._configService=a;const{menu:u,...c}=i.merge({},Pe,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(yr,c),this._initCommand()}onStarting(){i.registerDependencies(this._injector,[[_e],[Te],[Ie],[De],[Ce],[me],[Le],[se],[je],[D.ConditionalFormattingClearController],[Ae],[Fe]]),i.touchDependencies(this._injector,[[_e]])}onReady(){i.touchDependencies(this._injector,[[Le],[me]])}onRendered(){i.touchDependencies(this._injector,[[De],[D.ConditionalFormattingClearController],[Ie],[je],[se],[Ae],[Ce],[Te],[Fe]])}_initCommand(){[He,We,qe,Ge,ze,Ye,Ze,Ke,Xe,Se].forEach(e=>{this._commandService.registerCommand(e)})}},Cr(D.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Cr(D.UniverSheetsConditionalFormattingUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingUIPlugin=Rt([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin),nr(1,i.Inject(i.Injector)),nr(2,i.Inject(i.ICommandService)),nr(3,i.IConfigService)],D.UniverSheetsConditionalFormattingUIPlugin),D.AddAverageCfCommand=He,D.AddColorScaleConditionalRuleCommand=We,D.AddDataBarConditionalRuleCommand=qe,D.AddDuplicateValuesCfCommand=Ge,D.AddNumberCfCommand=ze,D.AddRankCfCommand=Ye,D.AddTextCfCommand=Ze,D.AddTimePeriodCfCommand=Ke,D.AddUniqueValuesCfCommand=Xe,D.OpenConditionalFormattingOperator=Se,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-conditional-formatting-ui",
|
|
3
|
-
"version": "0.7.0-nightly.
|
|
3
|
+
"version": "0.7.0-nightly.202505221607",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Conditional formatting plugin for Univer Sheets",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@univerjs/icons": "^0.3.24",
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/engine-formula": "0.7.0-nightly.
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/sheets": "0.7.0-nightly.
|
|
64
|
-
"@univerjs/sheets-formula-ui": "0.7.0-nightly.
|
|
65
|
-
"@univerjs/ui": "0.7.0-nightly.
|
|
66
|
-
"@univerjs/
|
|
58
|
+
"@univerjs/design": "0.7.0-nightly.202505221607",
|
|
59
|
+
"@univerjs/core": "0.7.0-nightly.202505221607",
|
|
60
|
+
"@univerjs/engine-formula": "0.7.0-nightly.202505221607",
|
|
61
|
+
"@univerjs/sheets": "0.7.0-nightly.202505221607",
|
|
62
|
+
"@univerjs/engine-render": "0.7.0-nightly.202505221607",
|
|
63
|
+
"@univerjs/sheets-conditional-formatting": "0.7.0-nightly.202505221607",
|
|
64
|
+
"@univerjs/sheets-formula-ui": "0.7.0-nightly.202505221607",
|
|
65
|
+
"@univerjs/sheets-ui": "0.7.0-nightly.202505221607",
|
|
66
|
+
"@univerjs/ui": "0.7.0-nightly.202505221607"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"postcss": "^8.5.3",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"tailwindcss": "^3.4.17",
|
|
73
73
|
"typescript": "^5.8.3",
|
|
74
74
|
"vite": "^6.3.5",
|
|
75
|
-
"vitest": "^3.1.
|
|
75
|
+
"vitest": "^3.1.4",
|
|
76
76
|
"@univerjs-infra/shared": "0.7.0"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|