| 1 |
(function(_elementor_schema) { |
| 2 |
|
| 3 |
//#region \0rolldown/runtime.js |
| 4 |
var __defProp = Object.defineProperty; |
| 5 |
var __name = (target, value) => __defProp(target, "name", { |
| 6 |
value, |
| 7 |
configurable: true |
| 8 |
}); |
| 9 |
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports); |
| 10 |
var __exportAll = (all, no_symbols) => { |
| 11 |
let target = {}; |
| 12 |
for (var name in all) { |
| 13 |
__defProp(target, name, { |
| 14 |
get: all[name], |
| 15 |
enumerable: true |
| 16 |
}); |
| 17 |
} |
| 18 |
if (!no_symbols) { |
| 19 |
__defProp(target, Symbol.toStringTag, { value: "Module" }); |
| 20 |
} |
| 21 |
return target; |
| 22 |
}; |
| 23 |
|
| 24 |
//#endregion |
| 25 |
|
| 26 |
//#region packages/packages/libs/editor-props/src/utils/create-prop-utils.ts |
| 27 |
var SCHEMA_CACHE = /* @__PURE__ */ new Map(); |
| 28 |
function getPropSchemaFromCache(key) { |
| 29 |
return SCHEMA_CACHE.get(key); |
| 30 |
} |
| 31 |
function createPropUtils(key, valueSchema) { |
| 32 |
const schema = _elementor_schema.z.strictObject({ |
| 33 |
$$type: _elementor_schema.z.literal(key), |
| 34 |
value: valueSchema, |
| 35 |
disabled: _elementor_schema.z.boolean().optional() |
| 36 |
}); |
| 37 |
function isValid(prop) { |
| 38 |
return schema.safeParse(prop).success; |
| 39 |
} |
| 40 |
function create(value, createOptions) { |
| 41 |
const fn = typeof value === "function" ? value : () => value; |
| 42 |
const { base, disabled } = createOptions || {}; |
| 43 |
if (!base) return { |
| 44 |
$$type: key, |
| 45 |
value: fn(), |
| 46 |
...disabled && { disabled } |
| 47 |
}; |
| 48 |
if (!isValid(base)) throw new Error(`Cannot create prop based on invalid value: ${JSON.stringify(base)}`); |
| 49 |
return { |
| 50 |
$$type: key, |
| 51 |
value: fn(base.value), |
| 52 |
...disabled && { disabled } |
| 53 |
}; |
| 54 |
} |
| 55 |
function extract(prop) { |
| 56 |
if (!isValid(prop)) return null; |
| 57 |
return prop.value; |
| 58 |
} |
| 59 |
const propUtil = { |
| 60 |
extract, |
| 61 |
isValid, |
| 62 |
create, |
| 63 |
schema, |
| 64 |
key |
| 65 |
}; |
| 66 |
SCHEMA_CACHE.set(key, propUtil); |
| 67 |
return propUtil; |
| 68 |
} |
| 69 |
function createArrayPropUtils(key, valueSchema, overrideKey) { |
| 70 |
return createPropUtils(overrideKey || `${key}-array`, _elementor_schema.z.array(valueSchema)); |
| 71 |
} |
| 72 |
|
| 73 |
//#endregion |
| 74 |
//#region packages/packages/libs/editor-props/src/prop-types/utils.ts |
| 75 |
var unknownChildrenSchema = _elementor_schema.z.any().nullable(); |
| 76 |
|
| 77 |
//#endregion |
| 78 |
//#region packages/packages/libs/editor-props/src/prop-types/shadow.ts |
| 79 |
var shadowPropTypeUtil = createPropUtils("shadow", _elementor_schema.z.strictObject({ |
| 80 |
position: unknownChildrenSchema, |
| 81 |
hOffset: unknownChildrenSchema, |
| 82 |
vOffset: unknownChildrenSchema, |
| 83 |
blur: unknownChildrenSchema, |
| 84 |
spread: unknownChildrenSchema, |
| 85 |
color: unknownChildrenSchema |
| 86 |
})); |
| 87 |
|
| 88 |
//#endregion |
| 89 |
//#region packages/packages/libs/editor-props/src/prop-types/box-shadow.ts |
| 90 |
var boxShadowPropTypeUtil = createPropUtils("box-shadow", _elementor_schema.z.array(shadowPropTypeUtil.schema)); |
| 91 |
|
| 92 |
//#endregion |
| 93 |
//#region packages/packages/libs/editor-props/src/prop-types/border-radius.ts |
| 94 |
var borderRadiusPropTypeUtil = createPropUtils("border-radius-v2", _elementor_schema.z.strictObject({ |
| 95 |
"start-start": unknownChildrenSchema, |
| 96 |
"start-end": unknownChildrenSchema, |
| 97 |
"end-start": unknownChildrenSchema, |
| 98 |
"end-end": unknownChildrenSchema |
| 99 |
})); |
| 100 |
|
| 101 |
//#endregion |
| 102 |
//#region packages/packages/libs/editor-props/src/prop-types/border-width.ts |
| 103 |
var borderWidthPropTypeUtil = createPropUtils("border-width-v2", _elementor_schema.z.strictObject({ |
| 104 |
"block-start": unknownChildrenSchema, |
| 105 |
"block-end": unknownChildrenSchema, |
| 106 |
"inline-start": unknownChildrenSchema, |
| 107 |
"inline-end": unknownChildrenSchema |
| 108 |
})); |
| 109 |
|
| 110 |
//#endregion |
| 111 |
//#region packages/packages/libs/editor-props/src/prop-types/classes.ts |
| 112 |
var CLASSES_PROP_KEY = "classes"; |
| 113 |
var classesPropTypeUtil = createPropUtils(CLASSES_PROP_KEY, _elementor_schema.z.array(_elementor_schema.z.string().regex(/^[a-z][a-z-_0-9]*$/i))); |
| 114 |
|
| 115 |
//#endregion |
| 116 |
//#region packages/packages/libs/editor-props/src/prop-types/color.ts |
| 117 |
var colorPropTypeUtil = createPropUtils("color", _elementor_schema.z.string()); |
| 118 |
|
| 119 |
//#endregion |
| 120 |
//#region packages/packages/libs/editor-props/src/prop-types/flex.ts |
| 121 |
var flexPropTypeUtil = createPropUtils("flex", _elementor_schema.z.strictObject({ |
| 122 |
flexGrow: unknownChildrenSchema, |
| 123 |
flexShrink: unknownChildrenSchema, |
| 124 |
flexBasis: unknownChildrenSchema |
| 125 |
})); |
| 126 |
|
| 127 |
//#endregion |
| 128 |
//#region packages/packages/libs/editor-props/src/prop-types/font-family.ts |
| 129 |
var baseUtil = createPropUtils("font-family", _elementor_schema.z.string().nullable()); |
| 130 |
var fontFamilyPropTypeUtil = Object.assign(baseUtil, { getEnqueueFontFamily: (value) => { |
| 131 |
const trimmed = value.trim(); |
| 132 |
if (trimmed.startsWith("\"") && trimmed.endsWith("\"") || trimmed.startsWith("'") && trimmed.endsWith("'")) return trimmed.slice(1, -1).trim(); |
| 133 |
return trimmed; |
| 134 |
} }); |
| 135 |
|
| 136 |
//#endregion |
| 137 |
//#region packages/packages/libs/editor-props/src/prop-types/image.ts |
| 138 |
var imagePropTypeUtil = createPropUtils("image", _elementor_schema.z.strictObject({ |
| 139 |
src: unknownChildrenSchema, |
| 140 |
size: unknownChildrenSchema |
| 141 |
})); |
| 142 |
|
| 143 |
//#endregion |
| 144 |
//#region packages/packages/libs/editor-props/src/prop-types/image-attachment-id.ts |
| 145 |
var imageAttachmentIdPropType = createPropUtils("image-attachment-id", _elementor_schema.z.number()); |
| 146 |
|
| 147 |
//#endregion |
| 148 |
//#region packages/packages/libs/editor-props/src/prop-types/image-src.ts |
| 149 |
var imageSrcPropTypeUtil = createPropUtils("image-src", _elementor_schema.z.strictObject({ |
| 150 |
id: unknownChildrenSchema, |
| 151 |
url: _elementor_schema.z.null(), |
| 152 |
alt: unknownChildrenSchema.optional().default(null) |
| 153 |
}).or(_elementor_schema.z.strictObject({ |
| 154 |
id: unknownChildrenSchema.optional().default(null), |
| 155 |
url: unknownChildrenSchema, |
| 156 |
alt: unknownChildrenSchema.optional().default(null) |
| 157 |
}))); |
| 158 |
|
| 159 |
//#endregion |
| 160 |
//#region packages/packages/libs/editor-props/src/prop-types/icon.ts |
| 161 |
var iconPropTypeUtil = createPropUtils("icon", _elementor_schema.z.strictObject({ |
| 162 |
value: unknownChildrenSchema, |
| 163 |
library: unknownChildrenSchema |
| 164 |
})); |
| 165 |
|
| 166 |
//#endregion |
| 167 |
//#region packages/packages/libs/editor-props/src/prop-types/svg-src.ts |
| 168 |
var svgSrcValueSchema = _elementor_schema.z.strictObject({ |
| 169 |
id: unknownChildrenSchema, |
| 170 |
url: _elementor_schema.z.null() |
| 171 |
}).or(_elementor_schema.z.strictObject({ |
| 172 |
id: _elementor_schema.z.null(), |
| 173 |
url: unknownChildrenSchema |
| 174 |
})).or(_elementor_schema.z.strictObject({ |
| 175 |
id: unknownChildrenSchema, |
| 176 |
url: unknownChildrenSchema |
| 177 |
})); |
| 178 |
var svgSrcPropTypeUtil = createPropUtils("svg-src", svgSrcValueSchema); |
| 179 |
|
| 180 |
//#endregion |
| 181 |
//#region packages/packages/libs/editor-props/src/prop-types/video-attachment-id.ts |
| 182 |
var videoAttachmentIdPropType = createPropUtils("video-attachment-id", _elementor_schema.z.number()); |
| 183 |
|
| 184 |
//#endregion |
| 185 |
//#region packages/packages/libs/editor-props/src/prop-types/video-src.ts |
| 186 |
var videoSrcPropTypeUtil = createPropUtils("video-src", _elementor_schema.z.strictObject({ |
| 187 |
id: unknownChildrenSchema, |
| 188 |
url: _elementor_schema.z.literal(null).optional() |
| 189 |
}).or(_elementor_schema.z.strictObject({ |
| 190 |
id: _elementor_schema.z.literal(null).optional(), |
| 191 |
url: unknownChildrenSchema |
| 192 |
}))); |
| 193 |
|
| 194 |
//#endregion |
| 195 |
//#region packages/packages/libs/editor-props/src/prop-types/dimensions.ts |
| 196 |
var dimensionsPropTypeUtil = createPropUtils("dimensions", _elementor_schema.z.strictObject({ |
| 197 |
"block-start": unknownChildrenSchema, |
| 198 |
"block-end": unknownChildrenSchema, |
| 199 |
"inline-start": unknownChildrenSchema, |
| 200 |
"inline-end": unknownChildrenSchema |
| 201 |
})); |
| 202 |
|
| 203 |
//#endregion |
| 204 |
//#region packages/packages/libs/editor-props/src/prop-types/number.ts |
| 205 |
var numberPropTypeUtil = createPropUtils("number", _elementor_schema.z.number().nullable()); |
| 206 |
|
| 207 |
//#endregion |
| 208 |
//#region packages/packages/libs/editor-props/src/prop-types/size.ts |
| 209 |
var sizeNumberOrEmpty = _elementor_schema.z.union([_elementor_schema.z.number(), _elementor_schema.z.literal("")]); |
| 210 |
var sizePropTypeUtil = createPropUtils("size", _elementor_schema.z.strictObject({ |
| 211 |
unit: _elementor_schema.z.enum([ |
| 212 |
"px", |
| 213 |
"em", |
| 214 |
"rem", |
| 215 |
"%", |
| 216 |
"vw", |
| 217 |
"vh", |
| 218 |
"ch", |
| 219 |
"fr" |
| 220 |
]), |
| 221 |
size: sizeNumberOrEmpty |
| 222 |
}).or(_elementor_schema.z.strictObject({ |
| 223 |
unit: _elementor_schema.z.enum([ |
| 224 |
"deg", |
| 225 |
"rad", |
| 226 |
"grad", |
| 227 |
"turn" |
| 228 |
]), |
| 229 |
size: sizeNumberOrEmpty |
| 230 |
})).or(_elementor_schema.z.strictObject({ |
| 231 |
unit: _elementor_schema.z.enum(["s", "ms"]), |
| 232 |
size: sizeNumberOrEmpty |
| 233 |
})).or(_elementor_schema.z.strictObject({ |
| 234 |
unit: _elementor_schema.z.literal("auto"), |
| 235 |
size: _elementor_schema.z.literal("") |
| 236 |
})).or(_elementor_schema.z.strictObject({ |
| 237 |
unit: _elementor_schema.z.literal("custom"), |
| 238 |
size: _elementor_schema.z.string() |
| 239 |
}))); |
| 240 |
|
| 241 |
//#endregion |
| 242 |
//#region packages/packages/libs/editor-props/src/prop-types/grid-track-size.ts |
| 243 |
var gridTrackSizePropTypeUtil = createPropUtils("grid-track-size", _elementor_schema.z.strictObject({ |
| 244 |
unit: _elementor_schema.z.literal("fr"), |
| 245 |
size: _elementor_schema.z.union([_elementor_schema.z.number(), _elementor_schema.z.literal("")]) |
| 246 |
}).or(_elementor_schema.z.strictObject({ |
| 247 |
unit: _elementor_schema.z.literal("custom"), |
| 248 |
size: _elementor_schema.z.string() |
| 249 |
}))); |
| 250 |
|
| 251 |
//#endregion |
| 252 |
//#region packages/packages/libs/editor-props/src/prop-types/span.ts |
| 253 |
var spanPropTypeUtil = createPropUtils("span", _elementor_schema.z.string().nullable()); |
| 254 |
|
| 255 |
//#endregion |
| 256 |
//#region packages/packages/libs/editor-props/src/prop-types/string.ts |
| 257 |
var stringPropTypeUtil = createPropUtils("string", _elementor_schema.z.string().nullable()); |
| 258 |
|
| 259 |
//#endregion |
| 260 |
//#region packages/packages/libs/editor-props/src/prop-types/string-array.ts |
| 261 |
var stringArrayPropTypeUtil = createArrayPropUtils(stringPropTypeUtil.key, stringPropTypeUtil.schema); |
| 262 |
|
| 263 |
//#endregion |
| 264 |
//#region packages/packages/libs/editor-props/src/prop-types/stroke.ts |
| 265 |
var strokePropTypeUtil = createPropUtils("stroke", _elementor_schema.z.strictObject({ |
| 266 |
color: unknownChildrenSchema, |
| 267 |
width: unknownChildrenSchema |
| 268 |
})); |
| 269 |
|
| 270 |
//#endregion |
| 271 |
//#region packages/packages/libs/editor-props/src/prop-types/url.ts |
| 272 |
var urlPropTypeUtil = createPropUtils("url", _elementor_schema.z.string().nullable()); |
| 273 |
|
| 274 |
//#endregion |
| 275 |
//#region packages/packages/libs/editor-props/src/prop-types/layout-direction.ts |
| 276 |
var layoutDirectionPropTypeUtil = createPropUtils("layout-direction", _elementor_schema.z.object({ |
| 277 |
row: _elementor_schema.z.any(), |
| 278 |
column: _elementor_schema.z.any() |
| 279 |
})); |
| 280 |
|
| 281 |
//#endregion |
| 282 |
//#region packages/packages/libs/editor-props/src/prop-types/link.ts |
| 283 |
var linkPropTypeUtil = createPropUtils("link", _elementor_schema.z.strictObject({ |
| 284 |
destination: unknownChildrenSchema, |
| 285 |
isTargetBlank: unknownChildrenSchema, |
| 286 |
tag: unknownChildrenSchema |
| 287 |
})); |
| 288 |
|
| 289 |
//#endregion |
| 290 |
//#region packages/packages/libs/editor-props/src/prop-types/email.ts |
| 291 |
var emailPropTypeUtil = createPropUtils("email", _elementor_schema.z.strictObject({ |
| 292 |
to: unknownChildrenSchema, |
| 293 |
subject: unknownChildrenSchema, |
| 294 |
message: unknownChildrenSchema, |
| 295 |
from: unknownChildrenSchema, |
| 296 |
"meta-data": unknownChildrenSchema, |
| 297 |
"send-as": unknownChildrenSchema, |
| 298 |
"from-name": unknownChildrenSchema, |
| 299 |
"reply-to": unknownChildrenSchema, |
| 300 |
cc: unknownChildrenSchema, |
| 301 |
bcc: unknownChildrenSchema |
| 302 |
})); |
| 303 |
|
| 304 |
//#endregion |
| 305 |
//#region packages/packages/libs/editor-props/src/prop-types/emails.ts |
| 306 |
var emailsPropTypeUtil = createPropUtils("emails", _elementor_schema.z.strictObject({ |
| 307 |
to: unknownChildrenSchema, |
| 308 |
subject: unknownChildrenSchema, |
| 309 |
message: unknownChildrenSchema, |
| 310 |
from: unknownChildrenSchema, |
| 311 |
"meta-data": unknownChildrenSchema, |
| 312 |
"send-as": unknownChildrenSchema, |
| 313 |
"from-name": unknownChildrenSchema, |
| 314 |
"reply-to": unknownChildrenSchema, |
| 315 |
cc: unknownChildrenSchema, |
| 316 |
bcc: unknownChildrenSchema |
| 317 |
})); |
| 318 |
|
| 319 |
//#endregion |
| 320 |
//#region packages/packages/libs/editor-props/src/prop-types/key-value.ts |
| 321 |
var keyValuePropTypeUtil = createPropUtils("key-value", _elementor_schema.z.strictObject({ |
| 322 |
key: unknownChildrenSchema, |
| 323 |
value: unknownChildrenSchema |
| 324 |
})); |
| 325 |
|
| 326 |
//#endregion |
| 327 |
//#region packages/packages/libs/editor-props/src/prop-types/selection-size.ts |
| 328 |
var selectionSizePropTypeUtil = createPropUtils("selection-size", _elementor_schema.z.strictObject({ |
| 329 |
selection: _elementor_schema.z.union([keyValuePropTypeUtil.schema, stringPropTypeUtil.schema]), |
| 330 |
size: unknownChildrenSchema |
| 331 |
})); |
| 332 |
|
| 333 |
//#endregion |
| 334 |
//#region packages/packages/libs/editor-props/src/prop-types/background-prop-types/background.ts |
| 335 |
var backgroundPropTypeUtil = createPropUtils("background", _elementor_schema.z.strictObject({ |
| 336 |
color: unknownChildrenSchema, |
| 337 |
clip: unknownChildrenSchema, |
| 338 |
"background-overlay": unknownChildrenSchema |
| 339 |
})); |
| 340 |
|
| 341 |
//#endregion |
| 342 |
//#region packages/packages/libs/editor-props/src/prop-types/background-prop-types/background-color-overlay.ts |
| 343 |
var backgroundColorOverlayPropTypeUtil = createPropUtils("background-color-overlay", unknownChildrenSchema); |
| 344 |
|
| 345 |
//#endregion |
| 346 |
//#region packages/packages/libs/editor-props/src/prop-types/background-prop-types/background-gradient-overlay.ts |
| 347 |
var backgroundGradientOverlayPropTypeUtil = createPropUtils("background-gradient-overlay", unknownChildrenSchema); |
| 348 |
|
| 349 |
//#endregion |
| 350 |
//#region packages/packages/libs/editor-props/src/prop-types/background-prop-types/background-image-overlay.ts |
| 351 |
var backgroundImageOverlayPropTypeUtil = createPropUtils("background-image-overlay", unknownChildrenSchema); |
| 352 |
|
| 353 |
//#endregion |
| 354 |
//#region packages/packages/libs/editor-props/src/prop-types/background-prop-types/background-overlay.ts |
| 355 |
var backgroundOverlayItem = backgroundColorOverlayPropTypeUtil.schema.or(backgroundGradientOverlayPropTypeUtil.schema).or(backgroundImageOverlayPropTypeUtil.schema); |
| 356 |
var backgroundOverlayPropTypeUtil = createPropUtils("background-overlay", _elementor_schema.z.array(backgroundOverlayItem)); |
| 357 |
|
| 358 |
//#endregion |
| 359 |
//#region packages/packages/libs/editor-props/src/prop-types/background-prop-types/background-image-position-offset.ts |
| 360 |
var backgroundImagePositionOffsetPropTypeUtil = createPropUtils("background-image-position-offset", unknownChildrenSchema); |
| 361 |
|
| 362 |
//#endregion |
| 363 |
//#region packages/packages/libs/editor-props/src/prop-types/background-prop-types/background-image-size-scale.ts |
| 364 |
var backgroundImageSizeScalePropTypeUtil = createPropUtils("background-image-size-scale", unknownChildrenSchema); |
| 365 |
|
| 366 |
//#endregion |
| 367 |
//#region packages/packages/libs/editor-props/src/prop-types/boolean.ts |
| 368 |
var booleanPropTypeUtil = createPropUtils("boolean", _elementor_schema.z.boolean().nullable()); |
| 369 |
|
| 370 |
//#endregion |
| 371 |
//#region packages/packages/libs/editor-props/src/prop-types/color-stop.ts |
| 372 |
var colorStopPropTypeUtil = createPropUtils("color-stop", _elementor_schema.z.strictObject({ |
| 373 |
color: unknownChildrenSchema, |
| 374 |
offset: unknownChildrenSchema |
| 375 |
})); |
| 376 |
|
| 377 |
//#endregion |
| 378 |
//#region packages/packages/libs/editor-props/src/prop-types/gradient-color-stop.ts |
| 379 |
var gradientColorStopPropTypeUtil = createPropUtils("gradient-color-stop", _elementor_schema.z.array(colorStopPropTypeUtil.schema)); |
| 380 |
|
| 381 |
//#endregion |
| 382 |
//#region packages/packages/libs/editor-props/src/prop-types/number-range.ts |
| 383 |
var numberRangePropTypeUtil = createPropUtils("number-range", _elementor_schema.z.strictObject({ |
| 384 |
min: unknownChildrenSchema, |
| 385 |
max: unknownChildrenSchema |
| 386 |
})); |
| 387 |
|
| 388 |
//#endregion |
| 389 |
//#region packages/packages/libs/editor-props/src/prop-types/date-time.ts |
| 390 |
var DateTimePropTypeUtil = createPropUtils("date-time", _elementor_schema.z.strictObject({ |
| 391 |
date: unknownChildrenSchema, |
| 392 |
time: unknownChildrenSchema |
| 393 |
})); |
| 394 |
|
| 395 |
//#endregion |
| 396 |
//#region packages/packages/libs/editor-props/src/prop-types/position.ts |
| 397 |
var positionPropTypeUtil = createPropUtils("object-position", _elementor_schema.z.strictObject({ |
| 398 |
x: unknownChildrenSchema, |
| 399 |
y: unknownChildrenSchema |
| 400 |
})); |
| 401 |
|
| 402 |
//#endregion |
| 403 |
//#region packages/packages/libs/editor-props/src/prop-types/query.ts |
| 404 |
var queryPropTypeUtil = createPropUtils("query", _elementor_schema.z.strictObject({ |
| 405 |
id: unknownChildrenSchema, |
| 406 |
label: unknownChildrenSchema |
| 407 |
})); |
| 408 |
|
| 409 |
//#endregion |
| 410 |
//#region packages/packages/libs/editor-props/src/prop-types/query-filter.ts |
| 411 |
var queryFilterPropTypeUtil = createPropUtils("query-filter", _elementor_schema.z.strictObject({ |
| 412 |
key: unknownChildrenSchema, |
| 413 |
values: unknownChildrenSchema, |
| 414 |
taxonomies: unknownChildrenSchema |
| 415 |
})); |
| 416 |
var queryFilterArrayPropTypeUtil = createArrayPropUtils(queryFilterPropTypeUtil.key, queryFilterPropTypeUtil.schema); |
| 417 |
|
| 418 |
//#endregion |
| 419 |
//#region packages/packages/libs/editor-props/src/prop-types/html.ts |
| 420 |
var htmlPropTypeUtil = createPropUtils("html", _elementor_schema.z.string().nullable()); |
| 421 |
|
| 422 |
//#endregion |
| 423 |
//#region packages/packages/libs/editor-props/src/prop-types/html-v2.ts |
| 424 |
var childElementSchema = _elementor_schema.z.lazy(() => _elementor_schema.z.object({ |
| 425 |
id: _elementor_schema.z.string(), |
| 426 |
type: _elementor_schema.z.string(), |
| 427 |
content: _elementor_schema.z.string().optional(), |
| 428 |
children: _elementor_schema.z.array(childElementSchema).optional() |
| 429 |
})); |
| 430 |
var htmlV2ValueSchema = _elementor_schema.z.object({ |
| 431 |
content: _elementor_schema.z.string().nullable(), |
| 432 |
children: _elementor_schema.z.array(childElementSchema) |
| 433 |
}); |
| 434 |
var htmlV2PropTypeUtil = createPropUtils("html-v2", htmlV2ValueSchema); |
| 435 |
|
| 436 |
//#endregion |
| 437 |
//#region packages/packages/libs/editor-props/src/prop-types/html-v3.ts |
| 438 |
var htmlV3ValueSchema = _elementor_schema.z.object({ |
| 439 |
content: stringPropTypeUtil.schema.nullable(), |
| 440 |
children: _elementor_schema.z.array(_elementor_schema.z.unknown()) |
| 441 |
}); |
| 442 |
var htmlV3PropTypeUtil = createPropUtils("html-v3", htmlV3ValueSchema); |
| 443 |
|
| 444 |
//#endregion |
| 445 |
//#region packages/packages/libs/editor-props/src/prop-types/escaped-html.ts |
| 446 |
var escapedHtmlPropTypeUtil = createPropUtils("escaped-html", _elementor_schema.z.string().nullable()); |
| 447 |
|
| 448 |
//#endregion |
| 449 |
//#region packages/packages/libs/editor-props/src/prop-types/filter-prop-types/drop-shadow-filter.ts |
| 450 |
var dropShadowFilterPropTypeUtil = createPropUtils("drop-shadow", _elementor_schema.z.object({ |
| 451 |
xAxis: unknownChildrenSchema, |
| 452 |
yAxis: unknownChildrenSchema, |
| 453 |
blur: unknownChildrenSchema, |
| 454 |
color: unknownChildrenSchema |
| 455 |
})); |
| 456 |
|
| 457 |
//#endregion |
| 458 |
//#region packages/packages/libs/editor-props/src/prop-types/filter-prop-types/filter-functions/blur-filter.ts |
| 459 |
var blurFilterPropTypeUtil = createPropUtils("blur", _elementor_schema.z.strictObject({ size: unknownChildrenSchema })); |
| 460 |
|
| 461 |
//#endregion |
| 462 |
//#region packages/packages/libs/editor-props/src/prop-types/filter-prop-types/filter-functions/color-tone-filter.ts |
| 463 |
var colorToneFilterPropTypeUtil = createPropUtils("color-tone", _elementor_schema.z.strictObject({ size: unknownChildrenSchema })); |
| 464 |
|
| 465 |
//#endregion |
| 466 |
//#region packages/packages/libs/editor-props/src/prop-types/filter-prop-types/filter-functions/hue-rotate-filter.ts |
| 467 |
var hueRotateFilterPropTypeUtil = createPropUtils("hue-rotate", _elementor_schema.z.strictObject({ size: unknownChildrenSchema })); |
| 468 |
|
| 469 |
//#endregion |
| 470 |
//#region packages/packages/libs/editor-props/src/prop-types/filter-prop-types/filter-functions/intensity-filter.ts |
| 471 |
var intensityFilterPropTypeUtil = createPropUtils("intensity", _elementor_schema.z.strictObject({ size: unknownChildrenSchema })); |
| 472 |
|
| 473 |
//#endregion |
| 474 |
//#region packages/packages/libs/editor-props/src/prop-types/filter-prop-types/filter.ts |
| 475 |
var cssFilterFunctionPropUtil = createPropUtils("css-filter-func", _elementor_schema.z.object({ |
| 476 |
func: stringPropTypeUtil.schema, |
| 477 |
args: _elementor_schema.z.union([ |
| 478 |
blurFilterPropTypeUtil.schema, |
| 479 |
intensityFilterPropTypeUtil.schema, |
| 480 |
colorToneFilterPropTypeUtil.schema, |
| 481 |
hueRotateFilterPropTypeUtil.schema, |
| 482 |
dropShadowFilterPropTypeUtil.schema |
| 483 |
]) |
| 484 |
})); |
| 485 |
var filterPropTypeUtil = createPropUtils("filter", _elementor_schema.z.array(cssFilterFunctionPropUtil.schema)); |
| 486 |
|
| 487 |
//#endregion |
| 488 |
//#region packages/packages/libs/editor-props/src/prop-types/transform-prop-types/transform.ts |
| 489 |
var transformPropTypeUtil = createPropUtils("transform", _elementor_schema.z.strictObject({ |
| 490 |
"transform-functions": unknownChildrenSchema, |
| 491 |
"transform-origin": unknownChildrenSchema, |
| 492 |
perspective: unknownChildrenSchema, |
| 493 |
"perspective-origin": unknownChildrenSchema |
| 494 |
})); |
| 495 |
|
| 496 |
//#endregion |
| 497 |
//#region packages/packages/libs/editor-props/src/prop-types/transform-prop-types/types.ts |
| 498 |
var TransformFunctionKeys = { |
| 499 |
move: "transform-move", |
| 500 |
scale: "transform-scale", |
| 501 |
rotate: "transform-rotate", |
| 502 |
skew: "transform-skew" |
| 503 |
}; |
| 504 |
|
| 505 |
//#endregion |
| 506 |
//#region packages/packages/libs/editor-props/src/prop-types/transform-prop-types/transform-functions/move-transform.ts |
| 507 |
var moveTransformPropTypeUtil = createPropUtils(TransformFunctionKeys.move, _elementor_schema.z.strictObject({ |
| 508 |
x: unknownChildrenSchema, |
| 509 |
y: unknownChildrenSchema, |
| 510 |
z: unknownChildrenSchema |
| 511 |
})); |
| 512 |
|
| 513 |
//#endregion |
| 514 |
//#region packages/packages/libs/editor-props/src/prop-types/transform-prop-types/transform-functions/rotate-transform.ts |
| 515 |
var rotateTransformPropTypeUtil = createPropUtils(TransformFunctionKeys.rotate, _elementor_schema.z.strictObject({ |
| 516 |
x: unknownChildrenSchema, |
| 517 |
y: unknownChildrenSchema, |
| 518 |
z: unknownChildrenSchema |
| 519 |
})); |
| 520 |
|
| 521 |
//#endregion |
| 522 |
//#region packages/packages/libs/editor-props/src/prop-types/transform-prop-types/transform-functions/scale-transform.ts |
| 523 |
var scaleTransformPropTypeUtil = createPropUtils(TransformFunctionKeys.scale, _elementor_schema.z.strictObject({ |
| 524 |
x: numberPropTypeUtil.schema.nullable(), |
| 525 |
y: numberPropTypeUtil.schema.nullable(), |
| 526 |
z: numberPropTypeUtil.schema.nullable() |
| 527 |
})); |
| 528 |
|
| 529 |
//#endregion |
| 530 |
//#region packages/packages/libs/editor-props/src/prop-types/transform-prop-types/transform-functions/skew-transform.ts |
| 531 |
var skewTransformPropTypeUtil = createPropUtils(TransformFunctionKeys.skew, _elementor_schema.z.strictObject({ |
| 532 |
x: unknownChildrenSchema, |
| 533 |
y: unknownChildrenSchema |
| 534 |
})); |
| 535 |
|
| 536 |
//#endregion |
| 537 |
//#region packages/packages/libs/editor-props/src/prop-types/transform-prop-types/transform-functions.ts |
| 538 |
var filterTypes = moveTransformPropTypeUtil.schema.or(scaleTransformPropTypeUtil.schema).or(rotateTransformPropTypeUtil.schema).or(skewTransformPropTypeUtil.schema); |
| 539 |
var transformFunctionsPropTypeUtil = createPropUtils("transform-functions", _elementor_schema.z.array(filterTypes)); |
| 540 |
|
| 541 |
//#endregion |
| 542 |
//#region packages/packages/libs/editor-props/src/prop-types/transform-prop-types/transform-origin.ts |
| 543 |
var transformOriginPropTypeUtil = createPropUtils("transform-origin", _elementor_schema.z.strictObject({ |
| 544 |
x: unknownChildrenSchema, |
| 545 |
y: unknownChildrenSchema, |
| 546 |
z: unknownChildrenSchema |
| 547 |
})); |
| 548 |
|
| 549 |
//#endregion |
| 550 |
//#region packages/packages/libs/editor-props/src/prop-types/transform-prop-types/perspective-origin.ts |
| 551 |
var perspectiveOriginPropTypeUtil = createPropUtils("perspective-origin", _elementor_schema.z.strictObject({ |
| 552 |
x: unknownChildrenSchema, |
| 553 |
y: unknownChildrenSchema |
| 554 |
})); |
| 555 |
|
| 556 |
//#endregion |
| 557 |
//#region packages/packages/libs/editor-props/src/prop-types/filter-prop-types/backdrop-filter.ts |
| 558 |
var backdropFilterPropTypeUtil = createPropUtils("backdrop-filter", _elementor_schema.z.array(cssFilterFunctionPropUtil.schema)); |
| 559 |
|
| 560 |
//#endregion |
| 561 |
//#region packages/packages/libs/editor-props/src/prop-types/date-range.ts |
| 562 |
var dateRangePropTypeUtil = createPropUtils("date-range", _elementor_schema.z.strictObject({ |
| 563 |
min: unknownChildrenSchema, |
| 564 |
max: unknownChildrenSchema |
| 565 |
})); |
| 566 |
|
| 567 |
//#endregion |
| 568 |
//#region packages/packages/libs/editor-props/src/prop-types/date-string.ts |
| 569 |
var dateStringPropTypeUtil = createPropUtils("date-string", _elementor_schema.z.string()); |
| 570 |
|
| 571 |
//#endregion |
| 572 |
//#region packages/packages/libs/editor-props/src/prop-types/time-range.ts |
| 573 |
var timeRangePropTypeUtil = createPropUtils("time-range", _elementor_schema.z.strictObject({ |
| 574 |
min: unknownChildrenSchema, |
| 575 |
max: unknownChildrenSchema |
| 576 |
})); |
| 577 |
|
| 578 |
//#endregion |
| 579 |
//#region packages/packages/libs/editor-props/src/prop-types/time-string.ts |
| 580 |
var timeStringPropTypeUtil = createPropUtils("time-string", _elementor_schema.z.string()); |
| 581 |
|
| 582 |
//#endregion |
| 583 |
//#region packages/packages/libs/editor-props/src/utils/adjust-llm-prop-value-schema.ts |
| 584 |
var ensureNotNull = (v, fallback) => v === null ? fallback : v; |
| 585 |
var defaultOptions = { transformers: {} }; |
| 586 |
var adjustLlmPropValueSchema = (value, { transformers = {}, forceKey = void 0 } = defaultOptions) => { |
| 587 |
const clone = structuredClone(value); |
| 588 |
if (typeof clone !== "object" || clone === null) return null; |
| 589 |
if (Array.isArray(clone)) return clone.map((item) => adjustLlmPropValueSchema(item, { |
| 590 |
forceKey, |
| 591 |
transformers |
| 592 |
})); |
| 593 |
const transformablePropValue = clone; |
| 594 |
if ("$intention" in transformablePropValue) delete transformablePropValue.$intention; |
| 595 |
if (forceKey) transformablePropValue.$$type = forceKey; |
| 596 |
switch (transformablePropValue.$$type) { |
| 597 |
case "size": { |
| 598 |
const { value: rawSizePropValue } = transformablePropValue; |
| 599 |
return { |
| 600 |
$$type: "size", |
| 601 |
value: { |
| 602 |
unit: typeof rawSizePropValue.unit === "string" ? rawSizePropValue.unit : ensureNotNull(stringPropTypeUtil.extract(rawSizePropValue.unit), "px"), |
| 603 |
size: typeof rawSizePropValue.size === "string" || typeof rawSizePropValue.size === "number" ? rawSizePropValue.size : ensureNotNull(stringPropTypeUtil.extract(rawSizePropValue.size), numberPropTypeUtil.extract(rawSizePropValue.size)) |
| 604 |
} |
| 605 |
}; |
| 606 |
} |
| 607 |
case "html-v3": { |
| 608 |
const { value: rawHtmlV3PropValue } = transformablePropValue; |
| 609 |
return { |
| 610 |
$$type: "html-v3", |
| 611 |
value: { |
| 612 |
...rawHtmlV3PropValue, |
| 613 |
children: Array.isArray(rawHtmlV3PropValue.children) ? rawHtmlV3PropValue.children : [] |
| 614 |
} |
| 615 |
}; |
| 616 |
} |
| 617 |
default: |
| 618 |
const transformer = transformers?.[transformablePropValue.$$type]; |
| 619 |
if (transformer) return transformer(transformablePropValue.value); |
| 620 |
} |
| 621 |
if (typeof transformablePropValue.value === "object") if (Array.isArray(transformablePropValue.value)) transformablePropValue.value = adjustLlmPropValueSchema(transformablePropValue.value, { transformers }); |
| 622 |
else { |
| 623 |
const { value: objectValue } = transformablePropValue; |
| 624 |
const clonedObject = clone; |
| 625 |
clonedObject.value = {}; |
| 626 |
Object.entries(objectValue).forEach(([key, childProp]) => { |
| 627 |
clonedObject.value[key] = adjustLlmPropValueSchema(childProp, { transformers }); |
| 628 |
}); |
| 629 |
} |
| 630 |
return clone; |
| 631 |
}; |
| 632 |
|
| 633 |
//#endregion |
| 634 |
//#region packages/packages/libs/editor-props/src/utils/llm-schema-to-props.ts |
| 635 |
function jsonSchemaToPropType(schema, key = schema.key) { |
| 636 |
const meta = {}; |
| 637 |
if (schema.description) meta.description = schema.description; |
| 638 |
if (schema.anyOf && Array.isArray(schema.anyOf)) return convertJsonSchemaToUnionPropType(schema, meta); |
| 639 |
if (schema.type === "object" && schema.properties) return convertJsonSchemaToObjectPropType(schema, meta, key); |
| 640 |
if (schema.type === "array" && schema.items) return convertJsonSchemaToArrayPropType(schema, meta, key); |
| 641 |
return convertJsonSchemaToPlainPropType(schema, meta, key); |
| 642 |
} |
| 643 |
function convertJsonSchemaToPlainPropType(schema, meta, key = schema.key) { |
| 644 |
const settings = {}; |
| 645 |
let propKey = key || "string"; |
| 646 |
if (schema.type === "number") propKey = "number"; |
| 647 |
else if (schema.type === "boolean") propKey = "boolean"; |
| 648 |
else if (schema.type === "string") propKey = "string"; |
| 649 |
if (Array.isArray(schema.enum)) settings.enum = schema.enum; |
| 650 |
return { |
| 651 |
kind: "plain", |
| 652 |
key: propKey, |
| 653 |
settings, |
| 654 |
meta |
| 655 |
}; |
| 656 |
} |
| 657 |
function convertJsonSchemaToUnionPropType(schema, meta) { |
| 658 |
const propTypes = {}; |
| 659 |
if (!schema.anyOf || !Array.isArray(schema.anyOf)) throw new Error("Invalid anyOf schema"); |
| 660 |
for (const variantSchema of schema.anyOf) if (variantSchema.type === "object" && variantSchema.properties && variantSchema.properties.$$type && variantSchema.properties.value) { |
| 661 |
const typeProperty = variantSchema.properties.$$type; |
| 662 |
let typeKey; |
| 663 |
if (typeProperty.enum && Array.isArray(typeProperty.enum) && typeProperty.enum.length > 0) typeKey = typeProperty.enum[0]; |
| 664 |
else continue; |
| 665 |
propTypes[typeKey] = convertJsonSchemaToPropType(variantSchema.properties.value); |
| 666 |
} |
| 667 |
return { |
| 668 |
kind: "union", |
| 669 |
prop_types: propTypes, |
| 670 |
settings: {}, |
| 671 |
meta |
| 672 |
}; |
| 673 |
} |
| 674 |
function convertJsonSchemaToObjectPropType(schema, meta, key = schema.key) { |
| 675 |
const shape = {}; |
| 676 |
if (!schema.properties) return { |
| 677 |
kind: "object", |
| 678 |
key, |
| 679 |
shape: {}, |
| 680 |
settings: {}, |
| 681 |
meta |
| 682 |
}; |
| 683 |
const requiredFields = Array.isArray(schema.required) ? schema.required : []; |
| 684 |
for (const [propKey, propSchema] of Object.entries(schema.properties)) { |
| 685 |
const subPropType = convertJsonSchemaToPropType(propSchema, key); |
| 686 |
if (requiredFields.includes(propKey)) subPropType.settings = { |
| 687 |
...subPropType.settings, |
| 688 |
required: true |
| 689 |
}; |
| 690 |
shape[propKey] = subPropType; |
| 691 |
} |
| 692 |
return { |
| 693 |
kind: "object", |
| 694 |
key: key || "object", |
| 695 |
shape, |
| 696 |
settings: {}, |
| 697 |
meta |
| 698 |
}; |
| 699 |
} |
| 700 |
function convertJsonSchemaToArrayPropType(schema, meta, key = schema.key) { |
| 701 |
if (!schema.items) throw new Error("Array schema must have items property"); |
| 702 |
const itemPropType = convertJsonSchemaToPropType(schema.items); |
| 703 |
return { |
| 704 |
kind: "array", |
| 705 |
key: key || "array", |
| 706 |
item_prop_type: itemPropType, |
| 707 |
settings: {}, |
| 708 |
meta |
| 709 |
}; |
| 710 |
} |
| 711 |
function convertJsonSchemaToPropType(schema, key) { |
| 712 |
return jsonSchemaToPropType(schema, key); |
| 713 |
} |
| 714 |
|
| 715 |
//#endregion |
| 716 |
//#region packages/packages/libs/editor-props/src/utils/props-to-llm-schema.ts |
| 717 |
var DYNAMIC_PROP_TYPE_KEY = "dynamic"; |
| 718 |
var OVERRIDABLE_PROP_TYPE_KEY = "overridable"; |
| 719 |
var dynamicTagNamesResolver = null; |
| 720 |
function setDynamicTagNamesResolver(resolver) { |
| 721 |
dynamicTagNamesResolver = resolver; |
| 722 |
} |
| 723 |
function propTypeToJsonSchema(propType, suppressDynamic = false) { |
| 724 |
const description = propType.meta?.description; |
| 725 |
const schema = {}; |
| 726 |
if (description) schema.description = description; |
| 727 |
if (propType.initial_value !== null && propType.initial_value !== void 0) schema.examples = [propType.initial_value]; |
| 728 |
switch (propType.kind) { |
| 729 |
case "union": return convertUnionPropType(propType, schema, suppressDynamic); |
| 730 |
case "object": return convertObjectPropType(propType, schema, suppressDynamic); |
| 731 |
case "array": return convertArrayPropType(propType, schema, suppressDynamic); |
| 732 |
default: return convertPlainPropType(propType, schema); |
| 733 |
} |
| 734 |
} |
| 735 |
function convertPlainPropType(propType, baseSchema) { |
| 736 |
const schema = { ...baseSchema }; |
| 737 |
if (!Object.hasOwn(propType, "kind")) throw new Error(`PropType kind is undefined for propType with key: ${propType.key ?? "[unknown key]"}`); |
| 738 |
const enumValues = propType.settings?.enum || []; |
| 739 |
switch (propType.kind) { |
| 740 |
case "string": |
| 741 |
case "number": |
| 742 |
case "boolean": return { |
| 743 |
...schema, |
| 744 |
type: "object", |
| 745 |
properties: { |
| 746 |
$$type: { |
| 747 |
type: "string", |
| 748 |
const: propType.key ?? propType.kind |
| 749 |
}, |
| 750 |
value: { |
| 751 |
type: propType.kind, |
| 752 |
...enumValues.length > 0 ? { enum: enumValues } : {} |
| 753 |
} |
| 754 |
}, |
| 755 |
required: ["$$type", "value"] |
| 756 |
}; |
| 757 |
case "unknown": return {}; |
| 758 |
default: return { |
| 759 |
...schema, |
| 760 |
type: "object", |
| 761 |
$$type: propType.kind, |
| 762 |
value: { type: propType.kind } |
| 763 |
}; |
| 764 |
} |
| 765 |
} |
| 766 |
function convertUnionPropType(propType, baseSchema, suppressDynamic) { |
| 767 |
const schema = structuredClone(baseSchema); |
| 768 |
const propTypes = propType.prop_types || {}; |
| 769 |
const offersDynamic = !suppressDynamic && Boolean(propTypes[DYNAMIC_PROP_TYPE_KEY]); |
| 770 |
const suppressNestedDynamic = suppressDynamic || offersDynamic; |
| 771 |
const schemas = []; |
| 772 |
for (const [typeKey, subPropType] of Object.entries(propTypes)) { |
| 773 |
if (typeKey === OVERRIDABLE_PROP_TYPE_KEY) continue; |
| 774 |
if (typeKey === DYNAMIC_PROP_TYPE_KEY) { |
| 775 |
if (offersDynamic) schemas.push(convertDynamicPropType(subPropType)); |
| 776 |
continue; |
| 777 |
} |
| 778 |
schemas.push(propTypeToJsonSchema(subPropType, suppressNestedDynamic)); |
| 779 |
} |
| 780 |
if (schemas.length > 0) schema.anyOf = schemas; |
| 781 |
const propTypeDescription = propType.meta?.description; |
| 782 |
if (propTypeDescription) schema.description = propTypeDescription; |
| 783 |
return schema; |
| 784 |
} |
| 785 |
function convertDynamicPropType(propType) { |
| 786 |
const categories = Array.isArray(propType.settings?.categories) ? propType.settings.categories : []; |
| 787 |
const allowedTagNames = dynamicTagNamesResolver?.(categories) ?? []; |
| 788 |
return { |
| 789 |
type: "object", |
| 790 |
description: `Bind THIS value to a dynamic tag instead of a static value (this may be a nested field, e.g. an image's "src"). Look up the chosen tag in the "elementor://dynamic-tags" resource and populate "settings" exactly as its schema requires.`, |
| 791 |
properties: { |
| 792 |
$$type: { |
| 793 |
type: "string", |
| 794 |
const: DYNAMIC_PROP_TYPE_KEY |
| 795 |
}, |
| 796 |
value: { |
| 797 |
type: "object", |
| 798 |
properties: { |
| 799 |
name: { |
| 800 |
type: "string", |
| 801 |
description: "Dynamic tag name from \"elementor://dynamic-tags\".", |
| 802 |
...allowedTagNames.length ? { enum: allowedTagNames } : {} |
| 803 |
}, |
| 804 |
settings: { |
| 805 |
type: "object", |
| 806 |
description: "Tag settings matching the chosen tag's schema in the resource." |
| 807 |
} |
| 808 |
}, |
| 809 |
required: ["name"] |
| 810 |
} |
| 811 |
}, |
| 812 |
required: ["$$type", "value"] |
| 813 |
}; |
| 814 |
} |
| 815 |
function convertObjectPropType(propType, baseSchema, suppressDynamic) { |
| 816 |
const schema = structuredClone(baseSchema); |
| 817 |
schema.type = "object"; |
| 818 |
const internalStructure = { properties: { |
| 819 |
$$type: { |
| 820 |
type: "string", |
| 821 |
const: propType.key |
| 822 |
}, |
| 823 |
value: { |
| 824 |
type: "object", |
| 825 |
properties: {}, |
| 826 |
additionalProperties: false |
| 827 |
} |
| 828 |
} }; |
| 829 |
const required = ["$$type", "value"]; |
| 830 |
const valueRequired = []; |
| 831 |
const shape = propType.shape || {}; |
| 832 |
for (const [key, subPropType] of Object.entries(shape)) { |
| 833 |
const propSchema = propTypeToJsonSchema(subPropType, suppressDynamic); |
| 834 |
if (subPropType.settings?.required === true) valueRequired.push(key); |
| 835 |
if (internalStructure.properties.value.properties) internalStructure.properties.value.properties[key] = propSchema; |
| 836 |
} |
| 837 |
schema.required = required; |
| 838 |
if (valueRequired.length > 0) internalStructure.properties.value.required = valueRequired; |
| 839 |
return { |
| 840 |
...schema, |
| 841 |
...internalStructure |
| 842 |
}; |
| 843 |
} |
| 844 |
function convertArrayPropType(propType, baseSchema, suppressDynamic) { |
| 845 |
const schema = structuredClone(baseSchema); |
| 846 |
schema.type = "object"; |
| 847 |
let items; |
| 848 |
const itemPropType = propType.item_prop_type; |
| 849 |
if (itemPropType) items = propTypeToJsonSchema(itemPropType, suppressDynamic); |
| 850 |
schema.properties = { |
| 851 |
$$type: { |
| 852 |
type: "string", |
| 853 |
const: propType.key |
| 854 |
}, |
| 855 |
value: { |
| 856 |
type: "array", |
| 857 |
...items ? { items } : {} |
| 858 |
} |
| 859 |
}; |
| 860 |
return schema; |
| 861 |
} |
| 862 |
var nonConfigurablePropKeys = [ |
| 863 |
"_cssid", |
| 864 |
"classes", |
| 865 |
"attributes" |
| 866 |
]; |
| 867 |
function isPropKeyConfigurable(propKey, propType) { |
| 868 |
if (!nonConfigurablePropKeys.includes(propKey)) return true; |
| 869 |
return !!(!Array.isArray(propType?.meta) && propType?.meta?.llm_configurable); |
| 870 |
} |
| 871 |
function configurableKeys(schema) { |
| 872 |
return Object.keys(schema).filter((key) => isPropKeyConfigurable(key, schema[key])); |
| 873 |
} |
| 874 |
function enrichWithIntention(jsonSchema, text = "Describe the desired outcome") { |
| 875 |
const result = structuredClone(jsonSchema); |
| 876 |
if (!result.properties) return jsonSchema; |
| 877 |
result.properties.$intention = { |
| 878 |
type: "string", |
| 879 |
description: text |
| 880 |
}; |
| 881 |
result.required = [...result.required || [], "$intention"]; |
| 882 |
return result; |
| 883 |
} |
| 884 |
function removeIntention(jsonSchema) { |
| 885 |
const result = structuredClone(jsonSchema); |
| 886 |
if (!result.properties) return jsonSchema; |
| 887 |
delete result.properties.$intention; |
| 888 |
if (result.required) result.required = result.required.filter((req) => req !== "$intention"); |
| 889 |
return result; |
| 890 |
} |
| 891 |
|
| 892 |
//#endregion |
| 893 |
//#region node_modules/jsonschema/lib/helpers.js |
| 894 |
var require_helpers = /* @__PURE__ */ __commonJSMin(((exports, module) => { |
| 895 |
var ValidationError = exports.ValidationError = function ValidationError(message, instance, schema, path, name, argument) { |
| 896 |
if (Array.isArray(path)) { |
| 897 |
this.path = path; |
| 898 |
this.property = path.reduce(function(sum, item) { |
| 899 |
return sum + makeSuffix(item); |
| 900 |
}, "instance"); |
| 901 |
} else if (path !== void 0) this.property = path; |
| 902 |
if (message) this.message = message; |
| 903 |
if (schema) { |
| 904 |
var id = schema.$id || schema.id; |
| 905 |
this.schema = id || schema; |
| 906 |
} |
| 907 |
if (instance !== void 0) this.instance = instance; |
| 908 |
this.name = name; |
| 909 |
this.argument = argument; |
| 910 |
this.stack = this.toString(); |
| 911 |
}; |
| 912 |
ValidationError.prototype.toString = function toString() { |
| 913 |
return this.property + " " + this.message; |
| 914 |
}; |
| 915 |
var ValidatorResult = exports.ValidatorResult = function ValidatorResult(instance, schema, options, ctx) { |
| 916 |
this.instance = instance; |
| 917 |
this.schema = schema; |
| 918 |
this.options = options; |
| 919 |
this.path = ctx.path; |
| 920 |
this.propertyPath = ctx.propertyPath; |
| 921 |
this.errors = []; |
| 922 |
this.throwError = options && options.throwError; |
| 923 |
this.throwFirst = options && options.throwFirst; |
| 924 |
this.throwAll = options && options.throwAll; |
| 925 |
this.disableFormat = options && options.disableFormat === true; |
| 926 |
}; |
| 927 |
ValidatorResult.prototype.addError = function addError(detail) { |
| 928 |
var err; |
| 929 |
if (typeof detail == "string") err = new ValidationError(detail, this.instance, this.schema, this.path); |
| 930 |
else { |
| 931 |
if (!detail) throw new Error("Missing error detail"); |
| 932 |
if (!detail.message) throw new Error("Missing error message"); |
| 933 |
if (!detail.name) throw new Error("Missing validator type"); |
| 934 |
err = new ValidationError(detail.message, this.instance, this.schema, this.path, detail.name, detail.argument); |
| 935 |
} |
| 936 |
this.errors.push(err); |
| 937 |
if (this.throwFirst) throw new ValidatorResultError(this); |
| 938 |
else if (this.throwError) throw err; |
| 939 |
return err; |
| 940 |
}; |
| 941 |
ValidatorResult.prototype.importErrors = function importErrors(res) { |
| 942 |
if (typeof res == "string" || res && res.validatorType) this.addError(res); |
| 943 |
else if (res && res.errors) this.errors = this.errors.concat(res.errors); |
| 944 |
}; |
| 945 |
function stringizer(v, i) { |
| 946 |
return i + ": " + v.toString() + "\n"; |
| 947 |
} |
| 948 |
ValidatorResult.prototype.toString = function toString(res) { |
| 949 |
return this.errors.map(stringizer).join(""); |
| 950 |
}; |
| 951 |
Object.defineProperty(ValidatorResult.prototype, "valid", { get: function() { |
| 952 |
return !this.errors.length; |
| 953 |
} }); |
| 954 |
module.exports.ValidatorResultError = ValidatorResultError; |
| 955 |
function ValidatorResultError(result) { |
| 956 |
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, ValidatorResultError); |
| 957 |
this.instance = result.instance; |
| 958 |
this.schema = result.schema; |
| 959 |
this.options = result.options; |
| 960 |
this.errors = result.errors; |
| 961 |
} |
| 962 |
ValidatorResultError.prototype = /* @__PURE__ */ new Error(); |
| 963 |
ValidatorResultError.prototype.constructor = ValidatorResultError; |
| 964 |
ValidatorResultError.prototype.name = "Validation Error"; |
| 965 |
/** |
| 966 |
* Describes a problem with a Schema which prevents validation of an instance |
| 967 |
* @name SchemaError |
| 968 |
* @constructor |
| 969 |
*/ |
| 970 |
var SchemaError = exports.SchemaError = function SchemaError(msg, schema) { |
| 971 |
this.message = msg; |
| 972 |
this.schema = schema; |
| 973 |
Error.call(this, msg); |
| 974 |
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, SchemaError); |
| 975 |
}; |
| 976 |
SchemaError.prototype = Object.create(Error.prototype, { |
| 977 |
constructor: { |
| 978 |
value: SchemaError, |
| 979 |
enumerable: false |
| 980 |
}, |
| 981 |
name: { |
| 982 |
value: "SchemaError", |
| 983 |
enumerable: false |
| 984 |
} |
| 985 |
}); |
| 986 |
var SchemaContext = exports.SchemaContext = function SchemaContext(schema, options, path, base, schemas) { |
| 987 |
this.schema = schema; |
| 988 |
this.options = options; |
| 989 |
if (Array.isArray(path)) { |
| 990 |
this.path = path; |
| 991 |
this.propertyPath = path.reduce(function(sum, item) { |
| 992 |
return sum + makeSuffix(item); |
| 993 |
}, "instance"); |
| 994 |
} else this.propertyPath = path; |
| 995 |
this.base = base; |
| 996 |
this.schemas = schemas; |
| 997 |
}; |
| 998 |
SchemaContext.prototype.resolve = function resolve(target) { |
| 999 |
return (() => resolveUrl(this.base, target))(); |
| 1000 |
}; |
| 1001 |
SchemaContext.prototype.makeChild = function makeChild(schema, propertyName) { |
| 1002 |
var path = propertyName === void 0 ? this.path : this.path.concat([propertyName]); |
| 1003 |
var id = schema.$id || schema.id; |
| 1004 |
let base = (() => resolveUrl(this.base, id || ""))(); |
| 1005 |
var ctx = new SchemaContext(schema, this.options, path, base, Object.create(this.schemas)); |
| 1006 |
if (id && !ctx.schemas[base]) ctx.schemas[base] = schema; |
| 1007 |
return ctx; |
| 1008 |
}; |
| 1009 |
var FORMAT_REGEXPS = exports.FORMAT_REGEXPS = { |
| 1010 |
"date-time": /^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])[tT ](2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])(\.\d+)?([zZ]|[+-]([0-5][0-9]):(60|[0-5][0-9]))$/, |
| 1011 |
"date": /^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])$/, |
| 1012 |
"time": /^(2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])$/, |
| 1013 |
"duration": /P(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S)|\d+(D|M(\d+D)?|Y(\d+M(\d+D)?)?)(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S))?|\d+W)/i, |
| 1014 |
"email": /^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/, |
| 1015 |
"idn-email": /^("(?:[!#-\[\]-\u{10FFFF}]|\\[\t -\u{10FFFF}])*"|[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*)@([!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*|\[[!-Z\^-\u{10FFFF}]*\])$/u, |
| 1016 |
"ip-address": /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/, |
| 1017 |
"ipv6": /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/, |
| 1018 |
"uri": /^[a-zA-Z][a-zA-Z0-9+.-]*:[^\s]*$/, |
| 1019 |
"uri-reference": /^(((([A-Za-z][+\-.0-9A-Za-z]*(:%[0-9A-Fa-f]{2}|:[!$&-.0-;=?-Z_a-z~]|[/?])|\?)(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|([A-Za-z][+\-.0-9A-Za-z]*:?)?)|([A-Za-z][+\-.0-9A-Za-z]*:)?\/((%[0-9A-Fa-f]{2}|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?[/?]|[!$&-.0-;=?-Z_a-z~])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|(\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?)?))#(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|(([A-Za-z][+\-.0-9A-Za-z]*)?%[0-9A-Fa-f]{2}|[!$&-.0-9;=@_~]|[A-Za-z][+\-.0-9A-Za-z]*[!$&-*,;=@_~])(%[0-9A-Fa-f]{2}|[!$&-.0-9;=@-Z_a-z~])*((([/?](%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*)?#|[/?])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*)?|([A-Za-z][+\-.0-9A-Za-z]*(:%[0-9A-Fa-f]{2}|:[!$&-.0-;=?-Z_a-z~]|[/?])|\?)(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|([A-Za-z][+\-.0-9A-Za-z]*:)?\/((%[0-9A-Fa-f]{2}|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?[/?]|[!$&-.0-;=?-Z_a-z~])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~])*|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~])+(:\d*)?|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?:\d*|\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~]+)?|[.0-:A-Fa-f]+)\])?)?|[A-Za-z][+\-.0-9A-Za-z]*:?)?$/, |
| 1020 |
"iri": /^[a-zA-Z][a-zA-Z0-9+.-]*:[^\s]*$/, |
| 1021 |
"iri-reference": /^(((([A-Za-z][+\-.0-9A-Za-z]*(:%[0-9A-Fa-f]{2}|:[!$&-.0-;=?-Z_a-z~-\u{10FFFF}]|[/?])|\?)(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*|([A-Za-z][+\-.0-9A-Za-z]*:?)?)|([A-Za-z][+\-.0-9A-Za-z]*:)?\/((%[0-9A-Fa-f]{2}|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~-\u{10FFFF}])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?[/?]|[!$&-.0-;=?-Z_a-z~-\u{10FFFF}])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*|(\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~-\u{10FFFF}])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?)?))#(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*|(([A-Za-z][+\-.0-9A-Za-z]*)?%[0-9A-Fa-f]{2}|[!$&-.0-9;=@_~-\u{10FFFF}]|[A-Za-z][+\-.0-9A-Za-z]*[!$&-*,;=@_~-\u{10FFFF}])(%[0-9A-Fa-f]{2}|[!$&-.0-9;=@-Z_a-z~-\u{10FFFF}])*((([/?](%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*)?#|[/?])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*)?|([A-Za-z][+\-.0-9A-Za-z]*(:%[0-9A-Fa-f]{2}|:[!$&-.0-;=?-Z_a-z~-\u{10FFFF}]|[/?])|\?)(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*|([A-Za-z][+\-.0-9A-Za-z]*:)?\/((%[0-9A-Fa-f]{2}|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~-\u{10FFFF}])+|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?)(:\d*)?[/?]|[!$&-.0-;=?-Z_a-z~-\u{10FFFF}])(%[0-9A-Fa-f]{2}|[!$&-;=?-Z_a-z~-\u{10FFFF}])*|\/((%[0-9A-Fa-f]{2}|[!$&-.0-9;=A-Z_a-z~-\u{10FFFF}])+(:\d*)?|(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?:\d*|\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?)?|[A-Za-z][+\-.0-9A-Za-z]*:?)?$/u, |
| 1022 |
"uuid": /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i, |
| 1023 |
"uri-template": /(%[0-9a-f]{2}|[!#$&(-;=?@\[\]_a-z~]|\{[!#&+,./;=?@|]?(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?(,(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?)*\})*/iu, |
| 1024 |
"json-pointer": /^(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*$/iu, |
| 1025 |
"relative-json-pointer": /^\d+(#|(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*)$/iu, |
| 1026 |
"hostname": /^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/, |
| 1027 |
"host-name": /^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/, |
| 1028 |
"utc-millisec": function(input) { |
| 1029 |
return typeof input === "string" && parseFloat(input) === parseInt(input, 10) && !isNaN(input); |
| 1030 |
}, |
| 1031 |
"regex": function(input) { |
| 1032 |
var result = true; |
| 1033 |
try { |
| 1034 |
new RegExp(input); |
| 1035 |
} catch (e) { |
| 1036 |
result = false; |
| 1037 |
} |
| 1038 |
return result; |
| 1039 |
}, |
| 1040 |
"style": /[\r\n\t ]*[^\r\n\t ][^:]*:[\r\n\t ]*[^\r\n\t ;]*[\r\n\t ]*;?/, |
| 1041 |
"color": /^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/, |
| 1042 |
"phone": /^\+(?:[0-9] ?){6,14}[0-9]$/, |
| 1043 |
"alpha": /^[a-zA-Z]+$/, |
| 1044 |
"alphanumeric": /^[a-zA-Z0-9]+$/ |
| 1045 |
}; |
| 1046 |
FORMAT_REGEXPS.regexp = FORMAT_REGEXPS.regex; |
| 1047 |
FORMAT_REGEXPS.pattern = FORMAT_REGEXPS.regex; |
| 1048 |
FORMAT_REGEXPS.ipv4 = FORMAT_REGEXPS["ip-address"]; |
| 1049 |
exports.isFormat = function isFormat(input, format, validator) { |
| 1050 |
if (typeof input === "string" && FORMAT_REGEXPS[format] !== void 0) { |
| 1051 |
if (FORMAT_REGEXPS[format] instanceof RegExp) return FORMAT_REGEXPS[format].test(input); |
| 1052 |
if (typeof FORMAT_REGEXPS[format] === "function") return FORMAT_REGEXPS[format](input); |
| 1053 |
} else if (validator && validator.customFormats && typeof validator.customFormats[format] === "function") return validator.customFormats[format](input); |
| 1054 |
return true; |
| 1055 |
}; |
| 1056 |
var makeSuffix = exports.makeSuffix = function makeSuffix(key) { |
| 1057 |
key = key.toString(); |
| 1058 |
if (!key.match(/[.\s\[\]]/) && !key.match(/^[\d]/)) return "." + key; |
| 1059 |
if (key.match(/^\d+$/)) return "[" + key + "]"; |
| 1060 |
return "[" + JSON.stringify(key) + "]"; |
| 1061 |
}; |
| 1062 |
exports.deepCompareStrict = function deepCompareStrict(a, b) { |
| 1063 |
if (typeof a !== typeof b) return false; |
| 1064 |
if (Array.isArray(a)) { |
| 1065 |
if (!Array.isArray(b)) return false; |
| 1066 |
if (a.length !== b.length) return false; |
| 1067 |
return a.every(function(v, i) { |
| 1068 |
return deepCompareStrict(a[i], b[i]); |
| 1069 |
}); |
| 1070 |
} |
| 1071 |
if (typeof a === "object") { |
| 1072 |
if (!a || !b) return a === b; |
| 1073 |
var aKeys = Object.keys(a); |
| 1074 |
var bKeys = Object.keys(b); |
| 1075 |
if (aKeys.length !== bKeys.length) return false; |
| 1076 |
return aKeys.every(function(v) { |
| 1077 |
return deepCompareStrict(a[v], b[v]); |
| 1078 |
}); |
| 1079 |
} |
| 1080 |
return a === b; |
| 1081 |
}; |
| 1082 |
function deepMerger(target, dst, e, i) { |
| 1083 |
if (typeof e === "object") dst[i] = deepMerge(target[i], e); |
| 1084 |
else if (target.indexOf(e) === -1) dst.push(e); |
| 1085 |
} |
| 1086 |
function copyist(src, dst, key) { |
| 1087 |
dst[key] = src[key]; |
| 1088 |
} |
| 1089 |
function copyistWithDeepMerge(target, src, dst, key) { |
| 1090 |
if (typeof src[key] !== "object" || !src[key]) dst[key] = src[key]; |
| 1091 |
else if (!target[key]) dst[key] = src[key]; |
| 1092 |
else dst[key] = deepMerge(target[key], src[key]); |
| 1093 |
} |
| 1094 |
function deepMerge(target, src) { |
| 1095 |
var array = Array.isArray(src); |
| 1096 |
var dst = array && [] || {}; |
| 1097 |
if (array) { |
| 1098 |
target = target || []; |
| 1099 |
dst = dst.concat(target); |
| 1100 |
src.forEach(deepMerger.bind(null, target, dst)); |
| 1101 |
} else { |
| 1102 |
if (target && typeof target === "object") Object.keys(target).forEach(copyist.bind(null, target, dst)); |
| 1103 |
Object.keys(src).forEach(copyistWithDeepMerge.bind(null, target, src, dst)); |
| 1104 |
} |
| 1105 |
return dst; |
| 1106 |
} |
| 1107 |
module.exports.deepMerge = deepMerge; |
| 1108 |
/** |
| 1109 |
* Validates instance against the provided schema |
| 1110 |
* Implements URI+JSON Pointer encoding, e.g. "%7e"="~0"=>"~", "~1"="%2f"=>"/" |
| 1111 |
* @param o |
| 1112 |
* @param s The path to walk o along |
| 1113 |
* @return any |
| 1114 |
*/ |
| 1115 |
exports.objectGetPath = function objectGetPath(o, s) { |
| 1116 |
var parts = s.split("/").slice(1); |
| 1117 |
var k; |
| 1118 |
while (typeof (k = parts.shift()) == "string") { |
| 1119 |
var n = decodeURIComponent(k.replace(/~0/, "~").replace(/~1/g, "/")); |
| 1120 |
if (!(n in o)) return; |
| 1121 |
o = o[n]; |
| 1122 |
} |
| 1123 |
return o; |
| 1124 |
}; |
| 1125 |
function pathEncoder(v) { |
| 1126 |
return "/" + encodeURIComponent(v).replace(/~/g, "%7E"); |
| 1127 |
} |
| 1128 |
/** |
| 1129 |
* Accept an Array of property names and return a JSON Pointer URI fragment |
| 1130 |
* @param Array a |
| 1131 |
* @return {String} |
| 1132 |
*/ |
| 1133 |
exports.encodePath = function encodePointer(a) { |
| 1134 |
return a.map(pathEncoder).join(""); |
| 1135 |
}; |
| 1136 |
/** |
| 1137 |
* Calculate the number of decimal places a number uses |
| 1138 |
* We need this to get correct results out of multipleOf and divisibleBy |
| 1139 |
* when either figure is has decimal places, due to IEEE-754 float issues. |
| 1140 |
* @param number |
| 1141 |
* @returns {number} |
| 1142 |
*/ |
| 1143 |
exports.getDecimalPlaces = function getDecimalPlaces(number) { |
| 1144 |
var decimalPlaces = 0; |
| 1145 |
if (isNaN(number)) return decimalPlaces; |
| 1146 |
if (typeof number !== "number") number = Number(number); |
| 1147 |
var parts = number.toString().split("e"); |
| 1148 |
if (parts.length === 2) if (parts[1][0] !== "-") return decimalPlaces; |
| 1149 |
else decimalPlaces = Number(parts[1].slice(1)); |
| 1150 |
var decimalParts = parts[0].split("."); |
| 1151 |
if (decimalParts.length === 2) decimalPlaces += decimalParts[1].length; |
| 1152 |
return decimalPlaces; |
| 1153 |
}; |
| 1154 |
exports.isSchema = function isSchema(val) { |
| 1155 |
return typeof val === "object" && val || typeof val === "boolean"; |
| 1156 |
}; |
| 1157 |
/** |
| 1158 |
* Resolve target URL from a base and relative URL. |
| 1159 |
* Similar to Node's URL Lib's legacy resolve function. |
| 1160 |
* Code from example in deprecation note in said library. |
| 1161 |
* @param string |
| 1162 |
* @param string |
| 1163 |
* @returns {string} |
| 1164 |
*/ |
| 1165 |
var resolveUrl = exports.resolveUrl = function resolveUrl(from, to) { |
| 1166 |
const resolvedUrl = new URL(to, new URL(from, "resolve://")); |
| 1167 |
if (resolvedUrl.protocol === "resolve:") { |
| 1168 |
const { pathname, search, hash } = resolvedUrl; |
| 1169 |
return pathname + search + hash; |
| 1170 |
} |
| 1171 |
return resolvedUrl.toString(); |
| 1172 |
}; |
| 1173 |
})); |
| 1174 |
|
| 1175 |
//#endregion |
| 1176 |
//#region node_modules/jsonschema/lib/attribute.js |
| 1177 |
var require_attribute = /* @__PURE__ */ __commonJSMin(((exports, module) => { |
| 1178 |
var helpers = require_helpers(); |
| 1179 |
/** @type ValidatorResult */ |
| 1180 |
var ValidatorResult = helpers.ValidatorResult; |
| 1181 |
/** @type SchemaError */ |
| 1182 |
var SchemaError = helpers.SchemaError; |
| 1183 |
var attribute = {}; |
| 1184 |
attribute.ignoreProperties = { |
| 1185 |
"id": true, |
| 1186 |
"default": true, |
| 1187 |
"description": true, |
| 1188 |
"title": true, |
| 1189 |
"additionalItems": true, |
| 1190 |
"then": true, |
| 1191 |
"else": true, |
| 1192 |
"$schema": true, |
| 1193 |
"$ref": true, |
| 1194 |
"extends": true |
| 1195 |
}; |
| 1196 |
/** |
| 1197 |
* @name validators |
| 1198 |
*/ |
| 1199 |
var validators = attribute.validators = {}; |
| 1200 |
/** |
| 1201 |
* Validates whether the instance if of a certain type |
| 1202 |
* @param instance |
| 1203 |
* @param schema |
| 1204 |
* @param options |
| 1205 |
* @param ctx |
| 1206 |
* @return {ValidatorResult|null} |
| 1207 |
*/ |
| 1208 |
validators.type = function validateType(instance, schema, options, ctx) { |
| 1209 |
if (instance === void 0) return null; |
| 1210 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1211 |
var types = Array.isArray(schema.type) ? schema.type : [schema.type]; |
| 1212 |
if (!types.some(this.testType.bind(this, instance, schema, options, ctx))) { |
| 1213 |
var list = types.map(function(v) { |
| 1214 |
if (!v) return; |
| 1215 |
var id = v.$id || v.id; |
| 1216 |
return id ? "<" + id + ">" : v + ""; |
| 1217 |
}); |
| 1218 |
result.addError({ |
| 1219 |
name: "type", |
| 1220 |
argument: list, |
| 1221 |
message: "is not of a type(s) " + list |
| 1222 |
}); |
| 1223 |
} |
| 1224 |
return result; |
| 1225 |
}; |
| 1226 |
function testSchemaNoThrow(instance, options, ctx, callback, schema) { |
| 1227 |
var throwError = options.throwError; |
| 1228 |
var throwAll = options.throwAll; |
| 1229 |
options.throwError = false; |
| 1230 |
options.throwAll = false; |
| 1231 |
var res = this.validateSchema(instance, schema, options, ctx); |
| 1232 |
options.throwError = throwError; |
| 1233 |
options.throwAll = throwAll; |
| 1234 |
if (!res.valid && callback instanceof Function) callback(res); |
| 1235 |
return res.valid; |
| 1236 |
} |
| 1237 |
/** |
| 1238 |
* Validates whether the instance matches some of the given schemas |
| 1239 |
* @param instance |
| 1240 |
* @param schema |
| 1241 |
* @param options |
| 1242 |
* @param ctx |
| 1243 |
* @return {ValidatorResult|null} |
| 1244 |
*/ |
| 1245 |
validators.anyOf = function validateAnyOf(instance, schema, options, ctx) { |
| 1246 |
if (instance === void 0) return null; |
| 1247 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1248 |
var inner = new ValidatorResult(instance, schema, options, ctx); |
| 1249 |
if (!Array.isArray(schema.anyOf)) throw new SchemaError("anyOf must be an array"); |
| 1250 |
if (!schema.anyOf.some(testSchemaNoThrow.bind(this, instance, options, ctx, function(res) { |
| 1251 |
inner.importErrors(res); |
| 1252 |
}))) { |
| 1253 |
var list = schema.anyOf.map(function(v, i) { |
| 1254 |
var id = v.$id || v.id; |
| 1255 |
if (id) return "<" + id + ">"; |
| 1256 |
return v.title && JSON.stringify(v.title) || v["$ref"] && "<" + v["$ref"] + ">" || "[subschema " + i + "]"; |
| 1257 |
}); |
| 1258 |
if (options.nestedErrors) result.importErrors(inner); |
| 1259 |
result.addError({ |
| 1260 |
name: "anyOf", |
| 1261 |
argument: list, |
| 1262 |
message: "is not any of " + list.join(",") |
| 1263 |
}); |
| 1264 |
} |
| 1265 |
return result; |
| 1266 |
}; |
| 1267 |
/** |
| 1268 |
* Validates whether the instance matches every given schema |
| 1269 |
* @param instance |
| 1270 |
* @param schema |
| 1271 |
* @param options |
| 1272 |
* @param ctx |
| 1273 |
* @return {String|null} |
| 1274 |
*/ |
| 1275 |
validators.allOf = function validateAllOf(instance, schema, options, ctx) { |
| 1276 |
if (instance === void 0) return null; |
| 1277 |
if (!Array.isArray(schema.allOf)) throw new SchemaError("allOf must be an array"); |
| 1278 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1279 |
var self = this; |
| 1280 |
schema.allOf.forEach(function(v, i) { |
| 1281 |
var valid = self.validateSchema(instance, v, options, ctx); |
| 1282 |
if (!valid.valid) { |
| 1283 |
var msg = v.$id || v.id || v.title && JSON.stringify(v.title) || v["$ref"] && "<" + v["$ref"] + ">" || "[subschema " + i + "]"; |
| 1284 |
result.addError({ |
| 1285 |
name: "allOf", |
| 1286 |
argument: { |
| 1287 |
id: msg, |
| 1288 |
length: valid.errors.length, |
| 1289 |
valid |
| 1290 |
}, |
| 1291 |
message: "does not match allOf schema " + msg + " with " + valid.errors.length + " error[s]:" |
| 1292 |
}); |
| 1293 |
result.importErrors(valid); |
| 1294 |
} |
| 1295 |
}); |
| 1296 |
return result; |
| 1297 |
}; |
| 1298 |
/** |
| 1299 |
* Validates whether the instance matches exactly one of the given schemas |
| 1300 |
* @param instance |
| 1301 |
* @param schema |
| 1302 |
* @param options |
| 1303 |
* @param ctx |
| 1304 |
* @return {String|null} |
| 1305 |
*/ |
| 1306 |
validators.oneOf = function validateOneOf(instance, schema, options, ctx) { |
| 1307 |
if (instance === void 0) return null; |
| 1308 |
if (!Array.isArray(schema.oneOf)) throw new SchemaError("oneOf must be an array"); |
| 1309 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1310 |
var inner = new ValidatorResult(instance, schema, options, ctx); |
| 1311 |
var count = schema.oneOf.filter(testSchemaNoThrow.bind(this, instance, options, ctx, function(res) { |
| 1312 |
inner.importErrors(res); |
| 1313 |
})).length; |
| 1314 |
var list = schema.oneOf.map(function(v, i) { |
| 1315 |
return v.$id || v.id || v.title && JSON.stringify(v.title) || v["$ref"] && "<" + v["$ref"] + ">" || "[subschema " + i + "]"; |
| 1316 |
}); |
| 1317 |
if (count !== 1) { |
| 1318 |
if (options.nestedErrors) result.importErrors(inner); |
| 1319 |
result.addError({ |
| 1320 |
name: "oneOf", |
| 1321 |
argument: list, |
| 1322 |
message: "is not exactly one from " + list.join(",") |
| 1323 |
}); |
| 1324 |
} |
| 1325 |
return result; |
| 1326 |
}; |
| 1327 |
/** |
| 1328 |
* Validates "then" or "else" depending on the result of validating "if" |
| 1329 |
* @param instance |
| 1330 |
* @param schema |
| 1331 |
* @param options |
| 1332 |
* @param ctx |
| 1333 |
* @return {String|null} |
| 1334 |
*/ |
| 1335 |
validators.if = function validateIf(instance, schema, options, ctx) { |
| 1336 |
if (instance === void 0) return null; |
| 1337 |
if (!helpers.isSchema(schema.if)) throw new Error("Expected \"if\" keyword to be a schema"); |
| 1338 |
var ifValid = testSchemaNoThrow.call(this, instance, options, ctx, null, schema.if); |
| 1339 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1340 |
var res; |
| 1341 |
if (ifValid) { |
| 1342 |
if (schema.then === void 0) return; |
| 1343 |
if (!helpers.isSchema(schema.then)) throw new Error("Expected \"then\" keyword to be a schema"); |
| 1344 |
res = this.validateSchema(instance, schema.then, options, ctx.makeChild(schema.then)); |
| 1345 |
result.importErrors(res); |
| 1346 |
} else { |
| 1347 |
if (schema.else === void 0) return; |
| 1348 |
if (!helpers.isSchema(schema.else)) throw new Error("Expected \"else\" keyword to be a schema"); |
| 1349 |
res = this.validateSchema(instance, schema.else, options, ctx.makeChild(schema.else)); |
| 1350 |
result.importErrors(res); |
| 1351 |
} |
| 1352 |
return result; |
| 1353 |
}; |
| 1354 |
function getEnumerableProperty(object, key) { |
| 1355 |
if (Object.hasOwnProperty.call(object, key)) return object[key]; |
| 1356 |
if (!(key in object)) return; |
| 1357 |
while (object = Object.getPrototypeOf(object)) if (Object.propertyIsEnumerable.call(object, key)) return object[key]; |
| 1358 |
} |
| 1359 |
/** |
| 1360 |
* Validates propertyNames |
| 1361 |
* @param instance |
| 1362 |
* @param schema |
| 1363 |
* @param options |
| 1364 |
* @param ctx |
| 1365 |
* @return {String|null|ValidatorResult} |
| 1366 |
*/ |
| 1367 |
validators.propertyNames = function validatePropertyNames(instance, schema, options, ctx) { |
| 1368 |
if (!this.types.object(instance)) return; |
| 1369 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1370 |
var subschema = schema.propertyNames !== void 0 ? schema.propertyNames : {}; |
| 1371 |
if (!helpers.isSchema(subschema)) throw new SchemaError("Expected \"propertyNames\" to be a schema (object or boolean)"); |
| 1372 |
for (var property in instance) if (getEnumerableProperty(instance, property) !== void 0) { |
| 1373 |
var res = this.validateSchema(property, subschema, options, ctx.makeChild(subschema)); |
| 1374 |
result.importErrors(res); |
| 1375 |
} |
| 1376 |
return result; |
| 1377 |
}; |
| 1378 |
/** |
| 1379 |
* Validates properties |
| 1380 |
* @param instance |
| 1381 |
* @param schema |
| 1382 |
* @param options |
| 1383 |
* @param ctx |
| 1384 |
* @return {String|null|ValidatorResult} |
| 1385 |
*/ |
| 1386 |
validators.properties = function validateProperties(instance, schema, options, ctx) { |
| 1387 |
if (!this.types.object(instance)) return; |
| 1388 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1389 |
var properties = schema.properties || {}; |
| 1390 |
for (var property in properties) { |
| 1391 |
var subschema = properties[property]; |
| 1392 |
if (subschema === void 0) continue; |
| 1393 |
else if (subschema === null) throw new SchemaError("Unexpected null, expected schema in \"properties\""); |
| 1394 |
if (typeof options.preValidateProperty == "function") options.preValidateProperty(instance, property, subschema, options, ctx); |
| 1395 |
var prop = getEnumerableProperty(instance, property); |
| 1396 |
var res = this.validateSchema(prop, subschema, options, ctx.makeChild(subschema, property)); |
| 1397 |
if (res.instance !== result.instance[property]) result.instance[property] = res.instance; |
| 1398 |
result.importErrors(res); |
| 1399 |
} |
| 1400 |
return result; |
| 1401 |
}; |
| 1402 |
/** |
| 1403 |
* Test a specific property within in instance against the additionalProperties schema attribute |
| 1404 |
* This ignores properties with definitions in the properties schema attribute, but no other attributes. |
| 1405 |
* If too many more types of property-existence tests pop up they may need their own class of tests (like `type` has) |
| 1406 |
* @private |
| 1407 |
* @return {boolean} |
| 1408 |
*/ |
| 1409 |
function testAdditionalProperty(instance, schema, options, ctx, property, result) { |
| 1410 |
if (!this.types.object(instance)) return; |
| 1411 |
if (schema.properties && schema.properties[property] !== void 0) return; |
| 1412 |
if (schema.additionalProperties === false) result.addError({ |
| 1413 |
name: "additionalProperties", |
| 1414 |
argument: property, |
| 1415 |
message: "is not allowed to have the additional property " + JSON.stringify(property) |
| 1416 |
}); |
| 1417 |
else { |
| 1418 |
var additionalProperties = schema.additionalProperties || {}; |
| 1419 |
if (typeof options.preValidateProperty == "function") options.preValidateProperty(instance, property, additionalProperties, options, ctx); |
| 1420 |
var res = this.validateSchema(instance[property], additionalProperties, options, ctx.makeChild(additionalProperties, property)); |
| 1421 |
if (res.instance !== result.instance[property]) result.instance[property] = res.instance; |
| 1422 |
result.importErrors(res); |
| 1423 |
} |
| 1424 |
} |
| 1425 |
/** |
| 1426 |
* Validates patternProperties |
| 1427 |
* @param instance |
| 1428 |
* @param schema |
| 1429 |
* @param options |
| 1430 |
* @param ctx |
| 1431 |
* @return {String|null|ValidatorResult} |
| 1432 |
*/ |
| 1433 |
validators.patternProperties = function validatePatternProperties(instance, schema, options, ctx) { |
| 1434 |
if (!this.types.object(instance)) return; |
| 1435 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1436 |
var patternProperties = schema.patternProperties || {}; |
| 1437 |
for (var property in instance) { |
| 1438 |
var test = true; |
| 1439 |
for (var pattern in patternProperties) { |
| 1440 |
var subschema = patternProperties[pattern]; |
| 1441 |
if (subschema === void 0) continue; |
| 1442 |
else if (subschema === null) throw new SchemaError("Unexpected null, expected schema in \"patternProperties\""); |
| 1443 |
try { |
| 1444 |
var regexp = new RegExp(pattern, "u"); |
| 1445 |
} catch (_e) { |
| 1446 |
regexp = new RegExp(pattern); |
| 1447 |
} |
| 1448 |
if (!regexp.test(property)) continue; |
| 1449 |
test = false; |
| 1450 |
if (typeof options.preValidateProperty == "function") options.preValidateProperty(instance, property, subschema, options, ctx); |
| 1451 |
var res = this.validateSchema(instance[property], subschema, options, ctx.makeChild(subschema, property)); |
| 1452 |
if (res.instance !== result.instance[property]) result.instance[property] = res.instance; |
| 1453 |
result.importErrors(res); |
| 1454 |
} |
| 1455 |
if (test) testAdditionalProperty.call(this, instance, schema, options, ctx, property, result); |
| 1456 |
} |
| 1457 |
return result; |
| 1458 |
}; |
| 1459 |
/** |
| 1460 |
* Validates additionalProperties |
| 1461 |
* @param instance |
| 1462 |
* @param schema |
| 1463 |
* @param options |
| 1464 |
* @param ctx |
| 1465 |
* @return {String|null|ValidatorResult} |
| 1466 |
*/ |
| 1467 |
validators.additionalProperties = function validateAdditionalProperties(instance, schema, options, ctx) { |
| 1468 |
if (!this.types.object(instance)) return; |
| 1469 |
if (schema.patternProperties) return null; |
| 1470 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1471 |
for (var property in instance) testAdditionalProperty.call(this, instance, schema, options, ctx, property, result); |
| 1472 |
return result; |
| 1473 |
}; |
| 1474 |
/** |
| 1475 |
* Validates whether the instance value is at least of a certain length, when the instance value is a string. |
| 1476 |
* @param instance |
| 1477 |
* @param schema |
| 1478 |
* @return {String|null} |
| 1479 |
*/ |
| 1480 |
validators.minProperties = function validateMinProperties(instance, schema, options, ctx) { |
| 1481 |
if (!this.types.object(instance)) return; |
| 1482 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1483 |
if (!(Object.keys(instance).length >= schema.minProperties)) result.addError({ |
| 1484 |
name: "minProperties", |
| 1485 |
argument: schema.minProperties, |
| 1486 |
message: "does not meet minimum property length of " + schema.minProperties |
| 1487 |
}); |
| 1488 |
return result; |
| 1489 |
}; |
| 1490 |
/** |
| 1491 |
* Validates whether the instance value is at most of a certain length, when the instance value is a string. |
| 1492 |
* @param instance |
| 1493 |
* @param schema |
| 1494 |
* @return {String|null} |
| 1495 |
*/ |
| 1496 |
validators.maxProperties = function validateMaxProperties(instance, schema, options, ctx) { |
| 1497 |
if (!this.types.object(instance)) return; |
| 1498 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1499 |
if (!(Object.keys(instance).length <= schema.maxProperties)) result.addError({ |
| 1500 |
name: "maxProperties", |
| 1501 |
argument: schema.maxProperties, |
| 1502 |
message: "does not meet maximum property length of " + schema.maxProperties |
| 1503 |
}); |
| 1504 |
return result; |
| 1505 |
}; |
| 1506 |
/** |
| 1507 |
* Validates items when instance is an array |
| 1508 |
* @param instance |
| 1509 |
* @param schema |
| 1510 |
* @param options |
| 1511 |
* @param ctx |
| 1512 |
* @return {String|null|ValidatorResult} |
| 1513 |
*/ |
| 1514 |
validators.items = function validateItems(instance, schema, options, ctx) { |
| 1515 |
var self = this; |
| 1516 |
if (!this.types.array(instance)) return; |
| 1517 |
if (schema.items === void 0) return; |
| 1518 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1519 |
instance.every(function(value, i) { |
| 1520 |
if (Array.isArray(schema.items)) var items = schema.items[i] === void 0 ? schema.additionalItems : schema.items[i]; |
| 1521 |
else var items = schema.items; |
| 1522 |
if (items === void 0) return true; |
| 1523 |
if (items === false) { |
| 1524 |
result.addError({ |
| 1525 |
name: "items", |
| 1526 |
message: "additionalItems not permitted" |
| 1527 |
}); |
| 1528 |
return false; |
| 1529 |
} |
| 1530 |
var res = self.validateSchema(value, items, options, ctx.makeChild(items, i)); |
| 1531 |
if (res.instance !== result.instance[i]) result.instance[i] = res.instance; |
| 1532 |
result.importErrors(res); |
| 1533 |
return true; |
| 1534 |
}); |
| 1535 |
return result; |
| 1536 |
}; |
| 1537 |
/** |
| 1538 |
* Validates the "contains" keyword |
| 1539 |
* @param instance |
| 1540 |
* @param schema |
| 1541 |
* @param options |
| 1542 |
* @param ctx |
| 1543 |
* @return {String|null|ValidatorResult} |
| 1544 |
*/ |
| 1545 |
validators.contains = function validateContains(instance, schema, options, ctx) { |
| 1546 |
var self = this; |
| 1547 |
if (!this.types.array(instance)) return; |
| 1548 |
if (schema.contains === void 0) return; |
| 1549 |
if (!helpers.isSchema(schema.contains)) throw new Error("Expected \"contains\" keyword to be a schema"); |
| 1550 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1551 |
if (instance.some(function(value, i) { |
| 1552 |
return self.validateSchema(value, schema.contains, options, ctx.makeChild(schema.contains, i)).errors.length === 0; |
| 1553 |
}) === false) result.addError({ |
| 1554 |
name: "contains", |
| 1555 |
argument: schema.contains, |
| 1556 |
message: "must contain an item matching given schema" |
| 1557 |
}); |
| 1558 |
return result; |
| 1559 |
}; |
| 1560 |
/** |
| 1561 |
* Validates minimum and exclusiveMinimum when the type of the instance value is a number. |
| 1562 |
* @param instance |
| 1563 |
* @param schema |
| 1564 |
* @return {String|null} |
| 1565 |
*/ |
| 1566 |
validators.minimum = function validateMinimum(instance, schema, options, ctx) { |
| 1567 |
if (!this.types.number(instance)) return; |
| 1568 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1569 |
if (schema.exclusiveMinimum && schema.exclusiveMinimum === true) { |
| 1570 |
if (!(instance > schema.minimum)) result.addError({ |
| 1571 |
name: "minimum", |
| 1572 |
argument: schema.minimum, |
| 1573 |
message: "must be greater than " + schema.minimum |
| 1574 |
}); |
| 1575 |
} else if (!(instance >= schema.minimum)) result.addError({ |
| 1576 |
name: "minimum", |
| 1577 |
argument: schema.minimum, |
| 1578 |
message: "must be greater than or equal to " + schema.minimum |
| 1579 |
}); |
| 1580 |
return result; |
| 1581 |
}; |
| 1582 |
/** |
| 1583 |
* Validates maximum and exclusiveMaximum when the type of the instance value is a number. |
| 1584 |
* @param instance |
| 1585 |
* @param schema |
| 1586 |
* @return {String|null} |
| 1587 |
*/ |
| 1588 |
validators.maximum = function validateMaximum(instance, schema, options, ctx) { |
| 1589 |
if (!this.types.number(instance)) return; |
| 1590 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1591 |
if (schema.exclusiveMaximum && schema.exclusiveMaximum === true) { |
| 1592 |
if (!(instance < schema.maximum)) result.addError({ |
| 1593 |
name: "maximum", |
| 1594 |
argument: schema.maximum, |
| 1595 |
message: "must be less than " + schema.maximum |
| 1596 |
}); |
| 1597 |
} else if (!(instance <= schema.maximum)) result.addError({ |
| 1598 |
name: "maximum", |
| 1599 |
argument: schema.maximum, |
| 1600 |
message: "must be less than or equal to " + schema.maximum |
| 1601 |
}); |
| 1602 |
return result; |
| 1603 |
}; |
| 1604 |
/** |
| 1605 |
* Validates the number form of exclusiveMinimum when the type of the instance value is a number. |
| 1606 |
* @param instance |
| 1607 |
* @param schema |
| 1608 |
* @return {String|null} |
| 1609 |
*/ |
| 1610 |
validators.exclusiveMinimum = function validateExclusiveMinimum(instance, schema, options, ctx) { |
| 1611 |
if (typeof schema.exclusiveMinimum === "boolean") return; |
| 1612 |
if (!this.types.number(instance)) return; |
| 1613 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1614 |
if (!(instance > schema.exclusiveMinimum)) result.addError({ |
| 1615 |
name: "exclusiveMinimum", |
| 1616 |
argument: schema.exclusiveMinimum, |
| 1617 |
message: "must be strictly greater than " + schema.exclusiveMinimum |
| 1618 |
}); |
| 1619 |
return result; |
| 1620 |
}; |
| 1621 |
/** |
| 1622 |
* Validates the number form of exclusiveMaximum when the type of the instance value is a number. |
| 1623 |
* @param instance |
| 1624 |
* @param schema |
| 1625 |
* @return {String|null} |
| 1626 |
*/ |
| 1627 |
validators.exclusiveMaximum = function validateExclusiveMaximum(instance, schema, options, ctx) { |
| 1628 |
if (typeof schema.exclusiveMaximum === "boolean") return; |
| 1629 |
if (!this.types.number(instance)) return; |
| 1630 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1631 |
if (!(instance < schema.exclusiveMaximum)) result.addError({ |
| 1632 |
name: "exclusiveMaximum", |
| 1633 |
argument: schema.exclusiveMaximum, |
| 1634 |
message: "must be strictly less than " + schema.exclusiveMaximum |
| 1635 |
}); |
| 1636 |
return result; |
| 1637 |
}; |
| 1638 |
/** |
| 1639 |
* Perform validation for multipleOf and divisibleBy, which are essentially the same. |
| 1640 |
* @param instance |
| 1641 |
* @param schema |
| 1642 |
* @param validationType |
| 1643 |
* @param errorMessage |
| 1644 |
* @returns {String|null} |
| 1645 |
*/ |
| 1646 |
var validateMultipleOfOrDivisbleBy = function validateMultipleOfOrDivisbleBy(instance, schema, options, ctx, validationType, errorMessage) { |
| 1647 |
if (!this.types.number(instance)) return; |
| 1648 |
var validationArgument = schema[validationType]; |
| 1649 |
if (validationArgument == 0) throw new SchemaError(validationType + " cannot be zero"); |
| 1650 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1651 |
var instanceDecimals = helpers.getDecimalPlaces(instance); |
| 1652 |
var divisorDecimals = helpers.getDecimalPlaces(validationArgument); |
| 1653 |
var multiplier = Math.pow(10, Math.max(instanceDecimals, divisorDecimals)); |
| 1654 |
if (Math.round(instance * multiplier) % Math.round(validationArgument * multiplier) !== 0) result.addError({ |
| 1655 |
name: validationType, |
| 1656 |
argument: validationArgument, |
| 1657 |
message: errorMessage + JSON.stringify(validationArgument) |
| 1658 |
}); |
| 1659 |
return result; |
| 1660 |
}; |
| 1661 |
/** |
| 1662 |
* Validates divisibleBy when the type of the instance value is a number. |
| 1663 |
* @param instance |
| 1664 |
* @param schema |
| 1665 |
* @return {String|null} |
| 1666 |
*/ |
| 1667 |
validators.multipleOf = function validateMultipleOf(instance, schema, options, ctx) { |
| 1668 |
return validateMultipleOfOrDivisbleBy.call(this, instance, schema, options, ctx, "multipleOf", "is not a multiple of (divisible by) "); |
| 1669 |
}; |
| 1670 |
/** |
| 1671 |
* Validates multipleOf when the type of the instance value is a number. |
| 1672 |
* @param instance |
| 1673 |
* @param schema |
| 1674 |
* @return {String|null} |
| 1675 |
*/ |
| 1676 |
validators.divisibleBy = function validateDivisibleBy(instance, schema, options, ctx) { |
| 1677 |
return validateMultipleOfOrDivisbleBy.call(this, instance, schema, options, ctx, "divisibleBy", "is not divisible by (multiple of) "); |
| 1678 |
}; |
| 1679 |
/** |
| 1680 |
* Validates whether the instance value is present. |
| 1681 |
* @param instance |
| 1682 |
* @param schema |
| 1683 |
* @return {String|null} |
| 1684 |
*/ |
| 1685 |
validators.required = function validateRequired(instance, schema, options, ctx) { |
| 1686 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1687 |
if (instance === void 0 && schema.required === true) result.addError({ |
| 1688 |
name: "required", |
| 1689 |
message: "is required" |
| 1690 |
}); |
| 1691 |
else if (this.types.object(instance) && Array.isArray(schema.required)) schema.required.forEach(function(n) { |
| 1692 |
if (getEnumerableProperty(instance, n) === void 0) result.addError({ |
| 1693 |
name: "required", |
| 1694 |
argument: n, |
| 1695 |
message: "requires property " + JSON.stringify(n) |
| 1696 |
}); |
| 1697 |
}); |
| 1698 |
return result; |
| 1699 |
}; |
| 1700 |
/** |
| 1701 |
* Validates whether the instance value matches the regular expression, when the instance value is a string. |
| 1702 |
* @param instance |
| 1703 |
* @param schema |
| 1704 |
* @return {String|null} |
| 1705 |
*/ |
| 1706 |
validators.pattern = function validatePattern(instance, schema, options, ctx) { |
| 1707 |
if (!this.types.string(instance)) return; |
| 1708 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1709 |
var pattern = schema.pattern; |
| 1710 |
try { |
| 1711 |
var regexp = new RegExp(pattern, "u"); |
| 1712 |
} catch (_e) { |
| 1713 |
regexp = new RegExp(pattern); |
| 1714 |
} |
| 1715 |
if (!instance.match(regexp)) result.addError({ |
| 1716 |
name: "pattern", |
| 1717 |
argument: schema.pattern, |
| 1718 |
message: "does not match pattern " + JSON.stringify(schema.pattern.toString()) |
| 1719 |
}); |
| 1720 |
return result; |
| 1721 |
}; |
| 1722 |
/** |
| 1723 |
* Validates whether the instance value is of a certain defined format or a custom |
| 1724 |
* format. |
| 1725 |
* The following formats are supported for string types: |
| 1726 |
* - date-time |
| 1727 |
* - date |
| 1728 |
* - time |
| 1729 |
* - ip-address |
| 1730 |
* - ipv6 |
| 1731 |
* - uri |
| 1732 |
* - color |
| 1733 |
* - host-name |
| 1734 |
* - alpha |
| 1735 |
* - alpha-numeric |
| 1736 |
* - utc-millisec |
| 1737 |
* @param instance |
| 1738 |
* @param schema |
| 1739 |
* @param [options] |
| 1740 |
* @param [ctx] |
| 1741 |
* @return {String|null} |
| 1742 |
*/ |
| 1743 |
validators.format = function validateFormat(instance, schema, options, ctx) { |
| 1744 |
if (instance === void 0) return; |
| 1745 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1746 |
if (!result.disableFormat && !helpers.isFormat(instance, schema.format, this)) result.addError({ |
| 1747 |
name: "format", |
| 1748 |
argument: schema.format, |
| 1749 |
message: "does not conform to the " + JSON.stringify(schema.format) + " format" |
| 1750 |
}); |
| 1751 |
return result; |
| 1752 |
}; |
| 1753 |
/** |
| 1754 |
* Validates whether the instance value is at least of a certain length, when the instance value is a string. |
| 1755 |
* @param instance |
| 1756 |
* @param schema |
| 1757 |
* @return {String|null} |
| 1758 |
*/ |
| 1759 |
validators.minLength = function validateMinLength(instance, schema, options, ctx) { |
| 1760 |
if (!this.types.string(instance)) return; |
| 1761 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1762 |
var hsp = instance.match(/[\uDC00-\uDFFF]/g); |
| 1763 |
if (!(instance.length - (hsp ? hsp.length : 0) >= schema.minLength)) result.addError({ |
| 1764 |
name: "minLength", |
| 1765 |
argument: schema.minLength, |
| 1766 |
message: "does not meet minimum length of " + schema.minLength |
| 1767 |
}); |
| 1768 |
return result; |
| 1769 |
}; |
| 1770 |
/** |
| 1771 |
* Validates whether the instance value is at most of a certain length, when the instance value is a string. |
| 1772 |
* @param instance |
| 1773 |
* @param schema |
| 1774 |
* @return {String|null} |
| 1775 |
*/ |
| 1776 |
validators.maxLength = function validateMaxLength(instance, schema, options, ctx) { |
| 1777 |
if (!this.types.string(instance)) return; |
| 1778 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1779 |
var hsp = instance.match(/[\uDC00-\uDFFF]/g); |
| 1780 |
if (!(instance.length - (hsp ? hsp.length : 0) <= schema.maxLength)) result.addError({ |
| 1781 |
name: "maxLength", |
| 1782 |
argument: schema.maxLength, |
| 1783 |
message: "does not meet maximum length of " + schema.maxLength |
| 1784 |
}); |
| 1785 |
return result; |
| 1786 |
}; |
| 1787 |
/** |
| 1788 |
* Validates whether instance contains at least a minimum number of items, when the instance is an Array. |
| 1789 |
* @param instance |
| 1790 |
* @param schema |
| 1791 |
* @return {String|null} |
| 1792 |
*/ |
| 1793 |
validators.minItems = function validateMinItems(instance, schema, options, ctx) { |
| 1794 |
if (!this.types.array(instance)) return; |
| 1795 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1796 |
if (!(instance.length >= schema.minItems)) result.addError({ |
| 1797 |
name: "minItems", |
| 1798 |
argument: schema.minItems, |
| 1799 |
message: "does not meet minimum length of " + schema.minItems |
| 1800 |
}); |
| 1801 |
return result; |
| 1802 |
}; |
| 1803 |
/** |
| 1804 |
* Validates whether instance contains no more than a maximum number of items, when the instance is an Array. |
| 1805 |
* @param instance |
| 1806 |
* @param schema |
| 1807 |
* @return {String|null} |
| 1808 |
*/ |
| 1809 |
validators.maxItems = function validateMaxItems(instance, schema, options, ctx) { |
| 1810 |
if (!this.types.array(instance)) return; |
| 1811 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1812 |
if (!(instance.length <= schema.maxItems)) result.addError({ |
| 1813 |
name: "maxItems", |
| 1814 |
argument: schema.maxItems, |
| 1815 |
message: "does not meet maximum length of " + schema.maxItems |
| 1816 |
}); |
| 1817 |
return result; |
| 1818 |
}; |
| 1819 |
/** |
| 1820 |
* Deep compares arrays for duplicates |
| 1821 |
* @param v |
| 1822 |
* @param i |
| 1823 |
* @param a |
| 1824 |
* @private |
| 1825 |
* @return {boolean} |
| 1826 |
*/ |
| 1827 |
function testArrays(v, i, a) { |
| 1828 |
var j; |
| 1829 |
var len = a.length; |
| 1830 |
for (j = i + 1; j < len; j++) if (helpers.deepCompareStrict(v, a[j])) return false; |
| 1831 |
return true; |
| 1832 |
} |
| 1833 |
/** |
| 1834 |
* Validates whether there are no duplicates, when the instance is an Array. |
| 1835 |
* @param instance |
| 1836 |
* @return {String|null} |
| 1837 |
*/ |
| 1838 |
validators.uniqueItems = function validateUniqueItems(instance, schema, options, ctx) { |
| 1839 |
if (schema.uniqueItems !== true) return; |
| 1840 |
if (!this.types.array(instance)) return; |
| 1841 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1842 |
if (!instance.every(testArrays)) result.addError({ |
| 1843 |
name: "uniqueItems", |
| 1844 |
message: "contains duplicate item" |
| 1845 |
}); |
| 1846 |
return result; |
| 1847 |
}; |
| 1848 |
/** |
| 1849 |
* Validate for the presence of dependency properties, if the instance is an object. |
| 1850 |
* @param instance |
| 1851 |
* @param schema |
| 1852 |
* @param options |
| 1853 |
* @param ctx |
| 1854 |
* @return {null|ValidatorResult} |
| 1855 |
*/ |
| 1856 |
validators.dependencies = function validateDependencies(instance, schema, options, ctx) { |
| 1857 |
if (!this.types.object(instance)) return; |
| 1858 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1859 |
for (var property in schema.dependencies) { |
| 1860 |
if (instance[property] === void 0) continue; |
| 1861 |
var dep = schema.dependencies[property]; |
| 1862 |
var childContext = ctx.makeChild(dep, property); |
| 1863 |
if (typeof dep == "string") dep = [dep]; |
| 1864 |
if (Array.isArray(dep)) dep.forEach(function(prop) { |
| 1865 |
if (instance[prop] === void 0) result.addError({ |
| 1866 |
name: "dependencies", |
| 1867 |
argument: childContext.propertyPath, |
| 1868 |
message: "property " + prop + " not found, required by " + childContext.propertyPath |
| 1869 |
}); |
| 1870 |
}); |
| 1871 |
else { |
| 1872 |
var res = this.validateSchema(instance, dep, options, childContext); |
| 1873 |
if (result.instance !== res.instance) result.instance = res.instance; |
| 1874 |
if (res && res.errors.length) { |
| 1875 |
result.addError({ |
| 1876 |
name: "dependencies", |
| 1877 |
argument: childContext.propertyPath, |
| 1878 |
message: "does not meet dependency required by " + childContext.propertyPath |
| 1879 |
}); |
| 1880 |
result.importErrors(res); |
| 1881 |
} |
| 1882 |
} |
| 1883 |
} |
| 1884 |
return result; |
| 1885 |
}; |
| 1886 |
/** |
| 1887 |
* Validates whether the instance value is one of the enumerated values. |
| 1888 |
* |
| 1889 |
* @param instance |
| 1890 |
* @param schema |
| 1891 |
* @return {ValidatorResult|null} |
| 1892 |
*/ |
| 1893 |
validators["enum"] = function validateEnum(instance, schema, options, ctx) { |
| 1894 |
if (instance === void 0) return null; |
| 1895 |
if (!Array.isArray(schema["enum"])) throw new SchemaError("enum expects an array", schema); |
| 1896 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1897 |
if (!schema["enum"].some(helpers.deepCompareStrict.bind(null, instance))) result.addError({ |
| 1898 |
name: "enum", |
| 1899 |
argument: schema["enum"], |
| 1900 |
message: "is not one of enum values: " + schema["enum"].map(String).join(",") |
| 1901 |
}); |
| 1902 |
return result; |
| 1903 |
}; |
| 1904 |
/** |
| 1905 |
* Validates whether the instance exactly matches a given value |
| 1906 |
* |
| 1907 |
* @param instance |
| 1908 |
* @param schema |
| 1909 |
* @return {ValidatorResult|null} |
| 1910 |
*/ |
| 1911 |
validators["const"] = function validateEnum(instance, schema, options, ctx) { |
| 1912 |
if (instance === void 0) return null; |
| 1913 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1914 |
if (!helpers.deepCompareStrict(schema["const"], instance)) result.addError({ |
| 1915 |
name: "const", |
| 1916 |
argument: schema["const"], |
| 1917 |
message: "does not exactly match expected constant: " + schema["const"] |
| 1918 |
}); |
| 1919 |
return result; |
| 1920 |
}; |
| 1921 |
/** |
| 1922 |
* Validates whether the instance if of a prohibited type. |
| 1923 |
* @param instance |
| 1924 |
* @param schema |
| 1925 |
* @param options |
| 1926 |
* @param ctx |
| 1927 |
* @return {null|ValidatorResult} |
| 1928 |
*/ |
| 1929 |
validators.not = validators.disallow = function validateNot(instance, schema, options, ctx) { |
| 1930 |
var self = this; |
| 1931 |
if (instance === void 0) return null; |
| 1932 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 1933 |
var notTypes = schema.not || schema.disallow; |
| 1934 |
if (!notTypes) return null; |
| 1935 |
if (!Array.isArray(notTypes)) notTypes = [notTypes]; |
| 1936 |
notTypes.forEach(function(type) { |
| 1937 |
if (self.testType(instance, schema, options, ctx, type)) { |
| 1938 |
var schemaId = type && (type.$id || type.id) || type; |
| 1939 |
result.addError({ |
| 1940 |
name: "not", |
| 1941 |
argument: schemaId, |
| 1942 |
message: "is of prohibited type " + schemaId |
| 1943 |
}); |
| 1944 |
} |
| 1945 |
}); |
| 1946 |
return result; |
| 1947 |
}; |
| 1948 |
module.exports = attribute; |
| 1949 |
})); |
| 1950 |
|
| 1951 |
//#endregion |
| 1952 |
//#region node_modules/jsonschema/lib/scan.js |
| 1953 |
var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => { |
| 1954 |
var helpers = require_helpers(); |
| 1955 |
module.exports.SchemaScanResult = SchemaScanResult; |
| 1956 |
function SchemaScanResult(found, ref) { |
| 1957 |
this.id = found; |
| 1958 |
this.ref = ref; |
| 1959 |
} |
| 1960 |
/** |
| 1961 |
* Adds a schema with a certain urn to the Validator instance. |
| 1962 |
* @param string uri |
| 1963 |
* @param object schema |
| 1964 |
* @return {Object} |
| 1965 |
*/ |
| 1966 |
module.exports.scan = function scan(base, schema) { |
| 1967 |
function scanSchema(baseuri, schema) { |
| 1968 |
if (!schema || typeof schema != "object") return; |
| 1969 |
if (schema.$ref) { |
| 1970 |
let resolvedUri = helpers.resolveUrl(baseuri, schema.$ref); |
| 1971 |
ref[resolvedUri] = ref[resolvedUri] ? ref[resolvedUri] + 1 : 0; |
| 1972 |
return; |
| 1973 |
} |
| 1974 |
var id = schema.$id || schema.id; |
| 1975 |
let resolvedBase = helpers.resolveUrl(baseuri, id); |
| 1976 |
var ourBase = id ? resolvedBase : baseuri; |
| 1977 |
if (ourBase) { |
| 1978 |
if (ourBase.indexOf("#") < 0) ourBase += "#"; |
| 1979 |
if (found[ourBase]) { |
| 1980 |
if (!helpers.deepCompareStrict(found[ourBase], schema)) throw new Error("Schema <" + ourBase + "> already exists with different definition"); |
| 1981 |
return found[ourBase]; |
| 1982 |
} |
| 1983 |
found[ourBase] = schema; |
| 1984 |
if (ourBase[ourBase.length - 1] == "#") found[ourBase.substring(0, ourBase.length - 1)] = schema; |
| 1985 |
} |
| 1986 |
scanArray(ourBase + "/items", Array.isArray(schema.items) ? schema.items : [schema.items]); |
| 1987 |
scanArray(ourBase + "/extends", Array.isArray(schema.extends) ? schema.extends : [schema.extends]); |
| 1988 |
scanSchema(ourBase + "/additionalItems", schema.additionalItems); |
| 1989 |
scanObject(ourBase + "/properties", schema.properties); |
| 1990 |
scanSchema(ourBase + "/additionalProperties", schema.additionalProperties); |
| 1991 |
scanObject(ourBase + "/definitions", schema.definitions); |
| 1992 |
scanObject(ourBase + "/patternProperties", schema.patternProperties); |
| 1993 |
scanObject(ourBase + "/dependencies", schema.dependencies); |
| 1994 |
scanArray(ourBase + "/disallow", schema.disallow); |
| 1995 |
scanArray(ourBase + "/allOf", schema.allOf); |
| 1996 |
scanArray(ourBase + "/anyOf", schema.anyOf); |
| 1997 |
scanArray(ourBase + "/oneOf", schema.oneOf); |
| 1998 |
scanSchema(ourBase + "/not", schema.not); |
| 1999 |
} |
| 2000 |
function scanArray(baseuri, schemas) { |
| 2001 |
if (!Array.isArray(schemas)) return; |
| 2002 |
for (var i = 0; i < schemas.length; i++) scanSchema(baseuri + "/" + i, schemas[i]); |
| 2003 |
} |
| 2004 |
function scanObject(baseuri, schemas) { |
| 2005 |
if (!schemas || typeof schemas != "object") return; |
| 2006 |
for (var p in schemas) scanSchema(baseuri + "/" + p, schemas[p]); |
| 2007 |
} |
| 2008 |
var found = {}; |
| 2009 |
var ref = {}; |
| 2010 |
scanSchema(base, schema); |
| 2011 |
return new SchemaScanResult(found, ref); |
| 2012 |
}; |
| 2013 |
})); |
| 2014 |
|
| 2015 |
//#endregion |
| 2016 |
//#region node_modules/jsonschema/lib/validator.js |
| 2017 |
var require_validator = /* @__PURE__ */ __commonJSMin(((exports, module) => { |
| 2018 |
var attribute = require_attribute(); |
| 2019 |
var helpers = require_helpers(); |
| 2020 |
var scanSchema = require_scan().scan; |
| 2021 |
var ValidatorResult = helpers.ValidatorResult; |
| 2022 |
var ValidatorResultError = helpers.ValidatorResultError; |
| 2023 |
var SchemaError = helpers.SchemaError; |
| 2024 |
var SchemaContext = helpers.SchemaContext; |
| 2025 |
var anonymousBase = "/"; |
| 2026 |
/** |
| 2027 |
* Creates a new Validator object |
| 2028 |
* @name Validator |
| 2029 |
* @constructor |
| 2030 |
*/ |
| 2031 |
var Validator = function Validator() { |
| 2032 |
this.customFormats = Object.create(Validator.prototype.customFormats); |
| 2033 |
this.schemas = {}; |
| 2034 |
this.unresolvedRefs = []; |
| 2035 |
this.types = Object.create(types); |
| 2036 |
this.attributes = Object.create(attribute.validators); |
| 2037 |
}; |
| 2038 |
Validator.prototype.customFormats = {}; |
| 2039 |
Validator.prototype.schemas = null; |
| 2040 |
Validator.prototype.types = null; |
| 2041 |
Validator.prototype.attributes = null; |
| 2042 |
Validator.prototype.unresolvedRefs = null; |
| 2043 |
/** |
| 2044 |
* Adds a schema with a certain urn to the Validator instance. |
| 2045 |
* @param schema |
| 2046 |
* @param urn |
| 2047 |
* @return {Object} |
| 2048 |
*/ |
| 2049 |
Validator.prototype.addSchema = function addSchema(schema, base) { |
| 2050 |
var self = this; |
| 2051 |
if (!schema) return null; |
| 2052 |
var scan = scanSchema(base || anonymousBase, schema); |
| 2053 |
var ourUri = base || schema.$id || schema.id; |
| 2054 |
for (var uri in scan.id) this.schemas[uri] = scan.id[uri]; |
| 2055 |
for (var uri in scan.ref) this.unresolvedRefs.push(uri); |
| 2056 |
this.unresolvedRefs = this.unresolvedRefs.filter(function(uri) { |
| 2057 |
return typeof self.schemas[uri] === "undefined"; |
| 2058 |
}); |
| 2059 |
return this.schemas[ourUri]; |
| 2060 |
}; |
| 2061 |
Validator.prototype.addSubSchemaArray = function addSubSchemaArray(baseuri, schemas) { |
| 2062 |
if (!Array.isArray(schemas)) return; |
| 2063 |
for (var i = 0; i < schemas.length; i++) this.addSubSchema(baseuri, schemas[i]); |
| 2064 |
}; |
| 2065 |
Validator.prototype.addSubSchemaObject = function addSubSchemaArray(baseuri, schemas) { |
| 2066 |
if (!schemas || typeof schemas != "object") return; |
| 2067 |
for (var p in schemas) this.addSubSchema(baseuri, schemas[p]); |
| 2068 |
}; |
| 2069 |
/** |
| 2070 |
* Sets all the schemas of the Validator instance. |
| 2071 |
* @param schemas |
| 2072 |
*/ |
| 2073 |
Validator.prototype.setSchemas = function setSchemas(schemas) { |
| 2074 |
this.schemas = schemas; |
| 2075 |
}; |
| 2076 |
/** |
| 2077 |
* Returns the schema of a certain urn |
| 2078 |
* @param urn |
| 2079 |
*/ |
| 2080 |
Validator.prototype.getSchema = function getSchema(urn) { |
| 2081 |
return this.schemas[urn]; |
| 2082 |
}; |
| 2083 |
/** |
| 2084 |
* Validates instance against the provided schema |
| 2085 |
* @param instance |
| 2086 |
* @param schema |
| 2087 |
* @param [options] |
| 2088 |
* @param [ctx] |
| 2089 |
* @return {Array} |
| 2090 |
*/ |
| 2091 |
Validator.prototype.validate = function validate(instance, schema, options, ctx) { |
| 2092 |
if (typeof schema !== "boolean" && typeof schema !== "object" || schema === null) throw new SchemaError("Expected `schema` to be an object or boolean"); |
| 2093 |
if (!options) options = {}; |
| 2094 |
var id = schema.$id || schema.id; |
| 2095 |
let base = helpers.resolveUrl(options.base, id || ""); |
| 2096 |
if (!ctx) { |
| 2097 |
ctx = new SchemaContext(schema, options, [], base, Object.create(this.schemas)); |
| 2098 |
if (!ctx.schemas[base]) ctx.schemas[base] = schema; |
| 2099 |
var found = scanSchema(base, schema); |
| 2100 |
for (var n in found.id) { |
| 2101 |
var sch = found.id[n]; |
| 2102 |
ctx.schemas[n] = sch; |
| 2103 |
} |
| 2104 |
} |
| 2105 |
if (options.required && instance === void 0) { |
| 2106 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 2107 |
result.addError("is required, but is undefined"); |
| 2108 |
return result; |
| 2109 |
} |
| 2110 |
var result = this.validateSchema(instance, schema, options, ctx); |
| 2111 |
if (!result) throw new Error("Result undefined"); |
| 2112 |
else if (options.throwAll && result.errors.length) throw new ValidatorResultError(result); |
| 2113 |
return result; |
| 2114 |
}; |
| 2115 |
/** |
| 2116 |
* @param Object schema |
| 2117 |
* @return mixed schema uri or false |
| 2118 |
*/ |
| 2119 |
function shouldResolve(schema) { |
| 2120 |
var ref = typeof schema === "string" ? schema : schema.$ref; |
| 2121 |
if (typeof ref == "string") return ref; |
| 2122 |
return false; |
| 2123 |
} |
| 2124 |
/** |
| 2125 |
* Validates an instance against the schema (the actual work horse) |
| 2126 |
* @param instance |
| 2127 |
* @param schema |
| 2128 |
* @param options |
| 2129 |
* @param ctx |
| 2130 |
* @private |
| 2131 |
* @return {ValidatorResult} |
| 2132 |
*/ |
| 2133 |
Validator.prototype.validateSchema = function validateSchema(instance, schema, options, ctx) { |
| 2134 |
var result = new ValidatorResult(instance, schema, options, ctx); |
| 2135 |
if (typeof schema === "boolean") { |
| 2136 |
if (schema === true) schema = {}; |
| 2137 |
else if (schema === false) schema = { type: [] }; |
| 2138 |
} else if (!schema) throw new Error("schema is undefined"); |
| 2139 |
if (schema["extends"]) if (Array.isArray(schema["extends"])) { |
| 2140 |
var schemaobj = { |
| 2141 |
schema, |
| 2142 |
ctx |
| 2143 |
}; |
| 2144 |
schema["extends"].forEach(this.schemaTraverser.bind(this, schemaobj)); |
| 2145 |
schema = schemaobj.schema; |
| 2146 |
schemaobj.schema = null; |
| 2147 |
schemaobj.ctx = null; |
| 2148 |
schemaobj = null; |
| 2149 |
} else schema = helpers.deepMerge(schema, this.superResolve(schema["extends"], ctx)); |
| 2150 |
var switchSchema = shouldResolve(schema); |
| 2151 |
if (switchSchema) { |
| 2152 |
var resolved = this.resolve(schema, switchSchema, ctx); |
| 2153 |
var subctx = new SchemaContext(resolved.subschema, options, ctx.path, resolved.switchSchema, ctx.schemas); |
| 2154 |
return this.validateSchema(instance, resolved.subschema, options, subctx); |
| 2155 |
} |
| 2156 |
var skipAttributes = options && options.skipAttributes || []; |
| 2157 |
for (var key in schema) if (!attribute.ignoreProperties[key] && skipAttributes.indexOf(key) < 0) { |
| 2158 |
var validatorErr = null; |
| 2159 |
var validator = this.attributes[key]; |
| 2160 |
if (validator) validatorErr = validator.call(this, instance, schema, options, ctx); |
| 2161 |
else if (options.allowUnknownAttributes === false) throw new SchemaError("Unsupported attribute: " + key, schema); |
| 2162 |
if (validatorErr) result.importErrors(validatorErr); |
| 2163 |
} |
| 2164 |
if (typeof options.rewrite == "function") result.instance = options.rewrite.call(this, instance, schema, options, ctx); |
| 2165 |
return result; |
| 2166 |
}; |
| 2167 |
/** |
| 2168 |
* @private |
| 2169 |
* @param Object schema |
| 2170 |
* @param SchemaContext ctx |
| 2171 |
* @returns Object schema or resolved schema |
| 2172 |
*/ |
| 2173 |
Validator.prototype.schemaTraverser = function schemaTraverser(schemaobj, s) { |
| 2174 |
schemaobj.schema = helpers.deepMerge(schemaobj.schema, this.superResolve(s, schemaobj.ctx)); |
| 2175 |
}; |
| 2176 |
/** |
| 2177 |
* @private |
| 2178 |
* @param Object schema |
| 2179 |
* @param SchemaContext ctx |
| 2180 |
* @returns Object schema or resolved schema |
| 2181 |
*/ |
| 2182 |
Validator.prototype.superResolve = function superResolve(schema, ctx) { |
| 2183 |
var ref = shouldResolve(schema); |
| 2184 |
if (ref) return this.resolve(schema, ref, ctx).subschema; |
| 2185 |
return schema; |
| 2186 |
}; |
| 2187 |
/** |
| 2188 |
* @private |
| 2189 |
* @param Object schema |
| 2190 |
* @param Object switchSchema |
| 2191 |
* @param SchemaContext ctx |
| 2192 |
* @return Object resolved schemas {subschema:String, switchSchema: String} |
| 2193 |
* @throws SchemaError |
| 2194 |
*/ |
| 2195 |
Validator.prototype.resolve = function resolve(schema, switchSchema, ctx) { |
| 2196 |
switchSchema = ctx.resolve(switchSchema); |
| 2197 |
if (ctx.schemas[switchSchema]) return { |
| 2198 |
subschema: ctx.schemas[switchSchema], |
| 2199 |
switchSchema |
| 2200 |
}; |
| 2201 |
let fragment = new URL(switchSchema, "thismessage::/").hash; |
| 2202 |
var document = fragment && fragment.length && switchSchema.substr(0, switchSchema.length - fragment.length); |
| 2203 |
if (!document || !ctx.schemas[document]) throw new SchemaError("no such schema <" + switchSchema + ">", schema); |
| 2204 |
var subschema = helpers.objectGetPath(ctx.schemas[document], fragment.substr(1)); |
| 2205 |
if (subschema === void 0) throw new SchemaError("no such schema " + fragment + " located in <" + document + ">", schema); |
| 2206 |
return { |
| 2207 |
subschema, |
| 2208 |
switchSchema |
| 2209 |
}; |
| 2210 |
}; |
| 2211 |
/** |
| 2212 |
* Tests whether the instance if of a certain type. |
| 2213 |
* @private |
| 2214 |
* @param instance |
| 2215 |
* @param schema |
| 2216 |
* @param options |
| 2217 |
* @param ctx |
| 2218 |
* @param type |
| 2219 |
* @return {boolean} |
| 2220 |
*/ |
| 2221 |
Validator.prototype.testType = function validateType(instance, schema, options, ctx, type) { |
| 2222 |
if (type === void 0) return; |
| 2223 |
else if (type === null) throw new SchemaError("Unexpected null in \"type\" keyword"); |
| 2224 |
if (typeof this.types[type] == "function") return this.types[type].call(this, instance); |
| 2225 |
if (type && typeof type == "object") { |
| 2226 |
var res = this.validateSchema(instance, type, options, ctx); |
| 2227 |
return res === void 0 || !(res && res.errors.length); |
| 2228 |
} |
| 2229 |
return true; |
| 2230 |
}; |
| 2231 |
var types = Validator.prototype.types = {}; |
| 2232 |
types.string = function testString(instance) { |
| 2233 |
return typeof instance == "string"; |
| 2234 |
}; |
| 2235 |
types.number = function testNumber(instance) { |
| 2236 |
return typeof instance == "number" && isFinite(instance); |
| 2237 |
}; |
| 2238 |
types.integer = function testInteger(instance) { |
| 2239 |
return typeof instance == "number" && instance % 1 === 0; |
| 2240 |
}; |
| 2241 |
types.boolean = function testBoolean(instance) { |
| 2242 |
return typeof instance == "boolean"; |
| 2243 |
}; |
| 2244 |
types.array = function testArray(instance) { |
| 2245 |
return Array.isArray(instance); |
| 2246 |
}; |
| 2247 |
types["null"] = function testNull(instance) { |
| 2248 |
return instance === null; |
| 2249 |
}; |
| 2250 |
types.date = function testDate(instance) { |
| 2251 |
return instance instanceof Date; |
| 2252 |
}; |
| 2253 |
types.any = function testAny(instance) { |
| 2254 |
return true; |
| 2255 |
}; |
| 2256 |
types.object = function testObject(instance) { |
| 2257 |
return instance && typeof instance === "object" && !Array.isArray(instance) && !(instance instanceof Date); |
| 2258 |
}; |
| 2259 |
module.exports = Validator; |
| 2260 |
})); |
| 2261 |
|
| 2262 |
//#endregion |
| 2263 |
//#region node_modules/jsonschema/lib/index.js |
| 2264 |
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => { |
| 2265 |
var Validator = module.exports.Validator = require_validator(); |
| 2266 |
module.exports.ValidatorResult = require_helpers().ValidatorResult; |
| 2267 |
module.exports.ValidatorResultError = require_helpers().ValidatorResultError; |
| 2268 |
module.exports.ValidationError = require_helpers().ValidationError; |
| 2269 |
module.exports.SchemaError = require_helpers().SchemaError; |
| 2270 |
module.exports.SchemaScanResult = require_scan().SchemaScanResult; |
| 2271 |
module.exports.scan = require_scan().scan; |
| 2272 |
module.exports.validate = function(instance, schema, options) { |
| 2273 |
return new Validator().validate(instance, schema, options); |
| 2274 |
}; |
| 2275 |
})); |
| 2276 |
|
| 2277 |
//#endregion |
| 2278 |
//#region packages/packages/libs/editor-props/src/utils/validate-prop-value.ts |
| 2279 |
var import_lib = require_lib(); |
| 2280 |
function processValidationError(error) { |
| 2281 |
const detailed = { |
| 2282 |
path: error.path, |
| 2283 |
message: error.message, |
| 2284 |
schema: error.schema, |
| 2285 |
instance: error.instance, |
| 2286 |
name: error.name |
| 2287 |
}; |
| 2288 |
if (error.name === "anyOf" && error.schema && typeof error.schema === "object" && "anyOf" in error.schema) detailed.variants = (error.schema.anyOf || []).map((variantSchema, idx) => { |
| 2289 |
const variantResult = (0, import_lib.validate)(error.instance, variantSchema); |
| 2290 |
let discriminator = `variant-${idx}`; |
| 2291 |
if (variantSchema && typeof variantSchema === "object" && "properties" in variantSchema && variantSchema.properties && typeof variantSchema.properties === "object" && "$$type" in variantSchema.properties) { |
| 2292 |
const typeProperty = variantSchema.properties.$$type; |
| 2293 |
if (typeProperty && typeof typeProperty === "object" && "const" in typeProperty && typeof typeProperty.const === "string") discriminator = typeProperty.const; |
| 2294 |
} |
| 2295 |
return { |
| 2296 |
discriminator, |
| 2297 |
errors: variantResult.errors.map(processValidationError) |
| 2298 |
}; |
| 2299 |
}); |
| 2300 |
return detailed; |
| 2301 |
} |
| 2302 |
function formatDetailedErrors(errors, indent = "") { |
| 2303 |
const lines = []; |
| 2304 |
for (const error of errors) { |
| 2305 |
const pathStr = error.path.length > 0 ? error.path.join(".") : "root"; |
| 2306 |
lines.push(`${indent}Error at ${pathStr}: ${error.message}`); |
| 2307 |
if (error.variants && error.variants.length > 0) { |
| 2308 |
lines.push(`${indent} Tried ${error.variants.length} variant(s):`); |
| 2309 |
for (const variant of error.variants) { |
| 2310 |
lines.push(`${indent} - ${variant.discriminator}:`); |
| 2311 |
if (variant.errors.length === 0) lines.push(`${indent} (no errors - this variant matched!)`); |
| 2312 |
else for (const nestedError of variant.errors) { |
| 2313 |
const nestedPathStr = nestedError.path.length > 0 ? nestedError.path.join(".") : "root"; |
| 2314 |
lines.push(`${indent} ${nestedPathStr}: ${nestedError.message}`); |
| 2315 |
if (nestedError.variants && nestedError.variants.length > 0) lines.push(formatDetailedErrors([nestedError], `${indent} `)); |
| 2316 |
} |
| 2317 |
} |
| 2318 |
} |
| 2319 |
} |
| 2320 |
return lines.join("\n"); |
| 2321 |
} |
| 2322 |
var validatePropValue = (schema, value) => { |
| 2323 |
const jsonSchema = propTypeToJsonSchema(schema); |
| 2324 |
if (value === null) return { |
| 2325 |
valid: true, |
| 2326 |
errors: [], |
| 2327 |
errorMessages: [], |
| 2328 |
jsonSchema: JSON.stringify(propTypeToJsonSchema(schema)) |
| 2329 |
}; |
| 2330 |
const result = (0, import_lib.validate)(value, jsonSchema); |
| 2331 |
const detailedErrors = result.errors.map(processValidationError); |
| 2332 |
return { |
| 2333 |
valid: result.valid, |
| 2334 |
errors: result.errors, |
| 2335 |
errorMessages: formatDetailedErrors(detailedErrors), |
| 2336 |
jsonSchema: JSON.stringify(jsonSchema) |
| 2337 |
}; |
| 2338 |
}; |
| 2339 |
|
| 2340 |
//#endregion |
| 2341 |
//#region packages/packages/libs/editor-props/src/utils/is-transformable.ts |
| 2342 |
var transformableSchema = _elementor_schema.z.object({ |
| 2343 |
$$type: _elementor_schema.z.string(), |
| 2344 |
value: _elementor_schema.z.any(), |
| 2345 |
disabled: _elementor_schema.z.boolean().optional() |
| 2346 |
}); |
| 2347 |
var isTransformable = (value) => { |
| 2348 |
return transformableSchema.safeParse(value).success; |
| 2349 |
}; |
| 2350 |
|
| 2351 |
//#endregion |
| 2352 |
//#region packages/packages/libs/editor-props/src/utils/filter-empty-values.ts |
| 2353 |
var filterEmptyValues = (value) => { |
| 2354 |
if (isEmpty(value)) return null; |
| 2355 |
if (Array.isArray(value)) return value.map(filterEmptyValues).filter((item) => !isEmpty(item)); |
| 2356 |
if (typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, val]) => [key, filterEmptyValues(val)]).filter(([, val]) => !isEmpty(val))); |
| 2357 |
return value; |
| 2358 |
}; |
| 2359 |
var isEmpty = (value) => { |
| 2360 |
if (value && isTransformable(value)) return isEmpty(value.value); |
| 2361 |
return isNullish(value) || isNullishArray(value) || isNullishObject(value); |
| 2362 |
}; |
| 2363 |
var isNullish = (value) => value === null || value === void 0 || value === ""; |
| 2364 |
var isNullishArray = (value) => Array.isArray(value) && value.every(isEmpty); |
| 2365 |
var isNullishObject = (value) => { |
| 2366 |
return typeof value === "object" && isNullishArray(Object.values(value)); |
| 2367 |
}; |
| 2368 |
|
| 2369 |
//#endregion |
| 2370 |
//#region packages/packages/libs/editor-props/src/utils/is-overridable.ts |
| 2371 |
function isOverridable(value) { |
| 2372 |
return isTransformable(value) && value.$$type === "overridable"; |
| 2373 |
} |
| 2374 |
function rewrapOverridableValue(existing, newInner) { |
| 2375 |
return { |
| 2376 |
...existing, |
| 2377 |
value: { |
| 2378 |
...existing.value, |
| 2379 |
origin_value: newInner |
| 2380 |
} |
| 2381 |
}; |
| 2382 |
} |
| 2383 |
|
| 2384 |
//#endregion |
| 2385 |
//#region packages/packages/libs/editor-props/src/utils/merge-props.ts |
| 2386 |
function mergeProps(current, updates) { |
| 2387 |
let props = {}; |
| 2388 |
if (!Array.isArray(current)) props = structuredClone(current); |
| 2389 |
Object.entries(updates).forEach(([key, value]) => { |
| 2390 |
if (value === null || value === void 0) delete props[key]; |
| 2391 |
else props[key] = value; |
| 2392 |
}); |
| 2393 |
return props; |
| 2394 |
} |
| 2395 |
|
| 2396 |
//#endregion |
| 2397 |
//#region packages/packages/libs/editor-props/src/utils/prop-dependency-utils.ts |
| 2398 |
function isDependencyMet(dependency, values) { |
| 2399 |
if (!dependency?.terms.length) return { isMet: true }; |
| 2400 |
const { relation, terms } = dependency; |
| 2401 |
const method = getRelationMethod(relation); |
| 2402 |
const failingDependencies = []; |
| 2403 |
return { |
| 2404 |
isMet: terms[method]((term) => { |
| 2405 |
const result = isDependency(term) ? isDependencyMet(term, values).isMet : evaluateTerm(term, extractValue(term.path, values, term.nestedPath)?.value); |
| 2406 |
if (!result) failingDependencies.push(term); |
| 2407 |
return result; |
| 2408 |
}), |
| 2409 |
failingDependencies |
| 2410 |
}; |
| 2411 |
} |
| 2412 |
function evaluateTerm(term, actualValue) { |
| 2413 |
const { value: valueToCompare, operator } = term; |
| 2414 |
switch (operator) { |
| 2415 |
case "eq": |
| 2416 |
case "ne": return actualValue === valueToCompare === ("eq" === operator); |
| 2417 |
case "gt": |
| 2418 |
case "lte": |
| 2419 |
if (!isNumber(actualValue) || !isNumber(valueToCompare)) return false; |
| 2420 |
return Number(actualValue) > Number(valueToCompare) === ("gt" === operator); |
| 2421 |
case "lt": |
| 2422 |
case "gte": |
| 2423 |
if (!isNumber(actualValue) || !isNumber(valueToCompare)) return false; |
| 2424 |
return Number(actualValue) < Number(valueToCompare) === ("lt" === operator); |
| 2425 |
case "in": |
| 2426 |
case "nin": |
| 2427 |
if (!Array.isArray(valueToCompare)) return false; |
| 2428 |
return valueToCompare.includes(actualValue) === ("in" === operator); |
| 2429 |
case "contains": |
| 2430 |
case "ncontains": |
| 2431 |
if (("string" !== typeof actualValue || "string" !== typeof valueToCompare) && !Array.isArray(actualValue)) return false; |
| 2432 |
const transformedValue = Array.isArray(actualValue) ? actualValue.map((item) => isTransformable(item) ? item.value : item) : actualValue; |
| 2433 |
return "contains" === operator === transformedValue.includes(valueToCompare); |
| 2434 |
case "exists": |
| 2435 |
case "not_exist": return "exists" === operator === (!!actualValue || 0 === actualValue || false === actualValue); |
| 2436 |
default: return true; |
| 2437 |
} |
| 2438 |
} |
| 2439 |
function isNumber(value) { |
| 2440 |
return typeof value === "number" && !isNaN(value); |
| 2441 |
} |
| 2442 |
function getRelationMethod(relation) { |
| 2443 |
switch (relation) { |
| 2444 |
case "or": return "some"; |
| 2445 |
case "and": return "every"; |
| 2446 |
default: throw new Error(`Relation not supported ${relation}`); |
| 2447 |
} |
| 2448 |
} |
| 2449 |
function extractValue(path, elementValues, nestedPath = [], options = {}) { |
| 2450 |
const { unwrapOverridableLeaf = true } = options; |
| 2451 |
let resolved = path.reduce((acc, key, index) => { |
| 2452 |
const value = acc?.[key]; |
| 2453 |
if (index === path.length - 1) return value; |
| 2454 |
if (isOverridable(value)) { |
| 2455 |
const inner = value.value.origin_value; |
| 2456 |
return isTransformable(inner) ? inner.value ?? null : inner; |
| 2457 |
} |
| 2458 |
if (isTransformable(value)) return value.value ?? null; |
| 2459 |
return value; |
| 2460 |
}, elementValues); |
| 2461 |
if (unwrapOverridableLeaf && resolved && isOverridable(resolved)) resolved = resolved.value.origin_value ?? null; |
| 2462 |
if (!nestedPath?.length) return resolved; |
| 2463 |
return { |
| 2464 |
$$type: "unknown", |
| 2465 |
value: nestedPath.reduce((acc, key) => acc?.[key], resolved?.value) |
| 2466 |
}; |
| 2467 |
} |
| 2468 |
function isDependency(term) { |
| 2469 |
return "terms" in term; |
| 2470 |
} |
| 2471 |
|
| 2472 |
//#endregion |
| 2473 |
//#region packages/packages/libs/editor-props/src/utils/parse-html-children.ts |
| 2474 |
var INLINE_ELEMENTS = /* @__PURE__ */ new Set([ |
| 2475 |
"span", |
| 2476 |
"b", |
| 2477 |
"strong", |
| 2478 |
"i", |
| 2479 |
"em", |
| 2480 |
"u", |
| 2481 |
"a", |
| 2482 |
"del", |
| 2483 |
"sup", |
| 2484 |
"sub", |
| 2485 |
"s" |
| 2486 |
]); |
| 2487 |
function generateElementId() { |
| 2488 |
return `e-${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 9)}`; |
| 2489 |
} |
| 2490 |
function traverseChildren(node) { |
| 2491 |
const result = []; |
| 2492 |
for (const child of Array.from(node.children)) { |
| 2493 |
const tagName = child.tagName.toLowerCase(); |
| 2494 |
if (!INLINE_ELEMENTS.has(tagName)) { |
| 2495 |
result.push(...traverseChildren(child)); |
| 2496 |
continue; |
| 2497 |
} |
| 2498 |
let id = child.getAttribute("id"); |
| 2499 |
if (!id) { |
| 2500 |
id = generateElementId(); |
| 2501 |
child.setAttribute("id", id); |
| 2502 |
} |
| 2503 |
const childElement = { |
| 2504 |
id, |
| 2505 |
type: tagName |
| 2506 |
}; |
| 2507 |
const textContent = child.textContent?.trim(); |
| 2508 |
if (textContent) childElement.content = textContent; |
| 2509 |
const nestedChildren = traverseChildren(child); |
| 2510 |
if (nestedChildren.length > 0) childElement.children = nestedChildren; |
| 2511 |
result.push(childElement); |
| 2512 |
} |
| 2513 |
return result; |
| 2514 |
} |
| 2515 |
function parseHtmlChildren(html) { |
| 2516 |
if (!html) return { |
| 2517 |
content: html, |
| 2518 |
children: [] |
| 2519 |
}; |
| 2520 |
const doc = new DOMParser().parseFromString(`<body>${html}</body>`, "text/html"); |
| 2521 |
const parserError = doc.querySelector("parsererror"); |
| 2522 |
if (parserError) { |
| 2523 |
console.warn("HTML parsing error, returning original content:", parserError.textContent); |
| 2524 |
return { |
| 2525 |
content: html, |
| 2526 |
children: [] |
| 2527 |
}; |
| 2528 |
} |
| 2529 |
const body = doc.body; |
| 2530 |
const children = traverseChildren(body); |
| 2531 |
return { |
| 2532 |
content: body.innerHTML, |
| 2533 |
children |
| 2534 |
}; |
| 2535 |
} |
| 2536 |
|
| 2537 |
//#endregion |
| 2538 |
//#region packages/packages/libs/editor-props/src/index.ts |
| 2539 |
var src_exports = /* @__PURE__ */ __exportAll({ |
| 2540 |
CLASSES_PROP_KEY: () => CLASSES_PROP_KEY, |
| 2541 |
DateTimePropTypeUtil: () => DateTimePropTypeUtil, |
| 2542 |
Schema: () => Schema, |
| 2543 |
backdropFilterPropTypeUtil: () => backdropFilterPropTypeUtil, |
| 2544 |
backgroundColorOverlayPropTypeUtil: () => backgroundColorOverlayPropTypeUtil, |
| 2545 |
backgroundGradientOverlayPropTypeUtil: () => backgroundGradientOverlayPropTypeUtil, |
| 2546 |
backgroundImageOverlayPropTypeUtil: () => backgroundImageOverlayPropTypeUtil, |
| 2547 |
backgroundImagePositionOffsetPropTypeUtil: () => backgroundImagePositionOffsetPropTypeUtil, |
| 2548 |
backgroundImageSizeScalePropTypeUtil: () => backgroundImageSizeScalePropTypeUtil, |
| 2549 |
backgroundOverlayItem: () => backgroundOverlayItem, |
| 2550 |
backgroundOverlayPropTypeUtil: () => backgroundOverlayPropTypeUtil, |
| 2551 |
backgroundPropTypeUtil: () => backgroundPropTypeUtil, |
| 2552 |
blurFilterPropTypeUtil: () => blurFilterPropTypeUtil, |
| 2553 |
booleanPropTypeUtil: () => booleanPropTypeUtil, |
| 2554 |
borderRadiusPropTypeUtil: () => borderRadiusPropTypeUtil, |
| 2555 |
borderWidthPropTypeUtil: () => borderWidthPropTypeUtil, |
| 2556 |
boxShadowPropTypeUtil: () => boxShadowPropTypeUtil, |
| 2557 |
classesPropTypeUtil: () => classesPropTypeUtil, |
| 2558 |
colorPropTypeUtil: () => colorPropTypeUtil, |
| 2559 |
colorStopPropTypeUtil: () => colorStopPropTypeUtil, |
| 2560 |
colorToneFilterPropTypeUtil: () => colorToneFilterPropTypeUtil, |
| 2561 |
createArrayPropUtils: () => createArrayPropUtils, |
| 2562 |
createPropUtils: () => createPropUtils, |
| 2563 |
cssFilterFunctionPropUtil: () => cssFilterFunctionPropUtil, |
| 2564 |
dateRangePropTypeUtil: () => dateRangePropTypeUtil, |
| 2565 |
dateStringPropTypeUtil: () => dateStringPropTypeUtil, |
| 2566 |
dimensionsPropTypeUtil: () => dimensionsPropTypeUtil, |
| 2567 |
dropShadowFilterPropTypeUtil: () => dropShadowFilterPropTypeUtil, |
| 2568 |
emailPropTypeUtil: () => emailPropTypeUtil, |
| 2569 |
emailsPropTypeUtil: () => emailsPropTypeUtil, |
| 2570 |
escapedHtmlPropTypeUtil: () => escapedHtmlPropTypeUtil, |
| 2571 |
evaluateTerm: () => evaluateTerm, |
| 2572 |
extractValue: () => extractValue, |
| 2573 |
filterEmptyValues: () => filterEmptyValues, |
| 2574 |
filterPropTypeUtil: () => filterPropTypeUtil, |
| 2575 |
flexPropTypeUtil: () => flexPropTypeUtil, |
| 2576 |
fontFamilyPropTypeUtil: () => fontFamilyPropTypeUtil, |
| 2577 |
getPropSchemaFromCache: () => getPropSchemaFromCache, |
| 2578 |
gradientColorStopPropTypeUtil: () => gradientColorStopPropTypeUtil, |
| 2579 |
gridTrackSizePropTypeUtil: () => gridTrackSizePropTypeUtil, |
| 2580 |
htmlPropTypeUtil: () => htmlPropTypeUtil, |
| 2581 |
htmlV2PropTypeUtil: () => htmlV2PropTypeUtil, |
| 2582 |
htmlV3PropTypeUtil: () => htmlV3PropTypeUtil, |
| 2583 |
hueRotateFilterPropTypeUtil: () => hueRotateFilterPropTypeUtil, |
| 2584 |
iconPropTypeUtil: () => iconPropTypeUtil, |
| 2585 |
imageAttachmentIdPropType: () => imageAttachmentIdPropType, |
| 2586 |
imagePropTypeUtil: () => imagePropTypeUtil, |
| 2587 |
imageSrcPropTypeUtil: () => imageSrcPropTypeUtil, |
| 2588 |
intensityFilterPropTypeUtil: () => intensityFilterPropTypeUtil, |
| 2589 |
isDependency: () => isDependency, |
| 2590 |
isDependencyMet: () => isDependencyMet, |
| 2591 |
isEmpty: () => isEmpty, |
| 2592 |
isOverridable: () => isOverridable, |
| 2593 |
isTransformable: () => isTransformable, |
| 2594 |
keyValuePropTypeUtil: () => keyValuePropTypeUtil, |
| 2595 |
layoutDirectionPropTypeUtil: () => layoutDirectionPropTypeUtil, |
| 2596 |
linkPropTypeUtil: () => linkPropTypeUtil, |
| 2597 |
mergeProps: () => mergeProps, |
| 2598 |
moveTransformPropTypeUtil: () => moveTransformPropTypeUtil, |
| 2599 |
numberPropTypeUtil: () => numberPropTypeUtil, |
| 2600 |
numberRangePropTypeUtil: () => numberRangePropTypeUtil, |
| 2601 |
parseHtmlChildren: () => parseHtmlChildren, |
| 2602 |
perspectiveOriginPropTypeUtil: () => perspectiveOriginPropTypeUtil, |
| 2603 |
positionPropTypeUtil: () => positionPropTypeUtil, |
| 2604 |
queryFilterArrayPropTypeUtil: () => queryFilterArrayPropTypeUtil, |
| 2605 |
queryFilterPropTypeUtil: () => queryFilterPropTypeUtil, |
| 2606 |
queryPropTypeUtil: () => queryPropTypeUtil, |
| 2607 |
rewrapOverridableValue: () => rewrapOverridableValue, |
| 2608 |
rotateTransformPropTypeUtil: () => rotateTransformPropTypeUtil, |
| 2609 |
scaleTransformPropTypeUtil: () => scaleTransformPropTypeUtil, |
| 2610 |
selectionSizePropTypeUtil: () => selectionSizePropTypeUtil, |
| 2611 |
shadowPropTypeUtil: () => shadowPropTypeUtil, |
| 2612 |
sizePropTypeUtil: () => sizePropTypeUtil, |
| 2613 |
skewTransformPropTypeUtil: () => skewTransformPropTypeUtil, |
| 2614 |
spanPropTypeUtil: () => spanPropTypeUtil, |
| 2615 |
stringArrayPropTypeUtil: () => stringArrayPropTypeUtil, |
| 2616 |
stringPropTypeUtil: () => stringPropTypeUtil, |
| 2617 |
strokePropTypeUtil: () => strokePropTypeUtil, |
| 2618 |
svgSrcPropTypeUtil: () => svgSrcPropTypeUtil, |
| 2619 |
timeRangePropTypeUtil: () => timeRangePropTypeUtil, |
| 2620 |
timeStringPropTypeUtil: () => timeStringPropTypeUtil, |
| 2621 |
transformFunctionsPropTypeUtil: () => transformFunctionsPropTypeUtil, |
| 2622 |
transformOriginPropTypeUtil: () => transformOriginPropTypeUtil, |
| 2623 |
transformPropTypeUtil: () => transformPropTypeUtil, |
| 2624 |
urlPropTypeUtil: () => urlPropTypeUtil, |
| 2625 |
videoAttachmentIdPropType: () => videoAttachmentIdPropType, |
| 2626 |
videoSrcPropTypeUtil: () => videoSrcPropTypeUtil |
| 2627 |
}); |
| 2628 |
var Schema = { |
| 2629 |
jsonSchemaToPropType, |
| 2630 |
propTypeToJsonSchema, |
| 2631 |
adjustLlmPropValueSchema, |
| 2632 |
isPropKeyConfigurable, |
| 2633 |
nonConfigurablePropKeys, |
| 2634 |
configurableKeys, |
| 2635 |
validatePropValue, |
| 2636 |
enrichWithIntention, |
| 2637 |
removeIntention, |
| 2638 |
setDynamicTagNamesResolver |
| 2639 |
}; |
| 2640 |
|
| 2641 |
//#endregion |
| 2642 |
//#region \0elementor-package-library-entry |
| 2643 |
(window.elementorV2 = window.elementorV2 || {}).editorProps = src_exports; |
| 2644 |
|
| 2645 |
//#endregion |
| 2646 |
})(elementorV2.schema); |
| 2647 |
window.elementorV2.editorProps?.init?.(); |
| 2648 |
//# sourceMappingURL=editor-props.js.map |