json-schema-builder-react 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,7 +24,29 @@ yarn add json-schema-builder-react
24
24
  pnpm add json-schema-builder-react
25
25
  ```
26
26
 
27
- ### Styling
27
+ ## Prerequisites
28
+
29
+ This library requires the following peer dependencies to be installed in your project:
30
+
31
+ ### 1. Install shadcn/ui Components
32
+
33
+ This library uses [shadcn/ui](https://ui.shadcn.com/) components. You'll need to set up shadcn/ui and install the required components:
34
+
35
+ ```bash
36
+ # Initialize shadcn/ui (if not already done)
37
+ npx shadcn@latest init
38
+
39
+ # Install required components
40
+ npx shadcn@latest add button dialog input select checkbox tooltip card label textarea
41
+ ```
42
+
43
+ ### 2. Install Radix UI and Utility Libraries
44
+
45
+ ```bash
46
+ npm install @radix-ui/react-checkbox @radix-ui/react-dialog @radix-ui/react-label @radix-ui/react-select @radix-ui/react-slot @radix-ui/react-tooltip lucide-react class-variance-authority clsx tailwind-merge
47
+ ```
48
+
49
+ ### 3. Tailwind CSS Setup
28
50
 
29
51
  This library uses Tailwind CSS utility classes. You'll need Tailwind CSS configured in your project.
30
52
 
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),S=require("react"),Xe=require("@radix-ui/react-slot"),w=require("lucide-react"),Ze=require("@radix-ui/react-tooltip"),Qe=require("@radix-ui/react-select"),Ye=require("@radix-ui/react-dialog"),et=require("@radix-ui/react-label"),tt=require("@radix-ui/react-checkbox");function U(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(r,s,a.get?a:{enumerable:!0,get:()=>e[s]})}}return r.default=e,Object.freeze(r)}const I=U(S),J=U(Ze),P=U(Qe),E=U(Ye),ze=U(et),oe=U(tt);function Re(e){var r,s,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(r=0;r<n;r++)e[r]&&(s=Re(e[r]))&&(a&&(a+=" "),a+=s)}else for(s in e)e[s]&&(a&&(a+=" "),a+=s);return a}function Ae(){for(var e,r,s=0,a="",n=arguments.length;s<n;s++)(e=arguments[s])&&(r=Re(e))&&(a&&(a+=" "),a+=r);return a}const ke=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Se=Ae,qe=(e,r)=>s=>{var a;if((r==null?void 0:r.variants)==null)return Se(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:n,defaultVariants:o}=r,i=Object.keys(n).map(c=>{const d=s==null?void 0:s[c],h=o==null?void 0:o[c];if(d===null)return null;const f=ke(d)||ke(h);return n[c][f]}),l=s&&Object.entries(s).reduce((c,d)=>{let[h,f]=d;return f===void 0||(c[h]=f),c},{}),p=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((c,d)=>{let{class:h,className:f,...v}=d;return Object.entries(v).every(b=>{let[y,m]=b;return Array.isArray(m)?m.includes({...o,...l}[y]):{...o,...l}[y]===m})?[...c,h,f]:c},[]);return Se(e,i,p,s==null?void 0:s.class,s==null?void 0:s.className)},ge="-",st=e=>{const r=nt(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:i=>{const l=i.split(ge);return l[0]===""&&l.length!==1&&l.shift(),Oe(l,r)||rt(i)},getConflictingClassGroupIds:(i,l)=>{const p=s[i]||[];return l&&a[i]?[...p,...a[i]]:p}}},Oe=(e,r)=>{var i;if(e.length===0)return r.classGroupId;const s=e[0],a=r.nextPart.get(s),n=a?Oe(e.slice(1),a):void 0;if(n)return n;if(r.validators.length===0)return;const o=e.join(ge);return(i=r.validators.find(({validator:l})=>l(o)))==null?void 0:i.classGroupId},Ie=/^\[(.+)\]$/,rt=e=>{if(Ie.test(e)){const r=Ie.exec(e)[1],s=r==null?void 0:r.substring(0,r.indexOf(":"));if(s)return"arbitrary.."+s}},nt=e=>{const{theme:r,prefix:s}=e,a={nextPart:new Map,validators:[]};return ot(Object.entries(e.classGroups),s).forEach(([o,i])=>{ie(i,a,o,r)}),a},ie=(e,r,s,a)=>{e.forEach(n=>{if(typeof n=="string"){const o=n===""?r:Te(r,n);o.classGroupId=s;return}if(typeof n=="function"){if(at(n)){ie(n(a),r,s,a);return}r.validators.push({validator:n,classGroupId:s});return}Object.entries(n).forEach(([o,i])=>{ie(i,Te(r,o),s,a)})})},Te=(e,r)=>{let s=e;return r.split(ge).forEach(a=>{s.nextPart.has(a)||s.nextPart.set(a,{nextPart:new Map,validators:[]}),s=s.nextPart.get(a)}),s},at=e=>e.isThemeGetter,ot=(e,r)=>r?e.map(([s,a])=>{const n=a.map(o=>typeof o=="string"?r+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([i,l])=>[r+i,l])):o);return[s,n]}):e,it=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,s=new Map,a=new Map;const n=(o,i)=>{s.set(o,i),r++,r>e&&(r=0,a=s,s=new Map)};return{get(o){let i=s.get(o);if(i!==void 0)return i;if((i=a.get(o))!==void 0)return n(o,i),i},set(o,i){s.has(o)?s.set(o,i):n(o,i)}}},Le="!",lt=e=>{const{separator:r,experimentalParseClassName:s}=e,a=r.length===1,n=r[0],o=r.length,i=l=>{const p=[];let c=0,d=0,h;for(let m=0;m<l.length;m++){let j=l[m];if(c===0){if(j===n&&(a||l.slice(m,m+o)===r)){p.push(l.slice(d,m)),d=m+o;continue}if(j==="/"){h=m;continue}}j==="["?c++:j==="]"&&c--}const f=p.length===0?l:l.substring(d),v=f.startsWith(Le),b=v?f.substring(1):f,y=h&&h>d?h-d:void 0;return{modifiers:p,hasImportantModifier:v,baseClassName:b,maybePostfixModifierPosition:y}};return s?l=>s({className:l,parseClassName:i}):i},dt=e=>{if(e.length<=1)return e;const r=[];let s=[];return e.forEach(a=>{a[0]==="["?(r.push(...s.sort(),a),s=[]):s.push(a)}),r.push(...s.sort()),r},ct=e=>({cache:it(e.cacheSize),parseClassName:lt(e),...st(e)}),ut=/\s+/,mt=(e,r)=>{const{parseClassName:s,getClassGroupId:a,getConflictingClassGroupIds:n}=r,o=[],i=e.trim().split(ut);let l="";for(let p=i.length-1;p>=0;p-=1){const c=i[p],{modifiers:d,hasImportantModifier:h,baseClassName:f,maybePostfixModifierPosition:v}=s(c);let b=!!v,y=a(b?f.substring(0,v):f);if(!y){if(!b){l=c+(l.length>0?" "+l:l);continue}if(y=a(f),!y){l=c+(l.length>0?" "+l:l);continue}b=!1}const m=dt(d).join(":"),j=h?m+Le:m,g=j+y;if(o.includes(g))continue;o.push(g);const q=n(y,b);for(let u=0;u<q.length;++u){const z=q[u];o.push(j+z)}l=c+(l.length>0?" "+l:l)}return l};function pt(){let e=0,r,s,a="";for(;e<arguments.length;)(r=arguments[e++])&&(s=De(r))&&(a&&(a+=" "),a+=s);return a}const De=e=>{if(typeof e=="string")return e;let r,s="";for(let a=0;a<e.length;a++)e[a]&&(r=De(e[a]))&&(s&&(s+=" "),s+=r);return s};function ht(e,...r){let s,a,n,o=i;function i(p){const c=r.reduce((d,h)=>h(d),e());return s=ct(c),a=s.cache.get,n=s.cache.set,o=l,l(p)}function l(p){const c=a(p);if(c)return c;const d=mt(p,s);return n(p,d),d}return function(){return o(pt.apply(null,arguments))}}const k=e=>{const r=s=>s[e]||[];return r.isThemeGetter=!0,r},Ee=/^\[(?:([a-z-]+):)?(.+)\]$/i,ft=/^\d+\/\d+$/,gt=new Set(["px","full","screen"]),xt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bt=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,yt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,vt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,jt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,B=e=>K(e)||gt.has(e)||ft.test(e),_=e=>W(e,"length",Pt),K=e=>!!e&&!Number.isNaN(Number(e)),ae=e=>W(e,"number",K),X=e=>!!e&&Number.isInteger(Number(e)),wt=e=>e.endsWith("%")&&K(e.slice(0,-1)),x=e=>Ee.test(e),G=e=>xt.test(e),Nt=new Set(["length","size","percentage"]),Ct=e=>W(e,Nt,Me),kt=e=>W(e,"position",Me),St=new Set(["image","url"]),It=e=>W(e,St,Rt),Tt=e=>W(e,"",zt),Z=()=>!0,W=(e,r,s)=>{const a=Ee.exec(e);return a?a[1]?typeof r=="string"?a[1]===r:r.has(a[1]):s(a[2]):!1},Pt=e=>bt.test(e)&&!yt.test(e),Me=()=>!1,zt=e=>vt.test(e),Rt=e=>jt.test(e),At=()=>{const e=k("colors"),r=k("spacing"),s=k("blur"),a=k("brightness"),n=k("borderColor"),o=k("borderRadius"),i=k("borderSpacing"),l=k("borderWidth"),p=k("contrast"),c=k("grayscale"),d=k("hueRotate"),h=k("invert"),f=k("gap"),v=k("gradientColorStops"),b=k("gradientColorStopPositions"),y=k("inset"),m=k("margin"),j=k("opacity"),g=k("padding"),q=k("saturate"),u=k("scale"),z=k("sepia"),V=k("skew"),$=k("space"),R=k("translate"),D=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],Q=()=>["auto",x,r],C=()=>[x,r],je=()=>["",B,_],Y=()=>["auto",K,x],we=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ee=()=>["solid","dashed","dotted","double","none"],Ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ne=()=>["start","end","center","between","around","evenly","stretch"],H=()=>["","0",x],Ce=()=>["auto","avoid","all","avoid-page","page","left","right","column"],F=()=>[K,x];return{cacheSize:500,separator:":",theme:{colors:[Z],spacing:[B,_],blur:["none","",G,x],brightness:F(),borderColor:[e],borderRadius:["none","","full",G,x],borderSpacing:C(),borderWidth:je(),contrast:F(),grayscale:H(),hueRotate:F(),invert:H(),gap:C(),gradientColorStops:[e],gradientColorStopPositions:[wt,_],inset:Q(),margin:Q(),opacity:F(),padding:C(),saturate:F(),scale:F(),sepia:H(),skew:F(),space:C(),translate:C()},classGroups:{aspect:[{aspect:["auto","square","video",x]}],container:["container"],columns:[{columns:[G]}],"break-after":[{"break-after":Ce()}],"break-before":[{"break-before":Ce()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...we(),x]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",X,x]}],basis:[{basis:Q()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",x]}],grow:[{grow:H()}],shrink:[{shrink:H()}],order:[{order:["first","last","none",X,x]}],"grid-cols":[{"grid-cols":[Z]}],"col-start-end":[{col:["auto",{span:["full",X,x]},x]}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":[Z]}],"row-start-end":[{row:["auto",{span:[X,x]},x]}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",x]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",x]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...ne()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ne(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ne(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[g]}],px:[{px:[g]}],py:[{py:[g]}],ps:[{ps:[g]}],pe:[{pe:[g]}],pt:[{pt:[g]}],pr:[{pr:[g]}],pb:[{pb:[g]}],pl:[{pl:[g]}],m:[{m:[m]}],mx:[{mx:[m]}],my:[{my:[m]}],ms:[{ms:[m]}],me:[{me:[m]}],mt:[{mt:[m]}],mr:[{mr:[m]}],mb:[{mb:[m]}],ml:[{ml:[m]}],"space-x":[{"space-x":[$]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[$]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",x,r]}],"min-w":[{"min-w":[x,r,"min","max","fit"]}],"max-w":[{"max-w":[x,r,"none","full","min","max","fit","prose",{screen:[G]},G]}],h:[{h:[x,r,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[x,r,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[x,r,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[x,r,"auto","min","max","fit"]}],"font-size":[{text:["base",G,_]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ae]}],"font-family":[{font:[Z]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",x]}],"line-clamp":[{"line-clamp":["none",K,ae]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",B,x]}],"list-image":[{"list-image":["none",x]}],"list-style-type":[{list:["none","disc","decimal",x]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[j]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[j]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",B,_]}],"underline-offset":[{"underline-offset":["auto",B,x]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",x]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",x]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[j]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...we(),kt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Ct]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},It]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[v]}],"gradient-via":[{via:[v]}],"gradient-to":[{to:[v]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[j]}],"border-style":[{border:[...ee(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[j]}],"divide-style":[{divide:ee()}],"border-color":[{border:[n]}],"border-color-x":[{"border-x":[n]}],"border-color-y":[{"border-y":[n]}],"border-color-s":[{"border-s":[n]}],"border-color-e":[{"border-e":[n]}],"border-color-t":[{"border-t":[n]}],"border-color-r":[{"border-r":[n]}],"border-color-b":[{"border-b":[n]}],"border-color-l":[{"border-l":[n]}],"divide-color":[{divide:[n]}],"outline-style":[{outline:["",...ee()]}],"outline-offset":[{"outline-offset":[B,x]}],"outline-w":[{outline:[B,_]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:je()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[j]}],"ring-offset-w":[{"ring-offset":[B,_]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",G,Tt]}],"shadow-color":[{shadow:[Z]}],opacity:[{opacity:[j]}],"mix-blend":[{"mix-blend":[...Ne(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Ne()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[a]}],contrast:[{contrast:[p]}],"drop-shadow":[{"drop-shadow":["","none",G,x]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[q]}],sepia:[{sepia:[z]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[a]}],"backdrop-contrast":[{"backdrop-contrast":[p]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[j]}],"backdrop-saturate":[{"backdrop-saturate":[q]}],"backdrop-sepia":[{"backdrop-sepia":[z]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",x]}],duration:[{duration:F()}],ease:[{ease:["linear","in","out","in-out",x]}],delay:[{delay:F()}],animate:[{animate:["none","spin","ping","pulse","bounce",x]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[u]}],"scale-x":[{"scale-x":[u]}],"scale-y":[{"scale-y":[u]}],rotate:[{rotate:[X,x]}],"translate-x":[{"translate-x":[R]}],"translate-y":[{"translate-y":[R]}],"skew-x":[{"skew-x":[V]}],"skew-y":[{"skew-y":[V]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",x]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",x]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",x]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[B,_,ae]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},qt=ht(At);function N(...e){return qt(Ae(e))}const Ot=qe("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-full px-3 text-xs",lg:"h-10 rounded-full px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),O=I.forwardRef(({className:e,variant:r,size:s,asChild:a=!1,...n},o)=>{const i=a?Xe.Slot:"button";return t.jsx(i,{className:N(Ot({variant:r,size:s,className:e})),ref:o,...n})});O.displayName="Button";const L=I.forwardRef(({className:e,type:r,...s},a)=>t.jsx("input",{type:r,className:N("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:a,...s}));L.displayName="Input";const Lt=J.Provider,Dt=J.Root,Et=J.Trigger,Fe=I.forwardRef(({className:e,sideOffset:r=4,...s},a)=>t.jsx(J.Portal,{children:t.jsx(J.Content,{ref:a,sideOffset:r,className:N("z-50 overflow-hidden rounded-md bg-popover px-3 py-1.5 text-xs text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...s})}));Fe.displayName=J.Content.displayName;const le=P.Root,de=P.Value,se=I.forwardRef(({className:e,children:r,...s},a)=>t.jsxs(P.Trigger,{ref:a,className:N("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...s,children:[r,t.jsx(P.Icon,{asChild:!0,children:t.jsx(w.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));se.displayName=P.Trigger.displayName;const Be=I.forwardRef(({className:e,...r},s)=>t.jsx(P.ScrollUpButton,{ref:s,className:N("flex cursor-default items-center justify-center py-1",e),...r,children:t.jsx(w.ChevronUp,{className:"h-4 w-4"})}));Be.displayName=P.ScrollUpButton.displayName;const _e=I.forwardRef(({className:e,...r},s)=>t.jsx(P.ScrollDownButton,{ref:s,className:N("flex cursor-default items-center justify-center py-1",e),...r,children:t.jsx(w.ChevronDown,{className:"h-4 w-4"})}));_e.displayName=P.ScrollDownButton.displayName;const re=I.forwardRef(({className:e,children:r,position:s="popper",...a},n)=>t.jsx(P.Portal,{children:t.jsxs(P.Content,{ref:n,className:N("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,...a,children:[t.jsx(Be,{}),t.jsx(P.Viewport,{className:N("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),t.jsx(_e,{})]})}));re.displayName=P.Content.displayName;const Mt=I.forwardRef(({className:e,...r},s)=>t.jsx(P.Label,{ref:s,className:N("px-2 py-1.5 text-sm font-semibold",e),...r}));Mt.displayName=P.Label.displayName;const A=I.forwardRef(({className:e,children:r,...s},a)=>t.jsxs(P.Item,{ref:a,className:N("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[t.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(P.ItemIndicator,{children:t.jsx(w.Check,{className:"h-4 w-4"})})}),t.jsx(P.ItemText,{children:r})]}));A.displayName=P.Item.displayName;const Ft=I.forwardRef(({className:e,...r},s)=>t.jsx(P.Separator,{ref:s,className:N("-mx-1 my-1 h-px bg-muted",e),...r}));Ft.displayName=P.Separator.displayName;const Bt=E.Root,_t=E.Portal,Ge=I.forwardRef(({className:e,...r},s)=>t.jsx(E.Overlay,{ref:s,className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r}));Ge.displayName=E.Overlay.displayName;const Ve=I.forwardRef(({className:e,children:r,...s},a)=>t.jsxs(_t,{children:[t.jsx(Ge,{}),t.jsxs(E.Content,{ref:a,className:N("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...s,children:[r,t.jsxs(E.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(w.X,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ve.displayName=E.Content.displayName;const $e=({className:e,...r})=>t.jsx("div",{className:N("flex flex-col space-y-1.5 text-center sm:text-left",e),...r});$e.displayName="DialogHeader";const Ke=({className:e,...r})=>t.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...r});Ke.displayName="DialogFooter";const Je=I.forwardRef(({className:e,...r},s)=>t.jsx(E.Title,{ref:s,className:N("text-lg font-semibold leading-none tracking-tight",e),...r}));Je.displayName=E.Title.displayName;const Gt=I.forwardRef(({className:e,...r},s)=>t.jsx(E.Description,{ref:s,className:N("text-sm text-muted-foreground",e),...r}));Gt.displayName=E.Description.displayName;const Vt=qe("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),T=I.forwardRef(({className:e,...r},s)=>t.jsx(ze.Root,{ref:s,className:N(Vt(),e),...r}));T.displayName=ze.Root.displayName;const ce=I.forwardRef(({className:e,...r},s)=>t.jsx(oe.Root,{ref:s,className:N("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...r,children:t.jsx(oe.Indicator,{className:N("grid place-content-center text-current"),children:t.jsx(w.Check,{className:"h-4 w-4"})})}));ce.displayName=oe.Root.displayName;const xe=I.forwardRef(({className:e,...r},s)=>t.jsx("textarea",{className:N("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:s,...r}));xe.displayName="Textarea";const $t=e=>e.trim().toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g,"_"),Kt=(e,r,s=!1,a=!1)=>{const n=(c,d)=>{r({...e,[c]:d})};return{handleTitleChange:c=>{n("title",c)},handleTitleBlur:()=>{if(s&&e.title){const c=$t(e.title);n("key",c)}},handleKeyChange:c=>{(s||a)&&n("key",c)},handleFieldChange:n,handleConstraintChange:(c,d)=>{r({...e,[c]:d})}}},ue={string:"String",number:"Number",integer:"Integer",boolean:"Boolean",object:"Object",array:"Array",null:"Null",file:"File"},Ue=S.createContext({getTypeLabel:e=>ue[e],typeLabels:ue});function Jt({children:e,customLabels:r={}}){const s={...ue,...r},a=n=>s[n]||n;return t.jsx(Ue.Provider,{value:{getTypeLabel:a,typeLabels:s},children:e})}function We(){return S.useContext(Ue)}function me({property:e,open:r,onOpenChange:s,onUpdate:a,isArrayItem:n=!1,isNewProperty:o=!1,propertyLabel:i={singular:"Property",plural:"Properties"},showRegex:l=!1,keyEditable:p=!1}){var q;const{typeLabels:c}=We(),[d,h]=S.useState(e);S.useEffect(()=>{r&&h(e)},[e,r]);const{handleTitleChange:f,handleTitleBlur:v,handleKeyChange:b,handleFieldChange:y,handleConstraintChange:m}=Kt(d,h,o,p),j=()=>{var u;(u=d.title)!=null&&u.trim()&&(a(d),s(!1))},g=()=>{h(e),s(!1)};return t.jsx(Bt,{open:r,onOpenChange:s,children:t.jsxs(Ve,{className:"max-w-2xl max-h-[80vh] flex flex-col gap-0 p-0","data-testid":"dialog-edit-property",children:[t.jsx($e,{className:"px-6 pt-6 pb-4 shrink-0",children:t.jsx(Je,{children:o?`Add ${i.singular}`:`Edit ${i.singular}`})}),t.jsxs("div",{className:"space-y-6 px-6 pb-4 overflow-y-auto flex-1 min-h-0",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs(T,{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Type"]}),t.jsxs(le,{value:d.type,onValueChange:u=>y("type",u),"data-testid":"select-type-dialog",children:[t.jsx(se,{children:t.jsx(de,{})}),t.jsxs(re,{children:[t.jsx(A,{value:"string",children:c.string}),t.jsx(A,{value:"number",children:c.number}),t.jsx(A,{value:"integer",children:c.integer}),t.jsx(A,{value:"boolean",children:c.boolean}),t.jsx(A,{value:"object",children:c.object}),t.jsx(A,{value:"array",children:c.array}),t.jsx(A,{value:"file",children:c.file}),t.jsx(A,{value:"null",children:c.null})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs(T,{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Title"]}),t.jsx(L,{value:d.title||"",onChange:u=>f(u.target.value),onBlur:v,placeholder:"Property Title","data-testid":"input-title-dialog",required:!0}),!o&&d.key&&t.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["Key: ",d.key]})]}),(o||p)&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{children:"Key"}),t.jsx(L,{value:d.key,onChange:u=>b(u.target.value),placeholder:"property_key","data-testid":"input-key-dialog"}),!o&&t.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-500",children:"⚠️ Changing the key may break existing references to this property"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{children:"Description"}),t.jsx(xe,{placeholder:"Optional description",value:d.description||"",onChange:u=>y("description",u.target.value),rows:2,"data-testid":"input-edit-description"})]}),d.type==="array"&&t.jsxs("div",{className:"space-y-2 border-l-2 border-border pl-4 mt-2",children:[t.jsxs(T,{className:"font-semibold text-xs text-muted-foreground",children:[c.array," Items"]}),d.items?t.jsxs("div",{className:"bg-muted/40 p-2 rounded",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{children:"Item Type"}),t.jsxs(le,{value:d.items.type,onValueChange:u=>h({...d,items:{...d.items,type:u}}),children:[t.jsx(se,{children:t.jsx(de,{})}),t.jsxs(re,{children:[t.jsx(A,{value:"string",children:c.string}),t.jsx(A,{value:"number",children:c.number}),t.jsx(A,{value:"integer",children:c.integer}),t.jsx(A,{value:"boolean",children:c.boolean}),t.jsx(A,{value:"object",children:c.object}),t.jsx(A,{value:"array",children:c.array}),t.jsx(A,{value:"file",children:c.file}),t.jsx(A,{value:"null",children:c.null})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{children:"Item Title"}),t.jsx(L,{value:d.items.title||"",onChange:u=>h({...d,items:{...d.items,title:u.target.value}}),placeholder:"Item Title"})]}),t.jsxs(O,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>h({...d,items:void 0}),children:["Remove ",c.array," Item Schema"]})]}):t.jsxs(O,{variant:"outline",size:"sm",onClick:()=>{h({...d,items:{id:Date.now().toString()+Math.random(),key:"item",type:"string",required:!1}})},children:["Add ",c.array," Item Schema"]})]}),!n&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ce,{id:"prop-required",checked:d.required,onCheckedChange:u=>y("required",u),"data-testid":"checkbox-edit-required"}),t.jsx(T,{htmlFor:"prop-required",className:"cursor-pointer",children:"Required field"})]}),d.type==="string"&&t.jsxs("details",{className:"border rounded-md",children:[t.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:t.jsxs("h4",{className:"text-sm font-medium inline",children:[c.string," Constraints"]})}),t.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{htmlFor:"min-length",children:"Minimum Length"}),t.jsx(L,{id:"min-length",type:"number",placeholder:"0",value:d.minLength||"",onChange:u=>m("minLength",u.target.value?parseInt(u.target.value):void 0),"data-testid":"input-edit-minlength"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{htmlFor:"max-length",children:"Maximum Length"}),t.jsx(L,{id:"max-length",type:"number",placeholder:"∞",value:d.maxLength||"",onChange:u=>m("maxLength",u.target.value?parseInt(u.target.value):void 0),"data-testid":"input-edit-maxlength"})]})]}),l&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{htmlFor:"pattern",children:"Pattern (regex)"}),t.jsx(L,{id:"pattern",placeholder:"^[a-z]+$",value:d.pattern||"",onChange:u=>m("pattern",u.target.value),className:"font-mono text-sm","data-testid":"input-edit-pattern"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{children:"Enum Values"}),t.jsx("div",{className:"space-y-2",children:[...d.enum||[],""].map((u,z)=>{var V;return t.jsx(L,{placeholder:z===(((V=d.enum)==null?void 0:V.length)||0)?"Add new value...":"Enum value",value:u,onChange:$=>{const R=$.target.value,D=d.enum||[];if(z===D.length)R.trim()&&m("enum",[...D,R.trim()]);else if(R.trim()){const M=[...D];M[z]=R.trim(),m("enum",M)}else{const M=D.filter((Q,C)=>C!==z);m("enum",M.length>0?M:void 0)}},"data-testid":`input-edit-enum-${z}`},z)})}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter allowed values (empty fields will be removed)"})]})]})]}),(d.type==="number"||d.type==="integer")&&t.jsxs("details",{className:"border rounded-md",children:[t.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:t.jsx("h4",{className:"text-sm font-medium inline",children:"Numeric Constraints"})}),t.jsx("div",{className:"space-y-4 p-4 pt-0",children:t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{htmlFor:"minimum",children:"Minimum Value"}),t.jsx(L,{id:"minimum",type:"number",placeholder:"-∞",value:d.minimum??"",onChange:u=>m("minimum",u.target.value?parseFloat(u.target.value):void 0),"data-testid":"input-edit-minimum"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{htmlFor:"maximum",children:"Maximum Value"}),t.jsx(L,{id:"maximum",type:"number",placeholder:"∞",value:d.maximum??"",onChange:u=>m("maximum",u.target.value?parseFloat(u.target.value):void 0),"data-testid":"input-edit-maximum"})]})]})})]}),d.type==="array"&&t.jsxs("details",{className:"border rounded-md",children:[t.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:t.jsxs("h4",{className:"text-sm font-medium inline",children:[c.array," Constraints"]})}),t.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{htmlFor:"min-items",children:"Minimum Items"}),t.jsx(L,{id:"min-items",type:"number",placeholder:"0",value:d.minItems||"",onChange:u=>m("minItems",u.target.value?parseInt(u.target.value):void 0),"data-testid":"input-edit-minitems"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{htmlFor:"max-items",children:"Maximum Items"}),t.jsx(L,{id:"max-items",type:"number",placeholder:"∞",value:d.maxItems||"",onChange:u=>m("maxItems",u.target.value?parseInt(u.target.value):void 0),"data-testid":"input-edit-maxitems"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ce,{id:"unique-items",checked:d.uniqueItems||!1,onCheckedChange:u=>m("uniqueItems",u),"data-testid":"checkbox-edit-unique"}),t.jsx(T,{htmlFor:"unique-items",className:"cursor-pointer",children:"All items must be unique"})]})]})]})]}),t.jsxs(Ke,{className:"px-6 py-4 border-t bg-background shrink-0",children:[t.jsx(O,{variant:"outline",onClick:g,"data-testid":"button-cancel",children:"Cancel"}),t.jsx(O,{onClick:j,"data-testid":"button-save",disabled:!((q=d.title)!=null&&q.trim()),children:"Save Changes"})]})]})})}function Pe(e,r,s={}){const{allowEmpty:a=!1,onEditStart:n,onEditCancel:o}=s,[i,l]=S.useState(!1),[p,c]=S.useState(e);S.useEffect(()=>{i||c(e)},[e,i]);const d=()=>{c(e),l(!0),n==null||n()},h=b=>{c(b)},f=()=>{const b=p.trim();if(!a&&!b){c(e),l(!1);return}b!==e&&r(b),l(!1)};return{isEditing:i,value:p,startEdit:d,handleChange:h,handleBlur:f,handleKeyDown:b=>{b.key==="Enter"?f():b.key==="Escape"&&(c(e),l(!1),o==null||o())}}}function Ut(e,r){const[s,a]=S.useState(!1);return{isChangingType:s,setIsChangingType:a,handleTypeChange:i=>{const l={...e,type:i};i!=="string"&&(delete l.minLength,delete l.maxLength,delete l.pattern,delete l.enum),i!=="number"&&i!=="integer"&&(delete l.minimum,delete l.maximum),i!=="array"&&(delete l.minItems,delete l.maxItems,delete l.uniqueItems,delete l.items),i!=="object"&&delete l.children,r(l),a(!1)},availableTypes:["string","number","integer","boolean","object","array","file"]}}const be=()=>`${Date.now()}-${Math.random()}`;function ye(e={}){const{onConfirm:r,onCancel:s,createInitialData:a}=e,[n,o]=S.useState(!1),[i,l]=S.useState(null),p=f=>{const v=f??(a?a():null);l(v),o(!0)},c=()=>{o(!1),l(null),s==null||s()};return{isOpen:n,data:i,open:p,close:c,confirm:f=>{r==null||r(f),o(!1),l(null)},setIsOpen:f=>{f?o(!0):c()}}}function Wt(e,r){const s=ye({createInitialData:()=>({id:be(),key:"",type:"string",required:!1}),onConfirm:o=>{r({...e,children:[...e.children||[],o]})}});return{addChild:()=>s.open(),updateChild:(o,i)=>{const l=e.children.map(p=>p.id===o?i:p);r({...e,children:l})},deleteChild:o=>{const i=e.children.filter(l=>l.id!==o);r({...e,children:i})},addChildDialog:{isOpen:s.isOpen,data:s.data,setIsOpen:s.setIsOpen,confirm:s.confirm}}}function pe({property:e,onUpdate:r,onDelete:s,level:a=1,isArrayItem:n=!1,showRegex:o=!1,keyEditable:i=!1}){const{getTypeLabel:l,typeLabels:p}=We(),c=ye(),d=Pe(e.title||e.key||"",g=>r({...e,title:g}),{allowEmpty:!1}),h=Pe(e.description||"",g=>r({...e,description:g||void 0}),{allowEmpty:!0}),f=Ut(e,r),v=Wt(e,r),b=`h${Math.min(a,6)}`,y=e.type==="object",m=y&&e.children&&e.children.length>0,j={1:"text-lg font-semibold",2:"text-base",3:"text-base",4:"text-base",5:"text-sm",6:"text-sm"}[a]||"text-sm";return t.jsxs("div",{className:"group",children:[t.jsxs("div",{className:"flex gap-4 items-center rounded-md -mx-2 px-2 py-1 transition-colors hover:bg-accent/50",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"flex items-start gap-3",children:[!n&&t.jsx("button",{onClick:()=>r({...e,required:!e.required}),className:"shrink-0 transition-all hover:scale-110 mt-0.5",title:e.required?"Required field - click to make optional":"Optional field - click to make required",children:e.required?t.jsx("span",{className:"block w-4 h-4 rounded-full bg-primary"}):t.jsx("span",{className:"block w-4 h-4 rounded-full border border-dashed border-gray-400"})}),d.isEditing?t.jsx(L,{value:d.value,onChange:g=>d.handleChange(g.target.value),onBlur:d.handleBlur,onKeyDown:d.handleKeyDown,autoFocus:!0,className:j,placeholder:"Enter title"}):t.jsxs("div",{className:"flex gap-2 flex-wrap flex-1",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(b,{className:`${j} cursor-pointer hover:text-primary transition-colors leading-none`,onClick:d.startEdit,children:e.title||e.key||t.jsx("span",{className:"text-muted-foreground italic",children:"unnamed"})}),f.isChangingType?t.jsxs(le,{value:e.type,onValueChange:g=>f.handleTypeChange(g),open:f.isChangingType,onOpenChange:f.setIsChangingType,children:[t.jsx(se,{className:"w-[140px] h-7",children:t.jsx(de,{})}),t.jsx(re,{children:f.availableTypes.map(g=>t.jsx(A,{value:g,children:p[g]},g))})]}):t.jsx(Lt,{children:t.jsxs(Dt,{children:[t.jsx(Et,{asChild:!0,children:t.jsxs("button",{onClick:()=>f.setIsChangingType(!0),className:"cursor-pointer hover:bg-accent rounded p-0.5 transition-colors",children:[e.type==="string"&&t.jsx(w.Type,{className:"w-5 h-5 text-muted-foreground"}),e.type==="number"&&t.jsx(w.Hash,{className:"w-5 h-5 text-muted-foreground"}),e.type==="integer"&&t.jsx(w.Hash,{className:"w-5 h-5 text-muted-foreground"}),e.type==="boolean"&&t.jsx(w.CheckSquare,{className:"w-5 h-5 text-muted-foreground"}),e.type==="object"&&t.jsx(w.Braces,{className:"w-5 h-5 text-muted-foreground"}),e.type==="array"&&t.jsx(w.List,{className:"w-5 h-5 text-muted-foreground"}),e.type==="file"&&t.jsx(w.FileText,{className:"w-5 h-5 text-muted-foreground"})]})}),t.jsxs(Fe,{children:[l(e.type),e.type==="array"&&e.items?` of ${l(e.items.type)}`:"",t.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Click to change type"})]})]})}),e.type==="object"&&t.jsx(O,{variant:"ghost",size:"icon",className:"opacity-0 group-hover:opacity-100 h-6 w-6",onClick:v.addChild,"data-testid":`button-add-child-${e.id}`,children:t.jsx(w.Plus,{className:"!w-5 !h-5"})})]}),t.jsx("div",{className:"flex-1",children:h.isEditing?t.jsx(L,{value:h.value,onChange:g=>h.handleChange(g.target.value),onBlur:h.handleBlur,onKeyDown:h.handleKeyDown,autoFocus:!0,className:"text-sm flex-1",placeholder:"Enter description"}):t.jsx(t.Fragment,{children:e.description?t.jsx("p",{className:"text-sm text-muted-foreground flex-1 min-w-[200px] cursor-pointer hover:text-foreground transition-colors","data-testid":`text-description-${e.id}`,onClick:h.startEdit,children:e.description}):t.jsx("p",{className:"text-sm text-muted-foreground/50 flex-1 min-w-[200px] cursor-pointer hover:text-muted-foreground italic transition-colors",onClick:h.startEdit,children:"Add description..."})})})]})]})}),t.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[t.jsx(O,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c.open(e),"data-testid":`button-edit-${e.id}`,children:t.jsx(w.Pencil,{className:"w-3 h-3"})}),y&&e.type!=="object"&&t.jsx(O,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:v.addChild,"data-testid":`button-add-child-${e.id}`,children:t.jsx(w.Plus,{className:"w-3 h-3"})}),t.jsx(O,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:s,"data-testid":`button-delete-${e.id}`,children:t.jsx(w.Trash2,{className:"w-3 h-3"})})]})]}),m&&t.jsx("div",{className:a===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:e.children.map(g=>t.jsx(pe,{property:g,onUpdate:q=>v.updateChild(g.id,q),onDelete:()=>v.deleteChild(g.id),level:a+1,showRegex:o,keyEditable:i},g.id))}),e.type==="array"&&e.items&&t.jsxs("div",{className:a===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:[t.jsxs("div",{className:"mb-2 text-xs text-muted-foreground font-semibold uppercase",children:[l("array")," Items"]}),t.jsx(pe,{property:e.items,onUpdate:g=>r({...e,items:g}),onDelete:()=>r({...e,items:void 0}),level:a+1,isArrayItem:!0,showRegex:o,keyEditable:i})]}),t.jsx(me,{property:c.data||e,open:c.isOpen,onOpenChange:c.setIsOpen,onUpdate:g=>{r(g),c.close()},isArrayItem:n,isNewProperty:!1,showRegex:o,keyEditable:i}),v.addChildDialog.isOpen&&v.addChildDialog.data&&t.jsx(me,{property:v.addChildDialog.data,open:v.addChildDialog.isOpen,isNewProperty:!0,onOpenChange:v.addChildDialog.setIsOpen,onUpdate:v.addChildDialog.confirm,showRegex:o,keyEditable:i})]})}const ve=I.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("rounded-xl border bg-card text-card-foreground shadow",e),...r}));ve.displayName="Card";const Ht=I.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("flex flex-col space-y-1.5 p-6",e),...r}));Ht.displayName="CardHeader";const Xt=I.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("font-semibold leading-none tracking-tight",e),...r}));Xt.displayName="CardTitle";const Zt=I.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("text-sm text-muted-foreground",e),...r}));Zt.displayName="CardDescription";const Qt=I.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("p-6 pt-0",e),...r}));Qt.displayName="CardContent";const Yt=I.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("flex items-center p-6 pt-0",e),...r}));Yt.displayName="CardFooter";const es=()=>new Promise((e,r)=>{const s=document.createElement("input");s.type="file",s.accept=".json",s.onchange=a=>{var i;const n=(i=a.target.files)==null?void 0:i[0];if(!n){r(new Error("No file selected"));return}const o=new FileReader;o.onload=l=>{var p;try{const c=JSON.parse((p=l.target)==null?void 0:p.result);e(c)}catch{r(new Error("Invalid JSON file"))}},o.onerror=()=>r(new Error("Failed to read file")),o.readAsText(n)},s.click()}),He=(e,r="schema.json")=>{const s=JSON.stringify(e,null,2),a=new Blob([s],{type:"application/json"}),n=URL.createObjectURL(a),o=document.createElement("a");o.href=n,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)};function ts({schema:e}){const[r,s]=S.useState(!1),a=JSON.stringify(e,null,2),n=async()=>{await navigator.clipboard.writeText(a),s(!0),setTimeout(()=>s(!1),2e3)},o=()=>{He(e,"schema.json")};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[t.jsx("h2",{className:"text-sm font-medium",children:"JSON Schema Output"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(O,{variant:"outline",size:"sm",onClick:n,"data-testid":"button-copy",children:r?t.jsx(w.CheckCircle2,{className:"w-4 h-4"}):t.jsx(w.Copy,{className:"w-4 h-4"})}),t.jsx(O,{variant:"outline",size:"sm",onClick:o,"data-testid":"button-download",children:t.jsx(w.Download,{className:"w-4 h-4"})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsx(ve,{className:"m-4 bg-muted/30",children:t.jsx("pre",{className:"p-6 text-xs font-mono overflow-auto","data-testid":"text-json-output",children:t.jsx("code",{children:a})})})})]})}function ss({title:e,description:r,version:s,onUpdate:a}){const[n,o]=S.useState(!1);return t.jsxs(ve,{className:"p-4",children:[t.jsxs(O,{variant:"ghost",onClick:()=>o(!n),className:"w-full justify-between px-2 h-auto hover:bg-transparent","data-testid":"button-toggle-metadata",children:[t.jsx("h3",{className:"text-sm font-medium",children:"Schema Metadata"}),n?t.jsx(w.ChevronDown,{className:"w-4 h-4"}):t.jsx(w.ChevronRight,{className:"w-4 h-4"})]}),n&&t.jsxs("div",{className:"mt-4 space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{htmlFor:"schema-title",className:"text-xs text-muted-foreground",children:"Title"}),t.jsx(L,{id:"schema-title",placeholder:"My Schema",value:e,onChange:i=>a("title",i.target.value),"data-testid":"input-title"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{htmlFor:"schema-description",className:"text-xs text-muted-foreground",children:"Description"}),t.jsx(xe,{id:"schema-description",placeholder:"Describe your schema...",value:r,onChange:i=>a("description",i.target.value),className:"resize-none",rows:3,"data-testid":"input-schema-description"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(T,{htmlFor:"schema-version",className:"text-xs text-muted-foreground",children:"Version"}),t.jsx(L,{id:"schema-version",placeholder:"1.0.0",value:s,onChange:i=>a("version",i.target.value),"data-testid":"input-version"})]})]})]})}const te=(e,r,s=!0)=>{const a={type:"object"};s&&r&&(r.title&&(a.title=r.title),r.description&&(a.description=r.description));const n=he(e);Object.keys(n).length>0&&(a.properties=n);const o=e.filter(i=>i.required&&i.key).map(i=>i.key);return o.length>0&&(a.required=o),a},he=e=>{const r={};return e.forEach(s=>{if(!s.key)return;const n={type:s.type==="file"?"string":s.type};if(s.title&&(n.title=s.title),s.description&&(n.description=s.description),s.type==="file"&&(n.format="filename"),s.type==="string"&&(s.minLength!==void 0&&(n.minLength=s.minLength),s.maxLength!==void 0&&(n.maxLength=s.maxLength),s.pattern&&(n.pattern=s.pattern),s.enum&&s.enum.length>0&&(n.enum=s.enum)),(s.type==="number"||s.type==="integer")&&(s.minimum!==void 0&&(n.minimum=s.minimum),s.maximum!==void 0&&(n.maximum=s.maximum)),s.type==="array"&&(s.minItems!==void 0&&(n.minItems=s.minItems),s.maxItems!==void 0&&(n.maxItems=s.maxItems),s.uniqueItems&&(n.uniqueItems=s.uniqueItems),s.items&&(n.items=he([s.items])[s.items.key]||{type:s.items.type})),s.type==="object"&&s.children&&s.children.length>0){n.properties=he(s.children);const o=s.children.filter(i=>i.required&&i.key).map(i=>i.key);o.length>0&&(n.required=o)}r[s.key]=n}),r},rs=e=>{const r={properties:[]};return(e.title||e.description)&&(r.metadata={title:typeof e.title=="string"?e.title:"",description:typeof e.description=="string"?e.description:"",version:"1.0.0"}),e.properties&&typeof e.properties=="object"&&(r.properties=fe(e.properties,Array.isArray(e.required)?e.required:[])),r},fe=(e,r=[])=>e?Object.entries(e).filter(([,s])=>typeof s=="object").map(([s,a])=>{const n=a;let o=typeof n.type=="string"?n.type:"string";o==="string"&&n.format==="filename"&&(o="file");const i={id:be(),key:s,title:typeof n.title=="string"?n.title:void 0,type:o,description:typeof n.description=="string"?n.description:void 0,required:r.includes(s)};return n.minLength!==void 0&&(i.minLength=n.minLength),n.maxLength!==void 0&&(i.maxLength=n.maxLength),n.pattern&&(i.pattern=n.pattern),n.enum&&Array.isArray(n.enum)&&(i.enum=n.enum),n.minimum!==void 0&&(i.minimum=n.minimum),n.maximum!==void 0&&(i.maximum=n.maximum),n.minItems!==void 0&&(i.minItems=n.minItems),n.maxItems!==void 0&&(i.maxItems=n.maxItems),n.uniqueItems&&(i.uniqueItems=n.uniqueItems),i.type==="array"&&n.items&&typeof n.items=="object"&&!Array.isArray(n.items)&&(i.items=fe({item:n.items},[]).find(l=>l.key==="item")),n.properties&&typeof n.properties=="object"&&(i.children=fe(n.properties,Array.isArray(n.required)?n.required:[])),i}):[],ns=({schema:e,onChange:r,includeMetadata:s=!0})=>{const{properties:a,metadata:n}=S.useMemo(()=>rs(e),[e]),o=a,i=n||{title:"",description:"",version:""},l=S.useCallback(()=>({id:be(),key:"",type:"string",required:!1}),[]),p=S.useCallback((b,y)=>{const m=o.some(q=>q.id===b);let j;m?j=o.map(q=>q.id===b?y:q):j=[...o,y];const g=te(j,i,s);r(g)},[o,i,s,r]),c=S.useCallback(b=>{const y=o.filter(j=>j.id!==b),m=te(y,i,s);r(m)},[o,i,s,r]),d=S.useCallback(()=>{const y=te([],{title:"",description:""},s);r(y)},[s,r]),h=S.useCallback((b,y)=>{const m={...i,[b]:y},j=te(o,m,s);r(j)},[o,i,s,r]),f=S.useCallback(async()=>{const b=await es();r(b)},[r]),v=S.useCallback(()=>{He(e,"schema.json")},[e]);return{properties:o,metadata:i,addProperty:l,updateProperty:p,deleteProperty:c,clearAll:d,updateMetadata:h,importSchema:f,downloadSchema:v}};function as(){const[e,r]=S.useState("light");S.useEffect(()=>{const n=localStorage.getItem("theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");r(n),document.documentElement.classList.toggle("dark",n==="dark")},[]);const s=()=>{const a=e==="light"?"dark":"light";r(a),localStorage.setItem("theme",a),document.documentElement.classList.toggle("dark",a==="dark")};return t.jsx(O,{variant:"ghost",size:"icon",onClick:s,"data-testid":"button-theme-toggle",children:e==="light"?t.jsx(w.Moon,{className:"w-4 h-4"}):t.jsx(w.Sun,{className:"w-4 h-4"})})}function os({schema:e,onChange:r,showMetadata:s=!1,showImport:a=!0,showClear:n=!0,showOutput:o=!0,showHeader:i=!0,className:l="",showSummary:p=!1,typeLabels:c,propertyLabel:d={singular:"property",plural:"properties"},showRegex:h=!1,keyEditable:f=!1}){const{properties:v,metadata:b,addProperty:y,updateProperty:m,deleteProperty:j,clearAll:g,updateMetadata:q,importSchema:u}=ns({schema:e,onChange:r,includeMetadata:s}),z=ye({createInitialData:()=>y(),onConfirm:R=>{m(R.id,R)}}),V=()=>{g()},$=async()=>{await u()};return t.jsx(Jt,{customLabels:c,children:t.jsxs("div",{className:`${l} flex flex-col json-schema-builder-react`,children:[i&&t.jsx("header",{className:"h-16 border-b flex items-center justify-between px-6",children:t.jsxs("div",{className:"flex items-center gap-3",children:[a&&t.jsx(O,{variant:"outline",size:"sm",onClick:$,"data-testid":"button-import",children:t.jsx(w.Upload,{className:"w-4 h-4"})}),n&&t.jsx(O,{variant:"outline",size:"sm",onClick:V,disabled:v.length===0,"data-testid":"button-clear",children:t.jsx(w.Trash2,{className:"w-4 h-4"})}),t.jsx(as,{})]})}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:o?"w-3/5 border-r":"w-full",children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"flex-1 overflow-auto p-2 space-y-4",children:[s&&t.jsx(ss,{title:b.title,description:b.description,version:b.version,onUpdate:(R,D)=>q(R,D)}),v.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:t.jsx(w.Plus,{className:"w-8 h-8 text-muted-foreground"})}),t.jsxs("h2",{className:"text-lg font-medium mb-2",children:["No ",d.plural," yet"]}),t.jsxs("p",{className:"text-sm text-muted-foreground mb-6 max-w-sm",children:["Start building your JSON schema by adding your first"," ",d.singular]}),t.jsxs(O,{onClick:()=>z.open(),"data-testid":"button-add-first",children:[t.jsx(w.Plus,{className:"w-4 h-4 mr-2"}),"Add ",d.singular]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"space-y-1",children:v.map(R=>t.jsx(pe,{property:R,onUpdate:D=>m(R.id,D),onDelete:()=>j(R.id),showRegex:h,keyEditable:f},R.id))}),p&&t.jsxs("div",{className:"pt-4 border-t flex items-center justify-between text-sm text-muted-foreground",children:[t.jsxs("span",{children:[v.length," ",v.length===1?d.singular:d.plural]}),t.jsxs("span",{children:[v.filter(R=>R.required).length," required"]})]})]})]}),v.length>0&&t.jsx("div",{className:"border-t p-2 pt-4 bg-background",children:t.jsxs(O,{onClick:()=>z.open(),className:"w-full",variant:"outline","data-testid":"button-add-property",children:[t.jsx(w.Plus,{className:"w-4 h-4"}),"Add ",d.singular]})})]})}),o&&t.jsx("div",{className:"w-2/5",children:t.jsx(ts,{schema:e})})]}),z.isOpen&&z.data&&t.jsx(me,{property:z.data,open:z.isOpen,isNewProperty:!0,onOpenChange:z.setIsOpen,propertyLabel:d,onUpdate:z.confirm,showRegex:h,keyEditable:f})]})})}exports.JsonSchemaBuilder=os;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("react"),ge=require("@radix-ui/react-slot"),ae=require("class-variance-authority"),je=require("clsx"),ve=require("tailwind-merge"),u=require("lucide-react"),ye=require("@radix-ui/react-tooltip"),be=require("@radix-ui/react-select"),Ne=require("@radix-ui/react-dialog"),we=require("@radix-ui/react-label"),Ce=require("@radix-ui/react-checkbox");function F(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(a,s,r.get?r:{enumerable:!0,get:()=>t[s]})}}return a.default=t,Object.freeze(a)}const v=F(j),E=F(ye),w=F(be),L=F(Ne),ie=F(we),K=F(Ce);function f(...t){return ve.twMerge(je.clsx(t))}const ke=ae.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-full px-3 text-xs",lg:"h-10 rounded-full px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),I=v.forwardRef(({className:t,variant:a,size:s,asChild:r=!1,...i},l)=>{const n=r?ge.Slot:"button";return e.jsx(n,{className:f(ke({variant:a,size:s,className:t})),ref:l,...i})});I.displayName="Button";const D=v.forwardRef(({className:t,type:a,...s},r)=>e.jsx("input",{type:a,className:f("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:r,...s}));D.displayName="Input";const Se=E.Provider,Ie=E.Root,Te=E.Trigger,ne=v.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(E.Portal,{children:e.jsx(E.Content,{ref:r,sideOffset:a,className:f("z-50 overflow-hidden rounded-md bg-popover px-3 py-1.5 text-xs text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...s})}));ne.displayName=E.Content.displayName;const J=w.Root,V=w.Value,M=v.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(w.Trigger,{ref:r,className:f("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(w.Icon,{asChild:!0,children:e.jsx(u.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));M.displayName=w.Trigger.displayName;const re=v.forwardRef(({className:t,...a},s)=>e.jsx(w.ScrollUpButton,{ref:s,className:f("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(u.ChevronUp,{className:"h-4 w-4"})}));re.displayName=w.ScrollUpButton.displayName;const le=v.forwardRef(({className:t,...a},s)=>e.jsx(w.ScrollDownButton,{ref:s,className:f("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(u.ChevronDown,{className:"h-4 w-4"})}));le.displayName=w.ScrollDownButton.displayName;const _=v.forwardRef(({className:t,children:a,position:s="popper",...r},i)=>e.jsx(w.Portal,{children:e.jsxs(w.Content,{ref:i,className:f("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,...r,children:[e.jsx(re,{}),e.jsx(w.Viewport,{className:f("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(le,{})]})}));_.displayName=w.Content.displayName;const De=v.forwardRef(({className:t,...a},s)=>e.jsx(w.Label,{ref:s,className:f("px-2 py-1.5 text-sm font-semibold",t),...a}));De.displayName=w.Label.displayName;const k=v.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(w.Item,{ref:r,className:f("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(u.Check,{className:"h-4 w-4"})})}),e.jsx(w.ItemText,{children:a})]}));k.displayName=w.Item.displayName;const qe=v.forwardRef(({className:t,...a},s)=>e.jsx(w.Separator,{ref:s,className:f("-mx-1 my-1 h-px bg-muted",t),...a}));qe.displayName=w.Separator.displayName;const Pe=L.Root,Oe=L.Portal,de=v.forwardRef(({className:t,...a},s)=>e.jsx(L.Overlay,{ref:s,className:f("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));de.displayName=L.Overlay.displayName;const oe=v.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(Oe,{children:[e.jsx(de,{}),e.jsxs(L.Content,{ref:r,className:f("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s,children:[a,e.jsxs(L.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(u.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));oe.displayName=L.Content.displayName;const ce=({className:t,...a})=>e.jsx("div",{className:f("flex flex-col space-y-1.5 text-center sm:text-left",t),...a});ce.displayName="DialogHeader";const me=({className:t,...a})=>e.jsx("div",{className:f("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});me.displayName="DialogFooter";const ue=v.forwardRef(({className:t,...a},s)=>e.jsx(L.Title,{ref:s,className:f("text-lg font-semibold leading-none tracking-tight",t),...a}));ue.displayName=L.Title.displayName;const Le=v.forwardRef(({className:t,...a},s)=>e.jsx(L.Description,{ref:s,className:f("text-sm text-muted-foreground",t),...a}));Le.displayName=L.Description.displayName;const Re=ae.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),N=v.forwardRef(({className:t,...a},s)=>e.jsx(ie.Root,{ref:s,className:f(Re(),t),...a}));N.displayName=ie.Root.displayName;const H=v.forwardRef(({className:t,...a},s)=>e.jsx(K.Root,{ref:s,className:f("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e.jsx(K.Indicator,{className:f("grid place-content-center text-current"),children:e.jsx(u.Check,{className:"h-4 w-4"})})}));H.displayName=K.Root.displayName;const Y=v.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:f("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:s,...a}));Y.displayName="Textarea";const Ee=t=>t.trim().toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g,"_"),Fe=(t,a,s=!1,r=!1)=>{const i=(o,d)=>{a({...t,[o]:d})};return{handleTitleChange:o=>{i("title",o)},handleTitleBlur:()=>{if(s&&t.title){const o=Ee(t.title);i("key",o)}},handleKeyChange:o=>{(s||r)&&i("key",o)},handleFieldChange:i,handleConstraintChange:(o,d)=>{a({...t,[o]:d})}}},U={string:"String",number:"Number",integer:"Integer",boolean:"Boolean",object:"Object",array:"Array",null:"Null",file:"File"},he=j.createContext({getTypeLabel:t=>U[t],typeLabels:U});function ze({children:t,customLabels:a={}}){const s={...U,...a},r=i=>s[i]||i;return e.jsx(he.Provider,{value:{getTypeLabel:r,typeLabels:s},children:t})}function xe(){return j.useContext(he)}function X({property:t,open:a,onOpenChange:s,onUpdate:r,isArrayItem:i=!1,isNewProperty:l=!1,propertyLabel:n={singular:"Property",plural:"Properties"},showRegex:m=!1,keyEditable:C=!1}){var O;const{typeLabels:o}=xe(),[d,g]=j.useState(t);j.useEffect(()=>{a&&g(t)},[t,a]);const{handleTitleChange:y,handleTitleBlur:p,handleKeyChange:x,handleFieldChange:S,handleConstraintChange:b}=Fe(d,g,l,C),P=()=>{var c;(c=d.title)!=null&&c.trim()&&(r(d),s(!1))},h=()=>{g(t),s(!1)};return e.jsx(Pe,{open:a,onOpenChange:s,children:e.jsxs(oe,{className:"max-w-2xl max-h-[80vh] flex flex-col gap-0 p-0","data-testid":"dialog-edit-property",children:[e.jsx(ce,{className:"px-6 pt-6 pb-4 shrink-0",children:e.jsx(ue,{children:l?`Add ${n.singular}`:`Edit ${n.singular}`})}),e.jsxs("div",{className:"space-y-6 px-6 pb-4 overflow-y-auto flex-1 min-h-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(N,{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Type"]}),e.jsxs(J,{value:d.type,onValueChange:c=>S("type",c),"data-testid":"select-type-dialog",children:[e.jsx(M,{children:e.jsx(V,{})}),e.jsxs(_,{children:[e.jsx(k,{value:"string",children:o.string}),e.jsx(k,{value:"number",children:o.number}),e.jsx(k,{value:"integer",children:o.integer}),e.jsx(k,{value:"boolean",children:o.boolean}),e.jsx(k,{value:"object",children:o.object}),e.jsx(k,{value:"array",children:o.array}),e.jsx(k,{value:"file",children:o.file}),e.jsx(k,{value:"null",children:o.null})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(N,{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Title"]}),e.jsx(D,{value:d.title||"",onChange:c=>y(c.target.value),onBlur:p,placeholder:"Property Title","data-testid":"input-title-dialog",required:!0}),!l&&d.key&&e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["Key: ",d.key]})]}),(l||C)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Key"}),e.jsx(D,{value:d.key,onChange:c=>x(c.target.value),placeholder:"property_key","data-testid":"input-key-dialog"}),!l&&e.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-500",children:"⚠️ Changing the key may break existing references to this property"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Description"}),e.jsx(Y,{placeholder:"Optional description",value:d.description||"",onChange:c=>S("description",c.target.value),rows:2,"data-testid":"input-edit-description"})]}),d.type==="array"&&e.jsxs("div",{className:"space-y-2 border-l-2 border-border pl-4 mt-2",children:[e.jsxs(N,{className:"font-semibold text-xs text-muted-foreground",children:[o.array," Items"]}),d.items?e.jsxs("div",{className:"bg-muted/40 p-2 rounded",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Item Type"}),e.jsxs(J,{value:d.items.type,onValueChange:c=>g({...d,items:{...d.items,type:c}}),children:[e.jsx(M,{children:e.jsx(V,{})}),e.jsxs(_,{children:[e.jsx(k,{value:"string",children:o.string}),e.jsx(k,{value:"number",children:o.number}),e.jsx(k,{value:"integer",children:o.integer}),e.jsx(k,{value:"boolean",children:o.boolean}),e.jsx(k,{value:"object",children:o.object}),e.jsx(k,{value:"array",children:o.array}),e.jsx(k,{value:"file",children:o.file}),e.jsx(k,{value:"null",children:o.null})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Item Title"}),e.jsx(D,{value:d.items.title||"",onChange:c=>g({...d,items:{...d.items,title:c.target.value}}),placeholder:"Item Title"})]}),e.jsxs(I,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>g({...d,items:void 0}),children:["Remove ",o.array," Item Schema"]})]}):e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>{g({...d,items:{id:Date.now().toString()+Math.random(),key:"item",type:"string",required:!1}})},children:["Add ",o.array," Item Schema"]})]}),!i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{id:"prop-required",checked:d.required,onCheckedChange:c=>S("required",c),"data-testid":"checkbox-edit-required"}),e.jsx(N,{htmlFor:"prop-required",className:"cursor-pointer",children:"Required field"})]}),d.type==="string"&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsxs("h4",{className:"text-sm font-medium inline",children:[o.string," Constraints"]})}),e.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"min-length",children:"Minimum Length"}),e.jsx(D,{id:"min-length",type:"number",placeholder:"0",value:d.minLength||"",onChange:c=>b("minLength",c.target.value?parseInt(c.target.value):void 0),"data-testid":"input-edit-minlength"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"max-length",children:"Maximum Length"}),e.jsx(D,{id:"max-length",type:"number",placeholder:"∞",value:d.maxLength||"",onChange:c=>b("maxLength",c.target.value?parseInt(c.target.value):void 0),"data-testid":"input-edit-maxlength"})]})]}),m&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"pattern",children:"Pattern (regex)"}),e.jsx(D,{id:"pattern",placeholder:"^[a-z]+$",value:d.pattern||"",onChange:c=>b("pattern",c.target.value),className:"font-mono text-sm","data-testid":"input-edit-pattern"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Enum Values"}),e.jsx("div",{className:"space-y-2",children:[...d.enum||[],""].map((c,q)=>{var B;return e.jsx(D,{placeholder:q===(((B=d.enum)==null?void 0:B.length)||0)?"Add new value...":"Enum value",value:c,onChange:$=>{const T=$.target.value,R=d.enum||[];if(q===R.length)T.trim()&&b("enum",[...R,T.trim()]);else if(T.trim()){const z=[...R];z[q]=T.trim(),b("enum",z)}else{const z=R.filter((Ye,pe)=>pe!==q);b("enum",z.length>0?z:void 0)}},"data-testid":`input-edit-enum-${q}`},q)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter allowed values (empty fields will be removed)"})]})]})]}),(d.type==="number"||d.type==="integer")&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsx("h4",{className:"text-sm font-medium inline",children:"Numeric Constraints"})}),e.jsx("div",{className:"space-y-4 p-4 pt-0",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"minimum",children:"Minimum Value"}),e.jsx(D,{id:"minimum",type:"number",placeholder:"-∞",value:d.minimum??"",onChange:c=>b("minimum",c.target.value?parseFloat(c.target.value):void 0),"data-testid":"input-edit-minimum"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"maximum",children:"Maximum Value"}),e.jsx(D,{id:"maximum",type:"number",placeholder:"∞",value:d.maximum??"",onChange:c=>b("maximum",c.target.value?parseFloat(c.target.value):void 0),"data-testid":"input-edit-maximum"})]})]})})]}),d.type==="array"&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsxs("h4",{className:"text-sm font-medium inline",children:[o.array," Constraints"]})}),e.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"min-items",children:"Minimum Items"}),e.jsx(D,{id:"min-items",type:"number",placeholder:"0",value:d.minItems||"",onChange:c=>b("minItems",c.target.value?parseInt(c.target.value):void 0),"data-testid":"input-edit-minitems"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"max-items",children:"Maximum Items"}),e.jsx(D,{id:"max-items",type:"number",placeholder:"∞",value:d.maxItems||"",onChange:c=>b("maxItems",c.target.value?parseInt(c.target.value):void 0),"data-testid":"input-edit-maxitems"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{id:"unique-items",checked:d.uniqueItems||!1,onCheckedChange:c=>b("uniqueItems",c),"data-testid":"checkbox-edit-unique"}),e.jsx(N,{htmlFor:"unique-items",className:"cursor-pointer",children:"All items must be unique"})]})]})]})]}),e.jsxs(me,{className:"px-6 py-4 border-t bg-background shrink-0",children:[e.jsx(I,{variant:"outline",onClick:h,"data-testid":"button-cancel",children:"Cancel"}),e.jsx(I,{onClick:P,"data-testid":"button-save",disabled:!((O=d.title)!=null&&O.trim()),children:"Save Changes"})]})]})})}function se(t,a,s={}){const{allowEmpty:r=!1,onEditStart:i,onEditCancel:l}=s,[n,m]=j.useState(!1),[C,o]=j.useState(t);j.useEffect(()=>{n||o(t)},[t,n]);const d=()=>{o(t),m(!0),i==null||i()},g=x=>{o(x)},y=()=>{const x=C.trim();if(!r&&!x){o(t),m(!1);return}x!==t&&a(x),m(!1)};return{isEditing:n,value:C,startEdit:d,handleChange:g,handleBlur:y,handleKeyDown:x=>{x.key==="Enter"?y():x.key==="Escape"&&(o(t),m(!1),l==null||l())}}}function Be(t,a){const[s,r]=j.useState(!1);return{isChangingType:s,setIsChangingType:r,handleTypeChange:n=>{const m={...t,type:n};n!=="string"&&(delete m.minLength,delete m.maxLength,delete m.pattern,delete m.enum),n!=="number"&&n!=="integer"&&(delete m.minimum,delete m.maximum),n!=="array"&&(delete m.minItems,delete m.maxItems,delete m.uniqueItems,delete m.items),n!=="object"&&delete m.children,a(m),r(!1)},availableTypes:["string","number","integer","boolean","object","array","file"]}}const Z=()=>`${Date.now()}-${Math.random()}`;function ee(t={}){const{onConfirm:a,onCancel:s,createInitialData:r}=t,[i,l]=j.useState(!1),[n,m]=j.useState(null),C=y=>{const p=y??(r?r():null);m(p),l(!0)},o=()=>{l(!1),m(null),s==null||s()};return{isOpen:i,data:n,open:C,close:o,confirm:y=>{a==null||a(y),l(!1),m(null)},setIsOpen:y=>{y?l(!0):o()}}}function Ae(t,a){const s=ee({createInitialData:()=>({id:Z(),key:"",type:"string",required:!1}),onConfirm:l=>{a({...t,children:[...t.children||[],l]})}});return{addChild:()=>s.open(),updateChild:(l,n)=>{const m=t.children.map(C=>C.id===l?n:C);a({...t,children:m})},deleteChild:l=>{const n=t.children.filter(m=>m.id!==l);a({...t,children:n})},addChildDialog:{isOpen:s.isOpen,data:s.data,setIsOpen:s.setIsOpen,confirm:s.confirm}}}function G({property:t,onUpdate:a,onDelete:s,level:r=1,isArrayItem:i=!1,showRegex:l=!1,keyEditable:n=!1}){const{getTypeLabel:m,typeLabels:C}=xe(),o=ee(),d=se(t.title||t.key||"",h=>a({...t,title:h}),{allowEmpty:!1}),g=se(t.description||"",h=>a({...t,description:h||void 0}),{allowEmpty:!0}),y=Be(t,a),p=Ae(t,a),x=`h${Math.min(r,6)}`,S=t.type==="object",b=S&&t.children&&t.children.length>0,P={1:"text-lg font-semibold",2:"text-base",3:"text-base",4:"text-base",5:"text-sm",6:"text-sm"}[r]||"text-sm";return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex gap-4 items-center rounded-md -mx-2 px-2 py-1 transition-colors hover:bg-accent/50",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start gap-3",children:[!i&&e.jsx("button",{onClick:()=>a({...t,required:!t.required}),className:"shrink-0 transition-all hover:scale-110 mt-0.5",title:t.required?"Required field - click to make optional":"Optional field - click to make required",children:t.required?e.jsx("span",{className:"block w-4 h-4 rounded-full bg-primary"}):e.jsx("span",{className:"block w-4 h-4 rounded-full border border-dashed border-gray-400"})}),d.isEditing?e.jsx(D,{value:d.value,onChange:h=>d.handleChange(h.target.value),onBlur:d.handleBlur,onKeyDown:d.handleKeyDown,autoFocus:!0,className:P,placeholder:"Enter title"}):e.jsxs("div",{className:"flex gap-2 flex-wrap flex-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(x,{className:`${P} cursor-pointer hover:text-primary transition-colors leading-none`,onClick:d.startEdit,children:t.title||t.key||e.jsx("span",{className:"text-muted-foreground italic",children:"unnamed"})}),y.isChangingType?e.jsxs(J,{value:t.type,onValueChange:h=>y.handleTypeChange(h),open:y.isChangingType,onOpenChange:y.setIsChangingType,children:[e.jsx(M,{className:"w-[140px] h-7",children:e.jsx(V,{})}),e.jsx(_,{children:y.availableTypes.map(h=>e.jsx(k,{value:h,children:C[h]},h))})]}):e.jsx(Se,{children:e.jsxs(Ie,{children:[e.jsx(Te,{asChild:!0,children:e.jsxs("button",{onClick:()=>y.setIsChangingType(!0),className:"cursor-pointer hover:bg-accent rounded p-0.5 transition-colors",children:[t.type==="string"&&e.jsx(u.Type,{className:"w-5 h-5 text-muted-foreground"}),t.type==="number"&&e.jsx(u.Hash,{className:"w-5 h-5 text-muted-foreground"}),t.type==="integer"&&e.jsx(u.Hash,{className:"w-5 h-5 text-muted-foreground"}),t.type==="boolean"&&e.jsx(u.CheckSquare,{className:"w-5 h-5 text-muted-foreground"}),t.type==="object"&&e.jsx(u.Braces,{className:"w-5 h-5 text-muted-foreground"}),t.type==="array"&&e.jsx(u.List,{className:"w-5 h-5 text-muted-foreground"}),t.type==="file"&&e.jsx(u.FileText,{className:"w-5 h-5 text-muted-foreground"})]})}),e.jsxs(ne,{children:[m(t.type),t.type==="array"&&t.items?` of ${m(t.items.type)}`:"",e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Click to change type"})]})]})}),t.type==="object"&&e.jsx(I,{variant:"ghost",size:"icon",className:"opacity-0 group-hover:opacity-100 h-6 w-6",onClick:p.addChild,"data-testid":`button-add-child-${t.id}`,children:e.jsx(u.Plus,{className:"!w-5 !h-5"})})]}),e.jsx("div",{className:"flex-1",children:g.isEditing?e.jsx(D,{value:g.value,onChange:h=>g.handleChange(h.target.value),onBlur:g.handleBlur,onKeyDown:g.handleKeyDown,autoFocus:!0,className:"text-sm flex-1",placeholder:"Enter description"}):e.jsx(e.Fragment,{children:t.description?e.jsx("p",{className:"text-sm text-muted-foreground flex-1 min-w-[200px] cursor-pointer hover:text-foreground transition-colors","data-testid":`text-description-${t.id}`,onClick:g.startEdit,children:t.description}):e.jsx("p",{className:"text-sm text-muted-foreground/50 flex-1 min-w-[200px] cursor-pointer hover:text-muted-foreground italic transition-colors",onClick:g.startEdit,children:"Add description..."})})})]})]})}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>o.open(t),"data-testid":`button-edit-${t.id}`,children:e.jsx(u.Pencil,{className:"w-3 h-3"})}),S&&t.type!=="object"&&e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:p.addChild,"data-testid":`button-add-child-${t.id}`,children:e.jsx(u.Plus,{className:"w-3 h-3"})}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:s,"data-testid":`button-delete-${t.id}`,children:e.jsx(u.Trash2,{className:"w-3 h-3"})})]})]}),b&&e.jsx("div",{className:r===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:t.children.map(h=>e.jsx(G,{property:h,onUpdate:O=>p.updateChild(h.id,O),onDelete:()=>p.deleteChild(h.id),level:r+1,showRegex:l,keyEditable:n},h.id))}),t.type==="array"&&t.items&&e.jsxs("div",{className:r===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:[e.jsxs("div",{className:"mb-2 text-xs text-muted-foreground font-semibold uppercase",children:[m("array")," Items"]}),e.jsx(G,{property:t.items,onUpdate:h=>a({...t,items:h}),onDelete:()=>a({...t,items:void 0}),level:r+1,isArrayItem:!0,showRegex:l,keyEditable:n})]}),e.jsx(X,{property:o.data||t,open:o.isOpen,onOpenChange:o.setIsOpen,onUpdate:h=>{a(h),o.close()},isArrayItem:i,isNewProperty:!1,showRegex:l,keyEditable:n}),p.addChildDialog.isOpen&&p.addChildDialog.data&&e.jsx(X,{property:p.addChildDialog.data,open:p.addChildDialog.isOpen,isNewProperty:!0,onOpenChange:p.addChildDialog.setIsOpen,onUpdate:p.addChildDialog.confirm,showRegex:l,keyEditable:n})]})}const te=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("rounded-xl border bg-card text-card-foreground shadow",t),...a}));te.displayName="Card";const Me=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("flex flex-col space-y-1.5 p-6",t),...a}));Me.displayName="CardHeader";const _e=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("font-semibold leading-none tracking-tight",t),...a}));_e.displayName="CardTitle";const $e=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("text-sm text-muted-foreground",t),...a}));$e.displayName="CardDescription";const Ke=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("p-6 pt-0",t),...a}));Ke.displayName="CardContent";const Je=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("flex items-center p-6 pt-0",t),...a}));Je.displayName="CardFooter";const Ve=()=>new Promise((t,a)=>{const s=document.createElement("input");s.type="file",s.accept=".json",s.onchange=r=>{var n;const i=(n=r.target.files)==null?void 0:n[0];if(!i){a(new Error("No file selected"));return}const l=new FileReader;l.onload=m=>{var C;try{const o=JSON.parse((C=m.target)==null?void 0:C.result);t(o)}catch{a(new Error("Invalid JSON file"))}},l.onerror=()=>a(new Error("Failed to read file")),l.readAsText(i)},s.click()}),fe=(t,a="schema.json")=>{const s=JSON.stringify(t,null,2),r=new Blob([s],{type:"application/json"}),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=a,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)};function He({schema:t}){const[a,s]=j.useState(!1),r=JSON.stringify(t,null,2),i=async()=>{await navigator.clipboard.writeText(r),s(!0),setTimeout(()=>s(!1),2e3)},l=()=>{fe(t,"schema.json")};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h2",{className:"text-sm font-medium",children:"JSON Schema Output"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(I,{variant:"outline",size:"sm",onClick:i,"data-testid":"button-copy",children:a?e.jsx(u.CheckCircle2,{className:"w-4 h-4"}):e.jsx(u.Copy,{className:"w-4 h-4"})}),e.jsx(I,{variant:"outline",size:"sm",onClick:l,"data-testid":"button-download",children:e.jsx(u.Download,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(te,{className:"m-4 bg-muted/30",children:e.jsx("pre",{className:"p-6 text-xs font-mono overflow-auto","data-testid":"text-json-output",children:e.jsx("code",{children:r})})})})]})}function Ue({title:t,description:a,version:s,onUpdate:r}){const[i,l]=j.useState(!1);return e.jsxs(te,{className:"p-4",children:[e.jsxs(I,{variant:"ghost",onClick:()=>l(!i),className:"w-full justify-between px-2 h-auto hover:bg-transparent","data-testid":"button-toggle-metadata",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Schema Metadata"}),i?e.jsx(u.ChevronDown,{className:"w-4 h-4"}):e.jsx(u.ChevronRight,{className:"w-4 h-4"})]}),i&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"schema-title",className:"text-xs text-muted-foreground",children:"Title"}),e.jsx(D,{id:"schema-title",placeholder:"My Schema",value:t,onChange:n=>r("title",n.target.value),"data-testid":"input-title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"schema-description",className:"text-xs text-muted-foreground",children:"Description"}),e.jsx(Y,{id:"schema-description",placeholder:"Describe your schema...",value:a,onChange:n=>r("description",n.target.value),className:"resize-none",rows:3,"data-testid":"input-schema-description"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"schema-version",className:"text-xs text-muted-foreground",children:"Version"}),e.jsx(D,{id:"schema-version",placeholder:"1.0.0",value:s,onChange:n=>r("version",n.target.value),"data-testid":"input-version"})]})]})]})}const A=(t,a,s=!0)=>{const r={type:"object"};s&&a&&(a.title&&(r.title=a.title),a.description&&(r.description=a.description));const i=Q(t);Object.keys(i).length>0&&(r.properties=i);const l=t.filter(n=>n.required&&n.key).map(n=>n.key);return l.length>0&&(r.required=l),r},Q=t=>{const a={};return t.forEach(s=>{if(!s.key)return;const i={type:s.type==="file"?"string":s.type};if(s.title&&(i.title=s.title),s.description&&(i.description=s.description),s.type==="file"&&(i.format="filename"),s.type==="string"&&(s.minLength!==void 0&&(i.minLength=s.minLength),s.maxLength!==void 0&&(i.maxLength=s.maxLength),s.pattern&&(i.pattern=s.pattern),s.enum&&s.enum.length>0&&(i.enum=s.enum)),(s.type==="number"||s.type==="integer")&&(s.minimum!==void 0&&(i.minimum=s.minimum),s.maximum!==void 0&&(i.maximum=s.maximum)),s.type==="array"&&(s.minItems!==void 0&&(i.minItems=s.minItems),s.maxItems!==void 0&&(i.maxItems=s.maxItems),s.uniqueItems&&(i.uniqueItems=s.uniqueItems),s.items&&(i.items=Q([s.items])[s.items.key]||{type:s.items.type})),s.type==="object"&&s.children&&s.children.length>0){i.properties=Q(s.children);const l=s.children.filter(n=>n.required&&n.key).map(n=>n.key);l.length>0&&(i.required=l)}a[s.key]=i}),a},Xe=t=>{const a={properties:[]};return(t.title||t.description)&&(a.metadata={title:typeof t.title=="string"?t.title:"",description:typeof t.description=="string"?t.description:"",version:"1.0.0"}),t.properties&&typeof t.properties=="object"&&(a.properties=W(t.properties,Array.isArray(t.required)?t.required:[])),a},W=(t,a=[])=>t?Object.entries(t).filter(([,s])=>typeof s=="object").map(([s,r])=>{const i=r;let l=typeof i.type=="string"?i.type:"string";l==="string"&&i.format==="filename"&&(l="file");const n={id:Z(),key:s,title:typeof i.title=="string"?i.title:void 0,type:l,description:typeof i.description=="string"?i.description:void 0,required:a.includes(s)};return i.minLength!==void 0&&(n.minLength=i.minLength),i.maxLength!==void 0&&(n.maxLength=i.maxLength),i.pattern&&(n.pattern=i.pattern),i.enum&&Array.isArray(i.enum)&&(n.enum=i.enum),i.minimum!==void 0&&(n.minimum=i.minimum),i.maximum!==void 0&&(n.maximum=i.maximum),i.minItems!==void 0&&(n.minItems=i.minItems),i.maxItems!==void 0&&(n.maxItems=i.maxItems),i.uniqueItems&&(n.uniqueItems=i.uniqueItems),n.type==="array"&&i.items&&typeof i.items=="object"&&!Array.isArray(i.items)&&(n.items=W({item:i.items},[]).find(m=>m.key==="item")),i.properties&&typeof i.properties=="object"&&(n.children=W(i.properties,Array.isArray(i.required)?i.required:[])),n}):[],Ge=({schema:t,onChange:a,includeMetadata:s=!0})=>{const{properties:r,metadata:i}=j.useMemo(()=>Xe(t),[t]),l=r,n=i||{title:"",description:"",version:""},m=j.useCallback(()=>({id:Z(),key:"",type:"string",required:!1}),[]),C=j.useCallback((x,S)=>{const b=l.some(O=>O.id===x);let P;b?P=l.map(O=>O.id===x?S:O):P=[...l,S];const h=A(P,n,s);a(h)},[l,n,s,a]),o=j.useCallback(x=>{const S=l.filter(P=>P.id!==x),b=A(S,n,s);a(b)},[l,n,s,a]),d=j.useCallback(()=>{const S=A([],{title:"",description:""},s);a(S)},[s,a]),g=j.useCallback((x,S)=>{const b={...n,[x]:S},P=A(l,b,s);a(P)},[l,n,s,a]),y=j.useCallback(async()=>{const x=await Ve();a(x)},[a]),p=j.useCallback(()=>{fe(t,"schema.json")},[t]);return{properties:l,metadata:n,addProperty:m,updateProperty:C,deleteProperty:o,clearAll:d,updateMetadata:g,importSchema:y,downloadSchema:p}};function Qe(){const[t,a]=j.useState("light");j.useEffect(()=>{const i=localStorage.getItem("theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");a(i),document.documentElement.classList.toggle("dark",i==="dark")},[]);const s=()=>{const r=t==="light"?"dark":"light";a(r),localStorage.setItem("theme",r),document.documentElement.classList.toggle("dark",r==="dark")};return e.jsx(I,{variant:"ghost",size:"icon",onClick:s,"data-testid":"button-theme-toggle",children:t==="light"?e.jsx(u.Moon,{className:"w-4 h-4"}):e.jsx(u.Sun,{className:"w-4 h-4"})})}function We({schema:t,onChange:a,showMetadata:s=!1,showImport:r=!0,showClear:i=!0,showOutput:l=!0,showHeader:n=!0,className:m="",showSummary:C=!1,typeLabels:o,propertyLabel:d={singular:"property",plural:"properties"},showRegex:g=!1,keyEditable:y=!1}){const{properties:p,metadata:x,addProperty:S,updateProperty:b,deleteProperty:P,clearAll:h,updateMetadata:O,importSchema:c}=Ge({schema:t,onChange:a,includeMetadata:s}),q=ee({createInitialData:()=>S(),onConfirm:T=>{b(T.id,T)}}),B=()=>{h()},$=async()=>{await c()};return e.jsx(ze,{customLabels:o,children:e.jsxs("div",{className:`${m} flex flex-col json-schema-builder-react`,children:[n&&e.jsx("header",{className:"h-16 border-b flex items-center justify-between px-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx(I,{variant:"outline",size:"sm",onClick:$,"data-testid":"button-import",children:e.jsx(u.Upload,{className:"w-4 h-4"})}),i&&e.jsx(I,{variant:"outline",size:"sm",onClick:B,disabled:p.length===0,"data-testid":"button-clear",children:e.jsx(u.Trash2,{className:"w-4 h-4"})}),e.jsx(Qe,{})]})}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:l?"w-3/5 border-r":"w-full",children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 overflow-auto p-2 space-y-4",children:[s&&e.jsx(Ue,{title:x.title,description:x.description,version:x.version,onUpdate:(T,R)=>O(T,R)}),p.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:e.jsx(u.Plus,{className:"w-8 h-8 text-muted-foreground"})}),e.jsxs("h2",{className:"text-lg font-medium mb-2",children:["No ",d.plural," yet"]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6 max-w-sm",children:["Start building your JSON schema by adding your first"," ",d.singular]}),e.jsxs(I,{onClick:()=>q.open(),"data-testid":"button-add-first",children:[e.jsx(u.Plus,{className:"w-4 h-4 mr-2"}),"Add ",d.singular]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-1",children:p.map(T=>e.jsx(G,{property:T,onUpdate:R=>b(T.id,R),onDelete:()=>P(T.id),showRegex:g,keyEditable:y},T.id))}),C&&e.jsxs("div",{className:"pt-4 border-t flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[p.length," ",p.length===1?d.singular:d.plural]}),e.jsxs("span",{children:[p.filter(T=>T.required).length," required"]})]})]})]}),p.length>0&&e.jsx("div",{className:"border-t p-2 pt-4 bg-background",children:e.jsxs(I,{onClick:()=>q.open(),className:"w-full",variant:"outline","data-testid":"button-add-property",children:[e.jsx(u.Plus,{className:"w-4 h-4"}),"Add ",d.singular]})})]})}),l&&e.jsx("div",{className:"w-2/5",children:e.jsx(He,{schema:t})})]}),q.isOpen&&q.data&&e.jsx(X,{property:q.data,open:q.isOpen,isNewProperty:!0,onOpenChange:q.setIsOpen,propertyLabel:d,onUpdate:q.confirm,showRegex:g,keyEditable:y})]})})}exports.JsonSchemaBuilder=We;
2
2
  //# sourceMappingURL=index.cjs.map