"use strict";var e=require('./../../ext-esm/tslib/tslib.es6.js'),n=require("react/jsx-runtime"),t=require("react"),r=require("classnames"),o=require("lodash"),i=require("@material-ui/core"),a=require("@material-ui/lab/Autocomplete"),l=require("@material-ui/icons/Close"),u=require("../Tooltip/Tooltip.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../Tooltip/ScrollableTooltip.js");var p=s(r),c=s(a),d=s(l),f=function(e){return o.get(o.get(e.split('Create "'),"1","").split('"'),"0","")},g=i.makeStyles((function(e){return{root:{width:200},paper:{maxHeight:400,boxShadow:"0px 5px 5px -3px rgb(0 0 0 / 20%), 0px 8px 10px 1px rgb(0 0 0 / 14%), 0px 3px 14px 2px rgb(0 0 0 / 12%)",margin:0},createLabel:{fontSize:"16px",lineHeight:"22.5px",color:e.palette.primary.main},openIcon:{marginLeft:5},option:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",width:"100%"},closeIcon:{width:16,height:16}}}));module.exports=function(r){var i=r.isCreatable,a=r.options,l=r.value,s=r.getOptionLabel,x=r.onInputChange,h=r.onChange,m=void 0===h?o.noop:h,v=r.renderOption,_=r.classes,b=e.__rest(r,["isCreatable","options","value","getOptionLabel","onInputChange","onChange","renderOption","classes"]),C=g(),q=t.useMemo((function(){return null==a?void 0:a.map((function(e){return i?s(e):e}))}),[a]),j=t.useMemo((function(){return i?s(l)||"":l}),[l]),I=t.useState(q),w=I[0],S=I[1],y=t.useState(null),L=y[0],O=y[1];t.useEffect((function(){S(q)}),[q]);return n.jsx(c.default,e.__assign({value:j,onChange:i?function(n,t){return function(n){if((null==n?void 0:n.includes('Create "'))&&s(n)===s(L)){O(null);var t=f(L);S(e.__spreadArray(e.__spreadArray([],q,!0),[t],!1)),m(t,!0)}else m(n,!1)}(t)}:m,onInputChange:i?function(n,t){return function(n){if(""===n)O(null),S(q);else if(q.find((function(e){return e===n}))){var t=q.filter((function(e){return!e.includes('Create "')}));S(t)}else{var r=function(e){return'Create "'.concat(e,'"')}(n);O(r),S(e.__spreadArray(e.__spreadArray([],q,!0),[r],!1))}}(t)}:x,options:w,getOptionLabel:i?function(e){return String(e)}:s,renderOption:i?function(t){var r,o=f(t);return n.jsx(u.Tooltip,e.__assign({title:t},{children:n.jsx("div",e.__assign({className:p.default((r={},r[C.createLabel]=o&&t!==o,r),C.option,null==_?void 0:_.optionLabelClass)},{children:t}))}))}:v,classes:e.__assign({root:p.default(C.root,null==_?void 0:_.root),paper:p.default(C.paper,null==_?void 0:_.paper),popupIndicator:C.openIcon},_),closeIcon:(j||L)&&n.jsx(d.default,{className:C.closeIcon})},b))};
