import{q as h,bg as y,B as i,t as c,bp as S,bq as P,b5 as V,v as C}from"./index.10c3f8e5.js";import{u as q}from"./use-response-handle.23bba72b.js";const R={api:{type:Function,required:!0},value:{type:String},requestProp:{type:String},responseLabelProp:{type:String},responseValProp:{type:String},placeholder:{type:String}};function j(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!V(e)}const w=h({name:"RemoteSelect",props:R,emits:["listChange","itemChange"],setup(e,{emit:n}){const s=y(e,"value"),d=q(),l=i([]),o=i(!1);async function m(a){if(!a)return;const{responseLabelProp:t,responseValProp:r,requestProp:u,api:g}=e;o.value=!0;const{code:b,data:f,message:v}=await g({[u||t]:a});d({code:b,message:v,handler:()=>{l.value=f.list.map(p=>({label:p[t],value:p[r]})),n("listChange",C(l))}}),o.value=!1}return()=>{let a;return c(P,{modelValue:s.value,"onUpdate:modelValue":t=>s.value=t,placeholder:e.placeholder,remoteMethod:m,loading:o.value,reserveKeyword:!0,filterable:!0,clearable:!0,remote:!0,onChange:()=>n("itemChange")},j(a=l.value.map((t,r)=>c(S,{label:t.label,key:r,value:t.value},null)))?a:{default:()=>[a]})}}});export{w as R};
