import{_ as A}from"./nselect.vue-pdhj5atk.js";import{u as E,c as F,a as W,_ as q}from"./nfr71ycs.js";import{_ as z}from"./nswitch.vue-bpoo3j7g.js";import{_ as J}from"./ndropdown.vue-n11pas9i.js";import{_ as O}from"./ncode-block.vue-ctkw4rc7.js";import{_ as G}from"./ndrawer.vue-gbiu9bgk.js";import{A as h,d as x}from"./vendor/quicktype-core-dsrweb93.js";import{p as H,k,q as N,x as C,V as c,U as m,a3 as n,a5 as d,a4 as r,S as i,J as f,F as D,ag as S,u as _,aa as V,ae as K}from"./vendor/json-editor-vue-m9gzt21j.js";import"./vendor/unocss-oyl7opas.js";import"./vendor/shiki-imfwxqoq.js";import"./client-oeqdl4pb.js";const M={border:"b base",flex:"~ items-center gap-2",sticky:"","left-0":"","right-0":"","top-0":"","z-1":"","bg-base":"",p3:""},P={key:0,flex:"~ items-center justify-center",absolute:"","bottom--1":"","right--2":"","h-4":"","w-4":"","rounded-full":"","bg-lime:30":"","text-8px":""},Q={flex:"~ col","w-100":"","of-auto":"",py2:""},R={"text-xs":"",capitalize:"",op75:""},ie=H({__name:"DataSchemaDrawer",setup(X){const s=E(),b=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=F(async()=>{if(b.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(`
`)}),j=N(()=>{const e=l.value.toLocaleLowerCase();return e.startsWith("javascript")?"javascript":e.startsWith("json")?"json":e.startsWith("typescript")?"typescript":e});C(o,()=>{b.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=A,u=q,p=z,L=J,I=O,T=G;return v.value?(n(),c(K,{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",M,[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,S(_(h.all),a=>(n(),f("option",{key:a.displayName},V(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",P,V(o.value.length),1)):m("",!0)]),default:r(()=>[i("div",Q,[(n(!0),f(D,null,S(o.value,(a,g)=>(n(),c(p,{key:a.name,modelValue:o.value[g].defaultValue,"onUpdate:modelValue":U=>o.value[g].defaultValue=U,flex:"~ gap-2",rounded:"",px2:"",py2:""},{default:r(()=>[i("span",R,V(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:j.value,code:_(y)},null,8,["lang","code"])):m("",!0)]),_:1},8,["model-value"])])):m("",!0)}}});export{ie as default};
