import { jsx } from "react/jsx-runtime";
import { useEditor } from "@tldraw/editor";
import { useCallback, useRef } from "react";
import { TldrawUiInput } from "../primitives/TldrawUiInput.mjs";
const PageItemInput = function PageItemInput2({
  name,
  id,
  isCurrentPage
}) {
  const editor = useEditor();
  const rInput = useRef(null);
  const handleFocus = useCallback(() => {
    editor.mark("rename page");
  }, [editor]);
  const handleChange = useCallback(
    (value) => {
      editor.renamePage(id, value || "New Page");
    },
    [editor, id]
  );
  return /* @__PURE__ */ jsx(
    TldrawUiInput,
    {
      className: "tlui-page-menu__item__input",
      ref: (el) => rInput.current = el,
      defaultValue: name,
      onValueChange: handleChange,
      onFocus: handleFocus,
      shouldManuallyMaintainScrollPositionWhenFocused: true,
      autofocus: isCurrentPage,
      autoselect: true
    }
  );
};
export {
  PageItemInput
};
//# sourceMappingURL=PageItemInput.mjs.map
