import"./rolldown-runtime-DIIn1E2Q.js";import{t as e}from"./types-DPJvCrdo.js";import{Ii as t,Li as n,i as r,mr as i,pr as a}from"./dialogService-CfgsFapJ.js";import{t as o}from"./dialogStore-G2juoay4.js";var s=[{combo:{ctrl:!0,key:`Enter`},commandId:`Comfy.QueuePrompt`},{combo:{ctrl:!0,shift:!0,key:`Enter`},commandId:`Comfy.QueuePromptFront`},{combo:{ctrl:!0,alt:!0,key:`Enter`},commandId:`Comfy.Interrupt`},{combo:{key:`r`},commandId:`Comfy.RefreshNodeDefinitions`},{combo:{key:`w`},commandId:`Workspace.ToggleSidebarTab.workflows`},{combo:{key:`n`},commandId:`Workspace.ToggleSidebarTab.node-library`},{combo:{key:`m`},commandId:`Workspace.ToggleSidebarTab.model-library`},{combo:{key:`a`},commandId:`Workspace.ToggleSidebarTab.assets`},{combo:{alt:!0,key:`m`},commandId:`Comfy.ToggleLinear`},{combo:{alt:!0,key:`µ`},commandId:`Comfy.ToggleLinear`},{combo:{key:`s`,ctrl:!0},commandId:`Comfy.SaveWorkflow`},{combo:{key:`o`,ctrl:!0},commandId:`Comfy.OpenWorkflow`},{combo:{key:`g`,ctrl:!0},commandId:`Comfy.Graph.GroupSelectedNodes`},{combo:{key:`,`,ctrl:!0},commandId:`Comfy.ShowSettingsDialog`},{combo:{key:`=`,alt:!0},commandId:`Comfy.Canvas.ZoomIn`,targetElementId:`graph-canvas`},{combo:{key:`+`,alt:!0,shift:!0},commandId:`Comfy.Canvas.ZoomIn`,targetElementId:`graph-canvas`},{combo:{key:`+`,alt:!0},commandId:`Comfy.Canvas.ZoomIn`,targetElementId:`graph-canvas`},{combo:{key:`-`,alt:!0},commandId:`Comfy.Canvas.ZoomOut`,targetElementId:`graph-canvas`},{combo:{key:`.`},commandId:`Comfy.Canvas.FitView`,targetElementId:`graph-canvas-container`},{combo:{key:`p`},commandId:`Comfy.Canvas.ToggleSelected.Pin`,targetElementId:`graph-canvas-container`},{combo:{key:`c`,alt:!0},commandId:`Comfy.Canvas.ToggleSelectedNodes.Collapse`,targetElementId:`graph-canvas-container`},{combo:{key:`b`,ctrl:!0},commandId:`Comfy.Canvas.ToggleSelectedNodes.Bypass`,targetElementId:`graph-canvas-container`},{combo:{key:`m`,ctrl:!0},commandId:`Comfy.Canvas.ToggleSelectedNodes.Mute`,targetElementId:`graph-canvas-container`},{combo:{key:"`",ctrl:!0},commandId:`Workspace.ToggleBottomPanelTab.logs-terminal`},{combo:{key:`e`,ctrl:!0,shift:!0},commandId:`Comfy.Graph.ConvertToSubgraph`},{combo:{key:`m`,alt:!0,shift:!0},commandId:`Comfy.Canvas.ToggleMinimap`},{combo:{ctrl:!0,shift:!0,key:`k`},commandId:`Workspace.ToggleBottomPanel.Shortcuts`},{combo:{key:`v`},commandId:`Comfy.Canvas.Unlock`},{combo:{key:`h`},commandId:`Comfy.Canvas.Lock`},{combo:{key:`Escape`},commandId:`Comfy.Graph.ExitSubgraph`},{combo:{ctrl:!0,key:`a`},commandId:`Comfy.Canvas.SelectAll`,targetElementId:`graph-canvas-container`},{combo:{ctrl:!0,shift:!0,key:`v`},commandId:`Comfy.Canvas.PasteFromClipboardWithConnect`,targetElementId:`graph-canvas-container`},{combo:{key:`Delete`},commandId:`Comfy.Canvas.DeleteSelectedItems`,targetElementId:`graph-canvas-container`},{combo:{key:`Backspace`},commandId:`Comfy.Canvas.DeleteSelectedItems`,targetElementId:`graph-canvas-container`}];function useKeybindingService(){let c=n(),l=t(),u=r(),d=o();async function keybindHandler(e){let t=i.fromEvent(e);if(t.isModifier)return;let n=e.composedPath()[0];if(t.isReservedByTextInput&&(n.tagName===`TEXTAREA`||n.tagName===`INPUT`||n.contentEditable===`true`||n.tagName===`SPAN`&&n.classList.contains(`property_value`)))return;let r=c.getKeybinding(t);if(r){let t=r.targetElementId===`graph-canvas`?`graph-canvas-container`:r.targetElementId;if(t&&!document.getElementById(t)?.contains(n)||e.key===`Escape`&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&d.dialogStack.length>0)return;e.preventDefault(),new Set([`Comfy.QueuePrompt`,`Comfy.QueuePromptFront`,`Comfy.QueueSelectedOutputNodes`]).has(r.commandId)?await l.execute(r.commandId,{metadata:{trigger_source:`keybinding`}}):await l.execute(r.commandId);return}if(!(e.ctrlKey||e.altKey||e.metaKey)&&e.key===`Escape`){let e=document.querySelectorAll(`.comfy-modal`);for(let t of e)if(window.getComputedStyle(t).getPropertyValue(`display`)!==`none`){t.style.display=`none`;break}for(let e of document.querySelectorAll(`dialog`))e.close()}}function registerCoreKeybindings(){for(let t of s)e&&t.commandId===`Workspace.ToggleBottomPanelTab.logs-terminal`||c.addDefaultKeybinding(new a(t))}function registerUserKeybindings(){let t=u.get(`Comfy.Keybinding.UnsetBindings`);for(let e of t)c.unsetKeybinding(new a(e));let n=u.get(`Comfy.Keybinding.NewBindings`);for(let t of n)e&&t.commandId===`Workspace.ToggleBottomPanelTab.logs-terminal`||c.addUserKeybinding(new a(t))}async function persistUserKeybindings(){await u.setMany({"Comfy.Keybinding.NewBindings":Object.values(c.getUserKeybindings()),"Comfy.Keybinding.UnsetBindings":Object.values(c.getUserUnsetKeybindings())})}return{keybindHandler,registerCoreKeybindings,registerUserKeybindings,persistUserKeybindings}}export{useKeybindingService as t};
//# sourceMappingURL=keybindingService-JaMQaEFh.js.map