{
  "version": 3,
  "sources": ["../../src/assets/TLBaseAsset.ts"],
  "sourcesContent": ["import { BaseRecord } from '@tldraw/store'\nimport { JsonObject } from '@tldraw/utils'\nimport { T } from '@tldraw/validate'\nimport { idValidator } from '../misc/id-validator'\nimport { TLAssetId } from '../records/TLAsset'\n\n/**\n * Base interface for all asset records in tldraw. Assets represent external resources\n * like images, videos, or bookmarks that shapes can reference. This interface extends\n * the base record system with asset-specific typing.\n *\n * @param Type - The specific asset type identifier (e.g., 'image', 'video', 'bookmark')\n * @param Props - The properties object specific to this asset type\n *\n * @example\n * ```ts\n * // Define a custom asset type\n * interface MyCustomAsset extends TLBaseAsset<'custom', { url: string; title: string }> {}\n *\n * const customAsset: MyCustomAsset = {\n *   id: 'asset:custom123',\n *   typeName: 'asset',\n *   type: 'custom',\n *   props: {\n *     url: 'https://example.com',\n *     title: 'My Custom Asset'\n *   },\n *   meta: {}\n * }\n * ```\n *\n * @public\n */\nexport interface TLBaseAsset<Type extends string, Props> extends BaseRecord<'asset', TLAssetId> {\n\t/** The specific type of this asset (e.g., 'image', 'video', 'bookmark') */\n\ttype: Type\n\t/** Type-specific properties for this asset */\n\tprops: Props\n\t/** User-defined metadata that can be attached to this asset */\n\tmeta: JsonObject\n}\n\n/**\n * A validator for asset record type IDs. This validator ensures that asset IDs\n * follow the correct format and type structure required by tldraw's asset system.\n * Asset IDs are prefixed with 'asset:' followed by a unique identifier.\n *\n * @example\n * ```ts\n * import { assetIdValidator } from '@tldraw/tlschema'\n *\n * // Valid asset ID\n * const validId = 'asset:abc123'\n * console.log(assetIdValidator.isValid(validId)) // true\n *\n * // Invalid asset ID\n * const invalidId = 'shape:abc123'\n * console.log(assetIdValidator.isValid(invalidId)) // false\n * ```\n *\n * @public\n */\nexport const assetIdValidator = idValidator<TLAssetId>('asset')\n\n/**\n * Creates a validator for a specific asset record type. This factory function generates\n * a complete validator that validates the entire asset record structure including the\n * base properties (id, typeName, type, meta) and the type-specific props.\n *\n * @param type - The asset type identifier (e.g., 'image', 'video', 'bookmark')\n * @param props - The validator for the asset's type-specific properties\n * @returns A complete validator for the asset record type\n *\n * @example\n * ```ts\n * import { createAssetValidator, TLBaseAsset } from '@tldraw/tlschema'\n * import { T } from '@tldraw/validate'\n *\n * // Define a custom asset type\n * type TLCustomAsset = TLBaseAsset<'custom', {\n *   url: string\n *   title: string\n *   description?: string\n * }>\n *\n * // Create validator for the custom asset\n * const customAssetValidator = createAssetValidator('custom', T.object({\n *   url: T.string,\n *   title: T.string,\n *   description: T.string.optional()\n * }))\n *\n * // Use the validator\n * const assetData = {\n *   id: 'asset:custom123',\n *   typeName: 'asset' as const,\n *   type: 'custom' as const,\n *   props: {\n *     url: 'https://example.com',\n *     title: 'My Custom Asset'\n *   },\n *   meta: {}\n * }\n *\n * const validatedAsset = customAssetValidator.validate(assetData)\n * ```\n *\n * @public\n */\nexport function createAssetValidator<Type extends string, Props extends JsonObject>(\n\ttype: Type,\n\tprops: T.Validator<Props>\n) {\n\treturn T.object<{\n\t\tid: TLAssetId\n\t\ttypeName: 'asset'\n\t\ttype: Type\n\t\tprops: Props\n\t\tmeta: JsonObject\n\t}>({\n\t\tid: assetIdValidator,\n\t\ttypeName: T.literal('asset'),\n\t\ttype: T.literal(type),\n\t\tprops,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n}\n"],
  "mappings": "AAEA,SAAS,SAAS;AAClB,SAAS,mBAAmB;AA2DrB,MAAM,mBAAmB,YAAuB,OAAO;AA+CvD,SAAS,qBACf,MACA,OACC;AACD,SAAO,EAAE,OAMN;AAAA,IACF,IAAI;AAAA,IACJ,UAAU,EAAE,QAAQ,OAAO;AAAA,IAC3B,MAAM,EAAE,QAAQ,IAAI;AAAA,IACpB;AAAA,IACA,MAAM,EAAE;AAAA,EACT,CAAC;AACF;",
  "names": []
}
