@tempots/beatui 1.2.2 → 1.3.0

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.
Files changed (26) hide show
  1. package/dist/beatui.css +1096 -141
  2. package/dist/beatui.tailwind.css +1096 -141
  3. package/dist/deep-merge-Bydz6jLt.cjs +1 -0
  4. package/dist/{deep-merge-DwXDd3iF.js → deep-merge-CzZVsVF-.js} +1 -1
  5. package/dist/{duration-input-CjNZyVkf.cjs → duration-input-BrYLC1js.cjs} +1 -1
  6. package/dist/{duration-input-CnMMvPgT.js → duration-input-CFu6vq-y.js} +1 -1
  7. package/dist/index.cjs.js +4 -4
  8. package/dist/index.es.js +6359 -5270
  9. package/dist/json-schema/index.cjs.js +1 -1
  10. package/dist/json-schema/index.es.js +3 -3
  11. package/dist/json-structure/index.cjs.js +1 -1
  12. package/dist/json-structure/index.es.js +2 -2
  13. package/dist/types/components/form/input/index.d.ts +2 -1
  14. package/dist/types/components/form/input/multi-select.d.ts +98 -0
  15. package/dist/types/components/form/input/range-slider.d.ts +175 -0
  16. package/dist/types/components/media/carousel.d.ts +117 -0
  17. package/dist/types/components/media/index.d.ts +1 -0
  18. package/dist/types/components/navigation/index.d.ts +1 -0
  19. package/dist/types/components/navigation/navigation-progress.d.ts +72 -0
  20. package/dist/types/components/overlay/index.d.ts +1 -0
  21. package/dist/types/components/overlay/onboarding-tour.d.ts +98 -0
  22. package/dist/{widget-customization-D2a6SVP3.js → widget-customization-BAchyOUo.js} +1 -1
  23. package/dist/{widget-customization-CD_NyRQ8.cjs → widget-customization-DELy3SMQ.cjs} +1 -1
  24. package/package.json +1 -1
  25. package/dist/deep-merge-Bjv1NvKj.cjs +0 -1
  26. package/dist/types/components/form/input/advanced-slider.d.ts +0 -143
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@tempots/dom"),A=require("../oneof-branch-detection-BEkAezNi.cjs"),_=require("../translations-qefRsdGi.cjs"),Q=require("../notice-Q0A1gIho.cjs"),j=require("../widget-customization-CD_NyRQ8.cjs"),F=require("../stack-dwLevGa2.cjs"),v=require("../use-form-BvBkVEKi.cjs"),W=require("@tempots/std"),k=require("../deep-merge-Bjv1NvKj.cjs"),T=require("../utils-DmEuG3Np.cjs"),Se=require("../text-input-D_IxFd0M.cjs"),we=require("../input-container-BkPcNDaZ.cjs"),_e=require("ajv");function Oe(e){if(!e||typeof e!="object")return!1;const t=e;return!!(e.if||t.dependentRequired||t.dependentSchemas||e.dependencies)}function Ce(e,t,n,r=[]){if(!n)return null;try{if(A.compileWithCache(n,e)(t)){const o=e.title||"disallowed schema";return{path:r,message:`Value matches ${o}`,notSchema:e}}return null}catch{return null}}function Ae(e,t,n,r=[]){const i=[],a=[],o=ae(e,t,n);o&&i.push(o);const s=Array.isArray(e.required)?[...e.required]:[];if(typeof t=="object"&&t!=null&&!Array.isArray(t)){const m=t,f=e.dependentRequired;if(f){for(const[d,p]of Object.entries(f))if(Object.prototype.hasOwnProperty.call(m,d))for(const w of p)s.push(w)}const b=e.dependencies;if(b){for(const[d,p]of Object.entries(b))if(Object.prototype.hasOwnProperty.call(m,d))if(Array.isArray(p))for(const w of p)s.push(w);else typeof p=="object"&&p&&i.push(p)}const S=e.dependentSchemas;if(S)for(const[d,p]of Object.entries(S))Object.prototype.hasOwnProperty.call(m,d)&&i.push(p)}const u=[e,...i],{mergedSchema:c,conflicts:y}=A.mergeAllOf(u,r);if(s.length>0){const m=new Set([...c.required??[],...s]);c.required=[...m]}return a.push(...y),{effective:c,conflicts:a}}function ae(e,t,n){if(!n||!e.if||typeof e.if!="object")return null;try{if(A.compileWithCache(n,e.if)(t)){const a=e.then;if(a&&typeof a=="object")return a}else{const a=e.else;if(a&&typeof a=="object")return a}}catch{}return null}function J(e,t,n){const r=new Set;if(!t||typeof t!="object")return r;if(e.properties&&Object.keys(e.properties).forEach(o=>{o in t&&r.add(o)}),e.patternProperties&&Object.keys(t).forEach(o=>{Object.keys(e.patternProperties).forEach(s=>{try{new RegExp(s).test(o)&&r.add(o)}catch{}})}),e.additionalProperties===!0||e.additionalProperties&&typeof e.additionalProperties=="object"){const o=new Set;e.properties&&Object.keys(e.properties).forEach(s=>{s in t&&o.add(s)}),e.patternProperties&&Object.keys(t).forEach(s=>{Object.keys(e.patternProperties).forEach(u=>{try{new RegExp(u).test(s)&&o.add(s)}catch{}})}),Object.keys(t).forEach(s=>{o.has(s)||r.add(s)})}e.allOf&&e.allOf.forEach(o=>{typeof o=="object"&&J(o,t,n).forEach(u=>r.add(u))});const i=ae(e,t,n);i&&J(i,t,n).forEach(s=>r.add(s));const a=e.dependentSchemas;return a&&Object.keys(a).forEach(o=>{if(o in t){const s=a[o];typeof s=="object"&&J(s,t,n).forEach(c=>r.add(c))}}),e.dependencies&&Object.keys(e.dependencies).forEach(o=>{if(o in t){const s=e.dependencies[o];typeof s=="object"&&!Array.isArray(s)&&J(s,t,n).forEach(c=>r.add(c))}}),r}function $({ctx:e}){const{examples:t,default:n}=e;let{description:r}=e;r==null&&t!=null&&n!=null&&(Array.isArray(t)?r=`example: ${t[0]}`:r=`example: ${t}`);const i=[];if(e.isDeprecated&&i.push("deprecated"),e.isReadOnly&&!e.shouldIgnoreReadOnly&&i.push("read-only"),e.isWriteOnly&&!e.shouldShowWriteOnly&&i.push("write-only"),i.length>0){const a=`(${i.join(", ")})`;r=r?`${r} ${a}`:a}return{label:e.suppressLabel?void 0:e.widgetLabel,description:r,required:e.isPropertyRequired,layout:e.horizontal?"horizontal":"vertical"}}function G(e,t){if(e.default!=null)return t(e.default);if(Array.isArray(e.examples))return t(e.examples[0]);if(e.examples!=null)return t(e.examples)}function je(e){return e==null?1:Math.round(e)}function oe(e){return e.isWriteOnly&&!e.shouldShowWriteOnly}function se(e){return e.isReadOnly&&!e.shouldIgnoreReadOnly||e.isDeprecated}function R({ctx:e,controller:t,resolved:n}){const r=n?.widget,i={controller:t,ctx:e,options:n?.options,setStatus:e.setStatus,formValue:e.formValue,validationMode:e.validationMode,submitting:e.submitting};if(r!=null&&e.widgetRegistry){const o=e.widgetRegistry.get(r);if(o)return o.factory(i)}if(r!=null){const o=j.globalWidgetRegistry.get(r);if(o)return o.factory(i)}if(e.widgetRegistry){const o=e.widgetRegistry.findBestWidget(e);if(o)return o.registration.factory(i)}const a=j.globalWidgetRegistry.findBestWidget(e);return a?a.registration.factory(i):null}function ke(e){const{options:t,selected:n,onChange:r,mode:i="auto",size:a="sm",keyFor:o=y=>String(y),parseKey:s=y=>y}=e,u=t.length;if((i==="auto"?u<=3?"segmented":"select":i)==="segmented"){const y=Object.fromEntries(t.map(m=>[o(m.value),m.label]));return k.SegmentedInput({options:y,value:l.Value.map(n,m=>o(m)),onChange:m=>r(s(m)),size:a})}return k.NativeSelect({options:t.map(y=>({type:"value",value:y.value,label:y.label})),value:n,onChange:r})}function Ie({ctx:e,showSelector:t,selector:n,inner:r}){return e.isRoot?t?F.Stack(l.attr.class("bc-stack--gap-2"),n,r):r:v.InputWrapper({...$({ctx:e}),content:t?F.Stack(l.attr.class("bc-stack--gap-2 bc-stack--align-start"),n,r):r})}function Ke(e,t){if(e===null)return t.includes("null")?"null":null;switch(typeof e){case"string":return t.includes("string")?"string":null;case"number":return Number.isInteger(e)&&t.includes("integer")?"integer":t.includes("number")?"number":null;case"boolean":return t.includes("boolean")?"boolean":null;case"object":return Array.isArray(e)?t.includes("array")?"array":null:t.includes("object")?"object":null;default:return null}}function ze(e,t){try{switch(t){case"string":return e==null?{ok:!0,value:void 0}:{ok:!0,value:String(e)};case"number":{if(typeof e=="number")return{ok:!0,value:e};if(typeof e=="string"){const n=Number(e);return Number.isFinite(n)?{ok:!0,value:n}:{ok:!1}}return typeof e=="boolean"?{ok:!0,value:e?1:0}:{ok:!1}}case"integer":return typeof e=="number"&&Number.isInteger(e)?{ok:!0,value:e}:typeof e=="string"?/^[-+]?\d+$/.test(e.trim())?{ok:!0,value:parseInt(e,10)}:{ok:!1}:typeof e=="boolean"?{ok:!0,value:e?1:0}:{ok:!1};case"boolean":{if(typeof e=="boolean")return{ok:!0,value:e};if(typeof e=="string"){const n=e.trim().toLowerCase();return n==="true"||n==="1"||n==="yes"?{ok:!0,value:!0}:n==="false"||n==="0"||n==="no"?{ok:!0,value:!1}:{ok:!1}}return typeof e=="number"?{ok:!0,value:e!==0}:{ok:!1}}case"array":return Array.isArray(e)?{ok:!0,value:e}:{ok:!1};case"object":return e!=null&&typeof e=="object"&&!Array.isArray(e)?{ok:!0,value:e}:{ok:!1};case"null":return{ok:!0,value:null}}}catch{return{ok:!1}}}function He(e){switch(e){case"null":return null;case"array":return[];case"object":return{};default:return}}function Ge(e){if(typeof e=="boolean")return{};const t=e["x:ui"];if(t!=null&&typeof t=="object"&&!Array.isArray(t)){const n=t;return{unionDefault:typeof n.unionDefault=="string"?n.unionDefault:void 0,confirmBranchChange:!!n.confirmBranchChange,selector:n.selector==="segmented"||n.selector==="select"?n.selector:void 0}}return{}}function Xe(e){const{definition:t}=e;if(typeof t=="boolean")return;const n={pattern:t.pattern,minLength:t.minLength,maxLength:t.maxLength},r=T.resolveWidget(t,e.name),i=r?.widget;if(i!=null)switch(i){case"binary":return{...n,format:"binary",...r?.options};case"date":return{...n,format:"date"};case"date-time":return{...n,format:"date-time"};case"email":return{...n,format:"email"};case"markdown":return{...n,format:"markdown"};case"password":return{...n,format:"password"};case"textarea":return{...n,format:"textarea"};case"time":return{...n,format:"time"};case"uuid":return{format:"uuid"};case"url":return{...n,format:"url"};case"uri":return{...n,format:"uri"};case"uri-reference":return{...n,format:"uri-reference"};case"hostname":return{...n,format:"hostname"};case"ipv4":return{...n,format:"ipv4"};case"ipv6":return{...n,format:"ipv6"};case"regex":return{...n,format:"regex"};case"duration":return{...n,format:"duration"};case"color":return{...n,format:"color"}}}const Ye=e=>{const{after:t,disabled:n}=e,r=Se.mapInputOptions(e,a=>a??void 0,a=>a??null),i=k.NullableResetAfter(e.value,n,e.onChange??e.onInput);return j.Base64Input({...r,after:t!=null?l.Fragment(i,t):i})};function de({ctx:e,options:t,controller:n}){const r=Xe(e),i=!e.isNullable,a=()=>i?k.transformNullToUndefined(n):n;switch(r?.format){case"email":return v.Control(j.NullableEmailInput,{...t,controller:a()});case"date":return v.MappedControl(j.NullableDateInput,{...t,controller:a(),toInput:o=>o==null?null:new Date(o),fromInput:o=>o?.toISOString().split("T")[0]??null});case"date-time":return v.MappedControl(j.NullableDateTimeInput,{...t,controller:a(),toInput:o=>o==null?null:new Date(o),fromInput:o=>o?.toISOString()??null});case"time":return v.Control(j.NullableTextInput,{...t,controller:a(),placeholder:"HH:MM:SS"});case"password":return v.Control(j.NullablePasswordInput,{...t,controller:a()});case"binary":{const{definition:o}=e,s=typeof o=="object"?o["x:ui"]:void 0;return r.mediaType&&(r.mediaType.startsWith("image/")||r.mediaType.startsWith("video/")||r.mediaType.startsWith("audio/")||r.mediaType==="application/pdf"||s?.preferFileUpload===!0)?v.Control(Ye,{...t,controller:a(),mode:"input",accept:r.mediaType||"*/*",maxFileSize:(typeof s?.maxBytes=="number"?s.maxBytes:void 0)||(typeof s?.maxFileSize=="number"?s.maxFileSize:void 0),showFileList:!0}):v.Control(j.NullableTextArea,{...t,controller:a(),placeholder:"Paste base64-encoded data",rows:3})}case"uri":case"url":return v.Control(j.NullableUrlInput,{...t,controller:a(),placeholder:"https://example.com"});case"uri-reference":return v.Control(j.NullableTextInput,{...t,controller:a(),placeholder:"Enter URL..."});case"hostname":return v.Control(j.NullableTextInput,{...t,controller:a(),placeholder:"example.com"});case"ipv4":return v.Control(j.NullableTextInput,{...t,controller:a(),placeholder:"192.168.1.1"});case"ipv6":return v.Control(j.NullableTextInput,{...t,controller:a(),placeholder:"2001:db8::1"});case"regex":return v.Control(j.NullableTextArea,{...t,controller:a(),placeholder:"^[a-zA-Z0-9]+$",rows:3});case"duration":return k.WithTemporal(({Duration:o})=>v.MappedControl(k.NullableDurationInput,{...t,controller:a(),toInput:s=>s==null?null:o.from(s),fromInput:s=>s?.toString?.()??null}));case"color":return v.Control(j.ColorSwatchInput,{...t,controller:n,displayValue:!0});case"uuid":return v.Control(j.NullableUuidInput,{...t,controller:a()});case"textarea":return v.Control(j.NullableTextArea,{...t,controller:a()});default:return v.Control(j.NullableTextInput,{...t,controller:a()})}}function ee({ctx:e,controller:t}){if(oe(e))return l.Empty;const n=T.resolveWidget(e.definition,e.name),r=n?.widget,i=R({ctx:e,controller:t,resolved:n});if(i)return i;const a={...$({ctx:e}),placeholder:G(e.definition,String),disabled:se(e)};if((e.isNullable||e.isOptional)&&!e.shouldShowPresenceToggle)return de({ctx:e,options:a,controller:t});if(r!=null&&["url","uri","uri-reference","hostname","ipv4","ipv6","regex","duration","binary","markdown","time","color"].includes(r))return de({ctx:e,options:a,controller:t});switch(r){case"email":return v.Control(Q.EmailInput,{...a,controller:k.transformEmptyStringToUndefined(t)});case"password":return v.Control(Q.PasswordInput,{...a,controller:k.transformEmptyStringToUndefined(t)});case"uuid":return v.Control(k.UuidInput,{...a,controller:k.transformEmptyStringToUndefined(t)});case"textarea":return v.Control(k.TextArea,{...a,controller:k.transformEmptyStringToUndefined(t)});default:return v.Control(Se.TextInput,{...a,controller:k.transformEmptyStringToUndefined(t)})}}function Ze(e){const t=T.resolveWidget(e.definition,e.name);if(t?.widget==="slider")return{widget:"slider",options:t.options};if(t?.widget==="rating")return{widget:"rating",options:t.options};const n=e.definition,r=typeof n=="object"?n["x:ui"]:void 0;return r?.displayFormat==="currency"?{widget:"currency",options:{currency:typeof r?.currency=="string"?r.currency:"USD"}}:r?.displayFormat==="percent"?{widget:"percent"}:{widget:"number"}}function X({ctx:e,controller:t}){if(oe(e))return l.Empty;const n=e.definition,r=Ze(e),i=T.resolveWidget(e.definition,e.name),a=R({ctx:e,controller:t,resolved:i});if(a)return a;const o={...$({ctx:e}),placeholder:G(e.definition,String),min:n.minimum,max:n.maximum,step:n.multipleOf,disabled:se(e)},s=(e.isNullable||e.isOptional)&&!e.shouldShowPresenceToggle,u=s&&!e.isNullable;switch(r.widget){case"rating":const c=(typeof r.options?.max=="number"?r.options.max:n.maximum)||5;return s?v.Control(j.NullableRatingInput,{...o,max:c,controller:u?k.transformNullToUndefined(t):t}):v.Control(j.RatingInput,{...o,max:c,controller:t});case"slider":return s?v.Control(j.NullableSliderInput,{...o,controller:u?k.transformNullToUndefined(t):t}):v.Control(j.SliderInput,{...o,controller:t});case"currency":const y=typeof r.options?.currency=="string"?r.options.currency:"USD";return s?v.Control(k.MaskInput,{...o,mask:pe(y),controller:t}):v.Control(k.MaskInput,{...o,mask:pe(y),controller:t});case"percent":return s?v.Control(k.MaskInput,{...o,mask:me(),controller:t}):v.Control(k.MaskInput,{...o,mask:me(),controller:t});default:return s?v.Control(k.NullableNumberInput,{...o,controller:u?k.transformNullToUndefined(t):t}):v.Control(k.NumberInput,{...o,controller:t})}}function pe(e){return`${Qe(e)} 000,000.00`}function me(){return"000.00%"}function Qe(e){return{USD:"$",EUR:"€",GBP:"£",JPY:"¥",CAD:"C$",AUD:"A$"}[e.toUpperCase()]||e}function te({ctx:e,controller:t}){return X({ctx:e.with({definition:{...e.definition,multipleOf:je(e.definition.multipleOf)}}),controller:t})}function ne({ctx:e,controller:t}){if(oe(e))return l.Empty;const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i={...$({ctx:e}),disabled:se(e)},a=v.Control(v.CheckboxInput,{...i,controller:t});if(!e.isNullable&&(!e.isOptional||e.shouldShowPresenceToggle))return a;const o=!e.isNullable;return v.Control(v.CheckboxInput,{...i,controller:t,after:k.NullableResetAfter(t.signal,t.disabled,()=>t.change(o?void 0:null))})}function le({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});return r||l.WithElement(()=>{t.change(null)})}function et({conflicts:e}){return e.length===0?l.Empty:l.Use(_.BeatUII18n,t=>Q.Notice({variant:"warning",tone:"prominent",title:t.value.schemaConflictsDetected,class:"bc-schema-conflicts-banner"},l.html.ul(l.attr.style("margin: 0; padding-left: 1.25rem; list-style-type: disc;"),...e.map(n=>l.html.li(l.attr.style("margin-bottom: 0.25rem;"),n.message,n.path.length>0?l.html.code(l.attr.style("margin-left: 0.5rem; font-size: 0.75rem; opacity: 0.7;"),` (${n.path.join(".")})`):null)))))}function tt({violations:e}){return e.length===0?l.Empty:l.Use(_.BeatUII18n,t=>Q.Notice({variant:"danger",tone:"prominent",title:t.value.schemaViolationsDetected,class:"bc-not-violations-banner"},l.html.ul(l.attr.style("margin: 0; padding-left: 1.25rem; list-style-type: disc;"),...e.map(n=>l.html.li(l.attr.style("margin-bottom: 0.25rem;"),n.message,n.path.length>0?l.html.code(l.attr.style("margin-left: 0.5rem; font-size: 0.75rem; opacity: 0.7;"),` (${n.path.join(".")})`):null)))))}function nt({ctx:e,controller:t,content:n}){const r=l.Value.map(t.signal,o=>o!==void 0),i=e.widgetLabel??"Property",a=o=>{if(o){const s=e.default;if(s!==void 0)t.change(s);else{const u=e.definition;u.type==="string"?t.change(""):u.type==="number"||u.type==="integer"?t.change(0):u.type==="boolean"?t.change(!1):u.type==="array"?t.change([]):u.type==="object"?t.change({}):t.change(null)}}else t.change(void 0)};return F.Stack(l.html.div(l.attr.class("bc-presence-toggle"),v.InputWrapper({layout:"horizontal",label:`Include ${i}`,content:j.Switch({value:r,onChange:a,size:"xs"})})),l.When(r,()=>n))}function V(e,t,n){const r=e.schemaConflicts.length>0,i=e.notViolations.length>0,a=e.shouldShowPresenceToggle&&n!=null;let o=t;return a&&n!=null&&(o=nt({ctx:e,controller:n,content:t})),!r&&!i?o:F.Stack(l.attr.class("bc-stack--gap-2"),i?tt({violations:e.notViolations}):null,r?et({conflicts:e.schemaConflicts}):null,o)}function Ne(e){if(typeof e=="boolean")return;const t=e["x:ui"];if(!t||!t.visibleIf)return;const n=t.visibleIf;if(typeof n=="string"||typeof n=="object"&&n!==null)return n}function rt(e){if(e.startsWith("!"))return{field:e.slice(1),operator:"falsy"};if(e.includes("!=")){const[t,n]=e.split("!=",2);return{field:t.trim(),operator:"notEquals",value:ye(n.trim())}}if(e.includes("=")){const[t,n]=e.split("=",2);return{field:t.trim(),operator:"equals",value:ye(n.trim())}}return{field:e.trim(),operator:"truthy"}}function ye(e){if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e!=="undefined")return/^-?\d+(\.\d+)?$/.test(e)?parseFloat(e):e}function it(e,t){if(e==null||typeof e!="object")return;const n=t.split(".");let r=e;for(const i of n){if(r==null||typeof r!="object")return;if(Array.isArray(r)){const a=parseInt(i,10);if(!isNaN(a))r=r[a];else return}else r=r[i]}return r}function re(e,t){const n=it(t,e.field);switch(e.operator){case"equals":return n===e.value;case"notEquals":return n!==e.value;case"truthy":return!!n;case"falsy":return!n;case"contains":return typeof n=="string"&&typeof e.value=="string"||Array.isArray(n)?n.includes(e.value):!1;case"notContains":return typeof n=="string"&&typeof e.value=="string"||Array.isArray(n)?!n.includes(e.value):!0;case"greaterThan":return typeof n=="number"&&typeof e.value=="number"&&n>e.value;case"lessThan":return typeof n=="number"&&typeof e.value=="number"&&n<e.value;case"greaterThanOrEqual":return typeof n=="number"&&typeof e.value=="number"&&n>=e.value;case"lessThanOrEqual":return typeof n=="number"&&typeof e.value=="number"&&n<=e.value;case"in":return Array.isArray(e.values)&&e.values.includes(n);case"notIn":return!Array.isArray(e.values)||!e.values.includes(n);default:return!1}}function Pe(e,t){const n=e.conditions.map(r=>"operator"in r&&["and","or","not"].includes(r.operator)?Pe(r,t):re(r,t));switch(e.operator){case"and":return n.every(Boolean);case"or":return n.some(Boolean);case"not":return!n[0];default:return!1}}function at(e,t){try{if(typeof e=="string"){const n=rt(e);return re(n,t)}return"operator"in e&&["and","or","not"].includes(e.operator)?Pe(e,t):re(e,t)}catch(n){return console.warn("Error evaluating visibility condition:",n),!0}}function ot(e,t){return l.computedOf(t)(n=>at(e,n))}const ge={behavior:"hide",clearOnHide:!1};function st({ctx:e,controller:t,children:n,options:r=ge}){const i=Ne(e.definition);if(!i)return n;const a={...ge,...r},o=lt(t),s=ot(i,o);return a.clearOnHide&&s.on(u=>{!u&&t.signal.value!==void 0&&t.change(void 0)}),a.behavior==="unmount"?l.When(s,()=>n):n}function lt(e){return e.signal}function Ve({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const a=e.definition.enum??[],o=(e.isNullable||e.isOptional)&&!a.includes(null),s=!e.isNullable;return l.Use(_.BeatUII18n,u=>{const c=a.map(m=>({type:"value",value:m,label:String(m)}));o&&c.unshift({type:"value",value:null,label:l.Value.get(u.$.selectNone)});const y=o&&s?k.transformNullToUndefined(t):t;return k.NativeSelectControl({...$({ctx:e}),options:c,controller:y,equality:(m,f)=>m==null&&f==null?!0:m===f})})}function Ee({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition;return l.Fragment(l.WithElement(()=>{l.Value.get(t.signal)!==i.const&&t.change(i.const)}),k.Group(F.MutedLabel(e.widgetLabel,": "),F.Label(String(i.const))))}function Te(e,t,n){const{controller:r,effCtx:i,patternProps:a,apSchema:o,canRemove:s,lockKeyAfterSet:u,validatePropertyName:c}=n,y=r.field(e),m=l.prop(e),f=l.prop(null);let b=o;if(t){const w=Object.keys(a).find(h=>{try{return new RegExp(h).test(e)}catch{return!1}});if(w){const h=a[w];h!==!1&&typeof h=="object"&&(b=h)}}const S=w=>{const h=(w??"").trim();if(!h||h===e||Object.prototype.hasOwnProperty.call(l.Value.get(r.signal)??{},h))return;const g=c(h);if(!g.ok){f.set(g.message);return}f.set(null);const O={...l.Value.get(r.signal)??{}},C=O[e];delete O[e],O[h]=C,r.change(O)},d=l.Use(_.BeatUII18n,w=>v.CloseButton({size:"xs",label:w.$.removeItem,disabled:!s(Object.keys(l.Value.get(r.signal)??{}).length),onClick:()=>{const h=Object.keys(l.Value.get(r.signal)??{}).length;if(!s(h))return;const g={...l.Value.get(r.signal)??{}};delete g[e],r.change(g)}})),p=l.Value.map(y.signal,w=>u&&w!=null);return l.html.div(l.attr.class("bc-object-helpers__row"),l.style.gridTemplateColumns("2fr 3fr min-content"),v.InputWrapper({content:j.EditableText({value:m,onChange:S,disabled:l.computedOf(r.disabled,p)((w,h)=>w||h)}),error:l.Ensure(f,w=>l.html.div(l.attr.class("bc-object-helpers__error"),w)),description:Object.keys(a).length>0?l.html.div(l.attr.class("bc-object-helpers__description"),"Allowed patterns: ",Object.keys(a).join(", ")):null}),l.html.div(B({ctx:i.with({definition:b,suppressLabel:!0}).append(e),controller:y})),l.html.div(l.attr.class("bc-object-helpers__remove"),d))}function Fe(e,t,n){const{controller:r,effCtx:i,patternProps:a,apSchema:o,unevaluatedProps:s,canRemove:u,lockKeyAfterSet:c,validatePropertyName:y}=n,m=r.field(e),f=l.prop(e),b=l.prop(null);let S;if(s&&typeof s=="object")S=s;else if(t){const h=Object.keys(a).find(g=>{try{return new RegExp(g).test(e)}catch{return!1}});if(h){const g=a[h];g!==!1&&typeof g=="object"?S=g:S=o}else S=o}else S=o;const d=h=>{const g=(h??"").trim();if(!g||g===e||Object.prototype.hasOwnProperty.call(l.Value.get(r.signal)??{},g))return;const O=y(g);if(!O.ok){b.set(O.message);return}b.set(null);const C={...l.Value.get(r.signal)??{}},N=C[e];delete C[e],C[g]=N,r.change(C)},p=l.Use(_.BeatUII18n,h=>v.CloseButton({size:"xs",label:h.$.removeItem,disabled:!u(Object.keys(l.Value.get(r.signal)??{}).length),onClick:()=>{const g=Object.keys(l.Value.get(r.signal)??{}).length;if(!u(g))return;const O={...l.Value.get(r.signal)??{}};delete O[e],r.change(O)}})),w=l.Value.map(m.signal,h=>c&&h!=null);return l.html.div(l.attr.class("bc-object-helpers__row"),l.style.gridTemplateColumns("2fr 3fr min-content"),v.InputWrapper({content:j.EditableText({value:f,onChange:d,disabled:l.computedOf(r.disabled,w)((h,g)=>h||g)}),error:l.Ensure(b,h=>l.html.div(l.attr.class("bc-object-helpers__error"),h)),description:l.html.div(l.attr.class("bc-object-helpers__description"),s===!1?"Unevaluated property (not allowed by schema)":"Unevaluated property",Object.keys(a).length>0?l.html.span(" • Allowed patterns: ",Object.keys(a).join(", ")):null)}),l.html.div(B({ctx:i.with({definition:S,suppressLabel:!0}).append(e),controller:m})),l.html.div(l.attr.class("bc-object-helpers__remove"),p))}function We(e){const t=e.properties??{},n=new Set(Object.keys(t)),r=e.additionalProperties??!0,i=r!==!1,a=r===!0||r===void 0?{}:r,o=e.minProperties??0,s=e.maxProperties??1/0,u=e.unevaluatedProperties;let c=!0,y=null;u===!1?(c=!1,y="No unevaluated properties are allowed by schema"):u&&typeof u=="object"&&(c=!0);const m=e.patternProperties??{},f=Object.keys(m).filter(Boolean).map(p=>{try{return new RegExp(p)}catch{return null}}).filter(p=>p!=null),b=e.propertyNames,S=e["x:ui"],d=!!(S&&typeof S=="object"&&S.lockKeyAfterSet);return{knownProps:t,knownKeys:n,ap:r,apAllowed:i,apSchema:a,minProps:o,maxProps:s,unevaluatedProps:u,canAddUnevaluated:c,unevaluatedTooltip:y,patternProps:m,patternList:f,propertyNamesDef:b,lockKeyAfterSet:d}}function Re(e,t){const{knownKeys:n,apAllowed:r,patternList:i,patternProps:a,propertyNamesDef:o}=e;return s=>{const u=(s??"").trim();if(u==="")return{ok:!1,message:"Key cannot be empty"};if(o===!1)return{ok:!1,message:"No property names are allowed by schema"};if(o&&typeof o=="object"&&t)try{const c=t.compile(o);if(!c(u))return{ok:!1,message:c.errors?.[0]?.message??"Invalid property name"}}catch{}if(!r&&!n.has(u)){if(i.length===0)return{ok:!1,message:"Only declared properties are allowed"};if(!i.some(y=>y.test(u)))return{ok:!1,message:`Key must match one of: ${Object.keys(a).join(", ")}`}}return{ok:!0}}}function Me(e){const{minProps:t,apSchema:n,unevaluatedProps:r}=e;return{canRemove:s=>s>t,makeDefaultFor:s=>{const u=G(s,y=>y);if(u!==void 0)return u;const c=s.type;if(c==="string")return"";if(c==="number"||c==="integer")return 0;if(c==="boolean")return!1;if(c==="array")return[];if(c==="object")return{}},getValueSchemaForNew:()=>r&&typeof r=="object"?r:n}}function ut({ctx:e,controller:t,config:n,effective:r}){const i=W.objectEntries(n.knownProps).filter(([,s])=>s!==!1),a=i.map(([s])=>s);return{children:i.map(([s,u])=>{const c=s,y=t.field(c);return B({ctx:e.with({definition:u,isPropertyRequired:Array.isArray(r.required)?r.required.includes(c):e.hasRequiredProperty(c),suppressLabel:!1}).append(c),controller:y})}),names:a}}function ct({controller:e,config:t,validatePropertyName:n,helpers:r}){if(!t.apAllowed)return null;const i=(a,o)=>{const s=a,u=y=>o.has(y)?!1:n(y).ok;if(u(s))return s;let c=1;for(;o.has(s+c)||!u(s+c);)c++;return s+c};return l.Use(_.BeatUII18n,a=>we.Button({variant:"outline",disabled:l.Value.map(e.signal,o=>!t.canAddUnevaluated||Object.keys(o??{}).length>=t.maxProps),onClick:()=>{const o=l.Value.get(e.signal)??{},s=Object.keys(o);if(!t.canAddUnevaluated||s.length>=t.maxProps)return;const u=new Set(s),c=i("property",u);if(!n(c).ok)return;const m=r.getValueSchemaForNew(),f=r.makeDefaultFor(m),b={...o,[c]:f};e.change(b)}},l.attr.title(t.unevaluatedTooltip),a.$.addLabel))}function Le({ctx:e,containerLayout:t,content:n}){return!e.suppressLabel&&e.name!=null&&(!t||!["fieldset","group"].includes(t.format||""))?v.InputWrapper({...$({ctx:e}),content:n}):n}function ft({ctx:e,controller:t,baseDef:n}){const r=We(n),i=Re(r,e.ajv),a=Me(r),{children:o,names:s}=ut({ctx:e,controller:t,config:r,effective:n}),u=l.MapSignal(t.signal,b=>{const d=Object.keys(b??{}).filter(g=>!r.knownKeys.has(g));if(d.length===0)return l.Empty;const p=J(n,b??{},e.ajv),w=d.filter(g=>!p.has(g)),h=d.filter(g=>p.has(g));return l.Fragment(...h.map(g=>{const O=r.patternList.some(C=>C.test(g));return Te(g,O,{controller:t,effCtx:e,patternProps:r.patternProps,apSchema:r.apSchema,canRemove:a.canRemove,lockKeyAfterSet:r.lockKeyAfterSet,validatePropertyName:i})}),...w.map(g=>{const O=r.patternList.some(C=>C.test(g));return Fe(g,O,{controller:t,effCtx:e,patternProps:r.patternProps,apSchema:r.apSchema,unevaluatedProps:r.unevaluatedProps,canRemove:a.canRemove,lockKeyAfterSet:r.lockKeyAfterSet,validatePropertyName:i})}))}),c=ct({controller:t,config:r,validatePropertyName:i,helpers:a}),y=A.getContainerLayout(e),m=[...o,u,c].filter(Boolean),f=A.applyContainerLayout(y,e,m,s);return Le({ctx:e,containerLayout:y,content:f})}function dt({ctx:e,controller:t,baseDef:n}){return l.MapSignal(t.signal,r=>{const{effective:i,conflicts:a}=Ae(n,r,e.ajv,e.path),o=e.with({definition:i,schemaConflicts:[...e.schemaConflicts,...a]}),s=We(i),u=Re(s,e.ajv),c=Me(s),y=Object.keys(r??{}),m=y.filter(I=>!s.knownKeys.has(I)),f=J(i,r??{},e.ajv),b=m.filter(I=>!f.has(I)),S=m.filter(I=>f.has(I)),d=s.apAllowed&&s.canAddUnevaluated&&y.length<s.maxProps,p=(I,M)=>{const P=I,D=z=>M.has(z)?!1:u(z).ok;if(D(P))return P;let x=1;for(;M.has(P+x)||!D(P+x);)x++;return P+x},w=l.Use(_.BeatUII18n,I=>we.Button({variant:"outline",disabled:!d,onClick:()=>{if(!d)return;const M=new Set(Object.keys(l.Value.get(t.signal)??{})),P=p("property",M);if(!u(P).ok)return;const x=c.getValueSchemaForNew(),z=c.makeDefaultFor(x),Z={...l.Value.get(t.signal)??{},[P]:z};t.change(Z)}},l.attr.title(s.unevaluatedTooltip),I.$.addLabel)),h=A.getContainerLayout(o),g=W.objectEntries(s.knownProps).filter(([,I])=>I!==!1),C=[...g.map(([I])=>I),...S,...b],N=[...g.map(([I,M])=>{const P=I,D=t.field(P);return B({ctx:o.with({definition:M,isPropertyRequired:Array.isArray(i.required)?i.required.includes(P):o.hasRequiredProperty(P),suppressLabel:!1}).append(P),controller:D})}),...S.map(I=>{const M=s.patternList.some(P=>P.test(I));return Te(I,M,{controller:t,effCtx:o,patternProps:s.patternProps,apSchema:s.apSchema,canRemove:c.canRemove,lockKeyAfterSet:s.lockKeyAfterSet,validatePropertyName:u})}),...b.map(I=>{const M=s.patternList.some(P=>P.test(I));return Fe(I,M,{controller:t,effCtx:o,patternProps:s.patternProps,apSchema:s.apSchema,unevaluatedProps:s.unevaluatedProps,canRemove:c.canRemove,lockKeyAfterSet:s.lockKeyAfterSet,validatePropertyName:u})}),s.apAllowed?w:null].filter(Boolean),K=A.applyContainerLayout(h,o,N,C);return Le({ctx:o,containerLayout:h,content:K})})}function ue({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition;return Oe(i)?dt({ctx:e,controller:t,baseDef:i}):ft({ctx:e,controller:t,baseDef:i})}function pt(e){if(typeof e=="boolean")return{discriminator:null,type:null};if(e.discriminator&&typeof e.discriminator=="object"){const n=e.discriminator;if(typeof n.propertyName=="string")return{discriminator:{propertyName:n.propertyName,mapping:n.mapping||{}},type:"openapi"}}const t=e["x:ui"];return t?.discriminatorKey&&typeof t.discriminatorKey=="string"?{discriminator:{key:t.discriminatorKey,mapping:t.discriminatorMapping||{}},type:"beatui"}:{discriminator:null,type:null}}function mt(e,t,n){if(!t.discriminator||!n||typeof n!="object")return null;const{discriminator:r,type:i}=t;if(i==="openapi"){const a=r,o=n[a.propertyName];if(o==null)return null;if(a.mapping&&a.mapping[o]){const s=a.mapping[o];return yt(e,s)}return he(e,a.propertyName,o)}if(i==="beatui"){const a=r,o=n[a.key];if(o==null)return null;if(a.mapping&&a.mapping[o]!=null){const s=a.mapping[o];return s>=0&&s<e.length?s:null}return he(e,a.key,o)}return null}function yt(e,t){for(let n=0;n<e.length;n++){const r=e[n];if(typeof r=="object"&&r.$ref===t)return n}return null}function he(e,t,n){for(let r=0;r<e.length;r++){const i=e[r];if(typeof i!="object")continue;const a=i.properties;if(a&&a[t]){const o=a[t];if(typeof o=="object"&&o.const===n||typeof o=="object"&&Array.isArray(o.enum)&&o.enum.length===1&&o.enum[0]===n)return r}if(i.const===n)return r}return null}function Ue({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition.anyOf;return Be({ctx:e,controller:t,kind:"anyOf",variants:i})}function $e({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition.oneOf;return Be({ctx:e,controller:t,kind:"oneOf",variants:i})}function gt({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const a=e.definition.allOf.filter(c=>typeof c=="object").map(c=>A.resolveAnyRef(c,e.schema,e.ajv)),{mergedSchema:o,conflicts:s}=A.mergeAllOf(a,e.path),u=e.with({definition:o,schemaConflicts:[...e.schemaConflicts,...s]});return B({ctx:u,controller:t})}function Be({ctx:e,controller:t,kind:n,variants:r}){const i=r.map((d,p)=>A.getOneOfBranchLabel(d,p,`${n} ${p+1}`)),a=typeof e.definition=="boolean"?{discriminator:null,type:null}:pt(e.definition),o=l.computedOf(t.signal,e.ajv)((d,p)=>{if(n==="oneOf"){if(a.discriminator){const w=mt(r,a,d);if(w!==null)return w}return A.autoSelectOneOfBranch(e,d,p)}return A.autoSelectOneOfBranch(e,d,p)}),s=l.Value.get(o),u=l.prop(s>=0?s:0);t.onDispose(()=>u.dispose());let c=!1;const y=o.on(d=>{!c&&d>=0&&u.set(d)});t.onDispose(y);const m=r.length,f=d=>{c=!0,u.set(d)},b=m>1?ke({options:r.map((d,p)=>({value:p,label:i[p]})),selected:u,onChange:f}):"",S=l.MapSignal(u,d=>B({ctx:e.with({definition:r[l.Value.get(d)],suppressLabel:!e.isRoot}),controller:t}));return Ie({ctx:e,showSelector:m>1,selector:b,inner:S})}function B({ctx:e,controller:t}){const n=typeof e.definition=="boolean"?{}:e.definition;let r=n?.$ref?A.resolveRef(n,e.schema):n,i=e.with({definition:r});if(r?.allOf!=null){const o=r.allOf.filter(s=>typeof s=="object"&&s!==null);if(o.length>0){const s=o.map(f=>A.resolveAnyRef(f,e.schema,e.ajv)),{mergedSchema:u,conflicts:c}=A.mergeAllOf(s,e.path),{allOf:y,...m}=r;r={...m,...u},i=e.with({definition:r,schemaConflicts:[...e.schemaConflicts,...c]})}}let a=[...i.notViolations];if(r?.not!=null&&typeof r.not=="object"){const o=l.Value.get(t.signal),s=Ce(r.not,o,i.ajv,i.path);s&&(a=[...a,s],i=i.with({notViolations:a}))}if(r==null)return E(i,t,V(i,Y({ctx:i,controller:t}),t));if(r.enum!=null)return E(i,t,V(i,Ve({ctx:i,controller:t}),t));if(r.const!=null)return E(i,t,V(i,Ee({ctx:i,controller:t}),t));if(r.anyOf!=null)return E(i,t,V(i,Ue({ctx:i,controller:t}),t));if(r.oneOf!=null)return E(i,t,V(i,$e({ctx:i,controller:t}),t));if(r?.type==null)return V(i,Y({ctx:i,controller:t}),t);if(Array.isArray(r.type)){const s=r.type.filter(u=>u!=="null");if(s.length===1&&["string","number","integer","boolean"].includes(s[0]))switch(s[0]){case"number":return V(i,X({ctx:i,controller:t}),t);case"integer":return V(i,te({ctx:i,controller:t}),t);case"string":return V(i,ee({ctx:i,controller:t}),t);case"boolean":return V(i,ne({ctx:i,controller:t}),t)}return E(i,t,V(i,fe({ctx:i,controller:t}),t))}switch(r.type){case"number":return E(i,t,V(i,X({ctx:i,controller:t}),t));case"integer":return E(i,t,V(i,te({ctx:i,controller:t}),t));case"string":return E(i,t,V(i,ee({ctx:i,controller:t}),t));case"boolean":return E(i,t,V(i,ne({ctx:i,controller:t}),t));case"array":return E(i,t,V(i,ce({ctx:i,controller:t instanceof v.ArrayController?t:t.array()}),t));case"object":{const o=ue({ctx:i,controller:t instanceof v.ObjectController?t:t.object()});return i.isRoot?E(i,t,V(i,o,t)):E(i,t,V(i,l.html.div(l.attr.class("bc-json-schema-object"),o),t))}case"null":return E(i,t,V(i,le({ctx:i,controller:t}),t));default:return console.warn("Unknown type",r.type),E(i,t,V(i,l.html.div(l.attr.class("bc-json-schema-unknown"),"Unknown"),t))}}function xe({schema:e,controller:t,ajv:n,widgetRegistry:r,setStatus:i,formValue:a,validationMode:o,submitting:s}){const u=new A.SchemaContext({schema:e,definition:e,horizontal:!1,isPropertyRequired:!1,path:[],ajv:n,widgetRegistry:r,setStatus:i,formValue:a,validationMode:o,submitting:s});return e===!0?Y({ctx:u,controller:t}):e===!1?l.Empty:B({ctx:u,controller:t})}function E(e,t,n){return Ne(e.definition)?st({ctx:e,controller:t,children:n,options:{behavior:"hide",clearOnHide:!1}}):n}function ht(e){return e.prefixItems!=null?{isTuple:!0,prefixItems:e.prefixItems,additionalItemsSchema:Array.isArray(e.items)?!0:e.items??!0,tupleLabels:be(e)}:Array.isArray(e.items)?{isTuple:!0,prefixItems:e.items,additionalItemsSchema:e.additionalItems??!0,tupleLabels:be(e)}:{isTuple:!1,prefixItems:[],additionalItemsSchema:e.items??!0}}function be(e){if(typeof e=="boolean")return;const t=e["x:ui"];return Array.isArray(t?.tupleLabels)?t.tupleLabels:void 0}function ce({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition,a=ht(i),o=l.computedOf(t.signal)(f=>{const b=f?.length??0;return!(i.maxItems!=null&&b>=i.maxItems||a.isTuple&&b>=a.prefixItems.length&&a.additionalItemsSchema===!1)}),s=l.computedOf(t.signal)(f=>{const b=f?.length??0;return i.minItems==null||b>i.minItems}),u=l.computedOf(t.signal)(f=>{if(!i.uniqueItems||!f)return new Set;const b=new Map,S=new Set;for(let d=0;d<f.length;d++){const p=JSON.stringify(f[d]);b.has(p)?(S.add(b.get(p)),S.add(d)):b.set(p,d)}return S}),c=l.computedOf(t.signal)(f=>{if(!i.contains||!f)return{matchingIndices:new Set,count:0,isValid:!0};const b=new Set;let S=0;if(e.ajv)try{const h=e.ajv.compile(i.contains);for(let g=0;g<f.length;g++)h(f[g])&&(b.add(g),S++)}catch{}else{const h=i.contains,g=O=>{if(typeof h=="boolean")return h;if(typeof h!="object"||h==null)return!1;const C=h,N=C.type;if(N==="integer"||N==="number")return!(typeof O!="number"||!Number.isFinite(O)||N==="integer"&&!Number.isInteger(O)||typeof C.minimum=="number"&&O<C.minimum||typeof C.exclusiveMinimum=="number"&&O<=C.exclusiveMinimum||typeof C.maximum=="number"&&O>C.maximum||typeof C.exclusiveMaximum=="number"&&O>=C.exclusiveMaximum||typeof C.multipleOf=="number"&&O%C.multipleOf!==0);if(N==="string"){if(typeof O!="string"||typeof C.minLength=="number"&&O.length<C.minLength||typeof C.maxLength=="number"&&O.length>C.maxLength)return!1;if(typeof C.pattern=="string")try{if(!new RegExp(C.pattern).test(O))return!1}catch{}return!0}return!1};for(let O=0;O<f.length;O++)g(f[O])&&(b.add(O),S++)}const d=i.minContains??(i.contains?1:0),p=i.maxContains,w=S>=d&&(p==null||S<=p);return{matchingIndices:b,count:S,isValid:w,minContains:d,maxContains:p}}),y=i.contains?c.map(f=>{const b=typeof i.contains=="object"&&i.contains.title?i.contains.title:"required pattern";if(!f.isValid){if(f.count<(f.minContains??0))return`Must contain at least ${f.minContains??0} item(s) matching ${b} (currently ${f.count})`;if(f.maxContains!=null&&f.count>f.maxContains)return`Must contain at most ${f.maxContains} item(s) matching ${b} (currently ${f.count})`}return`Contains ${f.count} item(s) matching ${b}`}):null,m=k.ListControl({...$({ctx:e}),createItem:()=>{const f=t.signal.value?.length??0;if(a.isTuple&&f<a.prefixItems.length){const b=a.prefixItems[f];return G(b,()=>{})}else return G(a.additionalItemsSchema,()=>{})},controller:t,showAdd:!0,addDisabled:l.computedOf(o)(f=>!f),showRemove:!0,removeDisabled:l.computedOf(s)(f=>!f),element:f=>{const b=f.item,S=f.position.index;let d,p;a.isTuple&&S<a.prefixItems.length?(d=a.prefixItems[S],a.tupleLabels?.[S]?p=a.tupleLabels[S]:typeof d=="object"&&d.title?p=d.title:p=`Item ${S+1}`):(d=a.additionalItemsSchema,a.isTuple&&(p=`Additional Item ${S-a.prefixItems.length+1}`));const w=B({ctx:e.with({definition:d}).append(S),controller:b}),h=u.map(N=>N.has(S)),g=c.map(N=>N.matchingIndices.has(S));let O=w;p&&a.isTuple&&(O=F.Stack(l.attr.class("bc-stack--gap-1"),F.Label(l.attr.class("bc-array-control__item-label"),p),O));const C=[];return i.uniqueItems&&C.push(l.When(h,()=>F.Label(l.attr.class("bc-array-control__indicator bc-array-control__indicator--error"),"⚠️ Duplicate value"))),i.contains&&C.push(l.When(g,()=>F.Label(l.attr.class("bc-array-control__indicator bc-array-control__indicator--success"),"✓ Matches required pattern"))),C.length>0?F.Stack(l.attr.class("bc-stack--gap-1"),O,...C):O}});return i.contains&&y?F.Stack(l.attr.class("bc-stack--gap-2"),m,l.MapSignal(l.computedOf(c,y)((f,b)=>({info:f,summary:b})),({info:f,summary:b})=>F.Label(l.attr.class(f.isValid?"bc-array-control__summary bc-array-control__summary--success":"bc-array-control__summary bc-array-control__summary--error"),b))):m}function bt(e){return e.map(t=>({key:t,label:W.upperCaseFirst(t),detect:n=>Ke(n,[t])===t,convert:n=>ze(n,t),defaultValue:()=>He(t)}))}function fe({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition;let a=i.type??[];const o=Ge(i),s=a.includes("null"),u=a.filter(d=>d!=="null"&&(d==="string"||d==="number"||d==="integer"||d==="boolean")),c=s&&u.length===a.length-1;c&&(a=u);const y=bt(a),m=new k.UnionController(t.path,t.change,t.signal,t.status,{disabled:t.disabled},y);t.onDispose(()=>m.dispose());const f=d=>ke({options:a.map(p=>({value:p,label:W.upperCaseFirst(p)})),selected:m.activeBranch,onChange:d,mode:o.selector??"auto"}),b=d=>{m.switchToBranch(d,o.confirmBranchChange)},S=l.MapSignal(m.activeBranch,d=>{const p=l.Value.get(d),w=m.getBranchController(p);if(c&&(p==="number"||p==="integer")){const g=i;return v.Control(k.NullableNumberInput,{...$({ctx:e.with({suppressLabel:!e.isRoot})}),controller:w,min:g.minimum,max:g.maximum,step:p==="integer"?je(g.multipleOf):g.multipleOf})}const h=e.with({definition:{...i,type:p},suppressLabel:!e.isRoot});switch(p){case"string":return ee({ctx:h,controller:w});case"number":return X({ctx:h,controller:w});case"integer":return te({ctx:h,controller:w});case"boolean":return ne({ctx:h,controller:w});case"null":return le({ctx:h,controller:w});case"array":{const g=w.array();return ce({ctx:h,controller:g})}case"object":{const g=w.object();return ue({ctx:h,controller:g})}default:return v.Control(k.NullableNumberInput,{...$({ctx:h}),controller:w})}});return Ie({ctx:e,showSelector:a.length>1,selector:f(b),inner:S})}function Y({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});return r||(e.definition===!0?Y({ctx:e.with({definition:{type:["string","number","object","array","boolean","null"]}}),controller:t}):fe({ctx:e.with({definition:{...e.definition,type:["string","number","object","array","boolean","null"]}}),controller:t}))}function vt(e){if(typeof e=="boolean")return[];const t=e["x:ui"];return!t||!Array.isArray(t.crossField)?[]:t.crossField.filter(n=>typeof n=="object"&&n!=null&&typeof n.id=="string"&&Array.isArray(n.fields)&&typeof n.validate=="function")}function St(e,t,n=!1){const r=[],i=[...t].sort((a,o)=>(o.priority||0)-(a.priority||0));for(const a of i)if(!(a.onSubmitOnly&&!n))try{const o={};for(const u of a.fields)o[u]=wt(e,u);const s=a.validate(o,e);if(!s.valid){const u=a.targets||a.fields;if(s.fieldErrors)for(const[c,y]of Object.entries(s.fieldErrors))r.push({instancePath:`/${c}`,schemaPath:`#/x:ui/crossField/${a.id}`,keyword:"crossField",params:{ruleId:a.id,fields:a.fields,context:s.context},message:y});else{const c=s.message||a.message||"Cross-field validation failed";for(const y of u)r.push({instancePath:`/${y}`,schemaPath:`#/x:ui/crossField/${a.id}`,keyword:"crossField",params:{ruleId:a.id,fields:a.fields,context:s.context},message:c})}}}catch(o){console.warn(`Error in cross-field validation rule ${a.id}:`,o);const s=a.targets?.[0]||a.fields[0];r.push({instancePath:`/${s}`,schemaPath:`#/x:ui/crossField/${a.id}`,keyword:"crossField",params:{ruleId:a.id,fields:a.fields},message:"Cross-field validation error"})}return r.length>0?A.ajvErrorsToControllerValidation(r):W.Validation.valid}function wt(e,t){if(e==null||typeof e!="object")return;const n=t.split(".");let r=e;for(const i of n){if(r==null||typeof r!="object")return;if(Array.isArray(r)){const a=parseInt(i,10);if(!isNaN(a))r=r[a];else return}else r=r[i]}return r}function Ot(e){if(typeof e=="boolean")return;const t=e["x:ui"];if(!t)return;const n={};Array.isArray(t.when)&&(n.when=t.when.filter(i=>typeof i=="object"&&i!=null&&"watch"in i&&"condition"in i)),Array.isArray(t.crossField)&&(n.crossField=t.crossField.filter(i=>typeof i=="object"&&i!=null&&Array.isArray(i.fields)&&typeof i.validate=="function"));const r=vt(e);return r.length>0&&(n.crossFieldRules=r),Array.isArray(t.async)&&(n.async=t.async.filter(i=>typeof i=="object"&&i!=null&&typeof i.validate=="function")),Object.keys(n).length>0?n:void 0}function ie(e,t){if(!e.startsWith("$."))throw new Error(`Invalid JSONPath: ${e}. Must start with '$.'.`);const n=e.slice(2).split(/[.[\]]/).filter(Boolean);let r=t;for(const i of n){if(r==null)return;if(typeof r=="object"&&!Array.isArray(r))r=r[i];else if(Array.isArray(r)){const a=parseInt(i,10);if(!isNaN(a))r=r[a];else return}else return}return r}function Ct(e,t){try{if(typeof e.condition=="function"){const r=(Array.isArray(e.watch)?e.watch:[e.watch]).map(i=>ie(i,t));return e.condition(r.length===1?r[0]:r,t)}return typeof e.condition=="string"?!!ie(e.condition,t):!1}catch(n){return console.warn("Error evaluating conditional validation:",n),!1}}function At(e,t,n,r){const i=[];if(r&&!r(e)&&r.errors&&i.push(...r.errors),n.when){for(const a of n.when)if(Ct(a,t)?a.then:a.else,a.validate)try{const s=a.validate(e,t);s&&i.push({instancePath:"",schemaPath:"#/x:ui/when",keyword:"conditional",params:{},message:s})}catch(s){console.warn("Error in conditional validation:",s)}}if(n.crossField)for(const a of n.crossField)try{const o={};for(const u of a.fields)o[u]=ie(`$.${u}`,t);const s=a.validate(o,t);if(s){const u=a.target||a.fields[0];i.push({instancePath:`/${u}`,schemaPath:"#/x:ui/crossField",keyword:"crossField",params:{fields:a.fields},message:a.message||s})}}catch(o){console.warn("Error in cross-field validation:",o)}if(n.crossFieldRules&&n.crossFieldRules.length>0){const a=St(t,n.crossFieldRules);if(a.type==="invalid"){const o=jt(a);i.push(...o)}}return i.length>0?A.ajvErrorsToControllerValidation(i):W.Validation.valid}function jt(e){if(e.type==="valid")return[];const t=[];function n(r,i=""){if(r.message&&t.push({instancePath:i,schemaPath:"#/crossField",keyword:"crossField",params:{},message:r.message}),r.dependencies)for(const[a,o]of Object.entries(r.dependencies)){const s=i?`${i}/${a}`:`/${a}`;n(o,s)}}return n(e.error),t}function kt(e,t){const n=new Set;if(e.when)for(const r of e.when)(Array.isArray(r.watch)?r.watch:[r.watch]).forEach(a=>n.add(a));if(e.crossField)for(const r of e.crossField)r.fields.forEach(i=>n.add(i));return{watchedPaths:Array.from(n),shouldRevalidate:r=>Array.from(n).some(i=>r.startsWith(i)||i.startsWith(r))}}function It(e){if(typeof e=="boolean")return[];const t=e["x:ui"];return!t||!Array.isArray(t.async)?[]:t.async.filter(n=>typeof n=="object"&&n!=null&&typeof n.id=="string"&&typeof n.field=="string"&&typeof n.validate=="function")}class Nt{timeouts=new Map;validationStates=new Map;abortControllers=new Map;getValidationState(t){return this.validationStates.has(t)||this.validationStates.set(t,l.prop({isValidating:!1,result:W.Validation.valid,lastValidatedValue:void 0,lastValidatedAt:0})),this.validationStates.get(t)}async validateField(t,n,r,i=!1){const a=`${t.field}_${t.id}`,o=this.getValidationState(a),s=this.timeouts.get(a);s!==void 0&&clearTimeout(s);const u=this.abortControllers.get(a);if(u&&u.abort(),!i&&o.value.lastValidatedValue===n)return;if(t.minLength&&typeof n=="string"&&n.length<t.minLength){o.set({...o.value,result:W.Validation.valid,isValidating:!1});return}const c=setTimeout(async()=>{const y=new AbortController;this.abortControllers.set(a,y),o.set({...o.value,isValidating:!0,result:t.loadingMessage?W.Validation.invalid({message:t.loadingMessage}):o.value.result});try{const m=await t.validate(n,r);if(y.signal.aborted)return;const f=m.valid?W.Validation.valid:W.Validation.invalid({message:m.message||"Async validation failed",context:m.context});o.set({isValidating:!1,result:f,lastValidatedValue:n,lastValidatedAt:Date.now()})}catch(m){if(y.signal.aborted)return;const f=m instanceof Error?m.message:"Async validation error";o.set({isValidating:!1,result:W.Validation.invalid({message:f}),lastValidatedValue:n,lastValidatedAt:Date.now()})}finally{this.abortControllers.delete(a),this.timeouts.delete(a)}},i?0:t.debounce||300);this.timeouts.set(a,c)}cancelAll(){for(const t of this.timeouts.values())clearTimeout(t);this.timeouts.clear();for(const t of this.abortControllers.values())t.abort();this.abortControllers.clear()}getAllValidationResults(){const t={};for(const[n,r]of this.validationStates.entries()){const i=r.value;!i.isValidating&&i.result.type==="invalid"&&(t[n]=i.result)}return t}isValidating(){for(const t of this.validationStates.values())if(t.value.isValidating)return!0;return!1}dispose(){this.cancelAll();for(const t of this.validationStates.values())t.dispose();this.validationStates.clear()}}function q(e){if(typeof e!="boolean")return Pt(e)}function Pt(e){if(e.default!==void 0)return e.default;if(Array.isArray(e.examples)&&e.examples.length>0)return e.examples[0];if(e.const!==void 0)return e.const;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];if(Mt(e))return null;if(e.allOf&&Array.isArray(e.allOf))return Vt(e.allOf);const t=e.oneOf??e.anyOf;if(t&&Array.isArray(t))for(const n of t){const r=q(n);if(r!==void 0)return r}return Et(e)}function Vt(e){const t={};let n=!1;for(const r of e){const i=q(r);i!==void 0&&typeof i=="object"&&i!==null&&(Object.assign(t,i),n=!0)}return n?t:void 0}function Et(e){switch(Lt(e)){case"object":return Tt(e);case"array":return Ft(e);case"string":return Wt(e);case"number":case"integer":return Rt(e);case"boolean":return!1;case"null":return null;default:return}}function Tt(e){if(!e.properties)return{};const t=new Set(e.required??[]),n={};let r=!1;for(const[i,a]of Object.entries(e.properties)){if(!t.has(i)||typeof a=="boolean")continue;const o=q(a);o!==void 0&&(n[i]=o,r=!0)}return r?n:{}}function Ft(e){const t=e.minItems??0;if(t===0)return[];const n=e.items;if(!n||typeof n=="boolean")return Array(t).fill(null);if(Array.isArray(n))return n.slice(0,t).map(i=>q(i)??null);const r=q(n);return Array(t).fill(r??null)}function Wt(e){switch(e.format){case"date":return Ut();case"date-time":return $t();case"time":return"00:00:00";default:return""}}function Rt(e){const t=e.type==="integer";let n=e.minimum,r=e.maximum;if(e.exclusiveMinimum!==void 0){const o=typeof e.exclusiveMinimum=="number"?e.exclusiveMinimum:e.exclusiveMinimum?n??0:void 0;o!==void 0&&(n=t?o+1:o+ve(e))}if(e.exclusiveMaximum!==void 0){const o=typeof e.exclusiveMaximum=="number"?e.exclusiveMaximum:e.exclusiveMaximum?r??0:void 0;o!==void 0&&(r=t?o-1:o-ve(e))}let i;n!==void 0&&r!==void 0?i=(n+r)/2:n!==void 0?i=n:r!==void 0?i=0<=r?0:r:i=0;const a=e.multipleOf;return a!==void 0&&a>0&&(i=Math.round(i/a)*a,n!==void 0&&i<n&&(i=Math.ceil(n/a)*a),r!==void 0&&i>r&&(i=Math.floor(r/a)*a)),t&&(i=Math.round(i)),i}function ve(e){return e.multipleOf!==void 0?e.multipleOf:.001}function Mt(e){return Array.isArray(e.type)?e.type.includes("null"):!1}function Lt(e){if(typeof e.type=="string")return e.type;if(Array.isArray(e.type))return e.type.find(t=>t!=="null");if(e.properties!==void 0)return"object";if(e.items!==void 0)return"array"}function Ut(){return new Date().toISOString().split("T")[0]}function $t(){return new Date().toISOString()}function Bt(e){const t=globalThis.structuredClone;return typeof t=="function"?t(e):JSON.parse(JSON.stringify(e))}function xt(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function Dt(e){const t=new j.WidgetRegistry;for(let n=0;n<e.length;n++){const r=e[n],i=r.displayName??`custom-widget-${n}`;t.register(i,{factory:r.factory,displayName:r.displayName??`Custom Widget ${n+1}`,description:r.description,supportedTypes:r.supportedTypes,priority:r.priority??50,canFallback:!0,matcher:r.matcher})}return t}function Jt({schema:e,initialValue:t,externalSchemas:n,refResolver:r,sanitizeAdditional:i,validationMode:a,validateDebounceMs:o,customWidgets:s,applySchemaDefaults:u=!0,submitting:c},y){const m=t!==void 0?l.Value.get(t):void 0,f=q(e);let b;return t===void 0?b=f??{}:u?b=k.deepMergeDefaults(f,m):b=m,l.Async(A.getAjvForSchema(e,{externalSchemas:n,refResolver:r,sanitizeAdditional:i}),S=>{if(S.ok){const{ajv:d,validate:p}=S.value,w=Ot(e),h=It(e),g=h.length>0?new Nt:null,O=a??"onTouched",C=L=>{const U=p(L);let H;return U?H=W.Validation.valid:H=A.ajvErrorsToControllerValidation(p.errors??[]),w?At(L,L,w,p):H},{controller:N,setStatus:K}=v.useController({initialValue:b,validationMode:O,validateDebounceMs:o,validate:O==="onSubmit"?void 0:C}),I=w?kt(w):null,M=i!==!1;let P=!1;const D=M?N.signal.on(L=>{if(P)return;const U=Bt(L);p(U)&&!xt(U,L)&&(P=!0,N.change(U),P=!1)}):()=>{},x=I?N.signal.on((L,U)=>{U!=null&&JSON.stringify(L)!==JSON.stringify(U)&&setTimeout(()=>{const qe=N.status.value;K(qe)},10)}):()=>{},z=g&&h.length>0?N.signal.on(L=>{for(const U of h)g.validateField(U,L,L)}):()=>{},Z=()=>{D(),x(),z(),g?.dispose(),N.dispose()},De=s?Dt(s):void 0,Je=l.Fragment(l.OnDispose(Z),xe({schema:e,controller:N,ajv:d,widgetRegistry:De,setStatus:K,formValue:N.signal,validationMode:O,submitting:c}));return y({Form:Je,controller:N,setStatus:K})}return l.html.div(l.attr.class("bc-json-schema-form__error"),S.error)})}function qt(e,t){const r=(t?.ajv??new _e({allErrors:!0})).compile(e);return{"~standard":{version:1,vendor:"ajv",validate:i=>r(i)?{value:i}:{issues:_t(r.errors??[])},types:void 0}}}function _t(e){return e.map(t=>({message:Kt(t),path:zt(t)}))}function Kt(e){return e.message??`${e.keyword} validation failed`}function zt(e){const t=Ht(e.instancePath||"");if(e.keyword==="required"){const n=e.params.missingProperty;if(n!=null)return[...t,n]}if(e.keyword==="additionalProperties"){const n=e.params.additionalProperty;if(n!=null)return[...t,n]}if(e.keyword==="unevaluatedProperties"){const n=e.params.unevaluatedProperty;if(n!=null)return[...t,n]}return t.length>0?t:void 0}function Ht(e){return e?e.split("/").slice(1).map(n=>n.replace(/~1/g,"/").replace(/~0/g,"~")).map(n=>Gt(n)?Number(n):n):[]}function Gt(e){return/^\d+$/.test(e)}exports.SchemaContext=A.SchemaContext;exports.ajvErrorsToControllerValidation=A.ajvErrorsToControllerValidation;exports.ajvErrorsToDependencies=A.ajvErrorsToDependencies;exports.buildMessage=A.buildMessage;exports.buildPath=A.buildPath;exports.clearCaches=A.clearCaches;exports.clearCachesForAjv=A.clearCachesForAjv;exports.compileWithCache=A.compileWithCache;exports.getAjvForSchema=A.getAjvForSchema;exports.getCacheStats=A.getCacheStats;exports.jsonPointerToSegments=A.jsonPointerToSegments;exports.mergeAllOf=A.mergeAllOf;exports.createDiagnosticWidget=j.createDiagnosticWidget;exports.forFormat=j.forFormat;exports.forTypeAndFormat=j.forTypeAndFormat;exports.forXUI=j.forXUI;exports.JSONSchemaAllOf=gt;exports.JSONSchemaAny=Y;exports.JSONSchemaAnyOf=Ue;exports.JSONSchemaArray=ce;exports.JSONSchemaBoolean=ne;exports.JSONSchemaConst=Ee;exports.JSONSchemaControl=xe;exports.JSONSchemaEnum=Ve;exports.JSONSchemaForm=Jt;exports.JSONSchemaGenericControl=B;exports.JSONSchemaInteger=te;exports.JSONSchemaNull=le;exports.JSONSchemaNumber=X;exports.JSONSchemaObject=ue;exports.JSONSchemaOneOf=$e;exports.JSONSchemaString=ee;exports.JSONSchemaUnion=fe;exports.composeEffectiveObjectSchema=Ae;exports.createAJVStandardSchema=qt;exports.evaluateIfThenElseOverlay=ae;exports.evaluateNotViolation=Ce;exports.extractSchemaDefaults=q;exports.getEvaluatedProperties=J;exports.hasConditionalFeatures=Oe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@tempots/dom"),A=require("../oneof-branch-detection-BEkAezNi.cjs"),_=require("../translations-qefRsdGi.cjs"),Q=require("../notice-Q0A1gIho.cjs"),j=require("../widget-customization-DELy3SMQ.cjs"),F=require("../stack-dwLevGa2.cjs"),v=require("../use-form-BvBkVEKi.cjs"),W=require("@tempots/std"),k=require("../deep-merge-Bydz6jLt.cjs"),T=require("../utils-DmEuG3Np.cjs"),Se=require("../text-input-D_IxFd0M.cjs"),we=require("../input-container-BkPcNDaZ.cjs"),_e=require("ajv");function Oe(e){if(!e||typeof e!="object")return!1;const t=e;return!!(e.if||t.dependentRequired||t.dependentSchemas||e.dependencies)}function Ce(e,t,n,r=[]){if(!n)return null;try{if(A.compileWithCache(n,e)(t)){const o=e.title||"disallowed schema";return{path:r,message:`Value matches ${o}`,notSchema:e}}return null}catch{return null}}function Ae(e,t,n,r=[]){const i=[],a=[],o=ae(e,t,n);o&&i.push(o);const s=Array.isArray(e.required)?[...e.required]:[];if(typeof t=="object"&&t!=null&&!Array.isArray(t)){const m=t,f=e.dependentRequired;if(f){for(const[d,p]of Object.entries(f))if(Object.prototype.hasOwnProperty.call(m,d))for(const w of p)s.push(w)}const b=e.dependencies;if(b){for(const[d,p]of Object.entries(b))if(Object.prototype.hasOwnProperty.call(m,d))if(Array.isArray(p))for(const w of p)s.push(w);else typeof p=="object"&&p&&i.push(p)}const S=e.dependentSchemas;if(S)for(const[d,p]of Object.entries(S))Object.prototype.hasOwnProperty.call(m,d)&&i.push(p)}const u=[e,...i],{mergedSchema:c,conflicts:y}=A.mergeAllOf(u,r);if(s.length>0){const m=new Set([...c.required??[],...s]);c.required=[...m]}return a.push(...y),{effective:c,conflicts:a}}function ae(e,t,n){if(!n||!e.if||typeof e.if!="object")return null;try{if(A.compileWithCache(n,e.if)(t)){const a=e.then;if(a&&typeof a=="object")return a}else{const a=e.else;if(a&&typeof a=="object")return a}}catch{}return null}function J(e,t,n){const r=new Set;if(!t||typeof t!="object")return r;if(e.properties&&Object.keys(e.properties).forEach(o=>{o in t&&r.add(o)}),e.patternProperties&&Object.keys(t).forEach(o=>{Object.keys(e.patternProperties).forEach(s=>{try{new RegExp(s).test(o)&&r.add(o)}catch{}})}),e.additionalProperties===!0||e.additionalProperties&&typeof e.additionalProperties=="object"){const o=new Set;e.properties&&Object.keys(e.properties).forEach(s=>{s in t&&o.add(s)}),e.patternProperties&&Object.keys(t).forEach(s=>{Object.keys(e.patternProperties).forEach(u=>{try{new RegExp(u).test(s)&&o.add(s)}catch{}})}),Object.keys(t).forEach(s=>{o.has(s)||r.add(s)})}e.allOf&&e.allOf.forEach(o=>{typeof o=="object"&&J(o,t,n).forEach(u=>r.add(u))});const i=ae(e,t,n);i&&J(i,t,n).forEach(s=>r.add(s));const a=e.dependentSchemas;return a&&Object.keys(a).forEach(o=>{if(o in t){const s=a[o];typeof s=="object"&&J(s,t,n).forEach(c=>r.add(c))}}),e.dependencies&&Object.keys(e.dependencies).forEach(o=>{if(o in t){const s=e.dependencies[o];typeof s=="object"&&!Array.isArray(s)&&J(s,t,n).forEach(c=>r.add(c))}}),r}function $({ctx:e}){const{examples:t,default:n}=e;let{description:r}=e;r==null&&t!=null&&n!=null&&(Array.isArray(t)?r=`example: ${t[0]}`:r=`example: ${t}`);const i=[];if(e.isDeprecated&&i.push("deprecated"),e.isReadOnly&&!e.shouldIgnoreReadOnly&&i.push("read-only"),e.isWriteOnly&&!e.shouldShowWriteOnly&&i.push("write-only"),i.length>0){const a=`(${i.join(", ")})`;r=r?`${r} ${a}`:a}return{label:e.suppressLabel?void 0:e.widgetLabel,description:r,required:e.isPropertyRequired,layout:e.horizontal?"horizontal":"vertical"}}function G(e,t){if(e.default!=null)return t(e.default);if(Array.isArray(e.examples))return t(e.examples[0]);if(e.examples!=null)return t(e.examples)}function je(e){return e==null?1:Math.round(e)}function oe(e){return e.isWriteOnly&&!e.shouldShowWriteOnly}function se(e){return e.isReadOnly&&!e.shouldIgnoreReadOnly||e.isDeprecated}function R({ctx:e,controller:t,resolved:n}){const r=n?.widget,i={controller:t,ctx:e,options:n?.options,setStatus:e.setStatus,formValue:e.formValue,validationMode:e.validationMode,submitting:e.submitting};if(r!=null&&e.widgetRegistry){const o=e.widgetRegistry.get(r);if(o)return o.factory(i)}if(r!=null){const o=j.globalWidgetRegistry.get(r);if(o)return o.factory(i)}if(e.widgetRegistry){const o=e.widgetRegistry.findBestWidget(e);if(o)return o.registration.factory(i)}const a=j.globalWidgetRegistry.findBestWidget(e);return a?a.registration.factory(i):null}function ke(e){const{options:t,selected:n,onChange:r,mode:i="auto",size:a="sm",keyFor:o=y=>String(y),parseKey:s=y=>y}=e,u=t.length;if((i==="auto"?u<=3?"segmented":"select":i)==="segmented"){const y=Object.fromEntries(t.map(m=>[o(m.value),m.label]));return k.SegmentedInput({options:y,value:l.Value.map(n,m=>o(m)),onChange:m=>r(s(m)),size:a})}return k.NativeSelect({options:t.map(y=>({type:"value",value:y.value,label:y.label})),value:n,onChange:r})}function Ie({ctx:e,showSelector:t,selector:n,inner:r}){return e.isRoot?t?F.Stack(l.attr.class("bc-stack--gap-2"),n,r):r:v.InputWrapper({...$({ctx:e}),content:t?F.Stack(l.attr.class("bc-stack--gap-2 bc-stack--align-start"),n,r):r})}function Ke(e,t){if(e===null)return t.includes("null")?"null":null;switch(typeof e){case"string":return t.includes("string")?"string":null;case"number":return Number.isInteger(e)&&t.includes("integer")?"integer":t.includes("number")?"number":null;case"boolean":return t.includes("boolean")?"boolean":null;case"object":return Array.isArray(e)?t.includes("array")?"array":null:t.includes("object")?"object":null;default:return null}}function ze(e,t){try{switch(t){case"string":return e==null?{ok:!0,value:void 0}:{ok:!0,value:String(e)};case"number":{if(typeof e=="number")return{ok:!0,value:e};if(typeof e=="string"){const n=Number(e);return Number.isFinite(n)?{ok:!0,value:n}:{ok:!1}}return typeof e=="boolean"?{ok:!0,value:e?1:0}:{ok:!1}}case"integer":return typeof e=="number"&&Number.isInteger(e)?{ok:!0,value:e}:typeof e=="string"?/^[-+]?\d+$/.test(e.trim())?{ok:!0,value:parseInt(e,10)}:{ok:!1}:typeof e=="boolean"?{ok:!0,value:e?1:0}:{ok:!1};case"boolean":{if(typeof e=="boolean")return{ok:!0,value:e};if(typeof e=="string"){const n=e.trim().toLowerCase();return n==="true"||n==="1"||n==="yes"?{ok:!0,value:!0}:n==="false"||n==="0"||n==="no"?{ok:!0,value:!1}:{ok:!1}}return typeof e=="number"?{ok:!0,value:e!==0}:{ok:!1}}case"array":return Array.isArray(e)?{ok:!0,value:e}:{ok:!1};case"object":return e!=null&&typeof e=="object"&&!Array.isArray(e)?{ok:!0,value:e}:{ok:!1};case"null":return{ok:!0,value:null}}}catch{return{ok:!1}}}function He(e){switch(e){case"null":return null;case"array":return[];case"object":return{};default:return}}function Ge(e){if(typeof e=="boolean")return{};const t=e["x:ui"];if(t!=null&&typeof t=="object"&&!Array.isArray(t)){const n=t;return{unionDefault:typeof n.unionDefault=="string"?n.unionDefault:void 0,confirmBranchChange:!!n.confirmBranchChange,selector:n.selector==="segmented"||n.selector==="select"?n.selector:void 0}}return{}}function Xe(e){const{definition:t}=e;if(typeof t=="boolean")return;const n={pattern:t.pattern,minLength:t.minLength,maxLength:t.maxLength},r=T.resolveWidget(t,e.name),i=r?.widget;if(i!=null)switch(i){case"binary":return{...n,format:"binary",...r?.options};case"date":return{...n,format:"date"};case"date-time":return{...n,format:"date-time"};case"email":return{...n,format:"email"};case"markdown":return{...n,format:"markdown"};case"password":return{...n,format:"password"};case"textarea":return{...n,format:"textarea"};case"time":return{...n,format:"time"};case"uuid":return{format:"uuid"};case"url":return{...n,format:"url"};case"uri":return{...n,format:"uri"};case"uri-reference":return{...n,format:"uri-reference"};case"hostname":return{...n,format:"hostname"};case"ipv4":return{...n,format:"ipv4"};case"ipv6":return{...n,format:"ipv6"};case"regex":return{...n,format:"regex"};case"duration":return{...n,format:"duration"};case"color":return{...n,format:"color"}}}const Ye=e=>{const{after:t,disabled:n}=e,r=Se.mapInputOptions(e,a=>a??void 0,a=>a??null),i=k.NullableResetAfter(e.value,n,e.onChange??e.onInput);return j.Base64Input({...r,after:t!=null?l.Fragment(i,t):i})};function de({ctx:e,options:t,controller:n}){const r=Xe(e),i=!e.isNullable,a=()=>i?k.transformNullToUndefined(n):n;switch(r?.format){case"email":return v.Control(j.NullableEmailInput,{...t,controller:a()});case"date":return v.MappedControl(j.NullableDateInput,{...t,controller:a(),toInput:o=>o==null?null:new Date(o),fromInput:o=>o?.toISOString().split("T")[0]??null});case"date-time":return v.MappedControl(j.NullableDateTimeInput,{...t,controller:a(),toInput:o=>o==null?null:new Date(o),fromInput:o=>o?.toISOString()??null});case"time":return v.Control(j.NullableTextInput,{...t,controller:a(),placeholder:"HH:MM:SS"});case"password":return v.Control(j.NullablePasswordInput,{...t,controller:a()});case"binary":{const{definition:o}=e,s=typeof o=="object"?o["x:ui"]:void 0;return r.mediaType&&(r.mediaType.startsWith("image/")||r.mediaType.startsWith("video/")||r.mediaType.startsWith("audio/")||r.mediaType==="application/pdf"||s?.preferFileUpload===!0)?v.Control(Ye,{...t,controller:a(),mode:"input",accept:r.mediaType||"*/*",maxFileSize:(typeof s?.maxBytes=="number"?s.maxBytes:void 0)||(typeof s?.maxFileSize=="number"?s.maxFileSize:void 0),showFileList:!0}):v.Control(j.NullableTextArea,{...t,controller:a(),placeholder:"Paste base64-encoded data",rows:3})}case"uri":case"url":return v.Control(j.NullableUrlInput,{...t,controller:a(),placeholder:"https://example.com"});case"uri-reference":return v.Control(j.NullableTextInput,{...t,controller:a(),placeholder:"Enter URL..."});case"hostname":return v.Control(j.NullableTextInput,{...t,controller:a(),placeholder:"example.com"});case"ipv4":return v.Control(j.NullableTextInput,{...t,controller:a(),placeholder:"192.168.1.1"});case"ipv6":return v.Control(j.NullableTextInput,{...t,controller:a(),placeholder:"2001:db8::1"});case"regex":return v.Control(j.NullableTextArea,{...t,controller:a(),placeholder:"^[a-zA-Z0-9]+$",rows:3});case"duration":return k.WithTemporal(({Duration:o})=>v.MappedControl(k.NullableDurationInput,{...t,controller:a(),toInput:s=>s==null?null:o.from(s),fromInput:s=>s?.toString?.()??null}));case"color":return v.Control(j.ColorSwatchInput,{...t,controller:n,displayValue:!0});case"uuid":return v.Control(j.NullableUuidInput,{...t,controller:a()});case"textarea":return v.Control(j.NullableTextArea,{...t,controller:a()});default:return v.Control(j.NullableTextInput,{...t,controller:a()})}}function ee({ctx:e,controller:t}){if(oe(e))return l.Empty;const n=T.resolveWidget(e.definition,e.name),r=n?.widget,i=R({ctx:e,controller:t,resolved:n});if(i)return i;const a={...$({ctx:e}),placeholder:G(e.definition,String),disabled:se(e)};if((e.isNullable||e.isOptional)&&!e.shouldShowPresenceToggle)return de({ctx:e,options:a,controller:t});if(r!=null&&["url","uri","uri-reference","hostname","ipv4","ipv6","regex","duration","binary","markdown","time","color"].includes(r))return de({ctx:e,options:a,controller:t});switch(r){case"email":return v.Control(Q.EmailInput,{...a,controller:k.transformEmptyStringToUndefined(t)});case"password":return v.Control(Q.PasswordInput,{...a,controller:k.transformEmptyStringToUndefined(t)});case"uuid":return v.Control(k.UuidInput,{...a,controller:k.transformEmptyStringToUndefined(t)});case"textarea":return v.Control(k.TextArea,{...a,controller:k.transformEmptyStringToUndefined(t)});default:return v.Control(Se.TextInput,{...a,controller:k.transformEmptyStringToUndefined(t)})}}function Ze(e){const t=T.resolveWidget(e.definition,e.name);if(t?.widget==="slider")return{widget:"slider",options:t.options};if(t?.widget==="rating")return{widget:"rating",options:t.options};const n=e.definition,r=typeof n=="object"?n["x:ui"]:void 0;return r?.displayFormat==="currency"?{widget:"currency",options:{currency:typeof r?.currency=="string"?r.currency:"USD"}}:r?.displayFormat==="percent"?{widget:"percent"}:{widget:"number"}}function X({ctx:e,controller:t}){if(oe(e))return l.Empty;const n=e.definition,r=Ze(e),i=T.resolveWidget(e.definition,e.name),a=R({ctx:e,controller:t,resolved:i});if(a)return a;const o={...$({ctx:e}),placeholder:G(e.definition,String),min:n.minimum,max:n.maximum,step:n.multipleOf,disabled:se(e)},s=(e.isNullable||e.isOptional)&&!e.shouldShowPresenceToggle,u=s&&!e.isNullable;switch(r.widget){case"rating":const c=(typeof r.options?.max=="number"?r.options.max:n.maximum)||5;return s?v.Control(j.NullableRatingInput,{...o,max:c,controller:u?k.transformNullToUndefined(t):t}):v.Control(j.RatingInput,{...o,max:c,controller:t});case"slider":return s?v.Control(j.NullableSliderInput,{...o,controller:u?k.transformNullToUndefined(t):t}):v.Control(j.SliderInput,{...o,controller:t});case"currency":const y=typeof r.options?.currency=="string"?r.options.currency:"USD";return s?v.Control(k.MaskInput,{...o,mask:pe(y),controller:t}):v.Control(k.MaskInput,{...o,mask:pe(y),controller:t});case"percent":return s?v.Control(k.MaskInput,{...o,mask:me(),controller:t}):v.Control(k.MaskInput,{...o,mask:me(),controller:t});default:return s?v.Control(k.NullableNumberInput,{...o,controller:u?k.transformNullToUndefined(t):t}):v.Control(k.NumberInput,{...o,controller:t})}}function pe(e){return`${Qe(e)} 000,000.00`}function me(){return"000.00%"}function Qe(e){return{USD:"$",EUR:"€",GBP:"£",JPY:"¥",CAD:"C$",AUD:"A$"}[e.toUpperCase()]||e}function te({ctx:e,controller:t}){return X({ctx:e.with({definition:{...e.definition,multipleOf:je(e.definition.multipleOf)}}),controller:t})}function ne({ctx:e,controller:t}){if(oe(e))return l.Empty;const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i={...$({ctx:e}),disabled:se(e)},a=v.Control(v.CheckboxInput,{...i,controller:t});if(!e.isNullable&&(!e.isOptional||e.shouldShowPresenceToggle))return a;const o=!e.isNullable;return v.Control(v.CheckboxInput,{...i,controller:t,after:k.NullableResetAfter(t.signal,t.disabled,()=>t.change(o?void 0:null))})}function le({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});return r||l.WithElement(()=>{t.change(null)})}function et({conflicts:e}){return e.length===0?l.Empty:l.Use(_.BeatUII18n,t=>Q.Notice({variant:"warning",tone:"prominent",title:t.value.schemaConflictsDetected,class:"bc-schema-conflicts-banner"},l.html.ul(l.attr.style("margin: 0; padding-left: 1.25rem; list-style-type: disc;"),...e.map(n=>l.html.li(l.attr.style("margin-bottom: 0.25rem;"),n.message,n.path.length>0?l.html.code(l.attr.style("margin-left: 0.5rem; font-size: 0.75rem; opacity: 0.7;"),` (${n.path.join(".")})`):null)))))}function tt({violations:e}){return e.length===0?l.Empty:l.Use(_.BeatUII18n,t=>Q.Notice({variant:"danger",tone:"prominent",title:t.value.schemaViolationsDetected,class:"bc-not-violations-banner"},l.html.ul(l.attr.style("margin: 0; padding-left: 1.25rem; list-style-type: disc;"),...e.map(n=>l.html.li(l.attr.style("margin-bottom: 0.25rem;"),n.message,n.path.length>0?l.html.code(l.attr.style("margin-left: 0.5rem; font-size: 0.75rem; opacity: 0.7;"),` (${n.path.join(".")})`):null)))))}function nt({ctx:e,controller:t,content:n}){const r=l.Value.map(t.signal,o=>o!==void 0),i=e.widgetLabel??"Property",a=o=>{if(o){const s=e.default;if(s!==void 0)t.change(s);else{const u=e.definition;u.type==="string"?t.change(""):u.type==="number"||u.type==="integer"?t.change(0):u.type==="boolean"?t.change(!1):u.type==="array"?t.change([]):u.type==="object"?t.change({}):t.change(null)}}else t.change(void 0)};return F.Stack(l.html.div(l.attr.class("bc-presence-toggle"),v.InputWrapper({layout:"horizontal",label:`Include ${i}`,content:j.Switch({value:r,onChange:a,size:"xs"})})),l.When(r,()=>n))}function V(e,t,n){const r=e.schemaConflicts.length>0,i=e.notViolations.length>0,a=e.shouldShowPresenceToggle&&n!=null;let o=t;return a&&n!=null&&(o=nt({ctx:e,controller:n,content:t})),!r&&!i?o:F.Stack(l.attr.class("bc-stack--gap-2"),i?tt({violations:e.notViolations}):null,r?et({conflicts:e.schemaConflicts}):null,o)}function Ne(e){if(typeof e=="boolean")return;const t=e["x:ui"];if(!t||!t.visibleIf)return;const n=t.visibleIf;if(typeof n=="string"||typeof n=="object"&&n!==null)return n}function rt(e){if(e.startsWith("!"))return{field:e.slice(1),operator:"falsy"};if(e.includes("!=")){const[t,n]=e.split("!=",2);return{field:t.trim(),operator:"notEquals",value:ye(n.trim())}}if(e.includes("=")){const[t,n]=e.split("=",2);return{field:t.trim(),operator:"equals",value:ye(n.trim())}}return{field:e.trim(),operator:"truthy"}}function ye(e){if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e!=="undefined")return/^-?\d+(\.\d+)?$/.test(e)?parseFloat(e):e}function it(e,t){if(e==null||typeof e!="object")return;const n=t.split(".");let r=e;for(const i of n){if(r==null||typeof r!="object")return;if(Array.isArray(r)){const a=parseInt(i,10);if(!isNaN(a))r=r[a];else return}else r=r[i]}return r}function re(e,t){const n=it(t,e.field);switch(e.operator){case"equals":return n===e.value;case"notEquals":return n!==e.value;case"truthy":return!!n;case"falsy":return!n;case"contains":return typeof n=="string"&&typeof e.value=="string"||Array.isArray(n)?n.includes(e.value):!1;case"notContains":return typeof n=="string"&&typeof e.value=="string"||Array.isArray(n)?!n.includes(e.value):!0;case"greaterThan":return typeof n=="number"&&typeof e.value=="number"&&n>e.value;case"lessThan":return typeof n=="number"&&typeof e.value=="number"&&n<e.value;case"greaterThanOrEqual":return typeof n=="number"&&typeof e.value=="number"&&n>=e.value;case"lessThanOrEqual":return typeof n=="number"&&typeof e.value=="number"&&n<=e.value;case"in":return Array.isArray(e.values)&&e.values.includes(n);case"notIn":return!Array.isArray(e.values)||!e.values.includes(n);default:return!1}}function Pe(e,t){const n=e.conditions.map(r=>"operator"in r&&["and","or","not"].includes(r.operator)?Pe(r,t):re(r,t));switch(e.operator){case"and":return n.every(Boolean);case"or":return n.some(Boolean);case"not":return!n[0];default:return!1}}function at(e,t){try{if(typeof e=="string"){const n=rt(e);return re(n,t)}return"operator"in e&&["and","or","not"].includes(e.operator)?Pe(e,t):re(e,t)}catch(n){return console.warn("Error evaluating visibility condition:",n),!0}}function ot(e,t){return l.computedOf(t)(n=>at(e,n))}const ge={behavior:"hide",clearOnHide:!1};function st({ctx:e,controller:t,children:n,options:r=ge}){const i=Ne(e.definition);if(!i)return n;const a={...ge,...r},o=lt(t),s=ot(i,o);return a.clearOnHide&&s.on(u=>{!u&&t.signal.value!==void 0&&t.change(void 0)}),a.behavior==="unmount"?l.When(s,()=>n):n}function lt(e){return e.signal}function Ve({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const a=e.definition.enum??[],o=(e.isNullable||e.isOptional)&&!a.includes(null),s=!e.isNullable;return l.Use(_.BeatUII18n,u=>{const c=a.map(m=>({type:"value",value:m,label:String(m)}));o&&c.unshift({type:"value",value:null,label:l.Value.get(u.$.selectNone)});const y=o&&s?k.transformNullToUndefined(t):t;return k.NativeSelectControl({...$({ctx:e}),options:c,controller:y,equality:(m,f)=>m==null&&f==null?!0:m===f})})}function Ee({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition;return l.Fragment(l.WithElement(()=>{l.Value.get(t.signal)!==i.const&&t.change(i.const)}),k.Group(F.MutedLabel(e.widgetLabel,": "),F.Label(String(i.const))))}function Te(e,t,n){const{controller:r,effCtx:i,patternProps:a,apSchema:o,canRemove:s,lockKeyAfterSet:u,validatePropertyName:c}=n,y=r.field(e),m=l.prop(e),f=l.prop(null);let b=o;if(t){const w=Object.keys(a).find(h=>{try{return new RegExp(h).test(e)}catch{return!1}});if(w){const h=a[w];h!==!1&&typeof h=="object"&&(b=h)}}const S=w=>{const h=(w??"").trim();if(!h||h===e||Object.prototype.hasOwnProperty.call(l.Value.get(r.signal)??{},h))return;const g=c(h);if(!g.ok){f.set(g.message);return}f.set(null);const O={...l.Value.get(r.signal)??{}},C=O[e];delete O[e],O[h]=C,r.change(O)},d=l.Use(_.BeatUII18n,w=>v.CloseButton({size:"xs",label:w.$.removeItem,disabled:!s(Object.keys(l.Value.get(r.signal)??{}).length),onClick:()=>{const h=Object.keys(l.Value.get(r.signal)??{}).length;if(!s(h))return;const g={...l.Value.get(r.signal)??{}};delete g[e],r.change(g)}})),p=l.Value.map(y.signal,w=>u&&w!=null);return l.html.div(l.attr.class("bc-object-helpers__row"),l.style.gridTemplateColumns("2fr 3fr min-content"),v.InputWrapper({content:j.EditableText({value:m,onChange:S,disabled:l.computedOf(r.disabled,p)((w,h)=>w||h)}),error:l.Ensure(f,w=>l.html.div(l.attr.class("bc-object-helpers__error"),w)),description:Object.keys(a).length>0?l.html.div(l.attr.class("bc-object-helpers__description"),"Allowed patterns: ",Object.keys(a).join(", ")):null}),l.html.div(B({ctx:i.with({definition:b,suppressLabel:!0}).append(e),controller:y})),l.html.div(l.attr.class("bc-object-helpers__remove"),d))}function Fe(e,t,n){const{controller:r,effCtx:i,patternProps:a,apSchema:o,unevaluatedProps:s,canRemove:u,lockKeyAfterSet:c,validatePropertyName:y}=n,m=r.field(e),f=l.prop(e),b=l.prop(null);let S;if(s&&typeof s=="object")S=s;else if(t){const h=Object.keys(a).find(g=>{try{return new RegExp(g).test(e)}catch{return!1}});if(h){const g=a[h];g!==!1&&typeof g=="object"?S=g:S=o}else S=o}else S=o;const d=h=>{const g=(h??"").trim();if(!g||g===e||Object.prototype.hasOwnProperty.call(l.Value.get(r.signal)??{},g))return;const O=y(g);if(!O.ok){b.set(O.message);return}b.set(null);const C={...l.Value.get(r.signal)??{}},N=C[e];delete C[e],C[g]=N,r.change(C)},p=l.Use(_.BeatUII18n,h=>v.CloseButton({size:"xs",label:h.$.removeItem,disabled:!u(Object.keys(l.Value.get(r.signal)??{}).length),onClick:()=>{const g=Object.keys(l.Value.get(r.signal)??{}).length;if(!u(g))return;const O={...l.Value.get(r.signal)??{}};delete O[e],r.change(O)}})),w=l.Value.map(m.signal,h=>c&&h!=null);return l.html.div(l.attr.class("bc-object-helpers__row"),l.style.gridTemplateColumns("2fr 3fr min-content"),v.InputWrapper({content:j.EditableText({value:f,onChange:d,disabled:l.computedOf(r.disabled,w)((h,g)=>h||g)}),error:l.Ensure(b,h=>l.html.div(l.attr.class("bc-object-helpers__error"),h)),description:l.html.div(l.attr.class("bc-object-helpers__description"),s===!1?"Unevaluated property (not allowed by schema)":"Unevaluated property",Object.keys(a).length>0?l.html.span(" • Allowed patterns: ",Object.keys(a).join(", ")):null)}),l.html.div(B({ctx:i.with({definition:S,suppressLabel:!0}).append(e),controller:m})),l.html.div(l.attr.class("bc-object-helpers__remove"),p))}function We(e){const t=e.properties??{},n=new Set(Object.keys(t)),r=e.additionalProperties??!0,i=r!==!1,a=r===!0||r===void 0?{}:r,o=e.minProperties??0,s=e.maxProperties??1/0,u=e.unevaluatedProperties;let c=!0,y=null;u===!1?(c=!1,y="No unevaluated properties are allowed by schema"):u&&typeof u=="object"&&(c=!0);const m=e.patternProperties??{},f=Object.keys(m).filter(Boolean).map(p=>{try{return new RegExp(p)}catch{return null}}).filter(p=>p!=null),b=e.propertyNames,S=e["x:ui"],d=!!(S&&typeof S=="object"&&S.lockKeyAfterSet);return{knownProps:t,knownKeys:n,ap:r,apAllowed:i,apSchema:a,minProps:o,maxProps:s,unevaluatedProps:u,canAddUnevaluated:c,unevaluatedTooltip:y,patternProps:m,patternList:f,propertyNamesDef:b,lockKeyAfterSet:d}}function Re(e,t){const{knownKeys:n,apAllowed:r,patternList:i,patternProps:a,propertyNamesDef:o}=e;return s=>{const u=(s??"").trim();if(u==="")return{ok:!1,message:"Key cannot be empty"};if(o===!1)return{ok:!1,message:"No property names are allowed by schema"};if(o&&typeof o=="object"&&t)try{const c=t.compile(o);if(!c(u))return{ok:!1,message:c.errors?.[0]?.message??"Invalid property name"}}catch{}if(!r&&!n.has(u)){if(i.length===0)return{ok:!1,message:"Only declared properties are allowed"};if(!i.some(y=>y.test(u)))return{ok:!1,message:`Key must match one of: ${Object.keys(a).join(", ")}`}}return{ok:!0}}}function Me(e){const{minProps:t,apSchema:n,unevaluatedProps:r}=e;return{canRemove:s=>s>t,makeDefaultFor:s=>{const u=G(s,y=>y);if(u!==void 0)return u;const c=s.type;if(c==="string")return"";if(c==="number"||c==="integer")return 0;if(c==="boolean")return!1;if(c==="array")return[];if(c==="object")return{}},getValueSchemaForNew:()=>r&&typeof r=="object"?r:n}}function ut({ctx:e,controller:t,config:n,effective:r}){const i=W.objectEntries(n.knownProps).filter(([,s])=>s!==!1),a=i.map(([s])=>s);return{children:i.map(([s,u])=>{const c=s,y=t.field(c);return B({ctx:e.with({definition:u,isPropertyRequired:Array.isArray(r.required)?r.required.includes(c):e.hasRequiredProperty(c),suppressLabel:!1}).append(c),controller:y})}),names:a}}function ct({controller:e,config:t,validatePropertyName:n,helpers:r}){if(!t.apAllowed)return null;const i=(a,o)=>{const s=a,u=y=>o.has(y)?!1:n(y).ok;if(u(s))return s;let c=1;for(;o.has(s+c)||!u(s+c);)c++;return s+c};return l.Use(_.BeatUII18n,a=>we.Button({variant:"outline",disabled:l.Value.map(e.signal,o=>!t.canAddUnevaluated||Object.keys(o??{}).length>=t.maxProps),onClick:()=>{const o=l.Value.get(e.signal)??{},s=Object.keys(o);if(!t.canAddUnevaluated||s.length>=t.maxProps)return;const u=new Set(s),c=i("property",u);if(!n(c).ok)return;const m=r.getValueSchemaForNew(),f=r.makeDefaultFor(m),b={...o,[c]:f};e.change(b)}},l.attr.title(t.unevaluatedTooltip),a.$.addLabel))}function Le({ctx:e,containerLayout:t,content:n}){return!e.suppressLabel&&e.name!=null&&(!t||!["fieldset","group"].includes(t.format||""))?v.InputWrapper({...$({ctx:e}),content:n}):n}function ft({ctx:e,controller:t,baseDef:n}){const r=We(n),i=Re(r,e.ajv),a=Me(r),{children:o,names:s}=ut({ctx:e,controller:t,config:r,effective:n}),u=l.MapSignal(t.signal,b=>{const d=Object.keys(b??{}).filter(g=>!r.knownKeys.has(g));if(d.length===0)return l.Empty;const p=J(n,b??{},e.ajv),w=d.filter(g=>!p.has(g)),h=d.filter(g=>p.has(g));return l.Fragment(...h.map(g=>{const O=r.patternList.some(C=>C.test(g));return Te(g,O,{controller:t,effCtx:e,patternProps:r.patternProps,apSchema:r.apSchema,canRemove:a.canRemove,lockKeyAfterSet:r.lockKeyAfterSet,validatePropertyName:i})}),...w.map(g=>{const O=r.patternList.some(C=>C.test(g));return Fe(g,O,{controller:t,effCtx:e,patternProps:r.patternProps,apSchema:r.apSchema,unevaluatedProps:r.unevaluatedProps,canRemove:a.canRemove,lockKeyAfterSet:r.lockKeyAfterSet,validatePropertyName:i})}))}),c=ct({controller:t,config:r,validatePropertyName:i,helpers:a}),y=A.getContainerLayout(e),m=[...o,u,c].filter(Boolean),f=A.applyContainerLayout(y,e,m,s);return Le({ctx:e,containerLayout:y,content:f})}function dt({ctx:e,controller:t,baseDef:n}){return l.MapSignal(t.signal,r=>{const{effective:i,conflicts:a}=Ae(n,r,e.ajv,e.path),o=e.with({definition:i,schemaConflicts:[...e.schemaConflicts,...a]}),s=We(i),u=Re(s,e.ajv),c=Me(s),y=Object.keys(r??{}),m=y.filter(I=>!s.knownKeys.has(I)),f=J(i,r??{},e.ajv),b=m.filter(I=>!f.has(I)),S=m.filter(I=>f.has(I)),d=s.apAllowed&&s.canAddUnevaluated&&y.length<s.maxProps,p=(I,M)=>{const P=I,D=z=>M.has(z)?!1:u(z).ok;if(D(P))return P;let x=1;for(;M.has(P+x)||!D(P+x);)x++;return P+x},w=l.Use(_.BeatUII18n,I=>we.Button({variant:"outline",disabled:!d,onClick:()=>{if(!d)return;const M=new Set(Object.keys(l.Value.get(t.signal)??{})),P=p("property",M);if(!u(P).ok)return;const x=c.getValueSchemaForNew(),z=c.makeDefaultFor(x),Z={...l.Value.get(t.signal)??{},[P]:z};t.change(Z)}},l.attr.title(s.unevaluatedTooltip),I.$.addLabel)),h=A.getContainerLayout(o),g=W.objectEntries(s.knownProps).filter(([,I])=>I!==!1),C=[...g.map(([I])=>I),...S,...b],N=[...g.map(([I,M])=>{const P=I,D=t.field(P);return B({ctx:o.with({definition:M,isPropertyRequired:Array.isArray(i.required)?i.required.includes(P):o.hasRequiredProperty(P),suppressLabel:!1}).append(P),controller:D})}),...S.map(I=>{const M=s.patternList.some(P=>P.test(I));return Te(I,M,{controller:t,effCtx:o,patternProps:s.patternProps,apSchema:s.apSchema,canRemove:c.canRemove,lockKeyAfterSet:s.lockKeyAfterSet,validatePropertyName:u})}),...b.map(I=>{const M=s.patternList.some(P=>P.test(I));return Fe(I,M,{controller:t,effCtx:o,patternProps:s.patternProps,apSchema:s.apSchema,unevaluatedProps:s.unevaluatedProps,canRemove:c.canRemove,lockKeyAfterSet:s.lockKeyAfterSet,validatePropertyName:u})}),s.apAllowed?w:null].filter(Boolean),K=A.applyContainerLayout(h,o,N,C);return Le({ctx:o,containerLayout:h,content:K})})}function ue({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition;return Oe(i)?dt({ctx:e,controller:t,baseDef:i}):ft({ctx:e,controller:t,baseDef:i})}function pt(e){if(typeof e=="boolean")return{discriminator:null,type:null};if(e.discriminator&&typeof e.discriminator=="object"){const n=e.discriminator;if(typeof n.propertyName=="string")return{discriminator:{propertyName:n.propertyName,mapping:n.mapping||{}},type:"openapi"}}const t=e["x:ui"];return t?.discriminatorKey&&typeof t.discriminatorKey=="string"?{discriminator:{key:t.discriminatorKey,mapping:t.discriminatorMapping||{}},type:"beatui"}:{discriminator:null,type:null}}function mt(e,t,n){if(!t.discriminator||!n||typeof n!="object")return null;const{discriminator:r,type:i}=t;if(i==="openapi"){const a=r,o=n[a.propertyName];if(o==null)return null;if(a.mapping&&a.mapping[o]){const s=a.mapping[o];return yt(e,s)}return he(e,a.propertyName,o)}if(i==="beatui"){const a=r,o=n[a.key];if(o==null)return null;if(a.mapping&&a.mapping[o]!=null){const s=a.mapping[o];return s>=0&&s<e.length?s:null}return he(e,a.key,o)}return null}function yt(e,t){for(let n=0;n<e.length;n++){const r=e[n];if(typeof r=="object"&&r.$ref===t)return n}return null}function he(e,t,n){for(let r=0;r<e.length;r++){const i=e[r];if(typeof i!="object")continue;const a=i.properties;if(a&&a[t]){const o=a[t];if(typeof o=="object"&&o.const===n||typeof o=="object"&&Array.isArray(o.enum)&&o.enum.length===1&&o.enum[0]===n)return r}if(i.const===n)return r}return null}function Ue({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition.anyOf;return Be({ctx:e,controller:t,kind:"anyOf",variants:i})}function $e({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition.oneOf;return Be({ctx:e,controller:t,kind:"oneOf",variants:i})}function gt({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const a=e.definition.allOf.filter(c=>typeof c=="object").map(c=>A.resolveAnyRef(c,e.schema,e.ajv)),{mergedSchema:o,conflicts:s}=A.mergeAllOf(a,e.path),u=e.with({definition:o,schemaConflicts:[...e.schemaConflicts,...s]});return B({ctx:u,controller:t})}function Be({ctx:e,controller:t,kind:n,variants:r}){const i=r.map((d,p)=>A.getOneOfBranchLabel(d,p,`${n} ${p+1}`)),a=typeof e.definition=="boolean"?{discriminator:null,type:null}:pt(e.definition),o=l.computedOf(t.signal,e.ajv)((d,p)=>{if(n==="oneOf"){if(a.discriminator){const w=mt(r,a,d);if(w!==null)return w}return A.autoSelectOneOfBranch(e,d,p)}return A.autoSelectOneOfBranch(e,d,p)}),s=l.Value.get(o),u=l.prop(s>=0?s:0);t.onDispose(()=>u.dispose());let c=!1;const y=o.on(d=>{!c&&d>=0&&u.set(d)});t.onDispose(y);const m=r.length,f=d=>{c=!0,u.set(d)},b=m>1?ke({options:r.map((d,p)=>({value:p,label:i[p]})),selected:u,onChange:f}):"",S=l.MapSignal(u,d=>B({ctx:e.with({definition:r[l.Value.get(d)],suppressLabel:!e.isRoot}),controller:t}));return Ie({ctx:e,showSelector:m>1,selector:b,inner:S})}function B({ctx:e,controller:t}){const n=typeof e.definition=="boolean"?{}:e.definition;let r=n?.$ref?A.resolveRef(n,e.schema):n,i=e.with({definition:r});if(r?.allOf!=null){const o=r.allOf.filter(s=>typeof s=="object"&&s!==null);if(o.length>0){const s=o.map(f=>A.resolveAnyRef(f,e.schema,e.ajv)),{mergedSchema:u,conflicts:c}=A.mergeAllOf(s,e.path),{allOf:y,...m}=r;r={...m,...u},i=e.with({definition:r,schemaConflicts:[...e.schemaConflicts,...c]})}}let a=[...i.notViolations];if(r?.not!=null&&typeof r.not=="object"){const o=l.Value.get(t.signal),s=Ce(r.not,o,i.ajv,i.path);s&&(a=[...a,s],i=i.with({notViolations:a}))}if(r==null)return E(i,t,V(i,Y({ctx:i,controller:t}),t));if(r.enum!=null)return E(i,t,V(i,Ve({ctx:i,controller:t}),t));if(r.const!=null)return E(i,t,V(i,Ee({ctx:i,controller:t}),t));if(r.anyOf!=null)return E(i,t,V(i,Ue({ctx:i,controller:t}),t));if(r.oneOf!=null)return E(i,t,V(i,$e({ctx:i,controller:t}),t));if(r?.type==null)return V(i,Y({ctx:i,controller:t}),t);if(Array.isArray(r.type)){const s=r.type.filter(u=>u!=="null");if(s.length===1&&["string","number","integer","boolean"].includes(s[0]))switch(s[0]){case"number":return V(i,X({ctx:i,controller:t}),t);case"integer":return V(i,te({ctx:i,controller:t}),t);case"string":return V(i,ee({ctx:i,controller:t}),t);case"boolean":return V(i,ne({ctx:i,controller:t}),t)}return E(i,t,V(i,fe({ctx:i,controller:t}),t))}switch(r.type){case"number":return E(i,t,V(i,X({ctx:i,controller:t}),t));case"integer":return E(i,t,V(i,te({ctx:i,controller:t}),t));case"string":return E(i,t,V(i,ee({ctx:i,controller:t}),t));case"boolean":return E(i,t,V(i,ne({ctx:i,controller:t}),t));case"array":return E(i,t,V(i,ce({ctx:i,controller:t instanceof v.ArrayController?t:t.array()}),t));case"object":{const o=ue({ctx:i,controller:t instanceof v.ObjectController?t:t.object()});return i.isRoot?E(i,t,V(i,o,t)):E(i,t,V(i,l.html.div(l.attr.class("bc-json-schema-object"),o),t))}case"null":return E(i,t,V(i,le({ctx:i,controller:t}),t));default:return console.warn("Unknown type",r.type),E(i,t,V(i,l.html.div(l.attr.class("bc-json-schema-unknown"),"Unknown"),t))}}function xe({schema:e,controller:t,ajv:n,widgetRegistry:r,setStatus:i,formValue:a,validationMode:o,submitting:s}){const u=new A.SchemaContext({schema:e,definition:e,horizontal:!1,isPropertyRequired:!1,path:[],ajv:n,widgetRegistry:r,setStatus:i,formValue:a,validationMode:o,submitting:s});return e===!0?Y({ctx:u,controller:t}):e===!1?l.Empty:B({ctx:u,controller:t})}function E(e,t,n){return Ne(e.definition)?st({ctx:e,controller:t,children:n,options:{behavior:"hide",clearOnHide:!1}}):n}function ht(e){return e.prefixItems!=null?{isTuple:!0,prefixItems:e.prefixItems,additionalItemsSchema:Array.isArray(e.items)?!0:e.items??!0,tupleLabels:be(e)}:Array.isArray(e.items)?{isTuple:!0,prefixItems:e.items,additionalItemsSchema:e.additionalItems??!0,tupleLabels:be(e)}:{isTuple:!1,prefixItems:[],additionalItemsSchema:e.items??!0}}function be(e){if(typeof e=="boolean")return;const t=e["x:ui"];return Array.isArray(t?.tupleLabels)?t.tupleLabels:void 0}function ce({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition,a=ht(i),o=l.computedOf(t.signal)(f=>{const b=f?.length??0;return!(i.maxItems!=null&&b>=i.maxItems||a.isTuple&&b>=a.prefixItems.length&&a.additionalItemsSchema===!1)}),s=l.computedOf(t.signal)(f=>{const b=f?.length??0;return i.minItems==null||b>i.minItems}),u=l.computedOf(t.signal)(f=>{if(!i.uniqueItems||!f)return new Set;const b=new Map,S=new Set;for(let d=0;d<f.length;d++){const p=JSON.stringify(f[d]);b.has(p)?(S.add(b.get(p)),S.add(d)):b.set(p,d)}return S}),c=l.computedOf(t.signal)(f=>{if(!i.contains||!f)return{matchingIndices:new Set,count:0,isValid:!0};const b=new Set;let S=0;if(e.ajv)try{const h=e.ajv.compile(i.contains);for(let g=0;g<f.length;g++)h(f[g])&&(b.add(g),S++)}catch{}else{const h=i.contains,g=O=>{if(typeof h=="boolean")return h;if(typeof h!="object"||h==null)return!1;const C=h,N=C.type;if(N==="integer"||N==="number")return!(typeof O!="number"||!Number.isFinite(O)||N==="integer"&&!Number.isInteger(O)||typeof C.minimum=="number"&&O<C.minimum||typeof C.exclusiveMinimum=="number"&&O<=C.exclusiveMinimum||typeof C.maximum=="number"&&O>C.maximum||typeof C.exclusiveMaximum=="number"&&O>=C.exclusiveMaximum||typeof C.multipleOf=="number"&&O%C.multipleOf!==0);if(N==="string"){if(typeof O!="string"||typeof C.minLength=="number"&&O.length<C.minLength||typeof C.maxLength=="number"&&O.length>C.maxLength)return!1;if(typeof C.pattern=="string")try{if(!new RegExp(C.pattern).test(O))return!1}catch{}return!0}return!1};for(let O=0;O<f.length;O++)g(f[O])&&(b.add(O),S++)}const d=i.minContains??(i.contains?1:0),p=i.maxContains,w=S>=d&&(p==null||S<=p);return{matchingIndices:b,count:S,isValid:w,minContains:d,maxContains:p}}),y=i.contains?c.map(f=>{const b=typeof i.contains=="object"&&i.contains.title?i.contains.title:"required pattern";if(!f.isValid){if(f.count<(f.minContains??0))return`Must contain at least ${f.minContains??0} item(s) matching ${b} (currently ${f.count})`;if(f.maxContains!=null&&f.count>f.maxContains)return`Must contain at most ${f.maxContains} item(s) matching ${b} (currently ${f.count})`}return`Contains ${f.count} item(s) matching ${b}`}):null,m=k.ListControl({...$({ctx:e}),createItem:()=>{const f=t.signal.value?.length??0;if(a.isTuple&&f<a.prefixItems.length){const b=a.prefixItems[f];return G(b,()=>{})}else return G(a.additionalItemsSchema,()=>{})},controller:t,showAdd:!0,addDisabled:l.computedOf(o)(f=>!f),showRemove:!0,removeDisabled:l.computedOf(s)(f=>!f),element:f=>{const b=f.item,S=f.position.index;let d,p;a.isTuple&&S<a.prefixItems.length?(d=a.prefixItems[S],a.tupleLabels?.[S]?p=a.tupleLabels[S]:typeof d=="object"&&d.title?p=d.title:p=`Item ${S+1}`):(d=a.additionalItemsSchema,a.isTuple&&(p=`Additional Item ${S-a.prefixItems.length+1}`));const w=B({ctx:e.with({definition:d}).append(S),controller:b}),h=u.map(N=>N.has(S)),g=c.map(N=>N.matchingIndices.has(S));let O=w;p&&a.isTuple&&(O=F.Stack(l.attr.class("bc-stack--gap-1"),F.Label(l.attr.class("bc-array-control__item-label"),p),O));const C=[];return i.uniqueItems&&C.push(l.When(h,()=>F.Label(l.attr.class("bc-array-control__indicator bc-array-control__indicator--error"),"⚠️ Duplicate value"))),i.contains&&C.push(l.When(g,()=>F.Label(l.attr.class("bc-array-control__indicator bc-array-control__indicator--success"),"✓ Matches required pattern"))),C.length>0?F.Stack(l.attr.class("bc-stack--gap-1"),O,...C):O}});return i.contains&&y?F.Stack(l.attr.class("bc-stack--gap-2"),m,l.MapSignal(l.computedOf(c,y)((f,b)=>({info:f,summary:b})),({info:f,summary:b})=>F.Label(l.attr.class(f.isValid?"bc-array-control__summary bc-array-control__summary--success":"bc-array-control__summary bc-array-control__summary--error"),b))):m}function bt(e){return e.map(t=>({key:t,label:W.upperCaseFirst(t),detect:n=>Ke(n,[t])===t,convert:n=>ze(n,t),defaultValue:()=>He(t)}))}function fe({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});if(r)return r;const i=e.definition;let a=i.type??[];const o=Ge(i),s=a.includes("null"),u=a.filter(d=>d!=="null"&&(d==="string"||d==="number"||d==="integer"||d==="boolean")),c=s&&u.length===a.length-1;c&&(a=u);const y=bt(a),m=new k.UnionController(t.path,t.change,t.signal,t.status,{disabled:t.disabled},y);t.onDispose(()=>m.dispose());const f=d=>ke({options:a.map(p=>({value:p,label:W.upperCaseFirst(p)})),selected:m.activeBranch,onChange:d,mode:o.selector??"auto"}),b=d=>{m.switchToBranch(d,o.confirmBranchChange)},S=l.MapSignal(m.activeBranch,d=>{const p=l.Value.get(d),w=m.getBranchController(p);if(c&&(p==="number"||p==="integer")){const g=i;return v.Control(k.NullableNumberInput,{...$({ctx:e.with({suppressLabel:!e.isRoot})}),controller:w,min:g.minimum,max:g.maximum,step:p==="integer"?je(g.multipleOf):g.multipleOf})}const h=e.with({definition:{...i,type:p},suppressLabel:!e.isRoot});switch(p){case"string":return ee({ctx:h,controller:w});case"number":return X({ctx:h,controller:w});case"integer":return te({ctx:h,controller:w});case"boolean":return ne({ctx:h,controller:w});case"null":return le({ctx:h,controller:w});case"array":{const g=w.array();return ce({ctx:h,controller:g})}case"object":{const g=w.object();return ue({ctx:h,controller:g})}default:return v.Control(k.NullableNumberInput,{...$({ctx:h}),controller:w})}});return Ie({ctx:e,showSelector:a.length>1,selector:f(b),inner:S})}function Y({ctx:e,controller:t}){const n=T.resolveWidget(e.definition,e.name),r=R({ctx:e,controller:t,resolved:n});return r||(e.definition===!0?Y({ctx:e.with({definition:{type:["string","number","object","array","boolean","null"]}}),controller:t}):fe({ctx:e.with({definition:{...e.definition,type:["string","number","object","array","boolean","null"]}}),controller:t}))}function vt(e){if(typeof e=="boolean")return[];const t=e["x:ui"];return!t||!Array.isArray(t.crossField)?[]:t.crossField.filter(n=>typeof n=="object"&&n!=null&&typeof n.id=="string"&&Array.isArray(n.fields)&&typeof n.validate=="function")}function St(e,t,n=!1){const r=[],i=[...t].sort((a,o)=>(o.priority||0)-(a.priority||0));for(const a of i)if(!(a.onSubmitOnly&&!n))try{const o={};for(const u of a.fields)o[u]=wt(e,u);const s=a.validate(o,e);if(!s.valid){const u=a.targets||a.fields;if(s.fieldErrors)for(const[c,y]of Object.entries(s.fieldErrors))r.push({instancePath:`/${c}`,schemaPath:`#/x:ui/crossField/${a.id}`,keyword:"crossField",params:{ruleId:a.id,fields:a.fields,context:s.context},message:y});else{const c=s.message||a.message||"Cross-field validation failed";for(const y of u)r.push({instancePath:`/${y}`,schemaPath:`#/x:ui/crossField/${a.id}`,keyword:"crossField",params:{ruleId:a.id,fields:a.fields,context:s.context},message:c})}}}catch(o){console.warn(`Error in cross-field validation rule ${a.id}:`,o);const s=a.targets?.[0]||a.fields[0];r.push({instancePath:`/${s}`,schemaPath:`#/x:ui/crossField/${a.id}`,keyword:"crossField",params:{ruleId:a.id,fields:a.fields},message:"Cross-field validation error"})}return r.length>0?A.ajvErrorsToControllerValidation(r):W.Validation.valid}function wt(e,t){if(e==null||typeof e!="object")return;const n=t.split(".");let r=e;for(const i of n){if(r==null||typeof r!="object")return;if(Array.isArray(r)){const a=parseInt(i,10);if(!isNaN(a))r=r[a];else return}else r=r[i]}return r}function Ot(e){if(typeof e=="boolean")return;const t=e["x:ui"];if(!t)return;const n={};Array.isArray(t.when)&&(n.when=t.when.filter(i=>typeof i=="object"&&i!=null&&"watch"in i&&"condition"in i)),Array.isArray(t.crossField)&&(n.crossField=t.crossField.filter(i=>typeof i=="object"&&i!=null&&Array.isArray(i.fields)&&typeof i.validate=="function"));const r=vt(e);return r.length>0&&(n.crossFieldRules=r),Array.isArray(t.async)&&(n.async=t.async.filter(i=>typeof i=="object"&&i!=null&&typeof i.validate=="function")),Object.keys(n).length>0?n:void 0}function ie(e,t){if(!e.startsWith("$."))throw new Error(`Invalid JSONPath: ${e}. Must start with '$.'.`);const n=e.slice(2).split(/[.[\]]/).filter(Boolean);let r=t;for(const i of n){if(r==null)return;if(typeof r=="object"&&!Array.isArray(r))r=r[i];else if(Array.isArray(r)){const a=parseInt(i,10);if(!isNaN(a))r=r[a];else return}else return}return r}function Ct(e,t){try{if(typeof e.condition=="function"){const r=(Array.isArray(e.watch)?e.watch:[e.watch]).map(i=>ie(i,t));return e.condition(r.length===1?r[0]:r,t)}return typeof e.condition=="string"?!!ie(e.condition,t):!1}catch(n){return console.warn("Error evaluating conditional validation:",n),!1}}function At(e,t,n,r){const i=[];if(r&&!r(e)&&r.errors&&i.push(...r.errors),n.when){for(const a of n.when)if(Ct(a,t)?a.then:a.else,a.validate)try{const s=a.validate(e,t);s&&i.push({instancePath:"",schemaPath:"#/x:ui/when",keyword:"conditional",params:{},message:s})}catch(s){console.warn("Error in conditional validation:",s)}}if(n.crossField)for(const a of n.crossField)try{const o={};for(const u of a.fields)o[u]=ie(`$.${u}`,t);const s=a.validate(o,t);if(s){const u=a.target||a.fields[0];i.push({instancePath:`/${u}`,schemaPath:"#/x:ui/crossField",keyword:"crossField",params:{fields:a.fields},message:a.message||s})}}catch(o){console.warn("Error in cross-field validation:",o)}if(n.crossFieldRules&&n.crossFieldRules.length>0){const a=St(t,n.crossFieldRules);if(a.type==="invalid"){const o=jt(a);i.push(...o)}}return i.length>0?A.ajvErrorsToControllerValidation(i):W.Validation.valid}function jt(e){if(e.type==="valid")return[];const t=[];function n(r,i=""){if(r.message&&t.push({instancePath:i,schemaPath:"#/crossField",keyword:"crossField",params:{},message:r.message}),r.dependencies)for(const[a,o]of Object.entries(r.dependencies)){const s=i?`${i}/${a}`:`/${a}`;n(o,s)}}return n(e.error),t}function kt(e,t){const n=new Set;if(e.when)for(const r of e.when)(Array.isArray(r.watch)?r.watch:[r.watch]).forEach(a=>n.add(a));if(e.crossField)for(const r of e.crossField)r.fields.forEach(i=>n.add(i));return{watchedPaths:Array.from(n),shouldRevalidate:r=>Array.from(n).some(i=>r.startsWith(i)||i.startsWith(r))}}function It(e){if(typeof e=="boolean")return[];const t=e["x:ui"];return!t||!Array.isArray(t.async)?[]:t.async.filter(n=>typeof n=="object"&&n!=null&&typeof n.id=="string"&&typeof n.field=="string"&&typeof n.validate=="function")}class Nt{timeouts=new Map;validationStates=new Map;abortControllers=new Map;getValidationState(t){return this.validationStates.has(t)||this.validationStates.set(t,l.prop({isValidating:!1,result:W.Validation.valid,lastValidatedValue:void 0,lastValidatedAt:0})),this.validationStates.get(t)}async validateField(t,n,r,i=!1){const a=`${t.field}_${t.id}`,o=this.getValidationState(a),s=this.timeouts.get(a);s!==void 0&&clearTimeout(s);const u=this.abortControllers.get(a);if(u&&u.abort(),!i&&o.value.lastValidatedValue===n)return;if(t.minLength&&typeof n=="string"&&n.length<t.minLength){o.set({...o.value,result:W.Validation.valid,isValidating:!1});return}const c=setTimeout(async()=>{const y=new AbortController;this.abortControllers.set(a,y),o.set({...o.value,isValidating:!0,result:t.loadingMessage?W.Validation.invalid({message:t.loadingMessage}):o.value.result});try{const m=await t.validate(n,r);if(y.signal.aborted)return;const f=m.valid?W.Validation.valid:W.Validation.invalid({message:m.message||"Async validation failed",context:m.context});o.set({isValidating:!1,result:f,lastValidatedValue:n,lastValidatedAt:Date.now()})}catch(m){if(y.signal.aborted)return;const f=m instanceof Error?m.message:"Async validation error";o.set({isValidating:!1,result:W.Validation.invalid({message:f}),lastValidatedValue:n,lastValidatedAt:Date.now()})}finally{this.abortControllers.delete(a),this.timeouts.delete(a)}},i?0:t.debounce||300);this.timeouts.set(a,c)}cancelAll(){for(const t of this.timeouts.values())clearTimeout(t);this.timeouts.clear();for(const t of this.abortControllers.values())t.abort();this.abortControllers.clear()}getAllValidationResults(){const t={};for(const[n,r]of this.validationStates.entries()){const i=r.value;!i.isValidating&&i.result.type==="invalid"&&(t[n]=i.result)}return t}isValidating(){for(const t of this.validationStates.values())if(t.value.isValidating)return!0;return!1}dispose(){this.cancelAll();for(const t of this.validationStates.values())t.dispose();this.validationStates.clear()}}function q(e){if(typeof e!="boolean")return Pt(e)}function Pt(e){if(e.default!==void 0)return e.default;if(Array.isArray(e.examples)&&e.examples.length>0)return e.examples[0];if(e.const!==void 0)return e.const;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];if(Mt(e))return null;if(e.allOf&&Array.isArray(e.allOf))return Vt(e.allOf);const t=e.oneOf??e.anyOf;if(t&&Array.isArray(t))for(const n of t){const r=q(n);if(r!==void 0)return r}return Et(e)}function Vt(e){const t={};let n=!1;for(const r of e){const i=q(r);i!==void 0&&typeof i=="object"&&i!==null&&(Object.assign(t,i),n=!0)}return n?t:void 0}function Et(e){switch(Lt(e)){case"object":return Tt(e);case"array":return Ft(e);case"string":return Wt(e);case"number":case"integer":return Rt(e);case"boolean":return!1;case"null":return null;default:return}}function Tt(e){if(!e.properties)return{};const t=new Set(e.required??[]),n={};let r=!1;for(const[i,a]of Object.entries(e.properties)){if(!t.has(i)||typeof a=="boolean")continue;const o=q(a);o!==void 0&&(n[i]=o,r=!0)}return r?n:{}}function Ft(e){const t=e.minItems??0;if(t===0)return[];const n=e.items;if(!n||typeof n=="boolean")return Array(t).fill(null);if(Array.isArray(n))return n.slice(0,t).map(i=>q(i)??null);const r=q(n);return Array(t).fill(r??null)}function Wt(e){switch(e.format){case"date":return Ut();case"date-time":return $t();case"time":return"00:00:00";default:return""}}function Rt(e){const t=e.type==="integer";let n=e.minimum,r=e.maximum;if(e.exclusiveMinimum!==void 0){const o=typeof e.exclusiveMinimum=="number"?e.exclusiveMinimum:e.exclusiveMinimum?n??0:void 0;o!==void 0&&(n=t?o+1:o+ve(e))}if(e.exclusiveMaximum!==void 0){const o=typeof e.exclusiveMaximum=="number"?e.exclusiveMaximum:e.exclusiveMaximum?r??0:void 0;o!==void 0&&(r=t?o-1:o-ve(e))}let i;n!==void 0&&r!==void 0?i=(n+r)/2:n!==void 0?i=n:r!==void 0?i=0<=r?0:r:i=0;const a=e.multipleOf;return a!==void 0&&a>0&&(i=Math.round(i/a)*a,n!==void 0&&i<n&&(i=Math.ceil(n/a)*a),r!==void 0&&i>r&&(i=Math.floor(r/a)*a)),t&&(i=Math.round(i)),i}function ve(e){return e.multipleOf!==void 0?e.multipleOf:.001}function Mt(e){return Array.isArray(e.type)?e.type.includes("null"):!1}function Lt(e){if(typeof e.type=="string")return e.type;if(Array.isArray(e.type))return e.type.find(t=>t!=="null");if(e.properties!==void 0)return"object";if(e.items!==void 0)return"array"}function Ut(){return new Date().toISOString().split("T")[0]}function $t(){return new Date().toISOString()}function Bt(e){const t=globalThis.structuredClone;return typeof t=="function"?t(e):JSON.parse(JSON.stringify(e))}function xt(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function Dt(e){const t=new j.WidgetRegistry;for(let n=0;n<e.length;n++){const r=e[n],i=r.displayName??`custom-widget-${n}`;t.register(i,{factory:r.factory,displayName:r.displayName??`Custom Widget ${n+1}`,description:r.description,supportedTypes:r.supportedTypes,priority:r.priority??50,canFallback:!0,matcher:r.matcher})}return t}function Jt({schema:e,initialValue:t,externalSchemas:n,refResolver:r,sanitizeAdditional:i,validationMode:a,validateDebounceMs:o,customWidgets:s,applySchemaDefaults:u=!0,submitting:c},y){const m=t!==void 0?l.Value.get(t):void 0,f=q(e);let b;return t===void 0?b=f??{}:u?b=k.deepMergeDefaults(f,m):b=m,l.Async(A.getAjvForSchema(e,{externalSchemas:n,refResolver:r,sanitizeAdditional:i}),S=>{if(S.ok){const{ajv:d,validate:p}=S.value,w=Ot(e),h=It(e),g=h.length>0?new Nt:null,O=a??"onTouched",C=L=>{const U=p(L);let H;return U?H=W.Validation.valid:H=A.ajvErrorsToControllerValidation(p.errors??[]),w?At(L,L,w,p):H},{controller:N,setStatus:K}=v.useController({initialValue:b,validationMode:O,validateDebounceMs:o,validate:O==="onSubmit"?void 0:C}),I=w?kt(w):null,M=i!==!1;let P=!1;const D=M?N.signal.on(L=>{if(P)return;const U=Bt(L);p(U)&&!xt(U,L)&&(P=!0,N.change(U),P=!1)}):()=>{},x=I?N.signal.on((L,U)=>{U!=null&&JSON.stringify(L)!==JSON.stringify(U)&&setTimeout(()=>{const qe=N.status.value;K(qe)},10)}):()=>{},z=g&&h.length>0?N.signal.on(L=>{for(const U of h)g.validateField(U,L,L)}):()=>{},Z=()=>{D(),x(),z(),g?.dispose(),N.dispose()},De=s?Dt(s):void 0,Je=l.Fragment(l.OnDispose(Z),xe({schema:e,controller:N,ajv:d,widgetRegistry:De,setStatus:K,formValue:N.signal,validationMode:O,submitting:c}));return y({Form:Je,controller:N,setStatus:K})}return l.html.div(l.attr.class("bc-json-schema-form__error"),S.error)})}function qt(e,t){const r=(t?.ajv??new _e({allErrors:!0})).compile(e);return{"~standard":{version:1,vendor:"ajv",validate:i=>r(i)?{value:i}:{issues:_t(r.errors??[])},types:void 0}}}function _t(e){return e.map(t=>({message:Kt(t),path:zt(t)}))}function Kt(e){return e.message??`${e.keyword} validation failed`}function zt(e){const t=Ht(e.instancePath||"");if(e.keyword==="required"){const n=e.params.missingProperty;if(n!=null)return[...t,n]}if(e.keyword==="additionalProperties"){const n=e.params.additionalProperty;if(n!=null)return[...t,n]}if(e.keyword==="unevaluatedProperties"){const n=e.params.unevaluatedProperty;if(n!=null)return[...t,n]}return t.length>0?t:void 0}function Ht(e){return e?e.split("/").slice(1).map(n=>n.replace(/~1/g,"/").replace(/~0/g,"~")).map(n=>Gt(n)?Number(n):n):[]}function Gt(e){return/^\d+$/.test(e)}exports.SchemaContext=A.SchemaContext;exports.ajvErrorsToControllerValidation=A.ajvErrorsToControllerValidation;exports.ajvErrorsToDependencies=A.ajvErrorsToDependencies;exports.buildMessage=A.buildMessage;exports.buildPath=A.buildPath;exports.clearCaches=A.clearCaches;exports.clearCachesForAjv=A.clearCachesForAjv;exports.compileWithCache=A.compileWithCache;exports.getAjvForSchema=A.getAjvForSchema;exports.getCacheStats=A.getCacheStats;exports.jsonPointerToSegments=A.jsonPointerToSegments;exports.mergeAllOf=A.mergeAllOf;exports.createDiagnosticWidget=j.createDiagnosticWidget;exports.forFormat=j.forFormat;exports.forTypeAndFormat=j.forTypeAndFormat;exports.forXUI=j.forXUI;exports.JSONSchemaAllOf=gt;exports.JSONSchemaAny=Y;exports.JSONSchemaAnyOf=Ue;exports.JSONSchemaArray=ce;exports.JSONSchemaBoolean=ne;exports.JSONSchemaConst=Ee;exports.JSONSchemaControl=xe;exports.JSONSchemaEnum=Ve;exports.JSONSchemaForm=Jt;exports.JSONSchemaGenericControl=B;exports.JSONSchemaInteger=te;exports.JSONSchemaNull=le;exports.JSONSchemaNumber=X;exports.JSONSchemaObject=ue;exports.JSONSchemaOneOf=$e;exports.JSONSchemaString=ee;exports.JSONSchemaUnion=fe;exports.composeEffectiveObjectSchema=Ae;exports.createAJVStandardSchema=qt;exports.evaluateIfThenElseOverlay=ae;exports.evaluateNotViolation=Ce;exports.extractSchemaDefaults=q;exports.getEvaluatedProperties=J;exports.hasConditionalFeatures=Oe;
@@ -3,12 +3,12 @@ import { m as ve, c as $e, g as Le, a as Be, r as De, e as gt, f as Oe, S as ht,
3
3
  import { j as Nr, k as Rr, l as Vr, n as Er, o as Fr, p as Tr, q as Mr } from "../oneof-branch-detection-DSzC0PkO.js";
4
4
  import { B as q } from "../translations-DT5QQ4WO.js";
5
5
  import { P as wt, E as St, N as xe } from "../notice-Du3tWJTW.js";
6
- import { g as je, B as At, N as H, a as fe, b as Ot, C as jt, c as kt, d as Ct, e as Pt, f as It, h as Nt, i as Rt, S as Vt, j as Et, R as Ft, k as Tt, E as _e, W as Mt } from "../widget-customization-D2a6SVP3.js";
7
- import { l as $r, m as Lr, n as Br, o as Dr } from "../widget-customization-D2a6SVP3.js";
6
+ import { g as je, B as At, N as H, a as fe, b as Ot, C as jt, c as kt, d as Ct, e as Pt, f as It, h as Nt, i as Rt, S as Vt, j as Et, R as Ft, k as Tt, E as _e, W as Mt } from "../widget-customization-BAchyOUo.js";
7
+ import { l as $r, m as Lr, n as Br, o as Dr } from "../widget-customization-BAchyOUo.js";
8
8
  import { S as _, L as ee, M as Wt } from "../stack-BLMteGTn.js";
9
9
  import { I as ie, b as A, M as de, a as ke, C as Ue, O as $t, A as Lt, f as Bt } from "../use-form-D_TJyZhP.js";
10
10
  import { objectEntries as Ke, upperCaseFirst as qe, Validation as $ } from "@tempots/std";
11
- import { S as Dt, b as xt, N as Je, W as _t, c as Ut, t as te, e as Q, T as Kt, U as qt, f as pe, g as Jt, M as ae, G as zt, h as Ht, L as Gt, i as Xt, j as Yt } from "../deep-merge-DwXDd3iF.js";
11
+ import { S as Dt, b as xt, N as Je, W as _t, c as Ut, t as te, e as Q, T as Kt, U as qt, f as pe, g as Jt, M as ae, G as zt, h as Ht, L as Gt, i as Xt, j as Yt } from "../deep-merge-CzZVsVF-.js";
12
12
  import { r as V } from "../utils-vUtP6iPG.js";
13
13
  import { m as Zt, T as Qt } from "../text-input-BAn02BzO.js";
14
14
  import { B as ze } from "../input-container-CO3DNqpp.js";