{
  "version": 3,
  "sources": ["../../src/shapes/TLHighlightShape.ts"],
  "sourcesContent": ["import { T } from '@tldraw/validate'\nimport { b64Vecs } from '../misc/b64Vecs'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/TLShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DefaultColorStyle, TLDefaultColorStyle } from '../styles/TLColorStyle'\nimport { DefaultSizeStyle, TLDefaultSizeStyle } from '../styles/TLSizeStyle'\nimport { TLBaseShape } from './TLBaseShape'\nimport { DrawShapeSegment, TLDrawShapeSegment } from './TLDrawShape'\n\n/**\n * Properties for a highlight shape. Highlight shapes represent highlighting strokes made with\n * a highlighting tool, typically used to emphasize or mark up content.\n *\n * @public\n * @example\n * ```ts\n * const highlightProps: TLHighlightShapeProps = {\n *   color: 'yellow',\n *   size: 'm',\n *   segments: [{ type: 'straight', points: [{ x: 0, y: 0, z: 0.5 }] }],\n *   isComplete: true,\n *   isPen: false,\n *   scale: 1\n * }\n * ```\n */\nexport interface TLHighlightShapeProps {\n\t/** The color style of the highlight stroke */\n\tcolor: TLDefaultColorStyle\n\t/** The size style determining the thickness of the highlight stroke */\n\tsize: TLDefaultSizeStyle\n\t/** Array of segments that make up the highlight stroke path */\n\tsegments: TLDrawShapeSegment[]\n\t/** Whether the highlight stroke has been completed by the user */\n\tisComplete: boolean\n\t/** Whether the highlight was drawn with a pen/stylus (affects rendering style) */\n\tisPen: boolean\n\t/** Scale factor applied to the highlight shape for display */\n\tscale: number\n\t/** Horizontal scale factor for lazy resize */\n\tscaleX: number\n\t/** Vertical scale factor for lazy resize */\n\tscaleY: number\n}\n\n/**\n * A highlight shape representing a highlighting stroke drawn by the user. Highlight shapes\n * are typically semi-transparent and used for marking up or emphasizing content on the canvas.\n *\n * @public\n * @example\n * ```ts\n * const highlightShape: TLHighlightShape = {\n *   id: 'shape:highlight1',\n *   type: 'highlight',\n *   x: 100,\n *   y: 50,\n *   rotation: 0,\n *   index: 'a1',\n *   parentId: 'page:main',\n *   isLocked: false,\n *   opacity: 0.7,\n *   props: {\n *     color: 'yellow',\n *     size: 'l',\n *     segments: [],\n *     isComplete: false,\n *     isPen: false,\n *     scale: 1\n *   },\n *   meta: {},\n *   typeName: 'shape'\n * }\n * ```\n */\nexport type TLHighlightShape = TLBaseShape<'highlight', TLHighlightShapeProps>\n\n/**\n * Validation schema for highlight shape properties. Defines the runtime validation rules\n * for all properties of highlight shapes.\n *\n * @public\n * @example\n * ```ts\n * import { highlightShapeProps } from '@tldraw/tlschema'\n *\n * // Used internally by the validation system\n * const validator = T.object(highlightShapeProps)\n * const validatedProps = validator.validate(someHighlightProps)\n * ```\n */\n/** @public */\nexport const highlightShapeProps: RecordProps<TLHighlightShape> = {\n\tcolor: DefaultColorStyle,\n\tsize: DefaultSizeStyle,\n\tsegments: T.arrayOf(DrawShapeSegment),\n\tisComplete: T.boolean,\n\tisPen: T.boolean,\n\tscale: T.nonZeroNumber,\n\tscaleX: T.nonZeroFiniteNumber,\n\tscaleY: T.nonZeroFiniteNumber,\n}\n\nconst Versions = createShapePropsMigrationIds('highlight', {\n\tAddScale: 1,\n\tBase64: 2,\n\tLegacyPointsConversion: 3,\n})\n\n/**\n * Version identifiers for highlight shape migrations. These version numbers track\n * schema changes over time to enable proper data migration.\n *\n * @public\n */\nexport { Versions as highlightShapeVersions }\n\n/**\n * Migration sequence for highlight shapes. Handles schema evolution over time by defining\n * how to upgrade and downgrade highlight shape data between different versions.\n *\n * @public\n */\nexport const highlightShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddScale,\n\t\t\tup: (props) => {\n\t\t\t\tprops.scale = 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.scale\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.Base64,\n\t\t\tup: (props) => {\n\t\t\t\t// Convert VecModel[] arrays directly to delta-encoded base64 in 'path'\n\t\t\t\tprops.segments = props.segments.map((segment: any) => {\n\t\t\t\t\tif (segment.path !== undefined) return segment\n\t\t\t\t\tconst { points, ...rest } = segment\n\t\t\t\t\tconst vecModels = Array.isArray(points) ? points : b64Vecs._legacyDecodePoints(points)\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...rest,\n\t\t\t\t\t\tpath: b64Vecs.encodePoints(vecModels),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tprops.scaleX = props.scaleX ?? 1\n\t\t\t\tprops.scaleY = props.scaleY ?? 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\t// Convert delta-encoded 'path' back to VecModel[] arrays in 'points'\n\t\t\t\tprops.segments = props.segments.map((segment: any) => {\n\t\t\t\t\tconst { path, ...rest } = segment\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...rest,\n\t\t\t\t\t\tpoints: b64Vecs.decodePoints(path),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tdelete props.scaleX\n\t\t\t\tdelete props.scaleY\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.LegacyPointsConversion,\n\t\t\tup: (props) => {\n\t\t\t\t// Handle legacy data that was already migrated to v2 with absolute Float16 in 'points'\n\t\t\t\t// Convert 'points' to delta-encoded 'path'\n\t\t\t\tprops.segments = props.segments.map((segment: any) => {\n\t\t\t\t\t// If segment already has 'path', it's already in the new format\n\t\t\t\t\tif (segment.path !== undefined) return segment\n\n\t\t\t\t\tconst { points, ...rest } = segment\n\t\t\t\t\tconst vecModels = Array.isArray(points) ? points : b64Vecs._legacyDecodePoints(points)\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...rest,\n\t\t\t\t\t\tpath: b64Vecs.encodePoints(vecModels),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t},\n\t\t\tdown: (_props) => {\n\t\t\t\t// handled by the previous down migration\n\t\t\t},\n\t\t},\n\t],\n})\n"],
  "mappings": "AAAA,SAAS,SAAS;AAClB,SAAS,eAAe;AACxB,SAAS,8BAA8B,yCAAyC;A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