@univerjs/sheets-conditional-formatting-ui 0.21.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/umd/index.js CHANGED
@@ -1,6 +1,6 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/sheets`),require(`@univerjs/sheets-conditional-formatting`),require(`@univerjs/ui`),require(`react`),require(`@univerjs/design`),require(`@univerjs/engine-formula`),require(`@univerjs/sheets-formula-ui`),require(`react/jsx-runtime`),require(`@univerjs/sheets-ui`),require(`rxjs`),require(`@univerjs/sheets-formula`),require(`@univerjs/engine-render`),require(`rxjs/operators`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-conditional-formatting`,`@univerjs/ui`,`react`,`@univerjs/design`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`,`react/jsx-runtime`,`@univerjs/sheets-ui`,`rxjs`,`@univerjs/sheets-formula`,`@univerjs/engine-render`,`rxjs/operators`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsConditionalFormattingUi={},e.UniverCore,e.UniverSheets,e.UniverSheetsConditionalFormatting,e.UniverUi,e.React,e.UniverDesign,e.UniverEngineFormula,e.UniverSheetsFormulaUi,e.React,e.UniverSheetsUi,e.rxjs,e.UniverSheetsFormula,e.UniverEngineRender,e.rxjs.operators))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let h={type:t.CommandType.COMMAND,id:`sheet.command.add-average-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c}=i,l=e.get(r.ConditionalFormattingRuleModel),u=e.get(t.ICommandService),d=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!d)return!1;let{unitId:f,subUnitId:p}=d,m={ranges:a,cfId:l.createCfId(f,p),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:c,style:o}};return u.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:p,rule:m})}},g={type:t.CommandType.COMMAND,id:`sheet.command.add-color-scale-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,config:o,stopIfTrue:s}=i,c=e.get(r.ConditionalFormattingRuleModel),l=e.get(t.ICommandService),u=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!u)return!1;let{unitId:d,subUnitId:f}=u,p={ranges:a,cfId:c.createCfId(d,f),stopIfTrue:!!s,rule:{type:r.CFRuleType.colorScale,config:o}};return l.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:p})}},_={type:t.CommandType.COMMAND,id:`sheet.command.add-data-bar-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,min:o,max:s,nativeColor:c,positiveColor:l,isGradient:u,stopIfTrue:d,isShowValue:f}=i,p=e.get(r.ConditionalFormattingRuleModel),m=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!m)return!1;let{unitId:h,subUnitId:g}=m,_=e.get(t.ICommandService),v={ranges:a,cfId:p.createCfId(h,g),stopIfTrue:!!d,rule:{type:r.CFRuleType.dataBar,isShowValue:f,config:{min:o,max:s,nativeColor:c,positiveColor:l,isGradient:u}}};return _.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:g,rule:v})}},v={type:t.CommandType.COMMAND,id:`sheet.command.add-duplicate-values-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s}=i,c=e.get(r.ConditionalFormattingRuleModel),l=e.get(t.ICommandService),u=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!u)return!1;let{unitId:d,subUnitId:f}=u,p={ranges:a,cfId:c.createCfId(d,f),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:o}};return l.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:p})}},y={type:t.CommandType.COMMAND,id:`sheet.command.add-number-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c,value:l}=i,u=e.get(r.ConditionalFormattingRuleModel),d=e.get(t.ICommandService),f=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!f)return!1;let{unitId:p,subUnitId:m}=f,h=u.createCfId(p,m),g;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(c)){let e=l;if(e.length!==2||!Array.isArray(e))return!1;g={ranges:a,cfId:h,stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:c,style:o,value:e}}}else{let e=l;if(typeof e!=`number`)return!1;g={ranges:a,cfId:h,stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:c,style:o,value:e}}}return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:p,subUnitId:m,rule:g})}},b={type:t.CommandType.COMMAND,id:`sheet.command.add-rank-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,isPercent:c,isBottom:l,value:u}=i,d=e.get(r.ConditionalFormattingRuleModel),f=e.get(t.IUniverInstanceService),p=e.get(t.ICommandService),m=(0,n.getSheetCommandTarget)(f);if(!m)return!1;let{unitId:h,subUnitId:g}=m,_={ranges:a,cfId:d.createCfId(h,g),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:c,isBottom:l,style:o,value:u}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:g,rule:_})}},x={type:t.CommandType.COMMAND,id:`sheet.command.add-text-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c,value:l}=i,u=e.get(r.ConditionalFormattingRuleModel),d=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!d)return!1;let{unitId:f,subUnitId:p}=d,m=e.get(t.ICommandService),h={ranges:a,cfId:u.createCfId(f,p),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:c,style:o,value:l}};return m.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:p,rule:h})}},S={type:t.CommandType.COMMAND,id:`sheet.command.add-time-period-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c}=i,l=e.get(r.ConditionalFormattingRuleModel),u=e.get(t.IUniverInstanceService),d=e.get(t.ICommandService),f=(0,n.getSheetCommandTarget)(u);if(!f)return!1;let{unitId:p,subUnitId:m}=f,h={ranges:a,cfId:l.createCfId(p,m),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:c,style:o}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:p,subUnitId:m,rule:h})}},C={type:t.CommandType.COMMAND,id:`sheet.command.add-uniqueValues-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s}=i,c=e.get(r.ConditionalFormattingRuleModel),l=e.get(t.IUniverInstanceService),u=e.get(t.ICommandService),d=(0,n.getSheetCommandTarget)(l);if(!d)return!1;let{unitId:f,subUnitId:p}=d,m={ranges:a,cfId:c.createCfId(f,p),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:o}};return u.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:p,rule:m})}};function w({ref:e,...t}){let{icon:n,id:r,className:i,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),l=(0,a.useRef)(`_${O()}`);return T(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:c,...s},o)}function T(e,t,n,r,i){return(0,a.createElement)(e.tag,{key:t,...E(e,n,i),...r},(D(e,n).children||[]).map((r,a)=>T(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function E(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function D(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function O(){return Math.random().toString(36).substring(2,8)}w.displayName=`UniverIcon`;let k={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},A=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`bold-icon`,ref:t,icon:k}))});A.displayName=`BoldIcon`;let j={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.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.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.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`}}]},M=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`delete-icon`,ref:t,icon:j}))});M.displayName=`DeleteIcon`;let N={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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`}}]},P=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`increase-icon`,ref:t,icon:N}))});P.displayName=`IncreaseIcon`;let F={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z`}}]},ee=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`italic-icon`,ref:t,icon:F}))});ee.displayName=`ItalicIcon`;let te={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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`}}]},ne=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`more-down-icon`,ref:t,icon:te}))});ne.displayName=`MoreDownIcon`;let re={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z`}}]},ie=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`sequence-icon`,ref:t,icon:re}))});ie.displayName=`SequenceIcon`;let ae={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z`}}]},oe=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`strikethrough-icon`,ref:t,icon:ae}))});oe.displayName=`StrikethroughIcon`;let I={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z`}}]},se=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`underline-icon`,ref:t,icon:I}))});se.displayName=`UnderlineIcon`;let ce={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`colorChannel1`,d:`M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},le=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`font-color-double-icon`,ref:t,icon:ce}))});le.displayName=`FontColorDoubleIcon`;let ue={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z`}}]},de=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`paint-bucket-double-icon`,ref:t,icon:ue}))});de.displayName=`PaintBucketDoubleIcon`;let fe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,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`,fillRule:`evenodd`,clipRule:`evenodd`}}]},pe=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`slash-double-icon`,ref:t,icon:fe}))});pe.displayName=`SlashDoubleIcon`;let L=e=>{let{color:n,onChange:r,disable:i=!1,Icon:s=de,className:c}=e,u=(0,a.useMemo)(()=>new t.ColorKit(n),[n]),d=()=>(0,l.jsx)(s,{className:(0,o.clsx)(`univer-fill-primary-600`,i&&c),extend:{colorChannel1:u.isValid?n:``}});return i?d():(0,l.jsx)(o.Dropdown,{overlay:(0,l.jsx)(`div`,{className:`univer-rounded-lg univer-p-4`,children:(0,l.jsx)(o.ColorPicker,{value:n,onChange:r})}),children:(0,l.jsx)(`span`,{className:(0,o.clsx)(`univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,c),children:d()})})},R=e=>{let n=e.rule;if(!n)return null;let i=(0,a.useMemo)(()=>{if(n.type===r.CFRuleType.colorScale){let e=n.config.map((e,n)=>({color:new t.ColorKit(e.color),value:n})),i=e.length-1;return[,,,,,].fill(``).map((e,t,n)=>t*i/(n.length-1)).map(t=>(0,r.getColorScaleFromValue)(e,t))}return null},[n]),s=(0,a.useMemo)(()=>{if(n.type===r.CFRuleType.iconSet)return n.config.map(e=>{let t=r.iconMap[e.iconType];return t&&t[Number(e.iconId)]})},[n]),c=`univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs`;switch(n.type){case r.CFRuleType.dataBar:{var u,d;let{isGradient:e}=n.config,t=e?`linear-gradient(to right, ${n.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:n.config.positiveColor;return(0,l.jsxs)(`div`,{className:c,children:[(0,l.jsx)(`div`,{className:`univer-h-full univer-w-1/2 univer-border univer-border-solid`,style:{background:e?`linear-gradient(to right, rgb(255 255 255),${n.config.nativeColor||r.defaultDataBarNativeColor})`:n.config.nativeColor,borderColor:(u=n.config.nativeColor)==null?r.defaultDataBarNativeColor:u}}),(0,l.jsx)(`div`,{className:`univer-h-full univer-w-1/2 univer-border univer-border-solid`,style:{background:t,borderColor:(d=n.config.positiveColor)==null?r.defaultDataBarPositiveColor:d}})]})}case r.CFRuleType.colorScale:return i&&(0,l.jsx)(`div`,{className:c,children:i.map((e,t)=>(0,l.jsx)(`div`,{className:`univer-h-full`,style:{width:`${100/i.length}%`,background:e}},t))});case r.CFRuleType.iconSet:return s&&(0,l.jsx)(`div`,{className:c,children:s.map((e,t)=>e?(0,l.jsx)(`img`,{className:`univer-h-full`,src:e,draggable:!1},t):(0,l.jsx)(pe,{},t))});case r.CFRuleType.highlightCell:{var f,p,m;let{ul:e,st:i,it:a,bl:s,bg:u,cl:d}=n.style,h=(e==null?void 0:e.s)===t.BooleanNumber.TRUE,g=(i==null?void 0:i.s)===t.BooleanNumber.TRUE,_=a===t.BooleanNumber.TRUE,v=s===t.BooleanNumber.TRUE,y=(f=u==null?void 0:u.rgb)==null?r.DEFAULT_BG_COLOR:f,b=(p=d==null?void 0:d.rgb)==null?r.DEFAULT_FONT_COLOR:p,x={textDecoration:(m=`${h?`underline`:``} ${g?`line-through`:``}`.replace(/^ /,``))==null?void 0:m,backgroundColor:y,color:b};return(0,l.jsx)(`div`,{className:(0,o.clsx)(c,{"univer-font-bold":v,"univer-italic":_}),style:x,children:`123`})}}},z=(0,o.clsx)(`univer-mt-5 univer-px-1 univer-py-2 univer-rounded`,o.borderClassName),B=(e,t)=>({label:t.t(`sheet.cf.valueType.${e}`),value:e}),me=e=>{var n;let{type:s,className:u,onChange:d,id:f,value:p}=e,m=(0,i.useDependency)(t.IUniverInstanceService),h=m.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),g=(n=m.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId(),_=(0,a.useMemo)(()=>String(p).startsWith(`=`)?String(p):`=`,[p]),v=(0,a.useMemo)(()=>[r.CFValueType.max,r.CFValueType.min,`none`].includes(s)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(s)?{min:0,max:100}:{min:-(2**53-1),max:2**53-1},[s]),y=(0,a.useRef)(null),[b,x]=(0,a.useState)(!1);return(0,i.useSidebarClick)(e=>{var t;(t=y.current)!=null&&t.isClickOutSide(e)&&x(!1)}),s===r.CFValueType.formula?(0,l.jsx)(`div`,{className:`univer-ml-1 univer-w-full`,children:(0,l.jsx)(c.FormulaEditor,{ref:y,className:(0,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 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,o.borderClassName),initValue:_,unitId:h,subUnitId:g,isFocus:b,onChange:(e=``)=>{d(e||``)},onFocus:()=>x(!0)})}):(0,l.jsx)(o.InputNumber,{className:u,value:Number(e.value)||0,onChange:t=>e.onChange(t||0),...v})},he=e=>{var n;let{interceptorManager:s}=e,c=(0,i.useDependency)(t.LocaleService),u=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.colorScale?e.rule:void 0,d=[B(r.CFValueType.num,c),B(r.CFValueType.percent,c),B(r.CFValueType.percentile,c),B(r.CFValueType.formula,c)],f=[B(r.CFValueType.min,c),...d],p=[B(`none`,c),...d],m=[B(r.CFValueType.max,c),...d],[h,g]=(0,a.useState)(()=>{var e;let t=r.CFValueType.min;return u&&((e=u.config[0])==null?void 0:e.value.type)||t}),[_,v]=(0,a.useState)(()=>{var e;let t=`none`;return!u||u.config.length!==3?t:((e=u.config[1])==null?void 0:e.value.type)||t}),[y,b]=(0,a.useState)(()=>{var e;let t=r.CFValueType.max;return u&&((e=u.config[u.config.length-1])==null?void 0:e.value.type)||t}),[x,S]=(0,a.useState)(()=>{if(!u)return 10;let e=u.config[0];return(e==null?void 0:e.value.value)===void 0?10:e==null?void 0:e.value.value}),[C,w]=(0,a.useState)(()=>{var e;if(!u||u.config.length!==3)return 50;let t=(e=u.config[1])==null?void 0:e.value.value;return t===void 0?50:t}),[T,E]=(0,a.useState)(()=>{var e;if(!u)return 90;let t=(e=u.config[u.config.length-1])==null?void 0:e.value.value;return t===void 0?90:t}),[D,O]=(0,a.useState)(()=>{var e;return u&&((e=u.config[0])==null?void 0:e.color)||`#d0d9fb`}),[k,A]=(0,a.useState)(()=>{var e;let t=`#7790f3`;return!u||u.config.length!==3?t:((e=u.config[1])==null?void 0:e.color)||t}),[j,M]=(0,a.useState)(()=>{var e;return u&&((e=u.config[u.config.length-1])==null?void 0:e.color)||`#2e55ef`}),N=(0,a.useMemo)(()=>e=>{let{minType:t,medianType:n,maxType:i,minValue:a,medianValue:o,maxValue:s,minColor:c,medianColor:l,maxColor:u}=e,d=[];return d.push({color:c,value:{type:t,value:a}}),n!==`none`&&d.push({color:l,value:{type:n,value:o}}),d.push({color:u,value:{type:i,value:s}}),{config:d.map((e,t)=>({...e,index:t})),type:r.CFRuleType.colorScale}},[]);(0,a.useEffect)(()=>s.intercept(s.getInterceptPoints().submit,{handler(){return N({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),[N,h,_,y,x,C,T,D,k,j,s]);let P=t=>{e.onChange(N(t))};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:z,children:(0,l.jsx)(R,{rule:N({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})})}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.min`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-h-8 univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-flex-shrink-0`,options:f,value:h,onChange:e=>{g(e);let t=(0,r.createDefaultValueByValueType)(e,10);S(t),P({minType:e,medianType:_,maxType:y,minValue:t,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(me,{id:`min`,className:`univer-ml-1`,value:x,type:h,onChange:e=>{S(e),P({minType:h,medianType:_,maxType:y,minValue:e,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(L,{className:`univer-ml-1`,color:D,onChange:e=>{O(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:e,medianColor:k,maxColor:j})}})]}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.medianValue`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-h-8 univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-flex-shrink-0`,options:p,value:_,onChange:e=>{v(e);let t=(0,r.createDefaultValueByValueType)(e,50);w(t),P({minType:h,medianType:e,maxType:y,minValue:x,medianValue:t,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(me,{id:`median`,className:`univer-ml-1`,value:C,type:_,onChange:e=>{w(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:e,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),_!==`none`&&(0,l.jsx)(L,{className:`univer-ml-1`,color:k,onChange:e=>{A(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:e,maxColor:j})}})]}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.max`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-h-8 univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-flex-shrink-0`,options:m,value:y,onChange:e=>{b(e);let t=(0,r.createDefaultValueByValueType)(e,90);E(t),P({minType:h,medianType:_,maxType:e,minValue:x,medianValue:C,maxValue:t,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(me,{id:`max`,className:`univer-ml-1`,value:T,type:y,onChange:e=>{E(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:e,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(L,{className:`univer-ml-1`,color:j,onChange:e=>{M(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:e})}})]})]})},V=(e,t)=>({label:t.t(`sheet.cf.valueType.${e}`),value:e}),ge=e=>{var n;let{onChange:s,className:u,value:d,type:f,id:p,disabled:m=!1}=e,h=(0,i.useDependency)(t.IUniverInstanceService),g=h.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),_=(n=h.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId(),v=(0,a.useRef)(null),[y,b]=(0,a.useState)(!1);(0,i.useSidebarClick)(e=>{var t;(t=v.current)!=null&&t.isClickOutSide(e)&&b(!1)});let x=(0,a.useRef)(d),S=(0,a.useMemo)(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(f)?{max:100,min:0}:{min:-(2**53-1),max:2**53-1},[f]);if(f===r.CFValueType.formula){let e=String(x.current).startsWith(`=`)?String(x.current)||``:`=`;return(0,l.jsx)(`div`,{className:`univer-ml-3 univer-w-full`,children:(0,l.jsx)(c.FormulaEditor,{ref:v,className:(0,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 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,o.borderClassName),initValue:e,unitId:g,subUnitId:_,isFocus:y,onChange:(e=``)=>{s(e||``)},onFocus:()=>b(!0)})})}return(0,l.jsx)(o.InputNumber,{className:u,value:Number(d)||0,disabled:m,onChange:e=>{s(e||0)},...S})},_e=e=>{var n;let{interceptorManager:s}=e,c=(0,i.useDependency)(t.LocaleService),u=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.dataBar?e.rule:void 0,[d,f]=(0,a.useState)(()=>{var e;return u&&(e=u.config)!=null&&e.isGradient?`1`:`0`}),[p,m]=(0,a.useState)(()=>{var e;return u&&((e=u.config)==null?void 0:e.positiveColor)||r.defaultDataBarPositiveColor}),[h,g]=(0,a.useState)(()=>{var e;return u&&((e=u.config)==null?void 0:e.nativeColor)||r.defaultDataBarNativeColor}),_=[V(r.CFValueType.num,c),V(r.CFValueType.percent,c),V(r.CFValueType.percentile,c),V(r.CFValueType.formula,c)],v=[V(r.CFValueType.min,c),..._],y=[V(r.CFValueType.max,c),..._],[b,x]=(0,a.useState)(()=>{var e;let t=v[0].value;return u&&((e=u.config)==null?void 0:e.min.type)||t}),[S,C]=(0,a.useState)(()=>{var e;let t=y[0].value;return u&&((e=u.config)==null?void 0:e.max.type)||t}),[w,T]=(0,a.useState)(()=>{var e;if(!u)return 0;let t=((e=u.config)==null?void 0:e.min)||{};return t.type===r.CFValueType.formula?t.value||`=`:t.value||0}),[E,D]=(0,a.useState)(()=>{var e;if(!u)return 100;let t=((e=u.config)==null?void 0:e.max)||{};return t.type===r.CFValueType.formula?t.value||`=`:t.value===void 0?100:t.value}),[O,k]=(0,a.useState)(()=>u?u.isShowValue===void 0?!0:!!u.isShowValue:!0),A=e=>({config:{min:{type:e.minValueType,value:e.minValue},max:{type:e.maxValueType,value:e.maxValue},isGradient:e.isGradient===`1`,positiveColor:e.positiveColor||r.defaultDataBarPositiveColor,nativeColor:e.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:e.isShowValue});(0,a.useEffect)(()=>s.intercept(s.getInterceptPoints().submit,{handler(){return A({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}}),[d,w,b,E,S,p,h,s,O]);let j=t=>{e.onChange(A(t))},M=e=>{m(e),j({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:e,nativeColor:h,isShowValue:O})},N=e=>{g(e),j({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:e,isShowValue:O})},P=e=>_.map(e=>e.value).includes(e);return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:z,children:(0,l.jsx)(R,{rule:A({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.fillType`)}),(0,l.jsxs)(`div`,{className:`univer-ml-1 univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsxs)(o.RadioGroup,{value:d,onChange:e=>{f(e),j({isGradient:e,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})},children:[(0,l.jsx)(o.Radio,{value:`0`,children:(0,l.jsx)(`span`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.pureColor`)})}),(0,l.jsx)(o.Radio,{value:`1`,children:(0,l.jsx)(`span`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.gradient`)})})]}),(0,l.jsxs)(`div`,{className:`univer-ml-6 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{checked:!O,onChange:e=>{k(!e),j({isGradient:e,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:!e})}}),c.t(`sheet.cf.panel.onlyShowDataBar`)]})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.colorSet`)}),(0,l.jsxs)(`div`,{className:`univer-ml-1 univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsxs)(`div`,{className:`univer-flex univer-items-center`,children:[(0,l.jsx)(`div`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.native`)}),(0,l.jsx)(L,{color:h,onChange:N})]}),(0,l.jsxs)(`div`,{className:`univer-ml-3 univer-flex univer-items-center`,children:[(0,l.jsx)(`div`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.positive`)}),(0,l.jsx)(L,{color:p,onChange:M})]})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.min`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-w-1/2 univer-flex-shrink-0`,options:v,value:b,onChange:e=>{x(e);let t=(0,r.createDefaultValueByValueType)(e,10);T(t),j({isGradient:d,minValue:t,minValueType:e,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}}),(0,l.jsx)(ge,{id:`min`,className:`univer-ml-3`,disabled:!P(b),type:b,value:w,onChange:e=>{T(e||0),j({isGradient:d,minValue:e||0,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}})]}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.max`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-w-1/2 univer-flex-shrink-0`,options:y,value:S,onChange:e=>{C(e);let t=(0,r.createDefaultValueByValueType)(e,90);D(t),j({isGradient:d,minValue:w,minValueType:b,maxValue:t,maxValueType:e,positiveColor:p,nativeColor:h,isShowValue:O})}}),(0,l.jsx)(ge,{className:`univer-ml-3`,disabled:!P(S),id:`max`,type:S,value:E,onChange:e=>{D(e||0),j({isGradient:d,minValue:w,minValueType:b,maxValue:e||0,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}})]})]})]})},ve=e=>[t.BooleanNumber.FALSE,void 0].includes(e)?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE,ye=e=>e!==t.BooleanNumber.FALSE,be=e=>{let{style:n,onChange:i,className:s}=e,[c,u]=(0,a.useState)(()=>{if(n!=null&&n.bl)return n.bl}),[d,f]=(0,a.useState)(()=>{if(n!=null&&n.it)return n.it}),[p,m]=(0,a.useState)(()=>{if(n!=null&&n.ul)return n.ul.s}),[h,g]=(0,a.useState)(()=>{if(n!=null&&n.st)return n.st.s}),[_,v]=(0,a.useState)(()=>{var e;return!(n==null||(e=n.cl)==null)&&e.rgb?n.cl.rgb:`#2f56ef`}),[y,b]=(0,a.useState)(()=>{var e;return!(n==null||(e=n.bg)==null)&&e.rgb?n.bg.rgb:`#e8ecfc`});(0,a.useEffect)(()=>{let e={bl:c,it:d};_!==void 0&&(e.cl={rgb:_}),y!==void 0&&(e.bg={rgb:y}),h!==void 0&&(e.st={s:h}),p!==void 0&&(e.ul={s:p}),i((0,r.removeUndefinedAttr)(e))},[c,d,p,h,_,y]);let x=`univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1`;return(0,l.jsxs)(`div`,{className:(0,o.clsx)(`univer-my-2.5 univer-flex univer-justify-between`,s),children:[(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ye(c||t.BooleanNumber.FALSE)}),onClick:()=>u(ve(c)),children:(0,l.jsx)(A,{})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ye(d||t.BooleanNumber.FALSE)}),onClick:()=>f(ve(d)),children:(0,l.jsx)(ee,{})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ye(p||t.BooleanNumber.FALSE)}),onClick:()=>m(ve(p)),children:(0,l.jsx)(se,{})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ye(h||t.BooleanNumber.FALSE)}),onClick:()=>g(ve(h)),children:(0,l.jsx)(oe,{})}),(0,l.jsx)(L,{color:_,onChange:v,Icon:le}),(0,l.jsx)(L,{color:y,onChange:b})]})},xe=e=>{var n;let{onChange:s,interceptorManager:u}=e,d=(0,i.useDependency)(t.LocaleService),f=(0,i.useDependency)(t.IUniverInstanceService).getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),p=f.getActiveSheet(),m=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.highlightCell?e.rule:void 0,h=(0,a.useRef)(null),[g,_]=(0,a.useState)(!1),v=(0,a.useRef)(null),[y,b]=(0,a.useState)({}),[x,S]=(0,a.useState)(()=>(m==null?void 0:m.subType)===r.CFSubRuleType.formula?m.value:`=`),[C,w]=(0,a.useState)(void 0),T=e=>({style:e.style,value:x,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});(0,a.useEffect)(()=>u.intercept(u.getInterceptPoints().submit,{handler(){return T({style:y,formula:x})}}),[y,x,u]),(0,a.useEffect)(()=>u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(e,t,n)=>C||x.length===1||!x.startsWith(`=`)?(w(d.t(`sheet.cf.errorMessage.formulaError`)),!1):n(e)}),[C,x]);let E=e=>{s(T(e))};return(0,i.useSidebarClick)(e=>{var t;(t=v.current)!=null&&t.isClickOutSide(e)&&_(!1)}),(0,l.jsxs)(`div`,{ref:h,children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:d.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(c.FormulaEditor,{ref:v,className:(0,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 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,o.borderClassName),errorText:C,isFocus:g,initValue:x,unitId:f.getUnitId(),subUnitId:p==null?void 0:p.getSheetId(),onFocus:()=>{_(!0)},onChange:e=>{S(e),E({style:y,formula:e})},onVerify:(e,t)=>{!e||t.length===1?w(d.t(`sheet.cf.errorMessage.formulaError`)):w(void 0)}})}),(0,l.jsx)(`div`,{className:z,children:(0,l.jsx)(R,{rule:T({style:y,formula:x})})}),(0,l.jsx)(be,{style:m==null?void 0:m.style,className:`univer-mt-3`,onChange:e=>{b(e),E({style:e,formula:x})}})]})},Se=e=>(0,l.jsxs)(`div`,{className:`univer-relative`,children:[(0,l.jsx)(`div`,{className:`univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500`,children:e.errorText}),e.children]}),H=(e,t)=>({label:t.t(`sheet.cf.operator.${e}`),value:e}),Ce=e=>{let{type:n,operator:s,onChange:c,value:u,interceptorManager:d}=e,f=(0,i.useDependency)(t.LocaleService),[p,m]=(0,a.useState)(()=>typeof u==`number`?u:0),[h,g]=(0,a.useState)(``),[_,v]=(0,a.useState)(()=>typeof u==`string`?u:``),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(()=>Array.isArray(u)?u[0]===void 0?0:u[0]:0),[C,w]=(0,a.useState)(``),[T,E]=(0,a.useState)(()=>Array.isArray(u)?u[1]===void 0?100:u[1]:100),[D,O]=(0,a.useState)(``);switch((0,a.useEffect)(()=>{switch(n){case r.CFSubRuleType.text:[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(s)&&c(_);break;case r.CFSubRuleType.number:[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(s)&&c(p),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(s)&&c([x,T]);break}},[n]),(0,a.useEffect)(()=>{let e=d.intercept(d.getInterceptPoints().beforeSubmit,{handler:(e,t,i)=>{switch(n){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(s))return _?i(e):(b(f.t(`sheet.cf.errorMessage.notBlank`)),!1)}return i(e)}});return()=>{e()}},[n,p,_,s]),n){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(s)){let e=e=>{v(e),c(e)};return(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(Se,{errorText:y,children:(0,l.jsx)(o.Input,{value:_,onChange:t=>{b(``),e(t)}})})})}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(s))return(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(Se,{errorText:h,children:(0,l.jsx)(o.InputNumber,{className:`univer-w-full`,min:-(2**53-1),max:2**53-1,value:p,onChange:e=>{m(e||0),c(e||0),g(``)}})})});if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(s))return(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(Se,{errorText:C,children:(0,l.jsx)(o.InputNumber,{min:-(2**53-1),max:2**53-1,value:x,onChange:e=>{S(e||0),c([e||0,T]),w(``)}})}),(0,l.jsx)(Se,{errorText:D,children:(0,l.jsx)(o.InputNumber,{className:`univer-ml-3`,min:-(2**53-1),max:2**53-1,value:T,onChange:e=>{E(e||0),c([x,e||0]),O(``)}})})]})}return null},we=(e,t)=>{switch(e){case r.CFSubRuleType.text:return[H(r.CFTextOperator.containsText,t),H(r.CFTextOperator.notContainsText,t),H(r.CFTextOperator.beginsWith,t),H(r.CFTextOperator.endsWith,t),H(r.CFTextOperator.equal,t),H(r.CFTextOperator.notEqual,t),H(r.CFTextOperator.containsBlanks,t),H(r.CFTextOperator.notContainsBlanks,t),H(r.CFTextOperator.containsErrors,t),H(r.CFTextOperator.notContainsErrors,t)];case r.CFSubRuleType.number:return[H(r.CFNumberOperator.between,t),H(r.CFNumberOperator.notBetween,t),H(r.CFNumberOperator.equal,t),H(r.CFNumberOperator.notEqual,t),H(r.CFNumberOperator.greaterThan,t),H(r.CFNumberOperator.greaterThanOrEqual,t),H(r.CFNumberOperator.lessThan,t),H(r.CFNumberOperator.lessThanOrEqual,t)];case r.CFSubRuleType.timePeriod:return[H(r.CFTimePeriodOperator.yesterday,t),H(r.CFTimePeriodOperator.today,t),H(r.CFTimePeriodOperator.tomorrow,t),H(r.CFTimePeriodOperator.last7Days,t),H(r.CFTimePeriodOperator.lastWeek,t),H(r.CFTimePeriodOperator.thisWeek,t),H(r.CFTimePeriodOperator.nextWeek,t),H(r.CFTimePeriodOperator.lastMonth,t),H(r.CFTimePeriodOperator.thisMonth,t),H(r.CFTimePeriodOperator.nextMonth,t)]}},Te=e=>{var n;let{interceptorManager:s,onChange:c}=e,u=(0,i.useDependency)(t.LocaleService),d=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.highlightCell?e.rule:void 0,[f,p]=(0,a.useState)(()=>{let e=r.CFSubRuleType.text;return d&&d.subType||e}),m=[{value:r.CFSubRuleType.text,label:u.t(`sheet.cf.subRuleType.text`)},{value:r.CFSubRuleType.number,label:u.t(`sheet.cf.subRuleType.number`)},{value:r.CFSubRuleType.timePeriod,label:u.t(`sheet.cf.subRuleType.timePeriod`)},{value:r.CFSubRuleType.duplicateValues,label:u.t(`sheet.cf.subRuleType.duplicateValues`)},{value:r.CFSubRuleType.uniqueValues,label:u.t(`sheet.cf.subRuleType.uniqueValues`)}],h=(0,a.useMemo)(()=>we(f,u),[f]),[g,_]=(0,a.useState)(()=>{let e=h?h[0].value:void 0;return d&&d.operator||e}),[v,y]=(0,a.useState)(()=>{var e;return d?(e=d.value)==null?(0,r.createDefaultValue)(d.subType,d.operator):e:``}),[b,x]=(0,a.useState)({}),S=(0,a.useMemo)(()=>e=>{var t,n,i;switch(e.subType||f){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(g)){var a,o,s,c;return{type:r.CFRuleType.highlightCell,subType:(a=e.subType)==null?f:a,operator:(o=e.operator)==null?g:o,style:(s=e.style)==null?b:s,value:(c=e.value)==null?v: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(g)){var l,u,d,p;return{type:r.CFRuleType.highlightCell,subType:(l=e.subType)==null?f:l,operator:(u=e.operator)==null?g:u,style:(d=e.style)==null?b:d,value:(p=e.value)==null?v:p}}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(g)){var m,h,_,y;return{type:r.CFRuleType.highlightCell,subType:(m=e.subType)==null?f:m,operator:(h=e.operator)==null?g:h,style:(_=e.style)==null?b:_,value:(y=e.value)==null?v:y}}break}return{type:r.CFRuleType.highlightCell,subType:(t=e.subType)==null?f:t,operator:(n=e.operator)==null?g:n,style:(i=e.style)==null?b:i}},[f,g,v,b]);(0,a.useEffect)(()=>s.intercept(s.getInterceptPoints().submit,{handler(){return S({})}}),[S,s]),(0,a.useEffect)(()=>{m.some(e=>e.value===f)||p(m[0].value)},[m]);let C=e=>{let t=e,n=we(t,u),i=n&&n[0].value;p(t),_(i),i&&y((0,r.createDefaultValue)(t,i)),c(S({subType:t,operator:i}))},w=e=>{let t=e;_(t),c(S({operator:t}))},T=e=>{y(e),c(S({value:e}))},E=(0,a.useMemo)(()=>`${f}_${g}_${Math.random()}`,[f,g]);return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:u.t(`sheet.cf.panel.styleRule`)}),(0,l.jsxs)(`div`,{className:`univer-flex univer-justify-between univer-gap-4`,children:[(0,l.jsx)(o.Select,{className:`univer-mt-3 univer-w-full`,onChange:C,value:f,options:m}),(h==null?void 0:h.length)&&(0,l.jsx)(o.Select,{className:`univer-mt-3 univer-w-full`,onChange:w,value:g||``,options:h})]}),(0,l.jsx)(Ce,{value:v,interceptorManager:s,type:f,operator:g,rule:d,onChange:T},E),(0,l.jsx)(`div`,{className:z,children:(0,l.jsx)(R,{rule:S({})})}),(0,l.jsx)(be,{style:d==null?void 0:d.style,className:`univer-ml-1`,onChange:e=>{x(e),c(S({style:e}))}})]})},Ee=(e,t)=>(r.iconMap[e]||[])[Number(t)]||``,De=e=>{var n;let{error:s,type:u,onChange:d}=e,f=(0,i.useDependency)(t.IUniverInstanceService),p=f.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),m=(n=f.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId(),h=(0,a.useRef)(null),[g,_]=(0,a.useState)(!1);return(0,i.useSidebarClick)(e=>{var t;(t=h.current)!=null&&t.isClickOutSide(e)&&_(!1)}),(0,l.jsx)(`div`,{className:`univer-relative`,children:u===r.CFValueType.formula?(0,l.jsx)(`div`,{className:`univer-w-full`,children:(0,l.jsx)(c.FormulaEditor,{ref:h,className:(0,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 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,o.borderClassName),initValue:String(e.value),unitId:p,subUnitId:m,isFocus:g,onChange:(e=``)=>{d(e||``)},onFocus:()=>_(!0)})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.InputNumber,{className:(0,o.clsx)({"univer-border-red-500":s}),value:Number(e.value)||0,onChange:e=>d(e==null?0:e)}),s&&(0,l.jsx)(`div`,{className:`univer-absolute univer-text-xs univer-text-red-500`,children:s})]})})},Oe=(e,t,n)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(n.length-1-t)*10},iconType:e,iconId:String(t)}),ke=(0,a.forwardRef)((e,n)=>{let{onClick:a}=e,o=(0,i.useDependency)(t.LocaleService),s=e=>{a(e)};return(0,l.jsx)(`div`,{ref:n,className:`univer-w-80`,children:r.iconGroup.map((e,t)=>(0,l.jsxs)(`div`,{className:`univer-mb-3`,children:[(0,l.jsx)(`div`,{className:`univer-mb-1 univer-text-sm`,children:o.t(e.title)}),(0,l.jsx)(`div`,{className:`univer-flex univer-flex-wrap`,children:e.group.map(e=>(0,l.jsx)(`div`,{className:`univer-mb-1 univer-flex univer-w-1/2 univer-items-center`,onClick:()=>{s(e.name)},children:(0,l.jsx)(`a`,{className:`univer-flex univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,children:e.list.map((e,t)=>(0,l.jsx)(`img`,{className:`univer-size-5`,src:e,draggable:!1},t))})},e.name))})]},t))})}),Ae=e=>{let{onClick:t}=e,n=(0,a.useMemo)(()=>{let e=[];for(let t in r.iconMap){let n=r.iconMap[t],i=t;n.forEach((t,n)=>{e.push({iconType:i,base64:t,iconId:String(n)})})}return e},[]),i=e=>{t(e.iconType,e.iconId)};return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{className:`univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1`,onClick:()=>i({iconType:r.EMPTY_ICON_TYPE,iconId:``,base64:``}),children:[(0,l.jsx)(pe,{className:`univer-size-5`}),(0,l.jsx)(`span`,{className:`univer-ml-2`,children:`无单元格图标`})]}),(0,l.jsx)(`div`,{className:`univer-flex univer-w-64 univer-flex-wrap`,children:n.map(e=>(0,l.jsx)(`div`,{className:`univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,children:(0,l.jsx)(`img`,{className:`univer-size-5`,src:e.base64,draggable:!1,onClick:()=>i(e)})},`${e.iconType}_${e.iconId}`))})]})},je=e=>{let{onChange:n,configList:s,errorMap:c={}}=e,u=(0,i.useDependency)(t.LocaleService),d=[{label:u.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:u.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],f=[{label:u.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:u.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:u.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:u.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],p=(e,t)=>{n([String(t),`value`,`value`],e)},m=(e,t)=>{n([String(t),`operator`],e),p((0,r.createDefaultValue)(r.CFSubRuleType.number,e),t)},h=(e,t)=>{n([String(t),`value`,`type`],e);let i=s[t];p((0,r.createDefaultValue)(r.CFSubRuleType.number,i.operator),t)};return(0,a.useMemo)(()=>s.map((e,t)=>{let i=c[t],a=Ee(e.iconType,e.iconId),g=t===s.length-1,_=t===0,v=s[t-1],y=(v==null?void 0:v.value.type)===r.CFValueType.formula?u.t(`sheet.cf.valueType.formula`):v==null?void 0:v.value.value;return(0,l.jsxs)(`div`,{className:t?`univer-mt-6`:`univer-mt-3`,children:[(0,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:[(0,l.jsxs)(`div`,{className:`univer-w-[45%]`,children:[u.t(`sheet.cf.iconSet.icon`),t+1]}),(0,l.jsx)(`div`,{className:`univer-w-[45%]`,children:(0,l.jsxs)(l.Fragment,{children:[!_&&!g&&u.t(`sheet.cf.iconSet.rule`),!_&&!g&&(0,l.jsxs)(`span`,{className:`univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200`,children:[u.t(`sheet.cf.iconSet.when`),u.t(`sheet.cf.symbol.${(0,r.getOppositeOperator)(v.operator)}`),y,g?``:` ${u.t(`sheet.cf.iconSet.and`)} `]})]})})]}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4`,children:[(0,l.jsx)(`div`,{className:`univer-flex univer-items-center`,children:(0,l.jsx)(o.Dropdown,{overlay:(0,l.jsx)(`div`,{className:`univer-rounded-lg univer-p-4`,children:(0,l.jsx)(Ae,{onClick:(r,i)=>{let a={...e,iconId:i,iconType:r};n([String(t)],a)},iconId:e.iconId,iconType:e.iconType})}),children:(0,l.jsxs)(`div`,{className:(0,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 dark:!univer-text-gray-200`,o.borderClassName),children:[a?(0,l.jsx)(`img`,{src:a,className:`univer-size-4`,draggable:!1}):(0,l.jsx)(pe,{className:`univer-size-4`}),(0,l.jsx)(ne,{})]})})}),g?(0,l.jsxs)(`div`,{className:`univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[u.t(`sheet.cf.iconSet.rule`),(0,l.jsxs)(`span`,{className:`univer-font-medium`,children:[u.t(`sheet.cf.iconSet.when`),u.t(`sheet.cf.symbol.${(0,r.getOppositeOperator)(v.operator)}`),y,g?``:` ${u.t(`sheet.cf.iconSet.and`)} `]})]}):(0,l.jsx)(o.Select,{options:d,value:e.operator,onChange:e=>{m(e,t)}})]}),g?(0,l.jsx)(`div`,{}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[(0,l.jsx)(`div`,{children:u.t(`sheet.cf.iconSet.type`)}),(0,l.jsx)(`div`,{children:u.t(`sheet.cf.iconSet.value`)})]}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4`,children:[(0,l.jsx)(o.Select,{options:f,value:e.value.type,onChange:e=>{h(e,t)}}),(0,l.jsx)(De,{id:t,type:e.value.type,error:i,value:e.value.value||``,onChange:e=>{p(e,t)}})]})]})]},t)}),[s,c])},Me=e=>{var n;let{interceptorManager:s}=e,c=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.iconSet?e.rule:void 0,u=(0,i.useDependency)(t.LocaleService),[d,f]=(0,a.useState)({}),[p,m]=(0,a.useState)(()=>{let e=Object.keys(r.iconMap)[0];if(c&&c.config.length){let e=c.config[0].iconType;if(!c.config.some(t=>t.iconType!==e))return e}return e}),[h,g]=(0,a.useState)(()=>{if(c&&c.config.length)return t.Tools.deepClone(c==null?void 0:c.config);let e=r.iconMap[p]||[];return Array(e.length).fill(``).map((e,t,n)=>t===n.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:2**53-1},iconType:p,iconId:String(t)}:Oe(p,t,n))}),[_,v]=(0,a.useState)(()=>c?!!c.isShowValue:!0),y=(0,a.useMemo)(()=>(0,l.jsx)(`div`,{className:`univer-flex univer-items-center`,children:h.map(e=>Ee(e.iconType,e.iconId)).map((e,t)=>e?(0,l.jsx)(`img`,{className:`univer-size-5`,src:e},t):(0,l.jsx)(pe,{className:`univer-size-5`},t))}),[h]),b=e=>{if(e.reduce((t,n,i)=>t.preType&&!t.result||e.length-1===i?t:n.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:t.preType?{result:t.preType===n.value.type,preType:n.value.type}:{result:!0,preType:n.value.type},{result:!0,preType:``}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(e[0].value.type)){let t={};return e.forEach((n,i,a)=>{if(i-1<0||i===a.length-1)return;let o=e[i-1],s=(0,r.getOppositeOperator)(o.operator);(0,r.compareWithNumber)({operator:s,value:o.value.value},n.value.value)||(t[i]=`${u.t(`sheet.cf.form.${s}`,String(o.value.value))} `)}),t}return{}},x=(e,n)=>{(0,t.get)(h,e)!==n&&((0,t.set)(h,e,n),g([...h]),f(b(h)))},S=e=>{m(e);let t=r.iconMap[e]||[],n=Array(t.length).fill(``).map((t,n,r)=>Oe(e,n,r));g(n),f(b(n))};(0,a.useEffect)(()=>{let e=s.intercept(s.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:_,config:h}}});return()=>{e()}},[_,h,s]),(0,a.useEffect)(()=>{let e=s.intercept(s.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(d).length===0}});return()=>{e()}},[_,h,s,d]);let C=()=>{let e=h.map(e=>({...e}));h.forEach((t,n)=>{let r=e[h.length-1-n];t.iconId=r.iconId,t.iconType=r.iconType}),g([...h])},w=(0,i.useDependency)(i.ILayoutService),[T,E]=(0,a.useState)();return(0,i.useScrollYOverContainer)(T,w.rootContainerElement),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600`,children:u.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(o.Dropdown,{overlay:(0,l.jsx)(`div`,{className:`univer-rounded-lg univer-p-4`,children:(0,l.jsx)(ke,{ref:e=>{!T&&e&&E(e)},iconType:p,onClick:S})}),children:(0,l.jsxs)(`div`,{className:(0,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:[y,(0,l.jsx)(ne,{})]})})}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsxs)(`div`,{className:`univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{onChange:C}),u.t(`sheet.cf.iconSet.reverseIconOrder`)]}),(0,l.jsxs)(`div`,{className:`univer-ml-6 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{checked:!_,onChange:e=>{v(!e)}}),u.t(`sheet.cf.iconSet.onlyShowIcon`)]})]}),(0,l.jsx)(je,{errorMap:d,onChange:x,configList:h})]})},Ne=e=>{var n;let{onChange:s,interceptorManager:c}=e,u=(0,i.useDependency)(t.LocaleService),d=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.highlightCell?e.rule:void 0,f=[{label:u.t(`sheet.cf.panel.isNotBottom`),value:`isNotBottom`},{label:u.t(`sheet.cf.panel.isBottom`),value:`isBottom`},{label:u.t(`sheet.cf.panel.greaterThanAverage`),value:`greaterThanAverage`},{label:u.t(`sheet.cf.panel.lessThanAverage`),value:`lessThanAverage`}],[p,m]=(0,a.useState)(()=>{let e=f[0].value,t=d==null?void 0:d.type;if(!d)return e;switch(t){case r.CFRuleType.highlightCell:switch(d.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(d.operator)?`greaterThanAverage`:[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(d.operator)?`lessThanAverage`:e;case r.CFSubRuleType.rank:return d.isBottom?`isBottom`:`isNotBottom`}}return e}),[h,g]=(0,a.useState)(()=>{let e=d==null?void 0:d.type;if(!d)return 10;switch(e){case r.CFRuleType.highlightCell:switch(d.subType){case r.CFSubRuleType.rank:return d.value||10}}return 10}),[_,v]=(0,a.useState)(()=>{let e=d==null?void 0:d.type;if(!d)return!1;switch(e){case r.CFRuleType.highlightCell:switch(d.subType){case r.CFSubRuleType.rank:return d.isPercent||!1}}return!1}),[y,b]=(0,a.useState)({}),x=e=>{let{type:t,isPercent:n,value:i,style:a}=e;if(t===`isNotBottom`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:n,isBottom:!1,value:i,style:a};if(t===`isBottom`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:n,isBottom:!0,value:i,style:a};if(t===`greaterThanAverage`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:a};if(t===`lessThanAverage`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:a}};(0,a.useEffect)(()=>c.intercept(c.getInterceptPoints().submit,{handler(){return x({type:p,isPercent:_,value:h,style:y})}}),[p,_,h,y,c]);let S=e=>{s(x(e))};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:u.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(o.Select,{className:`univer-mt-3 univer-w-full`,value:p,options:f,onChange:e=>{m(e),S({type:e,isPercent:_,value:h,style:y})}}),[`isNotBottom`,`isBottom`].includes(p)&&(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(o.InputNumber,{min:1,max:1e3,value:h,onChange:e=>{let t=e||0;g(t),S({type:p,isPercent:_,value:t,style:y})}}),(0,l.jsxs)(`div`,{className:`univer-ml-3 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{checked:_,onChange:e=>{v(!!e),S({type:p,isPercent:!!e,value:h,style:y})}}),u.t(`sheet.cf.valueType.percent`)]})]}),(0,l.jsx)(`div`,{className:z,children:(0,l.jsx)(R,{rule:x({type:p,isPercent:_,value:h,style:y})})}),(0,l.jsx)(be,{style:d==null?void 0:d.style,className:`univer-mt-3`,onChange:e=>{b(e),S({type:p,isPercent:_,value:h,style:e})}})]})},Pe=(0,t.createInterceptorKey)(`beforeSubmit`),Fe=(0,t.createInterceptorKey)(`submit`),Ie=e=>e.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),Le=e=>{var n;return(n=e.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId()},Re=e=>{var u,d,f;let p=(0,i.useDependency)(t.LocaleService),m=(0,i.useDependency)(t.ICommandService),h=(0,i.useDependency)(t.IUniverInstanceService),g=(0,i.useDependency)(r.ConditionalFormattingRuleModel),_=(0,i.useDependency)(n.SheetsSelectionsService),v=Ie(h),y=Le(h),[b,x]=(0,a.useState)(void 0),S=(0,a.useRef)((u=(d=e.rule)==null?void 0:d.ranges)==null?[]:u),C=(0,a.useMemo)(()=>{var t;let n=(t=e.rule)==null?void 0:t.ranges;if(!(n!=null&&n.length)){var r,i;n=(r=(i=_.getCurrentSelections())==null?void 0:i.map(e=>e.range))==null?[]:r}return S.current=n,n!=null&&n.length?n.map(e=>{let t=(0,s.serializeRange)(e);return t===`NaN`?``:t}).filter(e=>!!e).join(`,`):``},[e.rule]),w=[{label:p.t(`sheet.cf.ruleType.highlightCell`),value:`1`},{label:p.t(`sheet.cf.panel.rankAndAverage`),value:`2`},{label:p.t(`sheet.cf.ruleType.dataBar`),value:`3`},{label:p.t(`sheet.cf.ruleType.colorScale`),value:`4`},{label:p.t(`sheet.cf.ruleType.formula`),value:`5`},{label:p.t(`sheet.cf.ruleType.iconSet`),value:`6`}],[T,E]=(0,a.useState)(()=>{var t;let n=(t=e.rule)==null?void 0:t.rule.type,i=w[0].value;if(!n)return i;switch(n){case r.CFRuleType.highlightCell:var a;switch((a=e.rule)==null?void 0:a.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 i}),D=(0,a.useRef)(void 0),O=(0,a.useMemo)(()=>new t.InterceptorManager({beforeSubmit:Pe,submit:Fe}),[]),k=(0,a.useMemo)(()=>{switch(T){case`1`:return Te;case`2`:return Ne;case`3`:return _e;case`4`:return he;case`5`:return xe;case`6`:return Me;default:return Te}},[T]);(0,a.useEffect)(()=>{let t=m.onCommandExecuted(t=>{if(t.id===n.RemoveSheetMutation.id){let n=t.params;n.subUnitId===y&&n.unitId===v&&e.onCancel()}t.id===n.SetWorksheetActiveOperation.id&&e.onCancel()});return()=>t.dispose()},[]);let A=e=>{D.current=e},j=e=>{S.current=e.split(`,`).filter(e=>!!e).map(s.deserializeRangeWithSheet).map(e=>e.range)};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:p.t(`sheet.cf.panel.range`)}),(0,l.jsxs)(`div`,{className:`univer-mt-4`,children:[(0,l.jsx)(c.RangeSelector,{unitId:v,subUnitId:y,initialValue:C,onChange:(e,t)=>j(t),onVerify:(e,t)=>{e?t.length<1?x(p.t(`sheet.cf.errorMessage.rangeError`)):x(void 0):x(p.t(`sheet.cf.errorMessage.rangeError`))}}),b&&(0,l.jsx)(`div`,{className:`univer-mt-1 univer-text-xs univer-text-red-500`,children:b})]}),(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:p.t(`sheet.cf.panel.styleType`)}),(0,l.jsx)(o.Select,{className:`univer-mt-4 univer-w-full`,value:T,options:w,onChange:e=>E(e)}),(0,l.jsx)(k,{interceptorManager:O,rule:(f=e.rule)==null?void 0:f.rule,onChange:A}),(0,l.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-end`,children:[(0,l.jsx)(o.Button,{onClick:()=>{e.onCancel()},children:p.t(`sheet.cf.panel.cancel`)}),(0,l.jsx)(o.Button,{className:`univer-ml-3`,variant:`primary`,onClick:()=>{if(b)return;let i=(()=>{let e=h.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!e)throw Error(`No active sheet found`);return S.current.map(t=>(0,n.setEndForRange)(t,e.getRowCount(),e.getColumnCount())).filter(e=>!(Number.isNaN(e.startRow)||Number.isNaN(e.startColumn)))})();if(O.fetchThroughInterceptors(O.getInterceptPoints().beforeSubmit)(!0,null)){let t=O.fetchThroughInterceptors(O.getInterceptPoints().submit)(null,null);if(t){let n=Ie(h),a=Le(h);if(!n||!a)throw Error(`No active sheet found`);let o={};e.rule&&e.rule.cfId?(o={...e.rule,ranges:i,rule:t},m.executeCommand(r.SetCfCommand.id,{unitId:n,subUnitId:a,rule:o}),e.onCancel()):(o={cfId:g.createCfId(n,a),ranges:i,rule:t,stopIfTrue:!1},m.executeCommand(r.AddCfCommand.id,{unitId:n,subUnitId:a,rule:o}),e.onCancel())}}},children:p.t(`sheet.cf.panel.submit`)})]})]})};function U(e){"@babel/helpers - typeof";return U=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},U(e)}function ze(e,t){if(U(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(U(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Be(e){var t=ze(e,`string`);return U(t)==`symbol`?t:t+``}function W(e,t,n){return(t=Be(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function G(e,t){return function(n,r){t(n,r,e)}}function K(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let q=class extends t.Disposable{constructor(e){super(),this._localeService=e,W(this,`_initLocal`,()=>{}),W(this,`_findReplaceIndex`,e=>{let t=/\{([^}]+)?\}/g,n=[],r=t.exec(e);for(;r;)n.push({startIndex:r.index,key:Number(r[1]),endIndex:r.index+r[0].length-1}),r=t.exec(e);return n}),this._initLocal()}tWithReactNode(e,...t){let n=this._localeService.getLocales(),r=e.split(`.`),i=n&&this._localeService.resolveKeyPath(n,r);if(typeof i==`string`){let e=[];return this._findReplaceIndex(i).forEach((n,r,a)=>{let o=a[r-1]||{startIndex:0,endIndex:-1};if(o.endIndex+1<n.startIndex){let t=i.slice(o.endIndex+1,n.startIndex);t&&e.push(t)}if(t[n.key]&&e.push(t[n.key]),r===a.length-1){let t=i.slice(n.endIndex+1);t&&e.push(t)}}),e}return[]}};q=K([G(0,(0,t.Inject)(t.LocaleService))],q);let Ve=(e,t)=>{let n=e.rule;switch(n.type){case r.CFRuleType.colorScale:return t.t(`sheet.cf.ruleType.colorScale`);case r.CFRuleType.dataBar:return t.t(`sheet.cf.ruleType.dataBar`);case r.CFRuleType.iconSet:return t.t(`sheet.cf.ruleType.iconSet`);case r.CFRuleType.highlightCell:switch(n.subType){case r.CFSubRuleType.average:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`,t.t(`sheet.cf.subRuleType.average`))}case r.CFSubRuleType.duplicateValues:return t.t(`sheet.cf.subRuleType.duplicateValues`);case r.CFSubRuleType.uniqueValues:return t.t(`sheet.cf.subRuleType.uniqueValues`);case r.CFSubRuleType.number:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`,...Array.isArray(n.value)?n.value.map(e=>String(e)):[String(n.value||``)])}case r.CFSubRuleType.text:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`,n.value||``)}case r.CFSubRuleType.timePeriod:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`)}case r.CFSubRuleType.rank:return n.isPercent?n.isBottom?t.t(`sheet.cf.preview.describe.bottomNPercent`,String(n.value)):t.t(`sheet.cf.preview.describe.topNPercent`,String(n.value)):n.isBottom?t.t(`sheet.cf.preview.describe.bottomN`,String(n.value)):t.t(`sheet.cf.preview.describe.topN`,String(n.value));case r.CFSubRuleType.formula:return t.t(`sheet.cf.ruleType.formula`)}}},He=e=>{let{onClick:c}=e,f=(0,i.useDependency)(r.ConditionalFormattingRuleModel),p=(0,i.useDependency)(t.IUniverInstanceService),m=(0,i.useDependency)(n.SheetsSelectionsService),h=(0,i.useDependency)(t.ICommandService),g=(0,i.useDependency)(t.LocaleService),_=(0,i.useDependency)(t.Injector),v=(0,i.useDependency)(q),y=(0,i.useObservable)(()=>p.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),b=y.getUnitId(),x=y.getActiveSheet();if(!x)throw Error(`No active sheet found`);let S=x.getSheetId(),[C,w]=(0,a.useState)([]),[T,E]=(0,a.useState)(`2`),[D,O]=(0,a.useState)(0),[k,A]=(0,a.useState)(``),j=[{label:g.t(`sheet.cf.panel.workSheet`),value:`2`},{label:g.t(`sheet.cf.panel.selectedRange`),value:`1`}],N=()=>{let e=f.getSubunitRules(b,S);if(!e||!e.length)return[];if(T===`1`){let n=m.getCurrentLastSelection();if(!n)return[];let r=n.range;return e.filter(e=>e.ranges.some(e=>t.Rectangle.intersects(e,r)))}else if(T===`2`)return[...e];return[]},[F,ee]=(0,a.useState)(N);(0,u.useHighlightRange)(C),(0,a.useEffect)(()=>{let e=h.onCommandExecuted(e=>{e.id===n.SetWorksheetActiveOperation.id&&O(Math.random())});return()=>e.dispose()}),(0,a.useEffect)(()=>{ee(N)},[T,D,b,S]),(0,a.useEffect)(()=>{if(T===`2`)return;let e=new d.Observable(e=>{let i=[n.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],a=h.onCommandExecuted(n=>{let{id:r,params:a}=n,o=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId();i.includes(r)&&a.unitId===o&&e.next(null)});return()=>a.dispose()}).pipe((0,d.debounceTime)(16)).subscribe(()=>{ee(N)});return()=>{e.unsubscribe()}},[p,T,b,S]),(0,a.useEffect)(()=>{let e=f.$ruleChange.subscribe(()=>{O(Math.random())});return()=>e.unsubscribe()},[f]);let te=e=>{var n;let i=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=(n=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId();if(!i||!a)throw Error(`No active sheet found`);h.executeCommand(r.DeleteCfCommand.id,{unitId:i,subUnitId:a,cfId:e.cfId})},ne=(e,t)=>{var n;let r=I[t.y];A((n=r==null?void 0:r.cfId)==null?``:n)},re=(e,n,i)=>{var a,o,s;A(``);let c=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),l=(a=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:a.getSheetId();if(!c||!l)throw Error(`No active sheet found`);let u=e=>{let t=I.length;return Math.min(t-1,Math.max(0,e))},d=(o=I[u(n.y)])==null?void 0:o.cfId,f=(s=I[u(i.y)])==null?void 0:s.cfId;!d||!f||d!==f&&h.executeCommand(r.MoveCfCommand.id,{unitId:c,subUnitId:l,start:{id:d,type:`self`},end:{id:f,type:i.y>n.y?`after`:`before`}})},ae=()=>{e.onCreate()},oe=()=>{T===`2`?h.executeCommand(r.ClearWorksheetCfCommand.id):T===`1`&&F.map(e=>({unitId:b,subUnitId:S,cfId:e.cfId})).forEach(e=>{h.executeCommand(r.DeleteCfCommand.id,e)})},I=(0,a.useMemo)(()=>{let e=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),r=e.getActiveSheet();return F.filter(t=>{let i=t.ranges;return(0,n.checkRangesEditablePermission)(_,e.getUnitId(),r.getSheetId(),i)})},[F]),se=(0,a.useMemo)(()=>{let e=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),r=e.getActiveSheet();return F.every(t=>{let i=t.ranges;return(0,n.checkRangesEditablePermission)(_,e.getUnitId(),r.getSheetId(),i)})},[F]);return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{className:`
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/sheets`),require(`@univerjs/sheets-conditional-formatting`),require(`@univerjs/ui`),require(`react`),require(`@univerjs/design`),require(`@univerjs/engine-formula`),require(`@univerjs/sheets-formula-ui`),require(`react/jsx-runtime`),require(`@univerjs/sheets-ui`),require(`rxjs`),require(`@univerjs/sheets-formula`),require(`@univerjs/engine-render`),require(`rxjs/operators`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-conditional-formatting`,`@univerjs/ui`,`react`,`@univerjs/design`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`,`react/jsx-runtime`,`@univerjs/sheets-ui`,`rxjs`,`@univerjs/sheets-formula`,`@univerjs/engine-render`,`rxjs/operators`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsConditionalFormattingUi={},e.UniverCore,e.UniverSheets,e.UniverSheetsConditionalFormatting,e.UniverUi,e.React,e.UniverDesign,e.UniverEngineFormula,e.UniverSheetsFormulaUi,e.React,e.UniverSheetsUi,e.rxjs,e.UniverSheetsFormula,e.UniverEngineRender,e.rxjs.operators))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let h={type:t.CommandType.COMMAND,id:`sheet.command.add-average-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c}=i,l=e.get(r.ConditionalFormattingRuleModel),u=e.get(t.ICommandService),d=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!d)return!1;let{unitId:f,subUnitId:p}=d,m={ranges:a,cfId:l.createCfId(f,p),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:c,style:o}};return u.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:p,rule:m})}},g={type:t.CommandType.COMMAND,id:`sheet.command.add-color-scale-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,config:o,stopIfTrue:s}=i,c=e.get(r.ConditionalFormattingRuleModel),l=e.get(t.ICommandService),u=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!u)return!1;let{unitId:d,subUnitId:f}=u,p={ranges:a,cfId:c.createCfId(d,f),stopIfTrue:!!s,rule:{type:r.CFRuleType.colorScale,config:o}};return l.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:p})}},_={type:t.CommandType.COMMAND,id:`sheet.command.add-data-bar-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,min:o,max:s,nativeColor:c,positiveColor:l,isGradient:u,stopIfTrue:d,isShowValue:f}=i,p=e.get(r.ConditionalFormattingRuleModel),m=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!m)return!1;let{unitId:h,subUnitId:g}=m,_=e.get(t.ICommandService),v={ranges:a,cfId:p.createCfId(h,g),stopIfTrue:!!d,rule:{type:r.CFRuleType.dataBar,isShowValue:f,config:{min:o,max:s,nativeColor:c,positiveColor:l,isGradient:u}}};return _.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:g,rule:v})}},v={type:t.CommandType.COMMAND,id:`sheet.command.add-duplicate-values-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s}=i,c=e.get(r.ConditionalFormattingRuleModel),l=e.get(t.ICommandService),u=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!u)return!1;let{unitId:d,subUnitId:f}=u,p={ranges:a,cfId:c.createCfId(d,f),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:o}};return l.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:p})}},y={type:t.CommandType.COMMAND,id:`sheet.command.add-number-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c,value:l}=i,u=e.get(r.ConditionalFormattingRuleModel),d=e.get(t.ICommandService),f=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!f)return!1;let{unitId:p,subUnitId:m}=f,h=u.createCfId(p,m),g;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(c)){let e=l;if(e.length!==2||!Array.isArray(e))return!1;g={ranges:a,cfId:h,stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:c,style:o,value:e}}}else{let e=l;if(typeof e!=`number`)return!1;g={ranges:a,cfId:h,stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:c,style:o,value:e}}}return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:p,subUnitId:m,rule:g})}},b={type:t.CommandType.COMMAND,id:`sheet.command.add-rank-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,isPercent:c,isBottom:l,value:u}=i,d=e.get(r.ConditionalFormattingRuleModel),f=e.get(t.IUniverInstanceService),p=e.get(t.ICommandService),m=(0,n.getSheetCommandTarget)(f);if(!m)return!1;let{unitId:h,subUnitId:g}=m,_={ranges:a,cfId:d.createCfId(h,g),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:c,isBottom:l,style:o,value:u}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:g,rule:_})}},x={type:t.CommandType.COMMAND,id:`sheet.command.add-text-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c,value:l}=i,u=e.get(r.ConditionalFormattingRuleModel),d=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!d)return!1;let{unitId:f,subUnitId:p}=d,m=e.get(t.ICommandService),h={ranges:a,cfId:u.createCfId(f,p),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:c,style:o,value:l}};return m.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:p,rule:h})}},S={type:t.CommandType.COMMAND,id:`sheet.command.add-time-period-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c}=i,l=e.get(r.ConditionalFormattingRuleModel),u=e.get(t.IUniverInstanceService),d=e.get(t.ICommandService),f=(0,n.getSheetCommandTarget)(u);if(!f)return!1;let{unitId:p,subUnitId:m}=f,h={ranges:a,cfId:l.createCfId(p,m),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:c,style:o}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:p,subUnitId:m,rule:h})}},C={type:t.CommandType.COMMAND,id:`sheet.command.add-uniqueValues-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s}=i,c=e.get(r.ConditionalFormattingRuleModel),l=e.get(t.IUniverInstanceService),u=e.get(t.ICommandService),d=(0,n.getSheetCommandTarget)(l);if(!d)return!1;let{unitId:f,subUnitId:p}=d,m={ranges:a,cfId:c.createCfId(f,p),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:o}};return u.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:p,rule:m})}};function w({ref:e,...t}){let{icon:n,id:r,className:i,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),l=(0,a.useRef)(`_${O()}`);return T(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:c,...s},o)}function T(e,t,n,r,i){return(0,a.createElement)(e.tag,{key:t,...E(e,n,i),...r},(D(e,n).children||[]).map((r,a)=>T(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function E(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function D(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function O(){return Math.random().toString(36).substring(2,8)}w.displayName=`UniverIcon`;let k={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},A=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`bold-icon`,ref:t,icon:k}))});A.displayName=`BoldIcon`;let j={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.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.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.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`}}]},M=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`delete-icon`,ref:t,icon:j}))});M.displayName=`DeleteIcon`;let N={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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`}}]},P=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`increase-icon`,ref:t,icon:N}))});P.displayName=`IncreaseIcon`;let F={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z`}}]},ee=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`italic-icon`,ref:t,icon:F}))});ee.displayName=`ItalicIcon`;let te={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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`}}]},ne=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`more-down-icon`,ref:t,icon:te}))});ne.displayName=`MoreDownIcon`;let re={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z`}}]},ie=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`sequence-icon`,ref:t,icon:re}))});ie.displayName=`SequenceIcon`;let ae={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z`}}]},oe=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`strikethrough-icon`,ref:t,icon:ae}))});oe.displayName=`StrikethroughIcon`;let I={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z`}}]},se=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`underline-icon`,ref:t,icon:I}))});se.displayName=`UnderlineIcon`;let ce={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`colorChannel1`,d:`M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},le=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`font-color-double-icon`,ref:t,icon:ce}))});le.displayName=`FontColorDoubleIcon`;let ue={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z`}}]},de=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`paint-bucket-double-icon`,ref:t,icon:ue}))});de.displayName=`PaintBucketDoubleIcon`;let fe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,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`,fillRule:`evenodd`,clipRule:`evenodd`}}]},L=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`slash-double-icon`,ref:t,icon:fe}))});L.displayName=`SlashDoubleIcon`;let R=e=>{let{color:n,onChange:r,disable:i=!1,Icon:s=de,className:c}=e,u=(0,a.useMemo)(()=>new t.ColorKit(n),[n]),d=()=>(0,l.jsx)(s,{className:(0,o.clsx)(`univer-fill-primary-600`,i&&c),extend:{colorChannel1:u.isValid?n:``}});return i?d():(0,l.jsx)(o.Dropdown,{overlay:(0,l.jsx)(`div`,{className:`univer-rounded-lg univer-p-4`,children:(0,l.jsx)(o.ColorPicker,{value:n,onChange:r})}),children:(0,l.jsx)(`span`,{className:(0,o.clsx)(`univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,c),children:d()})})},z=e=>{let n=e.rule;if(!n)return null;let i=(0,a.useMemo)(()=>{if(n.type===r.CFRuleType.colorScale){let e=n.config.map((e,n)=>({color:new t.ColorKit(e.color),value:n})),i=e.length-1;return[,,,,,].fill(``).map((e,t,n)=>t*i/(n.length-1)).map(t=>(0,r.getColorScaleFromValue)(e,t))}return null},[n]),s=(0,a.useMemo)(()=>{if(n.type===r.CFRuleType.iconSet)return n.config.map(e=>{let t=r.iconMap[e.iconType];return t&&t[Number(e.iconId)]})},[n]),c=`univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs`;switch(n.type){case r.CFRuleType.dataBar:{var u,d;let{isGradient:e}=n.config,t=e?`linear-gradient(to right, ${n.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:n.config.positiveColor;return(0,l.jsxs)(`div`,{className:c,children:[(0,l.jsx)(`div`,{className:`univer-h-full univer-w-1/2 univer-border univer-border-solid`,style:{background:e?`linear-gradient(to right, rgb(255 255 255),${n.config.nativeColor||r.defaultDataBarNativeColor})`:n.config.nativeColor,borderColor:(u=n.config.nativeColor)==null?r.defaultDataBarNativeColor:u}}),(0,l.jsx)(`div`,{className:`univer-h-full univer-w-1/2 univer-border univer-border-solid`,style:{background:t,borderColor:(d=n.config.positiveColor)==null?r.defaultDataBarPositiveColor:d}})]})}case r.CFRuleType.colorScale:return i&&(0,l.jsx)(`div`,{className:c,children:i.map((e,t)=>(0,l.jsx)(`div`,{className:`univer-h-full`,style:{width:`${100/i.length}%`,background:e}},t))});case r.CFRuleType.iconSet:return s&&(0,l.jsx)(`div`,{className:c,children:s.map((e,t)=>e?(0,l.jsx)(`img`,{className:`univer-h-full`,src:e,draggable:!1},t):(0,l.jsx)(L,{},t))});case r.CFRuleType.highlightCell:{var f,p,m;let{ul:e,st:i,it:a,bl:s,bg:u,cl:d}=n.style,h=(e==null?void 0:e.s)===t.BooleanNumber.TRUE,g=(i==null?void 0:i.s)===t.BooleanNumber.TRUE,_=a===t.BooleanNumber.TRUE,v=s===t.BooleanNumber.TRUE,y=(f=u==null?void 0:u.rgb)==null?r.DEFAULT_BG_COLOR:f,b=(p=d==null?void 0:d.rgb)==null?r.DEFAULT_FONT_COLOR:p,x={textDecoration:(m=`${h?`underline`:``} ${g?`line-through`:``}`.replace(/^ /,``))==null?void 0:m,backgroundColor:y,color:b};return(0,l.jsx)(`div`,{className:(0,o.clsx)(c,{"univer-font-bold":v,"univer-italic":_}),style:x,children:`123`})}}},B=(0,o.clsx)(`univer-mt-5 univer-px-1 univer-py-2 univer-rounded`,o.borderClassName),V=(e,t)=>({label:t.t(`sheet.cf.valueType.${e}`),value:e}),pe=e=>{var n;let{type:s,className:u,onChange:d,id:f,value:p}=e,m=(0,i.useDependency)(t.IUniverInstanceService),h=m.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),g=(n=m.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId(),_=(0,a.useMemo)(()=>String(p).startsWith(`=`)?String(p):`=`,[p]),v=(0,a.useMemo)(()=>[r.CFValueType.max,r.CFValueType.min,`none`].includes(s)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(s)?{min:0,max:100}:{min:-(2**53-1),max:2**53-1},[s]),y=(0,a.useRef)(null),[b,x]=(0,a.useState)(!1);return(0,i.useSidebarClick)(e=>{var t;(t=y.current)!=null&&t.isClickOutSide(e)&&x(!1)}),s===r.CFValueType.formula?(0,l.jsx)(`div`,{className:`univer-ml-1 univer-w-full`,children:(0,l.jsx)(c.FormulaEditor,{ref:y,className:(0,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 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,o.borderClassName),initValue:_,unitId:h,subUnitId:g,isFocus:b,onChange:(e=``)=>{d(e||``)},onFocus:()=>x(!0)})}):(0,l.jsx)(o.InputNumber,{className:u,value:Number(e.value)||0,onChange:t=>e.onChange(t||0),...v})},me=e=>{var n;let{interceptorManager:s}=e,c=(0,i.useDependency)(t.LocaleService),u=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.colorScale?e.rule:void 0,d=[V(r.CFValueType.num,c),V(r.CFValueType.percent,c),V(r.CFValueType.percentile,c),V(r.CFValueType.formula,c)],f=[V(r.CFValueType.min,c),...d],p=[V(`none`,c),...d],m=[V(r.CFValueType.max,c),...d],[h,g]=(0,a.useState)(()=>{var e;let t=r.CFValueType.min;return u&&((e=u.config[0])==null?void 0:e.value.type)||t}),[_,v]=(0,a.useState)(()=>{var e;let t=`none`;return!u||u.config.length!==3?t:((e=u.config[1])==null?void 0:e.value.type)||t}),[y,b]=(0,a.useState)(()=>{var e;let t=r.CFValueType.max;return u&&((e=u.config[u.config.length-1])==null?void 0:e.value.type)||t}),[x,S]=(0,a.useState)(()=>{if(!u)return 10;let e=u.config[0];return(e==null?void 0:e.value.value)===void 0?10:e==null?void 0:e.value.value}),[C,w]=(0,a.useState)(()=>{var e;if(!u||u.config.length!==3)return 50;let t=(e=u.config[1])==null?void 0:e.value.value;return t===void 0?50:t}),[T,E]=(0,a.useState)(()=>{var e;if(!u)return 90;let t=(e=u.config[u.config.length-1])==null?void 0:e.value.value;return t===void 0?90:t}),[D,O]=(0,a.useState)(()=>{var e;return u&&((e=u.config[0])==null?void 0:e.color)||`#d0d9fb`}),[k,A]=(0,a.useState)(()=>{var e;let t=`#7790f3`;return!u||u.config.length!==3?t:((e=u.config[1])==null?void 0:e.color)||t}),[j,M]=(0,a.useState)(()=>{var e;return u&&((e=u.config[u.config.length-1])==null?void 0:e.color)||`#2e55ef`}),N=(0,a.useMemo)(()=>e=>{let{minType:t,medianType:n,maxType:i,minValue:a,medianValue:o,maxValue:s,minColor:c,medianColor:l,maxColor:u}=e,d=[];return d.push({color:c,value:{type:t,value:a}}),n!==`none`&&d.push({color:l,value:{type:n,value:o}}),d.push({color:u,value:{type:i,value:s}}),{config:d.map((e,t)=>({...e,index:t})),type:r.CFRuleType.colorScale}},[]);(0,a.useEffect)(()=>s.intercept(s.getInterceptPoints().submit,{handler(){return N({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),[N,h,_,y,x,C,T,D,k,j,s]);let P=t=>{e.onChange(N(t))};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:B,children:(0,l.jsx)(z,{rule:N({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})})}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.min`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-h-8 univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-flex-shrink-0`,options:f,value:h,onChange:e=>{g(e);let t=(0,r.createDefaultValueByValueType)(e,10);S(t),P({minType:e,medianType:_,maxType:y,minValue:t,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(pe,{id:`min`,className:`univer-ml-1`,value:x,type:h,onChange:e=>{S(e),P({minType:h,medianType:_,maxType:y,minValue:e,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(R,{className:`univer-ml-1`,color:D,onChange:e=>{O(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:e,medianColor:k,maxColor:j})}})]}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.medianValue`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-h-8 univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-flex-shrink-0`,options:p,value:_,onChange:e=>{v(e);let t=(0,r.createDefaultValueByValueType)(e,50);w(t),P({minType:h,medianType:e,maxType:y,minValue:x,medianValue:t,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(pe,{id:`median`,className:`univer-ml-1`,value:C,type:_,onChange:e=>{w(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:e,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),_!==`none`&&(0,l.jsx)(R,{className:`univer-ml-1`,color:k,onChange:e=>{A(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:e,maxColor:j})}})]}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.max`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-h-8 univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-flex-shrink-0`,options:m,value:y,onChange:e=>{b(e);let t=(0,r.createDefaultValueByValueType)(e,90);E(t),P({minType:h,medianType:_,maxType:e,minValue:x,medianValue:C,maxValue:t,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(pe,{id:`max`,className:`univer-ml-1`,value:T,type:y,onChange:e=>{E(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:e,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(R,{className:`univer-ml-1`,color:j,onChange:e=>{M(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:e})}})]})]})},H=(e,t)=>({label:t.t(`sheet.cf.valueType.${e}`),value:e}),he=e=>{var n;let{onChange:s,className:u,value:d,type:f,id:p,disabled:m=!1}=e,h=(0,i.useDependency)(t.IUniverInstanceService),g=h.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),_=(n=h.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId(),v=(0,a.useRef)(null),[y,b]=(0,a.useState)(!1);(0,i.useSidebarClick)(e=>{var t;(t=v.current)!=null&&t.isClickOutSide(e)&&b(!1)});let x=(0,a.useRef)(d),S=(0,a.useMemo)(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(f)?{max:100,min:0}:{min:-(2**53-1),max:2**53-1},[f]);if(f===r.CFValueType.formula){let e=String(x.current).startsWith(`=`)?String(x.current)||``:`=`;return(0,l.jsx)(`div`,{className:`univer-ml-3 univer-w-full`,children:(0,l.jsx)(c.FormulaEditor,{ref:v,className:(0,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 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,o.borderClassName),initValue:e,unitId:g,subUnitId:_,isFocus:y,onChange:(e=``)=>{s(e||``)},onFocus:()=>b(!0)})})}return(0,l.jsx)(o.InputNumber,{className:u,value:Number(d)||0,disabled:m,onChange:e=>{s(e||0)},...S})},ge=e=>{var n;let{interceptorManager:s}=e,c=(0,i.useDependency)(t.LocaleService),u=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.dataBar?e.rule:void 0,[d,f]=(0,a.useState)(()=>{var e;return u&&(e=u.config)!=null&&e.isGradient?`1`:`0`}),[p,m]=(0,a.useState)(()=>{var e;return u&&((e=u.config)==null?void 0:e.positiveColor)||r.defaultDataBarPositiveColor}),[h,g]=(0,a.useState)(()=>{var e;return u&&((e=u.config)==null?void 0:e.nativeColor)||r.defaultDataBarNativeColor}),_=[H(r.CFValueType.num,c),H(r.CFValueType.percent,c),H(r.CFValueType.percentile,c),H(r.CFValueType.formula,c)],v=[H(r.CFValueType.min,c),..._],y=[H(r.CFValueType.max,c),..._],[b,x]=(0,a.useState)(()=>{var e;let t=v[0].value;return u&&((e=u.config)==null?void 0:e.min.type)||t}),[S,C]=(0,a.useState)(()=>{var e;let t=y[0].value;return u&&((e=u.config)==null?void 0:e.max.type)||t}),[w,T]=(0,a.useState)(()=>{var e;if(!u)return 0;let t=((e=u.config)==null?void 0:e.min)||{};return t.type===r.CFValueType.formula?t.value||`=`:t.value||0}),[E,D]=(0,a.useState)(()=>{var e;if(!u)return 100;let t=((e=u.config)==null?void 0:e.max)||{};return t.type===r.CFValueType.formula?t.value||`=`:t.value===void 0?100:t.value}),[O,k]=(0,a.useState)(()=>u?u.isShowValue===void 0?!0:!!u.isShowValue:!0),A=e=>({config:{min:{type:e.minValueType,value:e.minValue},max:{type:e.maxValueType,value:e.maxValue},isGradient:e.isGradient===`1`,positiveColor:e.positiveColor||r.defaultDataBarPositiveColor,nativeColor:e.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:e.isShowValue});(0,a.useEffect)(()=>s.intercept(s.getInterceptPoints().submit,{handler(){return A({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}}),[d,w,b,E,S,p,h,s,O]);let j=t=>{e.onChange(A(t))},M=e=>{m(e),j({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:e,nativeColor:h,isShowValue:O})},N=e=>{g(e),j({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:e,isShowValue:O})},P=e=>_.map(e=>e.value).includes(e);return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:B,children:(0,l.jsx)(z,{rule:A({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.fillType`)}),(0,l.jsxs)(`div`,{className:`univer-ml-1 univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsxs)(o.RadioGroup,{value:d,onChange:e=>{f(e),j({isGradient:e,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})},children:[(0,l.jsx)(o.Radio,{value:`0`,children:(0,l.jsx)(`span`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.pureColor`)})}),(0,l.jsx)(o.Radio,{value:`1`,children:(0,l.jsx)(`span`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.gradient`)})})]}),(0,l.jsxs)(`div`,{className:`univer-ml-6 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{checked:!O,onChange:e=>{k(!e),j({isGradient:e,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:!e})}}),c.t(`sheet.cf.panel.onlyShowDataBar`)]})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.colorSet`)}),(0,l.jsxs)(`div`,{className:`univer-ml-1 univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsxs)(`div`,{className:`univer-flex univer-items-center`,children:[(0,l.jsx)(`div`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.native`)}),(0,l.jsx)(R,{color:h,onChange:N})]}),(0,l.jsxs)(`div`,{className:`univer-ml-3 univer-flex univer-items-center`,children:[(0,l.jsx)(`div`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.positive`)}),(0,l.jsx)(R,{color:p,onChange:M})]})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.min`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-w-1/2 univer-flex-shrink-0`,options:v,value:b,onChange:e=>{x(e);let t=(0,r.createDefaultValueByValueType)(e,10);T(t),j({isGradient:d,minValue:t,minValueType:e,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}}),(0,l.jsx)(he,{id:`min`,className:`univer-ml-3`,disabled:!P(b),type:b,value:w,onChange:e=>{T(e||0),j({isGradient:d,minValue:e||0,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}})]}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.max`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-w-1/2 univer-flex-shrink-0`,options:y,value:S,onChange:e=>{C(e);let t=(0,r.createDefaultValueByValueType)(e,90);D(t),j({isGradient:d,minValue:w,minValueType:b,maxValue:t,maxValueType:e,positiveColor:p,nativeColor:h,isShowValue:O})}}),(0,l.jsx)(he,{className:`univer-ml-3`,disabled:!P(S),id:`max`,type:S,value:E,onChange:e=>{D(e||0),j({isGradient:d,minValue:w,minValueType:b,maxValue:e||0,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}})]})]})]})},_e=e=>[t.BooleanNumber.FALSE,void 0].includes(e)?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE,ve=e=>e!==t.BooleanNumber.FALSE,ye=e=>{let{style:n,onChange:i,className:s}=e,[c,u]=(0,a.useState)(()=>{if(n!=null&&n.bl)return n.bl}),[d,f]=(0,a.useState)(()=>{if(n!=null&&n.it)return n.it}),[p,m]=(0,a.useState)(()=>{if(n!=null&&n.ul)return n.ul.s}),[h,g]=(0,a.useState)(()=>{if(n!=null&&n.st)return n.st.s}),[_,v]=(0,a.useState)(()=>{var e;return!(n==null||(e=n.cl)==null)&&e.rgb?n.cl.rgb:`#2f56ef`}),[y,b]=(0,a.useState)(()=>{var e;return!(n==null||(e=n.bg)==null)&&e.rgb?n.bg.rgb:`#e8ecfc`});(0,a.useEffect)(()=>{let e={bl:c,it:d};_!==void 0&&(e.cl={rgb:_}),y!==void 0&&(e.bg={rgb:y}),h!==void 0&&(e.st={s:h}),p!==void 0&&(e.ul={s:p}),i((0,r.removeUndefinedAttr)(e))},[c,d,p,h,_,y]);let x=`univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1`;return(0,l.jsxs)(`div`,{className:(0,o.clsx)(`univer-my-2.5 univer-flex univer-justify-between`,s),children:[(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ve(c||t.BooleanNumber.FALSE)}),onClick:()=>u(_e(c)),children:(0,l.jsx)(A,{})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ve(d||t.BooleanNumber.FALSE)}),onClick:()=>f(_e(d)),children:(0,l.jsx)(ee,{})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ve(p||t.BooleanNumber.FALSE)}),onClick:()=>m(_e(p)),children:(0,l.jsx)(se,{})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ve(h||t.BooleanNumber.FALSE)}),onClick:()=>g(_e(h)),children:(0,l.jsx)(oe,{})}),(0,l.jsx)(R,{color:_,onChange:v,Icon:le}),(0,l.jsx)(R,{color:y,onChange:b})]})},be=e=>{var n;let{onChange:s,interceptorManager:u}=e,d=(0,i.useDependency)(t.LocaleService),f=(0,i.useDependency)(t.IUniverInstanceService).getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),p=f.getActiveSheet(),m=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.highlightCell?e.rule:void 0,h=(0,a.useRef)(null),[g,_]=(0,a.useState)(!1),v=(0,a.useRef)(null),[y,b]=(0,a.useState)({}),[x,S]=(0,a.useState)(()=>(m==null?void 0:m.subType)===r.CFSubRuleType.formula?m.value:`=`),[C,w]=(0,a.useState)(void 0),T=e=>({style:e.style,value:x,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});(0,a.useEffect)(()=>u.intercept(u.getInterceptPoints().submit,{handler(){return T({style:y,formula:x})}}),[y,x,u]),(0,a.useEffect)(()=>u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(e,t,n)=>C||x.length===1||!x.startsWith(`=`)?(w(d.t(`sheet.cf.errorMessage.formulaError`)),!1):n(e)}),[C,x]);let E=e=>{s(T(e))};return(0,i.useSidebarClick)(e=>{var t;(t=v.current)!=null&&t.isClickOutSide(e)&&_(!1)}),(0,l.jsxs)(`div`,{ref:h,children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:d.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(c.FormulaEditor,{ref:v,className:(0,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 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,o.borderClassName),errorText:C,isFocus:g,initValue:x,unitId:f.getUnitId(),subUnitId:p==null?void 0:p.getSheetId(),onFocus:()=>{_(!0)},onChange:e=>{S(e),E({style:y,formula:e})},onVerify:(e,t)=>{!e||t.length===1?w(d.t(`sheet.cf.errorMessage.formulaError`)):w(void 0)}})}),(0,l.jsx)(`div`,{className:B,children:(0,l.jsx)(z,{rule:T({style:y,formula:x})})}),(0,l.jsx)(ye,{style:m==null?void 0:m.style,className:`univer-mt-3`,onChange:e=>{b(e),E({style:e,formula:x})}})]})},xe=e=>(0,l.jsxs)(`div`,{className:`univer-relative`,children:[(0,l.jsx)(`div`,{className:`univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500`,children:e.errorText}),e.children]}),U=(e,t)=>({label:t.t(`sheet.cf.operator.${e}`),value:e}),Se=e=>{let{type:n,operator:s,onChange:c,value:u,interceptorManager:d}=e,f=(0,i.useDependency)(t.LocaleService),[p,m]=(0,a.useState)(()=>typeof u==`number`?u:0),[h,g]=(0,a.useState)(``),[_,v]=(0,a.useState)(()=>typeof u==`string`?u:``),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(()=>Array.isArray(u)?u[0]===void 0?0:u[0]:0),[C,w]=(0,a.useState)(``),[T,E]=(0,a.useState)(()=>Array.isArray(u)?u[1]===void 0?100:u[1]:100),[D,O]=(0,a.useState)(``);switch((0,a.useEffect)(()=>{switch(n){case r.CFSubRuleType.text:[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(s)&&c(_);break;case r.CFSubRuleType.number:[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(s)&&c(p),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(s)&&c([x,T]);break}},[n]),(0,a.useEffect)(()=>{let e=d.intercept(d.getInterceptPoints().beforeSubmit,{handler:(e,t,i)=>{switch(n){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(s))return _?i(e):(b(f.t(`sheet.cf.errorMessage.notBlank`)),!1)}return i(e)}});return()=>{e()}},[n,p,_,s]),n){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(s)){let e=e=>{v(e),c(e)};return(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(xe,{errorText:y,children:(0,l.jsx)(o.Input,{value:_,onChange:t=>{b(``),e(t)}})})})}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(s))return(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(xe,{errorText:h,children:(0,l.jsx)(o.InputNumber,{className:`univer-w-full`,min:-(2**53-1),max:2**53-1,value:p,onChange:e=>{m(e||0),c(e||0),g(``)}})})});if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(s))return(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(xe,{errorText:C,children:(0,l.jsx)(o.InputNumber,{min:-(2**53-1),max:2**53-1,value:x,onChange:e=>{S(e||0),c([e||0,T]),w(``)}})}),(0,l.jsx)(xe,{errorText:D,children:(0,l.jsx)(o.InputNumber,{className:`univer-ml-3`,min:-(2**53-1),max:2**53-1,value:T,onChange:e=>{E(e||0),c([x,e||0]),O(``)}})})]})}return null},Ce=(e,t)=>{switch(e){case r.CFSubRuleType.text:return[U(r.CFTextOperator.containsText,t),U(r.CFTextOperator.notContainsText,t),U(r.CFTextOperator.beginsWith,t),U(r.CFTextOperator.endsWith,t),U(r.CFTextOperator.equal,t),U(r.CFTextOperator.notEqual,t),U(r.CFTextOperator.containsBlanks,t),U(r.CFTextOperator.notContainsBlanks,t),U(r.CFTextOperator.containsErrors,t),U(r.CFTextOperator.notContainsErrors,t)];case r.CFSubRuleType.number:return[U(r.CFNumberOperator.between,t),U(r.CFNumberOperator.notBetween,t),U(r.CFNumberOperator.equal,t),U(r.CFNumberOperator.notEqual,t),U(r.CFNumberOperator.greaterThan,t),U(r.CFNumberOperator.greaterThanOrEqual,t),U(r.CFNumberOperator.lessThan,t),U(r.CFNumberOperator.lessThanOrEqual,t)];case r.CFSubRuleType.timePeriod:return[U(r.CFTimePeriodOperator.yesterday,t),U(r.CFTimePeriodOperator.today,t),U(r.CFTimePeriodOperator.tomorrow,t),U(r.CFTimePeriodOperator.last7Days,t),U(r.CFTimePeriodOperator.lastWeek,t),U(r.CFTimePeriodOperator.thisWeek,t),U(r.CFTimePeriodOperator.nextWeek,t),U(r.CFTimePeriodOperator.lastMonth,t),U(r.CFTimePeriodOperator.thisMonth,t),U(r.CFTimePeriodOperator.nextMonth,t)]}},we=e=>{var n;let{interceptorManager:s,onChange:c}=e,u=(0,i.useDependency)(t.LocaleService),d=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.highlightCell?e.rule:void 0,[f,p]=(0,a.useState)(()=>{let e=r.CFSubRuleType.text;return d&&d.subType||e}),m=[{value:r.CFSubRuleType.text,label:u.t(`sheet.cf.subRuleType.text`)},{value:r.CFSubRuleType.number,label:u.t(`sheet.cf.subRuleType.number`)},{value:r.CFSubRuleType.timePeriod,label:u.t(`sheet.cf.subRuleType.timePeriod`)},{value:r.CFSubRuleType.duplicateValues,label:u.t(`sheet.cf.subRuleType.duplicateValues`)},{value:r.CFSubRuleType.uniqueValues,label:u.t(`sheet.cf.subRuleType.uniqueValues`)}],h=(0,a.useMemo)(()=>Ce(f,u),[f]),[g,_]=(0,a.useState)(()=>{let e=h?h[0].value:void 0;return d&&d.operator||e}),[v,y]=(0,a.useState)(()=>{var e;return d?(e=d.value)==null?(0,r.createDefaultValue)(d.subType,d.operator):e:``}),[b,x]=(0,a.useState)({}),S=(0,a.useMemo)(()=>e=>{var t,n,i;switch(e.subType||f){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(g)){var a,o,s,c;return{type:r.CFRuleType.highlightCell,subType:(a=e.subType)==null?f:a,operator:(o=e.operator)==null?g:o,style:(s=e.style)==null?b:s,value:(c=e.value)==null?v: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(g)){var l,u,d,p;return{type:r.CFRuleType.highlightCell,subType:(l=e.subType)==null?f:l,operator:(u=e.operator)==null?g:u,style:(d=e.style)==null?b:d,value:(p=e.value)==null?v:p}}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(g)){var m,h,_,y;return{type:r.CFRuleType.highlightCell,subType:(m=e.subType)==null?f:m,operator:(h=e.operator)==null?g:h,style:(_=e.style)==null?b:_,value:(y=e.value)==null?v:y}}break}return{type:r.CFRuleType.highlightCell,subType:(t=e.subType)==null?f:t,operator:(n=e.operator)==null?g:n,style:(i=e.style)==null?b:i}},[f,g,v,b]);(0,a.useEffect)(()=>s.intercept(s.getInterceptPoints().submit,{handler(){return S({})}}),[S,s]),(0,a.useEffect)(()=>{m.some(e=>e.value===f)||p(m[0].value)},[m]);let C=e=>{let t=e,n=Ce(t,u),i=n&&n[0].value;p(t),_(i),i&&y((0,r.createDefaultValue)(t,i)),c(S({subType:t,operator:i}))},w=e=>{let t=e;_(t),c(S({operator:t}))},T=e=>{y(e),c(S({value:e}))},E=(0,a.useMemo)(()=>`${f}_${g}_${Math.random()}`,[f,g]);return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:u.t(`sheet.cf.panel.styleRule`)}),(0,l.jsxs)(`div`,{className:`univer-flex univer-justify-between univer-gap-4`,children:[(0,l.jsx)(o.Select,{className:`univer-mt-3 univer-w-full`,onChange:C,value:f,options:m}),(h==null?void 0:h.length)&&(0,l.jsx)(o.Select,{className:`univer-mt-3 univer-w-full`,onChange:w,value:g||``,options:h})]}),(0,l.jsx)(Se,{value:v,interceptorManager:s,type:f,operator:g,rule:d,onChange:T},E),(0,l.jsx)(`div`,{className:B,children:(0,l.jsx)(z,{rule:S({})})}),(0,l.jsx)(ye,{style:d==null?void 0:d.style,className:`univer-ml-1`,onChange:e=>{x(e),c(S({style:e}))}})]})},Te=(e,t)=>(r.iconMap[e]||[])[Number(t)]||``,Ee=e=>{var n;let{error:s,type:u,onChange:d}=e,f=(0,i.useDependency)(t.IUniverInstanceService),p=f.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),m=(n=f.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId(),h=(0,a.useRef)(null),[g,_]=(0,a.useState)(!1);return(0,i.useSidebarClick)(e=>{var t;(t=h.current)!=null&&t.isClickOutSide(e)&&_(!1)}),(0,l.jsx)(`div`,{className:`univer-relative`,children:u===r.CFValueType.formula?(0,l.jsx)(`div`,{className:`univer-w-full`,children:(0,l.jsx)(c.FormulaEditor,{ref:h,className:(0,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 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,o.borderClassName),initValue:String(e.value),unitId:p,subUnitId:m,isFocus:g,onChange:(e=``)=>{d(e||``)},onFocus:()=>_(!0)})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.InputNumber,{className:(0,o.clsx)({"univer-border-red-500":s}),value:Number(e.value)||0,onChange:e=>d(e==null?0:e)}),s&&(0,l.jsx)(`div`,{className:`univer-absolute univer-text-xs univer-text-red-500`,children:s})]})})},De=(e,t,n)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(n.length-1-t)*10},iconType:e,iconId:String(t)}),Oe=(0,a.forwardRef)((e,n)=>{let{onClick:a}=e,o=(0,i.useDependency)(t.LocaleService),s=e=>{a(e)};return(0,l.jsx)(`div`,{ref:n,className:`univer-w-80`,children:r.iconGroup.map((e,t)=>(0,l.jsxs)(`div`,{className:`univer-mb-3`,children:[(0,l.jsx)(`div`,{className:`univer-mb-1 univer-text-sm`,children:o.t(e.title)}),(0,l.jsx)(`div`,{className:`univer-flex univer-flex-wrap`,children:e.group.map(e=>(0,l.jsx)(`div`,{className:`univer-mb-1 univer-flex univer-w-1/2 univer-items-center`,onClick:()=>{s(e.name)},children:(0,l.jsx)(`a`,{className:`univer-flex univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,children:e.list.map((e,t)=>(0,l.jsx)(`img`,{className:`univer-size-5`,src:e,draggable:!1},t))})},e.name))})]},t))})}),ke=e=>{let{onClick:t}=e,n=(0,a.useMemo)(()=>{let e=[];for(let t in r.iconMap){let n=r.iconMap[t],i=t;n.forEach((t,n)=>{e.push({iconType:i,base64:t,iconId:String(n)})})}return e},[]),i=e=>{t(e.iconType,e.iconId)};return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{className:`univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1`,onClick:()=>i({iconType:r.EMPTY_ICON_TYPE,iconId:``,base64:``}),children:[(0,l.jsx)(L,{className:`univer-size-5`}),(0,l.jsx)(`span`,{className:`univer-ml-2`,children:`无单元格图标`})]}),(0,l.jsx)(`div`,{className:`univer-flex univer-w-64 univer-flex-wrap`,children:n.map(e=>(0,l.jsx)(`div`,{className:`univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,children:(0,l.jsx)(`img`,{className:`univer-size-5`,src:e.base64,draggable:!1,onClick:()=>i(e)})},`${e.iconType}_${e.iconId}`))})]})},Ae=e=>{let{onChange:n,configList:s,errorMap:c={}}=e,u=(0,i.useDependency)(t.LocaleService),d=[{label:u.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:u.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],f=[{label:u.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:u.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:u.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:u.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],p=(e,t)=>{n([String(t),`value`,`value`],e)},m=(e,t)=>{n([String(t),`operator`],e),p((0,r.createDefaultValue)(r.CFSubRuleType.number,e),t)},h=(e,t)=>{n([String(t),`value`,`type`],e);let i=s[t];p((0,r.createDefaultValue)(r.CFSubRuleType.number,i.operator),t)};return(0,a.useMemo)(()=>s.map((e,t)=>{let i=c[t],a=Te(e.iconType,e.iconId),g=t===s.length-1,_=t===0,v=s[t-1],y=(v==null?void 0:v.value.type)===r.CFValueType.formula?u.t(`sheet.cf.valueType.formula`):v==null?void 0:v.value.value;return(0,l.jsxs)(`div`,{className:t?`univer-mt-6`:`univer-mt-3`,children:[(0,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:[(0,l.jsxs)(`div`,{className:`univer-w-[45%]`,children:[u.t(`sheet.cf.iconSet.icon`),t+1]}),(0,l.jsx)(`div`,{className:`univer-w-[45%]`,children:(0,l.jsxs)(l.Fragment,{children:[!_&&!g&&u.t(`sheet.cf.iconSet.rule`),!_&&!g&&(0,l.jsxs)(`span`,{className:`univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200`,children:[u.t(`sheet.cf.iconSet.when`),u.t(`sheet.cf.symbol.${(0,r.getOppositeOperator)(v.operator)}`),y,g?``:` ${u.t(`sheet.cf.iconSet.and`)} `]})]})})]}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4`,children:[(0,l.jsx)(`div`,{className:`univer-flex univer-items-center`,children:(0,l.jsx)(o.Dropdown,{overlay:(0,l.jsx)(`div`,{className:`univer-rounded-lg univer-p-4`,children:(0,l.jsx)(ke,{onClick:(r,i)=>{let a={...e,iconId:i,iconType:r};n([String(t)],a)},iconId:e.iconId,iconType:e.iconType})}),children:(0,l.jsxs)(`div`,{className:(0,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 dark:!univer-text-gray-200`,o.borderClassName),children:[a?(0,l.jsx)(`img`,{src:a,className:`univer-size-4`,draggable:!1}):(0,l.jsx)(L,{className:`univer-size-4`}),(0,l.jsx)(ne,{})]})})}),g?(0,l.jsxs)(`div`,{className:`univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[u.t(`sheet.cf.iconSet.rule`),(0,l.jsxs)(`span`,{className:`univer-font-medium`,children:[u.t(`sheet.cf.iconSet.when`),u.t(`sheet.cf.symbol.${(0,r.getOppositeOperator)(v.operator)}`),y,g?``:` ${u.t(`sheet.cf.iconSet.and`)} `]})]}):(0,l.jsx)(o.Select,{options:d,value:e.operator,onChange:e=>{m(e,t)}})]}),g?(0,l.jsx)(`div`,{}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[(0,l.jsx)(`div`,{children:u.t(`sheet.cf.iconSet.type`)}),(0,l.jsx)(`div`,{children:u.t(`sheet.cf.iconSet.value`)})]}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4`,children:[(0,l.jsx)(o.Select,{options:f,value:e.value.type,onChange:e=>{h(e,t)}}),(0,l.jsx)(Ee,{id:t,type:e.value.type,error:i,value:e.value.value||``,onChange:e=>{p(e,t)}})]})]})]},t)}),[s,c])},je=e=>{var n;let{interceptorManager:s}=e,c=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.iconSet?e.rule:void 0,u=(0,i.useDependency)(t.LocaleService),[d,f]=(0,a.useState)({}),[p,m]=(0,a.useState)(()=>{let e=Object.keys(r.iconMap)[0];if(c&&c.config.length){let e=c.config[0].iconType;if(!c.config.some(t=>t.iconType!==e))return e}return e}),[h,g]=(0,a.useState)(()=>{if(c&&c.config.length)return t.Tools.deepClone(c==null?void 0:c.config);let e=r.iconMap[p]||[];return Array(e.length).fill(``).map((e,t,n)=>t===n.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:2**53-1},iconType:p,iconId:String(t)}:De(p,t,n))}),[_,v]=(0,a.useState)(()=>c?!!c.isShowValue:!0),y=(0,a.useMemo)(()=>(0,l.jsx)(`div`,{className:`univer-flex univer-items-center`,children:h.map(e=>Te(e.iconType,e.iconId)).map((e,t)=>e?(0,l.jsx)(`img`,{className:`univer-size-5`,src:e},t):(0,l.jsx)(L,{className:`univer-size-5`},t))}),[h]),b=e=>{if(e.reduce((t,n,i)=>t.preType&&!t.result||e.length-1===i?t:n.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:t.preType?{result:t.preType===n.value.type,preType:n.value.type}:{result:!0,preType:n.value.type},{result:!0,preType:``}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(e[0].value.type)){let t={};return e.forEach((n,i,a)=>{if(i-1<0||i===a.length-1)return;let o=e[i-1],s=(0,r.getOppositeOperator)(o.operator);(0,r.compareWithNumber)({operator:s,value:o.value.value},n.value.value)||(t[i]=`${u.t(`sheet.cf.form.${s}`,String(o.value.value))} `)}),t}return{}},x=(e,n)=>{(0,t.get)(h,e)!==n&&((0,t.set)(h,e,n),g([...h]),f(b(h)))},S=e=>{m(e);let t=r.iconMap[e]||[],n=Array(t.length).fill(``).map((t,n,r)=>De(e,n,r));g(n),f(b(n))};(0,a.useEffect)(()=>{let e=s.intercept(s.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:_,config:h}}});return()=>{e()}},[_,h,s]),(0,a.useEffect)(()=>{let e=s.intercept(s.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(d).length===0}});return()=>{e()}},[_,h,s,d]);let C=()=>{let e=h.map(e=>({...e}));h.forEach((t,n)=>{let r=e[h.length-1-n];t.iconId=r.iconId,t.iconType=r.iconType}),g([...h])},w=(0,i.useDependency)(i.ILayoutService),[T,E]=(0,a.useState)();return(0,i.useScrollYOverContainer)(T,w.rootContainerElement),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600`,children:u.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(o.Dropdown,{overlay:(0,l.jsx)(`div`,{className:`univer-rounded-lg univer-p-4`,children:(0,l.jsx)(Oe,{ref:e=>{!T&&e&&E(e)},iconType:p,onClick:S})}),children:(0,l.jsxs)(`div`,{className:(0,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:[y,(0,l.jsx)(ne,{})]})})}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsxs)(`div`,{className:`univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{onChange:C}),u.t(`sheet.cf.iconSet.reverseIconOrder`)]}),(0,l.jsxs)(`div`,{className:`univer-ml-6 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{checked:!_,onChange:e=>{v(!e)}}),u.t(`sheet.cf.iconSet.onlyShowIcon`)]})]}),(0,l.jsx)(Ae,{errorMap:d,onChange:x,configList:h})]})},Me=e=>{var n;let{onChange:s,interceptorManager:c}=e,u=(0,i.useDependency)(t.LocaleService),d=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.highlightCell?e.rule:void 0,f=[{label:u.t(`sheet.cf.panel.isNotBottom`),value:`isNotBottom`},{label:u.t(`sheet.cf.panel.isBottom`),value:`isBottom`},{label:u.t(`sheet.cf.panel.greaterThanAverage`),value:`greaterThanAverage`},{label:u.t(`sheet.cf.panel.lessThanAverage`),value:`lessThanAverage`}],[p,m]=(0,a.useState)(()=>{let e=f[0].value,t=d==null?void 0:d.type;if(!d)return e;switch(t){case r.CFRuleType.highlightCell:switch(d.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(d.operator)?`greaterThanAverage`:[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(d.operator)?`lessThanAverage`:e;case r.CFSubRuleType.rank:return d.isBottom?`isBottom`:`isNotBottom`}}return e}),[h,g]=(0,a.useState)(()=>{let e=d==null?void 0:d.type;if(!d)return 10;switch(e){case r.CFRuleType.highlightCell:switch(d.subType){case r.CFSubRuleType.rank:return d.value||10}}return 10}),[_,v]=(0,a.useState)(()=>{let e=d==null?void 0:d.type;if(!d)return!1;switch(e){case r.CFRuleType.highlightCell:switch(d.subType){case r.CFSubRuleType.rank:return d.isPercent||!1}}return!1}),[y,b]=(0,a.useState)({}),x=e=>{let{type:t,isPercent:n,value:i,style:a}=e;if(t===`isNotBottom`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:n,isBottom:!1,value:i,style:a};if(t===`isBottom`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:n,isBottom:!0,value:i,style:a};if(t===`greaterThanAverage`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:a};if(t===`lessThanAverage`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:a}};(0,a.useEffect)(()=>c.intercept(c.getInterceptPoints().submit,{handler(){return x({type:p,isPercent:_,value:h,style:y})}}),[p,_,h,y,c]);let S=e=>{s(x(e))};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:u.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(o.Select,{className:`univer-mt-3 univer-w-full`,value:p,options:f,onChange:e=>{m(e),S({type:e,isPercent:_,value:h,style:y})}}),[`isNotBottom`,`isBottom`].includes(p)&&(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(o.InputNumber,{min:1,max:1e3,value:h,onChange:e=>{let t=e||0;g(t),S({type:p,isPercent:_,value:t,style:y})}}),(0,l.jsxs)(`div`,{className:`univer-ml-3 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{checked:_,onChange:e=>{v(!!e),S({type:p,isPercent:!!e,value:h,style:y})}}),u.t(`sheet.cf.valueType.percent`)]})]}),(0,l.jsx)(`div`,{className:B,children:(0,l.jsx)(z,{rule:x({type:p,isPercent:_,value:h,style:y})})}),(0,l.jsx)(ye,{style:d==null?void 0:d.style,className:`univer-mt-3`,onChange:e=>{b(e),S({type:p,isPercent:_,value:h,style:e})}})]})},Ne=(0,t.createInterceptorKey)(`beforeSubmit`),Pe=(0,t.createInterceptorKey)(`submit`),Fe=e=>e.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),Ie=e=>{var n;return(n=e.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId()},Le=e=>{var u,d,f;let p=(0,i.useDependency)(t.LocaleService),m=(0,i.useDependency)(t.ICommandService),h=(0,i.useDependency)(t.IUniverInstanceService),g=(0,i.useDependency)(r.ConditionalFormattingRuleModel),_=(0,i.useDependency)(n.SheetsSelectionsService),v=Fe(h),y=Ie(h),[b,x]=(0,a.useState)(void 0),S=(0,a.useRef)((u=(d=e.rule)==null?void 0:d.ranges)==null?[]:u),C=(0,a.useMemo)(()=>{var t;let n=(t=e.rule)==null?void 0:t.ranges;if(!(n!=null&&n.length)){var r,i;n=(r=(i=_.getCurrentSelections())==null?void 0:i.map(e=>e.range))==null?[]:r}return S.current=n,n!=null&&n.length?n.map(e=>{let t=(0,s.serializeRange)(e);return t===`NaN`?``:t}).filter(e=>!!e).join(`,`):``},[e.rule]),w=[{label:p.t(`sheet.cf.ruleType.highlightCell`),value:`1`},{label:p.t(`sheet.cf.panel.rankAndAverage`),value:`2`},{label:p.t(`sheet.cf.ruleType.dataBar`),value:`3`},{label:p.t(`sheet.cf.ruleType.colorScale`),value:`4`},{label:p.t(`sheet.cf.ruleType.formula`),value:`5`},{label:p.t(`sheet.cf.ruleType.iconSet`),value:`6`}],[T,E]=(0,a.useState)(()=>{var t;let n=(t=e.rule)==null?void 0:t.rule.type,i=w[0].value;if(!n)return i;switch(n){case r.CFRuleType.highlightCell:var a;switch((a=e.rule)==null?void 0:a.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 i}),D=(0,a.useRef)(void 0),O=(0,a.useMemo)(()=>new t.InterceptorManager({beforeSubmit:Ne,submit:Pe}),[]),k=(0,a.useMemo)(()=>{switch(T){case`1`:return we;case`2`:return Me;case`3`:return ge;case`4`:return me;case`5`:return be;case`6`:return je;default:return we}},[T]);(0,a.useEffect)(()=>{let t=m.onCommandExecuted(t=>{if(t.id===n.RemoveSheetMutation.id){let n=t.params;n.subUnitId===y&&n.unitId===v&&e.onCancel()}t.id===n.SetWorksheetActiveOperation.id&&e.onCancel()});return()=>t.dispose()},[]);let A=e=>{D.current=e},j=e=>{S.current=e.split(`,`).filter(e=>!!e).map(s.deserializeRangeWithSheet).map(e=>e.range)};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:p.t(`sheet.cf.panel.range`)}),(0,l.jsxs)(`div`,{className:`univer-mt-4`,children:[(0,l.jsx)(c.RangeSelector,{unitId:v,subUnitId:y,initialValue:C,onChange:(e,t)=>j(t),onVerify:(e,t)=>{e?t.length<1?x(p.t(`sheet.cf.errorMessage.rangeError`)):x(void 0):x(p.t(`sheet.cf.errorMessage.rangeError`))}}),b&&(0,l.jsx)(`div`,{className:`univer-mt-1 univer-text-xs univer-text-red-500`,children:b})]}),(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:p.t(`sheet.cf.panel.styleType`)}),(0,l.jsx)(o.Select,{className:`univer-mt-4 univer-w-full`,value:T,options:w,onChange:e=>E(e)}),(0,l.jsx)(k,{interceptorManager:O,rule:(f=e.rule)==null?void 0:f.rule,onChange:A}),(0,l.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-end`,children:[(0,l.jsx)(o.Button,{onClick:()=>{e.onCancel()},children:p.t(`sheet.cf.panel.cancel`)}),(0,l.jsx)(o.Button,{className:`univer-ml-3`,variant:`primary`,onClick:()=>{if(b)return;let i=(()=>{let e=h.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!e)throw Error(`No active sheet found`);return S.current.map(t=>(0,n.setEndForRange)(t,e.getRowCount(),e.getColumnCount())).filter(e=>!(Number.isNaN(e.startRow)||Number.isNaN(e.startColumn)))})();if(O.fetchThroughInterceptors(O.getInterceptPoints().beforeSubmit)(!0,null)){let t=O.fetchThroughInterceptors(O.getInterceptPoints().submit)(null,null);if(t){let n=Fe(h),a=Ie(h);if(!n||!a)throw Error(`No active sheet found`);let o={};e.rule&&e.rule.cfId?(o={...e.rule,ranges:i,rule:t},m.executeCommand(r.SetCfCommand.id,{unitId:n,subUnitId:a,rule:o}),e.onCancel()):(o={cfId:g.createCfId(n,a),ranges:i,rule:t,stopIfTrue:!1},m.executeCommand(r.AddCfCommand.id,{unitId:n,subUnitId:a,rule:o}),e.onCancel())}}},children:p.t(`sheet.cf.panel.submit`)})]})]})};function W(e){"@babel/helpers - typeof";return W=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},W(e)}function Re(e,t){if(W(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(W(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ze(e){var t=Re(e,`string`);return W(t)==`symbol`?t:t+``}function G(e,t,n){return(t=ze(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function K(e,t){return function(n,r){t(n,r,e)}}function q(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let J=class extends t.Disposable{constructor(e){super(),this._localeService=e,G(this,`_initLocal`,()=>{}),G(this,`_findReplaceIndex`,e=>{let t=/\{([^}]+)?\}/g,n=[],r=t.exec(e);for(;r;)n.push({startIndex:r.index,key:Number(r[1]),endIndex:r.index+r[0].length-1}),r=t.exec(e);return n}),this._initLocal()}tWithReactNode(e,...t){let n=this._localeService.getLocales(),r=e.split(`.`),i=n&&this._localeService.resolveKeyPath(n,r);if(typeof i==`string`){let e=[];return this._findReplaceIndex(i).forEach((n,r,a)=>{let o=a[r-1]||{startIndex:0,endIndex:-1};if(o.endIndex+1<n.startIndex){let t=i.slice(o.endIndex+1,n.startIndex);t&&e.push(t)}if(t[n.key]&&e.push(t[n.key]),r===a.length-1){let t=i.slice(n.endIndex+1);t&&e.push(t)}}),e}return[]}};J=q([K(0,(0,t.Inject)(t.LocaleService))],J);let Be=(e,t)=>{let n=e.rule;switch(n.type){case r.CFRuleType.colorScale:return t.t(`sheet.cf.ruleType.colorScale`);case r.CFRuleType.dataBar:return t.t(`sheet.cf.ruleType.dataBar`);case r.CFRuleType.iconSet:return t.t(`sheet.cf.ruleType.iconSet`);case r.CFRuleType.highlightCell:switch(n.subType){case r.CFSubRuleType.average:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`,t.t(`sheet.cf.subRuleType.average`))}case r.CFSubRuleType.duplicateValues:return t.t(`sheet.cf.subRuleType.duplicateValues`);case r.CFSubRuleType.uniqueValues:return t.t(`sheet.cf.subRuleType.uniqueValues`);case r.CFSubRuleType.number:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`,...Array.isArray(n.value)?n.value.map(e=>String(e)):[String(n.value||``)])}case r.CFSubRuleType.text:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`,n.value||``)}case r.CFSubRuleType.timePeriod:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`)}case r.CFSubRuleType.rank:return n.isPercent?n.isBottom?t.t(`sheet.cf.preview.describe.bottomNPercent`,String(n.value)):t.t(`sheet.cf.preview.describe.topNPercent`,String(n.value)):n.isBottom?t.t(`sheet.cf.preview.describe.bottomN`,String(n.value)):t.t(`sheet.cf.preview.describe.topN`,String(n.value));case r.CFSubRuleType.formula:return t.t(`sheet.cf.ruleType.formula`)}}},Ve=e=>{let{onClick:c}=e,f=(0,i.useDependency)(r.ConditionalFormattingRuleModel),p=(0,i.useDependency)(t.IUniverInstanceService),m=(0,i.useDependency)(n.SheetsSelectionsService),h=(0,i.useDependency)(t.ICommandService),g=(0,i.useDependency)(t.LocaleService),_=(0,i.useDependency)(t.Injector),v=(0,i.useDependency)(J),y=(0,i.useObservable)(()=>p.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),b=y.getUnitId(),x=y.getActiveSheet();if(!x)throw Error(`No active sheet found`);let S=x.getSheetId(),[C,w]=(0,a.useState)([]),[T,E]=(0,a.useState)(`2`),[D,O]=(0,a.useState)(0),[k,A]=(0,a.useState)(``),j=[{label:g.t(`sheet.cf.panel.workSheet`),value:`2`},{label:g.t(`sheet.cf.panel.selectedRange`),value:`1`}],N=()=>{let e=f.getSubunitRules(b,S);if(!e||!e.length)return[];if(T===`1`){let n=m.getCurrentLastSelection();if(!n)return[];let r=n.range;return e.filter(e=>e.ranges.some(e=>t.Rectangle.intersects(e,r)))}else if(T===`2`)return[...e];return[]},[F,ee]=(0,a.useState)(N);(0,u.useHighlightRange)(C),(0,a.useEffect)(()=>{let e=h.onCommandExecuted(e=>{e.id===n.SetWorksheetActiveOperation.id&&O(Math.random())});return()=>e.dispose()}),(0,a.useEffect)(()=>{ee(N)},[T,D,b,S]),(0,a.useEffect)(()=>{if(T===`2`)return;let e=new d.Observable(e=>{let i=[n.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],a=h.onCommandExecuted(n=>{let{id:r,params:a}=n,o=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId();i.includes(r)&&a.unitId===o&&e.next(null)});return()=>a.dispose()}).pipe((0,d.debounceTime)(16)).subscribe(()=>{ee(N)});return()=>{e.unsubscribe()}},[p,T,b,S]),(0,a.useEffect)(()=>{let e=f.$ruleChange.subscribe(()=>{O(Math.random())});return()=>e.unsubscribe()},[f]);let te=e=>{var n;let i=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=(n=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId();if(!i||!a)throw Error(`No active sheet found`);h.executeCommand(r.DeleteCfCommand.id,{unitId:i,subUnitId:a,cfId:e.cfId})},ne=(e,t)=>{var n;let r=I[t.y];A((n=r==null?void 0:r.cfId)==null?``:n)},re=(e,n,i)=>{var a,o,s;A(``);let c=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),l=(a=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:a.getSheetId();if(!c||!l)throw Error(`No active sheet found`);let u=e=>{let t=I.length;return Math.min(t-1,Math.max(0,e))},d=(o=I[u(n.y)])==null?void 0:o.cfId,f=(s=I[u(i.y)])==null?void 0:s.cfId;!d||!f||d!==f&&h.executeCommand(r.MoveCfCommand.id,{unitId:c,subUnitId:l,start:{id:d,type:`self`},end:{id:f,type:i.y>n.y?`after`:`before`}})},ae=()=>{e.onCreate()},oe=()=>{T===`2`?h.executeCommand(r.ClearWorksheetCfCommand.id):T===`1`&&F.map(e=>({unitId:b,subUnitId:S,cfId:e.cfId})).forEach(e=>{h.executeCommand(r.DeleteCfCommand.id,e)})},I=(0,a.useMemo)(()=>{let e=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),r=e.getActiveSheet();return F.filter(t=>{let i=t.ranges;return(0,n.checkRangesEditablePermission)(_,e.getUnitId(),r.getSheetId(),i)})},[F]),se=(0,a.useMemo)(()=>{let e=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),r=e.getActiveSheet();return F.every(t=>{let i=t.ranges;return(0,n.checkRangesEditablePermission)(_,e.getUnitId(),r.getSheetId(),i)})},[F]);return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{className:`
2
2
  univer-mb-2 univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm
3
- `,children:[(0,l.jsx)(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:v.tWithReactNode(`sheet.cf.panel.managerRuleSelect`,(0,l.jsx)(o.Select,{className:`univer-w-36`,options:j,value:T,onChange:e=>{E(e)}})).map((e,t)=>(0,l.jsx)(`span`,{children:e},t))}),(0,l.jsxs)(`div`,{className:`univer-flex univer-justify-end univer-space-x-2`,children:[(0,l.jsx)(o.Tooltip,{title:g.t(`sheet.cf.panel.createRule`),placement:`bottom`,children:(0,l.jsx)(`a`,{className:`univer-size-5 univer-cursor-pointer`,onClick:ae,children:(0,l.jsx)(P,{})})}),F.length&&se?(0,l.jsx)(o.Tooltip,{title:g.t(`sheet.cf.panel.clear`),placement:`bottom`,children:(0,l.jsx)(`a`,{className:`univer-size-5 univer-cursor-pointer`,onClick:oe,children:(0,l.jsx)(M,{className:`univer-text-red-500`})})}):(0,l.jsx)(`div`,{children:(0,l.jsx)(M,{className:`univer-text-gray-300`})})]})]}),(0,l.jsx)(`div`,{children:(0,l.jsx)(o.DraggableList,{className:`univer-w-full`,draggableHandle:`.draggableHandle`,list:I,onListChange:()=>void 0,idKey:`cfId`,rowHeight:60,margin:[0,10],onDragStop:re,onDragStart:ne,itemRender:e=>(0,l.jsxs)(`div`,{className:(0,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 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-bg-gray-100 dark:!univer-bg-gray-700":k===e.cfId}),onMouseMove:()=>{e.ranges!==C&&w(e.ranges)},onMouseLeave:()=>w([]),onClick:()=>{c(e)},children:[(0,l.jsx)(`div`,{className:(0,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:e=>e.stopPropagation(),children:(0,l.jsx)(ie,{})}),(0,l.jsxs)(`div`,{className:`univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden`,children:[(0,l.jsx)(`div`,{className:`univer-text-sm univer-text-gray-900 dark:!univer-text-white`,children:Ve(e,g)}),(0,l.jsx)(`div`,{className:`
3
+ `,children:[(0,l.jsx)(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:v.tWithReactNode(`sheet.cf.panel.managerRuleSelect`,(0,l.jsx)(o.Select,{className:`univer-w-36`,options:j,value:T,onChange:e=>{E(e)}})).map((e,t)=>(0,l.jsx)(`span`,{children:e},t))}),(0,l.jsxs)(`div`,{className:`univer-flex univer-justify-end univer-space-x-2`,children:[(0,l.jsx)(o.Tooltip,{title:g.t(`sheet.cf.panel.createRule`),placement:`bottom`,children:(0,l.jsx)(`a`,{className:`univer-size-5 univer-cursor-pointer`,onClick:ae,children:(0,l.jsx)(P,{})})}),F.length&&se?(0,l.jsx)(o.Tooltip,{title:g.t(`sheet.cf.panel.clear`),placement:`bottom`,children:(0,l.jsx)(`a`,{className:`univer-size-5 univer-cursor-pointer`,onClick:oe,children:(0,l.jsx)(M,{className:`univer-text-red-500`})})}):(0,l.jsx)(`div`,{children:(0,l.jsx)(M,{className:`univer-text-gray-300`})})]})]}),(0,l.jsx)(`div`,{children:(0,l.jsx)(o.DraggableList,{className:`univer-w-full`,draggableHandle:`.draggableHandle`,list:I,onListChange:()=>void 0,idKey:`cfId`,rowHeight:60,margin:[0,10],onDragStop:re,onDragStart:ne,itemRender:e=>(0,l.jsxs)(`div`,{className:(0,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 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-bg-gray-100 dark:!univer-bg-gray-700":k===e.cfId}),onMouseMove:()=>{e.ranges!==C&&w(e.ranges)},onMouseLeave:()=>w([]),onClick:()=>{c(e)},children:[(0,l.jsx)(`div`,{className:(0,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:e=>e.stopPropagation(),children:(0,l.jsx)(ie,{})}),(0,l.jsxs)(`div`,{className:`univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden`,children:[(0,l.jsx)(`div`,{className:`univer-text-sm univer-text-gray-900 dark:!univer-text-white`,children:Be(e,g)}),(0,l.jsx)(`div`,{className:`
4
4
  univer-max-w-[250px] univer-overflow-hidden univer-text-ellipsis univer-text-xs
5
5
  univer-text-gray-400
6
- `,children:e.ranges.map(e=>(0,s.serializeRange)(e)).join(`,`)})]}),(0,l.jsx)(`div`,{children:(0,l.jsx)(R,{rule:e.rule})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(`univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200`,{"univer-flex univer-items-center univer-justify-center":k===e.cfId}),onClick:t=>{t.stopPropagation(),te(e),w([])},children:(0,l.jsx)(M,{})})]})})})]})},Ue=e=>{let[t,n]=(0,a.useState)(e.rule),[r,i]=(0,a.useState)(!!e.rule);return(0,l.jsx)(`div`,{className:`univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4`,children:r?(0,l.jsx)(Re,{onCancel:()=>{i(!1),n(void 0)},rule:t}):(0,l.jsx)(He,{onClick:e=>{n(e),i(!0)},onCreate:()=>{i(!0)}})})},We=`sheet.conditional.formatting.panel`,J=class extends t.Disposable{constructor(e,n,r,i,a){super(),this._univerInstanceService=e,this._injector=n,this._componentManager=r,this._sidebarService=i,this._localeService=a,W(this,`_sidebarDisposable`,null),this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{var t;e||(t=this._sidebarDisposable)==null||t.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.id===We&&(e.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){let n={id:We,header:{title:this._localeService.t(`sheet.cf.title`)},children:{label:We,rule:e,key:(0,t.generateRandomId)(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this.disposeWithMe(this._componentManager.register(We,Ue))}};J=K([G(0,t.IUniverInstanceService),G(1,(0,t.Inject)(t.Injector)),G(2,(0,t.Inject)(i.ComponentManager)),G(3,(0,t.Inject)(i.ISidebarService)),G(4,(0,t.Inject)(t.LocaleService))],J);let Y=function(e){return e[e.createRule=1]=`createRule`,e[e.viewRule=2]=`viewRule`,e[e.highlightCell=3]=`highlightCell`,e[e.rank=4]=`rank`,e[e.formula=5]=`formula`,e[e.colorScale=6]=`colorScale`,e[e.dataBar=7]=`dataBar`,e[e.icon=8]=`icon`,e[e.clearRangeRules=9]=`clearRangeRules`,e[e.clearWorkSheetRules=10]=`clearWorkSheetRules`,e}({}),X={id:`sheet.operation.open.conditional.formatting.panel`,type:t.CommandType.OPERATION,handler:(e,i)=>{var a;let o=e.get(J),s=e.get(n.SheetsSelectionsService),c=e.get(t.ICommandService),l=((a=s.getCurrentSelections())==null?void 0:a.map(e=>e.range))||[];switch(i.value){case Y.highlightCell:o.openPanel({...(0,r.createDefaultRule)(),ranges:l});break;case Y.rank:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};o.openPanel(e);break}case Y.formula:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:`=`}};o.openPanel(e);break}case Y.colorScale:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.colorScale,config:[]}};o.openPanel(e);break}case Y.dataBar:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};o.openPanel(e);break}case Y.icon:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};o.openPanel(e);break}case Y.viewRule:o.openPanel();break;case Y.createRule:o.openPanel({...(0,r.createDefaultRule)(),ranges:l});break;case Y.clearRangeRules:c.executeCommand(r.ClearRangeCfCommand.id,{ranges:l});break;case Y.clearWorkSheetRules:c.executeCommand(r.ClearWorksheetCfCommand.id);break}return!0}},Ge=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._selectionManagerService=r,this._conditionalFormattingRuleModel=i,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{let r=[],i=[],a={redos:r,undos:i};if([n.ClearSelectionFormatCommand.id,n.ClearSelectionAllCommand.id].includes(e.id)){var o;let e=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(e=>e.range);if(!e)return a;let n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),s=n.getActiveSheet();if(!s)return a;let c=n.getUnitId(),l=s.getSheetId(),u=this._conditionalFormattingRuleModel.getSubunitRules(c,l);if(!u||!u.length)return a;let{redos:d,undos:f}=Ke(this._injector,u,e,c,l);r.push(...d),i.push(...f)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:n})=>{let r=[],i=[],a={redos:r,undos:i};if(!n||!n.length)return a;let o=this._conditionalFormattingRuleModel.getSubunitRules(e,t);if(!o||!o.length)return a;let{redos:s,undos:c}=Ke(this._injector,o,n,e,t);return r.push(...s),i.push(...c),a}}))}};Ge=K([G(0,(0,t.Inject)(t.Injector)),G(1,(0,t.Inject)(t.IUniverInstanceService)),G(2,(0,t.Inject)(n.SheetInterceptorService)),G(3,(0,t.Inject)(n.SheetsSelectionsService)),G(4,(0,t.Inject)(r.ConditionalFormattingRuleModel))],Ge);function Ke(e,i,a,o,s){let c=[],l=[];return i.filter(e=>a.some(n=>e.ranges.some(e=>t.Rectangle.getIntersects(e,n)))).forEach(t=>{let i=new n.RangeMergeUtil().add(...t.ranges).subtract(...a).merge();if(i.length){let n={id:r.SetConditionalRuleMutation.id,params:{unitId:o,subUnitId:s,rule:{...t,ranges:i}}},a=(0,r.setConditionalRuleMutationUndoFactory)(e,n.params);c.push(n),l.push(...a)}else{let n={id:r.DeleteConditionalRuleMutation.id,params:{unitId:o,subUnitId:s,cfId:t.cfId}},i=(0,r.DeleteConditionalRuleMutationUndoFactory)(e,n.params);c.push(n),l.push(...i)}}),{redos:c,undos:l}}var qe=`@univerjs/sheets-conditional-formatting-ui`,Je=`0.21.1`;let Ye=`sheets-conditional-formatting-ui.config`;Symbol(Ye);let Xe={},Z=class extends t.Disposable{constructor(e,t,n){super(),this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=t,this._injector=n,W(this,`_disposableMap`,new Map),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}_${t}_${n}`}_getRuleFormulas(e){let t=[],n=e.rule;switch(n.type){case r.CFRuleType.highlightCell:n.subType===r.CFSubRuleType.formula&&t.push(n.value);break;case r.CFRuleType.dataBar:{let e=n;e.config.min.type===r.CFValueType.formula&&t.push(e.config.min.value),e.config.max.type===r.CFValueType.formula&&t.push(e.config.max.value);break}case r.CFRuleType.colorScale:n.config.forEach(e=>{e.value.type===r.CFValueType.formula&&t.push(e.value.value)});break;case r.CFRuleType.iconSet:n.config.forEach(e=>{e.value.type===r.CFValueType.formula&&t.push(e.value.value)});break}return t}_updateRuleFormulas(e,n){let i=t.Tools.deepClone(e),a=i.rule,o=0;switch(a.type){case r.CFRuleType.highlightCell:a.subType===r.CFSubRuleType.formula&&(a.value=n[o++]);break;case r.CFRuleType.dataBar:{let e=a;e.config.min.type===r.CFValueType.formula&&(e.config.min.value=n[o++]),e.config.max.type===r.CFValueType.formula&&(e.config.max.value=n[o++]);break}case r.CFRuleType.colorScale:a.config.forEach(e=>{e.value.type===r.CFValueType.formula&&(e.value.value=n[o++])});break;case r.CFRuleType.iconSet:a.config.forEach(e=>{e.value.type===r.CFValueType.formula&&(e.value.value=n[o++])});break}return i}register(e,t,n){let i=n.ranges,a=this._getRuleFormulas(n),o=this._formulaRefRangeService.registerRangeFormula(e,t,i,a,i=>{if(i.length===0)return{undos:[{id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:n}}],redos:[{id:r.DeleteConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId}}]};let a=[],o=[],s=i[0],c=this._updateRuleFormulas(n,s.formulas);c.ranges=s.ranges,a.push({id:r.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId,rule:c}}),o.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,{unitId:e,subUnitId:t,cfId:n.cfId,rule:c}));for(let s=1;s<i.length;s++){let c=i[s],l=(0,r.createCfId)(),u=this._updateRuleFormulas(n,c.formulas);u.cfId=l,u.ranges=c.ranges,a.push({id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:u}}),o.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,{unitId:e,subUnitId:t,rule:u}))}return{undos:o,redos:a}}),s=this._getIdWithUnitId(e,t,n.cfId);this._disposableMap.set(s,o)}_initRefRange(){let e=this._conditionalFormattingRuleModel.getAll();for(let[t,n]of e)for(let[e,r]of n)for(let n of r)this.register(t,e,n);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(e=>{let{unitId:t,subUnitId:n,rule:r}=e;switch(e.type){case`add`:this.register(t,n,r);break;case`delete`:{let e=this._getIdWithUnitId(t,n,r.cfId),i=this._disposableMap.get(e);i&&(i.dispose(),this._disposableMap.delete(e));break}case`set`:{let e=this._getIdWithUnitId(t,n,r.cfId),i=this._disposableMap.get(e);i&&(i.dispose(),this._disposableMap.delete(e)),this.register(t,n,r);break}}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};Z=K([G(0,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(1,(0,t.Inject)(f.FormulaRefRangeService)),G(2,(0,t.Inject)(t.Injector))],Z);let Ze=[u.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,u.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,u.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER],Qe=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._sheetClipboardService=e,this._conditionalFormattingRuleModel=t,this._injector=n,this._conditionalFormattingViewModel=r,this._univerInstanceService=i,W(this,`_copyInfo`,void 0),this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,t,n)=>this._collectConditionalRule(e,t,n),onPasteCells:(e,t,n,r)=>!e||!this._copyInfo||!Ze.includes(r.pasteType)?{redos:[],undos:[]}:this._generateConditionalFormattingMutations(e,t,r)}))}_collectConditionalRule(e,r,i){let a=new t.ObjectMatrix,o={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:r,cfMap:o}};let s=this._injector.invoke(t=>(0,n.rangeToDiscreteRange)(i,t,e,r));if(!s)return;let{rows:c,cols:l}=s,u=new Set;c.forEach((t,n)=>{l.forEach((i,o)=>{let s=this._conditionalFormattingViewModel.getCellCfs(e,r,t,i);s&&(s.forEach(e=>u.add(e.cfId)),a.setValue(n,o,s.map(e=>e.cfId)))})}),u.forEach(t=>{let n=this._conditionalFormattingRuleModel.getRule(e,r,t);n&&(o[t]=n.rule)})}_generateConditionalFormattingMutations(e,i,a){let{unitId:o,subUnitId:s,range:c}=e,{unitId:l,subUnitId:d,range:f}=i,{copyType:p=u.COPY_TYPE.COPY}=a;if(!(0,n.getSheetCommandTarget)(this._univerInstanceService,{unitId:l,subUnitId:d}))return{redos:[],undos:[]};if(p===u.COPY_TYPE.CUT&&l===o&&d===s)return this._copyInfo=null,{redos:[],undos:[]};let{ranges:[m,h],mapFunc:g}=(0,u.virtualizeDiscreteRanges)([c,f]),_=(0,u.getRepeatRange)(m,h,!0),v={};t.Range.foreach(h,(e,n)=>{let{row:r,col:i}=g(e,n),a=this._conditionalFormattingViewModel.getCellCfs(l,d,r,i);a&&a.forEach(e=>{if(!v[e.cfId]){let n=new t.ObjectMatrix;v[e.cfId]={unitId:l,subUnitId:d,ruleMatrix:n};let r=this._conditionalFormattingRuleModel.getRule(l,d,e.cfId);r==null||r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})})}v[e.cfId].ruleMatrix.realDeleteValue(r,i)})}),p===u.COPY_TYPE.CUT&&(l!==o||d!==s)&&t.Range.foreach(m,(e,n)=>{let{row:r,col:i}=g(e,n),a=this._conditionalFormattingViewModel.getCellCfs(o,s,r,i);a&&a.forEach(e=>{if(!v[e.cfId]){let n=new t.ObjectMatrix;v[e.cfId]={unitId:o,subUnitId:s,ruleMatrix:n};let r=this._conditionalFormattingRuleModel.getRule(o,s,e.cfId);r==null||r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})})}v[e.cfId].ruleMatrix.realDeleteValue(r,i)})});let{matrix:y,info:b}=this._copyInfo,x=[],S={},C=e=>{let n=b==null?void 0:b.cfMap[e],r=[...this._conditionalFormattingRuleModel.getSubunitRules(l,d)||[],...x].find(e=>t.Tools.diffValue(e.rule,n));if(r)return S[e]=r,r;{let t={rule:n,cfId:this._conditionalFormattingRuleModel.createCfId(l,d),ranges:[],stopIfTrue:!1};return S[e]=t,x.push(t),t}};_.forEach(e=>{y&&y.forValue((n,r,i)=>{let a=t.Rectangle.getPositionRange({startRow:n,endRow:n,startColumn:r,endColumn:r},e.startRange),{row:o,col:s}=g(a.startRow,a.startColumn);i.forEach(e=>{let n=S[e]||C(e);if(!v[n.cfId]){let e=new t.ObjectMatrix;v[n.cfId]={unitId:l,subUnitId:d,ruleMatrix:e},n.ranges.forEach(n=>{t.Range.foreach(n,(t,n)=>{e.setValue(t,n,1)})})}v[n.cfId].ruleMatrix.setValue(o,s,1)})})});let w=[],T=[];for(let e in v){let{unitId:t,subUnitId:i,ruleMatrix:a}=v[e],o=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(a));if(!o.length){let n={unitId:t,subUnitId:i,cfId:e};w.push({id:r.DeleteConditionalRuleMutation.id,params:n}),T.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,n))}if(x.some(t=>t.cfId===e)){let t={unitId:l,subUnitId:d,rule:{...x.find(t=>t.cfId===e),ranges:o}};w.push({id:r.AddConditionalRuleMutation.id,params:t}),T.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,t))}else{let n=this._conditionalFormattingRuleModel.getRule(t,i,e);if(!n)continue;let a={unitId:t,subUnitId:i,rule:{...n,ranges:o}};w.push({id:r.SetConditionalRuleMutation.id,params:a}),T.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,a))}}return{redos:w,undos:T}}};Qe=K([G(0,(0,t.Inject)(u.ISheetClipboardService)),G(1,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(2,(0,t.Inject)(t.Injector)),G(3,(0,t.Inject)(r.ConditionalFormattingViewModel)),G(4,(0,t.Inject)(t.IUniverInstanceService))],Qe);let $e=class extends t.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===r.AddCfCommand.id){let{unitId:t,subUnitId:r,rule:{ranges:i}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],rangeTypes:[n.RangeProtectionPermissionEditPoint],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellStylePermission]},i,t,r)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.setStyleErr`))}}))}};$e=K([G(0,(0,t.Inject)(t.LocaleService)),G(1,t.ICommandService),G(2,(0,t.Inject)(n.SheetPermissionCheckController))],$e);let et=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._univerInstanceService=n,this._renderManagerService=r,this._conditionalFormattingViewModel=i,this._conditionalFormattingRuleModel=a,W(this,`_ruleChangeCacheMap`,new Map),this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var e,n;let r=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId();(e=this._renderManagerService.getRenderById(r))==null||e.with(u.SheetSkeletonManagerService).reCalculate(),(n=this._renderManagerService.getRenderById(r))==null||(n=n.mainComponent)==null||n.makeDirty()}_initSkeleton(){this.disposeWithMe((0,d.merge)(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe((0,m.bufferTime)(16),(0,m.filter)(e=>!!e.length),(0,m.filter)(e=>{let n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;let r=n.getActiveSheet();return r?e.filter(e=>e.unitId===n.getUnitId()&&e.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let i=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col);if(!i)return n(e);let a=t.workbook.getStyles(),o=(typeof(e==null?void 0:e.s)==`string`?a.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},s=e===t.rawData?{...t.rawData}:e;if(i.style){let e={...o,...i.style};Object.assign(s,{s:e})}return s.fontRenderExtension||(s.fontRenderExtension={},i.isShowValue!==void 0&&(s.fontRenderExtension.isSkip=!i.isShowValue)),i.dataBar&&(s.dataBar=i.dataBar),i.iconSet&&(s.iconSet=i.iconSet,s.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(s)},priority:10}))}};et=K([G(0,(0,t.Inject)(n.SheetInterceptorService)),G(1,(0,t.Inject)(r.ConditionalFormattingService)),G(2,(0,t.Inject)(t.IUniverInstanceService)),G(3,(0,t.Inject)(p.IRenderManagerService)),G(4,(0,t.Inject)(r.ConditionalFormattingViewModel)),G(5,(0,t.Inject)(r.ConditionalFormattingRuleModel))],et);let Q=class extends t.Plugin{constructor(e=Xe,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},Xe,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(Ye,o),this._initCommand(),this._injector.add([et]),this._injector.add([Qe]),this._injector.add([$e]),this._injector.add([q]),this._injector.add([Z])}_initCommand(){[h,g,_,v,y,b,x,S,C,X].forEach(e=>{this._commandService.registerCommand(e)})}};W(Q,`pluginName`,`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),W(Q,`packageName`,qe),W(Q,`version`,Je),W(Q,`type`,t.UniverInstanceType.UNIVER_SHEET),Q=K([(0,t.DependentOn)(r.UniverSheetsConditionalFormattingPlugin),G(1,(0,t.Inject)(t.Injector)),G(2,(0,t.Inject)(t.ICommandService)),G(3,t.IConfigService)],Q);let tt=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._univerInstanceService=t,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=i,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),i=(e,n,r,i,a)=>{var o;let s=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(o=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:o.getSheetId();if(!s||!c)return;let l={startRow:e.row,startColumn:e.col,endColumn:e.col,endRow:e.row},u={startRow:n.row,startColumn:n.col,endColumn:n.col,endRow:n.row};t.Range.foreach(r,(e,n)=>{let r=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},l),o=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},u),{row:d,col:f}=a(r.startRow,r.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(s,c,d,f),{row:m,col:h}=a(o.startRow,o.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(s,c,m,h);g&&g.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(s,c,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.realDeleteValue(m,h)}),p&&p.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(s,c,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.setValue(m,h,1)})})},a=(a,o)=>{var s,c;let l=(s=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:s.getUnitId(),d=(c=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null||(c=c.getActiveSheet())==null?void 0:c.getSheetId(),f=new Map,p=[],m=[];if(!l||!d)return e();let h=(0,u.virtualizeDiscreteRanges)([a,o]),[g,_]=h.ranges,{mapFunc:v}=h,y={row:g.startRow,col:g.startColumn};return n.AutoFillTools.getAutoFillRepeatRange(g,_).forEach(e=>{i(y,e.repeatStartCell,e.relativeRange,f,v)}),f.forEach((e,t)=>{let i=this._conditionalFormattingRuleModel.getRule(l,d,t);if(!i)return;let a=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(a.length){let e={unitId:l,subUnitId:d,rule:{...i,ranges:a}};p.push({id:r.SetConditionalRuleMutation.id,params:e}),m.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:l,subUnitId:d,cfId:i.cfId};p.push({id:r.DeleteConditionalRuleMutation.id,params:e}),m.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}),{undos:m,redos:p}},o={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(t,r,i)=>{if(i===n.AUTO_FILL_APPLY_TYPE.COPY||i===n.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||i===n.AUTO_FILL_APPLY_TYPE.SERIES){let{source:e,target:n}=t;return a(e,n)}return e()}};this.disposeWithMe(this._autoFillService.addHook(o))}};tt=K([G(0,(0,t.Inject)(t.Injector)),G(1,(0,t.Inject)(t.IUniverInstanceService)),G(2,(0,t.Inject)(n.IAutoFillService)),G(3,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(4,(0,t.Inject)(r.ConditionalFormattingViewModel))],tt);let nt=class extends t.Disposable{constructor(e,t){super(),this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe((0,t.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(n.AFTER_CELL_EDIT,{handler:(e,t,n)=>{var r;e||n(e);let i=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col),a=(r=i==null?void 0:i.style)==null?{}:r,o=Object.keys(a);if(e!=null&&e.p){var s;return(s=e.p.body)==null||(s=s.textRuns)==null||s.forEach(e=>{e.ts&&o.forEach(t=>{var n;(n=e.ts)==null||delete n[t]})}),n(e)}else{let r={...(typeof(e==null?void 0:e.s)==`string`?t.workbook.getStyles().get(e.s):e==null?void 0:e.s)||{}};return o.forEach(e=>{delete r[e]}),n({...e,s:{...r}})}}})))}};nt=K([G(0,(0,t.Inject)(n.SheetInterceptorService)),G(1,(0,t.Inject)(r.ConditionalFormattingService))],nt);let rt=(e,t)=>{let n=e=>e.endRow-e.startRow+1,r=e=>e.endColumn-e.startColumn+1,i=n(t)%n(e),a=r(t)%r(e),o=Math.floor(n(t)/n(e)),s=Math.floor(r(t)/r(e)),c=[],l={startRow:0,endRow:n(e)-1,startColumn:0,endColumn:r(e)-1};if(n(t)===1&&r(t)===1){let e={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};return c.push({repeatRelativeRange:l,startRange:e}),c}for(let u=0;u<o+(i?.1:0);u++)for(let d=0;d<s+(a?.1:0);d++){let f=n(e)*u,p=r(e)*d,m={startRow:f+t.startRow,endRow:f+t.startRow,startColumn:p+t.startColumn,endColumn:p+t.startColumn},h=l;u===o&&i&&(h={...h},h.endRow-=n(e)-i),d===s&&a&&(h={...h},h.endColumn-=r(e)-a),c.push({repeatRelativeRange:h,startRange:m})}return c},it=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._injector=e,this._univerInstanceService=t,this._formatPainterService=n,this._sheetsSelectionsService=r,this._conditionalFormattingRuleModel=i,this._conditionalFormattingViewModel=a,W(this,`_painterConfig`,null),this._initFormattingPainter()}_initFormattingPainter(){let e=()=>({redos:[],undos:[]}),i=(e,n,r,i,a)=>{let{unitId:o,subUnitId:s}=this._painterConfig,{targetUnitId:c,targetSubUnitId:l}=a,u={startRow:e.row,startColumn:e.col,endColumn:e.col,endRow:e.row},d={startRow:n.row,startColumn:n.col,endColumn:n.col,endRow:n.row};t.Range.foreach(r,(e,n)=>{let r=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},u),a=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},d),f=this._conditionalFormattingViewModel.getCellCfs(o,s,r.startRow,r.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(c,l,a.startRow,a.startColumn);p&&p.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(c,l,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.realDeleteValue(a.startRow,a.startColumn)}),f&&f.forEach(e=>{let t=i.get(e.cfId);t&&t.setValue(a.startRow,a.startColumn,1)})})},a=(a,o,s)=>{var c;let{range:l,unitId:u,subUnitId:d}=this._painterConfig,f=a!==u||d!==o,p=new Map,m=[],h=[];if(!a||!o||!u||!d)return e();let g=(c=this._conditionalFormattingRuleModel.getSubunitRules(u,d))==null?[]:c;g==null||g.forEach(e=>{let{ranges:n,cfId:r}=e;if(n.some(e=>t.Rectangle.intersects(l,e))){let e=new t.ObjectMatrix;f||n.forEach(n=>{t.Range.foreach(n,(t,n)=>{e.setValue(t,n,1)})}),p.set(r,e)}});let _={row:l.startRow,col:l.startColumn};return rt(l,s).forEach(e=>{i(_,{row:e.startRange.startRow,col:e.startRange.startColumn},e.repeatRelativeRange,p,{targetUnitId:a,targetSubUnitId:o})}),p.forEach((e,i)=>{if(f){let s=this._conditionalFormattingRuleModel.getRule(a,o,i),c=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(!s){if(c.length){let e=this._conditionalFormattingRuleModel.getRule(u,d,i);if(e){let n={unitId:a,subUnitId:o,rule:{...t.Tools.deepClone(e),cfId:this._conditionalFormattingRuleModel.createCfId(a,o),ranges:c}};m.push({id:r.AddConditionalRuleMutation.id,params:n}),h.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,n))}}}else if(c.length){let e={unitId:a,subUnitId:o,rule:{...s,ranges:c}};m.push({id:r.SetConditionalRuleMutation.id,params:e}),h.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:a,subUnitId:o,cfId:s.cfId};m.push({id:r.DeleteConditionalRuleMutation.id,params:e}),h.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}else{let t=this._conditionalFormattingRuleModel.getRule(u,d,i);if(!t)return;let a=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(a.length){let e={unitId:u,subUnitId:d,rule:{...t,ranges:a}};m.push({id:r.SetConditionalRuleMutation.id,params:e}),h.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:u,subUnitId:d,cfId:t.cfId};m.push({id:r.DeleteConditionalRuleMutation.id,params:e}),h.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}}),{undos:h,redos:m}},o={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:e=>{switch(e){case u.FormatPainterStatus.INFINITE:case u.FormatPainterStatus.ONCE:{var n,r;let e=(n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.getUnitId(),i=(r=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null||(r=r.getActiveSheet())==null?void 0:r.getSheetId(),a=this._sheetsSelectionsService.getCurrentLastSelection(),o=a==null?void 0:a.range;e&&i&&o&&(this._painterConfig={unitId:e,subUnitId:i,range:o});break}case u.FormatPainterStatus.OFF:this._painterConfig=null;break}},onApply:(e,t,n)=>this._painterConfig?a(e,t,n):{redos:[],undos:[]}};this._formatPainterService.addHook(o)}};it=K([G(0,(0,t.Inject)(t.Injector)),G(1,(0,t.Inject)(t.IUniverInstanceService)),G(2,(0,t.Inject)(u.IFormatPainterService)),G(3,(0,t.Inject)(n.SheetsSelectionsService)),G(4,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(5,(0,t.Inject)(r.ConditionalFormattingViewModel))],it);let at=class extends t.Disposable{constructor(e,t,n){super(),this._conditionalFormattingViewModel=e,this._univerInstanceService=t,this._renderManagerService=n,this._init()}_init(){let e=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),n=e=>{let t=e.getUnitId(),n=this._renderManagerService.getRenderById(t);if(!n)return;let i=n.with(u.SheetSkeletonManagerService);this.disposeWithMe(i.currentSkeleton$.subscribe(e=>{if(e){let t=e.skeleton.rowColumnSegment,n=t.endColumn-t.startColumn+1,i=(t.endRow-t.startRow+1)*n*9,a=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,i);this._conditionalFormattingViewModel.setCacheLength(a)}}))};e&&n(e),this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e&&n(e)})}};at=K([G(0,(0,t.Inject)(r.ConditionalFormattingViewModel)),G(1,t.IUniverInstanceService),G(2,p.IRenderManagerService)],at);let ot=[n.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],st=[{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}],ct=e=>{let a=e.get(n.SheetsSelectionsService),o=e.get(t.ICommandService),s=e.get(t.IUniverInstanceService),c=e.get(r.ConditionalFormattingRuleModel),l=new d.Observable(r=>(0,d.merge)(a.selectionMoveEnd$,a.selectionSet$,new d.Observable(e=>{let n=o.onCommandExecuted(n=>{var r;let{id:i,params:a}=n,o=(r=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getUnitId();ot.includes(i)&&a.unitId===o&&e.next(null)});return()=>n.dispose()})).pipe((0,m.debounceTime)(16)).subscribe(()=>{var i;let o=((i=a.getCurrentSelections())==null?void 0:i.map(e=>e.range))||[],l=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!l)return;let u=l.getActiveSheet();if(!u)return;let d=(c.getSubunitRules(l.getUnitId(),u.getSheetId())||[]).filter(e=>e.ranges.some(e=>o.some(n=>t.Rectangle.intersects(n,e)))).map(e=>e.ranges).every(t=>(0,n.checkRangesEditablePermission)(e,l.getUnitId(),u.getSheetId(),t));r.next(d)})),f=new d.Observable(r=>new d.Observable(e=>{let n=o.onCommandExecuted(n=>{var r;let{id:i,params:a}=n,o=(r=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getUnitId();ot.includes(i)&&a.unitId===o&&e.next(null)});return()=>n.dispose()}).pipe((0,m.debounceTime)(16)).subscribe(()=>{let i=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!i)return;let a=i.getActiveSheet();if(!a)return;let o=c.getSubunitRules(i.getUnitId(),a.getSheetId())||[];if(!o.length)return r.next(!1),!1;let l=o.map(e=>e.ranges).every(t=>(0,n.checkRangesEditablePermission)(e,i.getUnitId(),a.getSheetId(),t));r.next(l)})),p=new d.Observable(e=>{l.subscribe(t=>{let n=st.find(e=>e.value===Y.clearRangeRules);n&&(n.disabled=!t,e.next(st))}),f.subscribe(t=>{let n=st.find(e=>e.value===Y.clearWorkSheetRules);n&&(n.disabled=!t,e.next(st))}),e.next(st)});return{id:X.id,type:i.MenuItemType.SELECTOR,icon:`ConditionsDoubleIcon`,tooltip:`sheet.cf.title`,selections:p,hidden$:(0,i.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,u.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetSetCellStylePermission,n.WorksheetEditPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]})}},lt={[i.RibbonDataGroup.RULES]:{[X.id]:{order:1,menuItemFactory:ct}}},ut=class extends t.Disposable{constructor(e,t){super(),this._injector=e,this._menuManagerService=t,W(this,`_sidebarDisposable`,null),this._menuManagerService.mergeMenu(lt)}};ut=K([G(0,(0,t.Inject)(t.Injector)),G(1,i.IMenuManagerService)],ut);let $=class extends t.Plugin{constructor(e=Xe,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},Xe,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(Ye,o),this._initCommand()}onStarting(){(0,t.registerDependencies)(this._injector,[[et],[Qe],[tt],[$e],[J],[ut],[q],[nt],[Ge],[it],[at],[Z]]),(0,t.touchDependencies)(this._injector,[[et],[Z]])}onReady(){(0,t.touchDependencies)(this._injector,[[ut],[J]])}onRendered(){(0,t.touchDependencies)(this._injector,[[tt],[Ge],[Qe],[nt],[q],[it],[$e],[at]])}_initCommand(){[h,g,_,v,y,b,x,S,C,X].forEach(e=>{this._commandService.registerCommand(e)})}};W($,`pluginName`,`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),W($,`packageName`,qe),W($,`version`,Je),W($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=K([(0,t.DependentOn)(r.UniverSheetsConditionalFormattingPlugin,f.UniverSheetsFormulaPlugin),G(1,(0,t.Inject)(t.Injector)),G(2,(0,t.Inject)(t.ICommandService)),G(3,t.IConfigService)],$),e.AddAverageCfCommand=h,e.AddColorScaleConditionalRuleCommand=g,e.AddDataBarConditionalRuleCommand=_,e.AddDuplicateValuesCfCommand=v,e.AddNumberCfCommand=y,e.AddRankCfCommand=b,e.AddTextCfCommand=x,e.AddTimePeriodCfCommand=S,e.AddUniqueValuesCfCommand=C,Object.defineProperty(e,`ConditionalFormattingClearController`,{enumerable:!0,get:function(){return Ge}}),e.OpenConditionalFormattingOperator=X,Object.defineProperty(e,`UniverSheetsConditionalFormattingMobileUIPlugin`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,`UniverSheetsConditionalFormattingUIPlugin`,{enumerable:!0,get:function(){return $}})});
6
+ `,children:e.ranges.map(e=>(0,s.serializeRange)(e)).join(`,`)})]}),(0,l.jsx)(`div`,{children:(0,l.jsx)(z,{rule:e.rule})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(`univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200`,{"univer-flex univer-items-center univer-justify-center":k===e.cfId}),onClick:t=>{t.stopPropagation(),te(e),w([])},children:(0,l.jsx)(M,{})})]})})})]})},He=e=>{let[t,n]=(0,a.useState)(e.rule),[r,i]=(0,a.useState)(!!e.rule);return(0,l.jsx)(`div`,{className:`univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4`,children:r?(0,l.jsx)(Le,{onCancel:()=>{i(!1),n(void 0)},rule:t}):(0,l.jsx)(Ve,{onClick:e=>{n(e),i(!0)},onCreate:()=>{i(!0)}})})},Ue=`sheet.conditional.formatting.panel`,Y=class extends t.Disposable{constructor(e,n,r,i,a){super(),this._univerInstanceService=e,this._injector=n,this._componentManager=r,this._sidebarService=i,this._localeService=a,G(this,`_sidebarDisposable`,null),this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{var t;e||(t=this._sidebarDisposable)==null||t.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.id===Ue&&(e.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){let n={id:Ue,header:{title:this._localeService.t(`sheet.cf.title`)},children:{label:Ue,rule:e,key:(0,t.generateRandomId)(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ue,He))}};Y=q([K(0,t.IUniverInstanceService),K(1,(0,t.Inject)(t.Injector)),K(2,(0,t.Inject)(i.ComponentManager)),K(3,(0,t.Inject)(i.ISidebarService)),K(4,(0,t.Inject)(t.LocaleService))],Y);let X={id:`sheet.operation.open.conditional.formatting.panel`,type:t.CommandType.OPERATION,handler:(e,i)=>{var a;let o=e.get(Y),s=e.get(n.SheetsSelectionsService),c=e.get(t.ICommandService),l=((a=s.getCurrentSelections())==null?void 0:a.map(e=>e.range))||[];switch(i.value){case 3:o.openPanel({...(0,r.createDefaultRule)(),ranges:l});break;case 4:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};o.openPanel(e);break}case 5:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:`=`}};o.openPanel(e);break}case 6:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.colorScale,config:[]}};o.openPanel(e);break}case 7:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};o.openPanel(e);break}case 8:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};o.openPanel(e);break}case 2:o.openPanel();break;case 1:o.openPanel({...(0,r.createDefaultRule)(),ranges:l});break;case 9:c.executeCommand(r.ClearRangeCfCommand.id,{ranges:l});break;case 10:c.executeCommand(r.ClearWorksheetCfCommand.id);break}return!0}},Z=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._selectionManagerService=r,this._conditionalFormattingRuleModel=i,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{let r=[],i=[],a={redos:r,undos:i};if([n.ClearSelectionFormatCommand.id,n.ClearSelectionAllCommand.id].includes(e.id)){var o;let e=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(e=>e.range);if(!e)return a;let n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),s=n.getActiveSheet();if(!s)return a;let c=n.getUnitId(),l=s.getSheetId(),u=this._conditionalFormattingRuleModel.getSubunitRules(c,l);if(!u||!u.length)return a;let{redos:d,undos:f}=We(this._injector,u,e,c,l);r.push(...d),i.push(...f)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:n})=>{let r=[],i=[],a={redos:r,undos:i};if(!n||!n.length)return a;let o=this._conditionalFormattingRuleModel.getSubunitRules(e,t);if(!o||!o.length)return a;let{redos:s,undos:c}=We(this._injector,o,n,e,t);return r.push(...s),i.push(...c),a}}))}};Z=q([K(0,(0,t.Inject)(t.Injector)),K(1,(0,t.Inject)(t.IUniverInstanceService)),K(2,(0,t.Inject)(n.SheetInterceptorService)),K(3,(0,t.Inject)(n.SheetsSelectionsService)),K(4,(0,t.Inject)(r.ConditionalFormattingRuleModel))],Z);function We(e,i,a,o,s){let c=[],l=[];return i.filter(e=>a.some(n=>e.ranges.some(e=>t.Rectangle.getIntersects(e,n)))).forEach(t=>{let i=new n.RangeMergeUtil().add(...t.ranges).subtract(...a).merge();if(i.length){let n={id:r.SetConditionalRuleMutation.id,params:{unitId:o,subUnitId:s,rule:{...t,ranges:i}}},a=(0,r.setConditionalRuleMutationUndoFactory)(e,n.params);c.push(n),l.push(...a)}else{let n={id:r.DeleteConditionalRuleMutation.id,params:{unitId:o,subUnitId:s,cfId:t.cfId}},i=(0,r.DeleteConditionalRuleMutationUndoFactory)(e,n.params);c.push(n),l.push(...i)}}),{redos:c,undos:l}}var Ge=`@univerjs/sheets-conditional-formatting-ui`,Ke=`0.22.0`;let qe=`sheets-conditional-formatting-ui.config`;Symbol(qe);let Je={},Ye=class extends t.Disposable{constructor(e,t,n){super(),this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=t,this._injector=n,G(this,`_disposableMap`,new Map),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}_${t}_${n}`}_getRuleFormulas(e){let t=[],n=e.rule;switch(n.type){case r.CFRuleType.highlightCell:n.subType===r.CFSubRuleType.formula&&t.push(n.value);break;case r.CFRuleType.dataBar:{let e=n;e.config.min.type===r.CFValueType.formula&&t.push(e.config.min.value),e.config.max.type===r.CFValueType.formula&&t.push(e.config.max.value);break}case r.CFRuleType.colorScale:n.config.forEach(e=>{e.value.type===r.CFValueType.formula&&t.push(e.value.value)});break;case r.CFRuleType.iconSet:n.config.forEach(e=>{e.value.type===r.CFValueType.formula&&t.push(e.value.value)});break}return t}_updateRuleFormulas(e,n){let i=t.Tools.deepClone(e),a=i.rule,o=0;switch(a.type){case r.CFRuleType.highlightCell:a.subType===r.CFSubRuleType.formula&&(a.value=n[o++]);break;case r.CFRuleType.dataBar:{let e=a;e.config.min.type===r.CFValueType.formula&&(e.config.min.value=n[o++]),e.config.max.type===r.CFValueType.formula&&(e.config.max.value=n[o++]);break}case r.CFRuleType.colorScale:a.config.forEach(e=>{e.value.type===r.CFValueType.formula&&(e.value.value=n[o++])});break;case r.CFRuleType.iconSet:a.config.forEach(e=>{e.value.type===r.CFValueType.formula&&(e.value.value=n[o++])});break}return i}register(e,t,n){let i=n.ranges,a=this._getRuleFormulas(n),o=this._formulaRefRangeService.registerRangeFormula(e,t,i,a,i=>{if(i.length===0)return{undos:[{id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:n}}],redos:[{id:r.DeleteConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId}}]};let a=[],o=[],s=i[0],c=this._updateRuleFormulas(n,s.formulas);c.ranges=s.ranges,a.push({id:r.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId,rule:c}}),o.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,{unitId:e,subUnitId:t,cfId:n.cfId,rule:c}));for(let s=1;s<i.length;s++){let c=i[s],l=(0,r.createCfId)(),u=this._updateRuleFormulas(n,c.formulas);u.cfId=l,u.ranges=c.ranges,a.push({id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:u}}),o.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,{unitId:e,subUnitId:t,rule:u}))}return{undos:o,redos:a}}),s=this._getIdWithUnitId(e,t,n.cfId);this._disposableMap.set(s,o)}_initRefRange(){let e=this._conditionalFormattingRuleModel.getAll();for(let[t,n]of e)for(let[e,r]of n)for(let n of r)this.register(t,e,n);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(e=>{let{unitId:t,subUnitId:n,rule:r}=e;switch(e.type){case`add`:this.register(t,n,r);break;case`delete`:{let e=this._getIdWithUnitId(t,n,r.cfId),i=this._disposableMap.get(e);i&&(i.dispose(),this._disposableMap.delete(e));break}case`set`:{let e=this._getIdWithUnitId(t,n,r.cfId),i=this._disposableMap.get(e);i&&(i.dispose(),this._disposableMap.delete(e)),this.register(t,n,r);break}}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};Ye=q([K(0,(0,t.Inject)(r.ConditionalFormattingRuleModel)),K(1,(0,t.Inject)(f.FormulaRefRangeService)),K(2,(0,t.Inject)(t.Injector))],Ye);let Xe=[u.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,u.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,u.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER],Ze=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._sheetClipboardService=e,this._conditionalFormattingRuleModel=t,this._injector=n,this._conditionalFormattingViewModel=r,this._univerInstanceService=i,G(this,`_copyInfo`,void 0),this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,t,n)=>this._collectConditionalRule(e,t,n),onPasteCells:(e,t,n,r)=>!e||!this._copyInfo||!Xe.includes(r.pasteType)?{redos:[],undos:[]}:this._generateConditionalFormattingMutations(e,t,r)}))}_collectConditionalRule(e,r,i){let a=new t.ObjectMatrix,o={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:r,cfMap:o}};let s=this._injector.invoke(t=>(0,n.rangeToDiscreteRange)(i,t,e,r));if(!s)return;let{rows:c,cols:l}=s,u=new Set;c.forEach((t,n)=>{l.forEach((i,o)=>{let s=this._conditionalFormattingViewModel.getCellCfs(e,r,t,i);s&&(s.forEach(e=>u.add(e.cfId)),a.setValue(n,o,s.map(e=>e.cfId)))})}),u.forEach(t=>{let n=this._conditionalFormattingRuleModel.getRule(e,r,t);n&&(o[t]=n.rule)})}_generateConditionalFormattingMutations(e,i,a){let{unitId:o,subUnitId:s,range:c}=e,{unitId:l,subUnitId:d,range:f}=i,{copyType:p=u.COPY_TYPE.COPY}=a;if(!(0,n.getSheetCommandTarget)(this._univerInstanceService,{unitId:l,subUnitId:d}))return{redos:[],undos:[]};if(p===u.COPY_TYPE.CUT&&l===o&&d===s)return this._copyInfo=null,{redos:[],undos:[]};let{ranges:[m,h],mapFunc:g}=(0,u.virtualizeDiscreteRanges)([c,f]),_=(0,u.getRepeatRange)(m,h,!0),v={};t.Range.foreach(h,(e,n)=>{let{row:r,col:i}=g(e,n),a=this._conditionalFormattingViewModel.getCellCfs(l,d,r,i);a&&a.forEach(e=>{if(!v[e.cfId]){let n=new t.ObjectMatrix;v[e.cfId]={unitId:l,subUnitId:d,ruleMatrix:n};let r=this._conditionalFormattingRuleModel.getRule(l,d,e.cfId);r==null||r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})})}v[e.cfId].ruleMatrix.realDeleteValue(r,i)})}),p===u.COPY_TYPE.CUT&&(l!==o||d!==s)&&t.Range.foreach(m,(e,n)=>{let{row:r,col:i}=g(e,n),a=this._conditionalFormattingViewModel.getCellCfs(o,s,r,i);a&&a.forEach(e=>{if(!v[e.cfId]){let n=new t.ObjectMatrix;v[e.cfId]={unitId:o,subUnitId:s,ruleMatrix:n};let r=this._conditionalFormattingRuleModel.getRule(o,s,e.cfId);r==null||r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})})}v[e.cfId].ruleMatrix.realDeleteValue(r,i)})});let{matrix:y,info:b}=this._copyInfo,x=[],S={},C=e=>{let n=b==null?void 0:b.cfMap[e],r=[...this._conditionalFormattingRuleModel.getSubunitRules(l,d)||[],...x].find(e=>t.Tools.diffValue(e.rule,n));if(r)return S[e]=r,r;{let t={rule:n,cfId:this._conditionalFormattingRuleModel.createCfId(l,d),ranges:[],stopIfTrue:!1};return S[e]=t,x.push(t),t}};_.forEach(e=>{y&&y.forValue((n,r,i)=>{let a=t.Rectangle.getPositionRange({startRow:n,endRow:n,startColumn:r,endColumn:r},e.startRange),{row:o,col:s}=g(a.startRow,a.startColumn);i.forEach(e=>{let n=S[e]||C(e);if(!v[n.cfId]){let e=new t.ObjectMatrix;v[n.cfId]={unitId:l,subUnitId:d,ruleMatrix:e},n.ranges.forEach(n=>{t.Range.foreach(n,(t,n)=>{e.setValue(t,n,1)})})}v[n.cfId].ruleMatrix.setValue(o,s,1)})})});let w=[],T=[];for(let e in v){let{unitId:t,subUnitId:i,ruleMatrix:a}=v[e],o=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(a));if(!o.length){let n={unitId:t,subUnitId:i,cfId:e};w.push({id:r.DeleteConditionalRuleMutation.id,params:n}),T.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,n))}if(x.some(t=>t.cfId===e)){let t={unitId:l,subUnitId:d,rule:{...x.find(t=>t.cfId===e),ranges:o}};w.push({id:r.AddConditionalRuleMutation.id,params:t}),T.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,t))}else{let n=this._conditionalFormattingRuleModel.getRule(t,i,e);if(!n)continue;let a={unitId:t,subUnitId:i,rule:{...n,ranges:o}};w.push({id:r.SetConditionalRuleMutation.id,params:a}),T.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,a))}}return{redos:w,undos:T}}};Ze=q([K(0,(0,t.Inject)(u.ISheetClipboardService)),K(1,(0,t.Inject)(r.ConditionalFormattingRuleModel)),K(2,(0,t.Inject)(t.Injector)),K(3,(0,t.Inject)(r.ConditionalFormattingViewModel)),K(4,(0,t.Inject)(t.IUniverInstanceService))],Ze);let Qe=class extends t.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===r.AddCfCommand.id){let{unitId:t,subUnitId:r,rule:{ranges:i}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],rangeTypes:[n.RangeProtectionPermissionEditPoint],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellStylePermission]},i,t,r)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.setStyleErr`))}}))}};Qe=q([K(0,(0,t.Inject)(t.LocaleService)),K(1,t.ICommandService),K(2,(0,t.Inject)(n.SheetPermissionCheckController))],Qe);let $e=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._univerInstanceService=n,this._renderManagerService=r,this._conditionalFormattingViewModel=i,this._conditionalFormattingRuleModel=a,G(this,`_ruleChangeCacheMap`,new Map),this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var e,n;let r=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId();(e=this._renderManagerService.getRenderById(r))==null||e.with(u.SheetSkeletonManagerService).reCalculate(),(n=this._renderManagerService.getRenderById(r))==null||(n=n.mainComponent)==null||n.makeDirty()}_initSkeleton(){this.disposeWithMe((0,d.merge)(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe((0,m.bufferTime)(16),(0,m.filter)(e=>!!e.length),(0,m.filter)(e=>{let n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;let r=n.getActiveSheet();return r?e.filter(e=>e.unitId===n.getUnitId()&&e.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let i=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col);if(!i)return n(e);let a=t.workbook.getStyles(),o=(typeof(e==null?void 0:e.s)==`string`?a.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},s=e===t.rawData?{...t.rawData}:e;if(i.style){let e={...o,...i.style};Object.assign(s,{s:e})}return s.fontRenderExtension||(s.fontRenderExtension={},i.isShowValue!==void 0&&(s.fontRenderExtension.isSkip=!i.isShowValue)),i.dataBar&&(s.dataBar=i.dataBar),i.iconSet&&(s.iconSet=i.iconSet,s.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(s)},priority:10}))}};$e=q([K(0,(0,t.Inject)(n.SheetInterceptorService)),K(1,(0,t.Inject)(r.ConditionalFormattingService)),K(2,(0,t.Inject)(t.IUniverInstanceService)),K(3,(0,t.Inject)(p.IRenderManagerService)),K(4,(0,t.Inject)(r.ConditionalFormattingViewModel)),K(5,(0,t.Inject)(r.ConditionalFormattingRuleModel))],$e);let Q=class extends t.Plugin{constructor(e=Je,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},Je,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(qe,o),this._initCommand(),this._injector.add([$e]),this._injector.add([Ze]),this._injector.add([Qe]),this._injector.add([J]),this._injector.add([Ye])}_initCommand(){[h,g,_,v,y,b,x,S,C,X].forEach(e=>{this._commandService.registerCommand(e)})}};G(Q,`pluginName`,`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),G(Q,`packageName`,Ge),G(Q,`version`,Ke),G(Q,`type`,t.UniverInstanceType.UNIVER_SHEET),Q=q([(0,t.DependentOn)(r.UniverSheetsConditionalFormattingPlugin),K(1,(0,t.Inject)(t.Injector)),K(2,(0,t.Inject)(t.ICommandService)),K(3,t.IConfigService)],Q);let et=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._univerInstanceService=t,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=i,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),i=(e,n,r,i,a)=>{var o;let s=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(o=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:o.getSheetId();if(!s||!c)return;let l={startRow:e.row,startColumn:e.col,endColumn:e.col,endRow:e.row},u={startRow:n.row,startColumn:n.col,endColumn:n.col,endRow:n.row};t.Range.foreach(r,(e,n)=>{let r=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},l),o=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},u),{row:d,col:f}=a(r.startRow,r.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(s,c,d,f),{row:m,col:h}=a(o.startRow,o.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(s,c,m,h);g&&g.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(s,c,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.realDeleteValue(m,h)}),p&&p.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(s,c,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.setValue(m,h,1)})})},a=(a,o)=>{var s,c;let l=(s=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:s.getUnitId(),d=(c=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null||(c=c.getActiveSheet())==null?void 0:c.getSheetId(),f=new Map,p=[],m=[];if(!l||!d)return e();let h=(0,u.virtualizeDiscreteRanges)([a,o]),[g,_]=h.ranges,{mapFunc:v}=h,y={row:g.startRow,col:g.startColumn};return n.AutoFillTools.getAutoFillRepeatRange(g,_).forEach(e=>{i(y,e.repeatStartCell,e.relativeRange,f,v)}),f.forEach((e,t)=>{let i=this._conditionalFormattingRuleModel.getRule(l,d,t);if(!i)return;let a=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(a.length){let e={unitId:l,subUnitId:d,rule:{...i,ranges:a}};p.push({id:r.SetConditionalRuleMutation.id,params:e}),m.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:l,subUnitId:d,cfId:i.cfId};p.push({id:r.DeleteConditionalRuleMutation.id,params:e}),m.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}),{undos:m,redos:p}},o={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(t,r,i)=>{if(i===n.AUTO_FILL_APPLY_TYPE.COPY||i===n.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||i===n.AUTO_FILL_APPLY_TYPE.SERIES){let{source:e,target:n}=t;return a(e,n)}return e()}};this.disposeWithMe(this._autoFillService.addHook(o))}};et=q([K(0,(0,t.Inject)(t.Injector)),K(1,(0,t.Inject)(t.IUniverInstanceService)),K(2,(0,t.Inject)(n.IAutoFillService)),K(3,(0,t.Inject)(r.ConditionalFormattingRuleModel)),K(4,(0,t.Inject)(r.ConditionalFormattingViewModel))],et);let tt=class extends t.Disposable{constructor(e,t){super(),this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe((0,t.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(n.AFTER_CELL_EDIT,{handler:(e,t,n)=>{var r;e||n(e);let i=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col),a=(r=i==null?void 0:i.style)==null?{}:r,o=Object.keys(a);if(e!=null&&e.p){var s;return(s=e.p.body)==null||(s=s.textRuns)==null||s.forEach(e=>{e.ts&&o.forEach(t=>{var n;(n=e.ts)==null||delete n[t]})}),n(e)}else{let r={...(typeof(e==null?void 0:e.s)==`string`?t.workbook.getStyles().get(e.s):e==null?void 0:e.s)||{}};return o.forEach(e=>{delete r[e]}),n({...e,s:{...r}})}}})))}};tt=q([K(0,(0,t.Inject)(n.SheetInterceptorService)),K(1,(0,t.Inject)(r.ConditionalFormattingService))],tt);let nt=(e,t)=>{let n=e=>e.endRow-e.startRow+1,r=e=>e.endColumn-e.startColumn+1,i=n(t)%n(e),a=r(t)%r(e),o=Math.floor(n(t)/n(e)),s=Math.floor(r(t)/r(e)),c=[],l={startRow:0,endRow:n(e)-1,startColumn:0,endColumn:r(e)-1};if(n(t)===1&&r(t)===1){let e={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};return c.push({repeatRelativeRange:l,startRange:e}),c}for(let u=0;u<o+(i?.1:0);u++)for(let d=0;d<s+(a?.1:0);d++){let f=n(e)*u,p=r(e)*d,m={startRow:f+t.startRow,endRow:f+t.startRow,startColumn:p+t.startColumn,endColumn:p+t.startColumn},h=l;u===o&&i&&(h={...h},h.endRow-=n(e)-i),d===s&&a&&(h={...h},h.endColumn-=r(e)-a),c.push({repeatRelativeRange:h,startRange:m})}return c},rt=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._injector=e,this._univerInstanceService=t,this._formatPainterService=n,this._sheetsSelectionsService=r,this._conditionalFormattingRuleModel=i,this._conditionalFormattingViewModel=a,G(this,`_painterConfig`,null),this._initFormattingPainter()}_initFormattingPainter(){let e=()=>({redos:[],undos:[]}),i=(e,n,r,i,a)=>{let{unitId:o,subUnitId:s}=this._painterConfig,{targetUnitId:c,targetSubUnitId:l}=a,u={startRow:e.row,startColumn:e.col,endColumn:e.col,endRow:e.row},d={startRow:n.row,startColumn:n.col,endColumn:n.col,endRow:n.row};t.Range.foreach(r,(e,n)=>{let r=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},u),a=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},d),f=this._conditionalFormattingViewModel.getCellCfs(o,s,r.startRow,r.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(c,l,a.startRow,a.startColumn);p&&p.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(c,l,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.realDeleteValue(a.startRow,a.startColumn)}),f&&f.forEach(e=>{let t=i.get(e.cfId);t&&t.setValue(a.startRow,a.startColumn,1)})})},a=(a,o,s)=>{var c;let{range:l,unitId:u,subUnitId:d}=this._painterConfig,f=a!==u||d!==o,p=new Map,m=[],h=[];if(!a||!o||!u||!d)return e();let g=(c=this._conditionalFormattingRuleModel.getSubunitRules(u,d))==null?[]:c;g==null||g.forEach(e=>{let{ranges:n,cfId:r}=e;if(n.some(e=>t.Rectangle.intersects(l,e))){let e=new t.ObjectMatrix;f||n.forEach(n=>{t.Range.foreach(n,(t,n)=>{e.setValue(t,n,1)})}),p.set(r,e)}});let _={row:l.startRow,col:l.startColumn};return nt(l,s).forEach(e=>{i(_,{row:e.startRange.startRow,col:e.startRange.startColumn},e.repeatRelativeRange,p,{targetUnitId:a,targetSubUnitId:o})}),p.forEach((e,i)=>{if(f){let s=this._conditionalFormattingRuleModel.getRule(a,o,i),c=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(!s){if(c.length){let e=this._conditionalFormattingRuleModel.getRule(u,d,i);if(e){let n={unitId:a,subUnitId:o,rule:{...t.Tools.deepClone(e),cfId:this._conditionalFormattingRuleModel.createCfId(a,o),ranges:c}};m.push({id:r.AddConditionalRuleMutation.id,params:n}),h.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,n))}}}else if(c.length){let e={unitId:a,subUnitId:o,rule:{...s,ranges:c}};m.push({id:r.SetConditionalRuleMutation.id,params:e}),h.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:a,subUnitId:o,cfId:s.cfId};m.push({id:r.DeleteConditionalRuleMutation.id,params:e}),h.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}else{let t=this._conditionalFormattingRuleModel.getRule(u,d,i);if(!t)return;let a=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(a.length){let e={unitId:u,subUnitId:d,rule:{...t,ranges:a}};m.push({id:r.SetConditionalRuleMutation.id,params:e}),h.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:u,subUnitId:d,cfId:t.cfId};m.push({id:r.DeleteConditionalRuleMutation.id,params:e}),h.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}}),{undos:h,redos:m}},o={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:e=>{switch(e){case u.FormatPainterStatus.INFINITE:case u.FormatPainterStatus.ONCE:{var n,r;let e=(n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.getUnitId(),i=(r=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null||(r=r.getActiveSheet())==null?void 0:r.getSheetId(),a=this._sheetsSelectionsService.getCurrentLastSelection(),o=a==null?void 0:a.range;e&&i&&o&&(this._painterConfig={unitId:e,subUnitId:i,range:o});break}case u.FormatPainterStatus.OFF:this._painterConfig=null;break}},onApply:(e,t,n)=>this._painterConfig?a(e,t,n):{redos:[],undos:[]}};this._formatPainterService.addHook(o)}};rt=q([K(0,(0,t.Inject)(t.Injector)),K(1,(0,t.Inject)(t.IUniverInstanceService)),K(2,(0,t.Inject)(u.IFormatPainterService)),K(3,(0,t.Inject)(n.SheetsSelectionsService)),K(4,(0,t.Inject)(r.ConditionalFormattingRuleModel)),K(5,(0,t.Inject)(r.ConditionalFormattingViewModel))],rt);let it=class extends t.Disposable{constructor(e,t,n){super(),this._conditionalFormattingViewModel=e,this._univerInstanceService=t,this._renderManagerService=n,this._init()}_init(){let e=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),n=e=>{let t=e.getUnitId(),n=this._renderManagerService.getRenderById(t);if(!n)return;let i=n.with(u.SheetSkeletonManagerService);this.disposeWithMe(i.currentSkeleton$.subscribe(e=>{if(e){let t=e.skeleton.rowColumnSegment,n=t.endColumn-t.startColumn+1,i=(t.endRow-t.startRow+1)*n*9,a=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,i);this._conditionalFormattingViewModel.setCacheLength(a)}}))};e&&n(e),this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e&&n(e)})}};it=q([K(0,(0,t.Inject)(r.ConditionalFormattingViewModel)),K(1,t.IUniverInstanceService),K(2,p.IRenderManagerService)],it);let at=[n.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],ot=[{label:{name:`sheet.cf.ruleType.highlightCell`,selectable:!1},value:3},{label:{name:`sheet.cf.panel.rankAndAverage`,selectable:!1},value:4},{label:{name:`sheet.cf.ruleType.formula`,selectable:!1},value:5},{label:{name:`sheet.cf.ruleType.colorScale`,selectable:!1},value:6},{label:{name:`sheet.cf.ruleType.dataBar`,selectable:!1},value:7},{label:{name:`sheet.cf.ruleType.iconSet`,selectable:!1},value:8},{label:{name:`sheet.cf.menu.manageConditionalFormatting`,selectable:!1},value:2},{label:{name:`sheet.cf.menu.createConditionalFormatting`,selectable:!1},value:1},{label:{name:`sheet.cf.menu.clearRangeRules`,selectable:!1},value:9,disabled:!1},{label:{name:`sheet.cf.menu.clearWorkSheetRules`,selectable:!1},value:10}],st=e=>{let a=e.get(n.SheetsSelectionsService),o=e.get(t.ICommandService),s=e.get(t.IUniverInstanceService),c=e.get(r.ConditionalFormattingRuleModel),l=new d.Observable(r=>(0,d.merge)(a.selectionMoveEnd$,a.selectionSet$,new d.Observable(e=>{let n=o.onCommandExecuted(n=>{var r;let{id:i,params:a}=n,o=(r=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getUnitId();at.includes(i)&&a.unitId===o&&e.next(null)});return()=>n.dispose()})).pipe((0,m.debounceTime)(16)).subscribe(()=>{var i;let o=((i=a.getCurrentSelections())==null?void 0:i.map(e=>e.range))||[],l=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!l)return;let u=l.getActiveSheet();if(!u)return;let d=(c.getSubunitRules(l.getUnitId(),u.getSheetId())||[]).filter(e=>e.ranges.some(e=>o.some(n=>t.Rectangle.intersects(n,e)))).map(e=>e.ranges).every(t=>(0,n.checkRangesEditablePermission)(e,l.getUnitId(),u.getSheetId(),t));r.next(d)})),f=new d.Observable(r=>new d.Observable(e=>{let n=o.onCommandExecuted(n=>{var r;let{id:i,params:a}=n,o=(r=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getUnitId();at.includes(i)&&a.unitId===o&&e.next(null)});return()=>n.dispose()}).pipe((0,m.debounceTime)(16)).subscribe(()=>{let i=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!i)return;let a=i.getActiveSheet();if(!a)return;let o=c.getSubunitRules(i.getUnitId(),a.getSheetId())||[];if(!o.length)return r.next(!1),!1;let l=o.map(e=>e.ranges).every(t=>(0,n.checkRangesEditablePermission)(e,i.getUnitId(),a.getSheetId(),t));r.next(l)})),p=new d.Observable(e=>{l.subscribe(t=>{let n=ot.find(e=>e.value===9);n&&(n.disabled=!t,e.next(ot))}),f.subscribe(t=>{let n=ot.find(e=>e.value===10);n&&(n.disabled=!t,e.next(ot))}),e.next(ot)});return{id:X.id,type:i.MenuItemType.SELECTOR,icon:`ConditionsDoubleIcon`,tooltip:`sheet.cf.title`,selections:p,hidden$:(0,i.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,u.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetSetCellStylePermission,n.WorksheetEditPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]})}},ct={[i.RibbonDataGroup.RULES]:{[X.id]:{order:1,menuItemFactory:st}}},lt=class extends t.Disposable{constructor(e,t){super(),this._injector=e,this._menuManagerService=t,G(this,`_sidebarDisposable`,null),this._menuManagerService.mergeMenu(ct)}};lt=q([K(0,(0,t.Inject)(t.Injector)),K(1,i.IMenuManagerService)],lt);let $=class extends t.Plugin{constructor(e=Je,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},Je,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(qe,o),this._initCommand()}onStarting(){(0,t.registerDependencies)(this._injector,[[$e],[Ze],[et],[Qe],[Y],[lt],[J],[tt],[Z],[rt],[it],[Ye]]),(0,t.touchDependencies)(this._injector,[[$e],[Ye]])}onReady(){(0,t.touchDependencies)(this._injector,[[lt],[Y]])}onRendered(){(0,t.touchDependencies)(this._injector,[[et],[Z],[Ze],[tt],[J],[rt],[Qe],[it]])}_initCommand(){[h,g,_,v,y,b,x,S,C,X].forEach(e=>{this._commandService.registerCommand(e)})}};G($,`pluginName`,`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),G($,`packageName`,Ge),G($,`version`,Ke),G($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=q([(0,t.DependentOn)(r.UniverSheetsConditionalFormattingPlugin,f.UniverSheetsFormulaPlugin),K(1,(0,t.Inject)(t.Injector)),K(2,(0,t.Inject)(t.ICommandService)),K(3,t.IConfigService)],$),e.AddAverageCfCommand=h,e.AddColorScaleConditionalRuleCommand=g,e.AddDataBarConditionalRuleCommand=_,e.AddDuplicateValuesCfCommand=v,e.AddNumberCfCommand=y,e.AddRankCfCommand=b,e.AddTextCfCommand=x,e.AddTimePeriodCfCommand=S,e.AddUniqueValuesCfCommand=C,Object.defineProperty(e,`ConditionalFormattingClearController`,{enumerable:!0,get:function(){return Z}}),e.OpenConditionalFormattingOperator=X,Object.defineProperty(e,`UniverSheetsConditionalFormattingMobileUIPlugin`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,`UniverSheetsConditionalFormattingUIPlugin`,{enumerable:!0,get:function(){return $}})});
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-conditional-formatting-ui",
3
- "version": "0.21.1",
3
+ "version": "0.22.0",
4
4
  "private": false,
5
- "description": "Conditional formatting plugin for Univer Sheets",
6
- "author": "DreamNum <developer@univer.ai>",
5
+ "description": "Conditional formatting UI for Univer Sheets.",
6
+ "author": "DreamNum Co., Ltd. <developer@univer.ai>",
7
7
  "license": "Apache-2.0",
8
8
  "funding": {
9
9
  "type": "opencollective",
@@ -18,7 +18,11 @@
18
18
  "url": "https://github.com/dream-num/univer/issues"
19
19
  },
20
20
  "keywords": [
21
- "univer"
21
+ "univer",
22
+ "sheets",
23
+ "conditional-formatting",
24
+ "ui",
25
+ "plugin"
22
26
  ],
23
27
  "exports": {
24
28
  ".": {
@@ -55,25 +59,25 @@
55
59
  },
56
60
  "dependencies": {
57
61
  "@univerjs/icons": "^1.1.1",
58
- "@univerjs/core": "0.21.1",
59
- "@univerjs/design": "0.21.1",
60
- "@univerjs/engine-formula": "0.21.1",
61
- "@univerjs/engine-render": "0.21.1",
62
- "@univerjs/sheets": "0.21.1",
63
- "@univerjs/sheets-conditional-formatting": "0.21.1",
64
- "@univerjs/sheets-formula": "0.21.1",
65
- "@univerjs/sheets-formula-ui": "0.21.1",
66
- "@univerjs/sheets-ui": "0.21.1",
67
- "@univerjs/ui": "0.21.1"
62
+ "@univerjs/core": "0.22.0",
63
+ "@univerjs/design": "0.22.0",
64
+ "@univerjs/engine-formula": "0.22.0",
65
+ "@univerjs/engine-render": "0.22.0",
66
+ "@univerjs/sheets": "0.22.0",
67
+ "@univerjs/sheets-conditional-formatting": "0.22.0",
68
+ "@univerjs/sheets-formula": "0.22.0",
69
+ "@univerjs/sheets-formula-ui": "0.22.0",
70
+ "@univerjs/ui": "0.22.0",
71
+ "@univerjs/sheets-ui": "0.22.0"
68
72
  },
69
73
  "devDependencies": {
70
- "postcss": "^8.5.10",
74
+ "postcss": "^8.5.14",
71
75
  "react": "18.3.1",
72
76
  "rxjs": "^7.8.2",
73
77
  "tailwindcss": "3.4.18",
74
- "typescript": "^6.0.2",
75
- "vitest": "^4.1.4",
76
- "@univerjs-infra/shared": "0.21.1"
78
+ "typescript": "^6.0.3",
79
+ "vitest": "^4.1.5",
80
+ "@univerjs-infra/shared": "0.22.0"
77
81
  },
78
82
  "scripts": {
79
83
  "test": "vitest run",