{"version":3,"file":"dialects-D8eXzoGv.cjs","names":["DRAFT_2020_12_URIS: ReadonlySet<string>","DRAFT_2019_09_URIS: ReadonlySet<string>","DRAFT_07_URIS: ReadonlySet<string>","DRAFT_06_URIS: ReadonlySet<string>"],"sources":["../../core-internal/src/validators/dialects.ts"],"sourcesContent":["/**\n * Declared-dialect classification shared by the default validator providers.\n */\n\nimport type { JsonSchemaType } from './types';\n\n/**\n * Canonical `$schema` URIs per supported dialect (http + https variants, trailing-`#` stripped).\n */\nconst DRAFT_2020_12_URIS: ReadonlySet<string> = new Set([\n    'https://json-schema.org/draft/2020-12/schema',\n    'http://json-schema.org/draft/2020-12/schema'\n]);\nconst DRAFT_2019_09_URIS: ReadonlySet<string> = new Set([\n    'https://json-schema.org/draft/2019-09/schema',\n    'http://json-schema.org/draft/2019-09/schema'\n]);\nconst DRAFT_07_URIS: ReadonlySet<string> = new Set(['https://json-schema.org/draft-07/schema', 'http://json-schema.org/draft-07/schema']);\nconst DRAFT_06_URIS: ReadonlySet<string> = new Set(['https://json-schema.org/draft-06/schema', 'http://json-schema.org/draft-06/schema']);\n\n/**\n * Dialects the default providers dispatch on. draft-06 maps to `'draft-7'`: draft-07 only adds\n * keywords over draft-06 (`if`/`then`/`else`), and enforcing them on a draft-06 schema is the\n * accepted downlevel.\n */\nexport type DeclaredDialect = '2020-12' | '2019-09' | 'draft-7';\n\n/**\n * Whether a `$schema` value declares the 2019-09 dialect — the only supported dialect with\n * `$recursiveRef`/`$recursiveAnchor`. Non-throwing (unlike {@linkcode declaredDialect}) so\n * wire-layer callers can consult it for documents whose dialect may be unsupported.\n */\nexport function declares2019Dialect($schema: unknown): boolean {\n    return typeof $schema === 'string' && DRAFT_2019_09_URIS.has($schema.replace(/#$/, ''));\n}\n\n/**\n * Classify a schema's declared `$schema` dialect. No `$schema` (or a non-string one) means\n * 2020-12. Any other dialect throws a plain `Error` with a clear message rather than letting the\n * engine crash on an opaque internal error or silently mis-validate; `remedy` names the calling\n * provider's escape hatch in that message.\n */\nexport function declaredDialect(schema: JsonSchemaType, remedy: string): DeclaredDialect {\n    if (!('$schema' in schema) || typeof schema.$schema !== 'string') {\n        return '2020-12';\n    }\n    const declared = schema.$schema.replace(/#$/, '');\n    if (DRAFT_2020_12_URIS.has(declared)) {\n        return '2020-12';\n    }\n    if (DRAFT_2019_09_URIS.has(declared)) {\n        return '2019-09';\n    }\n    if (DRAFT_07_URIS.has(declared) || DRAFT_06_URIS.has(declared)) {\n        return 'draft-7';\n    }\n    throw new Error(\n        `JSON Schema declares an unsupported dialect (\"$schema\": \"${schema.$schema.slice(0, 200)}\"). ` +\n            `The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${remedy}`\n    );\n}\n"],"mappings":";;;;;AASA,MAAMA,qBAA0C,IAAI,IAAI,CACpD,gDACA,8CACH,CAAC;AACF,MAAMC,qBAA0C,IAAI,IAAI,CACpD,gDACA,8CACH,CAAC;AACF,MAAMC,gBAAqC,IAAI,IAAI,CAAC,2CAA2C,yCAAyC,CAAC;AACzI,MAAMC,gBAAqC,IAAI,IAAI,CAAC,2CAA2C,yCAAyC,CAAC;;;;;;AAczI,SAAgB,oBAAoB,SAA2B;AAC3D,QAAO,OAAO,YAAY,YAAY,mBAAmB,IAAI,QAAQ,QAAQ,MAAM,GAAG,CAAC;;;;;;;;AAS3F,SAAgB,gBAAgB,QAAwB,QAAiC;AACrF,KAAI,EAAE,aAAa,WAAW,OAAO,OAAO,YAAY,SACpD,QAAO;CAEX,MAAM,WAAW,OAAO,QAAQ,QAAQ,MAAM,GAAG;AACjD,KAAI,mBAAmB,IAAI,SAAS,CAChC,QAAO;AAEX,KAAI,mBAAmB,IAAI,SAAS,CAChC,QAAO;AAEX,KAAI,cAAc,IAAI,SAAS,IAAI,cAAc,IAAI,SAAS,CAC1D,QAAO;AAEX,OAAM,IAAI,MACN,4DAA4D,OAAO,QAAQ,MAAM,GAAG,IAAI,CAAC,2FACG,SAC/F"}