jedison
Version:
JavaScript Library for JSON Validation and Editing
1 lines • 157 kB
JavaScript
"use strict";function e(e){if(void 0!==e)return JSON.parse(JSON.stringify(e))}function t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function s(e,s,i){return e.replace(new RegExp(t(s),"g"),i)}function i(e){return s(s(e,"#","root"),"/","-")}function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function a(e){return Object.keys(e).sort().reduce((t,s)=>(t[s]=e[s],t),{})}function r(e,t){return f(e)&&f(t)&&(e=a(e),t=a(t)),JSON.stringify(e)===JSON.stringify(t)}function o(e,t){return!r(e,t)}function l(e){return null===e}function d(e){return void 0!==e}function c(e){return void 0===e}function h(e){return"number"==typeof e}function u(e){return h(e)&&e===Math.floor(e)}function p(e){return"string"==typeof e}function m(e){return"boolean"==typeof e}function g(e){return Array.isArray(e)}function f(e){return!l(e)&&!g(e)&&"object"==typeof e}function b(e){let t="any";return h(e)?t=u(e)?"integer":"number":p(e)?t="string":m(e)?t="boolean":g(e)?t="array":l(e)?t="null":f(e)&&(t="object"),t}function v(e,...t){if(!t.length)return e;const s=t.shift();return f(e)&&f(s)&&Object.keys(s).forEach(t=>{f(s[t])?(e[t]||Object.assign(e,{[t]:{}}),v(e[t],s[t])):Object.assign(e,{[t]:s[t]})}),v(e,...t)}function y(e,...t){if(!t.length)return e;const s=t.shift();return Array.isArray(e)&&Array.isArray(s)?e.push(...s):f(e)&&f(s)&&Object.keys(s).forEach(t=>{f(s[t])?(e[t]||Object.assign(e,{[t]:{}}),y(e[t],s[t])):Array.isArray(s[t])?(e[t]||(e[t]=[]),e[t].push(...s[t])):Object.assign(e,{[t]:s[t]})}),y(e,...t)}const C=(e,t)=>(Object.keys(t).forEach(s=>{s in e&&d(e[s])&&d(t[s])&&(f(e[s])&&f(t[s])||g(e[s])&&g(t[s])||p(e[s])&&p(t[s])||h(e[s])&&h(t[s])||m(e[s])&&m(t[s])||l(e[s])&&l(t[s]))&&(f(e[s])&&f(t[s])?C(e[s],t[s]):e[s]=t[s])}),e);function L(e,t){const s=t.split(".");let i=e;for(const a of s)if(Array.isArray(i)&&/^\d+$/.test(a)){const e=parseInt(a);if(!(e>=0&&e<i.length))return;i=i[e]}else{if(!n(i,a))return;i=i[a]}return i}function E(e,t){return e.replace(/{{(.*?)}}/g,e=>{const s=(e=e.replace(/\s/g,"")).split(/{{|}}/)[1];return L(t,s)})}function x(e,t,s){return Math.max(t,Math.min(e,s))}function I(e){const t=[],s=new Set;for(const i of e){const e=JSON.stringify(i);s.has(e)||(s.add(e),t.push(i))}return t}function w(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let s="";for(let i=0;i<e;i++){s+=t[Math.floor(62*Math.random())]}return s}const A={clone:e,escapeRegExp:t,replaceAll:s,pathToAttribute:i,hasOwn:n,sortObject:a,equal:r,different:o,isNull:l,isSet:d,notSet:c,isNumber:h,isInteger:u,isString:p,isBoolean:m,isArray:g,isObject:f,getType:b,mergeDeep:v,combineDeep:y,overwriteExistingProperties:C,getValueByJSONPath:L,compileTemplate:E,clamp:x,removeDuplicatesFromArray:I,generateRandomID:w};function T(t){return f(t.additionalProperties)||m(t.additionalProperties)?e(t.additionalProperties):void 0}function M(t){return f(t.propertyNames)||m(t.propertyNames)?e(t.propertyNames):void 0}function j(t){return g(t.allOf)?e(t.allOf):void 0}function P(t){return g(t.anyOf)?e(t.anyOf):void 0}function S(t){return e(t.const)}function k(t){return f(t.contains)||m(t.contains)?e(t.contains):void 0}function O(t){return e(t.default)}function D(t){return f(t.dependentRequired)?e(t.dependentRequired):void 0}function F(t){return f(t.dependentSchemas)?e(t.dependentSchemas):void 0}function H(t){return p(t.description)?e(t.description):void 0}function V(t){return f(t.else)||m(t.else)?e(t.else):void 0}function R(t){if(g(t.enum)&&t.enum.length>0)return e(t.enum)}function B(t){return h(t.exclusiveMaximum)?e(t.exclusiveMaximum):void 0}function q(e){return h(e.exclusiveMinimum)?e.exclusiveMinimum:void 0}function N(t){return p(t.format)?e(t.format):void 0}function U(t){return f(t.if)||m(t.if)?e(t.if):void 0}function z(t){return f(t.items)||m(t.items)?e(t.items):void 0}function W(t){return h(t.maximum)?e(t.maximum):void 0}function G(t){if(u(t.maxContains)&&t.maxContains>=0)return e(t.maxContains)}function $(t){if(u(t.maxItems)&&t.maxItems>=0)return e(t.maxItems)}function K(t){if(u(t.maxLength)&&t.maxLength>=0)return e(t.maxLength)}function J(t){if(u(t.maxProperties))return e(t.maxProperties)}function Z(t){return h(t.minimum)?e(t.minimum):void 0}function _(t){if(u(t.minContains)&&t.minContains>=0)return e(t.minContains)}function Q(t){if(u(t.minItems)&&t.minItems>=0)return e(t.minItems)}function X(t){if(u(t.minLength)&&t.minLength>=0)return e(t.minLength)}function Y(t){if(u(t.minProperties)&&t.minProperties>=0)return e(t.minProperties)}function ee(t){if(h(t.multipleOf)&&t.multipleOf>=0)return e(t.multipleOf)}function te(t){return f(t.not)||m(t.not)?e(t.not):void 0}function se(e,t){const s="x-"+t;return d(e[s])?e[s]:e["x-options"]&&d(e["x-options"][t])?e["x-options"][t]:void 0}function ie(t){return p(t.pattern)?e(t.pattern):void 0}function ne(t){return f(t.patternProperties)?e(t.patternProperties):void 0}function ae(t){return g(t.prefixItems)?e(t.prefixItems):void 0}function re(t){return f(t.properties)?e(t.properties):void 0}function oe(t){return m(t.readOnly)?e(t.readOnly):void 0}function le(e){return g(e.required)?[...new Set(e.required)]:void 0}function de(t){return f(t.then)||m(t.then)?e(t.then):void 0}function ce(t){return p(t.title)?e(t.title):void 0}function he(t){if(p(t.type)||g(t.type))return e(t.type)}function ue(t){return g(t.oneOf)?e(t.oneOf):void 0}function pe(t){return m(t.unevaluatedProperties)?e(t.unevaluatedProperties):void 0}function me(t){return m(t.uniqueItems)?e(t.uniqueItems):void 0}const ge={getSchemaX:function(e,t){return e["x-"+t]},getSchemaSchema:function(t){return p(t.$schema)?e(t.$schema):void 0},getSchemaAdditionalProperties:T,getSchemaPropertyNames:M,getSchemaAllOf:j,getSchemaAnyOf:P,getSchemaConst:S,getSchemaContains:k,getSchemaDefault:O,getSchemaDependentRequired:D,getSchemaDependentSchemas:F,getSchemaDescription:H,getSchemaElse:V,getSchemaEnum:R,getSchemaExclusiveMaximum:B,getSchemaExclusiveMinimum:q,getSchemaFormat:N,getSchemaIf:U,getSchemaItems:z,getSchemaMaximum:W,getSchemaMaxContains:G,getSchemaMaxItems:$,getSchemaMaxLength:K,getSchemaMaxProperties:J,getSchemaMinimum:Z,getSchemaMinContains:_,getSchemaMinItems:Q,getSchemaMinLength:X,getSchemaMinProperties:Y,getSchemaMultipleOf:ee,getSchemaNot:te,getSchemaXOption:se,getSchemaPattern:ie,getSchemaPatternProperties:ne,getSchemaPrefixItems:ae,getSchemaProperties:re,getSchemaReadOnly:oe,getSchemaRequired:le,getSchemaThen:de,getSchemaTitle:ce,getSchemaType:he,getSchemaOneOf:ue,getSchemaUnevaluatedProperties:pe,getSchemaUniqueItems:me};function fe(e){let t=[];const s=j(e.schema);return d(s)&&(s.forEach(s=>{const i=new ns({refParser:e.validator.refParser,schema:s,data:e.value,rootName:e.key}),n=i.getErrors();i.destroy(),n.forEach(t=>{t.path=e.path}),t.push(...n)}),t=I(t)),t}function be(e){const t=[],s=X(e.schema);if(p(e.value)&&d(s)){e.value=e.value.replace(/[\uDCA9]/g,"");e.value.length<s&&t.push({type:"error",path:e.path,constraint:"minLength",messages:[E(e.translator.translate("errorMinLength"),{minLength:s})]})}return t}function ve(e){const t=[],s=P(e.schema);if(d(s)){let i=!1;s.forEach(t=>{const s=new ns({refParser:e.validator.refParser,schema:t,data:e.value}),n=s.getErrors();s.destroy(),0===n.length&&(i=!0)}),i||t.push({type:"error",path:e.path,constraint:"anyOf",messages:[e.translator.translate("errorAnyOf")]})}return t}function ye(e){const t=[],s=R(e.schema);if(d(s)){!s.some(t=>JSON.stringify(e.value)===JSON.stringify(t))&&t.push({type:"error",path:e.path,constraint:"enum",messages:[E(e.translator.translate("errorEnum"),{enum:JSON.stringify(s)})]})}return t}function Ce(e){const t=[],s=B(e.schema);if(h(e.value)&&d(s)){e.value>=s&&t.push({type:"error",path:e.path,constraint:"exclusiveMaximum",messages:[E(e.translator.translate("errorExclusiveMaximum"),{exclusiveMaximum:s})]})}return t}function Le(e){const t=[],s=q(e.schema);if(h(e.value)&&d(s)){e.value<=s&&t.push({type:"error",path:e.path,constraint:"exclusiveMinimum",messages:[E(e.translator.translate("errorExclusiveMinimum"),{exclusiveMinimum:s})]})}return t}function Ee(e){const t=[],s=N(e.schema);let i=e.validator.assertFormat;if(se(e.schema,"assertFormat")&&(i=e.schema.options.assertFormat),d(s)&&p(e.value)&&i){let i;"email"===s&&(i=new RegExp(/^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/i)),"url"===s&&(i=new RegExp(/^(?:https?|ftp):\/\/(?:[^\s:@]+(?::[^\s:@]*)?@)?(?:(?:[^\s:@]+(?::[^\s:@]*)?@)?(?:[^\s:@](?:[^\s:@-]*[^\s:@])?\.?)+[a-zA-Z]{2,}|(?:\d{1,3}\.){3}\d{1,3})(?::\d{2,5})?(?:\/[^\s]*)?$/i)),"uuid"===s&&(i=new RegExp(/^(?:urn:uuid:)?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$/i));d(i)&&!i.test(e.value)&&t.push({type:"error",path:e.path,constraint:"format",messages:[E(e.translator.translate("errorFormat"),{format:s})]})}return t}function xe(e){const t=[],s=z(e.schema),i=ae(e.schema);if(g(e.value)&&d(s)){const n=d(i)?i.length:0;!1===s&&e.value.length>0&&e.value.length>n&&t.push({type:"error",path:e.path,constraint:"items",messages:[e.translator.translate("errorItems")]})}return t}function Ie(e){const t=[],s=$(e.schema);if(g(e.value)&&d(s)){e.value.length>s&&t.push({type:"error",path:e.path,constraint:"maxItems",messages:[E(e.translator.translate("errorMaxItems"),{maxItems:s})]})}return t}function we(e){const t=[],s=K(e.schema);if(p(e.value)&&d(s)){e.value=e.value.replace(/[\uDCA9]/g,"");e.value.length>s&&t.push({type:"error",path:e.path,constraint:"maxLength",messages:[E(e.translator.translate("errorMaxLength"),{maxLength:s})]})}return t}function Ae(e){const t=[],s=J(e.schema);if(f(e.value)&&d(s)){Object.keys(e.value).length>s&&t.push({type:"error",path:e.path,constraint:"maxProperties",messages:[E(e.translator.translate("errorMaxProperties"),{maxProperties:s})]})}return t}function Te(e){const t=[],s=Z(e.schema);if(h(e.value)&&d(s)){e.value<s&&t.push({type:"error",path:e.path,constraint:"minimum",messages:[E(e.translator.translate("errorMinimum"),{minimum:s})]})}return t}function Me(e){const t=[],s=Q(e.schema);if(g(e.value)&&d(s)){e.value.length<s&&t.push({type:"error",path:e.path,constraint:"minItems",messages:[E(e.translator.translate("errorMinItems"),{minItems:s})]})}return t}function je(e){const t=[],s=Y(e.schema);if(f(e.value)&&d(s)){Object.keys(e.value).length<s&&t.push({type:"error",path:e.path,constraint:"minProperties",messages:[E(e.translator.translate("errorMinProperties"),{minProperties:s})]})}return t}function Pe(e){const t=[],s=ee(e.schema);if(h(e.value)&&d(s)){if(0===e.value)return t;(!(e.value/s===Math.floor(e.value/s))||e.value.toString().includes("e"))&&t.push({type:"error",path:e.path,constraint:"multipleOf",messages:[E(e.translator.translate("errorMultipleOf"),{multipleOf:s})]})}return t}function Se(e){const t=[],s=te(e.schema);if(d(s)){const i=new ns({refParser:e.validator.refParser,schema:s,data:e.value}),n=i.getErrors();i.destroy();0===n.length&&t.push({type:"error",path:e.path,constraint:"not",messages:[E(e.translator.translate("errorNot"))]})}return t}function ke(e){const t=[],s=ue(e.schema);if(d(s)){let i=0;s.forEach(t=>{const s=new ns({refParser:e.validator.refParser,schema:t,data:e.value}),n=s.getErrors();s.destroy(),0===n.length&&i++}),1!==i&&t.push({type:"error",path:e.path,constraint:"oneOf",messages:[E(e.translator.translate("errorOneOf"),{counter:i})]})}return t}function Oe(e){const t=[],s=ie(e.schema);if(p(e.value)&&d(s)){!new RegExp(s).test(e.value)&&t.push({type:"error",path:e.path,constraint:"pattern",messages:[E(e.translator.translate("errorPattern"),{pattern:s})]})}return t}function De(e){let t=[];const s=ne(e.schema);return f(e.value)&&d(s)&&Object.keys(e.value).forEach(i=>{Object.keys(s).forEach(n=>{if(new RegExp(n).test(i)){const a=s[n],r=new ns({refParser:e.validator.refParser,schema:a,data:e.value[i]}),o=r.getErrors().map(t=>({type:"error",path:e.path+"/"+i,constraint:"patternProperties",messages:t.messages}));t=[...t,...o],r.destroy()}})}),t}function Fe(e){const t=re(e.schema),s=[];return f(e.value)&&d(t)&&Object.keys(t).forEach(i=>{if(n(e.value,i)){const n=t[i];e.validator.getErrors(e.value[i],n,i,e.path+"/"+i).length>0&&s.push(i)}}),s.length>0?[{type:"error",path:e.path,constraint:"properties",messages:[E(e.translator.translate("errorProperties"),{properties:s.join(", ")})]}]:[]}function He(e){const t=[],s=le(e.schema);if(f(e.value)&&d(s)){const i=[],n=Object.keys(e.value);s.forEach(e=>{n.includes(e)||i.push(e)});i.length>0&&t.push({type:"error",path:e.path,constraint:"required",messages:[E(e.translator.translate("errorRequired"),{required:i.join(", ")})]})}return t}function Ve(e){const t=[],s=he(e.schema);if("any"===s)return t;if(d(s)){const i={string:e=>p(e),number:e=>h(e),integer:e=>u(e),boolean:e=>m(e),array:e=>g(e),object:e=>f(e),null:e=>l(e)};let n=!0;n=g(s)?s.some(t=>i[t](e.value)):i[s](e.value),n||t.push({type:"error",path:e.path,constraint:"type",messages:[E(e.translator.translate("errorType"),{type:s,valueType:b(e.value)})]})}return t}function Re(e){const t=[],s=W(e.schema);if(h(e.value)&&d(s)){e.value>s&&t.push({type:"error",path:e.path,constraint:"maximum",messages:[E(e.translator.translate("errorMaximum"),{maximum:s})]})}return t}function Be(e){const t=[],s=me(e.schema);if(g(e.value)&&d(s)&&!0===s){const s=[];let i=!1;for(let t=0;t<e.value.length;t++){let n=e.value[t];f(n)&&(n=a(n));const r=JSON.stringify(n);if(i=s.some(e=>e===r),i)break;s.push(r)}i&&t.push({type:"error",path:e.path,constraint:"uniqueItems",messages:[e.translator.translate("errorUniqueItems")]})}return t}function qe(e){const t=[],s=T(e.schema),i=ne(e.schema),a=re(e.schema);if(f(e.value)&&d(s)){const r=a||{},o=s,l=i||{};Object.keys(e.value).forEach(s=>{const i=Object.keys(l).some(e=>new RegExp(e).test(s)),a=n(r,s);if(!i&&!a)if(!1===o)t.push({type:"error",path:e.path,constraint:"additionalProperties",messages:[E(e.translator.translate("errorAdditionalProperties"),{property:s})]});else if(f(o)){const i=new ns({refParser:e.validator.refParser,schema:o,data:e.value[s]}),n=i.getErrors().map(t=>({type:"error",path:`${e.path}.${s}`,constraint:"additionalProperties",messages:t.messages}));t.push(...n),i.destroy()}})}return t}const Ne={additionalProperties:qe,allOf:fe,anyOf:ve,enum:ye,exclusiveMaximum:Ce,exclusiveMinimum:Le,format:Ee,items:xe,maximum:Re,maxItems:Ie,maxLength:we,maxProperties:Ae,minimum:Te,minItems:Me,minLength:be,minProperties:je,multipleOf:Pe,not:Se,oneOf:ke,pattern:Oe,patternProperties:De,properties:Fe,required:He,type:Ve,uniqueItems:Be};function Ue(e){const t=[],s=S(e.schema);if(d(s)){o(e.value,s)&&t.push({type:"error",path:e.path,constraint:"const",messages:[E(e.translator.translate("errorConst"),{const:JSON.stringify(s)})]})}return t}function ze(e){const t=[],s=k(e.schema),i=_(e.schema),n=G(e.schema);if(g(e.value)&&d(s)){let a=0;e.value.forEach(t=>{const i=new ns({refParser:e.validator.refParser,schema:s,data:t});0===i.getErrors().length&&a++,i.destroy()});const r=0===a;if(d(i)){a<i&&t.push({type:"error",path:e.path,constraint:"minContains",messages:[E(e.translator.translate("errorMinContains"),{counter:a,minContains:i})]})}else r&&t.push({type:"error",path:e.path,constraint:"contains",messages:[e.translator.translate("errorContains")]});if(d(n)){a>n&&t.push({type:"error",path:e.path,constraint:"maxContains",messages:[E(e.translator.translate("errorMaxContains"),{counter:a,maxContains:n})]})}}return t}function We(e){const t=[],s=D(e.schema);if(f(e.value)&&d(s)){let i=[];Object.keys(s).forEach(t=>{if(d(e.value[t])){const a=s[t];i=a.filter(t=>!n(e.value,t))}});i.length>0&&t.push({type:"error",path:e.path,constraint:"dependentRequired",messages:[E(e.translator.translate("errorDependentRequired"),{dependentRequired:i.join(", ")})]})}return t}function Ge(e){let t=[];const s=F(e.schema);return f(e.value)&&d(s)&&Object.keys(s).forEach(i=>{if(d(e.value[i])){const n=s[i],a=new ns({refParser:e.validator.refParser,schema:n,data:e.value}),r=a.getErrors();a.destroy(),t=[...t,...r]}}),t}function $e(e){const t=[],s=U(e.schema),i=de(e.schema),n=V(e.schema);if(d(s)){if(c(i)&&c(n))return t;const a=new ns({refParser:e.validator.refParser,schema:s,data:e.value}),r=a.getErrors();a.destroy();let o=[],l=[];if(d(i)){const t=new ns({refParser:e.validator.refParser,schema:i,data:e.value});o=t.getErrors(),t.destroy()}if(d(n)){const t=new ns({refParser:e.validator.refParser,schema:n,data:e.value});l=t.getErrors(),t.destroy()}if(!0===s)return o;if(!1===s)return l;if(0===r.length)return o;if(r.length>0)return l}return t}function Ke(e){const t=[],s=ae(e.schema);return g(e.value)&&d(s)&&s.forEach((s,i)=>{const n=e.value[i];if(d(n)){const a=new ns({refParser:e.validator.refParser,schema:s,data:n}),r=a.getErrors();a.destroy(),r.length>0&&t.push({type:"error",path:e.path,constraint:"prefixItems",messages:[E(e.translator.translate("errorPrefixItems"),{index:i})]})}}),t}const Je={additionalProperties:qe,allOf:fe,anyOf:ve,const:Ue,contains:ze,dependentRequired:We,dependentSchemas:Ge,enum:ye,exclusiveMaximum:Ce,exclusiveMinimum:Le,format:Ee,if:$e,items:xe,maximum:Re,maxItems:Ie,maxLength:we,maxProperties:Ae,minimum:Te,minItems:Me,minLength:be,minProperties:je,multipleOf:Pe,not:Se,oneOf:ke,pattern:Oe,patternProperties:De,properties:Fe,prefixItems:Ke,required:He,type:Ve,uniqueItems:Be},Ze={additionalProperties:qe,allOf:fe,anyOf:ve,const:Ue,contains:ze,dependentRequired:We,dependentSchemas:Ge,enum:ye,exclusiveMaximum:Ce,exclusiveMinimum:Le,format:Ee,if:$e,items:xe,maximum:Re,maxItems:Ie,maxLength:we,maxProperties:Ae,minimum:Te,minItems:Me,minLength:be,minProperties:je,multipleOf:Pe,not:Se,oneOf:ke,pattern:Oe,patternProperties:De,properties:Fe,prefixItems:Ke,required:He,type:Ve,uniqueItems:Be};function _e(e){let t=[];const s=pe(e.schema),i=ne(e.schema),a=re(e.schema),r=j(e.schema),o=P(e.schema),l=ue(e.schema);if(f(e.value)&&d(s)){let c=d(a)?a:{};const h=s,u=i;[r,o,l].forEach(e=>{d(e)&&e.forEach(e=>{d(e.properties)&&(c={...c,...e.properties})})}),c&&Object.keys(e.value).forEach(s=>{let i=!1;if(d(u)&&Object.keys(u).forEach(e=>{const t=new RegExp(e);i=t.test(s)}),i||!1!==h||n(c,s)||t.push({type:"error",path:e.path,constraint:"unevaluatedProperties",messages:[E(e.translator.translate("errorUnevaluatedProperties"),{property:s})]}),!i&&f(h)&&!n(c,s)){const i=new ns({refParser:e.validator.refParser,schema:h,data:e.value[s]}),n=i.getErrors().map(e=>({type:"error",path:s,constraint:"unevaluatedProperties",messages:e.messages}));t=[...t,...n],i.destroy()}})}return t}const Qe={additionalProperties:qe,allOf:fe,anyOf:ve,const:Ue,contains:ze,dependentRequired:We,dependentSchemas:Ge,enum:ye,exclusiveMaximum:Ce,exclusiveMinimum:Le,format:Ee,if:$e,items:xe,maximum:Re,maxItems:Ie,maxLength:we,maxProperties:Ae,minimum:Te,minItems:Me,minLength:be,minProperties:je,multipleOf:Pe,not:Se,oneOf:ke,pattern:Oe,patternProperties:De,propertie:Fe,prefixItems:Ke,required:He,type:Ve,unevaluatedProperties:_e,uniqueItems:Be};const Xe={additionalProperties:qe,allOf:fe,anyOf:ve,const:Ue,contains:ze,dependentRequired:We,dependentSchemas:Ge,enum:ye,exclusiveMaximum:Ce,exclusiveMinimum:Le,format:Ee,if:$e,items:xe,maximum:Re,maxItems:Ie,maxLength:we,maxProperties:Ae,minimum:Te,minItems:Me,minLength:be,minProperties:je,multipleOf:Pe,not:Se,oneOf:ke,pattern:Oe,patternProperties:De,prefixItems:Ke,propertyNames:function(e){const t=[],s=M(e.schema);return f(e.value)&&d(s)&&Object.keys(e.value).forEach(i=>{new ns({refParser:e.validator.refParser,schema:s,data:i}).getErrors().length>0&&t.push({type:"error",path:e.path,constraint:"propertyNames",messages:[E(e.translator.translate("errorPropertyNames"),{propertyName:i})]})}),t},properties:Fe,required:He,type:Ve,unevaluatedProperties:_e,uniqueItems:Be};class Ye{constructor(e={}){this.refParser=e.refParser,this.constraints=e.constraints??{},this.assertFormat=!!e.assertFormat&&e.assertFormat,this.translator=!!e.translator&&e.translator,this.draft=Xe,this.jsonSchemaDrafts={"http://json-schema.org/draft-04/schema#":Ne,"http://json-schema.org/draft-06/schema#":Je,"http://json-schema.org/draft-07/schema#":Ze,"https://json-schema.org/draft/2019-09/schema":Qe,"https://json-schema.org/draft/2020-12/schema":Xe}}getErrors(t,s,i,a){let r=[];const o=e(s);if(m(o)&&!0===o)return r;if(m(o)&&!1===o)return[{type:"error",messages:["invalid"],path:a}];const l={...this.draft,...this.constraints};for(const[e,d]of Object.entries(l))if(n(o,e)){const e=d({validator:this,value:t,schema:o,key:i,path:a,translator:this.translator});e&&(r=[...r,...e])}const c=se(s,"messages");return d(c)&&(f(c)&&r.forEach(e=>{var t,s;const i=null==(s=null==c?void 0:c[null==(t=this.translator)?void 0:t.language])?void 0:s[null==e?void 0:e.constraint],n=null==c?void 0:c[null==e?void 0:e.constraint],a=i??n;return d(a)&&(e.messages=[a]),e}),g(c)&&r.length>0&&r.forEach(e=>(e.messages=c,e))),r}}class et{constructor(){this.listeners=[]}on(e,t){this.listeners.push({name:e,callback:t})}off(e){this.listeners=this.listeners.filter(t=>t.name!==e)}emit(e,...t){this.listeners.filter(t=>t.name===e).forEach(s=>{try{s.callback(...t)}catch(i){console.error(`Error in listener callback for event "${e}":`,i)}})}destroy(){Object.keys(this).forEach(e=>{delete this[e]})}}class tt extends et{constructor(e){super(),this.jedison=e.jedison,this.path=e.path||this.jedison.rootName,this.schema=e.schema,this.value=d(e.value)?e.value:void 0,this.isActive=!0,this.parent=e.parent||null,this.children=[],this.ui=null,this.isDirty=!1,this.watched={},this.key=this.path.split(this.jedison.pathSeparator).pop(),this.arrayTemplateData=e.arrayTemplateData||{},this.init()}init(){this.register(),this.setInitialValue(),this.prepare(),this.setDefaultValue(),this.registerWatcher(),this.setValueFormTemplate(),this.jedison.options.container&&this.setUI(),this.on("notifyParent",e=>{this.parent&&(this.parent.isDirty=!0,this.parent.onChildChange(e))})}setUI(){if(this.jedison.isEditor){const e=this.jedison.uiResolver.getClass(this.schema);this.ui=new e(this)}}getKey(){return this.key}getSchema(){return this.schema}register(){if(this.jedison.register(this),0===this.children.length)return;const e=t=>{this.jedison.register(t),t.children.length>0&&t.children.forEach(e)};this.children.forEach(e)}unregister(){if(this.jedison.unregister(this),0===this.children.length)return;const e=t=>{this.jedison.unregister(t),t.children.length>0&&t.children.forEach(e)};this.children.forEach(e)}setInitialValue(){const e=se(this.schema,"enforceEnumDefault"),t=se(this.schema,"enforceEnum"),s=e??this.jedison.options.enforceEnumDefault,i=t??this.jedison.options.enforceEnum,n=d(t)?i:s,a=R(this.schema);if(d(a)&&!a.includes(this.getValue())&&d(a[0])&&n&&this.setValue(a[0],!1),c(this.value)){let e;const t=he(this.schema);"boolean"===t&&(e=!1),"number"===t&&(e=0),"integer"===t&&(e=0),"string"===t&&(e=""),"array"===t&&(e=[]),"object"===t&&(e={}),"null"===t&&(e=null),this.value=e}}setDefaultValue(){const e=O(this.schema);d(e)&&this.setValue(e,!1);const t=se(this.schema,"enforceConst")??this.jedison.options.enforceConst;if(d(t)&&r(t,!0)){const e=S(this.schema);d(e)&&this.setValue(e,!1)}}registerWatcher(){const e=se(this.schema,"watch");d(e)&&Object.entries(e).forEach(([e,t])=>{this.jedison.watch(t,()=>{this.updateWatchedData(e,t)})})}updateWatchedData(e,t){const s=this.jedison.getInstance(t);d(s)&&(s&&(this.watched[e]={value:s.getValue(),schema:s.getSchema(),properties:s.schema.properties?Object.keys(s.schema.properties):[]}),this.setValueFormTemplate())}setValueFormTemplate(){const e=se(this.schema,"template");d(e)&&e&&this.setValue(E(e,this.watched))}getValue(){return e(this.value)}getTemplateData(){return{...this.arrayTemplateData,value:this.getValue(),settings:this.jedison.options.settings}}setValue(e,t=!0,s="api"){if(this.value===e)return this.value;if("object"!=typeof this.value&&"object"!=typeof e&&this.value===e)return this.value;const i=se(this.schema,"enforceConst")??this.jedison.options.enforceConst;if(d(i)&&r(i,!0)){const t=S(this.schema);d(t)&&(e=t)}return o(this.value,e)?(this.value=e,this.isDirty=!0,this.emit("set-value",e,s),this.emit("change",s),this.jedison.emit("instance-change",this,s),t&&this.emit("notifyParent",s),this.value):this.value}onChildChange(e){}getErrors(){if(!this.isActive)return[];return I(this.jedison.validator.getErrors(this.getValue(),this.schema,this.getKey(),this.path))}prepare(){}activate(){!1===this.isActive&&(this.isActive=!0,this.emit("notifyParent"))}deactivate(){!0===this.isActive&&(this.isActive=!1,this.emit("notifyParent"))}isReadOnly(){return!0===oe(this.schema)||!!this.parent&&this.parent.isReadOnly()}destroy(){this.unregister(),this.listeners=null,this.children.length>0&&(this.children.forEach(e=>e.destroy()),this.children=[]),this.ui&&(this.ui.destroy(),this.ui=null),Object.keys(this).forEach(e=>{this[e]=null}),super.destroy()}}class st{constructor(e){this.instance=e,this.theme=null,this.control=null,this.disabled=!1,this.readOnly=this.instance.isReadOnly(),this.showingValidationErrors=!1,this.markdownEnabled=!1,this.purifyEnabled=!1,this.title=null,this.description=null,this.init(),this.build(),this.setAttributes(),this.addEventListeners(),this.setVisibility(),this.setContainerAttributes(),this.refreshUI();("always"===this.instance.jedison.options.showErrors||"always"===se(this.instance.schema,"showErrors"))&&this.showValidationErrors(this.instance.getErrors());this.instance.on("change",()=>{this.refreshUI(),this.showValidationErrors(this.instance.getErrors())})}static resolves(e){}init(){this.theme=this.instance.jedison.theme,this.markdownEnabled=se(this.instance.schema,"parseMarkdown")??this.instance.jedison.options.parseMarkdown,this.purifyEnabled=se(this.instance.schema,"purifyHtml")??this.instance.jedison.options.purifyHtml}getLevel(){return(this.instance.path.match(/\//g)||[]).length}setVisibility(){const e=se(this.instance.schema,"hidden");d(e)&&!0===e&&(this.control.container.style.display="none",this.control.container.setAttribute("aria-hidden","true"))}setContainerAttributes(){this.control.container.setAttribute("data-level",this.getLevel()),this.control.container.setAttribute("data-path",this.instance.path),this.control.container.setAttribute("data-type",he(this.instance.schema));const e=se(this.instance.schema,"containerAttributes");if(d(e)&&f(e))for(const[t,s]of Object.entries(e))if("class"===t){s.split(" ").forEach(e=>{this.control.container.classList.add(e)})}else this.control.container.setAttribute(t,s)}build(){}adaptForTable(){}setAttributes(){const e=this.control.input;if(d(e)){const t=se(this.instance.schema,"inputAttributes");if(f(t))for(const[s,i]of Object.entries(t))e.setAttribute(s,i)}}getIdFromPath(e){const t=this.instance.jedison.options.id;return t?t+"-"+i(e):i(e)}getValidationEventType(){return"input"===(se(this.instance.schema,"showErrors")??this.instance.jedison.options.showErrors)?"input":"change"}addEventListeners(){}showValidationErrors(e,t=!1){e=e.filter(e=>e.path===this.instance.path),this.control.messages.innerHTML="",this.showingValidationErrors=!1;("never"===this.instance.jedison.options.showErrors||"never"===se(this.instance.schema,"showErrors"))&&!t||0===e.length||(e.forEach(e=>{"properties"!==e.constraint&&e.messages.forEach(t=>{let s;s="error"===e.type?this.getErrorFeedback({message:t}):this.getWarningFeedback({message:t}),this.control.messages.appendChild(s)})}),this.showingValidationErrors=!0)}getErrorFeedback(e){return this.theme.getErrorFeedback(e)}getWarningFeedback(e){return this.theme.getWarningFeedback(e)}disable(){this.disabled=!0,this.refreshUI()}enable(){this.disabled=!1,this.refreshUI()}purifyContent(e,t){if(this.instance.jedison.options.purifyHtml&&window.DOMPurify)return window.DOMPurify.sanitize(e,t);{const t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText}}getHtmlFromMarkdown(e){return window.marked.parse(e)}getTitle(){let e=!1;this.title=this.instance.getKey();const t=ce(this.instance.schema);if(d(t)&&(this.title=t,e=!0),e){this.title=E(this.title,this.instance.getTemplateData()),this.title=this.markdownEnabled?this.getHtmlFromMarkdown(this.title):this.title;const e=y({},this.instance.jedison.options.domPurifyOptions,{FORBID_TAGS:["p"]});this.title=this.purifyEnabled?this.purifyContent(this.title,e):this.title}return this.title}getDescription(){const e=H(this.instance.schema);if(d(e)){this.description=E(e,this.instance.getTemplateData()),this.description=this.markdownEnabled?this.getHtmlFromMarkdown(this.description):this.description;const t=this.instance.jedison.options.domPurifyOptions;this.description=this.purifyEnabled?this.purifyContent(this.description,t):this.description}return this.description}getInfo(e=null){const t=se(e??this.instance.schema,"info");if(!d(t))return t;const s=this.instance.jedison.options.domPurifyOptions;return d(t.title)&&(t.title=this.markdownEnabled?this.getHtmlFromMarkdown(t.title):t.title,t.title=this.purifyEnabled?this.purifyContent(t.title,s):t.title),d(t.content)&&(t.content=this.markdownEnabled?this.getHtmlFromMarkdown(t.content):t.content,t.content=this.purifyEnabled?this.purifyContent(t.content,s):t.content),t}refreshUI(){this.refreshDisabledState(),this.refreshTemplates()}refreshDisabledState(){this.control.container.querySelectorAll("button, input, select, textarea").forEach(e=>{this.disabled||this.readOnly||e.hasAttribute("always-disabled")?e.setAttribute("disabled",""):e.removeAttribute("disabled",""),e.hasAttribute("always-enabled")&&e.removeAttribute("disabled","")})}refreshTemplates(){this.control.legendText&&this.getTitle()&&(this.control.legendText.innerHTML=this.getTitle()),this.control.labelText&&this.getTitle()&&(this.control.labelText.innerHTML=this.getTitle()),this.control.description&&this.getDescription()&&(this.control.description.innerHTML=this.getDescription())}sanitize(e){return e}destroy(){this.control.container&&this.control.container.parentNode&&this.control.container.parentNode.removeChild(this.control.container),Object.keys(this).forEach(e=>{delete this[e]})}}class it extends st{static resolves(e){return d(U(e))}build(){this.control=this.theme.getIfThenElseControl({title:"Options",titleHidden:se(this.instance.schema,"titleHidden"),id:this.getIdFromPath(this.instance.path),description:H(this.instance.schema)})}refreshUI(){this.refreshDisabledState(),this.control.childrenSlot.innerHTML="",this.control.childrenSlot.appendChild(this.instance.activeInstance.ui.control.container),this.disabled||this.instance.isReadOnly()?this.instance.activeInstance.ui.disable():this.instance.activeInstance.ui.enable()}getErrorFeedback(e){return this.theme.getAlert(e)}}class nt extends tt{setUI(){this.ui=new it(this)}prepare(){this.instances=[],this.instanceStartingValues=[],this.instanceWithoutIf=null,this.activeInstance=null,this.index=0,this.schemas=[],this.ifThenElseShemas=[],this.traverseSchema(this.schema),delete this.schema.if,delete this.schema.then,delete this.schema.else,this.ifThenElseShemas.forEach(t=>{d(t.then)&&this.schemas.push(v({},e(this.schema),t.then)),d(t.else)&&this.schemas.push(v({},e(this.schema),t.else))});const t=e(this.schema);delete t.if,delete t.then,delete t.else,this.instanceWithoutIf=this.jedison.createInstance({jedison:this.jedison,schema:t,path:this.path,parent:this.parent}),this.schemas.forEach(e=>{const t=this.jedison.createInstance({jedison:this.jedison,schema:e,path:this.path,parent:this.parent});this.instanceStartingValues.push(t.getValue()),this.instances.push(t)}),this.on("set-value",(e,t)=>{this.changeValue(e,t)});const s=this.instanceWithoutIf.getValue();this.changeValue(s)}changeValue(e,t="api"){const s=this.getWithoutIfValueFromValue(e),i=this.getFittestIndex(s),a=i!==this.index;this.index=i,this.activeInstance=this.instances[i],this.activeInstance.register(),this.instances.forEach((i,r)=>{i.off("notifyParent"),i.children&&f(e)&&i.children.forEach(t=>{t.isMultiple&&n(e,t.getKey())&&t.setValue(e[t.getKey()],!0,"api")});const o=this.instanceStartingValues[r],l=i.getValue();let d=e;f(o)&&f(e)&&(a?(d=C(o,s),this.jedison.updateInstancesWatchedData()):d=C(l,e),"api"===t&&(d=C(l,e))),i.setValue(d,!1,t),i.on("notifyParent",e=>{const t=i.getValue();this.changeValue(t,e),this.emit("notifyParent",e),this.emit("change",e)})}),"api"===t&&this.hasNullableFields(this.activeInstance)&&this.activeInstance.setValue(e,!1,"secondary"),this.value=this.activeInstance.getValue()}getWithoutIfValueFromValue(e){let t=this.instanceWithoutIf.getValue();return f(t)&&f(e)?(t=C(t,e),t):e}switchInstance(e){this.index=e,this.activeInstance=this.instances[this.index]}traverseSchema(e){const t=U(e);if(d(t)){const s=de(e),i=V(e);this.ifThenElseShemas.push({if:t,then:d(s)?s:{}}),this.ifThenElseShemas.push({if:t,else:d(i)?i:{}})}}hasNullableFields(e){return!!e&&(!!this.isNullableSchema(e.schema)||!!e.children&&e.children.some(e=>this.hasNullableFields(e)))}isNullableSchema(e){return!!e&&(!(!e["x-format"]||!e["x-format"].includes("nullable"))||(!(!Array.isArray(e.type)||!e.type.includes("null"))||!!e.properties&&Object.values(e.properties).some(e=>this.isNullableSchema(e))))}getFittestIndex(t){let s=this.index;return this.ifThenElseShemas.forEach((i,n)=>{if(!0===i.if)s=0;else if(!1===i.if)s=1;else{const a=e(i.if);d(this.schema.type)&&(a.type=this.schema.type);const r=new ns({schema:a,data:t,refParser:this.jedison.refParser}),o=r.getErrors();r.destroy(),0===o.length&&i.then&&(s=n),o.length>0&&i.else&&(s=n)}}),s}destroy(){this.instances.forEach(e=>{e.destroy()}),super.destroy()}}class at extends tt{prepare(){this.instances=[],this.activeInstance=null,this.index=0,this.schemas=[],this.switcherOptionValues=[],this.switcherOptionsLabels=[],this.isMultiple=!0,this.on("set-value",()=>{this.onSetValue()});const t=he(this.schema);if(d(P(this.schema))||d(ue(this.schema))){const t=d(P(this.schema))?P(this.schema):ue(this.schema),s=e(this.schema);delete s.anyOf,delete s.oneOf,delete s.options,t.forEach((e,t)=>{let i="Option-"+(t+1);const n=se(e={...s,...e},"switcherTitle"),a=ce(e),r=H(e);d(r)&&(i=r),d(a)&&(i=a),d(n)&&(i=n),this.switcherOptionValues.push(t),this.switcherOptionsLabels.push(i),this.schemas.push(e)})}else if(g(t))t.forEach((e,t)=>{const s=v(this.schema),i={...s,type:e,title:e[0].toUpperCase()+e.slice(1)};d(s.title)&&(i.title=s.title),this.switcherOptionValues.push(t),this.switcherOptionsLabels.push(e.charAt(0).toUpperCase()+e.slice(1)),this.schemas.push(i)});else if("any"===t||!t){const t=e(this.schema);this.schemas=[{...t,type:"string"},{...t,type:"boolean"},{...t,type:"integer"},{...t,type:"number"},{...t,type:"array"},{...t,type:"object"},{...t,type:"null"}],this.schemas.forEach((e,t)=>{this.switcherOptionValues.push(t)}),this.switcherOptionsLabels=["String","Boolean","Integer","Number","Array","Object","Null"]}this.schemas.forEach(t=>{const s=this.jedison.createInstance({jedison:this.jedison,schema:t,path:this.path,parent:this.parent,value:e(this.value)});d(this.value)&&s.setValue(this.value,!1),s.unregister(),s.off("notifyParent"),s.on("notifyParent",e=>{this.value=this.activeInstance.getValue(),this.emit("notifyParent",e),this.emit("change",e)}),this.instances.push(s),this.register()});const s=this.getFittestIndex(this.value);this.switchInstance(s,this.value)}switchInstance(e,t,s="api"){this.index=e,this.activeInstance=this.instances[e],d(t)&&this.activeInstance.setValue(t,!1,s),this.setValue(this.activeInstance.getValue(),!0,s)}onSetValue(){if(o(this.activeInstance.getValue(),this.value)){const e=this.getFittestIndex(this.value);this.switchInstance(e,this.value)}}getFittestIndex(e){let t,s;for(let i=0;i<this.instances.length;i++){const n=this.instances[i],a=this.jedison.validator.getErrors(e,n.schema,n.getKey(),n.path);if(0===a.length){t=i;break}(void 0===t||void 0===s||a.length<s.length)&&(t=i,s=a)}return t}destroy(){this.instances.forEach(e=>{e.destroy()}),super.destroy()}}class rt extends tt{}class ot extends tt{prepare(){this.properties={},this.requiredProperties=new Set;const e=re(this.schema),t=le(this.schema);d(e)&&Object.keys(e).forEach(t=>{const s=e[t];this.properties[t]={schema:s};let i=!0;const n=this.jedison.options.deactivateNonRequired,a=se(this.schema,"deactivateNonRequired"),r=se(s,"deactivateNonRequired");!this.isRequired(t)&&d(n)&&!0===n&&(i=!1),!this.isRequired(t)&&d(a)&&!0===a&&(i=!1),!this.isRequired(t)&&d(r)&&!0===r&&(i=!1),i&&this.createChild(s,t)}),d(t)&&this.jedison.isEditor&&!0===this.jedison.options.enforceRequired&&t.forEach(e=>{this.requiredProperties.add(e),n(this.properties,e)||(this.properties[e]={},this.createChild({},e))}),this.refreshInstances(),this.on("set-value",(e,t)=>{this.addMissingRequiredPropertiesToValue(e),this.removeNotListedPropertiesFromValue(e),this.refreshInstances(t)})}removeNotListedPropertiesFromValue(e){const t=se(this.schema,"enforceAdditionalProperties"),s=d(t)?t:this.jedison.options.enforceAdditionalProperties,i=T(this.schema),a=ne(this.schema)||{};this.jedison.isEditor&&s&&d(i)&&!1===i&&Object.keys(e).forEach(t=>{const s=Object.keys(a).some(e=>new RegExp(e).test(t));n(this.properties,t)||s||(console.warn("deleting",t),delete e[t])})}addMissingRequiredPropertiesToValue(e){const t=se(this.schema,"enforceRequired")??this.jedison.options.enforceRequired;this.jedison.isEditor&&t&&this.requiredProperties.forEach(t=>{n(e,t)||(e[t]=this.getChild(t).getValue())})}isRequired(e){const t=le(this.schema),s=d(t)&&t.includes(e),i=this.isDependentRequired(e);return s||i}isDependentRequired(e){const t=D(this.schema);if(d(t)){let s=[];return Object.keys(t).forEach(e=>{if(d(this.value[e])){const i=t[e];s=i.filter(e=>!n(this.value,e))}}),s.includes(e)}return!1}createChild(t,s,i,n=!1){const a=this.jedison.createInstance({jedison:this.jedison,schema:t,path:this.path+this.jedison.pathSeparator+s,parent:this,value:e(i)});this.children.push(a),this.value[s]=a.getValue();const r=se(this.schema,"deactivateNonRequired")??this.jedison.options.deactivateNonRequired;return this.isRequired(s)||!d(r)||!0!==r||n||a.deactivate(),this.onChildChange(),a}deleteChild(e){for(let t=this.children.length-1;t>=0;t--){const s=this.children[t];s.getKey()===e&&(s.destroy(),this.children.splice(t,1),this.onChildChange())}}getChild(e){return this.children.find(t=>e===t.getKey().split(this.jedison.pathSeparator).pop())}getPropertySchema(e){let t;const s=T(this.schema),i=re(this.schema),a=ne(this.schema);return d(i)&&n(i,e)?t=i[e]:d(a)&&Object.keys(a).forEach(s=>{new RegExp(s).test(e)&&(t=a[s])}),c(t)&&d(s)&&(t=s),c(t)&&(t={}),t}onChildChange(e){const t={};this.children.forEach(e=>{if(e.isActive){const s=e.getKey();"__proto__"===s?Object.defineProperty(t,s,{value:e.getValue(),enumerable:!0}):t[s]=e.getValue()}}),this.value=t,this.jedison.emit("instance-change",this,e),this.emit("notifyParent",e),this.emit("change",e)}sortChildrenByPropertyOrder(){this.children=this.children.sort((e,t)=>{const s=se(e.schema,"propertyOrder"),i=se(t.schema,"propertyOrder"),n=h(s),a=h(i);return!n&&a?1:n&&!a||s<i?-1:s>i?1:0})}refreshInstances(e){const t=this.getValue();if(f(t)){Object.keys(t).forEach(s=>{const i=this.getChild(s);if(i){i.activate();const s=i.getValue(),n=t[i.getKey()];if(o(s,n)){const s=i.setValue(n,!1,e);t[i.getKey()]=s}}else{const e=this.getPropertySchema(s);this.createChild(e,s,t[s],!0)}});for(let e=this.children.length-1;e>=0;e--){const s=this.children[e],i=s.getKey();c(t[i])&&(this.getChild(i)?s.deactivate():this.deleteChild(i))}this.sortChildrenByPropertyOrder(),this.value=t}}}class lt extends tt{prepare(){const e=Q(this.schema),t=se(this.schema,"enforceMinItems"),s=d(t)?t:this.jedison.options.enforceMinItems,i=this.jedison.isEditor,n=d(s)&&!0===s,a=d(e);if(i&&n&&a)for(let r=0;r<e;r++)this.addItem();this.refreshChildren(),this.on("set-value",()=>{this.refreshChildren()})}createItemInstance(e){let t;const s=this.children.length,i=z(this.schema),n=ae(this.schema);t=d(i)?i:{};return d(n)&&d(n[s])&&(t=n[s]),this.jedison.createInstance({jedison:this.jedison,schema:t,path:this.path+this.jedison.pathSeparator+s,parent:this,arrayTemplateData:{i0:e,i1:e+1}})}setDefaultValue(){const e=O(this.schema);d(e)&&this.setValue(e)}move(t,s,i){const n=e(this.getValue()),a=n[t];n.splice(t,1),n.splice(s,0,a),this.setValue(n,!0,i),this.emit("item-move",i),this.jedison.emit("item-move",i)}addItem(t){const s=this.createItemInstance(),i=e(this.getValue());i.push(s.getValue()),s.destroy(),this.setValue(i,!0,t);const n=this.children[this.children.length-1];this.emit("item-add",t,n),this.jedison.emit("item-add",t,n)}deleteItem(t,s){const i=e(this.getValue()).filter((e,s)=>s!==t);this.setValue(i,!0,s),this.emit("item-delete",s),this.jedison.emit("item-delete",s)}onChildChange(e){const t=[];this.children.forEach(e=>{t.push(e.getValue())}),this.value=t,this.jedison.emit("instance-change",this,e),this.emit("notifyParent",e),this.emit("change",e)}refreshChildren(){this.children=[];const e=this.getValue();if(!g(e))return;const t=[];e.forEach((e,s)=>{const i=this.createItemInstance(s);this.children.push(i);const n=i.setValue(e,!1);t.push(n)}),this.value=t}}class dt extends tt{}class ct extends tt{}class ht extends tt{}const ut={properties:"glyphicon glyphicon-list",delete:"glyphicon glyphicon-trash",add:"glyphicon glyphicon-plus",moveUp:"glyphicon glyphicon-arrow-up",moveDown:"glyphicon glyphicon-arrow-down",collapse:"glyphicon glyphicon-chevron-down",expand:"glyphicon glyphicon-plus",drag:"glyphicon glyphicon-th",info:"glyphicon glyphicon-question-sign",close:"glyphicon glyphicon-remove"},pt={properties:"bi bi-card-list",delete:"bi bi-trash2",add:"bi bi-plus",moveUp:"bi bi-arrow-up",moveDown:"bi bi-arrow-down",collapse:"bi bi-chevron-down",expand:"bi bi-plus",drag:"bi bi-grip-vertical",info:"bi bi-question-circle",close:"bi bi-x"},mt={properties:"icon-list",delete:"icon-trash",add:"icon-plus",moveUp:"icon-arrow-up",moveDown:"icon-arrow-down",collapse:"icon-chevron-down",expand:"icon-plus",drag:"icon-th",info:"icon-question-sign",close:"icon-remove"},gt={properties:"fa fa-list",delete:"fa fa-trash-o",add:"fa fa-plus",moveUp:"fa fa-arrow-up",moveDown:"fa fa-arrow-down",collapse:"fa fa-chevron-down",expand:"fa fa-plus",drag:"fa fa-th",info:"fa fa-question-circle",close:"fa fa-times"},ft={properties:"fas fa-list",delete:"fas fa-trash",add:"fas fa-plus",moveUp:"fas fa-arrow-up",moveDown:"fas fa-arrow-down",collapse:"fas fa-chevron-down",expand:"fas fa-plus",drag:"fas fa-grip-vertical",info:"fas fa-question-circle",close:"fas fa-times"},bt={properties:"fa-solid fa-list",delete:"fa-solid fa-trash",add:"fa-solid fa-plus",moveUp:"fa-solid fa-arrow-up",moveDown:"fa-solid fa-arrow-down",collapse:"fa-solid fa-chevron-down",expand:"fa-solid fa-plus",drag:"fa-solid fa-grip-vertical",info:"fa-solid fa-circle-question",close:"fa-solid fa-xmark"};class vt extends st{sanitize(e){return Boolean(e)}}class yt extends vt{static resolves(e){return"boolean"===he(e)&&("radios"===se(e,"format")||"radios-inline"===se(e,"format"))}build(){this.control=this.theme.getRadiosControl({title:this.getTitle(),description:this.getDescription(),values:["false","true"],titles:se(this.instance.schema,"enumTitles")||["false","true"],id:this.getIdFromPath(this.instance.path),titleHidden:se(this.instance.schema,"titleHidden"),inline:"radios-inline"===se(this.instance.schema,"format"),info:this.getInfo()})}adaptForTable(){this.theme.adaptForTableRadiosControl(this.control)}addEventListeners(){this.control.radios.forEach(e=>{e.addEventListener("change",()=>{const t="true"===e.value;this.instance.setValue(t,!0,"user")})})}refreshUI(){this.refreshDisabledState(),this.control.radios.forEach(e=>{const t="true"===e.value;e.checked=t===this.instance.getValue()})}}class Ct extends vt{static resolves(e){return"boolean"===he(e)}build(){this.control=this.theme.getSelectControl({title:this.getTitle(),description:this.getDescription(),values:["false","true"],titles:se(this.instance.schema,"enumTitles")||["false","true"],id:this.getIdFromPath(this.instance.path),titleIconClass:se(this.instance.schema,"titleIconClass"),titleHidden:se(this.instance.schema,"titleHidden"),info:this.getInfo()})}adaptForTable(){this.theme.adaptForTableSelectControl(this.control)}addEventListeners(){this.control.input.addEventListener("change",()=>{const e="true"===this.control.input.value;this.instance.setValue(e,!0,"user")})}refreshUI(){this.refreshDisabledState(),this.control.input.value=!0===this.instance.getValue()?"true":"false"}}class Lt extends vt{static resolves(e){return"boolean"===he(e)&&"checkbox"===se(e,"format")}build(){this.control=this.theme.getCheckboxControl({title:this.getTitle(),description:this.getDescription(),id:this.getIdFromPath(this.instance.path),titleHidden:se(this.instance.schema,"titleHidden"),info:this.getInfo()})}adaptForTable(e){this.theme.adaptForTableCheckboxControl(this.control,e)}addEventListeners(){this.control.input.addEventListener("change",()=>{this.instance.setValue(this.control.input.checked,!0,"user")})}sanitize(e){return Boolean(e)}refreshUI(){this.refreshDisabledState(),this.control.input.checked=this.instance.getValue()}}class Et extends st{sanitize(e){return String(e)}}class xt extends Et{static resolves(e){return"string"===he(e)&&("radios"===se(e,"format")||"radios-inline"===se(e,"format"))}build(){this.control=this.theme.getRadiosControl({title:this.getTitle(),description:this.getDescription(),values:R(this.instance.schema),titles:se(this.instance.schema,"enumTitles")||R(this.instance.schema),id:this.getIdFromPath(this.instance.path),titleHidden:se(this.instance.schema,"titleHidden"),inline:"radios-inline"===se(this.instance.schema,"format"),info:this.getInfo()})}adaptForTable(){this.theme.adaptForTableRadiosControl(this.control)}addEventListeners(){this.control.radios.forEach(e=>{e.addEventListener("change",()=>{this.instance.setValue(e.value,!0,"user")})})}refreshUI(){this.refreshDisabledState(),this.control.radios.forEach(e=>{e.checked=e.value===this.instance.getValue()})}}class It extends Et{static resolves(e){return"string"===he(e)&&d(R(e))}build(){this.control=this.theme.getSelectControl({title:this.getTitle(),description:this.getDescription(),values:R(this.instance.schema),titles:se(this.instance.schema,"enumTitles")||R(this.instance.schema),id:this.getIdFromPath(this.instance.path),titleIconClass:se(this.instance.schema,"titleIconClass"),titleHidden:se(this.instance.schema,"titleHidden"),info:this.getInfo()})}adaptForTable(){this.theme.adaptForTableSelectControl(this.control)}addEventListeners(){this.control.input.addEventListener("change",()=>{this.instance.setValue(this.control.input.value,!0,"user")})}refreshUI(){this.refreshDisabledState(),this.control.input.value=this.instance.getValue()}}class wt extends Et{static resolves(e){return"string"===he(e)&&"textarea"===se(e,"format")}build(){this.control=this.theme.getTextareaControl({title:this.getTitle(),description:this.getDescription(),id:this.getIdFromPath(this.instance.path),titleIconClass:se(this.instance.schema,"titleIconClass"),titleHidden:se(this.instance.schema,"titleHidden"),info:this.getInfo()})}adaptForTable(){this.theme.adaptForTableTextareaControl(this.control)}addEventListeners(){const e=this.getValidationEventType();this.control.input.addEventListener(e,()=>{this.instance.setValue(this.control.input.value,!0,"user")})}refreshUI(){this.refreshDisabledState(),this.control.input.value=this.instance.getValue()}}class At extends Et{static resolves(e){const t=se(e,"format");return d(t)&&"awesomplete"===t&&window.Awesomplete&&"string"===he(e)}build(){this.control=this.theme.getInputControl({title:this.getTitle(),description:this.getDescription(),type:"text",id:this.getIdFromPath(this.instance.path),titleIconClass:se(this.instance.schema,"titleIconClass"),titleHidden:se(this.instance.schema,"titleHidden"),info:this.getInfo()});try{const e=se(this.instance.schema,"awesomplete")??{};this.awesomplete=new window.Awesomplete(this.control.input,e),this.control.container.querySelector(".awesomplete").style.display="block"}catch(e){console.error("Awesomplete is not available or not loaded correctly.",e)}}addEventListeners(){this.control.input.addEventListener("awesomplete-selectcomplete",()=>{this.instance.setValue(this.control.input.value,!0,"user")})}refreshUI(){this.refreshDisabledState(),this.control.input.value=this.instance.getValue()}destroy(){this.awesomplete.destroy(),super.destroy()}}class Tt extends Et{static resolves(e){const t=se(e,"format");return d(t)&&"emojiButton"===t&&window.EmojiButton&&"string"===he(e)}build(){this.control=this.theme.getInputControl({type:"button",title:this.getTitle(),description:this.getDescription(),id:this.getIdFromPath(this.instance.path),titleIconClass:se(this.instance.schema,"titleIconClass"),titleHidden:se(this.instance.schema,"titleHidden"),info:this.getInfo()}),this.control.input.classList.add("jedi-emoji-button"),this.control.input.value="😀";const e=se(this.instance.schema,"emojiButton")??{},t=Object.assign({theme:"auto",autoHide:!0,showPreview:!1,showSearch:!0,zIndex:1e4,position:"auto"},e);this.emojiButton=new window.EmojiButton(t)}addEventListeners(){this.emojiButton.on("emoji",e=>{this.control.input.value=e;let t=e;"object"==typeof e&&(t=e.emoji),this.instance.setValue(t,!0,"user")}),this.control.input.addEventListener("click",()=>{this.emojiButton.togglePicker(this.control.input)})}refreshUI(){this.refreshDisabledState(),this.control.input.value=this.instance.getValue()}destroy(){this.emojiButton&&(this.emojiButton=null),super.destroy()}}class Mt extends Et{static resolves(e){return"string"===he(e)}static getTypes(){return["hidden","color","date","datetime-local","email","number","month","password","search","time","tel","text","url","week"]}build(){const e=se(this.instance.schema,"format");this.control=this.theme.getInputControl({title:this.getTitle(),description:this.getDescription(),type:Mt.getTypes().includes(e)?e:"text",id:this.getIdFromPath(this.instance.path),titleIconClass:se(this.instance.schema,"titleIconClass"),titleHidden:se(this.instance.schema,"titleHidden")||"hidden"===e,info:this.getInfo()}),"color"===e&&0===this.instance.value.length&&this.instance.setValue("#000000",!1,"user")}adaptForTable(){this.theme.adapt