{"version":3,"file":"tippy-utils.cjs","names":["sticky"],"sources":["../../../components/popover/tippy_utils.js"],"sourcesContent":["import tippy, { sticky } from 'tippy.js';\n\nexport const BASE_TIPPY_DIRECTIONS = [\n  'bottom', 'bottom-start', 'bottom-end',\n  'right', 'right-start', 'right-end',\n  'left', 'left-start', 'left-end',\n  'top', 'top-start', 'top-end',\n];\n\nexport const TIPPY_STICKY_VALUES = [true, false, 'reference', 'popper'];\nexport const createTippyPopover = (anchorElement, options) => {\n  const { contentElement } = { ...options };\n  delete options.contentElement;\n  return tippy(anchorElement, {\n    ...options,\n    plugins: [sticky],\n    render: () => getContentWrapper(contentElement),\n  });\n};\n\nexport const createTippy = (anchorElement, options) => {\n  return tippy(anchorElement, {\n    ...options,\n    plugins: [sticky],\n  });\n};\n\nexport const getPopperOptions = ({\n  boundary = 'clippingParents',\n  fallbackPlacements = [],\n  hasHideModifierEnabled = false,\n  // If set to false the dialog will display over top of the anchor when there is insufficient space.\n  // if set to true it will never move from its position relative to the anchor and will clip instead.\n  tether = true,\n} = {}) => {\n  return {\n    modifiers: [\n      {\n        name: 'flip',\n        options: {\n          fallbackPlacements,\n          boundary,\n        },\n      },\n      {\n        name: 'hide',\n        enabled: hasHideModifierEnabled,\n      },\n      {\n        name: 'preventOverflow',\n        options: {\n          altAxis: !tether,\n          tether,\n        },\n      },\n    ],\n  };\n};\n\nconst createAnchor = (anchorWrapper) => {\n  const span = document.createElement('span');\n  span.innerText = anchorWrapper.innerText || '';\n  anchorWrapper.innerText = '';\n  anchorWrapper.appendChild(span);\n  return span;\n};\n\nexport const getAnchor = (anchorWrapper) => {\n  if (!anchorWrapper) {\n    console.warn('No anchor wrapper provided. This may cause issues with the popover.');\n    return;\n  }\n  const anchor = anchorWrapper.children[0];\n  if (!anchor) return createAnchor(anchorWrapper);\n  return anchor;\n};\n\nexport const getContentWrapper = content => {\n  // The recommended structure is to use the popper as an outer wrapper\n  const popper = document.createElement('div');\n  popper.className = 'tippy-box d-ps-absolute';\n  popper.appendChild(content);\n  return {\n    popper,\n  };\n};\n"],"mappings":"kJAEA,IAAa,EAAwB,CACnC,SAAU,eAAgB,aAC1B,QAAS,cAAe,YACxB,OAAQ,aAAc,WACtB,MAAO,YAAa,UACrB,CAEY,EAAsB,CAAC,GAAM,GAAO,YAAa,SAAS,CAC1D,GAAsB,EAAe,IAAY,CAC5D,GAAM,CAAE,kBAAmB,CAAE,GAAG,EAAS,CAEzC,OADA,OAAO,EAAQ,gBACf,EAAA,EAAA,SAAa,EAAe,CAC1B,GAAG,EACH,QAAS,CAACA,EAAAA,OAAO,CACjB,WAAc,EAAkB,EAAe,CAChD,CAAC,EAGS,GAAe,EAAe,KACzC,EAAA,EAAA,SAAa,EAAe,CAC1B,GAAG,EACH,QAAS,CAACA,EAAAA,OAAO,CAClB,CAAC,CAGS,GAAoB,CAC/B,WAAW,kBACX,qBAAqB,EAAE,CACvB,yBAAyB,GAGzB,SAAS,IACP,EAAE,IACG,CACL,UAAW,CACT,CACE,KAAM,OACN,QAAS,CACP,qBACA,WACD,CACF,CACD,CACE,KAAM,OACN,QAAS,EACV,CACD,CACE,KAAM,kBACN,QAAS,CACP,QAAS,CAAC,EACV,SACD,CACF,CACF,CACF,EAGG,EAAgB,GAAkB,CACtC,IAAM,EAAO,SAAS,cAAc,OAAO,CAI3C,MAHA,GAAK,UAAY,EAAc,WAAa,GAC5C,EAAc,UAAY,GAC1B,EAAc,YAAY,EAAK,CACxB,GAGI,EAAa,GAAkB,CAC1C,GAAI,CAAC,EAAe,CAClB,QAAQ,KAAK,sEAAsE,CACnF,OAIF,OAFe,EAAc,SAAS,IAClB,EAAa,EAAc,EAIpC,EAAoB,GAAW,CAE1C,IAAM,EAAS,SAAS,cAAc,MAAM,CAG5C,MAFA,GAAO,UAAY,0BACnB,EAAO,YAAY,EAAQ,CACpB,CACL,SACD"}