import { Handle } from "@atcute/lexicons"; import { createSignal, Show } from "solid-js"; import { resolveHandle } from "../../utils/api"; import { Button } from "../button.jsx"; import { TextInput } from "../text-input.jsx"; import { editorInstance } from "./state"; export const HandleInput = (props: { onClose: () => void }) => { const [resolving, setResolving] = createSignal(false); const [error, setError] = createSignal(""); let handleFormRef!: HTMLFormElement; const resolveDid = async (e: SubmitEvent) => { e.preventDefault(); const formData = new FormData(handleFormRef); const handleValue = formData.get("handle")?.toString().trim(); if (!handleValue) { setError("Please enter a handle"); return; } setResolving(true); setError(""); try { const did = await resolveHandle(handleValue as Handle); editorInstance.view.dispatch({ changes: { from: editorInstance.view.state.selection.main.head, insert: `"${did}"`, }, }); props.onClose(); handleFormRef.reset(); } catch (err: any) { setError(err.message || "Failed to resolve handle"); } finally { setResolving(false); } }; return (