{"version":3,"file":"tooltipHelper.cjs","sources":["../../../src/components/Tooltip/tooltipHelper.ts"],"sourcesContent":["export function getTooltipRect({\n  parentRect,\n  scrollOffset,\n  tooltipSize,\n  vertical,\n  horizontal,\n  isIcon = false,\n  outerMargin,\n}: {\n  parentRect: DOMRect\n  scrollOffset: { top: number; left: number }\n  tooltipSize: { width: number; height: number }\n  vertical: 'top' | 'middle' | 'bottom'\n  horizontal: 'left' | 'center' | 'right'\n  isIcon: boolean\n  outerMargin: number\n}): { top: number; left: number; $width: number; $height: number } {\n  const top = getTop({\n    parentRect,\n    tooltipHeight: tooltipSize.height,\n    vertical,\n    outerMargin,\n  })\n  const left = getLeft({\n    parentRect,\n    tooltipWidth: tooltipSize.width,\n    horizontal,\n    vertical,\n    isIcon,\n    outerMargin,\n  })\n\n  return {\n    top: top + scrollOffset.top,\n    left: left + scrollOffset.left,\n    $width: tooltipSize.width,\n    $height: tooltipSize.height,\n  }\n}\n\nfunction getTop({\n  parentRect,\n  tooltipHeight,\n  vertical,\n  outerMargin,\n}: {\n  parentRect: DOMRect\n  tooltipHeight: number\n  vertical: 'top' | 'middle' | 'bottom'\n  outerMargin: number\n}): number {\n  switch (vertical) {\n    case 'top':\n      return parentRect.top + parentRect.height + outerMargin\n    case 'middle':\n      return parentRect.top + (parentRect.height - tooltipHeight) / 2\n    case 'bottom':\n      return parentRect.top - tooltipHeight - outerMargin\n  }\n}\n\nfunction getLeft({\n  parentRect,\n  tooltipWidth,\n  horizontal,\n  vertical,\n  isIcon,\n  outerMargin,\n}: {\n  parentRect: DOMRect\n  tooltipWidth: number\n  horizontal: 'left' | 'center' | 'right'\n  vertical: 'top' | 'middle' | 'bottom'\n  isIcon: boolean\n  outerMargin: number\n}): number {\n  switch (vertical) {\n    case 'middle':\n      switch (horizontal) {\n        case 'right':\n          return parentRect.left - tooltipWidth - outerMargin\n        default:\n          return parentRect.left + parentRect.width + outerMargin\n      }\n    case 'top':\n    case 'bottom': {\n      const arrowPosition = 29 // length between Balloon edge and center of arrow\n      const iconGap = isIcon ? arrowPosition - parentRect.width / 2 : 0 // to align center of Balloon arrow and icon\n      switch (horizontal) {\n        case 'right':\n          return parentRect.left + parentRect.width - tooltipWidth + iconGap\n        case 'center':\n          return parentRect.left + (parentRect.width - tooltipWidth) / 2\n        case 'left':\n          return parentRect.left - iconGap\n      }\n    }\n  }\n}\n"],"names":[],"mappings":";;SAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,UAAU,EACV,MAAM,GAAG,KAAK,EACd,WAAW,GASZ,EAAA;IACC,MAAM,GAAG,GAAG,MAAM,CAAC;QACjB,UAAU;QACV,aAAa,EAAE,WAAW,CAAC,MAAM;QACjC,QAAQ;QACR,WAAW;AACZ,KAAA,CAAC;IACF,MAAM,IAAI,GAAG,OAAO,CAAC;QACnB,UAAU;QACV,YAAY,EAAE,WAAW,CAAC,KAAK;QAC/B,UAAU;QACV,QAAQ;QACR,MAAM;QACN,WAAW;AACZ,KAAA,CAAC;IAEF,OAAO;AACL,QAAA,GAAG,EAAE,GAAG,GAAG,YAAY,CAAC,GAAG;AAC3B,QAAA,IAAI,EAAE,IAAI,GAAG,YAAY,CAAC,IAAI;QAC9B,MAAM,EAAE,WAAW,CAAC,KAAK;QACzB,OAAO,EAAE,WAAW,CAAC,MAAM;KAC5B;AACH;AAEA,SAAS,MAAM,CAAC,EACd,UAAU,EACV,aAAa,EACb,QAAQ,EACR,WAAW,GAMZ,EAAA;IACC,QAAQ,QAAQ;AACd,QAAA,KAAK,KAAK;YACR,OAAO,UAAU,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,GAAG,WAAW;AACzD,QAAA,KAAK,QAAQ;AACX,YAAA,OAAO,UAAU,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,aAAa,IAAI,CAAC;AACjE,QAAA,KAAK,QAAQ;AACX,YAAA,OAAO,UAAU,CAAC,GAAG,GAAG,aAAa,GAAG,WAA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