import{_ as E}from"./nselect-h7b4tp2d.js";import{u as F,c as U,a as $,_ as q}from"#entry";import{_ as z}from"./nswitch-ikgdy16r.js";import{_ as J}from"./ndropdown-gskb7sy5.js";import{_ as O}from"./ncode-block-esxkr86l.js";import{_ as X}from"./ndrawer-j5h6fmbh.js";import{A as h,d as x}from"./vendor/quicktype-core-jsgpnknz.js";import{p as Z,k,q as D,x as N,W as c,a3 as m,X as n,a0 as d,Z as r,a2 as p,J as _,F as C,ag as S,u as f,aa as b,ae as G}from"./vendor/json-editor-vue-ho2zu772.js";import"./vendor/shiki-g7cm1eew.js";import"./vendor/unocss-b6xarsb2.js";import"./client-c6aoxv2l.js";const H={border:"b base",flex:"~ items-center gap-2",sticky:"","left-0":"","right-0":"","top-0":"","z-1":"","bg-base":"",p3:""},K={key:0,flex:"~ items-center justify-center",absolute:"","bottom--1":"","right--2":"","h-4":"","w-4":"","rounded-full":"","bg-lime:30":"","text-8px":""},M={flex:"~ col","w-100":"","of-auto":"",py2:""},P={"text-xs":"",capitalize:"",op75:""},Q=Z({__name:"DataSchemaDrawer",setup(R){const s=F(),w=k(0),l=k("TypeScript"),v=D(()=>h.all.find(e=>e.displayName===l.value)),o=k(v.value?.optionDefinitions.filter(e=>typeof e.defaultValue=="boolean")),y=U(async()=>{if(w.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,i)=>(u[i.name]=i.defaultValue,u),{})})).lines.join(`
`)}),j=D(()=>{const e=l.value.toLocaleLowerCase();return e.startsWith("javascript")?"javascript":e.startsWith("json")?"json":e.startsWith("typescript")?"typescript":e});N(o,()=>{w.value++},{deep:!0}),N(l,()=>{o.value=v.value?.optionDefinitions.filter(e=>typeof e.defaultValue=="boolean")});const B=$();function L(){B(y.value||"")}return(e,t)=>{const V=E,u=q,i=z,I=J,T=O,W=X;return v.value?(n(),c(G,{key:0,to:"body"},[d(W,{"model-value":!!f(s)?.input,"auto-close":"","max-w-screen":"","w-2xl":"","n-code-block":"",onClose:t[2]||(t[2]=a=>s.value=null)},{default:r(()=>[p("div",H,[t[3]||(t[3]=p("p",{"mr-2":""}," Schema ",-1)),d(V,{modelValue:l.value,"onUpdate:modelValue":t[0]||(t[0]=a=>l.value=a),n:"xs primary"},{default:r(()=>[(n(!0),_(C,null,S(f(h.all),a=>(n(),_("option",{key:a.displayName},b(a.displayName),1))),128))]),_:1},8,["modelValue"]),o.value?.length?(n(),c(I,{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(),_("span",K,b(o.value.length),1)):m("",!0)]),default:r(()=>[p("div",M,[(n(!0),_(C,null,S(o.value,(a,g)=>(n(),c(i,{key:a.name,modelValue:o.value[g].defaultValue,"onUpdate:modelValue":A=>o.value[g].defaultValue=A,flex:"~ gap-2",rounded:"",px2:"",py2:""},{default:r(()=>[p("span",P,b(a.description),1)]),_:2},1032,["modelValue","onUpdate:modelValue"]))),128))])]),_:1})):m("",!0),t[4]||(t[4]=p("div",{"flex-auto":""},null,-1)),d(u,{icon:"carbon-copy","mr-6":"","h-full":"",onClick:t[1]||(t[1]=a=>L())})]),f(y)?(n(),c(T,{key:0,lang:j.value,code:f(y)},null,8,["lang","code"])):m("",!0)]),_:1},8,["model-value"])])):m("",!0)}}}),ie=Object.assign(Q,{__name:"DataSchemaDrawer"});export{ie as default};
