import{__assign as o}from'./../../ext-esm/tslib/tslib.es6.js';import{jsxs as s,jsx as i}from"react/jsx-runtime";import{ListSubheader as n,MenuItem as t}from"@material-ui/core";import e from"@material-ui/icons/AddCircle";import{useState as r}from"react";import c from"classnames";import{isEmpty as a}from"lodash";import{GradientPreview as m}from"./GradientPreview/GradientPreview.js";import d from"../Select/index.js";import l from"../IconButton/index.js";import{useStyles as u}from"./GradientSelect.styles.js";import{DeleteFourIcon as p}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 I=function(I){var j=I.value,f=I.gradients,h=I.onChange,v=I.defaultGradients,C=I.onAction,g=I.readonly,b=u(),G=r(!1),k=G[0],P=G[1],x=function(o){var s,i;if(o.stopPropagation(),!g){var n=null===(i=null===(s=o.currentTarget.closest("li"))||void 0===s?void 0:s.dataset)||void 0===i?void 0:i.value;j===n&&P(!1),C("delete",n)}},F=a(f)&&g;return s(d,o({"data-testid":"gradient-select",label:"Gradients",value:j||"",className:b.select,onChange:function(o){var s=o.target;s.value&&h(s.value)},open:k,onClose:function(){return P(!1)},onOpen:function(){return P(!0)},inputProps:{name:"gradientId",id:"gradientId"},FormControlProps:{fullWidth:!0},fullWidth:!0,defaultValue:"",InputLabelProps:{shrink:!0}},{children:[i(n,o({className:b.listHeader},{children:"Gradients"})),!F&&s(n,o({className:b.subHeader},{children:["My Gradients",!g&&i(l,o({color:"primary","data-testid":"add-gradient-btn",className:b.addButton,onClick:function(){return C("add")},tooltipProps:{title:"Create Custom Gradient"}},{children:i(e,{color:"primary"})}))]})),f.map((function(n){var e=n.id,r=n.name,a=n.gradientStops;return s(t,o({value:e,className:b.customGradientListItem},{children:[i(m,{gradientStops:a}),i("span",{children:r}),i(l,o({className:c({disabled:g}),onClick:x,tooltipProps:{title:"Remove Gradient"},size:"medium"},{children:i(p,{})}))]}),e)})),!a(v)&&i(n,o({className:b.subHeader},{children:"Default Gradients"})),v.map((function(n){var e=n.id,r=n.name,c=n.gradientStops;return s(t,o({value:e,className:b.customGradientListItem},{children:[i(m,{gradientStops:c}),i("span",{children:r})]}),e)}))]}))};export{I as GradientSelect};
