{
  "version": 3,
  "sources": ["../../../src/handlers/entity/leader.ts"],
  "sourcesContent": ["import type { DXFTuple } from '../../types'\n\nimport common from './common'\n\nexport const TYPE = 'LEADER'\n\ninterface LeaderEntity {\n  type: typeof TYPE\n  vertices: Array<{ x: number; y: number; z: number }>\n\n  dimensionStyleName?: string\n  arrowheadFlag?: number\n  pathType?: number\n  creationFlag?: number\n  hooklineDirectionFlag?: number\n  hooklineFlag?: number\n  textHeight?: number\n  textWidth?: number\n  color?: number\n  annotationHandle?: string\n\n  normal?: { x: number; y: number; z: number }\n  horizontalDirection?: { x: number; y: number; z: number }\n  blockOffset?: { x: number; y: number; z: number }\n  annotationOffset?: { x: number; y: number; z: number }\n\n  [key: string]: unknown\n}\n\nfunction ensureVector3(\n  entity: LeaderEntity,\n  key: 'normal' | 'horizontalDirection' | 'blockOffset' | 'annotationOffset',\n): { x: number; y: number; z: number } {\n  if (!entity[key]) entity[key] = { x: 0, y: 0, z: 0 }\n  return entity[key] as { x: number; y: number; z: number }\n}\n\nexport const process = (tuples: DXFTuple[]): LeaderEntity => {\n  return tuples.reduce(\n    (entity, tuple) => {\n      const type = tuple[0]\n      const value = tuple[1]\n\n      switch (type) {\n        case 3:\n          entity.dimensionStyleName = String(value)\n          break\n\n        case 71:\n          entity.arrowheadFlag = value as number\n          break\n        case 72:\n          entity.pathType = value as number\n          break\n        case 73:\n          entity.creationFlag = value as number\n          break\n        case 74:\n          entity.hooklineDirectionFlag = value as number\n          break\n        case 75:\n          entity.hooklineFlag = value as number\n          break\n\n        case 40:\n          entity.textHeight = value as number\n          break\n        case 41:\n          entity.textWidth = value as number\n          break\n\n        case 76:\n          // Number of vertices in leader. Keep as metadata only.\n          entity.vertexCount = value as number\n          break\n\n        case 10:\n          entity.vertices.push({ x: value as number, y: 0, z: 0 })\n          break\n        case 20: {\n          const current = entity.vertices[entity.vertices.length - 1]\n          if (current) current.y = value as number\n          break\n        }\n        case 30: {\n          const current = entity.vertices[entity.vertices.length - 1]\n          if (current) current.z = value as number\n          break\n        }\n\n        case 77:\n          entity.color = value as number\n          break\n\n        case 340:\n          entity.annotationHandle = String(value)\n          break\n\n        case 210:\n          ensureVector3(entity, 'normal').x = value as number\n          break\n        case 220:\n          ensureVector3(entity, 'normal').y = value as number\n          break\n        case 230:\n          ensureVector3(entity, 'normal').z = value as number\n          break\n\n        case 211:\n          ensureVector3(entity, 'horizontalDirection').x = value as number\n          break\n        case 221:\n          ensureVector3(entity, 'horizontalDirection').y = value as number\n          break\n        case 231:\n          ensureVector3(entity, 'horizontalDirection').z = value as number\n          break\n\n        case 212:\n          ensureVector3(entity, 'blockOffset').x = value as number\n          break\n        case 222:\n          ensureVector3(entity, 'blockOffset').y = value as number\n          break\n        case 232:\n          ensureVector3(entity, 'blockOffset').z = value as number\n          break\n\n        case 213:\n          ensureVector3(entity, 'annotationOffset').x = value as number\n          break\n        case 223:\n          ensureVector3(entity, 'annotationOffset').y = value as number\n          break\n        case 233:\n          ensureVector3(entity, 'annotationOffset').z = value as number\n          break\n\n        default:\n          Object.assign(entity, common(type, value))\n          break\n      }\n\n      return entity\n    },\n    {\n      type: TYPE,\n      vertices: [],\n    } as LeaderEntity,\n  )\n}\n\nexport default { TYPE, process }\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAmB;AAEZ,MAAM,OAAO;AAyBpB,SAAS,cACP,QACA,KACqC;AACrC,MAAI,CAAC,OAAO,GAAG,EAAG,QAAO,GAAG,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AACnD,SAAO,OAAO,GAAG;AACnB;AAEO,MAAM,UAAU,CAAC,WAAqC;AAC3D,SAAO,OAAO;AAAA,IACZ,CAAC,QAAQ,UAAU;AACjB,YAAM,OAAO,MAAM,CAAC;AACpB,YAAM,QAAQ,MAAM,CAAC;AAErB,cAAQ,MAAM;AAAA,QACZ,KAAK;AACH,iBAAO,qBAAq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