import u, { useEffect as f } from "react";
import l from "react-dom/server";
import { noop as m } from "es-toolkit/function";
const p = 0, b = 0, E = (a) => {
  const { api: e, content: n, position: i, markerOffset: r, onClose: c = m } = a, s = (t) => {
    t.target.getState() === "closed" && c();
  };
  return f(() => {
    let t;
    if (e?.map && e?.ui) {
      const o = e.map.geoToScreen(i);
      o.x += r?.x ?? p, o.y += r?.y ?? b, t = new H.ui.InfoBubble(e.map.screenToGeo(o.x, o.y), {
        onStateChange: s,
        content: u.isValidElement(n) ? l.renderToStaticMarkup(n) : n
      }), e.ui.addBubble(t);
    }
    return () => {
      if (t)
        try {
          e?.ui?.removeBubble(t);
        } catch {
        }
    };
  }, [e]), null;
};
export {
  E as default
};
//# sourceMappingURL=InfoBubble.js.map
