import { t as createHeadlessToolbar } from "./create-headless-toolbar-BeX8jwVX.es.js";
import { onBeforeUnmount, shallowRef } from "vue";
var EMPTY_SNAPSHOT = {
	context: null,
	commands: {}
};
function useHeadlessToolbar(superdoc, commands) {
	if (!superdoc) return {
		snapshot: shallowRef(EMPTY_SNAPSHOT),
		execute: () => false
	};
	const controller = createHeadlessToolbar({
		superdoc,
		commands
	});
	const snapshot = shallowRef(controller.getSnapshot());
	const unsub = controller.subscribe(({ snapshot: s }) => {
		snapshot.value = s;
	});
	onBeforeUnmount(() => {
		unsub();
		controller.destroy();
	});
	const execute = ((...args) => {
		return controller.execute(...args);
	});
	return {
		snapshot,
		execute
	};
}
export { useHeadlessToolbar as t };
