import{i as e,n as t}from"./rolldown-runtime-BKYq3fBv.js";import{Do as n,Eo as r,Fa as i,Ia as a,La as o,Oo as s,Pa as c,To as l,at as u,da as d,fo as f,it as p,po as m,ua as h}from"./dialogService-DvYmp2_F.js";var g,_=t((()=>{g=[{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:`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},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`}]}));function useKeybindingService(){let e=s(),t=r(),n=m(),i=d();function shouldForwardToCanvas(e){return e.ctrlKey||e.altKey||e.metaKey?!1:[`Delete`,`Backspace`].includes(e.key)}async function keybindHandler(n){let r=a.fromEvent(n);if(r.isModifier)return;let o=n.composedPath()[0];if(r.isReservedByTextInput&&(o.tagName===`TEXTAREA`||o.tagName===`INPUT`||o.contentEditable===`true`||o.tagName===`SPAN`&&o.classList.contains(`property_value`)))return;let s=e.getKeybinding(r);if(s&&s.targetElementId!==`graph-canvas`){if(n.key===`Escape`&&!n.ctrlKey&&!n.altKey&&!n.metaKey&&i.dialogStack.length>0)return;n.preventDefault(),new Set([`Comfy.QueuePrompt`,`Comfy.QueuePromptFront`,`Comfy.QueueSelectedOutputNodes`]).has(s.commandId)?await t.execute(s.commandId,{metadata:{trigger_source:`keybinding`}}):await t.execute(s.commandId);return}if(!s&&shouldForwardToCanvas(n)){let e=p.canvas;if(e&&e.processKey&&typeof e.processKey==`function`){e.processKey(n);return}}if(!(n.ctrlKey||n.altKey||n.metaKey)&&n.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 g)e.addDefaultKeybinding(new c(t))}function registerUserKeybindings(){let t=n.get(`Comfy.Keybinding.UnsetBindings`);for(let n of t)e.unsetKeybinding(new c(n));let r=n.get(`Comfy.Keybinding.NewBindings`);for(let t of r)e.addUserKeybinding(new c(t))}async function persistUserKeybindings(){await n.set(`Comfy.Keybinding.NewBindings`,Object.values(e.getUserKeybindings())),await n.set(`Comfy.Keybinding.UnsetBindings`,Object.values(e.getUserUnsetKeybindings()))}return{keybindHandler,registerCoreKeybindings,registerUserKeybindings,persistUserKeybindings}}var v=t((()=>{f(),u(),l(),h(),_(),o(),i(),n()}));export{useKeybindingService as n,v as t};
//# sourceMappingURL=keybindingService-DU2IypAc.js.map