import{m as v,v as R,t as j,k as F,h as G,r as o,j as a,ay as V,W as D}from"./index-E0AVXOTn.js";import{S as Q}from"./search-NhYI7xr8.js";const W=v.form(["width:100%;display:flex;justify-content:space-between;align-items:center;margin:16px 0 0 auto;gap:8px;display:grid;grid-template-columns:1fr 2fr;","{width:60%;margin:20px 0 0 auto;}"],R.SM),Y=v.div(["width:100%;height:100%;> div{height:100%;> div:first-of-type{height:100%;}}"]),q=v.div(["width:100%;height:100%;position:relative;input{height:100%;padding:var(--spacing-10) var(--spacing-40) var(--spacing-10) var(--spacing-16);background-color:",";}button{position:absolute;top:50%;right:12px;transform:translateY(-50%);svg{width:16px;height:16px;path{stroke:",";}}}"],j.lightGray,j.darkGray),p={SearchForm:W,SelectContainer:Y,InputContainer:q},B=({searchTypeList:r,customKeyInfo:n,isOnlyKeywordUsable:s,placeholder:w="검색어 입력",containerStyle:C})=>{const S=(n==null?void 0:n.searchType)??"searchType",l=(n==null?void 0:n.searchKeyword)??"searchKeyword",{t:E}=F(),[u,M]=G(),b=u.get(S)??"",f=o.useMemo(()=>{var e;return s?((e=r.find(c=>u.has(c.value)))==null?void 0:e.value)??"":l},[u,r,l,s]),h=u.get(f)??"",[t,k]=o.useState(()=>s?r.find(e=>e.value===f)??r[0]??null:r.find(e=>e.value===b)??r[0]??null),i=o.useRef(null),P=e=>{e.preventDefault(),i.current&&M(c=>{var x;if(s){const d=new URLSearchParams(c);return r.forEach(g=>{var m;if(g.value===(t==null?void 0:t.value)){d.set(g.value,((m=i.current)==null?void 0:m.value)??"");return}d.delete(g.value)}),d.toString()}return{...Object.fromEntries(c),[l]:((x=i.current)==null?void 0:x.value)??"",[S]:(t==null?void 0:t.value)??""}},{replace:!0})};return o.useEffect(()=>{i.current&&h&&(i.current.value=h)},[h]),a.jsxs(p.SearchForm,{onSubmit:P,style:C,children:[a.jsx(p.SelectContainer,{children:a.jsx(V,{options:r,value:t,onChange:e=>{k(e)}})}),a.jsxs(p.InputContainer,{children:[a.jsx(D,{ref:i,placeholder:E(w)}),a.jsx("button",{children:a.jsx(Q,{})})]})]})};export{B as M};