"use strict"; (function (global) { function bindMouseInput(ctx) { if (!ctx?.canvas) return false; const { canvas, world, uiCache } = ctx; const actions = global.TarinaiPointerActionSystem.create(ctx); canvas.addEventListener("contextmenu", (e) => e.preventDefault()); canvas.addEventListener("mousedown", (e) => { if (e.button === 0) { const p = ctx.screenToWorldEvent(e); const started = actions?.beginToolAt?.(p, e.clientX, e.clientY, { notifyNoTarget: world.tool === "pinch" }); if (started) { e.preventDefault(); return; } } if (e.button !== 2) return; e.preventDefault(); ctx.beginPan(e.clientX, e.clientY, e.button); }); window.addEventListener("mouseup", (e) => { if (actions?.endActive?.(e.clientX, e.clientY)) return; ctx.endPan(e.button); }); window.addEventListener("mousemove", (e) => { const p = ctx.screenToWorldEvent(e); if (actions?.moveActive?.(p, e.clientX, e.clientY)) return; ctx.movePan(e.clientX, e.clientY); }); canvas.addEventListener("click", (e) => { if (actions?.shouldSuppressClick?.()) return; const p = ctx.screenToWorldEvent(e); actions?.dispatchTapAt?.(p); }); canvas.addEventListener("mousemove", (e) => ctx.updatePointerFromEvent(e)); canvas.addEventListener("wheel", resizeFieldFromWheel, { passive: false }); canvas.addEventListener("mouseleave", () => { world.pointer.inside = false; world.pointer.motion = 0; world.hoverGrabTarget = null; world.hoverDeleteTarget = null; world.hoverGiveTarget = null; world.hoverPokeTarget = null; }); return true; } global.TarinaiMouseInput = Object.freeze({ bindMouseInput }); })(window);