"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../tslib.es6-C4EgNkz1.js"),o=require("react"),N=require("classnames"),B=require("../forwardRef-DBQKIlPy.js"),R=require("../utils-C9NL3q0j.js"),V=require("../hooks-uidlIIid.js"),k=require("../icons/ebay-icon-chevron-down-12/index.js"),h=t=>{var{children:e}=t,r=f.__rest(t,["children"]);return o.createElement("option",Object.assign({},r),e)},_=t=>typeof t<"u",x=t=>{var{value:e,defaultValue:r,className:n,borderless:u,name:i,disabled:s,onChange:g=()=>{},onBlur:p=()=>{},onFocus:d=()=>{},floatingLabel:b,forwardedRef:l,children:m,inputSize:y,invalid:E}=t,a=f.__rest(t,["value","defaultValue","className","borderless","name","disabled","onChange","onBlur","onFocus","floatingLabel","forwardedRef","children","inputSize","invalid"]);const v=E||a["aria-invalid"]==="true",[w,O]=o.useState(r),C=V.useFloatingLabel({text:b,disabled:s,size:y,invalid:v}),F=c=>{const{value:S,selectedIndex:L}=c.target;_(e)||O(S),g(c,{index:L,selected:[S]})},G=c=>{p(c)},q=c=>{d(c)},j=N("select",n,{"select--borderless":u,"select--large":y==="large"});return o.createElement(C.Container,null,o.createElement(C.Label,{htmlFor:a.id}),o.createElement("span",{className:j},o.createElement("select",Object.assign({},a,{name:i,value:_(e)?e:w,disabled:s,onChange:F,onBlur:G,onFocus:q,ref:l}),z(m)),o.createElement(k.EbayIconChevronDown12,{height:"8",width:"8"})))},I=B.withForwardRef(x);function P(t){const e={};return t.forEach(r=>{const n=r.props;n.optgroup&&(Object.prototype.hasOwnProperty.call(e,n.optgroup)||(e[n.optgroup]=[]),e[n.optgroup].push(n))}),e}function z(t){const e=[],r=[];let n={},u=!1;const i=R.filterByType(t,h).map(s=>o.cloneElement(s,{}));if(i){n=P(i);let s;return i.forEach((g,p)=>{const d=g.props,{children:b,optgroup:l}=d,m=f.__rest(d,["children","optgroup"]);if(u=l&&e.indexOf(l)===-1,u){s=l;const E=n[s].map(a=>{const{children:v,optgroup:w}=a,O=f.__rest(a,["children","optgroup"]);return o.createElement(h,Object.assign({key:`opt-${a.value}`},O),v)});r.push(o.createElement("optgroup",{key:p,label:l},E)),e.push(l)}else l||r.push(o.createElement(h,Object.assign({key:p},m),b))}),r}}exports.EbaySelect=I;exports.EbaySelectOption=h;
