import{i as e,t}from"./react-B8IZ02wI.js";import{t as n}from"./select-CDwQ-YxO.js";import{N as r}from"./authStore-BvQBJ9ky.js";import{n as i}from"./index-Bg7bo8aA.js";var a=e(t(),1),o=i();function s(e){if(!e.length)return;let t=e.find(e=>e.name.includes(`公司总库`)||e.name===`总库`);if(t)return t.id;let n=e.find(e=>/^(WH-001|COMPANY|HQ)$/i.test(e.code||``));return n?n.id:e[0].id}function c({value:e,onChange:t,placeholder:i=`选择库房`,allowClear:c=!0,disabled:l,style:u,autoSelectDefault:d=!1}){let[f,p]=(0,a.useState)([]);return(0,a.useEffect)(()=>{let e=!1;return r.options().then(t=>{e||p((t.data||[]).map(e=>({value:e.id,label:e.name,code:e.code||``})))}).catch(()=>{e||p([])}),()=>{e=!0}},[]),(0,a.useEffect)(()=>{if(!d||e!=null||!f.length)return;let n=s(f.map(e=>({id:e.value,name:e.label,code:e.code})));n!=null&&t?.(n)},[d,e,f]),(0,o.jsx)(n,{value:e??void 0,onChange:e=>t?.(e),options:f.map(({value:e,label:t})=>({value:e,label:t})),placeholder:i,allowClear:c,disabled:l,style:{width:`100%`,...u},showSearch:!0,optionFilterProp:`label`})}export{s as n,c as t};