import{_ as E}from"./nselect.vue-beh7ue6r.js";import{u as F,c as U,a as W,_ as q}from"./m6q5jxyf.js";import{_ as z}from"./nswitch.vue-jbyu7ls8.js";import{_ as J}from"./ndropdown.vue-g7muyou7.js";import{_ as O}from"./ncode-block.vue-bir2wz4z.js";import{_ as P}from"./ndrawer.vue-l1gwm2vb.js";import{A as h,d as x}from"./vendor/quicktype-core-o2aektoq.js";import{p as Q,f as k,q as N,j as C,S as c,R as m,a1 as n,a3 as d,a2 as r,Q as i,P as f,F as D,ae as j,u as _,a8 as b,ac as R}from"./vendor/json-editor-vue-llkaejaf.js";import"./vendor/unocss-mvzv9iuf.js";import"./vendor/shiki-kdj4mcqm.js";import"./client-gsjyqe32.js";const G={border:"b base",flex:"~ items-center gap-2",sticky:"","left-0":"","right-0":"","top-0":"","z-1":"",p3:"","bg-base":""},H={key:0,flex:"~ items-center justify-center",absolute:"","bottom--1":"","right--2":"","h-4":"","w-4":"","rounded-full":"","bg-lime:30":"","text-8px":""},K={flex:"~ col","w-100":"","of-auto":"",py2:""},M={"text-xs":"",capitalize:"",op75:""},ie=Q({__name:"DataSchemaDrawer",setup(X){const s=F(),V=k(0),l=k("TypeScript"),v=N(()=>h.all.find(e=>e.displayName===l.value)),o=k(v.value?.optionDefinitions.filter(e=>typeof e.defaultValue=="boolean")),y=U(async()=>{if(V.value,!s.value)return"";const e=x.jsonInputForTargetLanguage(l.value);await e.addSource({name:s.value.name??"Data",samples:[s.value.input]});const t=new x.InputData;return t.addInput(e),(await x.quicktype({inputData:t,lang:l.value,rendererOptions:o.value?.reduce((u,p)=>(u[p.name]=p.defaultValue,u),{})})).lines.join(`
`)}),S=N(()=>{const e=l.value.toLocaleLowerCase();return e.startsWith("javascript")?"javascript":e.startsWith("json")?"json":e.startsWith("typescript")?"typescript":e});C(o,()=>{V.value++},{deep:!0}),C(l,()=>{o.value=v.value?.optionDefinitions.filter(e=>typeof e.defaultValue=="boolean")});const $=W();function B(){$(y.value||"")}return(e,t)=>{const w=E,u=q,p=z,L=J,I=O,T=P;return v.value?(n(),c(R,{key:0,to:"body"},[d(T,{"model-value":!!_(s)?.input,"auto-close":"","max-w-screen":"","w-2xl":"","n-code-block":"",onClose:t[2]||(t[2]=a=>s.value=null)},{default:r(()=>[i("div",G,[t[3]||(t[3]=i("p",{"mr-2":""}," Schema ",-1)),d(w,{modelValue:l.value,"onUpdate:modelValue":t[0]||(t[0]=a=>l.value=a),n:"xs primary"},{default:r(()=>[(n(!0),f(D,null,j(_(h.all),a=>(n(),f("option",{key:a.displayName},b(a.displayName),1))),128))]),_:1},8,["modelValue"]),o.value?.length?(n(),c(L,{key:0,n:"sm lime"},{trigger:r(({click:a})=>[d(u,{icon:"carbon-settings","h-full":"",onClick:g=>a()},null,8,["onClick"]),o.value?(n(),f("span",H,b(o.value.length),1)):m("",!0)]),default:r(()=>[i("div",K,[(n(!0),f(D,null,j(o.value,(a,g)=>(n(),c(p,{key:a.name,modelValue:o.value[g].defaultValue,"onUpdate:modelValue":A=>o.value[g].defaultValue=A,flex:"~ gap-2",rounded:"",px2:"",py2:""},{default:r(()=>[i("span",M,b(a.description),1)]),_:2},1032,["modelValue","onUpdate:modelValue"]))),128))])]),_:1})):m("",!0),t[4]||(t[4]=i("div",{"flex-auto":""},null,-1)),d(u,{icon:"carbon-copy","mr-6":"","h-full":"",onClick:t[1]||(t[1]=a=>B())})]),_(y)?(n(),c(I,{key:0,lang:S.value,code:_(y)},null,8,["lang","code"])):m("",!0)]),_:1},8,["model-value"])])):m("",!0)}}});export{ie as default};
