import{d as I,u as D,w as E,o as t,P as L,g as C,i as d,e as n,t as l,h as r,y as P,F as S,G as F,b6 as N,b5 as U,r as b,k as V,L as G,_ as K}from"./index-D92x6h1h.js";const M={class:"idnode-pick-class"},j={key:0,class:"idnode-pick-class__error",role:"alert"},q={key:1,class:"idnode-pick-class__status"},z={key:2,class:"idnode-pick-class__status"},A={key:3,class:"idnode-pick-class__field"},H={class:"idnode-pick-class__label"},J=["aria-label"],O=["value"],Q=["disabled"],R=I({__name:"IdnodePickClassDialog",props:{visible:{type:Boolean},buildersEndpoint:{},title:{},label:{}},emits:["pick","close"],setup(o,{emit:g}){const{t:u}=D();function c(e){return e.class??e.name??""}function k(e){return e.title??e.caption??c(e)}const f=o,y=g,_=b(!1),p=b(null),v=b([]),i=b("");async function w(){_.value=!0,p.value=null;try{const a=((await G(f.buildersEndpoint)).entries??[]).filter(s=>!!c(s));a.sort((s,x)=>k(s).localeCompare(k(x))),v.value=a,i.value=a[0]?c(a[0]):""}catch(e){p.value=e instanceof Error?e.message:String(e),v.value=[],i.value=""}finally{_.value=!1}}E(()=>f.visible,e=>{e&&w()},{immediate:!0});const m=V(()=>!_.value&&!!i.value);function B(){m.value&&y("pick",i.value)}function h(){y("close")}return(e,a)=>(t(),L(r(U),{visible:o.visible,header:o.title,modal:"",closable:!0,draggable:!1,style:{width:"420px"},"onUpdate:visible":a[1]||(a[1]=s=>{s||h()})},{footer:C(()=>[d("button",{type:"button",class:"idnode-pick-class__btn",onClick:h},l(r(u)("Cancel")),1),d("button",{type:"button",class:"idnode-pick-class__btn idnode-pick-class__btn--primary",disabled:!m.value,onClick:B},l(r(u)("Continue")),9,Q)]),default:C(()=>[d("div",M,[p.value?(t(),n("p",j,l(p.value),1)):_.value?(t(),n("p",q,l(r(u)("Loading types…")),1)):v.value.length===0?(t(),n("p",z,l(r(u)("No types available.")),1)):(t(),n("label",A,[d("span",H,l(o.label),1),P(d("select",{"onUpdate:modelValue":a[0]||(a[0]=s=>i.value=s),class:"idnode-pick-class__select","aria-label":o.label},[(t(!0),n(S,null,F(v.value,s=>(t(),n("option",{key:c(s),value:c(s)},l(k(s)),9,O))),128))],8,J),[[N,i.value]])]))])]),_:1},8,["visible","header"]))}}),W=K(R,[["__scopeId","data-v-c989cafe"]]);export{W as I};
