"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Slower = void 0; const tsparticles_engine_1 = require("tsparticles-engine"); const Slow_1 = require("./Options/Classes/Slow"); class Slower extends tsparticles_engine_1.ExternalInteractorBase { constructor(container) { super(container); } clear(particle, delta, force) { if (particle.slow.inRange && !force) { return; } particle.slow.factor = 1; } init() { const container = this.container, slow = container.actualOptions.interactivity.modes.slow; if (!slow) { return; } container.retina.slowModeRadius = slow.radius * container.retina.pixelRatio; } interact() { return __awaiter(this, void 0, void 0, function* () { }); } isEnabled(particle) { var _a; const container = this.container, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity).events; return events.onHover.enable && !!mouse.position && (0, tsparticles_engine_1.isInArray)("slow", events.onHover.mode); } loadModeOptions(options, ...sources) { if (!options.slow) { options.slow = new Slow_1.Slow(); } for (const source of sources) { options.slow.load(source === null || source === void 0 ? void 0 : source.slow); } } reset(particle) { particle.slow.inRange = false; const container = this.container, options = container.actualOptions, mousePos = container.interactivity.mouse.position, radius = container.retina.slowModeRadius, slow = options.interactivity.modes.slow; if (!slow || !radius || radius < 0 || !mousePos) { return; } const particlePos = particle.getPosition(), dist = (0, tsparticles_engine_1.getDistance)(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slow.factor; if (dist <= radius) { particle.slow.inRange = true; particle.slow.factor = proximityFactor / slowFactor; } } } exports.Slower = Slower;