import K from"./SchemaTabs-2e6dd274.js";import{u as V}from"./store-4494c957.js";import"./EditableInput-59a19c62.js";import{_ as T}from"./_plugin-vue_export-helper-c27b6911.js";import"./SchemaSections-5a65d0e0.js";import{b as O,c as I,a9 as W,aY as y,j as m,e as A,f as _,g as x,J as U,k as F,n as B,t as D}from"./index-a0da86f0.js";import{n as Y,i as $,t as L,w as q,a as z,b as G,c as H}from"./index-96e20e64.js";import"./_commonjsHelpers-de833af9.js";const N=$?window:void 0;function Q(i){var e;const r=y(i);return(e=r==null?void 0:r.$el)!=null?e:r}function C(...i){const e=[],r=()=>{e.forEach(o=>o()),e.length=0},h=(o,s,a,u)=>(o.addEventListener(s,a,u),()=>o.removeEventListener(s,a,u)),f=I(()=>{const o=L(y(i[0])).filter(s=>s!=null);return o.every(s=>typeof s!="string")?o:void 0}),d=q(()=>{var o,s;return[(s=(o=f.value)==null?void 0:o.map(a=>Q(a)))!=null?s:[N].filter(a=>a!=null),L(y(f.value?i[1]:i[0])),L(m(f.value?i[2]:i[1])),y(f.value?i[3]:i[2])]},([o,s,a,u])=>{if(r(),!(o!=null&&o.length)||!(s!=null&&s.length)||!(a!=null&&a.length))return;const g=G(u)?{...u}:u;e.push(...o.flatMap(p=>s.flatMap(E=>a.map(b=>h(p,E,b,g)))))},{flush:"post"}),c=()=>{d(),r()};return z(r),c}const X={ctrl:"control",command:"meta",cmd:"meta",option:"alt",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright"};function Z(i={}){const{reactive:e=!1,target:r=N,aliasMap:h=X,passive:f=!0,onEventFired:d=Y}=i,c=O(new Set),o={toJSON(){return{}},current:c},s=e?O(o):o,a=new Set,u=new Set,g=new Set;function p(n,t){n in s&&(e?s[n]=t:s[n].value=t)}function E(){c.clear();for(const n of g)p(n,!1)}function b(n,t){var w,S;const v=(w=n.key)==null?void 0:w.toLowerCase(),M=[(S=n.code)==null?void 0:S.toLowerCase(),v].filter(Boolean);v&&(t?c.add(v):c.delete(v));for(const l of M)g.add(l),p(l,t);if(v==="shift"&&!t){const l=Array.from(u),j=l.indexOf("shift");l.forEach((R,J)=>{J>=j&&(c.delete(R),p(R,!1))}),u.clear()}else typeof n.getModifierState=="function"&&n.getModifierState("Shift")&&t&&[...c,...M].forEach(l=>u.add(l));v==="meta"&&!t?(a.forEach(l=>{c.delete(l),p(l,!1)}),a.clear()):typeof n.getModifierState=="function"&&n.getModifierState("Meta")&&t&&[...c,...M].forEach(l=>a.add(l))}C(r,"keydown",n=>(b(n,!0),d(n)),{passive:f}),C(r,"keyup",n=>(b(n,!1),d(n)),{passive:f}),C("blur",E,{passive:f}),C("focus",E,{passive:f});const P=new Proxy(s,{get(n,t,w){if(typeof t!="string")return Reflect.get(n,t,w);if(t=t.toLowerCase(),t in h&&(t=h[t]),!(t in s))if(/[+_-]/.test(t)){const v=t.split(/[+_-]/g).map(k=>k.trim());s[t]=I(()=>v.map(k=>y(P[k])).every(Boolean))}else s[t]=W(!1);const S=Reflect.get(n,t,w);return e?y(S):S}});return P}const ee={class:"schema-canvas"},te={class:"schema-header"},se={class:"schema-actions"},ne={class:"schema-content"},oe={key:0,class:"schema-preview"},ae={__name:"SchemaCanvas",setup(i){const e=V(),{Backspace:r}=Z();H(r,d=>{d&&e.selectedField&&e.notUsingInput&&h(e.selectedField)});function h(d){e.removeProperty(d)}function f(){e.updateSchema();const d=new CustomEvent("schema-save",{detail:{schemaData:e.schema}});document.dispatchEvent(d)}return(d,c)=>(B(),A("div",ee,[_("div",te,[_("div",se,[_("button",{class:"preview-btn",onClick:c[0]||(c[0]=(...o)=>m(e).togglePreview&&m(e).togglePreview(...o))},x(m(e).preview?m(D)("Edit"):m(D)("Preview")),1),_("button",{class:"save-btn",onClick:f},x(m(D)("Save")),1)])]),m(e).preview?F("",!0):(B(),U(K,{key:0})),_("div",ne,[m(e).preview?(B(),A("div",oe,[_("pre",null,x(JSON.stringify(m(e).schema,null,2)),1)])):F("",!0)])]))}},ve=T(ae,[["__scopeId","data-v-a6a159d7"]]);export{ve as default};
