import{jsxs as o,jsx as s}from"react/jsx-runtime";import{ListSubheader as i,MenuItem as n}from"@material-ui/core";import t from"@material-ui/icons/AddCircle";import{useState as e}from"react";import c from"classnames";import{isEmpty as r}from"lodash";import{GradientPreview as a}from"./GradientPreview/GradientPreview.js";import m from"../Select/index.js";import d from"../IconButton/index.js";import{useStyles as l}from"./GradientSelect.styles.js";import{DeleteFourIcon as u}from"../../icons/iconParkIcons.js";import"../../icons/customIcons/icons/AddMessage.js";import"../../icons/customIcons/icons/Attention.js";import"../../icons/customIcons/icons/Collapse.js";import"../../icons/customIcons/icons/Dashboard.js";import"../../icons/customIcons/icons/Expand.js";import"../../icons/customIcons/icons/FolderClosed.js";import"../../icons/customIcons/icons/FolderClosedFilled.js";import"../../icons/customIcons/icons/FolderOpened.js";import"../../icons/customIcons/icons/GreaterOrEqual.js";import"../../icons/customIcons/icons/LessOrEqual.js";import"../../icons/customIcons/icons/Search.js";import"../../icons/customIcons/icons/Wellhub.js";import"../../icons/customIcons/icons/MultiRuler.js";import"../../icons/customIcons/icons/Checkbox.js";import"../../icons/customIcons/icons/CheckboxChecked.js";import"../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../icons/customIcons/icons/Radio.js";import"../../icons/customIcons/icons/RadioChecked.js";import"../../icons/customIcons/icons/SimulFrac.js";import"../../icons/customIcons/icons/ZipperFrac.js";import"../../icons/customIcons/icons/CautionFilled.js";import"../../icons/customIcons/icons/MoreApp.js";var p=function(p){var I=p.value,j=p.gradients,f=p.onChange,h=p.defaultGradients,v=p.onAction,C=p.readonly,g=l(),G=e(!1),b=G[0],k=G[1],P=function(o){var s,i;if(o.stopPropagation(),!C){var n=null===(i=null===(s=o.currentTarget.closest("li"))||void 0===s?void 0:s.dataset)||void 0===i?void 0:i.value;I===n&&k(!1),v("delete",n)}},x=r(j)&&C;return o(m,{"data-testid":"gradient-select",label:"Gradients",value:I||"",className:g.select,onChange:function(o){var s=o.target;s.value&&f(s.value)},open:b,onClose:function(){return k(!1)},onOpen:function(){return k(!0)},inputProps:{name:"gradientId",id:"gradientId"},FormControlProps:{fullWidth:!0},fullWidth:!0,defaultValue:"",InputLabelProps:{shrink:!0},children:[s(i,{className:g.listHeader,children:"Gradients"}),!x&&o(i,{className:g.subHeader,children:["My Gradients",!C&&s(d,{color:"primary","data-testid":"add-gradient-btn",className:g.addButton,onClick:function(){return v("add")},tooltipProps:{title:"Create Custom Gradient"},children:s(t,{color:"primary"})})]}),j.map((function(i){var t=i.id,e=i.name,r=i.gradientStops;return o(n,{value:t,className:g.customGradientListItem,children:[s(a,{gradientStops:r}),s("span",{children:e}),s(d,{className:c({disabled:C}),onClick:P,tooltipProps:{title:"Remove Gradient"},size:"medium",children:s(u,{})})]},t)})),!r(h)&&s(i,{className:g.subHeader,children:"Default Gradients"}),h.map((function(i){var t=i.id,e=i.name,c=i.gradientStops;return o(n,{value:t,className:g.customGradientListItem,children:[s(a,{gradientStops:c}),s("span",{children:e})]},t)}))]})};export{p as GradientSelect};
