{
  "version": 3,
  "sources": ["../../src/records/TLPointer.ts"],
  "sourcesContent": ["import {\n\tBaseRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n} from '@tldraw/store'\nimport { JsonObject } from '@tldraw/utils'\nimport { T } from '@tldraw/validate'\nimport { idValidator } from '../misc/id-validator'\n\n/**\n * Represents the current pointer/cursor position and activity state.\n * This record tracks the mouse or touch pointer coordinates and when\n * the pointer was last active, useful for cursor synchronization in\n * collaborative environments.\n *\n * There is typically one pointer record per browser tab that gets updated\n * as the user moves their mouse or touches the screen.\n *\n * @example\n * ```ts\n * const pointer: TLPointer = {\n *   id: 'pointer:pointer',\n *   typeName: 'pointer',\n *   x: 150,\n *   y: 200,\n *   lastActivityTimestamp: Date.now(),\n *   meta: {}\n * }\n * ```\n *\n * @public\n */\nexport interface TLPointer extends BaseRecord<'pointer', TLPointerId> {\n\tx: number\n\ty: number\n\tlastActivityTimestamp: number\n\tmeta: JsonObject\n}\n\n/**\n * A unique identifier for TLPointer records.\n *\n * Pointer IDs follow the format 'pointer:' followed by a unique identifier.\n * Typically there is one pointer record with a constant ID per session.\n *\n * @example\n * ```ts\n * const pointerId: TLPointerId = 'pointer:pointer'\n * ```\n *\n * @public\n */\nexport type TLPointerId = RecordId<TLPointer>\n\n/**\n * Runtime validator for TLPointer records. Validates the structure\n * and types of all pointer properties to ensure data integrity.\n *\n * @example\n * ```ts\n * const pointer = {\n *   id: 'pointer:pointer',\n *   typeName: 'pointer',\n *   x: 100,\n *   y: 200,\n *   lastActivityTimestamp: Date.now(),\n *   meta: {}\n * }\n * const isValid = pointerValidator.isValid(pointer) // true\n * ```\n *\n * @public\n */\nexport const pointerValidator: T.Validator<TLPointer> = T.model(\n\t'pointer',\n\tT.object({\n\t\ttypeName: T.literal('pointer'),\n\t\tid: idValidator<TLPointerId>('pointer'),\n\t\tx: T.number,\n\t\ty: T.number,\n\t\tlastActivityTimestamp: T.number,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/**\n * Migration version identifiers for TLPointer records. Each version\n * represents a schema change that requires data transformation when\n * loading older documents.\n *\n * @public\n */\nexport const pointerVersions = createMigrationIds('com.tldraw.pointer', {\n\tAddMeta: 1,\n})\n\n/**\n * Migration sequence for TLPointer records. Defines how to transform\n * pointer records between different schema versions, ensuring data\n * compatibility when loading documents created with different versions.\n *\n * @example\n * ```ts\n * // Migrations are applied automatically when loading documents\n * const migratedPointer = pointerMigrations.migrate(oldPointer, targetVersion)\n * ```\n *\n * @public\n */\nexport const pointerMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.tldraw.pointer',\n\trecordType: 'pointer',\n\tsequence: [\n\t\t{\n\t\t\tid: pointerVersions.AddMeta,\n\t\t\tup: (record: any) => {\n\t\t\t\trecord.meta = {}\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * The RecordType definition for TLPointer records. Defines validation,\n * scope, and default properties for pointer records in the tldraw store.\n *\n * Pointer records are scoped to the session level, meaning they are\n * specific to a browser tab and don't persist across sessions.\n *\n * @example\n * ```ts\n * const pointer = PointerRecordType.create({\n *   id: 'pointer:pointer',\n *   x: 0,\n *   y: 0\n * })\n * ```\n *\n * @public\n */\nexport const PointerRecordType = createRecordType<TLPointer>('pointer', {\n\tvalidator: pointerValidator,\n\tscope: 'session',\n}).withDefaultProperties(\n\t(): Omit<TLPointer, 'id' | 'typeName'> => ({\n\t\tx: 0,\n\t\ty: 0,\n\t\tlastActivityTimestamp: 0,\n\t\tmeta: {},\n\t})\n)\n\n/**\n * The constant ID used for the singleton TLPointer record.\n *\n * Since each browser tab typically has one pointer, this constant ID\n * is used universally across the application.\n *\n * @example\n * ```ts\n * const pointer = store.get(TLPOINTER_ID)\n * if (pointer) {\n *   console.log('Pointer at:', pointer.x, pointer.y)\n * }\n * ```\n *\n * @public\n */\nexport const TLPOINTER_ID = PointerRecordType.createId('pointer')\n"],
  "mappings": "AAAA;AAAA,EAEC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AAEP,SAAS,SAAS;AAClB,SAAS,mBAAmB;AAkErB,MAAM,mBAA2C,EAAE;AAAA,EACzD;AAAA,EACA,EAAE,OAAO;AAAA,IACR,UAAU,EAAE,QAAQ,SAAS;AAAA,IAC7B,IAAI,YAAyB,SAAS;AAAA,IACtC,GAAG,EAAE;AAAA,IACL,GAAG,EAAE;AAAA,IACL,uBAAuB,EAAE;AAAA,IACzB,MAAM,EAAE;AAAA,EACT,CAAC;AACF;AASO,MAAM,kBAAkB,mBAAmB,sBAAsB;AAAA,EACvE,SAAS;AACV,CAAC;AAeM,MAAM,oBAAoB,8BAA8B;AAAA,EAC9D,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,IACT;AAAA,MACC,IAAI,gBAAgB;AAAA,MACpB,IAAI,CAAC,WAAgB;AACpB,eAAO,OAAO,CAAC;AAAA,MAChB;AAAA,IACD;AAAA,EACD;AACD,CAAC;AAoBM,MAAM,oBAAoB,iBAA4B,WAAW;AAAA,EACvE,WAAW;AAAA,EACX,OAAO;AACR,CAAC,EAAE;AAAA,EACF,OAA2C;AAAA,IAC1C,GAAG;AAAA,IACH,GAAG;AAAA,IACH,uBAAuB;AAAA,IACvB,MAAM,CAAC;AAAA,EACR;AACD;AAkBO,MAAM,eAAe,kBAAkB,SAAS,SAAS;",
  "names": []
}
