import { RootElementContext } from "./context";
import { RootProps } from "./types";
import { Popover } from "@local-logic/core/ui";
import React from "react";

export const Root = (props: RootProps) => (
  <Popover.Root
    open={props.options.isOpen}
    onOpenChange={(open) =>
      props.onChange && props.onChange({ type: "open-change", data: open })
    }
  >
    <RootElementContext.Provider value={{ ...props }}>
      {props.children}
    </RootElementContext.Provider>
  </Popover.Root>
);

export const GoogleRoot = (props: RootProps) => (
  <div>
    <RootElementContext.Provider value={{ ...props }}>
      {props.children}
    </RootElementContext.Provider>
  </div>
);

// Export children
export { Marker } from "./Marker";
export { GoogleMarker } from "./Marker/GoogleMarker";
export { GoogleClusterMarker } from "./Marker/GoogleClusterMarker";
export { Content } from "./Content";
export { GoogleContent } from "./Content/GoogleContent";
