{"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/entity/src/index.ts"],"sourcesContent":["import type { PropType, VNode } from 'vue'\nimport { createCommentVNode, defineComponent, getCurrentInstance, h } from 'vue'\nimport type {\n  AnyObject,\n  EntityEmitType,\n  VcCallbackPropertyFunction,\n  VcComponentInternalInstance,\n  VcComponentPublicInstance,\n  VcGraphics,\n  VcPickEvent,\n  VcPosition,\n  VcReadyObject\n} from 'casc-cesium-utils/types'\nimport { useCommon } from 'casc-cesium-composables/index'\nimport { position, enableMouseEvent, show, viewFrom } from 'casc-cesium-utils/cesium-props'\nimport { getInstanceListener } from 'casc-cesium-utils/private/vm'\nimport { hSlot } from 'casc-cesium-utils/private/render'\nimport { kebabCase } from 'casc-cesium-utils/util'\nimport { commonEmits, pickEventEmits } from 'casc-cesium-utils/emits'\nimport {\n  VcGraphicsBillboardProps,\n  VcGraphicsBoxProps,\n  VcGraphicsCorridorProps,\n  VcGraphicsCylinderProps,\n  VcGraphicsEllipseProps,\n  VcGraphicsEllipsoidProps,\n  VcGraphicsEllipsoidRef,\n  VcGraphicsLabelProps,\n  VcGraphicsModelProps,\n  VcGraphicsPathProps,\n  VcGraphicsPlaneProps,\n  VcGraphicsPointProps,\n  VcGraphicsPolygonProps,\n  VcGraphicsPolylineProps,\n  VcGraphicsPolylineVolumeProps,\n  VcGraphicsRectangleProps,\n  VcGraphicsTilesetProps,\n  VcGraphicsWallProps\n} from '../../graphics'\n\nexport const entityProps = {\n  id: String,\n  name: String,\n  availability: Object as PropType<Cesium.TimeIntervalCollection>,\n  ...show,\n  description: [String, Object] as PropType<string | Cesium.CallbackProperty | VcCallbackPropertyFunction<string>>,\n  ...position,\n  orientation: Object as PropType<Cesium.Quaternion | Cesium.VelocityOrientationProperty | Cesium.CallbackProperty>,\n  ...viewFrom,\n  parent: Object as PropType<Cesium.Entity>,\n  billboard: Object as PropType<Cesium.BillboardGraphics | VcGraphicsBillboardProps>,\n  box: Object as PropType<Cesium.BoxGraphics | VcGraphicsBoxProps>,\n  corridor: Object as PropType<Cesium.CorridorGraphics | VcGraphicsCorridorProps>,\n  cylinder: Object as PropType<Cesium.CylinderGraphics | VcGraphicsCylinderProps>,\n  ellipse: Object as PropType<Cesium.EllipseGraphics | VcGraphicsEllipseProps>,\n  ellipsoid: Object as PropType<Cesium.EllipsoidGraphics | VcGraphicsEllipsoidRef>,\n  label: Object as PropType<Cesium.LabelGraphics | VcGraphicsLabelProps>,\n  model: Object as PropType<Cesium.ModelGraphics | VcGraphicsModelProps>,\n  tileset: Object as PropType<Cesium.Cesium3DTilesetGraphics | VcGraphicsTilesetProps>,\n  path: Object as PropType<Cesium.PathGraphics | VcGraphicsPathProps>,\n  plane: Object as PropType<Cesium.PlaneGraphics | VcGraphicsPlaneProps>,\n  point: Object as PropType<Cesium.PointGraphics | VcGraphicsPointProps>,\n  polygon: Object as PropType<Cesium.PolygonGraphics | VcGraphicsPolygonProps>,\n  polyline: Object as PropType<Cesium.PolylineGraphics | VcGraphicsPolylineProps>,\n  properties: Object,\n  polylineVolume: Object as PropType<Cesium.PolylineVolumeGraphics | VcGraphicsPolylineVolumeProps>,\n  rectangle: Object as PropType<Cesium.RectangleGraphics | VcGraphicsRectangleProps>,\n  wall: Object as PropType<Cesium.WallGraphics | VcGraphicsWallProps>,\n  ...enableMouseEvent\n}\n\nconst emits = {\n  ...commonEmits,\n  ...pickEventEmits,\n  definitionChanged: (property: Cesium.Property) => true,\n  'update:billboard': (payload: Cesium.BillboardGraphics) => true,\n  'update:box': (payload: Cesium.BoxGraphics) => true,\n  'update:corridor': (payload: Cesium.CorridorGraphics) => true,\n  'update:cylinder': (payload: Cesium.CylinderGraphics) => true,\n  'update:ellipse': (payload: Cesium.EllipseGraphics) => true,\n  'update:ellipsoid': (payload: Cesium.EllipsoidGraphics) => true,\n  'update:label': (payload: Cesium.LabelGraphics) => true,\n  'update:model': (payload: Cesium.ModelGraphics) => true,\n  'update:path': (payload: Cesium.PathGraphics) => true,\n  'update:plane': (payload: Cesium.PlaneGraphics) => true,\n  'update:point': (payload: Cesium.PointGraphics) => true,\n  'update:polygon': (payload: Cesium.PolygonGraphics) => true,\n  'update:polyline': (payload: Cesium.PolylineGraphics) => true,\n  'update:polylineVolume': (payload: Cesium.PolylineVolumeGraphics) => true,\n  'update:rectangle': (payload: Cesium.RectangleGraphics) => true,\n  'update:tileset': (payload: any) => true,\n  'update:wall': (payload: Cesium.WallGraphics) => true\n}\n\nexport default defineComponent({\n  name: 'VcEntity',\n  props: entityProps,\n  emits: emits,\n  setup(props, ctx) {\n    // state\n    const instance = getCurrentInstance() as VcComponentInternalInstance\n    instance.cesiumClass = 'Entity'\n    instance.cesiumEvents = ['definitionChanged']\n    const commonState = useCommon(props, ctx, instance)\n    if (commonState === void 0) {\n      return\n    }\n    const { $services } = commonState\n    const { emit } = ctx\n\n    // methods\n    instance.mount = async () => {\n      const entity = $services?.entities?.add(instance.cesiumObject as Cesium.Entity)\n      return $services?.entities.contains(entity)\n    }\n\n    instance.unmount = async () => {\n      return $services?.entities?.remove(instance.cesiumObject as Cesium.Entity)\n    }\n\n    const updateGraphics = (graphics, emitType) => {\n      const listener = getInstanceListener(instance, emitType)\n      if (listener) {\n        emit(emitType, graphics)\n      } else {\n        instance.cesiumObject && (instance.cesiumObject[emitType.substring(7)] = graphics)\n      }\n      graphics && (graphics._vcParent = instance.cesiumObject)\n      return true\n    }\n\n    // expose public methods\n    Object.assign(instance.proxy, {\n      // private but needed by VcGraphicsXXX\n      __updateGraphics: updateGraphics\n    })\n\n    return () =>\n      ctx.slots.default\n        ? h(\n            'i',\n            {\n              class: kebabCase(instance.proxy?.$options.name || ''),\n              style: { display: 'none !important' }\n            },\n            hSlot(ctx.slots.default)\n          )\n        : createCommentVNode(kebabCase(instance.proxy?.$options.name || ''))\n  }\n})\n\nexport type VcEntityEmits = typeof emits\n\nexport type VcEntityProps = {\n  /**\n   * A unique identifier for this object. If none is provided, a GUID is generated.\n   */\n  id?: string\n  /**\n   * A human readable name to display to users. It does not have to be unique.\n   */\n  name?: string\n  /**\n   * The availability, if any, associated with this object.\n   */\n  availability?: Cesium.TimeIntervalCollection\n  /**\n   * A boolean value indicating if the entity and its children are displayed.\n   */\n  show?: boolean\n  /**\n   * A string Property specifying an HTML description for this entity.\n   */\n  description?: string | Cesium.CallbackProperty | VcCallbackPropertyFunction<string>\n  /**\n   * A Property specifying the entity position.\n   */\n  position?: VcPosition\n  /**\n   * A Property specifying the entity orientation.\n   */\n  orientation?: Cesium.Quaternion | Cesium.VelocityOrientationProperty | Cesium.CallbackProperty\n  /**\n   * A suggested initial offset for viewing this object.\n   */\n  viewFrom?: VcPosition | Cesium.CallbackProperty\n  /**\n   * A parent entity to associate with this entity.\n   */\n  parent?: Cesium.Entity\n  /**\n   * A billboard to associate with this entity.\n   */\n  billboard?: Cesium.BillboardGraphics | VcGraphicsBillboardProps\n  /**\n   * A box to associate with this entity.\n   */\n  box?: Cesium.BoxGraphics | VcGraphicsBoxProps\n  /**\n   * A corridor to associate with this entity.\n   */\n  corridor?: Cesium.CorridorGraphics | VcGraphicsCorridorProps\n  /**\n   * A cylinder to associate with this entity.\n   */\n  cylinder?: Cesium.CylinderGraphics | VcGraphicsCylinderProps\n  /**\n   * A ellipse to associate with this entity.\n   */\n  ellipse?: Cesium.EllipseGraphics | VcGraphicsEllipseProps\n  /**\n   * A ellipsoid to associate with this entity.\n   */\n  ellipsoid?: Cesium.EllipsoidGraphics | VcGraphicsEllipsoidProps\n  /**\n   * A options.label to associate with this entity.\n   */\n  label?: Cesium.LabelGraphics | VcGraphicsLabelProps\n  /**\n   * A model to associate with this entity.\n   */\n  model?: Cesium.ModelGraphics | VcGraphicsModelProps\n  /**\n   * A 3D Tiles tileset to associate with this entity.\n   */\n  tileset?: Cesium.Cesium3DTilesetGraphics | VcGraphicsTilesetProps\n  /**\n   * A path to associate with this entity.\n   */\n  path?: Cesium.PathGraphics | VcGraphicsPathProps\n  /**\n   * A plane to associate with this entity.\n   */\n  plane?: Cesium.PlaneGraphics | VcGraphicsPlaneProps\n  /**\n   * A point to associate with this entity.\n   */\n  point?: Cesium.PointGraphics | VcGraphicsPointProps\n  /**\n   * A polygon to associate with this entity.\n   */\n  polygon?: Cesium.PolygonGraphics | VcGraphicsPolygonProps\n  /**\n   * A polyline to associate with this entity.\n   */\n  polyline?: Cesium.PolylineGraphics | VcGraphicsPolylineProps\n  /**\n   * Arbitrary properties to associate with this entity.\n   */\n  properties?: AnyObject\n  /**\n   * A polylineVolume to associate with this entity.\n   */\n  polylineVolume?: Cesium.PolylineVolumeGraphics | VcGraphicsPolylineVolumeProps\n  /**\n   * A rectangle to associate with this entity.\n   */\n  rectangle?: Cesium.RectangleGraphics | VcGraphicsRectangleProps\n  /**\n   * A wall to associate with this entity.\n   */\n  wall?: Cesium.WallGraphics | VcGraphicsWallProps\n  /**\n   * Triggers before the VcEntity is loaded.\n   */\n  onBeforeLoad?: (instance: VcComponentInternalInstance) => void\n  /**\n   * Triggers when the VcEntity is successfully loaded.\n   */\n  onReady?: (readyObject: VcReadyObject) => void\n  /**\n   * Triggers when the component load failed.\n   */\n  onUnready?: (e: any) => void\n  /**\n   * Triggers when the VcEntity is destroyed.\n   */\n  onDestroyed?: (instance: VcComponentInternalInstance) => void\n  /**\n   * Triggers when a property or sub-property is changed or modified.\n   */\n  onDefinitionChanged?: (property: Cesium.Property) => void\n  /**\n   * Triggers when the mouse is pressed on this entity.\n   */\n  onMousedown?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse bounces up on this entity.\n   */\n  onMouseup?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse clicks on this entity.\n   */\n  onClick?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse clicks outside this entity.\n   */\n  onClickout?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the left mouse button double-clicks this entity.\n   */\n  onDblclick?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse moves on this entity.\n   */\n  onMousemove?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse moves over to this entity.\n   */\n  onMouseover?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse moves out of this entity.\n   */\n  onMouseout?: (evt: VcPickEvent) => void\n}\nexport interface VcEntityRef extends VcComponentPublicInstance<VcEntityProps> {\n  /**\n   * private method, update graphic.\n   * @param graphics\n   * @param type\n   */\n  __updateGraphics: (graphics: VcGraphics | undefined, type: EntityEmitType) => boolean\n}\n\nexport interface VcEntitySlots {\n  /**\n   * Slot for vc-graphics-xxx.\n   */\n  default: () => VNode[]\n}\n"],"names":[],"mappings":";;;;;;;;;AAOY,MAAC,WAAW,GAAG;AAC3B,EAAE,EAAE,EAAE,MAAM;AACZ,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,YAAY,EAAE,MAAM;AACtB,EAAE,GAAG,IAAI;AACT,EAAE,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC/B,EAAE,GAAG,QAAQ;AACb,EAAE,WAAW,EAAE,MAAM;AACrB,EAAE,GAAG,QAAQ;AACb,EAAE,MAAM,EAAE,MAAM;AAChB,EAAE,SAAS,EAAE,MAAM;AACnB,EAAE,GAAG,EAAE,MAAM;AACb,EAAE,QAAQ,EAAE,MAAM;AAClB,EAAE,QAAQ,EAAE,MAAM;AAClB,EAAE,OAAO,EAAE,MAAM;AACjB,EAAE,SAAS,EAAE,MAAM;AACnB,EAAE,KAAK,EAAE,MAAM;AACf,EAAE,KAAK,EAAE,MAAM;AACf,EAAE,OAAO,EAAE,MAAM;AACjB,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,KAAK,EAAE,MAAM;AACf,EAAE,KAAK,EAAE,MAAM;AACf,EAAE,OAAO,EAAE,MAAM;AACjB,EAAE,QAAQ,EAAE,MAAM;AAClB,EAAE,UAAU,EAAE,MAAM;AACpB,EAAE,cAAc,EAAE,MAAM;AACxB,EAAE,SAAS,EAAE,MAAM;AACnB,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,GAAG,gBAA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