import{q as h,bb as y,B as i,t as c,bj as S,bk as P,b1 as V,v as C}from"./index.7a111e62.js";import{u as R}from"./use-response-handle.f995d678.js";const j={api:{type:Function,required:!0},value:{type:String},requestProp:{type:String},responseLabelProp:{type:String},responseValProp:{type:String},placeholder:{type:String}};function q(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!V(e)}const k=h({name:"RemoteSelect",props:j,emits:["listChange","itemChange"],setup(e,{emit:n}){const s=y(e,"value"),d=R(),l=i([]),o=i(!1);async function m(a){if(!a)return;const{responseLabelProp:t,responseValProp:r,requestProp:u,api:b}=e;o.value=!0;const{code:f,data:g,message:v}=await b({[u||t]:a});d({code:f,message:v,handler:()=>{l.value=g.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")},q(a=l.value.map((t,r)=>c(S,{label:t.label,key:r,value:t.value},null)))?a:{default:()=>[a]})}}});export{k as R};
