@univerjs/preset-sheets-conditional-formatting 0.7.0 → 0.8.0-beta.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/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@univerjs/sheets-conditional-formatting"),r=require("@univerjs/sheets-conditional-formatting-ui");require("@univerjs/sheets-conditional-formatting/facade");function i(){return{plugins:[t.UniverSheetsConditionalFormattingPlugin,r.UniverSheetsConditionalFormattingUIPlugin].filter(e=>!!e)}}exports.UniverSheetsConditionalFormattingPreset=i;Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});Object.keys(r).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@univerjs/sheets-conditional-formatting"),r=require("@univerjs/sheets-conditional-formatting-ui");require("@univerjs/sheets-conditional-formatting/lib/facade");function i(){return{plugins:[t.UniverSheetsConditionalFormattingPlugin,r.UniverSheetsConditionalFormattingUIPlugin].filter(e=>!!e)}}exports.UniverSheetsConditionalFormattingPreset=i;Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});Object.keys(r).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
package/lib/es/index.js CHANGED
@@ -2,7 +2,7 @@ import { UniverSheetsConditionalFormattingPlugin as i } from "@univerjs/sheets-c
2
2
  export * from "@univerjs/sheets-conditional-formatting";
3
3
  import { UniverSheetsConditionalFormattingUIPlugin as o } from "@univerjs/sheets-conditional-formatting-ui";
4
4
  export * from "@univerjs/sheets-conditional-formatting-ui";
5
- import "@univerjs/sheets-conditional-formatting/facade";
5
+ import "@univerjs/sheets-conditional-formatting/lib/facade";
6
6
  function m() {
7
7
  return {
8
8
  plugins: [
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-pointer-events-none{pointer-events:none}.univer-absolute{position:absolute}.univer-relative{position:relative}.univer-left-0{left:0}.univer-right-1{right:4px}.univer-my-2\.5{margin-top:10px;margin-bottom:10px}.univer-mb-1{margin-bottom:4px}.univer-mb-2{margin-bottom:8px}.univer-mb-2\.5{margin-bottom:10px}.univer-mb-3{margin-bottom:12px}.univer-ml-1{margin-left:4px}.univer-ml-1\.5{margin-left:6px}.univer-ml-2{margin-left:8px}.univer-ml-3{margin-left:12px}.univer-ml-6{margin-left:24px}.univer-mr-2{margin-right:8px}.univer-mt-0{margin-top:0}.univer-mt-1{margin-top:4px}.univer-mt-3{margin-top:12px}.univer-mt-4{margin-top:16px}.univer-mt-5{margin-top:20px}.univer-mt-6{margin-top:24px}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-hidden{display:none}.univer-size-4{width:16px;height:16px}.univer-size-5{width:20px;height:20px}.univer-size-6{width:24px;height:24px}.univer-h-5{height:20px}.univer-h-8{height:32px}.univer-h-full{height:100%}.univer-w-1\/2{width:50%}.univer-w-36{width:144px}.univer-w-64{width:256px}.univer-w-80{width:320px}.univer-w-\[45\%\]{width:45%}.univer-w-full{width:100%}.univer-min-w-0{min-width:0px}.univer-min-w-\[72px\]{min-width:72px}.univer-max-w-full{max-width:100%}.univer-flex-shrink{flex-shrink:1}.univer-flex-shrink-0{flex-shrink:0}.univer-cursor-grab{cursor:grab}.univer-cursor-pointer{cursor:pointer}.univer-flex-col{flex-direction:column}.univer-flex-wrap{flex-wrap:wrap}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:8px}.univer-gap-4{gap:16px}.univer-overflow-hidden{overflow:hidden}.univer-rounded{border-radius:4px}.univer-rounded-lg{border-radius:8px}.univer-rounded-md{border-radius:6px}.univer-border-red-500{border-color:var(--univer-red-500)}.univer-bg-gray-100{background-color:var(--univer-gray-100)}.univer-bg-white{background-color:var(--univer-white)}.univer-fill-primary-600{fill:var(--univer-primary-600)}.univer-p-1{padding:4px}.univer-p-4{padding:16px}.univer-px-1{padding-left:4px;padding-right:4px}.univer-px-4{padding-left:16px;padding-right:16px}.univer-py-2{padding-top:8px;padding-bottom:8px}.univer-pl-1{padding-left:4px}.univer-pl-5{padding-left:20px}.univer-pr-8{padding-right:32px}.univer-pt-2{padding-top:8px}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-xs{font-size:12px;line-height:16px}.univer-font-bold{font-weight:700}.univer-font-medium{font-weight:500}.univer-italic{font-style:italic}.univer-text-gray-300{color:var(--univer-gray-300)}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-600{color:var(--univer-gray-600)}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-red-500{color:var(--univer-red-500)}.univer-transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.univer-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover\:univer-border-primary-600:hover{border-color:var(--univer-primary-600)}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.hover\:univer-bg-gray-200:hover{background-color:var(--univer-gray-200)}.univer-group:hover .group-hover\:univer-flex{display:flex}.dark\:univer-bg-gray-700:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)}.dark\:univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)}.dark\:univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)}.\[\&\>div\:first-child\]\:univer-px-2\.5>div:first-child{padding-left:10px;padding-right:10px}.\[\&\>div\]\:univer-h-5>div{height:20px}.\[\&\>div\]\:univer-ring-transparent>div{--tw-ring-color: transparent }.\[\&_\.react-grid-item\]\:univer-transition-none .react-grid-item{transition-property:none}.\[\&_\.react-grid-placeholder\]\:univer-rounded .react-grid-placeholder{border-radius:4px}.\[\&_\.react-grid-placeholder\]\:\!univer-bg-gray-200 .react-grid-placeholder{background-color:var(--univer-gray-200)!important}
1
+ .univer-pointer-events-none{pointer-events:none}.univer-absolute{position:absolute}.univer-relative{position:relative}.univer-bottom-\[-13px\]{bottom:-13px}.univer-left-0{left:0}.univer-right-1{right:4px}.univer-z-\[999\]{z-index:999}.univer-my-2\.5{margin-top:10px;margin-bottom:10px}.univer-mb-1{margin-bottom:4px}.univer-mb-2{margin-bottom:8px}.univer-mb-2\.5{margin-bottom:10px}.univer-mb-3{margin-bottom:12px}.univer-ml-1{margin-left:4px}.univer-ml-1\.5{margin-left:6px}.univer-ml-2{margin-left:8px}.univer-ml-3{margin-left:12px}.univer-ml-6{margin-left:24px}.univer-mr-2{margin-right:8px}.univer-mt-0{margin-top:0}.univer-mt-1{margin-top:4px}.univer-mt-3{margin-top:12px}.univer-mt-4{margin-top:16px}.univer-mt-5{margin-top:20px}.univer-mt-6{margin-top:24px}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-hidden{display:none}.univer-size-4{width:16px;height:16px}.univer-size-5{width:20px;height:20px}.univer-size-6{width:24px;height:24px}.univer-h-5{height:20px}.univer-h-8{height:32px}.univer-h-full{height:100%}.univer-w-1\/2{width:50%}.univer-w-36{width:144px}.univer-w-64{width:256px}.univer-w-80{width:320px}.univer-w-\[45\%\]{width:45%}.univer-w-full{width:100%}.univer-min-w-0{min-width:0px}.univer-min-w-\[72px\]{min-width:72px}.univer-max-w-full{max-width:100%}.univer-flex-shrink{flex-shrink:1}.univer-flex-shrink-0{flex-shrink:0}.univer-cursor-grab{cursor:grab}.univer-cursor-pointer{cursor:pointer}.univer-flex-col{flex-direction:column}.univer-flex-wrap{flex-wrap:wrap}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:8px}.univer-gap-4{gap:16px}.univer-overflow-hidden{overflow:hidden}.univer-rounded{border-radius:4px}.univer-rounded-lg{border-radius:8px}.univer-rounded-md{border-radius:6px}.univer-border{border-width:1px}.univer-border-solid{border-style:solid}.univer-border-red-500{border-color:var(--univer-red-500)}.\!univer-bg-gray-700{background-color:var(--univer-gray-700)!important}.univer-bg-gray-100{background-color:var(--univer-gray-100)}.univer-bg-white{background-color:var(--univer-white)}.univer-fill-primary-600{fill:var(--univer-primary-600)}.univer-p-1{padding:4px}.univer-p-4{padding:16px}.univer-px-1{padding-left:4px;padding-right:4px}.univer-px-4{padding-left:16px;padding-right:16px}.univer-py-2{padding-top:8px;padding-bottom:8px}.univer-pl-1{padding-left:4px}.univer-pl-5{padding-left:20px}.univer-pr-8{padding-right:32px}.univer-pt-2{padding-top:8px}.univer-text-\[10px\]{font-size:10px}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-xs{font-size:12px;line-height:16px}.univer-font-bold{font-weight:700}.univer-font-medium{font-weight:500}.univer-italic{font-style:italic}.univer-text-gray-300{color:var(--univer-gray-300)}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-600{color:var(--univer-gray-600)}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-red-500{color:var(--univer-red-500)}.univer-transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.univer-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover\:univer-border-primary-600:hover{border-color:var(--univer-primary-600)}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.hover\:univer-bg-gray-200:hover{background-color:var(--univer-gray-200)}.univer-group:hover .group-hover\:univer-flex{display:flex}.dark\:\!univer-bg-gray-700:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.dark\:\!univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)!important}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.\[\&\>div\:first-child\]\:univer-px-2\.5>div:first-child{padding-left:10px;padding-right:10px}.\[\&\>div\]\:univer-h-5>div{height:20px}.\[\&\>div\]\:univer-ring-transparent>div{--tw-ring-color: transparent }.\[\&_\.react-grid-item\]\:univer-transition-none .react-grid-item{transition-property:none}.\[\&_\.react-grid-placeholder\]\:univer-rounded .react-grid-placeholder{border-radius:4px}.\[\&_\.react-grid-placeholder\]\:\!univer-bg-gray-200 .react-grid-placeholder{background-color:var(--univer-gray-200)!important}
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import { UniverSheetsConditionalFormattingPlugin as i } from "@univerjs/sheets-c
2
2
  export * from "@univerjs/sheets-conditional-formatting";
3
3
  import { UniverSheetsConditionalFormattingUIPlugin as o } from "@univerjs/sheets-conditional-formatting-ui";
4
4
  export * from "@univerjs/sheets-conditional-formatting-ui";
5
- import "@univerjs/sheets-conditional-formatting/facade";
5
+ import "@univerjs/sheets-conditional-formatting/lib/facade";
6
6
  function m() {
7
7
  return {
8
8
  plugins: [
@@ -1,5 +1,5 @@
1
1
  import { IPreset } from './types';
2
- import '@univerjs/sheets-conditional-formatting/facade';
2
+ import '@univerjs/sheets-conditional-formatting/lib/facade';
3
3
  import '@univerjs/sheets-conditional-formatting-ui/lib/index.css';
4
- export type * from '@univerjs/sheets-conditional-formatting/facade';
4
+ export type * from '@univerjs/sheets-conditional-formatting/lib/facade';
5
5
  export declare function UniverSheetsConditionalFormattingPreset(): IPreset;
package/lib/umd/index.js CHANGED
@@ -7,9 +7,8 @@
7
7
 
8
8
 
9
9
  // @univerjs/sheets-conditional-formatting-ui/index
10
- (function(D,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","rxjs","@univerjs/engine-render","rxjs/operators"],i):(D=typeof globalThis<"u"?globalThis:D||self,i(D.UniverSheetsConditionalFormattingUi={},D.UniverCore,D.UniverSheetsConditionalFormatting,D.UniverSheets,D.UniverUi,D.React,D.React,D.UniverDesign,D.UniverEngineFormula,D.UniverSheetsFormulaUi,D.UniverSheetsUi,D.rxjs,D.UniverEngineRender,D.rxjs.operators))})(this,function(D,i,t,P,j,s,m,O,Be,pe,W,X,at,fe){"use strict";var Or=Object.defineProperty;var Ur=(D,i,t)=>i in D?Or(D,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):D[i]=t;var ee=(D,i,t)=>Ur(D,typeof i!="symbol"?i+"":i,t);const He={type:i.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u}=e,c=r.get(t.ConditionalFormattingRuleModel),p=r.get(i.ICommandService),o=r.get(i.IUniverInstanceService),v=P.getSheetCommandTarget(o);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=c.createCfId(d,f),S={ranges:l,cfId:h,stopIfTrue:!!a,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:u,style:n}};return p.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:S})}},We={type:i.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:l,config:n,stopIfTrue:a}=e,u=r.get(t.ConditionalFormattingRuleModel),c=r.get(i.ICommandService),p=r.get(i.IUniverInstanceService),o=P.getSheetCommandTarget(p);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=u.createCfId(v,d),h={ranges:l,cfId:f,stopIfTrue:!!a,rule:{type:t.CFRuleType.colorScale,config:n}};return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}},qe={type:i.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:l,min:n,max:a,nativeColor:u,positiveColor:c,isGradient:p,stopIfTrue:o,isShowValue:v}=e,d=r.get(t.ConditionalFormattingRuleModel),f=r.get(i.IUniverInstanceService),h=P.getSheetCommandTarget(f);if(!h)return!1;const{unitId:S,subUnitId:_}=h,b=r.get(i.ICommandService),E=d.createCfId(S,_),N={ranges:l,cfId:E,stopIfTrue:!!o,rule:{type:t.CFRuleType.dataBar,isShowValue:v,config:{min:n,max:a,nativeColor:u,positiveColor:c,isGradient:p}}};return b.executeCommand(t.AddConditionalRuleMutation.id,{unitId:S,subUnitId:_,rule:N})}},Ge={type:i.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a}=e,u=r.get(t.ConditionalFormattingRuleModel),c=r.get(i.ICommandService),p=r.get(i.IUniverInstanceService),o=P.getSheetCommandTarget(p);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=u.createCfId(v,d),h={ranges:l,cfId:f,stopIfTrue:!!a,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.duplicateValues,style:n}};return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}},ze={type:i.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u,value:c}=e,p=r.get(t.ConditionalFormattingRuleModel),o=r.get(i.ICommandService),v=r.get(i.IUniverInstanceService),d=P.getSheetCommandTarget(v);if(!d)return!1;const{unitId:f,subUnitId:h}=d,S=p.createCfId(f,h);let _;if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(u)){const b=c;if(b.length!==2||!Array.isArray(b))return!1;_={ranges:l,cfId:S,stopIfTrue:!!a,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:u,style:n,value:b}}}else{const b=c;if(typeof b!="number")return!1;_={ranges:l,cfId:S,stopIfTrue:!!a,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:u,style:n,value:b}}}return o.executeCommand(t.AddConditionalRuleMutation.id,{unitId:f,subUnitId:h,rule:_})}},Ye={type:i.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,isPercent:u,isBottom:c,value:p}=e,o=r.get(t.ConditionalFormattingRuleModel),v=r.get(i.IUniverInstanceService),d=r.get(i.ICommandService),f=P.getSheetCommandTarget(v);if(!f)return!1;const{unitId:h,subUnitId:S}=f,_=o.createCfId(h,S),b={ranges:l,cfId:_,stopIfTrue:!!a,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:u,isBottom:c,style:n,value:p}};return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:S,rule:b})}},Ze={type:i.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u,value:c}=e,p=r.get(t.ConditionalFormattingRuleModel),o=r.get(i.IUniverInstanceService),v=P.getSheetCommandTarget(o);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=r.get(i.ICommandService),S=p.createCfId(d,f),_={ranges:l,cfId:S,stopIfTrue:!!a,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.text,operator:u,style:n,value:c}};return h.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:_})}},Ke={type:i.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a,operator:u}=e,c=r.get(t.ConditionalFormattingRuleModel),p=r.get(i.IUniverInstanceService),o=r.get(i.ICommandService),v=P.getSheetCommandTarget(p);if(!v)return!1;const{unitId:d,subUnitId:f}=v,h=c.createCfId(d,f),S={ranges:l,cfId:h,stopIfTrue:!!a,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.timePeriod,operator:u,style:n}};return o.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:S})}},Xe={type:i.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:l,style:n,stopIfTrue:a}=e,u=r.get(t.ConditionalFormattingRuleModel),c=r.get(i.IUniverInstanceService),p=r.get(i.ICommandService),o=P.getSheetCommandTarget(c);if(!o)return!1;const{unitId:v,subUnitId:d}=o,f=u.createCfId(v,d),h={ranges:l,cfId:f,stopIfTrue:!!a,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.uniqueValues,style:n}};return p.executeCommand(t.AddConditionalRuleMutation.id,{unitId:v,subUnitId:d,rule:h})}};var K=function(){return K=Object.assign||function(r){for(var e,l=1,n=arguments.length;l<n;l++){e=arguments[l];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=e[a])}return r},K.apply(this,arguments)},Tt=function(r,e){var l={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(l[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(r);a<n.length;a++)e.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(r,n[a])&&(l[n[a]]=r[n[a]]);return l},le=m.forwardRef(function(r,e){var l=r.icon,n=r.id,a=r.className,u=r.extend,c=Tt(r,["icon","id","className","extend"]),p="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),o=m.useRef("_".concat(Nt()));return lt(l,"".concat(n),{defIds:l.defIds,idSuffix:o.current},K({ref:e,className:p},c),u)});function lt(r,e,l,n,a){return m.createElement(r.tag,K(K({key:e},_t(r,l,a)),n),(xt(r,l).children||[]).map(function(u,c){return lt(u,"".concat(e,"-").concat(r.tag,"-").concat(c),l,void 0,a)}))}function _t(r,e,l){var n=K({},r.attrs);l!=null&&l.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=l.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(u){var c=u[0],p=u[1];c==="mask"&&typeof p=="string"&&(n[c]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var a=e.defIds;return!a||a.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(u){var c=u[0],p=u[1];typeof p=="string"&&(n[c]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function xt(r,e){var l,n=e.defIds;return!n||n.length===0?r:r.tag==="defs"&&(!((l=r.children)===null||l===void 0)&&l.length)?K(K({},r),{children:r.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.indexOf(a.attrs.id)>-1?K(K({},a),{attrs:K(K({},a.attrs),{id:a.attrs.id+e.idSuffix})}):a})}):r}function Nt(){return Math.random().toString(36).substring(2,8)}le.displayName="UniverIcon";var Et={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Re=m.forwardRef(function(r,e){return m.createElement(le,Object.assign({},r,{id:"delete-single",ref:e,icon:Et}))});Re.displayName="DeleteSingle";var Rt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},ut=m.forwardRef(function(r,e){return m.createElement(le,Object.assign({},r,{id:"increase-single",ref:e,icon:Rt}))});ut.displayName="IncreaseSingle";var Mt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Me=m.forwardRef(function(r,e){return m.createElement(le,Object.assign({},r,{id:"more-down-single",ref:e,icon:Mt}))});Me.displayName="MoreDownSingle";var wt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},it=m.forwardRef(function(r,e){return m.createElement(le,Object.assign({},r,{id:"sequence-single",ref:e,icon:wt}))});it.displayName="SequenceSingle";var Vt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_436_41",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.35 0.48H16.35V16.48H0.35z"}}]},{tag:"g",attrs:{mask:"url(#mask0_436_41)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z"}},{tag:"path",attrs:{fill:"#E5E5E5",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z"}}]}]},he=m.forwardRef(function(r,e){return m.createElement(le,Object.assign({},r,{id:"slash-single",ref:e,icon:Vt}))});he.displayName="SlashSingle";const te=r=>{const{color:e,onChange:l,disable:n=!1,iconId:a="PaintBucket",className:u,isNeedDropdownIcon:c=!0}=r,p=j.useDependency(j.ComponentManager),o=m.useMemo(()=>new i.ColorKit(e),[e]),v=p.get(a);return v?n?s.jsx(v,{className:O.clsx("univer-fill-primary-600",u),extend:{colorChannel1:o.isValid?e:""}}):s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(O.ColorPicker,{value:e,onChange:l})}),children:s.jsxs("span",{className:O.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100",u),children:[s.jsx(v,{className:"univer-fill-primary-600",extend:{colorChannel1:o.isValid?e:""}}),c&&s.jsx(Me,{className:"univer-ml-1.5 univer-text-gray-400"})]})}):null},ue=r=>{var u,c,p;const e=r.rule;if(!e)return null;const l=m.useMemo(()=>{if(e.type===t.CFRuleType.colorScale){const o=e.config.map((f,h)=>({color:new i.ColorKit(f.color),value:h})),v=o.length-1;return new Array(5).fill("").map((f,h,S)=>h*v/(S.length-1)).map(f=>t.getColorScaleFromValue(o,f))}return null},[e]),n=m.useMemo(()=>{if(e.type===t.CFRuleType.iconSet)return e.config.map(o=>{const v=t.iconMap[o.iconType];return v&&v[Number(o.iconId)]})},[e]),a=`univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center
11
- univer-justify-center univer-text-xs`;switch(e.type){case t.CFRuleType.dataBar:{const{isGradient:o}=e.config,v=o?`linear-gradient(to right, ${e.config.positiveColor||t.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,d=o?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||t.defaultDataBarNativeColor})`:e.config.nativeColor;return s.jsxs("div",{className:a,children:[s.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:d,border:`1px solid ${e.config.nativeColor||t.defaultDataBarNativeColor}`}}),s.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:v,border:`1px solid ${e.config.positiveColor||t.defaultDataBarPositiveColor}`}})]})}case t.CFRuleType.colorScale:return l&&s.jsx("div",{className:a,children:l.map((o,v)=>s.jsx("div",{className:"univer-h-full",style:{width:`${100/l.length}%`,background:o}},v))});case t.CFRuleType.iconSet:return n&&s.jsx("div",{className:a,children:n.map((o,v)=>o?s.jsx("img",{className:"univer-h-full",src:o,draggable:!1},v):s.jsx(he,{},v))});case t.CFRuleType.highlightCell:{const{ul:o,st:v,it:d,bl:f,bg:h,cl:S}=e.style,_=(o==null?void 0:o.s)===i.BooleanNumber.TRUE,b=(v==null?void 0:v.s)===i.BooleanNumber.TRUE,E=d===i.BooleanNumber.TRUE,N=f===i.BooleanNumber.TRUE,R=(u=h==null?void 0:h.rgb)!=null?u:t.DEFAULT_BG_COLOR,w=(c=S==null?void 0:S.rgb)!=null?c:t.DEFAULT_FONT_COLOR,M={textDecoration:(p=`${_?"underline":""} ${b?"line-through":""}`.replace(/^ /,""))!=null?p:void 0,backgroundColor:R,color:w};return s.jsx("div",{className:O.clsx(a,{"univer-font-bold":N,"univer-italic":E}),style:M,children:"123"})}}},ye=O.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",O.borderClassName),re=(r,e)=>({label:e.t(`sheet.cf.valueType.${r}`),value:r}),Je=r=>{var _;const{type:e,className:l,onChange:n,id:a,value:u}=r,c=j.useDependency(i.IUniverInstanceService),p=c.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(_=c.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:_.getSheetId(),v=m.useMemo(()=>String(u).startsWith("=")?String(u):"=",[u]),d=m.useMemo(()=>[t.CFValueType.max,t.CFValueType.min,"none"].includes(e)?{disabled:!0}:[t.CFValueType.percent,t.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),f=m.useRef(null),[h,S]=m.useState(!1);return j.useSidebarClick(b=>{var N;((N=f.current)==null?void 0:N.isClickOutSide(b))&&S(!1)}),e===t.CFValueType.formula?s.jsx("div",{className:"univer-ml-1 univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:f,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:univer-bg-gray-700 dark:univer-text-white hover:univer-border-primary-600",O.borderClassName),initValue:v,unitId:p,subUnitId:o,isFocus:h,onChange:(b="")=>{n(b||"")},onFocus:()=>S(!0)})}):s.jsx(O.InputNumber,{className:l,value:Number(r.value)||0,onChange:b=>r.onChange(b||0),...d})},Ot=r=>{var A;const{interceptorManager:e}=r,l=j.useDependency(i.LocaleService),n=((A=r.rule)==null?void 0:A.type)===t.CFRuleType.colorScale?r.rule:void 0,a=[re(t.CFValueType.num,l),re(t.CFValueType.percent,l),re(t.CFValueType.percentile,l),re(t.CFValueType.formula,l)],u=[re(t.CFValueType.min,l),...a],c=[re("none",l),...a],p=[re(t.CFValueType.max,l),...a],[o,v]=m.useState(()=>{var x;const g=t.CFValueType.min;return n&&((x=n.config[0])==null?void 0:x.value.type)||g}),[d,f]=m.useState(()=>{var x;const g="none";return!n||n.config.length!==3?g:((x=n.config[1])==null?void 0:x.value.type)||g}),[h,S]=m.useState(()=>{var x;const g=t.CFValueType.max;return n&&((x=n.config[n.config.length-1])==null?void 0:x.value.type)||g}),[_,b]=m.useState(()=>{if(!n)return 10;const x=n.config[0];return(x==null?void 0:x.value.value)===void 0?10:x==null?void 0:x.value.value}),[E,N]=m.useState(()=>{var F;if(!n||n.config.length!==3)return 50;const x=(F=n.config[1])==null?void 0:F.value.value;return x===void 0?50:x}),[R,w]=m.useState(()=>{var F;if(!n)return 90;const x=(F=n.config[n.config.length-1])==null?void 0:F.value.value;return x===void 0?90:x}),[M,y]=m.useState(()=>{var x;const g="#d0d9fb";return n&&((x=n.config[0])==null?void 0:x.color)||g}),[I,T]=m.useState(()=>{var x;const g="#7790f3";return!n||n.config.length!==3?g:((x=n.config[1])==null?void 0:x.color)||g}),[C,U]=m.useState(()=>{var x;const g="#2e55ef";return n&&((x=n.config[n.config.length-1])==null?void 0:x.color)||g}),V=m.useMemo(()=>g=>{const{minType:x,medianType:F,maxType:G,minValue:J,medianValue:Q,maxValue:de,minColor:ve,medianColor:L,maxColor:$}=g,H=[];return H.push({color:ve,value:{type:x,value:J}}),F!=="none"&&H.push({color:L,value:{type:F,value:Q}}),H.push({color:$,value:{type:G,value:de}}),{config:H.map((z,Y)=>({...z,index:Y})),type:t.CFRuleType.colorScale}},[]);m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return V({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),[V,o,d,h,_,E,R,M,I,C,e]);const k=g=>{r.onChange(V(g))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:V({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:C})})}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:univer-text-gray-200",children:l.t("sheet.cf.valueType.min")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:u,value:o,onChange:g=>{v(g);const x=t.createDefaultValueByValueType(g,10);b(x),k({minType:g,medianType:d,maxType:h,minValue:x,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"min",className:"univer-ml-1",value:_,type:o,onChange:g=>{b(g),k({minType:o,medianType:d,maxType:h,minValue:g,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(te,{className:"univer-ml-1",color:M,onChange:g=>{y(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:g,medianColor:I,maxColor:C})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600dark:univer-text-gray-200",children:l.t("sheet.cf.panel.medianValue")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:c,value:d,onChange:g=>{f(g);const x=t.createDefaultValueByValueType(g,50);N(x),k({minType:o,medianType:g,maxType:h,minValue:_,medianValue:x,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"median",className:"univer-ml-1",value:E,type:d,onChange:g=>{N(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:g,maxValue:R,minColor:M,medianColor:I,maxColor:C})}}),d!=="none"&&s.jsx(te,{className:"univer-ml-1",color:I,onChange:g=>{T(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:M,medianColor:g,maxColor:C})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:univer-text-gray-200",children:l.t("sheet.cf.valueType.max")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:p,value:h,onChange:g=>{S(g);const x=t.createDefaultValueByValueType(g,90);w(x),k({minType:o,medianType:d,maxType:g,minValue:_,medianValue:E,maxValue:x,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"max",className:"univer-ml-1",value:R,type:h,onChange:g=>{w(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:g,minColor:M,medianColor:I,maxColor:C})}}),s.jsx(te,{className:"univer-ml-1",color:C,onChange:g=>{U(g),k({minType:o,medianType:d,maxType:h,minValue:_,medianValue:E,maxValue:R,minColor:M,medianColor:I,maxColor:g})}})]})]})},ie=(r,e)=>({label:e.t(`sheet.cf.valueType.${r}`),value:r}),st=r=>{var b;const{onChange:e,className:l,value:n,type:a,id:u,disabled:c=!1}=r,p=j.useDependency(i.IUniverInstanceService),o=p.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),v=(b=p.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId(),d=m.useRef(null),[f,h]=m.useState(!1);j.useSidebarClick(E=>{var R;((R=d.current)==null?void 0:R.isClickOutSide(E))&&h(!1)});const S=m.useRef(n),_=m.useMemo(()=>[t.CFValueType.percentile,t.CFValueType.percent].includes(a)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[a]);if(a===t.CFValueType.formula){const E=String(S.current).startsWith("=")?String(S.current)||"":"=";return s.jsx("div",{className:"univer-ml-3 univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:d,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:univer-bg-gray-700 dark:univer-text-white hover:univer-border-primary-600",O.borderClassName),initValue:E,unitId:o,subUnitId:v,isFocus:f,onChange:(N="")=>{e(N||"")},onFocus:()=>h(!0)})})}return s.jsx(O.InputNumber,{className:l,value:Number(n)||0,disabled:c,onChange:E=>{e(E||0)},..._})},Ut=r=>{var A;const{interceptorManager:e}=r,l=j.useDependency(i.LocaleService),n=((A=r.rule)==null?void 0:A.type)===t.CFRuleType.dataBar?r.rule:void 0,[a,u]=m.useState(()=>{var x;const g="0";return n?(x=n.config)!=null&&x.isGradient?"1":"0":g}),[c,p]=m.useState(()=>{var g;return n&&((g=n.config)==null?void 0:g.positiveColor)||t.defaultDataBarPositiveColor}),[o,v]=m.useState(()=>{var g;return n&&((g=n.config)==null?void 0:g.nativeColor)||t.defaultDataBarNativeColor}),d=[ie(t.CFValueType.num,l),ie(t.CFValueType.percent,l),ie(t.CFValueType.percentile,l),ie(t.CFValueType.formula,l)],f=[ie(t.CFValueType.min,l),...d],h=[ie(t.CFValueType.max,l),...d],[S,_]=m.useState(()=>{var x;const g=f[0].value;return n&&((x=n.config)==null?void 0:x.min.type)||g}),[b,E]=m.useState(()=>{var x;const g=h[0].value;return n&&((x=n.config)==null?void 0:x.max.type)||g}),[N,R]=m.useState(()=>{var F;if(!n)return 0;const x=((F=n.config)==null?void 0:F.min)||{};return x.type===t.CFValueType.formula?x.value||"=":x.value||0}),[w,M]=m.useState(()=>{var F;if(!n)return 100;const x=((F=n.config)==null?void 0:F.max)||{};return x.type===t.CFValueType.formula?x.value||"=":x.value===void 0?100:x.value}),[y,I]=m.useState(()=>n?n.isShowValue===void 0?!0:!!n.isShowValue:!0),T=g=>({config:{min:{type:g.minValueType,value:g.minValue},max:{type:g.maxValueType,value:g.maxValue},isGradient:g.isGradient==="1",positiveColor:g.positiveColor||t.defaultDataBarPositiveColor,nativeColor:g.nativeColor||t.defaultDataBarNativeColor},type:t.CFRuleType.dataBar,isShowValue:g.isShowValue});m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return T({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}}),[a,N,S,w,b,c,o,e,y]);const C=g=>{r.onChange(T(g))},U=g=>{p(g),C({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:g,nativeColor:o,isShowValue:y})},V=g=>{v(g),C({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:g,isShowValue:y})},k=g=>d.map(x=>x.value).includes(g);return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:T({isGradient:a,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})})}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:l.t("sheet.cf.panel.fillType")}),s.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[s.jsxs(O.RadioGroup,{value:a,onChange:g=>{u(g),C({isGradient:g,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})},children:[s.jsx(O.Radio,{value:"0",children:s.jsx("span",{className:"univer-text-xs",children:l.t("sheet.cf.panel.pureColor")})}),s.jsx(O.Radio,{value:"1",children:s.jsx("span",{className:"univer-text-xs",children:l.t("sheet.cf.panel.gradient")})})]}),s.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:!y,onChange:g=>{I(!g),C({isGradient:g,minValue:N,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:!g})}}),l.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:l.t("sheet.cf.panel.colorSet")}),s.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[s.jsxs("div",{className:"univer-flex univer-items-center",children:[s.jsx("div",{className:"univer-text-xs",children:l.t("sheet.cf.panel.native")}),s.jsx(te,{color:o,onChange:V})]}),s.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[s.jsx("div",{className:"univer-text-xs",children:l.t("sheet.cf.panel.positive")}),s.jsx(te,{color:c,onChange:U})]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:l.t("sheet.cf.valueType.min")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:f,value:S,onChange:g=>{_(g);const x=t.createDefaultValueByValueType(g,10);R(x),C({isGradient:a,minValue:x,minValueType:g,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}}),s.jsx(st,{id:"min",className:"univer-ml-3",disabled:!k(S),type:S,value:N,onChange:g=>{R(g||0),C({isGradient:a,minValue:g||0,minValueType:S,maxValue:w,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:l.t("sheet.cf.valueType.max")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:b,onChange:g=>{E(g);const x=t.createDefaultValueByValueType(g,90);M(x),C({isGradient:a,minValue:N,minValueType:S,maxValue:x,maxValueType:g,positiveColor:c,nativeColor:o,isShowValue:y})}}),s.jsx(st,{className:"univer-ml-3",disabled:!k(b),id:"max",type:b,value:w,onChange:g=>{M(g||0),C({isGradient:a,minValue:N,minValueType:S,maxValue:g||0,maxValueType:b,positiveColor:c,nativeColor:o,isShowValue:y})}})]})]})]})},we=r=>[i.BooleanNumber.FALSE,void 0].includes(r)?i.BooleanNumber.TRUE:i.BooleanNumber.FALSE,Ve=r=>r!==i.BooleanNumber.FALSE,Qe=r=>{const{style:e,onChange:l,className:n}=r,a=j.useDependency(j.ComponentManager),[u,c]=m.useState(()=>{if(e!=null&&e.bl)return e.bl}),[p,o]=m.useState(()=>{if(e!=null&&e.it)return e.it}),[v,d]=m.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[f,h]=m.useState(()=>{if(e!=null&&e.st)return e.st.s}),[S,_]=m.useState(()=>{var T;const I="#2f56ef";return(T=e==null?void 0:e.cl)!=null&&T.rgb?e.cl.rgb:I}),[b,E]=m.useState(()=>{var T;const I="#e8ecfc";return(T=e==null?void 0:e.bg)!=null&&T.rgb?e.bg.rgb:I}),N=a.get("BoldSingle"),R=a.get("ItalicSingle"),w=a.get("UnderlineSingle"),M=a.get("StrikethroughSingle");m.useEffect(()=>{const I={bl:u,it:p};S!==void 0&&(I.cl={rgb:S}),b!==void 0&&(I.bg={rgb:b}),f!==void 0&&(I.st={s:f}),v!==void 0&&(I.ul={s:v}),l(t.removeUndefinedAttr(I))},[u,p,v,f,S,b]);const y="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return s.jsxs("div",{className:O.clsx("univer-my-2.5 univer-flex univer-justify-between",n),children:[N&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(u||i.BooleanNumber.FALSE)}),onClick:()=>c(we(u)),children:s.jsx(N,{})}),R&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(p||i.BooleanNumber.FALSE)}),onClick:()=>o(we(p)),children:s.jsx(R,{})}),w&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(v||i.BooleanNumber.FALSE)}),onClick:()=>d(we(v)),children:s.jsx(w,{})}),M&&s.jsx("div",{className:O.clsx(y,{"univer-bg-gray-100":Ve(f||i.BooleanNumber.FALSE)}),onClick:()=>h(we(f)),children:s.jsx(M,{})}),s.jsx(te,{color:S,onChange:_,iconId:"FontColor"}),s.jsx(te,{color:b,onChange:E,iconId:"PaintBucket"})]})},kt=r=>{var M;const{onChange:e,interceptorManager:l}=r,n=j.useDependency(i.LocaleService),u=j.useDependency(i.IUniverInstanceService).getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),c=u.getActiveSheet(),p=((M=r.rule)==null?void 0:M.type)===t.CFRuleType.highlightCell?r.rule:void 0,o=m.useRef(null),[v,d]=m.useState(!1),f=m.useRef(null),[h,S]=m.useState({}),[_,b]=m.useState(()=>(p==null?void 0:p.subType)===t.CFSubRuleType.formula?p.value:"="),[E,N]=m.useState(void 0),R=y=>({style:y.style,value:_,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});m.useEffect(()=>l.intercept(l.getInterceptPoints().submit,{handler(){return R({style:h})}}),[h,_,l]),m.useEffect(()=>l.intercept(l.getInterceptPoints().beforeSubmit,{handler:(I,T,C)=>E||_.length===1||!_.startsWith("=")?(N(n.t("sheet.cf.errorMessage.formulaError")),!1):C(I)}),[E,_]);const w=y=>{e(R(y))};return j.useSidebarClick(y=>{var T;((T=f.current)==null?void 0:T.isClickOutSide(y))&&d(!1)}),s.jsxs("div",{ref:o,children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:"univer-mt-3",children:s.jsx(pe.FormulaEditor,{ref:f,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:univer-bg-gray-700 dark:univer-text-white hover:univer-border-primary-600",O.borderClassName),errorText:E,isFocus:v,initValue:_,unitId:u.getUnitId(),subUnitId:c==null?void 0:c.getSheetId(),onFocus:()=>{d(!0)},onChange:y=>{b(y),w({style:h})},onVerify:(y,I)=>{!y||I.length===1?N(n.t("sheet.cf.errorMessage.formulaError")):N(void 0)}})}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:R({style:h})})}),s.jsx(Qe,{style:p==null?void 0:p.style,className:"univer-mt-3",onChange:y=>{S(y),w({style:y})}})]})},Oe=r=>s.jsxs("div",{style:{position:"relative"},children:[s.jsx("div",{style:{position:"absolute",zIndex:999,bottom:"-13px",fontSize:"10px",color:"red"},children:r.errorText}),r.children]}),B=(r,e)=>({label:e.t(`sheet.cf.operator.${r}`),value:r}),Pt=r=>{const{type:e,operator:l,onChange:n,value:a,interceptorManager:u}=r,c=j.useDependency(i.LocaleService),[p,o]=m.useState(()=>typeof a=="number"?a:0),[v,d]=m.useState(""),[f,h]=m.useState(()=>typeof a=="string"?a:""),[S,_]=m.useState(""),[b,E]=m.useState(()=>Array.isArray(a)?a[0]===void 0?0:a[0]:0),[N,R]=m.useState(""),[w,M]=m.useState(()=>Array.isArray(a)?a[1]===void 0?100:a[1]:100),[y,I]=m.useState("");switch(m.useEffect(()=>{switch(e){case t.CFSubRuleType.text:{[t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(l)&&n(f);break}case t.CFSubRuleType.number:{[t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(l)&&n(p),[t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(l)&&n([b,w]);break}}},[e]),m.useEffect(()=>{const T=u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(C,U,V)=>{switch(e){case t.CFSubRuleType.text:if([t.CFTextOperator.beginsWith,t.CFTextOperator.containsText,t.CFTextOperator.endsWith,t.CFTextOperator.notEqual,t.CFTextOperator.notContainsText,t.CFTextOperator.equal].includes(l))return f?V(C):(_(c.t("sheet.cf.errorMessage.notBlank")),!1)}return V(C)}});return()=>{T()}},[e,p,f,l]),e){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(l)){const T=C=>{h(C),n(C)};return s.jsx("div",{className:"univer-mt-3",children:s.jsx(Oe,{errorText:S,children:s.jsx(O.Input,{value:f,onChange:C=>{_(""),T(C)}})})})}break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(l)){const T=C=>{o(C||0),n(C||0),d("")};return s.jsx("div",{className:"univer-mt-3",children:s.jsx(Oe,{errorText:v,children:s.jsx(O.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:p,onChange:T})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(l)){const T=U=>{E(U||0),n([U||0,w]),R("")},C=U=>{M(U||0),n([b,U||0]),I("")};return s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(Oe,{errorText:N,children:s.jsx(O.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:b,onChange:T})}),s.jsx(Oe,{errorText:y,children:s.jsx(O.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:w,onChange:C})})]})}}}return null},ct=(r,e)=>{switch(r){case t.CFSubRuleType.text:return[B(t.CFTextOperator.containsText,e),B(t.CFTextOperator.notContainsText,e),B(t.CFTextOperator.beginsWith,e),B(t.CFTextOperator.endsWith,e),B(t.CFTextOperator.equal,e),B(t.CFTextOperator.notEqual,e),B(t.CFTextOperator.containsBlanks,e),B(t.CFTextOperator.notContainsBlanks,e),B(t.CFTextOperator.containsErrors,e),B(t.CFTextOperator.notContainsErrors,e)];case t.CFSubRuleType.number:return[B(t.CFNumberOperator.between,e),B(t.CFNumberOperator.notBetween,e),B(t.CFNumberOperator.equal,e),B(t.CFNumberOperator.notEqual,e),B(t.CFNumberOperator.greaterThan,e),B(t.CFNumberOperator.greaterThanOrEqual,e),B(t.CFNumberOperator.lessThan,e),B(t.CFNumberOperator.lessThanOrEqual,e)];case t.CFSubRuleType.timePeriod:return[B(t.CFTimePeriodOperator.yesterday,e),B(t.CFTimePeriodOperator.today,e),B(t.CFTimePeriodOperator.tomorrow,e),B(t.CFTimePeriodOperator.last7Days,e),B(t.CFTimePeriodOperator.lastWeek,e),B(t.CFTimePeriodOperator.thisWeek,e),B(t.CFTimePeriodOperator.nextWeek,e),B(t.CFTimePeriodOperator.lastMonth,e),B(t.CFTimePeriodOperator.thisMonth,e),B(t.CFTimePeriodOperator.nextMonth,e)]}},ot=r=>{var M;const{interceptorManager:e,onChange:l}=r,n=j.useDependency(i.LocaleService),a=((M=r.rule)==null?void 0:M.type)===t.CFRuleType.highlightCell?r.rule:void 0,[u,c]=m.useState(()=>{const y=t.CFSubRuleType.text;return a&&a.subType||y}),p=[{value:t.CFSubRuleType.text,label:n.t("sheet.cf.subRuleType.text")},{value:t.CFSubRuleType.number,label:n.t("sheet.cf.subRuleType.number")},{value:t.CFSubRuleType.timePeriod,label:n.t("sheet.cf.subRuleType.timePeriod")},{value:t.CFSubRuleType.duplicateValues,label:n.t("sheet.cf.subRuleType.duplicateValues")},{value:t.CFSubRuleType.uniqueValues,label:n.t("sheet.cf.subRuleType.uniqueValues")}],o=m.useMemo(()=>ct(u,n),[u]),[v,d]=m.useState(()=>{const y=o?o[0].value:void 0;return a&&a.operator||y}),[f,h]=m.useState(()=>{var T;const y="";return a?(T=a.value)!=null?T:t.createDefaultValue(a.subType,a.operator):y}),[S,_]=m.useState({}),b=m.useMemo(()=>y=>{var I,T,C,U,V,k,A,g,x,F,G,J,Q,de,ve;switch(y.subType||u){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(v))return{type:t.CFRuleType.highlightCell,subType:(I=y.subType)!=null?I:u,operator:(T=y.operator)!=null?T:v,style:(C=y.style)!=null?C:S,value:(U=y.value)!=null?U:f};break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(v))return{type:t.CFRuleType.highlightCell,subType:(V=y.subType)!=null?V:u,operator:(k=y.operator)!=null?k:v,style:(A=y.style)!=null?A:S,value:(g=y.value)!=null?g:f};if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(v))return{type:t.CFRuleType.highlightCell,subType:(x=y.subType)!=null?x:u,operator:(F=y.operator)!=null?F:v,style:(G=y.style)!=null?G:S,value:(J=y.value)!=null?J:f};break}}return{type:t.CFRuleType.highlightCell,subType:(Q=y.subType)!=null?Q:u,operator:(de=y.operator)!=null?de:v,style:(ve=y.style)!=null?ve:S}},[u,v,f,S]);m.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return b({})}}),[b,e]),m.useEffect(()=>{p.some(y=>y.value===u)||c(p[0].value)},[p]);const E=y=>{const I=y,T=ct(I,n),C=T&&T[0].value;c(I),d(C),C&&h(t.createDefaultValue(I,C)),l(b({subType:I,operator:C}))},N=y=>{const I=y;d(I),l(b({operator:I}))},R=y=>{h(y),l(b({value:y}))},w=m.useMemo(()=>`${u}_${v}_${Math.random()}`,[u,v]);return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:E,value:u,options:p}),(o==null?void 0:o.length)&&s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:N,value:v||"",options:o})]}),s.jsx(Pt,{value:f,interceptorManager:e,type:u,operator:v,rule:a,onChange:R},w),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:b({})})}),s.jsx(Qe,{style:a==null?void 0:a.style,className:"univer-ml-1",onChange:y=>{_(y),l(b({style:y}))}})]})},dt=(r,e)=>(t.iconMap[r]||[])[Number(e)]||"",Dt=r=>{var d;const{error:e,type:l,onChange:n}=r,a=j.useDependency(i.IUniverInstanceService),u=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(d=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),p=m.useRef(null),[o,v]=m.useState(!1);return j.useSidebarClick(f=>{var S;((S=p.current)==null?void 0:S.isClickOutSide(f))&&v(!1)}),s.jsx("div",{className:"univer-relative",children:l!==t.CFValueType.formula?s.jsxs(s.Fragment,{children:[s.jsx(O.InputNumber,{className:O.clsx({"univer-border-red-500":e}),value:Number(r.value)||0,onChange:f=>n(f!=null?f:0)}),e&&s.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):s.jsx("div",{className:"univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:p,initValue:String(r.value),unitId:u,subUnitId:c,isFocus:o,onChange:(f="")=>{n(f||"")},onFocus:()=>v(!0)})})})},vt=(r,e,l)=>({operator:t.CFNumberOperator.greaterThan,value:{type:t.CFValueType.num,value:(l.length-1-e)*10},iconType:r,iconId:String(e)}),jt=m.forwardRef((r,e)=>{const{onClick:l}=r,n=j.useDependency(i.LocaleService),a=u=>{l(u)};return s.jsx("div",{ref:e,className:"univer-w-80",children:t.iconGroup.map((u,c)=>s.jsxs("div",{className:"univer-mb-3",children:[s.jsx("div",{className:"univer-mb-1 univer-text-sm",children:n.t(u.title)}),s.jsx("div",{className:"univer-flex univer-flex-wrap",children:u.group.map(p=>s.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{a(p.name)},children:s.jsx("a",{className:"univer-cursor-pointer univer-rounded hover:univer-bg-gray-100",children:p.list.map((o,v)=>s.jsx("img",{className:"univer-size-5",src:o,draggable:!1},v))})},p.name))})]},c))})}),At=r=>{const{onClick:e}=r,l=m.useMemo(()=>{const a=[];for(const u in t.iconMap){const c=t.iconMap[u],p=u;c.forEach((o,v)=>{a.push({iconType:p,base64:o,iconId:String(v)})})}return a},[]),n=a=>{e(a.iconType,a.iconId)};return s.jsxs("div",{children:[s.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>n({iconType:t.EMPTY_ICON_TYPE,iconId:""}),children:[s.jsx(he,{className:"univer-size-5"}),s.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),s.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:l.map(a=>s.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100",children:s.jsx("img",{className:"univer-size-5",src:a.base64,draggable:!1,onClick:()=>n(a)})},`${a.iconType}_${a.iconId}`))})]})},Lt=r=>{const{onChange:e,configList:l,errorMap:n={}}=r,a=j.useDependency(i.LocaleService),u=[{label:a.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThan}`),value:t.CFNumberOperator.greaterThan},{label:a.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThanOrEqual}`),value:t.CFNumberOperator.greaterThanOrEqual}],c=[{label:a.t(`sheet.cf.valueType.${t.CFValueType.num}`),value:t.CFValueType.num},{label:a.t(`sheet.cf.valueType.${t.CFValueType.percent}`),value:t.CFValueType.percent},{label:a.t(`sheet.cf.valueType.${t.CFValueType.percentile}`),value:t.CFValueType.percentile},{label:a.t(`sheet.cf.valueType.${t.CFValueType.formula}`),value:t.CFValueType.formula}],p=(f,h)=>{e([String(h),"value","value"],f)},o=(f,h)=>{e([String(h),"operator"],f);const S=t.createDefaultValue(t.CFSubRuleType.number,f);p(S,h)},v=(f,h)=>{e([String(h),"value","type"],f);const S=l[h],_=t.createDefaultValue(t.CFSubRuleType.number,S.operator);p(_,h)};return m.useMemo(()=>l.map((f,h)=>{const S=n[h],_=dt(f.iconType,f.iconId),b=h===l.length-1,E=h===0,N=l[h-1],R=(N==null?void 0:N.value.type)===t.CFValueType.formula?a.t("sheet.cf.valueType.formula"):N==null?void 0:N.value.value,w=(M,y)=>{const I={...f,iconId:y,iconType:M};e([String(h)],I)};return s.jsxs("div",{className:h?"univer-mt-6":"univer-mt-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:[s.jsxs("div",{className:"univer-w-[45%]",children:[a.t("sheet.cf.iconSet.icon"),h+1]}),s.jsx("div",{className:"univer-w-[45%]",children:s.jsxs(s.Fragment,{children:[!E&&!b&&a.t("sheet.cf.iconSet.rule"),!E&&!b&&s.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:univer-text-gray-200",children:["(",a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${t.getOppositeOperator(N.operator)}`),R,b?"":` ${a.t("sheet.cf.iconSet.and")} `,")"]})]})})]}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[s.jsx("div",{className:"univer-flex univer-items-center",children:s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(At,{onClick:w,iconId:f.iconId,iconType:f.iconType})}),children:s.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all dark:univer-text-gray-200 hover:univer-border-primary-600",O.borderClassName),children:[_?s.jsx("img",{src:_,className:"univer-size-4",draggable:!1}):s.jsx(he,{className:"univer-size-4"}),s.jsx(Me,{})]})})}),b?s.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:[a.t("sheet.cf.iconSet.rule"),s.jsxs("span",{className:"univer-font-medium",children:[a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${t.getOppositeOperator(N.operator)}`),R,b?"":` ${a.t("sheet.cf.iconSet.and")} `]})]}):s.jsx(O.Select,{options:u,value:f.operator,onChange:M=>{o(M,h)}})]}),b?s.jsx("div",{}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:[s.jsx("div",{children:a.t("sheet.cf.iconSet.type")}),s.jsx("div",{children:a.t("sheet.cf.iconSet.value")})]}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:c,value:f.value.type,onChange:M=>{v(M,h)}}),s.jsx("div",{children:s.jsx(Dt,{id:h,type:f.value.type,error:S,value:f.value.value||"",onChange:M=>{p(M,h)}})})]})]})]},h)}),[l,n])},Ft=r=>{var M;const{interceptorManager:e}=r,l=((M=r.rule)==null?void 0:M.type)===t.CFRuleType.iconSet?r.rule:void 0,n=j.useDependency(i.LocaleService),[a,u]=m.useState({}),[c,p]=m.useState(()=>{const y=Object.keys(t.iconMap)[0];if(l&&l.config.length){const I=l.config[0].iconType;if(!l.config.some(C=>C.iconType!==I))return I}return y}),[o,v]=m.useState(()=>{if(l&&l.config.length)return i.Tools.deepClone(l==null?void 0:l.config);const y=t.iconMap[c]||[];return new Array(y.length).fill("").map((I,T,C)=>T===C.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:c,iconId:String(T)}:vt(c,T,C))}),[d,f]=m.useState(()=>l?!!l.isShowValue:!0),h=m.useMemo(()=>{const y=o.map(I=>dt(I.iconType,I.iconId));return s.jsx("div",{className:"univer-flex univer-items-center",children:y.map((I,T)=>I?s.jsx("img",{className:"univer-size-5",src:I},T):s.jsx(he,{className:"univer-size-5"},T))})},[o]),S=y=>{if(y.reduce((T,C,U)=>T.preType&&!T.result||y.length-1===U?T:C.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:T.preType?{result:T.preType===C.value.type,preType:C.value.type}:{result:!0,preType:C.value.type},{result:!0,preType:""}).result&&[t.CFValueType.num,t.CFValueType.percent,t.CFValueType.percentile].includes(y[0].value.type)){const T={};return y.forEach((C,U,V)=>{if(U-1<0||U===V.length-1)return;const A=y[U-1],g=t.getOppositeOperator(A.operator);t.compareWithNumber({operator:g,value:A.value.value},C.value.value)||(T[U]=`${n.t(`sheet.cf.form.${g}`,String(A.value.value))} `)}),T}return{}},_=(y,I)=>{i.get(o,y)!==I&&(i.set(o,y,I),v([...o]),u(S(o)))},b=y=>{p(y);const I=t.iconMap[y]||[],T=new Array(I.length).fill("").map((C,U,V)=>vt(y,U,V));v(T),u(S(T))};m.useEffect(()=>{const y=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:t.CFRuleType.iconSet,isShowValue:d,config:o}}});return()=>{y()}},[d,o,e]),m.useEffect(()=>{const y=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(a).length===0}});return()=>{y()}},[d,o,e,a]);const E=()=>{const y=o.map(I=>({...I}));o.forEach((I,T)=>{const C=o.length-1-T,U=y[C];I.iconId=U.iconId,I.iconType=U.iconType}),v([...o])},N=j.useDependency(j.ILayoutService),[R,w]=m.useState();return j.useScrollYOverContainer(R,N.rootContainerElement),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:"univer-mt-3",children:s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(jt,{ref:y=>{!R&&y&&w(y)},iconType:c,onClick:b})}),children:s.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",O.borderClassName),children:[h,s.jsx(Me,{})]})})}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[s.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{onChange:E}),n.t("sheet.cf.iconSet.reverseIconOrder")]}),s.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:!d,onChange:y=>{f(!y)}}),n.t("sheet.cf.iconSet.onlyShowIcon")]})]}),s.jsx(Lt,{errorMap:a,onChange:_,configList:o})]})},$t=r=>{var E;const{onChange:e,interceptorManager:l}=r,n=j.useDependency(i.LocaleService),a=((E=r.rule)==null?void 0:E.type)===t.CFRuleType.highlightCell?r.rule:void 0,u=[{label:n.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:n.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:n.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:n.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[c,p]=m.useState(()=>{const N=u[0].value,R=a==null?void 0:a.type;if(!a)return N;switch(R){case t.CFRuleType.highlightCell:switch(a.subType){case t.CFSubRuleType.average:return[t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual].includes(a.operator)?"greaterThanAverage":[t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(a.operator)?"lessThanAverage":N;case t.CFSubRuleType.rank:return a.isBottom?"isBottom":"isNotBottom"}}return N}),[o,v]=m.useState(()=>{const R=a==null?void 0:a.type;if(!a)return 10;switch(R){case t.CFRuleType.highlightCell:switch(a.subType){case t.CFSubRuleType.rank:return a.value||10}}return 10}),[d,f]=m.useState(()=>{const R=a==null?void 0:a.type;if(!a)return!1;switch(R){case t.CFRuleType.highlightCell:switch(a.subType){case t.CFSubRuleType.rank:return a.isPercent||!1}}return!1}),[h,S]=m.useState({}),_=N=>{const{type:R,isPercent:w,value:M,style:y}=N;if(R==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:w,isBottom:!1,value:M,style:y};if(R==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:w,isBottom:!0,value:M,style:y};if(R==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:y};if(R==="lessThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.lessThan,style:y}};m.useEffect(()=>l.intercept(l.getInterceptPoints().submit,{handler(){return _({type:c,isPercent:d,value:o,style:h})}}),[c,d,o,h,l]);const b=N=>{e(_(N))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",value:c,options:u,onChange:N=>{p(N),b({type:N,isPercent:d,value:o,style:h})}}),["isNotBottom","isBottom"].includes(c)&&s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.InputNumber,{min:1,max:1e3,value:o,onChange:N=>{const R=N||0;v(R),b({type:c,isPercent:d,value:R,style:h})}}),s.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:d,onChange:N=>{f(!!N),b({type:c,isPercent:!!N,value:o,style:h})}}),n.t("sheet.cf.valueType.percent")]})]}),s.jsx("div",{className:ye,children:s.jsx(ue,{rule:_({type:c,isPercent:d,value:o,style:h})})}),s.jsx(Qe,{style:a==null?void 0:a.style,className:"univer-mt-3",onChange:N=>{S(N),b({type:c,isPercent:d,value:o,style:N})}})]})},Bt=i.createInterceptorKey("beforeSubmit"),Ht=i.createInterceptorKey("submit"),pt=r=>r.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),ft=r=>{var e;return(e=r.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},Wt=r=>{var T,C,U;const e=j.useDependency(i.LocaleService),l=j.useDependency(i.ICommandService),n=j.useDependency(i.IUniverInstanceService),a=j.useDependency(t.ConditionalFormattingRuleModel),u=j.useDependency(P.SheetsSelectionsService),c=pt(n),p=ft(n),[o,v]=m.useState(void 0),d=m.useRef((C=(T=r.rule)==null?void 0:T.ranges)!=null?C:[]),f=m.useMemo(()=>{var k,A,g;let V=(k=r.rule)==null?void 0:k.ranges;return V!=null&&V.length||(V=(g=(A=u.getCurrentSelections())==null?void 0:A.map(x=>x.range))!=null?g:[]),d.current=V,V!=null&&V.length?V.map(x=>{const F=Be.serializeRange(x);return F==="NaN"?"":F}).filter(x=>!!x).join(","):""},[r.rule]),h=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[S,_]=m.useState(()=>{var A,g;const V=(A=r.rule)==null?void 0:A.rule.type,k=h[0].value;if(!V)return k;switch(V){case t.CFRuleType.highlightCell:{switch((g=r.rule)==null?void 0:g.rule.subType){case t.CFSubRuleType.number:case t.CFSubRuleType.text:case t.CFSubRuleType.duplicateValues:case t.CFSubRuleType.uniqueValues:case t.CFSubRuleType.timePeriod:return"1";case t.CFSubRuleType.average:case t.CFSubRuleType.rank:return"2";case t.CFSubRuleType.formula:return"5"}break}case t.CFRuleType.dataBar:return"3";case t.CFRuleType.colorScale:return"4";case t.CFRuleType.iconSet:return"6"}return k}),b=m.useRef(void 0),E=m.useMemo(()=>new i.InterceptorManager({beforeSubmit:Bt,submit:Ht}),[]),N=m.useMemo(()=>{switch(S){case"1":return ot;case"2":return $t;case"3":return Ut;case"4":return Ot;case"5":return kt;case"6":return Ft;default:return ot}},[S]);m.useEffect(()=>{const V=l.onCommandExecuted(k=>{if(k.id===P.RemoveSheetMutation.id){const A=k.params;A.subUnitId===p&&A.unitId===c&&r.onCancel()}k.id===P.SetWorksheetActiveOperation.id&&r.onCancel()});return()=>V.dispose()},[]);const R=V=>{b.current=V},w=V=>{const k=V.split(",").filter(A=>!!A).map(Be.deserializeRangeWithSheet).map(A=>A.range);d.current=k},M=()=>{if(o)return;const k=(()=>{const g=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!g)throw new Error("No active sheet found");return d.current.map(G=>P.setEndForRange(G,g.getRowCount(),g.getColumnCount())).filter(G=>!(Number.isNaN(G.startRow)||Number.isNaN(G.startColumn)))})();if(E.fetchThroughInterceptors(E.getInterceptPoints().beforeSubmit)(!0,null)){const g=E.fetchThroughInterceptors(E.getInterceptPoints().submit)(null,null);if(g){const x=pt(n),F=ft(n);if(!x||!F)throw new Error("No active sheet found");let G={};r.rule&&r.rule.cfId?(G={...r.rule,ranges:k,rule:g},l.executeCommand(t.SetCfCommand.id,{unitId:x,subUnitId:F,rule:G}),r.onCancel()):(G={cfId:a.createCfId(x,F),ranges:k,rule:g,stopIfTrue:!1},l.executeCommand(t.AddCfCommand.id,{unitId:x,subUnitId:F,rule:G}),r.onCancel())}}},y=()=>{r.onCancel()},I=(V,k)=>{V?k.length<1?v(e.t("sheet.cf.errorMessage.rangeError")):v(void 0):v(e.t("sheet.cf.errorMessage.rangeError"))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),s.jsxs("div",{className:"univer-mt-4",children:[s.jsx(pe.RangeSelector,{unitId:c,subUnitId:p,initialValue:f,onChange:(V,k)=>w(k),onVerify:I}),o&&s.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:o})]}),s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),s.jsx(O.Select,{className:"univer-mt-4 univer-w-full",value:S,options:h,onChange:V=>_(V)}),s.jsx(N,{interceptorManager:E,rule:(U=r.rule)==null?void 0:U.rule,onChange:R}),s.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[s.jsx(O.Button,{onClick:y,children:e.t("sheet.cf.panel.cancel")}),s.jsx(O.Button,{className:"univer-ml-3",variant:"primary",onClick:M,children:e.t("sheet.cf.panel.submit")})]})]})};var qt=Object.getOwnPropertyDescriptor,Gt=(r,e,l,n)=>{for(var a=n>1?void 0:n?qt(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},zt=(r,e)=>(l,n)=>e(l,n,r);let se=class extends i.Disposable{constructor(e){super();ee(this,"_initLocal",()=>{});ee(this,"_findReplaceIndex",e=>{const l=/\{([^}]+)?\}/g,n=[];let a=l.exec(e);for(;a;)n.push({startIndex:a.index,key:Number(a[1]),endIndex:a.index+a[0].length-1}),a=l.exec(e);return n});this._localeService=e,this._initLocal()}tWithReactNode(e,...l){const n=this._localeService.getLocales(),a=e.split("."),u=n&&this._localeService.resolveKeyPath(n,a);if(typeof u=="string"){const c=[];return this._findReplaceIndex(u).forEach((p,o,v)=>{const d=v[o-1]||{endIndex:-1};if(d.endIndex+1<p.startIndex){const f=u.slice(d.endIndex+1,p.startIndex);f&&c.push(f)}if(l[p.key]&&c.push(l[p.key]),o===v.length-1){const f=u.slice(p.endIndex+1);f&&c.push(f)}}),c}return[]}};se=Gt([zt(0,i.Inject(i.LocaleService))],se);const Yt=(r,e)=>{const l=r.rule;switch(l.type){case t.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case t.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case t.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case t.CFRuleType.highlightCell:switch(l.subType){case t.CFSubRuleType.average:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`,e.t("sheet.cf.subRuleType.average"))}case t.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case t.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case t.CFSubRuleType.number:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`,...Array.isArray(l.value)?l.value.map(a=>String(a)):[String(l.value||"")])}case t.CFSubRuleType.text:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`,l.value||"")}case t.CFSubRuleType.timePeriod:{const n=l.operator;return e.t(`sheet.cf.preview.describe.${n}`)}case t.CFSubRuleType.rank:return l.isPercent?l.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(l.value)):e.t("sheet.cf.preview.describe.topNPercent",String(l.value)):l.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(l.value)):e.t("sheet.cf.preview.describe.topN",String(l.value));case t.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let ht=0;const Zt=r=>{const{onClick:e}=r,l=j.useDependency(t.ConditionalFormattingRuleModel),n=j.useDependency(i.IUniverInstanceService),a=j.useDependency(P.SheetsSelectionsService),u=j.useDependency(i.ICommandService),c=j.useDependency(i.LocaleService),p=j.useDependency(i.Injector),o=j.useDependency(j.ISidebarService),v=j.useDependency(se),d=j.useObservable(()=>n.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),f=d.getUnitId(),h=d.getActiveSheet();if(!h)throw new Error("No active sheet found");const S=h.getSheetId(),[_,b]=m.useState([]),[E,N]=m.useState("2"),[R,w]=m.useState(0),[M,y]=m.useState(-1),[I,T]=m.useState(ht),C=m.useRef(null),U=[{label:c.t("sheet.cf.panel.workSheet"),value:"2"},{label:c.t("sheet.cf.panel.selectedRange"),value:"1"}],V=()=>{const L=l.getSubunitRules(f,S);if(!L||!L.length)return[];if(E==="1"){const $=a.getCurrentLastSelection();if(!$)return[];const H=$.range;return L.filter(z=>z.ranges.some(Y=>i.Rectangle.intersects(Y,H)))}else if(E==="2")return[...L];return[]},[k,A]=m.useState(V);W.useHighlightRange(_),m.useEffect(()=>{const L=u.onCommandExecuted($=>{$.id===P.SetWorksheetActiveOperation.id&&w(Math.random())});return()=>L.dispose()}),m.useEffect(()=>{A(V)},[E,R,f,S]),m.useEffect(()=>{if(E==="2")return;const L=new X.Observable($=>{const H=[P.SetSelectionsOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],q=u.onCommandExecuted(z=>{const{id:Y,params:ne}=z,ae=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();H.includes(Y)&&ne.unitId===ae&&$.next(null)});return()=>q.dispose()}).pipe(X.debounceTime(16)).subscribe(()=>{A(V)});return()=>{L.unsubscribe()}},[n,E,f,S]),m.useEffect(()=>{const L=l.$ruleChange.subscribe(()=>{w(Math.random())});return()=>L.unsubscribe()},[l]),m.useEffect(()=>{const L=()=>{var z,Y;const q=Math.max(0,((Y=(z=C.current)==null?void 0:z.getBoundingClientRect().width)!=null?Y:0)-8);return ht=q,q},H=new X.Observable(q=>{const z=o.getContainer();if(z){let Y=setTimeout(()=>{q.next(void 0)},150);const ne=()=>{Y&&clearTimeout(Y),Y=null},ae=$e=>{$e.propertyName==="width"&&(ne(),q.next(void 0))};return z.addEventListener("transitionend",ae),()=>{ne(),z.removeEventListener("transitionend",ae)}}}).pipe(X.debounceTime(16)).subscribe(()=>{T(L())});return()=>{H.unsubscribe()}},[]);const g=L=>{var q;const $=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),H=(q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:q.getSheetId();if(!$||!H)throw new Error("No active sheet found");u.executeCommand(t.DeleteCfCommand.id,{unitId:$,subUnitId:H,cfId:L.cfId})},x=(L,$)=>{y($.y)},F=(L,$,H)=>{var $e;y(-1);const q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),z=($e=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:$e.getSheetId();if(!q||!z)throw new Error("No active sheet found");const Y=wr=>{const Vr=k.length;return Math.min(Vr-1,Math.max(0,wr))},ne=k[Y($.y)].cfId,ae=k[Y(H.y)].cfId;ne!==ae&&u.executeCommand(t.MoveCfCommand.id,{unitId:q,subUnitId:z,start:{id:ne,type:"self"},end:{id:ae,type:H.y>$.y?"after":"before"}})},G=()=>{r.onCreate()},J=()=>{E==="2"?u.executeCommand(t.ClearWorksheetCfCommand.id):E==="1"&&k.map($=>({unitId:f,subUnitId:S,cfId:$.cfId})).forEach($=>{u.executeCommand(t.DeleteCfCommand.id,$)})},Q=m.useMemo(()=>{const L=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),$=L.getActiveSheet();return k.filter(H=>{const q=H.ranges;return P.checkRangesEditablePermission(p,L.getUnitId(),$.getSheetId(),q)})},[k]),de=Q.map((L,$)=>({i:L.cfId,x:0,w:12,y:$,h:1,isResizable:!1})),ve=m.useMemo(()=>{const L=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),$=L.getActiveSheet();return k.every(H=>{const q=H.ranges;return P.checkRangesEditablePermission(p,L.getUnitId(),$.getSheetId(),q)})},[k]);return s.jsxs("div",{children:[s.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[s.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:v.tWithReactNode("sheet.cf.panel.managerRuleSelect",s.jsx(O.Select,{className:"univer-w-36",options:U,value:E,onChange:L=>{N(L)}})).map((L,$)=>s.jsx("span",{children:L},$))}),s.jsxs("div",{className:"univer-flex univer-justify-end",children:[s.jsx(O.Tooltip,{title:c.t("sheet.cf.panel.createRule"),placement:"bottom",children:s.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:G,children:s.jsx(ut,{})})}),k.length&&ve?s.jsx(O.Tooltip,{title:c.t("sheet.cf.panel.clear"),placement:"bottom",children:s.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:J,children:s.jsx(Re,{className:"univer-text-red-500"})})}):s.jsx("div",{children:s.jsx(Re,{className:"univer-text-gray-300"})})]})]}),s.jsx("div",{ref:C,children:I>0&&s.jsx(O.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:de,cols:12,rowHeight:60,width:I,margin:[0,10],onDragStop:F,onDragStart:x,children:Q==null?void 0:Q.map((L,$)=>s.jsx("div",{children:s.jsxs("div",{className:O.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100",{"univer-bg-gray-100":M===$}),onMouseMove:()=>{L.ranges!==_&&b(L.ranges)},onMouseLeave:()=>b([]),onClick:()=>{e(L)},children:[s.jsx("div",{className:O.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:H=>H.stopPropagation(),children:s.jsx(it,{})}),s.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:univer-text-white",children:Yt(L,c)}),s.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:L.ranges.map(H=>Be.serializeRange(H)).join(",")})]}),s.jsx("div",{children:s.jsx(ue,{rule:L.rule})}),s.jsx("div",{className:O.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":M===$}),onClick:H=>{H.stopPropagation(),g(L),b([])},children:s.jsx(Re,{})})]})},`${L.cfId}`))})})]})},Kt=r=>{const[e,l]=m.useState(r.rule),[n,a]=m.useState(!!r.rule),u=()=>{a(!0)},c=()=>{a(!1),l(void 0)},p=o=>{l(o),a(!0)};return s.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between",children:n?s.jsx(Wt,{onCancel:c,rule:e}):s.jsx(Zt,{onClick:p,onCreate:u})})};var Xt=Object.getOwnPropertyDescriptor,Jt=(r,e,l,n)=>{for(var a=n>1?void 0:n?Xt(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},ge=(r,e)=>(l,n)=>e(l,n,r);const Ue="sheet.conditional.formatting.panel";let me=class extends i.Disposable{constructor(e,l,n,a,u){super();ee(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=l,this._componentManager=n,this._sidebarService=a,this._localeService=u,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(c=>{var p;c||(p=this._sidebarDisposable)==null||p.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(c=>{c.id===Ue&&(c.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const l={id:Ue,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ue,rule:e,key:i.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(l)}_initPanel(){this._componentManager.register(Ue,Kt)}};me=Jt([ge(0,i.IUniverInstanceService),ge(1,i.Inject(i.Injector)),ge(2,i.Inject(j.ComponentManager)),ge(3,i.Inject(j.ISidebarService)),ge(4,i.Inject(i.LocaleService))],me);var Z=(r=>(r[r.createRule=1]="createRule",r[r.viewRule=2]="viewRule",r[r.highlightCell=3]="highlightCell",r[r.rank=4]="rank",r[r.formula=5]="formula",r[r.colorScale=6]="colorScale",r[r.dataBar=7]="dataBar",r[r.icon=8]="icon",r[r.clearRangeRules=9]="clearRangeRules",r[r.clearWorkSheetRules=10]="clearWorkSheetRules",r))(Z||{});const Se={id:"sheet.operation.open.conditional.formatting.panel",type:i.CommandType.OPERATION,handler:(r,e)=>{var p;const l=r.get(me),n=r.get(P.SheetsSelectionsService),a=r.get(i.ICommandService),u=((p=n.getCurrentSelections())==null?void 0:p.map(o=>o.range))||[];switch(e.value){case 3:{l.openPanel({...t.createDefaultRule(),ranges:u});break}case 4:{const o={...t.createDefaultRule,ranges:u,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank}};l.openPanel(o);break}case 5:{const o={...t.createDefaultRule,ranges:u,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula,value:"="}};l.openPanel(o);break}case 6:{const o={...t.createDefaultRule,ranges:u,rule:{type:t.CFRuleType.colorScale,config:[]}};l.openPanel(o);break}case 7:{const o={...t.createDefaultRule,ranges:u,rule:{type:t.CFRuleType.dataBar,isShowValue:!0}};l.openPanel(o);break}case 8:{const o={...t.createDefaultRule,ranges:u,rule:{type:t.CFRuleType.iconSet,config:[],isShowValue:!0}};l.openPanel(o);break}case 2:{l.openPanel();break}case 1:{l.openPanel({...t.createDefaultRule(),ranges:u});break}case 9:{a.executeCommand(t.ClearRangeCfCommand.id,{ranges:u});break}case 10:{a.executeCommand(t.ClearWorksheetCfCommand.id);break}}return!0}};var Qt=Object.getOwnPropertyDescriptor,er=(r,e,l,n)=>{for(var a=n>1?void 0:n?Qt(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},be=(r,e)=>(l,n)=>e(l,n,r);let Ie=class extends i.Disposable{constructor(e,l,n,a,u){super();ee(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=l,this._injector=n,this._conditionalFormattingViewModel=a,this._univerInstanceService=u,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,l,n)=>this._collectConditionalRule(e,l,n),onPasteCells:(e,l,n,a)=>{const{copyType:u=W.COPY_TYPE.COPY,pasteType:c}=a,{range:p}=e||{},{range:o}=l;return this._generateConditionalFormattingMutations(o,{copyType:u,pasteType:c,copyRange:p})}}))}_collectConditionalRule(e,l,n){const a=new i.ObjectMatrix,u={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:l,cfMap:u}};const c=this._injector.invoke(d=>P.rangeToDiscreteRange(n,d,e,l));if(!c)return;const{rows:p,cols:o}=c,v=new Set;p.forEach((d,f)=>{o.forEach((h,S)=>{const _=this._conditionalFormattingViewModel.getCellCfs(e,l,d,h);_&&(_.forEach(b=>v.add(b.cfId)),a.setValue(f,S,_.map(b=>b.cfId)))})}),v.forEach(d=>{const f=this._conditionalFormattingRuleModel.getRule(e,l,d);f&&(u[d]=f.rule)})}_generateConditionalFormattingMutations(e,l){const n=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),a=n.getActiveSheet(),u=n.getUnitId();if(!a)return{redos:[],undos:[]};const c=a.getSheetId();if(l.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!l.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(l.pasteType))return{redos:[],undos:[]};const{ranges:[o,v],mapFunc:d}=W.virtualizeDiscreteRanges([l.copyRange,e]),f=W.getRepeatRange(o,v,!0),h={};i.Range.foreach(v,(y,I)=>{const{row:T,col:C}=d(y,I),U=this._conditionalFormattingViewModel.getCellCfs(u,c,T,C);U&&U.forEach(V=>{if(!h[V.cfId]){const k=new i.ObjectMatrix;h[V.cfId]=k;const A=this._conditionalFormattingRuleModel.getRule(u,c,V.cfId);A==null||A.ranges.forEach(g=>{i.Range.foreach(g,(x,F)=>{k.setValue(x,F,1)})})}h[V.cfId].realDeleteValue(T,C)})});const{matrix:S,info:_}=this._copyInfo,b=[];let E=this._conditionalFormattingRuleModel.createCfId(u,c);const N={},R=y=>{if(N[y])return N[y];const I=_==null?void 0:_.cfMap[y],T=[...this._conditionalFormattingRuleModel.getSubunitRules(u,c)||[],...b].find(C=>i.Tools.diffValue(C.rule,I));if(T)return N[y]=T,T;{const C={rule:I,cfId:E,ranges:[],stopIfTrue:!1};return N[y]=C,b.push(C),E=`${Number(E)+1}`,C}};f.forEach(y=>{S&&S.forValue((I,T,C)=>{const U=i.Rectangle.getPositionRange({startRow:I,endRow:I,startColumn:T,endColumn:T},y.startRange),{row:V,col:k}=d(U.startRow,U.startColumn);C.forEach(A=>{if(!h[A]){const g=R(A),x=new i.ObjectMatrix;h[A]=x,g.ranges.forEach(F=>{i.Range.foreach(F,(G,J)=>{x.setValue(G,J,1)})})}h[A].setValue(V,k,1)})})});const w=[],M=[];for(const y in h){const I=h[y],T=P.findAllRectangle(P.createTopMatrixFromMatrix(I));if(!T.length){const C={unitId:u,subUnitId:c,cfId:y};w.push({id:t.DeleteConditionalRuleMutation.id,params:C}),M.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,C))}if(b.some(C=>C.cfId===y)){const C=R(y),U={unitId:u,subUnitId:c,rule:{...C,ranges:T}};w.push({id:t.AddConditionalRuleMutation.id,params:U}),M.push(t.AddConditionalRuleMutationUndoFactory(this._injector,U))}else{const C=this._conditionalFormattingRuleModel.getRule(u,c,y);if(!C)continue;const U={unitId:u,subUnitId:c,rule:{...C,ranges:T}};w.push({id:t.SetConditionalRuleMutation.id,params:U}),M.push(...t.setConditionalRuleMutationUndoFactory(this._injector,U))}}return{redos:w,undos:M}}};Ie=er([be(0,i.Inject(W.ISheetClipboardService)),be(1,i.Inject(t.ConditionalFormattingRuleModel)),be(2,i.Inject(i.Injector)),be(3,i.Inject(t.ConditionalFormattingViewModel)),be(4,i.Inject(i.IUniverInstanceService))],Ie);var tr=Object.getOwnPropertyDescriptor,rr=(r,e,l,n)=>{for(var a=n>1?void 0:n?tr(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},et=(r,e)=>(l,n)=>e(l,n,r);let Ce=class extends i.Disposable{constructor(r,e,l){super(),this._localeService=r,this._commandService=e,this._sheetPermissionCheckController=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(r=>{r.id===t.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[P.WorkbookEditablePermission],rangeTypes:[P.RangeProtectionPermissionEditPoint],worksheetTypes:[P.WorksheetEditPermission,P.WorksheetSetCellStylePermission]},r.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Ce=rr([et(0,i.Inject(i.LocaleService)),et(1,i.ICommandService),et(2,i.Inject(P.SheetPermissionCheckController))],Ce);var nr=Object.getOwnPropertyDescriptor,ar=(r,e,l,n)=>{for(var a=n>1?void 0:n?nr(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},ke=(r,e)=>(l,n)=>e(l,n,r);let Te=class extends i.Disposable{constructor(r,e,l,n){super(),this._conditionalFormattingRuleModel=r,this._univerInstanceService=e,this._injector=l,this._refRangeService=n,this._initRefRange()}_initRefRange(){const r=new Map,e=(n,a,u)=>`${n}_${a}_${u}`,l=(n,a,u)=>{const c=o=>{const v=[...u.ranges],d=v.map(h=>P.handleDefaultRangeChangeWithEffectRefCommands(h,o)).filter(h=>!!h);if(t.isRangesEqual(d,v))return{redos:[],undos:[]};if(d.length){const h={unitId:n,subUnitId:a,rule:{...u,ranges:d}},S=[{id:t.SetConditionalRuleMutation.id,params:h}],_=t.setConditionalRuleMutationUndoFactory(this._injector,h);return{redos:S,undos:_}}else{const h={unitId:n,subUnitId:a,cfId:u.cfId},S=[{id:t.DeleteConditionalRuleMutation.id,params:h}],_=t.DeleteConditionalRuleMutationUndoFactory(this._injector,h);return{redos:S,undos:_}}},p=[];u.ranges.forEach(o=>{const v=this._refRangeService.registerRefRange(o,c);p.push(()=>v.dispose())}),r.set(e(n,a,u.cfId),()=>p.forEach(o=>o()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(n=>{const{unitId:a,subUnitId:u,rule:c}=n,p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!(n.unitId!==p.getUnitId()||n.subUnitId!==(o==null?void 0:o.getSheetId())))switch(n.type){case"add":{l(n.unitId,n.subUnitId,n.rule);break}case"delete":{const v=r.get(e(a,u,c.cfId));v&&v();break}case"set":{const v=r.get(e(a,u,c.cfId));v&&v(),l(n.unitId,n.subUnitId,n.rule)}}})),this.disposeWithMe(i.toDisposable(()=>{r.forEach(n=>{n()}),r.clear()}))}};Te=ar([ke(0,i.Inject(t.ConditionalFormattingRuleModel)),ke(1,i.Inject(i.IUniverInstanceService)),ke(2,i.Inject(i.Injector)),ke(3,i.Inject(P.RefRangeService))],Te);var lr=Object.getOwnPropertyDescriptor,ur=(r,e,l,n)=>{for(var a=n>1?void 0:n?lr(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},ce=(r,e)=>(l,n)=>e(l,n,r);let _e=class extends i.Disposable{constructor(e,l,n,a,u,c){super();ee(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=l,this._univerInstanceService=n,this._renderManagerService=a,this._conditionalFormattingViewModel=u,this._conditionalFormattingRuleModel=c,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var l,n,a;const e=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();(l=this._renderManagerService.getRenderById(e))==null||l.with(W.SheetSkeletonManagerService).reCalculate(),(a=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||a.makeDirty()}_initSkeleton(){this.disposeWithMe(X.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(fe.bufferTime(16),fe.filter(e=>!!e.length),fe.filter(e=>{const l=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!l)return!1;const n=l.getActiveSheet();return n?e.filter(a=>a.unitId===l.getUnitId()&&a.subUnitId===n.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(P.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,handler:(e,l,n)=>{const a=this._conditionalFormattingService.composeStyle(l.unitId,l.subUnitId,l.row,l.col);if(!a)return n(e);const u=l.workbook.getStyles(),p={...(typeof(e==null?void 0:e.s)=="string"?u.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}},o={...e,s:p};return a.style&&Object.assign(p,a.style),o.fontRenderExtension||(o.fontRenderExtension={},a.isShowValue!==void 0&&(o.fontRenderExtension.isSkip=!a.isShowValue)),a.dataBar&&(o.dataBar=a.dataBar),a.iconSet&&(o.iconSet=a.iconSet,o.fontRenderExtension.leftOffset=t.DEFAULT_PADDING+t.DEFAULT_WIDTH),n(o)},priority:10}))}};_e=ur([ce(0,i.Inject(P.SheetInterceptorService)),ce(1,i.Inject(t.ConditionalFormattingService)),ce(2,i.Inject(i.IUniverInstanceService)),ce(3,i.Inject(at.IRenderManagerService)),ce(4,i.Inject(t.ConditionalFormattingViewModel)),ce(5,i.Inject(t.ConditionalFormattingRuleModel))],_e);const yt="sheets-conditional-formatting-ui.config",Pe={};var ir=Object.defineProperty,sr=Object.getOwnPropertyDescriptor,cr=(r,e,l)=>e in r?ir(r,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):r[e]=l,or=(r,e,l,n)=>{for(var a=n>1?void 0:n?sr(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},tt=(r,e)=>(l,n)=>e(l,n,r),gt=(r,e,l)=>cr(r,typeof e!="symbol"?e+"":e,l);D.UniverSheetsConditionalFormattingMobileUIPlugin=class extends i.Plugin{constructor(e=Pe,l,n,a){super(),this._config=e,this._injector=l,this._commandService=n,this._configService=a;const{menu:u,...c}=i.merge({},Pe,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(yt,c),this._initCommand(),this._injector.add([_e]),this._injector.add([Te]),this._injector.add([Ie]),this._injector.add([Ce]),this._injector.add([se])}_initCommand(){[He,We,qe,Ge,ze,Ye,Ze,Ke,Xe,Se].forEach(e=>{this._commandService.registerCommand(e)})}},gt(D.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),gt(D.UniverSheetsConditionalFormattingMobileUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingMobileUIPlugin=or([i.DependentOn(t.UniverSheetsConditionalFormattingPlugin),tt(1,i.Inject(i.Injector)),tt(2,i.Inject(i.ICommandService)),tt(3,i.IConfigService)],D.UniverSheetsConditionalFormattingMobileUIPlugin);var dr=Object.getOwnPropertyDescriptor,vr=(r,e,l,n)=>{for(var a=n>1?void 0:n?dr(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},xe=(r,e)=>(l,n)=>e(l,n,r);let De=class extends i.Disposable{constructor(r,e,l,n,a){super(),this._injector=r,this._univerInstanceService=e,this._autoFillService=l,this._conditionalFormattingRuleModel=n,this._conditionalFormattingViewModel=a,this._initAutoFill()}_initAutoFill(){const r=()=>({redos:[],undos:[]}),e=(a,u,c,p,o)=>{var S;const v=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(S=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId();if(!v||!d)return;const f={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},h={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};i.Range.foreach(c,(_,b)=>{const E=i.Rectangle.getPositionRange({startRow:_,startColumn:b,endColumn:b,endRow:_},f),N=i.Rectangle.getPositionRange({startRow:_,startColumn:b,endColumn:b,endRow:_},h),{row:R,col:w}=o(E.startRow,E.startColumn),M=this._conditionalFormattingViewModel.getCellCfs(v,d,R,w),{row:y,col:I}=o(N.startRow,N.startColumn),T=this._conditionalFormattingViewModel.getCellCfs(v,d,y,I);T&&T.forEach(C=>{let U=p.get(C.cfId);if(!p.get(C.cfId)){const V=this._conditionalFormattingRuleModel.getRule(v,d,C.cfId);if(!V)return;U=new i.ObjectMatrix,V.ranges.forEach(k=>{i.Range.foreach(k,(A,g)=>{U.setValue(A,g,1)})}),p.set(C.cfId,U)}U.realDeleteValue(y,I)}),M&&M.forEach(C=>{let U=p.get(C.cfId);if(!p.get(C.cfId)){const V=this._conditionalFormattingRuleModel.getRule(v,d,C.cfId);if(!V)return;U=new i.ObjectMatrix,V.ranges.forEach(k=>{i.Range.foreach(k,(A,g)=>{U.setValue(A,g,1)})}),p.set(C.cfId,U)}U.setValue(y,I,1)})})},l=(a,u)=>{var N,R,w;const c=(N=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:N.getUnitId(),p=(w=(R=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:R.getActiveSheet())==null?void 0:w.getSheetId(),o=new Map,v=[],d=[];if(!c||!p)return r();const f=W.virtualizeDiscreteRanges([a,u]),[h,S]=f.ranges,{mapFunc:_}=f,b={row:h.startRow,col:h.startColumn};return W.getAutoFillRepeatRange(h,S).forEach(M=>{e(b,M.repeatStartCell,M.relativeRange,o,_)}),o.forEach((M,y)=>{const I=this._conditionalFormattingRuleModel.getRule(c,p,y);if(!I)return;const T=P.findAllRectangle(P.createTopMatrixFromMatrix(M));if(T.length){const C={unitId:c,subUnitId:p,rule:{...I,ranges:T}};v.push({id:t.SetConditionalRuleMutation.id,params:C}),d.push(...t.setConditionalRuleMutationUndoFactory(this._injector,C))}else{const C={unitId:c,subUnitId:p,cfId:I.cfId};v.push({id:t.DeleteConditionalRuleMutation.id,params:C}),d.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,C))}}),{undos:d,redos:v}},n={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(a,u,c)=>{if(c===W.APPLY_TYPE.COPY||c===W.APPLY_TYPE.ONLY_FORMAT||c===W.APPLY_TYPE.SERIES){const{source:p,target:o}=a;return l(p,o)}return r()}};this.disposeWithMe(this._autoFillService.addHook(n))}};De=vr([xe(0,i.Inject(i.Injector)),xe(1,i.Inject(i.IUniverInstanceService)),xe(2,i.Inject(W.IAutoFillService)),xe(3,i.Inject(t.ConditionalFormattingRuleModel)),xe(4,i.Inject(t.ConditionalFormattingViewModel))],De);var pr=Object.getOwnPropertyDescriptor,fr=(r,e,l,n)=>{for(var a=n>1?void 0:n?pr(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},Ne=(r,e)=>(l,n)=>e(l,n,r);D.ConditionalFormattingClearController=class extends i.Disposable{constructor(e,l,n,a,u){super(),this._injector=e,this._univerInstanceService=l,this._sheetInterceptorService=n,this._selectionManagerService=a,this._conditionalFormattingRuleModel=u,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var u;const l=[],n=[],a={redos:l,undos:n};if([P.ClearSelectionFormatCommand.id,P.ClearSelectionAllCommand.id].includes(e.id)){const c=(u=this._selectionManagerService.getCurrentSelections())==null?void 0:u.map(_=>_.range);if(!c)return a;const p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!o)return a;const v=p.getUnitId(),d=o.getSheetId(),f=this._conditionalFormattingRuleModel.getSubunitRules(v,d);if(!f||!f.length)return a;const{redos:h,undos:S}=mt(this._injector,f,c,v,d);l.push(...h),n.push(...S)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:l,ranges:n})=>{const a=[],u=[],c={redos:a,undos:u};if(!n||!n.length)return c;const p=this._conditionalFormattingRuleModel.getSubunitRules(e,l);if(!p||!p.length)return c;const{redos:o,undos:v}=mt(this._injector,p,n,e,l);return a.push(...o),u.push(...v),c}}))}},D.ConditionalFormattingClearController=fr([Ne(0,i.Inject(i.Injector)),Ne(1,i.Inject(i.IUniverInstanceService)),Ne(2,i.Inject(P.SheetInterceptorService)),Ne(3,i.Inject(P.SheetsSelectionsService)),Ne(4,i.Inject(t.ConditionalFormattingRuleModel))],D.ConditionalFormattingClearController);function mt(r,e,l,n,a){const u=[],c=[];return e.filter(p=>l.some(o=>p.ranges.some(v=>i.Rectangle.getIntersects(v,o)))).forEach(p=>{const v=new P.RangeMergeUtil().add(...p.ranges).subtract(...l).merge();if(v.length){const d={id:t.SetConditionalRuleMutation.id,params:{unitId:n,subUnitId:a,rule:{...p,ranges:v}}},f=t.setConditionalRuleMutationUndoFactory(r,d.params);u.push(d),c.push(...f)}else{const d={id:t.DeleteConditionalRuleMutation.id,params:{unitId:n,subUnitId:a,cfId:p.cfId}},f=t.DeleteConditionalRuleMutationUndoFactory(r,d.params);u.push(d),c.push(...f)}}),{redos:u,undos:c}}var hr=Object.getOwnPropertyDescriptor,yr=(r,e,l,n)=>{for(var a=n>1?void 0:n?hr(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},St=(r,e)=>(l,n)=>e(l,n,r);let je=class extends i.Disposable{constructor(r,e){super(),this._sheetInterceptorService=r,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(i.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(P.AFTER_CELL_EDIT,{handler:(r,e,l)=>{var c,p,o;r||l(r);const n=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),a=(c=n==null?void 0:n.style)!=null?c:{},u=Object.keys(a);if(r!=null&&r.p)return(o=(p=r.p.body)==null?void 0:p.textRuns)==null||o.forEach(v=>{v.ts&&u.forEach(d=>{var f;(f=v.ts)==null||delete f[d]})}),l(r);{const v={...(typeof(r==null?void 0:r.s)=="string"?e.workbook.getStyles().get(r.s):r==null?void 0:r.s)||{}};u.forEach(f=>{delete v[f]});const d={...r,s:{...v}};return l(d)}}})))}};je=yr([St(0,i.Inject(P.SheetInterceptorService)),St(1,i.Inject(t.ConditionalFormattingService))],je);const bt=[P.SetWorksheetActiveOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],Ee=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:Z.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:Z.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:Z.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:Z.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:Z.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:Z.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:Z.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:Z.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:Z.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:Z.clearWorkSheetRules}],gr=r=>{const e=r.get(P.SheetsSelectionsService),l=r.get(i.ICommandService),n=r.get(i.IUniverInstanceService),a=r.get(t.ConditionalFormattingRuleModel),u=new X.Observable(o=>X.merge(e.selectionMoveEnd$,e.selectionSet$,new X.Observable(v=>{const d=l.onCommandExecuted(f=>{var b;const{id:h,params:S}=f,_=(b=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:b.getUnitId();bt.includes(h)&&S.unitId===_&&v.next(null)});return()=>d.dispose()})).pipe(fe.debounceTime(16)).subscribe(()=>{var b;const v=((b=e.getCurrentSelections())==null?void 0:b.map(E=>E.range))||[],d=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!d)return;const f=d.getActiveSheet();if(!f)return;const _=(a.getSubunitRules(d.getUnitId(),f.getSheetId())||[]).filter(E=>E.ranges.some(N=>v.some(R=>i.Rectangle.intersects(R,N)))).map(E=>E.ranges).every(E=>P.checkRangesEditablePermission(r,d.getUnitId(),f.getSheetId(),E));o.next(_)})),c=new X.Observable(o=>new X.Observable(v=>{const d=l.onCommandExecuted(f=>{var b;const{id:h,params:S}=f,_=(b=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:b.getUnitId();bt.includes(h)&&S.unitId===_&&v.next(null)});return()=>d.dispose()}).pipe(fe.debounceTime(16)).subscribe(()=>{const v=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!v)return;const d=v.getActiveSheet();if(!d)return;const f=a.getSubunitRules(v.getUnitId(),d.getSheetId())||[];if(!f.length)return o.next(!1),!1;const h=f.map(S=>S.ranges).every(S=>P.checkRangesEditablePermission(r,v.getUnitId(),d.getSheetId(),S));o.next(h)})),p=new X.Observable(o=>{u.subscribe(v=>{const d=Ee.find(f=>f.value===Z.clearRangeRules);d&&(d.disabled=!v,o.next(Ee))}),c.subscribe(v=>{const d=Ee.find(f=>f.value===Z.clearWorkSheetRules);d&&(d.disabled=!v,o.next(Ee))}),o.next(Ee)});return{id:Se.id,type:j.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:p,hidden$:j.getMenuHiddenObservable(r,i.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(r,{workbookTypes:[P.WorkbookEditablePermission],worksheetTypes:[P.WorksheetSetCellStylePermission,P.WorksheetEditPermission],rangeTypes:[P.RangeProtectionPermissionEditPoint]})}},mr={[j.RibbonStartGroup.FORMULAS_INSERT]:{[Se.id]:{order:0,menuItemFactory:gr}}};var Sr=Object.getOwnPropertyDescriptor,br=(r,e,l,n)=>{for(var a=n>1?void 0:n?Sr(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},It=(r,e)=>(l,n)=>e(l,n,r);let Ae=class extends i.Disposable{constructor(e,l){super();ee(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=l,this._menuManagerService.mergeMenu(mr)}};Ae=br([It(0,i.Inject(i.Injector)),It(1,j.IMenuManagerService)],Ae);var Ir=Object.getOwnPropertyDescriptor,Cr=(r,e,l,n)=>{for(var a=n>1?void 0:n?Ir(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},oe=(r,e)=>(l,n)=>e(l,n,r);const Tr=(r,e)=>{const l=d=>d.endRow-d.startRow+1,n=d=>d.endColumn-d.startColumn+1,a=l(e)%l(r),u=n(e)%n(r),c=Math.floor(l(e)/l(r)),p=Math.floor(n(e)/n(r)),o=[],v={startRow:0,endRow:l(r)-1,startColumn:0,endColumn:n(r)-1};if(l(e)===1&&n(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return o.push({repeatRelativeRange:v,startRange:d}),o}for(let d=0;d<c+(a?.1:0);d++)for(let f=0;f<p+(u?.1:0);f++){const h=l(r)*d,S=n(r)*f,_={startRow:h+e.startRow,endRow:h+e.startRow,startColumn:S+e.startColumn,endColumn:S+e.startColumn};let b=v;d===c&&a&&(b={...b},b.endRow=b.endRow-(l(r)-a)),f===p&&u&&(b={...b},b.endColumn=b.endColumn-(n(r)-u)),o.push({repeatRelativeRange:b,startRange:_})}return o};let Le=class extends i.Disposable{constructor(e,l,n,a,u,c){super();ee(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=l,this._formatPainterService=n,this._sheetsSelectionsService=a,this._conditionalFormattingRuleModel=u,this._conditionalFormattingViewModel=c,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),l=(u,c,p,o,v)=>{const{unitId:d,subUnitId:f}=this._painterConfig,{targetUnitId:h,targetSubUnitId:S}=v,_={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row},b={startRow:c.row,startColumn:c.col,endColumn:c.col,endRow:c.row};i.Range.foreach(p,(E,N)=>{const R=i.Rectangle.getPositionRange({startRow:E,startColumn:N,endColumn:N,endRow:E},_),w=i.Rectangle.getPositionRange({startRow:E,startColumn:N,endColumn:N,endRow:E},b),M=this._conditionalFormattingViewModel.getCellCfs(d,f,R.startRow,R.startColumn),y=this._conditionalFormattingViewModel.getCellCfs(h,S,w.startRow,w.startColumn);y&&y.forEach(I=>{let T=o.get(I.cfId);if(!o.get(I.cfId)){const C=this._conditionalFormattingRuleModel.getRule(h,S,I.cfId);if(!C)return;T=new i.ObjectMatrix,C.ranges.forEach(U=>{i.Range.foreach(U,(V,k)=>{T.setValue(V,k,1)})}),o.set(I.cfId,T)}T.realDeleteValue(w.startRow,w.startColumn)}),M&&M.forEach(I=>{const T=o.get(I.cfId);T&&T.setValue(w.startRow,w.startColumn,1)})})},n=(u,c,p)=>{var R;const{range:o,unitId:v,subUnitId:d}=this._painterConfig,f=u!==v||d!==c,h=new Map,S=[],_=[];if(!u||!c||!v||!d)return e();const b=(R=this._conditionalFormattingRuleModel.getSubunitRules(v,d))!=null?R:[];b==null||b.forEach(w=>{const{ranges:M,cfId:y}=w;if(M.some(I=>i.Rectangle.intersects(o,I))){const I=new i.ObjectMatrix;f||M.forEach(T=>{i.Range.foreach(T,(C,U)=>{I.setValue(C,U,1)})}),h.set(y,I)}});const E={row:o.startRow,col:o.startColumn};return Tr(o,p).forEach(w=>{l(E,{row:w.startRange.startRow,col:w.startRange.startColumn},w.repeatRelativeRange,h,{targetUnitId:u,targetSubUnitId:c})}),h.forEach((w,M)=>{if(f){const y=this._conditionalFormattingRuleModel.getRule(u,c,M),I=P.findAllRectangle(P.createTopMatrixFromMatrix(w));if(y)if(I.length){const T={unitId:u,subUnitId:c,rule:{...y,ranges:I}};S.push({id:t.SetConditionalRuleMutation.id,params:T}),_.push(...t.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:u,subUnitId:c,cfId:y.cfId};S.push({id:t.DeleteConditionalRuleMutation.id,params:T}),_.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}else if(I.length){const T=this._conditionalFormattingRuleModel.getRule(v,d,M);if(T){const C={unitId:u,subUnitId:c,rule:{...i.Tools.deepClone(T),cfId:this._conditionalFormattingRuleModel.createCfId(u,c),ranges:I}};S.push({id:t.AddConditionalRuleMutation.id,params:C}),_.push(t.AddConditionalRuleMutationUndoFactory(this._injector,C))}}}else{const y=this._conditionalFormattingRuleModel.getRule(v,d,M);if(!y)return;const I=P.findAllRectangle(P.createTopMatrixFromMatrix(w));if(I.length){const T={unitId:v,subUnitId:d,rule:{...y,ranges:I}};S.push({id:t.SetConditionalRuleMutation.id,params:T}),_.push(...t.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:v,subUnitId:d,cfId:y.cfId};S.push({id:t.DeleteConditionalRuleMutation.id,params:T}),_.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}}}),{undos:_,redos:S}},a={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:u=>{var c,p,o;switch(u){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const v=(c=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:c.getUnitId(),d=(o=(p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getActiveSheet())==null?void 0:o.getSheetId(),f=this._sheetsSelectionsService.getCurrentLastSelection(),h=f==null?void 0:f.range;v&&d&&h&&(this._painterConfig={unitId:v,subUnitId:d,range:h});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(u,c,p)=>this._painterConfig?n(u,c,p):{redos:[],undos:[]}};this._formatPainterService.addHook(a)}};Le=Cr([oe(0,i.Inject(i.Injector)),oe(1,i.Inject(i.IUniverInstanceService)),oe(2,i.Inject(W.IFormatPainterService)),oe(3,i.Inject(P.SheetsSelectionsService)),oe(4,i.Inject(t.ConditionalFormattingRuleModel)),oe(5,i.Inject(t.ConditionalFormattingViewModel))],Le);var _r=Object.getOwnPropertyDescriptor,xr=(r,e,l,n)=>{for(var a=n>1?void 0:n?_r(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},rt=(r,e)=>(l,n)=>e(l,n,r);let Fe=class extends i.Disposable{constructor(r,e,l){super(),this._conditionalFormattingViewModel=r,this._univerInstanceService=e,this._renderManagerService=l,this._init()}_init(){const r=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),e=l=>{const n=l.getUnitId(),a=this._renderManagerService.getRenderById(n);if(!a)return;const u=a.with(W.SheetSkeletonManagerService);this.disposeWithMe(u.currentSkeleton$.subscribe(c=>{if(c){const p=c.skeleton.rowColumnSegment,o=p.endColumn-p.startColumn+1,d=(p.endRow-p.startRow+1)*o*9,f=Math.max(t.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(f)}}))};r&&e(r),this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(l=>{l&&e(l)})}};Fe=xr([rt(0,i.Inject(t.ConditionalFormattingViewModel)),rt(1,i.IUniverInstanceService),rt(2,at.IRenderManagerService)],Fe);var Nr=Object.defineProperty,Er=Object.getOwnPropertyDescriptor,Rr=(r,e,l)=>e in r?Nr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):r[e]=l,Mr=(r,e,l,n)=>{for(var a=n>1?void 0:n?Er(e,l):e,u=r.length-1,c;u>=0;u--)(c=r[u])&&(a=c(a)||a);return a},nt=(r,e)=>(l,n)=>e(l,n,r),Ct=(r,e,l)=>Rr(r,typeof e!="symbol"?e+"":e,l);D.UniverSheetsConditionalFormattingUIPlugin=class extends i.Plugin{constructor(e=Pe,l,n,a){super(),this._config=e,this._injector=l,this._commandService=n,this._configService=a;const{menu:u,...c}=i.merge({},Pe,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(yt,c),this._initCommand()}onStarting(){i.registerDependencies(this._injector,[[_e],[Te],[Ie],[De],[Ce],[me],[Ae],[se],[je],[D.ConditionalFormattingClearController],[Le],[Fe]]),i.touchDependencies(this._injector,[[_e]])}onReady(){i.touchDependencies(this._injector,[[Ae],[me]])}onRendered(){i.touchDependencies(this._injector,[[De],[D.ConditionalFormattingClearController],[Ie],[je],[se],[Le],[Ce],[Te],[Fe]])}_initCommand(){[He,We,qe,Ge,ze,Ye,Ze,Ke,Xe,Se].forEach(e=>{this._commandService.registerCommand(e)})}},Ct(D.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Ct(D.UniverSheetsConditionalFormattingUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingUIPlugin=Mr([i.DependentOn(t.UniverSheetsConditionalFormattingPlugin),nt(1,i.Inject(i.Injector)),nt(2,i.Inject(i.ICommandService)),nt(3,i.IConfigService)],D.UniverSheetsConditionalFormattingUIPlugin),D.AddAverageCfCommand=He,D.AddColorScaleConditionalRuleCommand=We,D.AddDataBarConditionalRuleCommand=qe,D.AddDuplicateValuesCfCommand=Ge,D.AddNumberCfCommand=ze,D.AddRankCfCommand=Ye,D.AddTextCfCommand=Ze,D.AddTimePeriodCfCommand=Ke,D.AddUniqueValuesCfCommand=Xe,D.OpenConditionalFormattingOperator=Se,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
10
+ (function(D,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","rxjs","@univerjs/engine-render","rxjs/operators"],i):(D=typeof globalThis<"u"?globalThis:D||self,i(D.UniverSheetsConditionalFormattingUi={},D.UniverCore,D.UniverSheetsConditionalFormatting,D.UniverSheets,D.UniverUi,D.React,D.React,D.UniverDesign,D.UniverEngineFormula,D.UniverSheetsFormulaUi,D.UniverSheetsUi,D.rxjs,D.UniverEngineRender,D.rxjs.operators))})(this,function(D,i,r,P,j,s,S,O,Be,pe,W,X,ar,fe){"use strict";var Ot=Object.defineProperty;var Ut=(D,i,r)=>i in D?Ot(D,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):D[i]=r;var ee=(D,i,r)=>Ut(D,typeof i!="symbol"?i+"":i,r);const He={type:i.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:a,operator:l}=e,c=t.get(r.ConditionalFormattingRuleModel),p=t.get(i.ICommandService),o=t.get(i.IUniverInstanceService),f=P.getSheetCommandTarget(o);if(!f)return!1;const{unitId:d,subUnitId:v}=f,g=c.createCfId(d,v),b={ranges:u,cfId:g,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:l,style:n}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:v,rule:b})}},We={type:i.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,config:n,stopIfTrue:a}=e,l=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.ICommandService),p=t.get(i.IUniverInstanceService),o=P.getSheetCommandTarget(p);if(!o)return!1;const{unitId:f,subUnitId:d}=o,v=l.createCfId(f,d),g={ranges:u,cfId:v,stopIfTrue:!!a,rule:{type:r.CFRuleType.colorScale,config:n}};return c.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:d,rule:g})}},qe={type:i.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,min:n,max:a,nativeColor:l,positiveColor:c,isGradient:p,stopIfTrue:o,isShowValue:f}=e,d=t.get(r.ConditionalFormattingRuleModel),v=t.get(i.IUniverInstanceService),g=P.getSheetCommandTarget(v);if(!g)return!1;const{unitId:b,subUnitId:T}=g,m=t.get(i.ICommandService),E=d.createCfId(b,T),N={ranges:u,cfId:E,stopIfTrue:!!o,rule:{type:r.CFRuleType.dataBar,isShowValue:f,config:{min:n,max:a,nativeColor:l,positiveColor:c,isGradient:p}}};return m.executeCommand(r.AddConditionalRuleMutation.id,{unitId:b,subUnitId:T,rule:N})}},Ge={type:i.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:a}=e,l=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.ICommandService),p=t.get(i.IUniverInstanceService),o=P.getSheetCommandTarget(p);if(!o)return!1;const{unitId:f,subUnitId:d}=o,v=l.createCfId(f,d),g={ranges:u,cfId:v,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:n}};return c.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:d,rule:g})}},ze={type:i.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:a,operator:l,value:c}=e,p=t.get(r.ConditionalFormattingRuleModel),o=t.get(i.ICommandService),f=t.get(i.IUniverInstanceService),d=P.getSheetCommandTarget(f);if(!d)return!1;const{unitId:v,subUnitId:g}=d,b=p.createCfId(v,g);let T;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(l)){const m=c;if(m.length!==2||!Array.isArray(m))return!1;T={ranges:u,cfId:b,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:l,style:n,value:m}}}else{const m=c;if(typeof m!="number")return!1;T={ranges:u,cfId:b,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:l,style:n,value:m}}}return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:g,rule:T})}},Ye={type:i.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:a,isPercent:l,isBottom:c,value:p}=e,o=t.get(r.ConditionalFormattingRuleModel),f=t.get(i.IUniverInstanceService),d=t.get(i.ICommandService),v=P.getSheetCommandTarget(f);if(!v)return!1;const{unitId:g,subUnitId:b}=v,T=o.createCfId(g,b),m={ranges:u,cfId:T,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:l,isBottom:c,style:n,value:p}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:g,subUnitId:b,rule:m})}},Ze={type:i.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:a,operator:l,value:c}=e,p=t.get(r.ConditionalFormattingRuleModel),o=t.get(i.IUniverInstanceService),f=P.getSheetCommandTarget(o);if(!f)return!1;const{unitId:d,subUnitId:v}=f,g=t.get(i.ICommandService),b=p.createCfId(d,v),T={ranges:u,cfId:b,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:l,style:n,value:c}};return g.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:v,rule:T})}},Ke={type:i.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:a,operator:l}=e,c=t.get(r.ConditionalFormattingRuleModel),p=t.get(i.IUniverInstanceService),o=t.get(i.ICommandService),f=P.getSheetCommandTarget(p);if(!f)return!1;const{unitId:d,subUnitId:v}=f,g=c.createCfId(d,v),b={ranges:u,cfId:g,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:l,style:n}};return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:v,rule:b})}},Xe={type:i.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(t,e){if(!e)return!1;const{ranges:u,style:n,stopIfTrue:a}=e,l=t.get(r.ConditionalFormattingRuleModel),c=t.get(i.IUniverInstanceService),p=t.get(i.ICommandService),o=P.getSheetCommandTarget(c);if(!o)return!1;const{unitId:f,subUnitId:d}=o,v=l.createCfId(f,d),g={ranges:u,cfId:v,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:n}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:d,rule:g})}};var K=function(){return K=Object.assign||function(t){for(var e,u=1,n=arguments.length;u<n;u++){e=arguments[u];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},K.apply(this,arguments)},Tr=function(t,e){var u={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(u[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a<n.length;a++)e.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(t,n[a])&&(u[n[a]]=t[n[a]]);return u},ue=S.forwardRef(function(t,e){var u=t.icon,n=t.id,a=t.className,l=t.extend,c=Tr(t,["icon","id","className","extend"]),p="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),o=S.useRef("_".concat(Nr()));return ur(u,"".concat(n),{defIds:u.defIds,idSuffix:o.current},K({ref:e,className:p},c),l)});function ur(t,e,u,n,a){return S.createElement(t.tag,K(K({key:e},_r(t,u,a)),n),(xr(t,u).children||[]).map(function(l,c){return ur(l,"".concat(e,"-").concat(t.tag,"-").concat(c),u,void 0,a)}))}function _r(t,e,u){var n=K({},t.attrs);u!=null&&u.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=u.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(l){var c=l[0],p=l[1];c==="mask"&&typeof p=="string"&&(n[c]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var a=e.defIds;return!a||a.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(l){var c=l[0],p=l[1];typeof p=="string"&&(n[c]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function xr(t,e){var u,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((u=t.children)===null||u===void 0)&&u.length)?K(K({},t),{children:t.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.indexOf(a.attrs.id)>-1?K(K({},a),{attrs:K(K({},a.attrs),{id:a.attrs.id+e.idSuffix})}):a})}):t}function Nr(){return Math.random().toString(36).substring(2,8)}ue.displayName="UniverIcon";var Er={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Me=S.forwardRef(function(t,e){return S.createElement(ue,Object.assign({},t,{id:"delete-single",ref:e,icon:Er}))});Me.displayName="DeleteSingle";var Mr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},lr=S.forwardRef(function(t,e){return S.createElement(ue,Object.assign({},t,{id:"increase-single",ref:e,icon:Mr}))});lr.displayName="IncreaseSingle";var Rr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Re=S.forwardRef(function(t,e){return S.createElement(ue,Object.assign({},t,{id:"more-down-single",ref:e,icon:Rr}))});Re.displayName="MoreDownSingle";var wr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},ir=S.forwardRef(function(t,e){return S.createElement(ue,Object.assign({},t,{id:"sequence-single",ref:e,icon:wr}))});ir.displayName="SequenceSingle";var Vr={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_436_41",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.35 0.48H16.35V16.48H0.35z"}}]},{tag:"g",attrs:{mask:"url(#mask0_436_41)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z"}},{tag:"path",attrs:{fill:"#E5E5E5",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z"}}]}]},he=S.forwardRef(function(t,e){return S.createElement(ue,Object.assign({},t,{id:"slash-single",ref:e,icon:Vr}))});he.displayName="SlashSingle";const re=t=>{const{color:e,onChange:u,disable:n=!1,iconId:a="PaintBucket",className:l,isNeedDropdownIcon:c=!0}=t,p=j.useDependency(j.ComponentManager),o=S.useMemo(()=>new i.ColorKit(e),[e]),f=p.get(a);return f?n?s.jsx(f,{className:O.clsx("univer-fill-primary-600",l),extend:{colorChannel1:o.isValid?e:""}}):s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(O.ColorPicker,{value:e,onChange:u})}),children:s.jsxs("span",{className:O.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",l),children:[s.jsx(f,{className:"univer-fill-primary-600",extend:{colorChannel1:o.isValid?e:""}}),c&&s.jsx(Re,{className:"univer-ml-1.5 univer-text-gray-400"})]})}):null},le=t=>{var l,c,p,o,f;const e=t.rule;if(!e)return null;const u=S.useMemo(()=>{if(e.type===r.CFRuleType.colorScale){const d=e.config.map((b,T)=>({color:new i.ColorKit(b.color),value:T})),v=d.length-1;return new Array(5).fill("").map((b,T,m)=>T*v/(m.length-1)).map(b=>r.getColorScaleFromValue(d,b))}return null},[e]),n=S.useMemo(()=>{if(e.type===r.CFRuleType.iconSet)return e.config.map(d=>{const v=r.iconMap[d.iconType];return v&&v[Number(d.iconId)]})},[e]),a="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case r.CFRuleType.dataBar:{const{isGradient:d}=e.config,v=d?`linear-gradient(to right, ${e.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,g=d?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||r.defaultDataBarNativeColor})`:e.config.nativeColor;return s.jsxs("div",{className:a,children:[s.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:g,borderColor:(l=e.config.nativeColor)!=null?l:r.defaultDataBarNativeColor}}),s.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:v,borderColor:(c=e.config.positiveColor)!=null?c:r.defaultDataBarPositiveColor}})]})}case r.CFRuleType.colorScale:return u&&s.jsx("div",{className:a,children:u.map((d,v)=>s.jsx("div",{className:"univer-h-full",style:{width:`${100/u.length}%`,background:d}},v))});case r.CFRuleType.iconSet:return n&&s.jsx("div",{className:a,children:n.map((d,v)=>d?s.jsx("img",{className:"univer-h-full",src:d,draggable:!1},v):s.jsx(he,{},v))});case r.CFRuleType.highlightCell:{const{ul:d,st:v,it:g,bl:b,bg:T,cl:m}=e.style,E=(d==null?void 0:d.s)===i.BooleanNumber.TRUE,N=(v==null?void 0:v.s)===i.BooleanNumber.TRUE,M=g===i.BooleanNumber.TRUE,w=b===i.BooleanNumber.TRUE,R=(p=T==null?void 0:T.rgb)!=null?p:r.DEFAULT_BG_COLOR,h=(o=m==null?void 0:m.rgb)!=null?o:r.DEFAULT_FONT_COLOR,I={textDecoration:(f=`${E?"underline":""} ${N?"line-through":""}`.replace(/^ /,""))!=null?f:void 0,backgroundColor:R,color:h};return s.jsx("div",{className:O.clsx(a,{"univer-font-bold":w,"univer-italic":M}),style:I,children:"123"})}}},ge=O.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",O.borderClassName),te=(t,e)=>({label:e.t(`sheet.cf.valueType.${t}`),value:t}),Je=t=>{var T;const{type:e,className:u,onChange:n,id:a,value:l}=t,c=j.useDependency(i.IUniverInstanceService),p=c.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(T=c.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:T.getSheetId(),f=S.useMemo(()=>String(l).startsWith("=")?String(l):"=",[l]),d=S.useMemo(()=>[r.CFValueType.max,r.CFValueType.min,"none"].includes(e)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),v=S.useRef(null),[g,b]=S.useState(!1);return j.useSidebarClick(m=>{var N;((N=v.current)==null?void 0:N.isClickOutSide(m))&&b(!1)}),e===r.CFValueType.formula?s.jsx("div",{className:"univer-ml-1 univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:v,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",O.borderClassName),initValue:f,unitId:p,subUnitId:o,isFocus:g,onChange:(m="")=>{n(m||"")},onFocus:()=>b(!0)})}):s.jsx(O.InputNumber,{className:u,value:Number(t.value)||0,onChange:m=>t.onChange(m||0),...d})},Or=t=>{var L;const{interceptorManager:e}=t,u=j.useDependency(i.LocaleService),n=((L=t.rule)==null?void 0:L.type)===r.CFRuleType.colorScale?t.rule:void 0,a=[te(r.CFValueType.num,u),te(r.CFValueType.percent,u),te(r.CFValueType.percentile,u),te(r.CFValueType.formula,u)],l=[te(r.CFValueType.min,u),...a],c=[te("none",u),...a],p=[te(r.CFValueType.max,u),...a],[o,f]=S.useState(()=>{var x;const y=r.CFValueType.min;return n&&((x=n.config[0])==null?void 0:x.value.type)||y}),[d,v]=S.useState(()=>{var x;const y="none";return!n||n.config.length!==3?y:((x=n.config[1])==null?void 0:x.value.type)||y}),[g,b]=S.useState(()=>{var x;const y=r.CFValueType.max;return n&&((x=n.config[n.config.length-1])==null?void 0:x.value.type)||y}),[T,m]=S.useState(()=>{if(!n)return 10;const x=n.config[0];return(x==null?void 0:x.value.value)===void 0?10:x==null?void 0:x.value.value}),[E,N]=S.useState(()=>{var F;if(!n||n.config.length!==3)return 50;const x=(F=n.config[1])==null?void 0:F.value.value;return x===void 0?50:x}),[M,w]=S.useState(()=>{var F;if(!n)return 90;const x=(F=n.config[n.config.length-1])==null?void 0:F.value.value;return x===void 0?90:x}),[R,h]=S.useState(()=>{var x;const y="#d0d9fb";return n&&((x=n.config[0])==null?void 0:x.color)||y}),[I,_]=S.useState(()=>{var x;const y="#7790f3";return!n||n.config.length!==3?y:((x=n.config[1])==null?void 0:x.color)||y}),[C,U]=S.useState(()=>{var x;const y="#2e55ef";return n&&((x=n.config[n.config.length-1])==null?void 0:x.color)||y}),V=S.useMemo(()=>y=>{const{minType:x,medianType:F,maxType:G,minValue:J,medianValue:Q,maxValue:de,minColor:ve,medianColor:A,maxColor:$}=y,H=[];return H.push({color:ve,value:{type:x,value:J}}),F!=="none"&&H.push({color:A,value:{type:F,value:Q}}),H.push({color:$,value:{type:G,value:de}}),{config:H.map((z,Y)=>({...z,index:Y})),type:r.CFRuleType.colorScale}},[]);S.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return V({minType:o,medianType:d,maxType:g,minValue:T,medianValue:E,maxValue:M,minColor:R,medianColor:I,maxColor:C})}}),[V,o,d,g,T,E,M,R,I,C,e]);const k=y=>{t.onChange(V(y))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:u.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:ge,children:s.jsx(le,{rule:V({minType:o,medianType:d,maxType:g,minValue:T,medianValue:E,maxValue:M,minColor:R,medianColor:I,maxColor:C})})}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:u.t("sheet.cf.valueType.min")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:l,value:o,onChange:y=>{f(y);const x=r.createDefaultValueByValueType(y,10);m(x),k({minType:y,medianType:d,maxType:g,minValue:x,medianValue:E,maxValue:M,minColor:R,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"min",className:"univer-ml-1",value:T,type:o,onChange:y=>{m(y),k({minType:o,medianType:d,maxType:g,minValue:y,medianValue:E,maxValue:M,minColor:R,medianColor:I,maxColor:C})}}),s.jsx(re,{className:"univer-ml-1",color:R,onChange:y=>{h(y),k({minType:o,medianType:d,maxType:g,minValue:T,medianValue:E,maxValue:M,minColor:y,medianColor:I,maxColor:C})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600dark:!univer-text-gray-200",children:u.t("sheet.cf.panel.medianValue")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:c,value:d,onChange:y=>{v(y);const x=r.createDefaultValueByValueType(y,50);N(x),k({minType:o,medianType:y,maxType:g,minValue:T,medianValue:x,maxValue:M,minColor:R,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"median",className:"univer-ml-1",value:E,type:d,onChange:y=>{N(y),k({minType:o,medianType:d,maxType:g,minValue:T,medianValue:y,maxValue:M,minColor:R,medianColor:I,maxColor:C})}}),d!=="none"&&s.jsx(re,{className:"univer-ml-1",color:I,onChange:y=>{_(y),k({minType:o,medianType:d,maxType:g,minValue:T,medianValue:E,maxValue:M,minColor:R,medianColor:y,maxColor:C})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:u.t("sheet.cf.valueType.max")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:p,value:g,onChange:y=>{b(y);const x=r.createDefaultValueByValueType(y,90);w(x),k({minType:o,medianType:d,maxType:y,minValue:T,medianValue:E,maxValue:x,minColor:R,medianColor:I,maxColor:C})}}),s.jsx(Je,{id:"max",className:"univer-ml-1",value:M,type:g,onChange:y=>{w(y),k({minType:o,medianType:d,maxType:g,minValue:T,medianValue:E,maxValue:y,minColor:R,medianColor:I,maxColor:C})}}),s.jsx(re,{className:"univer-ml-1",color:C,onChange:y=>{U(y),k({minType:o,medianType:d,maxType:g,minValue:T,medianValue:E,maxValue:M,minColor:R,medianColor:I,maxColor:y})}})]})]})},ie=(t,e)=>({label:e.t(`sheet.cf.valueType.${t}`),value:t}),sr=t=>{var m;const{onChange:e,className:u,value:n,type:a,id:l,disabled:c=!1}=t,p=j.useDependency(i.IUniverInstanceService),o=p.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),f=(m=p.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:m.getSheetId(),d=S.useRef(null),[v,g]=S.useState(!1);j.useSidebarClick(E=>{var M;((M=d.current)==null?void 0:M.isClickOutSide(E))&&g(!1)});const b=S.useRef(n),T=S.useMemo(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(a)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[a]);if(a===r.CFValueType.formula){const E=String(b.current).startsWith("=")?String(b.current)||"":"=";return s.jsx("div",{className:"univer-ml-3 univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:d,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",O.borderClassName),initValue:E,unitId:o,subUnitId:f,isFocus:v,onChange:(N="")=>{e(N||"")},onFocus:()=>g(!0)})})}return s.jsx(O.InputNumber,{className:u,value:Number(n)||0,disabled:c,onChange:E=>{e(E||0)},...T})},Ur=t=>{var L;const{interceptorManager:e}=t,u=j.useDependency(i.LocaleService),n=((L=t.rule)==null?void 0:L.type)===r.CFRuleType.dataBar?t.rule:void 0,[a,l]=S.useState(()=>{var x;const y="0";return n?(x=n.config)!=null&&x.isGradient?"1":"0":y}),[c,p]=S.useState(()=>{var y;return n&&((y=n.config)==null?void 0:y.positiveColor)||r.defaultDataBarPositiveColor}),[o,f]=S.useState(()=>{var y;return n&&((y=n.config)==null?void 0:y.nativeColor)||r.defaultDataBarNativeColor}),d=[ie(r.CFValueType.num,u),ie(r.CFValueType.percent,u),ie(r.CFValueType.percentile,u),ie(r.CFValueType.formula,u)],v=[ie(r.CFValueType.min,u),...d],g=[ie(r.CFValueType.max,u),...d],[b,T]=S.useState(()=>{var x;const y=v[0].value;return n&&((x=n.config)==null?void 0:x.min.type)||y}),[m,E]=S.useState(()=>{var x;const y=g[0].value;return n&&((x=n.config)==null?void 0:x.max.type)||y}),[N,M]=S.useState(()=>{var F;if(!n)return 0;const x=((F=n.config)==null?void 0:F.min)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value||0}),[w,R]=S.useState(()=>{var F;if(!n)return 100;const x=((F=n.config)==null?void 0:F.max)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value===void 0?100:x.value}),[h,I]=S.useState(()=>n?n.isShowValue===void 0?!0:!!n.isShowValue:!0),_=y=>({config:{min:{type:y.minValueType,value:y.minValue},max:{type:y.maxValueType,value:y.maxValue},isGradient:y.isGradient==="1",positiveColor:y.positiveColor||r.defaultDataBarPositiveColor,nativeColor:y.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:y.isShowValue});S.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return _({isGradient:a,minValue:N,minValueType:b,maxValue:w,maxValueType:m,positiveColor:c,nativeColor:o,isShowValue:h})}}),[a,N,b,w,m,c,o,e,h]);const C=y=>{t.onChange(_(y))},U=y=>{p(y),C({isGradient:a,minValue:N,minValueType:b,maxValue:w,maxValueType:m,positiveColor:y,nativeColor:o,isShowValue:h})},V=y=>{f(y),C({isGradient:a,minValue:N,minValueType:b,maxValue:w,maxValueType:m,positiveColor:c,nativeColor:y,isShowValue:h})},k=y=>d.map(x=>x.value).includes(y);return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:u.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:ge,children:s.jsx(le,{rule:_({isGradient:a,minValue:N,minValueType:b,maxValue:w,maxValueType:m,positiveColor:c,nativeColor:o,isShowValue:h})})}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:u.t("sheet.cf.panel.fillType")}),s.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[s.jsxs(O.RadioGroup,{value:a,onChange:y=>{l(y),C({isGradient:y,minValue:N,minValueType:b,maxValue:w,maxValueType:m,positiveColor:c,nativeColor:o,isShowValue:h})},children:[s.jsx(O.Radio,{value:"0",children:s.jsx("span",{className:"univer-text-xs",children:u.t("sheet.cf.panel.pureColor")})}),s.jsx(O.Radio,{value:"1",children:s.jsx("span",{className:"univer-text-xs",children:u.t("sheet.cf.panel.gradient")})})]}),s.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:!h,onChange:y=>{I(!y),C({isGradient:y,minValue:N,minValueType:b,maxValue:w,maxValueType:m,positiveColor:c,nativeColor:o,isShowValue:!y})}}),u.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:u.t("sheet.cf.panel.colorSet")}),s.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[s.jsxs("div",{className:"univer-flex univer-items-center",children:[s.jsx("div",{className:"univer-text-xs",children:u.t("sheet.cf.panel.native")}),s.jsx(re,{color:o,onChange:V})]}),s.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[s.jsx("div",{className:"univer-text-xs",children:u.t("sheet.cf.panel.positive")}),s.jsx(re,{color:c,onChange:U})]})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:u.t("sheet.cf.valueType.min")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:v,value:b,onChange:y=>{T(y);const x=r.createDefaultValueByValueType(y,10);M(x),C({isGradient:a,minValue:x,minValueType:y,maxValue:w,maxValueType:m,positiveColor:c,nativeColor:o,isShowValue:h})}}),s.jsx(sr,{id:"min",className:"univer-ml-3",disabled:!k(b),type:b,value:N,onChange:y=>{M(y||0),C({isGradient:a,minValue:y||0,minValueType:b,maxValue:w,maxValueType:m,positiveColor:c,nativeColor:o,isShowValue:h})}})]}),s.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:u.t("sheet.cf.valueType.max")}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:g,value:m,onChange:y=>{E(y);const x=r.createDefaultValueByValueType(y,90);R(x),C({isGradient:a,minValue:N,minValueType:b,maxValue:x,maxValueType:y,positiveColor:c,nativeColor:o,isShowValue:h})}}),s.jsx(sr,{className:"univer-ml-3",disabled:!k(m),id:"max",type:m,value:w,onChange:y=>{R(y||0),C({isGradient:a,minValue:N,minValueType:b,maxValue:y||0,maxValueType:m,positiveColor:c,nativeColor:o,isShowValue:h})}})]})]})]})},we=t=>[i.BooleanNumber.FALSE,void 0].includes(t)?i.BooleanNumber.TRUE:i.BooleanNumber.FALSE,Ve=t=>t!==i.BooleanNumber.FALSE,Qe=t=>{const{style:e,onChange:u,className:n}=t,a=j.useDependency(j.ComponentManager),[l,c]=S.useState(()=>{if(e!=null&&e.bl)return e.bl}),[p,o]=S.useState(()=>{if(e!=null&&e.it)return e.it}),[f,d]=S.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[v,g]=S.useState(()=>{if(e!=null&&e.st)return e.st.s}),[b,T]=S.useState(()=>{var _;const I="#2f56ef";return(_=e==null?void 0:e.cl)!=null&&_.rgb?e.cl.rgb:I}),[m,E]=S.useState(()=>{var _;const I="#e8ecfc";return(_=e==null?void 0:e.bg)!=null&&_.rgb?e.bg.rgb:I}),N=a.get("BoldSingle"),M=a.get("ItalicSingle"),w=a.get("UnderlineSingle"),R=a.get("StrikethroughSingle");S.useEffect(()=>{const I={bl:l,it:p};b!==void 0&&(I.cl={rgb:b}),m!==void 0&&(I.bg={rgb:m}),v!==void 0&&(I.st={s:v}),f!==void 0&&(I.ul={s:f}),u(r.removeUndefinedAttr(I))},[l,p,f,v,b,m]);const h="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return s.jsxs("div",{className:O.clsx("univer-my-2.5 univer-flex univer-justify-between",n),children:[N&&s.jsx("div",{className:O.clsx(h,{"univer-bg-gray-100":Ve(l||i.BooleanNumber.FALSE)}),onClick:()=>c(we(l)),children:s.jsx(N,{})}),M&&s.jsx("div",{className:O.clsx(h,{"univer-bg-gray-100":Ve(p||i.BooleanNumber.FALSE)}),onClick:()=>o(we(p)),children:s.jsx(M,{})}),w&&s.jsx("div",{className:O.clsx(h,{"univer-bg-gray-100":Ve(f||i.BooleanNumber.FALSE)}),onClick:()=>d(we(f)),children:s.jsx(w,{})}),R&&s.jsx("div",{className:O.clsx(h,{"univer-bg-gray-100":Ve(v||i.BooleanNumber.FALSE)}),onClick:()=>g(we(v)),children:s.jsx(R,{})}),s.jsx(re,{color:b,onChange:T,iconId:"FontColor"}),s.jsx(re,{color:m,onChange:E,iconId:"PaintBucket"})]})},kr=t=>{var R;const{onChange:e,interceptorManager:u}=t,n=j.useDependency(i.LocaleService),l=j.useDependency(i.IUniverInstanceService).getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),c=l.getActiveSheet(),p=((R=t.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?t.rule:void 0,o=S.useRef(null),[f,d]=S.useState(!1),v=S.useRef(null),[g,b]=S.useState({}),[T,m]=S.useState(()=>(p==null?void 0:p.subType)===r.CFSubRuleType.formula?p.value:"="),[E,N]=S.useState(void 0),M=h=>({style:h.style,value:T,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});S.useEffect(()=>u.intercept(u.getInterceptPoints().submit,{handler(){return M({style:g})}}),[g,T,u]),S.useEffect(()=>u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(I,_,C)=>E||T.length===1||!T.startsWith("=")?(N(n.t("sheet.cf.errorMessage.formulaError")),!1):C(I)}),[E,T]);const w=h=>{e(M(h))};return j.useSidebarClick(h=>{var _;((_=v.current)==null?void 0:_.isClickOutSide(h))&&d(!1)}),s.jsxs("div",{ref:o,children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:"univer-mt-3",children:s.jsx(pe.FormulaEditor,{ref:v,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",O.borderClassName),errorText:E,isFocus:f,initValue:T,unitId:l.getUnitId(),subUnitId:c==null?void 0:c.getSheetId(),onFocus:()=>{d(!0)},onChange:h=>{m(h),w({style:g})},onVerify:(h,I)=>{!h||I.length===1?N(n.t("sheet.cf.errorMessage.formulaError")):N(void 0)}})}),s.jsx("div",{className:ge,children:s.jsx(le,{rule:M({style:g})})}),s.jsx(Qe,{style:p==null?void 0:p.style,className:"univer-mt-3",onChange:h=>{b(h),w({style:h})}})]})},Oe=t=>s.jsxs("div",{className:"univer-relative",children:[s.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:t.errorText}),t.children]}),B=(t,e)=>({label:e.t(`sheet.cf.operator.${t}`),value:t}),Pr=t=>{const{type:e,operator:u,onChange:n,value:a,interceptorManager:l}=t,c=j.useDependency(i.LocaleService),[p,o]=S.useState(()=>typeof a=="number"?a:0),[f,d]=S.useState(""),[v,g]=S.useState(()=>typeof a=="string"?a:""),[b,T]=S.useState(""),[m,E]=S.useState(()=>Array.isArray(a)?a[0]===void 0?0:a[0]:0),[N,M]=S.useState(""),[w,R]=S.useState(()=>Array.isArray(a)?a[1]===void 0?100:a[1]:100),[h,I]=S.useState("");switch(S.useEffect(()=>{switch(e){case r.CFSubRuleType.text:{[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(u)&&n(v);break}case r.CFSubRuleType.number:{[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(u)&&n(p),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)&&n([m,w]);break}}},[e]),S.useEffect(()=>{const _=l.intercept(l.getInterceptPoints().beforeSubmit,{handler:(C,U,V)=>{switch(e){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(u))return v?V(C):(T(c.t("sheet.cf.errorMessage.notBlank")),!1)}return V(C)}});return()=>{_()}},[e,p,v,u]),e){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(u)){const _=C=>{g(C),n(C)};return s.jsx("div",{className:"univer-mt-3",children:s.jsx(Oe,{errorText:b,children:s.jsx(O.Input,{value:v,onChange:C=>{T(""),_(C)}})})})}break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(u)){const _=C=>{o(C||0),n(C||0),d("")};return s.jsx("div",{className:"univer-mt-3",children:s.jsx(Oe,{errorText:f,children:s.jsx(O.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:p,onChange:_})})})}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)){const _=U=>{E(U||0),n([U||0,w]),M("")},C=U=>{R(U||0),n([m,U||0]),I("")};return s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(Oe,{errorText:N,children:s.jsx(O.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:m,onChange:_})}),s.jsx(Oe,{errorText:h,children:s.jsx(O.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:w,onChange:C})})]})}}}return null},cr=(t,e)=>{switch(t){case r.CFSubRuleType.text:return[B(r.CFTextOperator.containsText,e),B(r.CFTextOperator.notContainsText,e),B(r.CFTextOperator.beginsWith,e),B(r.CFTextOperator.endsWith,e),B(r.CFTextOperator.equal,e),B(r.CFTextOperator.notEqual,e),B(r.CFTextOperator.containsBlanks,e),B(r.CFTextOperator.notContainsBlanks,e),B(r.CFTextOperator.containsErrors,e),B(r.CFTextOperator.notContainsErrors,e)];case r.CFSubRuleType.number:return[B(r.CFNumberOperator.between,e),B(r.CFNumberOperator.notBetween,e),B(r.CFNumberOperator.equal,e),B(r.CFNumberOperator.notEqual,e),B(r.CFNumberOperator.greaterThan,e),B(r.CFNumberOperator.greaterThanOrEqual,e),B(r.CFNumberOperator.lessThan,e),B(r.CFNumberOperator.lessThanOrEqual,e)];case r.CFSubRuleType.timePeriod:return[B(r.CFTimePeriodOperator.yesterday,e),B(r.CFTimePeriodOperator.today,e),B(r.CFTimePeriodOperator.tomorrow,e),B(r.CFTimePeriodOperator.last7Days,e),B(r.CFTimePeriodOperator.lastWeek,e),B(r.CFTimePeriodOperator.thisWeek,e),B(r.CFTimePeriodOperator.nextWeek,e),B(r.CFTimePeriodOperator.lastMonth,e),B(r.CFTimePeriodOperator.thisMonth,e),B(r.CFTimePeriodOperator.nextMonth,e)]}},or=t=>{var R;const{interceptorManager:e,onChange:u}=t,n=j.useDependency(i.LocaleService),a=((R=t.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?t.rule:void 0,[l,c]=S.useState(()=>{const h=r.CFSubRuleType.text;return a&&a.subType||h}),p=[{value:r.CFSubRuleType.text,label:n.t("sheet.cf.subRuleType.text")},{value:r.CFSubRuleType.number,label:n.t("sheet.cf.subRuleType.number")},{value:r.CFSubRuleType.timePeriod,label:n.t("sheet.cf.subRuleType.timePeriod")},{value:r.CFSubRuleType.duplicateValues,label:n.t("sheet.cf.subRuleType.duplicateValues")},{value:r.CFSubRuleType.uniqueValues,label:n.t("sheet.cf.subRuleType.uniqueValues")}],o=S.useMemo(()=>cr(l,n),[l]),[f,d]=S.useState(()=>{const h=o?o[0].value:void 0;return a&&a.operator||h}),[v,g]=S.useState(()=>{var _;const h="";return a?(_=a.value)!=null?_:r.createDefaultValue(a.subType,a.operator):h}),[b,T]=S.useState({}),m=S.useMemo(()=>h=>{var I,_,C,U,V,k,L,y,x,F,G,J,Q,de,ve;switch(h.subType||l){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(f))return{type:r.CFRuleType.highlightCell,subType:(I=h.subType)!=null?I:l,operator:(_=h.operator)!=null?_:f,style:(C=h.style)!=null?C:b,value:(U=h.value)!=null?U:v};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(f))return{type:r.CFRuleType.highlightCell,subType:(V=h.subType)!=null?V:l,operator:(k=h.operator)!=null?k:f,style:(L=h.style)!=null?L:b,value:(y=h.value)!=null?y:v};if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(f))return{type:r.CFRuleType.highlightCell,subType:(x=h.subType)!=null?x:l,operator:(F=h.operator)!=null?F:f,style:(G=h.style)!=null?G:b,value:(J=h.value)!=null?J:v};break}}return{type:r.CFRuleType.highlightCell,subType:(Q=h.subType)!=null?Q:l,operator:(de=h.operator)!=null?de:f,style:(ve=h.style)!=null?ve:b}},[l,f,v,b]);S.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return m({})}}),[m,e]),S.useEffect(()=>{p.some(h=>h.value===l)||c(p[0].value)},[p]);const E=h=>{const I=h,_=cr(I,n),C=_&&_[0].value;c(I),d(C),C&&g(r.createDefaultValue(I,C)),u(m({subType:I,operator:C}))},N=h=>{const I=h;d(I),u(m({operator:I}))},M=h=>{g(h),u(m({value:h}))},w=S.useMemo(()=>`${l}_${f}_${Math.random()}`,[l,f]);return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:E,value:l,options:p}),(o==null?void 0:o.length)&&s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:N,value:f||"",options:o})]}),s.jsx(Pr,{value:v,interceptorManager:e,type:l,operator:f,rule:a,onChange:M},w),s.jsx("div",{className:ge,children:s.jsx(le,{rule:m({})})}),s.jsx(Qe,{style:a==null?void 0:a.style,className:"univer-ml-1",onChange:h=>{T(h),u(m({style:h}))}})]})},dr=(t,e)=>(r.iconMap[t]||[])[Number(e)]||"",Dr=t=>{var d;const{error:e,type:u,onChange:n}=t,a=j.useDependency(i.IUniverInstanceService),l=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(d=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),p=S.useRef(null),[o,f]=S.useState(!1);return j.useSidebarClick(v=>{var b;((b=p.current)==null?void 0:b.isClickOutSide(v))&&f(!1)}),s.jsx("div",{className:"univer-relative",children:u!==r.CFValueType.formula?s.jsxs(s.Fragment,{children:[s.jsx(O.InputNumber,{className:O.clsx({"univer-border-red-500":e}),value:Number(t.value)||0,onChange:v=>n(v!=null?v:0)}),e&&s.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):s.jsx("div",{className:"univer-w-full",children:s.jsx(pe.FormulaEditor,{ref:p,initValue:String(t.value),unitId:l,subUnitId:c,isFocus:o,onChange:(v="")=>{n(v||"")},onFocus:()=>f(!0)})})})},vr=(t,e,u)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(u.length-1-e)*10},iconType:t,iconId:String(e)}),jr=S.forwardRef((t,e)=>{const{onClick:u}=t,n=j.useDependency(i.LocaleService),a=l=>{u(l)};return s.jsx("div",{ref:e,className:"univer-w-80",children:r.iconGroup.map((l,c)=>s.jsxs("div",{className:"univer-mb-3",children:[s.jsx("div",{className:"univer-mb-1 univer-text-sm",children:n.t(l.title)}),s.jsx("div",{className:"univer-flex univer-flex-wrap",children:l.group.map(p=>s.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{a(p.name)},children:s.jsx("a",{className:"univer-cursor-pointer univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",children:p.list.map((o,f)=>s.jsx("img",{className:"univer-size-5",src:o,draggable:!1},f))})},p.name))})]},c))})}),Lr=t=>{const{onClick:e}=t,u=S.useMemo(()=>{const a=[];for(const l in r.iconMap){const c=r.iconMap[l],p=l;c.forEach((o,f)=>{a.push({iconType:p,base64:o,iconId:String(f)})})}return a},[]),n=a=>{e(a.iconType,a.iconId)};return s.jsxs("div",{children:[s.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>n({iconType:r.EMPTY_ICON_TYPE,iconId:""}),children:[s.jsx(he,{className:"univer-size-5"}),s.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),s.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:u.map(a=>s.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",children:s.jsx("img",{className:"univer-size-5",src:a.base64,draggable:!1,onClick:()=>n(a)})},`${a.iconType}_${a.iconId}`))})]})},Ar=t=>{const{onChange:e,configList:u,errorMap:n={}}=t,a=j.useDependency(i.LocaleService),l=[{label:a.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:a.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],c=[{label:a.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:a.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:a.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:a.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],p=(v,g)=>{e([String(g),"value","value"],v)},o=(v,g)=>{e([String(g),"operator"],v);const b=r.createDefaultValue(r.CFSubRuleType.number,v);p(b,g)},f=(v,g)=>{e([String(g),"value","type"],v);const b=u[g],T=r.createDefaultValue(r.CFSubRuleType.number,b.operator);p(T,g)};return S.useMemo(()=>u.map((v,g)=>{const b=n[g],T=dr(v.iconType,v.iconId),m=g===u.length-1,E=g===0,N=u[g-1],M=(N==null?void 0:N.value.type)===r.CFValueType.formula?a.t("sheet.cf.valueType.formula"):N==null?void 0:N.value.value,w=(R,h)=>{const I={...v,iconId:h,iconType:R};e([String(g)],I)};return s.jsxs("div",{className:g?"univer-mt-6":"univer-mt-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[s.jsxs("div",{className:"univer-w-[45%]",children:[a.t("sheet.cf.iconSet.icon"),g+1]}),s.jsx("div",{className:"univer-w-[45%]",children:s.jsxs(s.Fragment,{children:[!E&&!m&&a.t("sheet.cf.iconSet.rule"),!E&&!m&&s.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:["(",a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${r.getOppositeOperator(N.operator)}`),M,m?"":` ${a.t("sheet.cf.iconSet.and")} `,")"]})]})})]}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[s.jsx("div",{className:"univer-flex univer-items-center",children:s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(Lr,{onClick:w,iconId:v.iconId,iconType:v.iconType})}),children:s.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all dark:!univer-text-gray-200 hover:univer-border-primary-600",O.borderClassName),children:[T?s.jsx("img",{src:T,className:"univer-size-4",draggable:!1}):s.jsx(he,{className:"univer-size-4"}),s.jsx(Re,{})]})})}),m?s.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[a.t("sheet.cf.iconSet.rule"),s.jsxs("span",{className:"univer-font-medium",children:[a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${r.getOppositeOperator(N.operator)}`),M,m?"":` ${a.t("sheet.cf.iconSet.and")} `]})]}):s.jsx(O.Select,{options:l,value:v.operator,onChange:R=>{o(R,g)}})]}),m?s.jsx("div",{}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[s.jsx("div",{children:a.t("sheet.cf.iconSet.type")}),s.jsx("div",{children:a.t("sheet.cf.iconSet.value")})]}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[s.jsx(O.Select,{className:"univer-flex-shrink-0",options:c,value:v.value.type,onChange:R=>{f(R,g)}}),s.jsx("div",{children:s.jsx(Dr,{id:g,type:v.value.type,error:b,value:v.value.value||"",onChange:R=>{p(R,g)}})})]})]})]},g)}),[u,n])},Fr=t=>{var R;const{interceptorManager:e}=t,u=((R=t.rule)==null?void 0:R.type)===r.CFRuleType.iconSet?t.rule:void 0,n=j.useDependency(i.LocaleService),[a,l]=S.useState({}),[c,p]=S.useState(()=>{const h=Object.keys(r.iconMap)[0];if(u&&u.config.length){const I=u.config[0].iconType;if(!u.config.some(C=>C.iconType!==I))return I}return h}),[o,f]=S.useState(()=>{if(u&&u.config.length)return i.Tools.deepClone(u==null?void 0:u.config);const h=r.iconMap[c]||[];return new Array(h.length).fill("").map((I,_,C)=>_===C.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:c,iconId:String(_)}:vr(c,_,C))}),[d,v]=S.useState(()=>u?!!u.isShowValue:!0),g=S.useMemo(()=>{const h=o.map(I=>dr(I.iconType,I.iconId));return s.jsx("div",{className:"univer-flex univer-items-center",children:h.map((I,_)=>I?s.jsx("img",{className:"univer-size-5",src:I},_):s.jsx(he,{className:"univer-size-5"},_))})},[o]),b=h=>{if(h.reduce((_,C,U)=>_.preType&&!_.result||h.length-1===U?_:C.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:_.preType?{result:_.preType===C.value.type,preType:C.value.type}:{result:!0,preType:C.value.type},{result:!0,preType:""}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(h[0].value.type)){const _={};return h.forEach((C,U,V)=>{if(U-1<0||U===V.length-1)return;const L=h[U-1],y=r.getOppositeOperator(L.operator);r.compareWithNumber({operator:y,value:L.value.value},C.value.value)||(_[U]=`${n.t(`sheet.cf.form.${y}`,String(L.value.value))} `)}),_}return{}},T=(h,I)=>{i.get(o,h)!==I&&(i.set(o,h,I),f([...o]),l(b(o)))},m=h=>{p(h);const I=r.iconMap[h]||[],_=new Array(I.length).fill("").map((C,U,V)=>vr(h,U,V));f(_),l(b(_))};S.useEffect(()=>{const h=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:d,config:o}}});return()=>{h()}},[d,o,e]),S.useEffect(()=>{const h=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(a).length===0}});return()=>{h()}},[d,o,e,a]);const E=()=>{const h=o.map(I=>({...I}));o.forEach((I,_)=>{const C=o.length-1-_,U=h[C];I.iconId=U.iconId,I.iconType=U.iconType}),f([...o])},N=j.useDependency(j.ILayoutService),[M,w]=S.useState();return j.useScrollYOverContainer(M,N.rootContainerElement),s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),s.jsx("div",{className:"univer-mt-3",children:s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg univer-p-4",children:s.jsx(jr,{ref:h=>{!M&&h&&w(h)},iconType:c,onClick:m})}),children:s.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",O.borderClassName),children:[g,s.jsx(Re,{})]})})}),s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[s.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{onChange:E}),n.t("sheet.cf.iconSet.reverseIconOrder")]}),s.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:!d,onChange:h=>{v(!h)}}),n.t("sheet.cf.iconSet.onlyShowIcon")]})]}),s.jsx(Ar,{errorMap:a,onChange:T,configList:o})]})},$r=t=>{var E;const{onChange:e,interceptorManager:u}=t,n=j.useDependency(i.LocaleService),a=((E=t.rule)==null?void 0:E.type)===r.CFRuleType.highlightCell?t.rule:void 0,l=[{label:n.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:n.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:n.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:n.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[c,p]=S.useState(()=>{const N=l[0].value,M=a==null?void 0:a.type;if(!a)return N;switch(M){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(a.operator)?"greaterThanAverage":[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(a.operator)?"lessThanAverage":N;case r.CFSubRuleType.rank:return a.isBottom?"isBottom":"isNotBottom"}}return N}),[o,f]=S.useState(()=>{const M=a==null?void 0:a.type;if(!a)return 10;switch(M){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.rank:return a.value||10}}return 10}),[d,v]=S.useState(()=>{const M=a==null?void 0:a.type;if(!a)return!1;switch(M){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.rank:return a.isPercent||!1}}return!1}),[g,b]=S.useState({}),T=N=>{const{type:M,isPercent:w,value:R,style:h}=N;if(M==="isNotBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:w,isBottom:!1,value:R,style:h};if(M==="isBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:w,isBottom:!0,value:R,style:h};if(M==="greaterThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:h};if(M==="lessThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:h}};S.useEffect(()=>u.intercept(u.getInterceptPoints().submit,{handler(){return T({type:c,isPercent:d,value:o,style:g})}}),[c,d,o,g,u]);const m=N=>{e(T(N))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),s.jsx(O.Select,{className:"univer-mt-3 univer-w-full",value:c,options:l,onChange:N=>{p(N),m({type:N,isPercent:d,value:o,style:g})}}),["isNotBottom","isBottom"].includes(c)&&s.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[s.jsx(O.InputNumber,{min:1,max:1e3,value:o,onChange:N=>{const M=N||0;f(M),m({type:c,isPercent:d,value:M,style:g})}}),s.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[s.jsx(O.Checkbox,{checked:d,onChange:N=>{v(!!N),m({type:c,isPercent:!!N,value:o,style:g})}}),n.t("sheet.cf.valueType.percent")]})]}),s.jsx("div",{className:ge,children:s.jsx(le,{rule:T({type:c,isPercent:d,value:o,style:g})})}),s.jsx(Qe,{style:a==null?void 0:a.style,className:"univer-mt-3",onChange:N=>{b(N),m({type:c,isPercent:d,value:o,style:N})}})]})},Br=i.createInterceptorKey("beforeSubmit"),Hr=i.createInterceptorKey("submit"),pr=t=>t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),fr=t=>{var e;return(e=t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},Wr=t=>{var _,C,U;const e=j.useDependency(i.LocaleService),u=j.useDependency(i.ICommandService),n=j.useDependency(i.IUniverInstanceService),a=j.useDependency(r.ConditionalFormattingRuleModel),l=j.useDependency(P.SheetsSelectionsService),c=pr(n),p=fr(n),[o,f]=S.useState(void 0),d=S.useRef((C=(_=t.rule)==null?void 0:_.ranges)!=null?C:[]),v=S.useMemo(()=>{var k,L,y;let V=(k=t.rule)==null?void 0:k.ranges;return V!=null&&V.length||(V=(y=(L=l.getCurrentSelections())==null?void 0:L.map(x=>x.range))!=null?y:[]),d.current=V,V!=null&&V.length?V.map(x=>{const F=Be.serializeRange(x);return F==="NaN"?"":F}).filter(x=>!!x).join(","):""},[t.rule]),g=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,T]=S.useState(()=>{var L,y;const V=(L=t.rule)==null?void 0:L.rule.type,k=g[0].value;if(!V)return k;switch(V){case r.CFRuleType.highlightCell:{switch((y=t.rule)==null?void 0:y.rule.subType){case r.CFSubRuleType.number:case r.CFSubRuleType.text:case r.CFSubRuleType.duplicateValues:case r.CFSubRuleType.uniqueValues:case r.CFSubRuleType.timePeriod:return"1";case r.CFSubRuleType.average:case r.CFSubRuleType.rank:return"2";case r.CFSubRuleType.formula:return"5"}break}case r.CFRuleType.dataBar:return"3";case r.CFRuleType.colorScale:return"4";case r.CFRuleType.iconSet:return"6"}return k}),m=S.useRef(void 0),E=S.useMemo(()=>new i.InterceptorManager({beforeSubmit:Br,submit:Hr}),[]),N=S.useMemo(()=>{switch(b){case"1":return or;case"2":return $r;case"3":return Ur;case"4":return Or;case"5":return kr;case"6":return Fr;default:return or}},[b]);S.useEffect(()=>{const V=u.onCommandExecuted(k=>{if(k.id===P.RemoveSheetMutation.id){const L=k.params;L.subUnitId===p&&L.unitId===c&&t.onCancel()}k.id===P.SetWorksheetActiveOperation.id&&t.onCancel()});return()=>V.dispose()},[]);const M=V=>{m.current=V},w=V=>{const k=V.split(",").filter(L=>!!L).map(Be.deserializeRangeWithSheet).map(L=>L.range);d.current=k},R=()=>{if(o)return;const k=(()=>{const y=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!y)throw new Error("No active sheet found");return d.current.map(G=>P.setEndForRange(G,y.getRowCount(),y.getColumnCount())).filter(G=>!(Number.isNaN(G.startRow)||Number.isNaN(G.startColumn)))})();if(E.fetchThroughInterceptors(E.getInterceptPoints().beforeSubmit)(!0,null)){const y=E.fetchThroughInterceptors(E.getInterceptPoints().submit)(null,null);if(y){const x=pr(n),F=fr(n);if(!x||!F)throw new Error("No active sheet found");let G={};t.rule&&t.rule.cfId?(G={...t.rule,ranges:k,rule:y},u.executeCommand(r.SetCfCommand.id,{unitId:x,subUnitId:F,rule:G}),t.onCancel()):(G={cfId:a.createCfId(x,F),ranges:k,rule:y,stopIfTrue:!1},u.executeCommand(r.AddCfCommand.id,{unitId:x,subUnitId:F,rule:G}),t.onCancel())}}},h=()=>{t.onCancel()},I=(V,k)=>{V?k.length<1?f(e.t("sheet.cf.errorMessage.rangeError")):f(void 0):f(e.t("sheet.cf.errorMessage.rangeError"))};return s.jsxs("div",{children:[s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),s.jsxs("div",{className:"univer-mt-4",children:[s.jsx(pe.RangeSelector,{unitId:c,subUnitId:p,initialValue:v,onChange:(V,k)=>w(k),onVerify:I}),o&&s.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:o})]}),s.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),s.jsx(O.Select,{className:"univer-mt-4 univer-w-full",value:b,options:g,onChange:V=>T(V)}),s.jsx(N,{interceptorManager:E,rule:(U=t.rule)==null?void 0:U.rule,onChange:M}),s.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[s.jsx(O.Button,{onClick:h,children:e.t("sheet.cf.panel.cancel")}),s.jsx(O.Button,{className:"univer-ml-3",variant:"primary",onClick:R,children:e.t("sheet.cf.panel.submit")})]})]})};var qr=Object.getOwnPropertyDescriptor,Gr=(t,e,u,n)=>{for(var a=n>1?void 0:n?qr(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},zr=(t,e)=>(u,n)=>e(u,n,t);let se=class extends i.Disposable{constructor(e){super();ee(this,"_initLocal",()=>{});ee(this,"_findReplaceIndex",e=>{const u=/\{([^}]+)?\}/g,n=[];let a=u.exec(e);for(;a;)n.push({startIndex:a.index,key:Number(a[1]),endIndex:a.index+a[0].length-1}),a=u.exec(e);return n});this._localeService=e,this._initLocal()}tWithReactNode(e,...u){const n=this._localeService.getLocales(),a=e.split("."),l=n&&this._localeService.resolveKeyPath(n,a);if(typeof l=="string"){const c=[];return this._findReplaceIndex(l).forEach((p,o,f)=>{const d=f[o-1]||{endIndex:-1};if(d.endIndex+1<p.startIndex){const v=l.slice(d.endIndex+1,p.startIndex);v&&c.push(v)}if(u[p.key]&&c.push(u[p.key]),o===f.length-1){const v=l.slice(p.endIndex+1);v&&c.push(v)}}),c}return[]}};se=Gr([zr(0,i.Inject(i.LocaleService))],se);const Yr=(t,e)=>{const u=t.rule;switch(u.type){case r.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case r.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case r.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case r.CFRuleType.highlightCell:switch(u.subType){case r.CFSubRuleType.average:{const n=u.operator;return e.t(`sheet.cf.preview.describe.${n}`,e.t("sheet.cf.subRuleType.average"))}case r.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case r.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case r.CFSubRuleType.number:{const n=u.operator;return e.t(`sheet.cf.preview.describe.${n}`,...Array.isArray(u.value)?u.value.map(a=>String(a)):[String(u.value||"")])}case r.CFSubRuleType.text:{const n=u.operator;return e.t(`sheet.cf.preview.describe.${n}`,u.value||"")}case r.CFSubRuleType.timePeriod:{const n=u.operator;return e.t(`sheet.cf.preview.describe.${n}`)}case r.CFSubRuleType.rank:return u.isPercent?u.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(u.value)):e.t("sheet.cf.preview.describe.topNPercent",String(u.value)):u.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(u.value)):e.t("sheet.cf.preview.describe.topN",String(u.value));case r.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let hr=0;const Zr=t=>{const{onClick:e}=t,u=j.useDependency(r.ConditionalFormattingRuleModel),n=j.useDependency(i.IUniverInstanceService),a=j.useDependency(P.SheetsSelectionsService),l=j.useDependency(i.ICommandService),c=j.useDependency(i.LocaleService),p=j.useDependency(i.Injector),o=j.useDependency(j.ISidebarService),f=j.useDependency(se),d=j.useObservable(()=>n.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),v=d.getUnitId(),g=d.getActiveSheet();if(!g)throw new Error("No active sheet found");const b=g.getSheetId(),[T,m]=S.useState([]),[E,N]=S.useState("2"),[M,w]=S.useState(0),[R,h]=S.useState(-1),[I,_]=S.useState(hr),C=S.useRef(null),U=[{label:c.t("sheet.cf.panel.workSheet"),value:"2"},{label:c.t("sheet.cf.panel.selectedRange"),value:"1"}],V=()=>{const A=u.getSubunitRules(v,b);if(!A||!A.length)return[];if(E==="1"){const $=a.getCurrentLastSelection();if(!$)return[];const H=$.range;return A.filter(z=>z.ranges.some(Y=>i.Rectangle.intersects(Y,H)))}else if(E==="2")return[...A];return[]},[k,L]=S.useState(V);W.useHighlightRange(T),S.useEffect(()=>{const A=l.onCommandExecuted($=>{$.id===P.SetWorksheetActiveOperation.id&&w(Math.random())});return()=>A.dispose()}),S.useEffect(()=>{L(V)},[E,M,v,b]),S.useEffect(()=>{if(E==="2")return;const A=new X.Observable($=>{const H=[P.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],q=l.onCommandExecuted(z=>{const{id:Y,params:ne}=z,ae=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();H.includes(Y)&&ne.unitId===ae&&$.next(null)});return()=>q.dispose()}).pipe(X.debounceTime(16)).subscribe(()=>{L(V)});return()=>{A.unsubscribe()}},[n,E,v,b]),S.useEffect(()=>{const A=u.$ruleChange.subscribe(()=>{w(Math.random())});return()=>A.unsubscribe()},[u]),S.useEffect(()=>{const A=()=>{var z,Y;const q=Math.max(0,((Y=(z=C.current)==null?void 0:z.getBoundingClientRect().width)!=null?Y:0)-8);return hr=q,q},H=new X.Observable(q=>{const z=o.getContainer();if(z){let Y=setTimeout(()=>{q.next(void 0)},150);const ne=()=>{Y&&clearTimeout(Y),Y=null},ae=$e=>{$e.propertyName==="width"&&(ne(),q.next(void 0))};return z.addEventListener("transitionend",ae),()=>{ne(),z.removeEventListener("transitionend",ae)}}}).pipe(X.debounceTime(16)).subscribe(()=>{_(A())});return()=>{H.unsubscribe()}},[]);const y=A=>{var q;const $=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),H=(q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:q.getSheetId();if(!$||!H)throw new Error("No active sheet found");l.executeCommand(r.DeleteCfCommand.id,{unitId:$,subUnitId:H,cfId:A.cfId})},x=(A,$)=>{h($.y)},F=(A,$,H)=>{var $e;h(-1);const q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),z=($e=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:$e.getSheetId();if(!q||!z)throw new Error("No active sheet found");const Y=wt=>{const Vt=k.length;return Math.min(Vt-1,Math.max(0,wt))},ne=k[Y($.y)].cfId,ae=k[Y(H.y)].cfId;ne!==ae&&l.executeCommand(r.MoveCfCommand.id,{unitId:q,subUnitId:z,start:{id:ne,type:"self"},end:{id:ae,type:H.y>$.y?"after":"before"}})},G=()=>{t.onCreate()},J=()=>{E==="2"?l.executeCommand(r.ClearWorksheetCfCommand.id):E==="1"&&k.map($=>({unitId:v,subUnitId:b,cfId:$.cfId})).forEach($=>{l.executeCommand(r.DeleteCfCommand.id,$)})},Q=S.useMemo(()=>{const A=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),$=A.getActiveSheet();return k.filter(H=>{const q=H.ranges;return P.checkRangesEditablePermission(p,A.getUnitId(),$.getSheetId(),q)})},[k]),de=Q.map((A,$)=>({i:A.cfId,x:0,w:12,y:$,h:1,isResizable:!1})),ve=S.useMemo(()=>{const A=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),$=A.getActiveSheet();return k.every(H=>{const q=H.ranges;return P.checkRangesEditablePermission(p,A.getUnitId(),$.getSheetId(),q)})},[k]);return s.jsxs("div",{children:[s.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[s.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:f.tWithReactNode("sheet.cf.panel.managerRuleSelect",s.jsx(O.Select,{className:"univer-w-36",options:U,value:E,onChange:A=>{N(A)}})).map((A,$)=>s.jsx("span",{children:A},$))}),s.jsxs("div",{className:"univer-flex univer-justify-end",children:[s.jsx(O.Tooltip,{title:c.t("sheet.cf.panel.createRule"),placement:"bottom",children:s.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:G,children:s.jsx(lr,{})})}),k.length&&ve?s.jsx(O.Tooltip,{title:c.t("sheet.cf.panel.clear"),placement:"bottom",children:s.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:J,children:s.jsx(Me,{className:"univer-text-red-500"})})}):s.jsx("div",{children:s.jsx(Me,{className:"univer-text-gray-300"})})]})]}),s.jsx("div",{ref:C,children:I>0&&s.jsx(O.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:de,cols:12,rowHeight:60,width:I,margin:[0,10],onDragStop:F,onDragStart:x,children:Q==null?void 0:Q.map((A,$)=>s.jsx("div",{children:s.jsxs("div",{className:O.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-bg-gray-100 dark:!univer-bg-gray-700":R===$}),onMouseMove:()=>{A.ranges!==T&&m(A.ranges)},onMouseLeave:()=>m([]),onClick:()=>{e(A)},children:[s.jsx("div",{className:O.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:H=>H.stopPropagation(),children:s.jsx(ir,{})}),s.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:Yr(A,c)}),s.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:A.ranges.map(H=>Be.serializeRange(H)).join(",")})]}),s.jsx("div",{children:s.jsx(le,{rule:A.rule})}),s.jsx("div",{className:O.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":R===$}),onClick:H=>{H.stopPropagation(),y(A),m([])},children:s.jsx(Me,{})})]})},`${A.cfId}`))})})]})},Kr=t=>{const[e,u]=S.useState(t.rule),[n,a]=S.useState(!!t.rule),l=()=>{a(!0)},c=()=>{a(!1),u(void 0)},p=o=>{u(o),a(!0)};return s.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between",children:n?s.jsx(Wr,{onCancel:c,rule:e}):s.jsx(Zr,{onClick:p,onCreate:l})})};var Xr=Object.getOwnPropertyDescriptor,Jr=(t,e,u,n)=>{for(var a=n>1?void 0:n?Xr(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},ye=(t,e)=>(u,n)=>e(u,n,t);const Ue="sheet.conditional.formatting.panel";let me=class extends i.Disposable{constructor(e,u,n,a,l){super();ee(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=u,this._componentManager=n,this._sidebarService=a,this._localeService=l,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(c=>{var p;c||(p=this._sidebarDisposable)==null||p.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(c=>{c.id===Ue&&(c.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const u={id:Ue,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ue,rule:e,key:i.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(u)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ue,Kr))}};me=Jr([ye(0,i.IUniverInstanceService),ye(1,i.Inject(i.Injector)),ye(2,i.Inject(j.ComponentManager)),ye(3,i.Inject(j.ISidebarService)),ye(4,i.Inject(i.LocaleService))],me);var Z=(t=>(t[t.createRule=1]="createRule",t[t.viewRule=2]="viewRule",t[t.highlightCell=3]="highlightCell",t[t.rank=4]="rank",t[t.formula=5]="formula",t[t.colorScale=6]="colorScale",t[t.dataBar=7]="dataBar",t[t.icon=8]="icon",t[t.clearRangeRules=9]="clearRangeRules",t[t.clearWorkSheetRules=10]="clearWorkSheetRules",t))(Z||{});const Se={id:"sheet.operation.open.conditional.formatting.panel",type:i.CommandType.OPERATION,handler:(t,e)=>{var p;const u=t.get(me),n=t.get(P.SheetsSelectionsService),a=t.get(i.ICommandService),l=((p=n.getCurrentSelections())==null?void 0:p.map(o=>o.range))||[];switch(e.value){case 3:{u.openPanel({...r.createDefaultRule(),ranges:l});break}case 4:{const o={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};u.openPanel(o);break}case 5:{const o={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:"="}};u.openPanel(o);break}case 6:{const o={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.colorScale,config:[]}};u.openPanel(o);break}case 7:{const o={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};u.openPanel(o);break}case 8:{const o={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};u.openPanel(o);break}case 2:{u.openPanel();break}case 1:{u.openPanel({...r.createDefaultRule(),ranges:l});break}case 9:{a.executeCommand(r.ClearRangeCfCommand.id,{ranges:l});break}case 10:{a.executeCommand(r.ClearWorksheetCfCommand.id);break}}return!0}};var Qr=Object.getOwnPropertyDescriptor,et=(t,e,u,n)=>{for(var a=n>1?void 0:n?Qr(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},be=(t,e)=>(u,n)=>e(u,n,t);let Ie=class extends i.Disposable{constructor(e,u,n,a,l){super();ee(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=u,this._injector=n,this._conditionalFormattingViewModel=a,this._univerInstanceService=l,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,u,n)=>this._collectConditionalRule(e,u,n),onPasteCells:(e,u,n,a)=>{const{copyType:l=W.COPY_TYPE.COPY,pasteType:c}=a,{range:p}=e||{},{range:o}=u;return this._generateConditionalFormattingMutations(o,{copyType:l,pasteType:c,copyRange:p})}}))}_collectConditionalRule(e,u,n){const a=new i.ObjectMatrix,l={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:u,cfMap:l}};const c=this._injector.invoke(d=>P.rangeToDiscreteRange(n,d,e,u));if(!c)return;const{rows:p,cols:o}=c,f=new Set;p.forEach((d,v)=>{o.forEach((g,b)=>{const T=this._conditionalFormattingViewModel.getCellCfs(e,u,d,g);T&&(T.forEach(m=>f.add(m.cfId)),a.setValue(v,b,T.map(m=>m.cfId)))})}),f.forEach(d=>{const v=this._conditionalFormattingRuleModel.getRule(e,u,d);v&&(l[d]=v.rule)})}_generateConditionalFormattingMutations(e,u){const n=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),a=n.getActiveSheet(),l=n.getUnitId();if(!a)return{redos:[],undos:[]};const c=a.getSheetId();if(u.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!u.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(u.pasteType))return{redos:[],undos:[]};const{ranges:[o,f],mapFunc:d}=W.virtualizeDiscreteRanges([u.copyRange,e]),v=W.getRepeatRange(o,f,!0),g={};i.Range.foreach(f,(h,I)=>{const{row:_,col:C}=d(h,I),U=this._conditionalFormattingViewModel.getCellCfs(l,c,_,C);U&&U.forEach(V=>{if(!g[V.cfId]){const k=new i.ObjectMatrix;g[V.cfId]=k;const L=this._conditionalFormattingRuleModel.getRule(l,c,V.cfId);L==null||L.ranges.forEach(y=>{i.Range.foreach(y,(x,F)=>{k.setValue(x,F,1)})})}g[V.cfId].realDeleteValue(_,C)})});const{matrix:b,info:T}=this._copyInfo,m=[];let E=this._conditionalFormattingRuleModel.createCfId(l,c);const N={},M=h=>{if(N[h])return N[h];const I=T==null?void 0:T.cfMap[h],_=[...this._conditionalFormattingRuleModel.getSubunitRules(l,c)||[],...m].find(C=>i.Tools.diffValue(C.rule,I));if(_)return N[h]=_,_;{const C={rule:I,cfId:E,ranges:[],stopIfTrue:!1};return N[h]=C,m.push(C),E=`${Number(E)+1}`,C}};v.forEach(h=>{b&&b.forValue((I,_,C)=>{const U=i.Rectangle.getPositionRange({startRow:I,endRow:I,startColumn:_,endColumn:_},h.startRange),{row:V,col:k}=d(U.startRow,U.startColumn);C.forEach(L=>{if(!g[L]){const y=M(L),x=new i.ObjectMatrix;g[L]=x,y.ranges.forEach(F=>{i.Range.foreach(F,(G,J)=>{x.setValue(G,J,1)})})}g[L].setValue(V,k,1)})})});const w=[],R=[];for(const h in g){const I=g[h],_=P.findAllRectangle(P.createTopMatrixFromMatrix(I));if(!_.length){const C={unitId:l,subUnitId:c,cfId:h};w.push({id:r.DeleteConditionalRuleMutation.id,params:C}),R.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,C))}if(m.some(C=>C.cfId===h)){const C=M(h),U={unitId:l,subUnitId:c,rule:{...C,ranges:_}};w.push({id:r.AddConditionalRuleMutation.id,params:U}),R.push(r.AddConditionalRuleMutationUndoFactory(this._injector,U))}else{const C=this._conditionalFormattingRuleModel.getRule(l,c,h);if(!C)continue;const U={unitId:l,subUnitId:c,rule:{...C,ranges:_}};w.push({id:r.SetConditionalRuleMutation.id,params:U}),R.push(...r.setConditionalRuleMutationUndoFactory(this._injector,U))}}return{redos:w,undos:R}}};Ie=et([be(0,i.Inject(W.ISheetClipboardService)),be(1,i.Inject(r.ConditionalFormattingRuleModel)),be(2,i.Inject(i.Injector)),be(3,i.Inject(r.ConditionalFormattingViewModel)),be(4,i.Inject(i.IUniverInstanceService))],Ie);var rt=Object.getOwnPropertyDescriptor,tt=(t,e,u,n)=>{for(var a=n>1?void 0:n?rt(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},er=(t,e)=>(u,n)=>e(u,n,t);let Ce=class extends i.Disposable{constructor(t,e,u){super(),this._localeService=t,this._commandService=e,this._sheetPermissionCheckController=u,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===r.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[P.WorkbookEditablePermission],rangeTypes:[P.RangeProtectionPermissionEditPoint],worksheetTypes:[P.WorksheetEditPermission,P.WorksheetSetCellStylePermission]},t.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Ce=tt([er(0,i.Inject(i.LocaleService)),er(1,i.ICommandService),er(2,i.Inject(P.SheetPermissionCheckController))],Ce);var nt=Object.getOwnPropertyDescriptor,at=(t,e,u,n)=>{for(var a=n>1?void 0:n?nt(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},ke=(t,e)=>(u,n)=>e(u,n,t);let Te=class extends i.Disposable{constructor(t,e,u,n){super(),this._conditionalFormattingRuleModel=t,this._univerInstanceService=e,this._injector=u,this._refRangeService=n,this._initRefRange()}_initRefRange(){const t=new Map,e=(n,a,l)=>`${n}_${a}_${l}`,u=(n,a,l)=>{const c=o=>{const f=[...l.ranges],d=f.map(g=>P.handleDefaultRangeChangeWithEffectRefCommands(g,o)).filter(g=>!!g);if(r.isRangesEqual(d,f))return{redos:[],undos:[]};if(d.length){const g={unitId:n,subUnitId:a,rule:{...l,ranges:d}},b=[{id:r.SetConditionalRuleMutation.id,params:g}],T=r.setConditionalRuleMutationUndoFactory(this._injector,g);return{redos:b,undos:T}}else{const g={unitId:n,subUnitId:a,cfId:l.cfId},b=[{id:r.DeleteConditionalRuleMutation.id,params:g}],T=r.DeleteConditionalRuleMutationUndoFactory(this._injector,g);return{redos:b,undos:T}}},p=[];l.ranges.forEach(o=>{const f=this._refRangeService.registerRefRange(o,c);p.push(()=>f.dispose())}),t.set(e(n,a,l.cfId),()=>p.forEach(o=>o()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(n=>{const{unitId:a,subUnitId:l,rule:c}=n,p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!(n.unitId!==p.getUnitId()||n.subUnitId!==(o==null?void 0:o.getSheetId())))switch(n.type){case"add":{u(n.unitId,n.subUnitId,n.rule);break}case"delete":{const f=t.get(e(a,l,c.cfId));f&&f();break}case"set":{const f=t.get(e(a,l,c.cfId));f&&f(),u(n.unitId,n.subUnitId,n.rule)}}})),this.disposeWithMe(i.toDisposable(()=>{t.forEach(n=>{n()}),t.clear()}))}};Te=at([ke(0,i.Inject(r.ConditionalFormattingRuleModel)),ke(1,i.Inject(i.IUniverInstanceService)),ke(2,i.Inject(i.Injector)),ke(3,i.Inject(P.RefRangeService))],Te);var ut=Object.getOwnPropertyDescriptor,lt=(t,e,u,n)=>{for(var a=n>1?void 0:n?ut(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},ce=(t,e)=>(u,n)=>e(u,n,t);let _e=class extends i.Disposable{constructor(e,u,n,a,l,c){super();ee(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=u,this._univerInstanceService=n,this._renderManagerService=a,this._conditionalFormattingViewModel=l,this._conditionalFormattingRuleModel=c,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var u,n,a;const e=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();(u=this._renderManagerService.getRenderById(e))==null||u.with(W.SheetSkeletonManagerService).reCalculate(),(a=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||a.makeDirty()}_initSkeleton(){this.disposeWithMe(X.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(fe.bufferTime(16),fe.filter(e=>!!e.length),fe.filter(e=>{const u=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!u)return!1;const n=u.getActiveSheet();return n?e.filter(a=>a.unitId===u.getUnitId()&&a.subUnitId===n.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(P.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,handler:(e,u,n)=>{const a=this._conditionalFormattingService.composeStyle(u.unitId,u.subUnitId,u.row,u.col);if(!a)return n(e);const l=u.workbook.getStyles(),p={...(typeof(e==null?void 0:e.s)=="string"?l.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}},o={...e,s:p};return a.style&&Object.assign(p,a.style),o.fontRenderExtension||(o.fontRenderExtension={},a.isShowValue!==void 0&&(o.fontRenderExtension.isSkip=!a.isShowValue)),a.dataBar&&(o.dataBar=a.dataBar),a.iconSet&&(o.iconSet=a.iconSet,o.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(o)},priority:10}))}};_e=lt([ce(0,i.Inject(P.SheetInterceptorService)),ce(1,i.Inject(r.ConditionalFormattingService)),ce(2,i.Inject(i.IUniverInstanceService)),ce(3,i.Inject(ar.IRenderManagerService)),ce(4,i.Inject(r.ConditionalFormattingViewModel)),ce(5,i.Inject(r.ConditionalFormattingRuleModel))],_e);const gr="sheets-conditional-formatting-ui.config",Pe={};var it=Object.defineProperty,st=Object.getOwnPropertyDescriptor,ct=(t,e,u)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,ot=(t,e,u,n)=>{for(var a=n>1?void 0:n?st(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},rr=(t,e)=>(u,n)=>e(u,n,t),yr=(t,e,u)=>ct(t,typeof e!="symbol"?e+"":e,u);D.UniverSheetsConditionalFormattingMobileUIPlugin=class extends i.Plugin{constructor(e=Pe,u,n,a){super(),this._config=e,this._injector=u,this._commandService=n,this._configService=a;const{menu:l,...c}=i.merge({},Pe,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(gr,c),this._initCommand(),this._injector.add([_e]),this._injector.add([Te]),this._injector.add([Ie]),this._injector.add([Ce]),this._injector.add([se])}_initCommand(){[He,We,qe,Ge,ze,Ye,Ze,Ke,Xe,Se].forEach(e=>{this._commandService.registerCommand(e)})}},yr(D.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),yr(D.UniverSheetsConditionalFormattingMobileUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingMobileUIPlugin=ot([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin),rr(1,i.Inject(i.Injector)),rr(2,i.Inject(i.ICommandService)),rr(3,i.IConfigService)],D.UniverSheetsConditionalFormattingMobileUIPlugin);var dt=Object.getOwnPropertyDescriptor,vt=(t,e,u,n)=>{for(var a=n>1?void 0:n?dt(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},xe=(t,e)=>(u,n)=>e(u,n,t);let De=class extends i.Disposable{constructor(t,e,u,n,a){super(),this._injector=t,this._univerInstanceService=e,this._autoFillService=u,this._conditionalFormattingRuleModel=n,this._conditionalFormattingViewModel=a,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),e=(a,l,c,p,o)=>{var b;const f=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(b=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!f||!d)return;const v={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},g={startRow:l.row,startColumn:l.col,endColumn:l.col,endRow:l.row};i.Range.foreach(c,(T,m)=>{const E=i.Rectangle.getPositionRange({startRow:T,startColumn:m,endColumn:m,endRow:T},v),N=i.Rectangle.getPositionRange({startRow:T,startColumn:m,endColumn:m,endRow:T},g),{row:M,col:w}=o(E.startRow,E.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(f,d,M,w),{row:h,col:I}=o(N.startRow,N.startColumn),_=this._conditionalFormattingViewModel.getCellCfs(f,d,h,I);_&&_.forEach(C=>{let U=p.get(C.cfId);if(!p.get(C.cfId)){const V=this._conditionalFormattingRuleModel.getRule(f,d,C.cfId);if(!V)return;U=new i.ObjectMatrix,V.ranges.forEach(k=>{i.Range.foreach(k,(L,y)=>{U.setValue(L,y,1)})}),p.set(C.cfId,U)}U.realDeleteValue(h,I)}),R&&R.forEach(C=>{let U=p.get(C.cfId);if(!p.get(C.cfId)){const V=this._conditionalFormattingRuleModel.getRule(f,d,C.cfId);if(!V)return;U=new i.ObjectMatrix,V.ranges.forEach(k=>{i.Range.foreach(k,(L,y)=>{U.setValue(L,y,1)})}),p.set(C.cfId,U)}U.setValue(h,I,1)})})},u=(a,l)=>{var N,M,w;const c=(N=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:N.getUnitId(),p=(w=(M=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:M.getActiveSheet())==null?void 0:w.getSheetId(),o=new Map,f=[],d=[];if(!c||!p)return t();const v=W.virtualizeDiscreteRanges([a,l]),[g,b]=v.ranges,{mapFunc:T}=v,m={row:g.startRow,col:g.startColumn};return W.getAutoFillRepeatRange(g,b).forEach(R=>{e(m,R.repeatStartCell,R.relativeRange,o,T)}),o.forEach((R,h)=>{const I=this._conditionalFormattingRuleModel.getRule(c,p,h);if(!I)return;const _=P.findAllRectangle(P.createTopMatrixFromMatrix(R));if(_.length){const C={unitId:c,subUnitId:p,rule:{...I,ranges:_}};f.push({id:r.SetConditionalRuleMutation.id,params:C}),d.push(...r.setConditionalRuleMutationUndoFactory(this._injector,C))}else{const C={unitId:c,subUnitId:p,cfId:I.cfId};f.push({id:r.DeleteConditionalRuleMutation.id,params:C}),d.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,C))}}),{undos:d,redos:f}},n={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(a,l,c)=>{if(c===W.APPLY_TYPE.COPY||c===W.APPLY_TYPE.ONLY_FORMAT||c===W.APPLY_TYPE.SERIES){const{source:p,target:o}=a;return u(p,o)}return t()}};this.disposeWithMe(this._autoFillService.addHook(n))}};De=vt([xe(0,i.Inject(i.Injector)),xe(1,i.Inject(i.IUniverInstanceService)),xe(2,i.Inject(W.IAutoFillService)),xe(3,i.Inject(r.ConditionalFormattingRuleModel)),xe(4,i.Inject(r.ConditionalFormattingViewModel))],De);var pt=Object.getOwnPropertyDescriptor,ft=(t,e,u,n)=>{for(var a=n>1?void 0:n?pt(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},Ne=(t,e)=>(u,n)=>e(u,n,t);D.ConditionalFormattingClearController=class extends i.Disposable{constructor(e,u,n,a,l){super(),this._injector=e,this._univerInstanceService=u,this._sheetInterceptorService=n,this._selectionManagerService=a,this._conditionalFormattingRuleModel=l,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var l;const u=[],n=[],a={redos:u,undos:n};if([P.ClearSelectionFormatCommand.id,P.ClearSelectionAllCommand.id].includes(e.id)){const c=(l=this._selectionManagerService.getCurrentSelections())==null?void 0:l.map(T=>T.range);if(!c)return a;const p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!o)return a;const f=p.getUnitId(),d=o.getSheetId(),v=this._conditionalFormattingRuleModel.getSubunitRules(f,d);if(!v||!v.length)return a;const{redos:g,undos:b}=mr(this._injector,v,c,f,d);u.push(...g),n.push(...b)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:u,ranges:n})=>{const a=[],l=[],c={redos:a,undos:l};if(!n||!n.length)return c;const p=this._conditionalFormattingRuleModel.getSubunitRules(e,u);if(!p||!p.length)return c;const{redos:o,undos:f}=mr(this._injector,p,n,e,u);return a.push(...o),l.push(...f),c}}))}},D.ConditionalFormattingClearController=ft([Ne(0,i.Inject(i.Injector)),Ne(1,i.Inject(i.IUniverInstanceService)),Ne(2,i.Inject(P.SheetInterceptorService)),Ne(3,i.Inject(P.SheetsSelectionsService)),Ne(4,i.Inject(r.ConditionalFormattingRuleModel))],D.ConditionalFormattingClearController);function mr(t,e,u,n,a){const l=[],c=[];return e.filter(p=>u.some(o=>p.ranges.some(f=>i.Rectangle.getIntersects(f,o)))).forEach(p=>{const f=new P.RangeMergeUtil().add(...p.ranges).subtract(...u).merge();if(f.length){const d={id:r.SetConditionalRuleMutation.id,params:{unitId:n,subUnitId:a,rule:{...p,ranges:f}}},v=r.setConditionalRuleMutationUndoFactory(t,d.params);l.push(d),c.push(...v)}else{const d={id:r.DeleteConditionalRuleMutation.id,params:{unitId:n,subUnitId:a,cfId:p.cfId}},v=r.DeleteConditionalRuleMutationUndoFactory(t,d.params);l.push(d),c.push(...v)}}),{redos:l,undos:c}}var ht=Object.getOwnPropertyDescriptor,gt=(t,e,u,n)=>{for(var a=n>1?void 0:n?ht(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},Sr=(t,e)=>(u,n)=>e(u,n,t);let je=class extends i.Disposable{constructor(t,e){super(),this._sheetInterceptorService=t,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(i.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(P.AFTER_CELL_EDIT,{handler:(t,e,u)=>{var c,p,o;t||u(t);const n=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),a=(c=n==null?void 0:n.style)!=null?c:{},l=Object.keys(a);if(t!=null&&t.p)return(o=(p=t.p.body)==null?void 0:p.textRuns)==null||o.forEach(f=>{f.ts&&l.forEach(d=>{var v;(v=f.ts)==null||delete v[d]})}),u(t);{const f={...(typeof(t==null?void 0:t.s)=="string"?e.workbook.getStyles().get(t.s):t==null?void 0:t.s)||{}};l.forEach(v=>{delete f[v]});const d={...t,s:{...f}};return u(d)}}})))}};je=gt([Sr(0,i.Inject(P.SheetInterceptorService)),Sr(1,i.Inject(r.ConditionalFormattingService))],je);const br=[P.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],Ee=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:Z.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:Z.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:Z.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:Z.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:Z.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:Z.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:Z.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:Z.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:Z.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:Z.clearWorkSheetRules}],yt=t=>{const e=t.get(P.SheetsSelectionsService),u=t.get(i.ICommandService),n=t.get(i.IUniverInstanceService),a=t.get(r.ConditionalFormattingRuleModel),l=new X.Observable(o=>X.merge(e.selectionMoveEnd$,e.selectionSet$,new X.Observable(f=>{const d=u.onCommandExecuted(v=>{var m;const{id:g,params:b}=v,T=(m=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();br.includes(g)&&b.unitId===T&&f.next(null)});return()=>d.dispose()})).pipe(fe.debounceTime(16)).subscribe(()=>{var m;const f=((m=e.getCurrentSelections())==null?void 0:m.map(E=>E.range))||[],d=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!d)return;const v=d.getActiveSheet();if(!v)return;const T=(a.getSubunitRules(d.getUnitId(),v.getSheetId())||[]).filter(E=>E.ranges.some(N=>f.some(M=>i.Rectangle.intersects(M,N)))).map(E=>E.ranges).every(E=>P.checkRangesEditablePermission(t,d.getUnitId(),v.getSheetId(),E));o.next(T)})),c=new X.Observable(o=>new X.Observable(f=>{const d=u.onCommandExecuted(v=>{var m;const{id:g,params:b}=v,T=(m=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();br.includes(g)&&b.unitId===T&&f.next(null)});return()=>d.dispose()}).pipe(fe.debounceTime(16)).subscribe(()=>{const f=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!f)return;const d=f.getActiveSheet();if(!d)return;const v=a.getSubunitRules(f.getUnitId(),d.getSheetId())||[];if(!v.length)return o.next(!1),!1;const g=v.map(b=>b.ranges).every(b=>P.checkRangesEditablePermission(t,f.getUnitId(),d.getSheetId(),b));o.next(g)})),p=new X.Observable(o=>{l.subscribe(f=>{const d=Ee.find(v=>v.value===Z.clearRangeRules);d&&(d.disabled=!f,o.next(Ee))}),c.subscribe(f=>{const d=Ee.find(v=>v.value===Z.clearWorkSheetRules);d&&(d.disabled=!f,o.next(Ee))}),o.next(Ee)});return{id:Se.id,type:j.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:p,hidden$:j.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(t,{workbookTypes:[P.WorkbookEditablePermission],worksheetTypes:[P.WorksheetSetCellStylePermission,P.WorksheetEditPermission],rangeTypes:[P.RangeProtectionPermissionEditPoint]})}},mt={[j.RibbonDataGroup.RULES]:{[Se.id]:{order:1,menuItemFactory:yt}}};var St=Object.getOwnPropertyDescriptor,bt=(t,e,u,n)=>{for(var a=n>1?void 0:n?St(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},Ir=(t,e)=>(u,n)=>e(u,n,t);let Le=class extends i.Disposable{constructor(e,u){super();ee(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=u,this._menuManagerService.mergeMenu(mt)}};Le=bt([Ir(0,i.Inject(i.Injector)),Ir(1,j.IMenuManagerService)],Le);var It=Object.getOwnPropertyDescriptor,Ct=(t,e,u,n)=>{for(var a=n>1?void 0:n?It(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},oe=(t,e)=>(u,n)=>e(u,n,t);const Tt=(t,e)=>{const u=d=>d.endRow-d.startRow+1,n=d=>d.endColumn-d.startColumn+1,a=u(e)%u(t),l=n(e)%n(t),c=Math.floor(u(e)/u(t)),p=Math.floor(n(e)/n(t)),o=[],f={startRow:0,endRow:u(t)-1,startColumn:0,endColumn:n(t)-1};if(u(e)===1&&n(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return o.push({repeatRelativeRange:f,startRange:d}),o}for(let d=0;d<c+(a?.1:0);d++)for(let v=0;v<p+(l?.1:0);v++){const g=u(t)*d,b=n(t)*v,T={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let m=f;d===c&&a&&(m={...m},m.endRow=m.endRow-(u(t)-a)),v===p&&l&&(m={...m},m.endColumn=m.endColumn-(n(t)-l)),o.push({repeatRelativeRange:m,startRange:T})}return o};let Ae=class extends i.Disposable{constructor(e,u,n,a,l,c){super();ee(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=u,this._formatPainterService=n,this._sheetsSelectionsService=a,this._conditionalFormattingRuleModel=l,this._conditionalFormattingViewModel=c,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),u=(l,c,p,o,f)=>{const{unitId:d,subUnitId:v}=this._painterConfig,{targetUnitId:g,targetSubUnitId:b}=f,T={startRow:l.row,startColumn:l.col,endColumn:l.col,endRow:l.row},m={startRow:c.row,startColumn:c.col,endColumn:c.col,endRow:c.row};i.Range.foreach(p,(E,N)=>{const M=i.Rectangle.getPositionRange({startRow:E,startColumn:N,endColumn:N,endRow:E},T),w=i.Rectangle.getPositionRange({startRow:E,startColumn:N,endColumn:N,endRow:E},m),R=this._conditionalFormattingViewModel.getCellCfs(d,v,M.startRow,M.startColumn),h=this._conditionalFormattingViewModel.getCellCfs(g,b,w.startRow,w.startColumn);h&&h.forEach(I=>{let _=o.get(I.cfId);if(!o.get(I.cfId)){const C=this._conditionalFormattingRuleModel.getRule(g,b,I.cfId);if(!C)return;_=new i.ObjectMatrix,C.ranges.forEach(U=>{i.Range.foreach(U,(V,k)=>{_.setValue(V,k,1)})}),o.set(I.cfId,_)}_.realDeleteValue(w.startRow,w.startColumn)}),R&&R.forEach(I=>{const _=o.get(I.cfId);_&&_.setValue(w.startRow,w.startColumn,1)})})},n=(l,c,p)=>{var M;const{range:o,unitId:f,subUnitId:d}=this._painterConfig,v=l!==f||d!==c,g=new Map,b=[],T=[];if(!l||!c||!f||!d)return e();const m=(M=this._conditionalFormattingRuleModel.getSubunitRules(f,d))!=null?M:[];m==null||m.forEach(w=>{const{ranges:R,cfId:h}=w;if(R.some(I=>i.Rectangle.intersects(o,I))){const I=new i.ObjectMatrix;v||R.forEach(_=>{i.Range.foreach(_,(C,U)=>{I.setValue(C,U,1)})}),g.set(h,I)}});const E={row:o.startRow,col:o.startColumn};return Tt(o,p).forEach(w=>{u(E,{row:w.startRange.startRow,col:w.startRange.startColumn},w.repeatRelativeRange,g,{targetUnitId:l,targetSubUnitId:c})}),g.forEach((w,R)=>{if(v){const h=this._conditionalFormattingRuleModel.getRule(l,c,R),I=P.findAllRectangle(P.createTopMatrixFromMatrix(w));if(h)if(I.length){const _={unitId:l,subUnitId:c,rule:{...h,ranges:I}};b.push({id:r.SetConditionalRuleMutation.id,params:_}),T.push(...r.setConditionalRuleMutationUndoFactory(this._injector,_))}else{const _={unitId:l,subUnitId:c,cfId:h.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:_}),T.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,_))}else if(I.length){const _=this._conditionalFormattingRuleModel.getRule(f,d,R);if(_){const C={unitId:l,subUnitId:c,rule:{...i.Tools.deepClone(_),cfId:this._conditionalFormattingRuleModel.createCfId(l,c),ranges:I}};b.push({id:r.AddConditionalRuleMutation.id,params:C}),T.push(r.AddConditionalRuleMutationUndoFactory(this._injector,C))}}}else{const h=this._conditionalFormattingRuleModel.getRule(f,d,R);if(!h)return;const I=P.findAllRectangle(P.createTopMatrixFromMatrix(w));if(I.length){const _={unitId:f,subUnitId:d,rule:{...h,ranges:I}};b.push({id:r.SetConditionalRuleMutation.id,params:_}),T.push(...r.setConditionalRuleMutationUndoFactory(this._injector,_))}else{const _={unitId:f,subUnitId:d,cfId:h.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:_}),T.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,_))}}}),{undos:T,redos:b}},a={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:l=>{var c,p,o;switch(l){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const f=(c=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:c.getUnitId(),d=(o=(p=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getActiveSheet())==null?void 0:o.getSheetId(),v=this._sheetsSelectionsService.getCurrentLastSelection(),g=v==null?void 0:v.range;f&&d&&g&&(this._painterConfig={unitId:f,subUnitId:d,range:g});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(l,c,p)=>this._painterConfig?n(l,c,p):{redos:[],undos:[]}};this._formatPainterService.addHook(a)}};Ae=Ct([oe(0,i.Inject(i.Injector)),oe(1,i.Inject(i.IUniverInstanceService)),oe(2,i.Inject(W.IFormatPainterService)),oe(3,i.Inject(P.SheetsSelectionsService)),oe(4,i.Inject(r.ConditionalFormattingRuleModel)),oe(5,i.Inject(r.ConditionalFormattingViewModel))],Ae);var _t=Object.getOwnPropertyDescriptor,xt=(t,e,u,n)=>{for(var a=n>1?void 0:n?_t(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},tr=(t,e)=>(u,n)=>e(u,n,t);let Fe=class extends i.Disposable{constructor(t,e,u){super(),this._conditionalFormattingViewModel=t,this._univerInstanceService=e,this._renderManagerService=u,this._init()}_init(){const t=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),e=u=>{const n=u.getUnitId(),a=this._renderManagerService.getRenderById(n);if(!a)return;const l=a.with(W.SheetSkeletonManagerService);this.disposeWithMe(l.currentSkeleton$.subscribe(c=>{if(c){const p=c.skeleton.rowColumnSegment,o=p.endColumn-p.startColumn+1,d=(p.endRow-p.startRow+1)*o*9,v=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(v)}}))};t&&e(t),this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(u=>{u&&e(u)})}};Fe=xt([tr(0,i.Inject(r.ConditionalFormattingViewModel)),tr(1,i.IUniverInstanceService),tr(2,ar.IRenderManagerService)],Fe);var Nt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Mt=(t,e,u)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,Rt=(t,e,u,n)=>{for(var a=n>1?void 0:n?Et(e,u):e,l=t.length-1,c;l>=0;l--)(c=t[l])&&(a=c(a)||a);return a},nr=(t,e)=>(u,n)=>e(u,n,t),Cr=(t,e,u)=>Mt(t,typeof e!="symbol"?e+"":e,u);D.UniverSheetsConditionalFormattingUIPlugin=class extends i.Plugin{constructor(e=Pe,u,n,a){super(),this._config=e,this._injector=u,this._commandService=n,this._configService=a;const{menu:l,...c}=i.merge({},Pe,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(gr,c),this._initCommand()}onStarting(){i.registerDependencies(this._injector,[[_e],[Te],[Ie],[De],[Ce],[me],[Le],[se],[je],[D.ConditionalFormattingClearController],[Ae],[Fe]]),i.touchDependencies(this._injector,[[_e]])}onReady(){i.touchDependencies(this._injector,[[Le],[me]])}onRendered(){i.touchDependencies(this._injector,[[De],[D.ConditionalFormattingClearController],[Ie],[je],[se],[Ae],[Ce],[Te],[Fe]])}_initCommand(){[He,We,qe,Ge,ze,Ye,Ze,Ke,Xe,Se].forEach(e=>{this._commandService.registerCommand(e)})}},Cr(D.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Cr(D.UniverSheetsConditionalFormattingUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingUIPlugin=Rt([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin),nr(1,i.Inject(i.Injector)),nr(2,i.Inject(i.ICommandService)),nr(3,i.IConfigService)],D.UniverSheetsConditionalFormattingUIPlugin),D.AddAverageCfCommand=He,D.AddColorScaleConditionalRuleCommand=We,D.AddDataBarConditionalRuleCommand=qe,D.AddDuplicateValuesCfCommand=Ge,D.AddNumberCfCommand=ze,D.AddRankCfCommand=Ye,D.AddTextCfCommand=Ze,D.AddTimePeriodCfCommand=Ke,D.AddUniqueValuesCfCommand=Xe,D.OpenConditionalFormattingOperator=Se,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
12
11
 
13
12
 
14
13
  // index
15
- (function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets-conditional-formatting-ui"),require("@univerjs/sheets-conditional-formatting/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets-conditional-formatting","@univerjs/sheets-conditional-formatting-ui","@univerjs/sheets-conditional-formatting/facade"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.UniverPresetSheetsConditionalFormatting={},e.UniverSheetsConditionalFormatting,e.UniverSheetsConditionalFormattingUi))})(this,function(e,i,n){"use strict";function t(){return{plugins:[i.UniverSheetsConditionalFormattingPlugin,n.UniverSheetsConditionalFormattingUIPlugin].filter(o=>!!o)}}e.UniverSheetsConditionalFormattingPreset=t,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
14
+ (function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets-conditional-formatting-ui"),require("@univerjs/sheets-conditional-formatting/lib/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets-conditional-formatting","@univerjs/sheets-conditional-formatting-ui","@univerjs/sheets-conditional-formatting/lib/facade"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.UniverPresetSheetsConditionalFormatting={},e.UniverSheetsConditionalFormatting,e.UniverSheetsConditionalFormattingUi))})(this,function(e,i,n){"use strict";function t(){return{plugins:[i.UniverSheetsConditionalFormattingPlugin,n.UniverSheetsConditionalFormattingUIPlugin].filter(o=>!!o)}}e.UniverSheetsConditionalFormattingPreset=t,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-conditional-formatting",
3
- "version": "0.7.0",
3
+ "version": "0.8.0-beta.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,16 +57,16 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/sheets-conditional-formatting": "0.7.0",
61
- "@univerjs/sheets-conditional-formatting-ui": "0.7.0"
60
+ "@univerjs/sheets-conditional-formatting": "0.8.0-beta.0",
61
+ "@univerjs/sheets-conditional-formatting-ui": "0.8.0-beta.0"
62
62
  },
63
63
  "devDependencies": {
64
- "@univerjs/core": "0.7.0",
64
+ "@univerjs/core": "0.8.0-beta.0",
65
65
  "react": "18.3.1",
66
66
  "react-dom": "18.3.1",
67
67
  "rxjs": "7.8.2",
68
68
  "typescript": "^5.8.3",
69
- "@univerjs-infra/shared": "0.7.0"
69
+ "@univerjs-infra/shared": "0.8.0-beta.0"
70
70
  },
71
71
  "scripts": {
72
72
  "prebuild:preset": "tsx prepare.ts",