"use strict";(globalThis.webpackChunk_tsparticles_wordpress=globalThis.webpackChunk_tsparticles_wordpress||[]).push([[6786],{6786(a,e,t){t.d(e,{BackgroundMaskPluginInstance:()=>n});var i=t(3199);class n{#a;#e;#t;#i;#n;constructor(a,e){this.#n=a,this.#a=e}canvasClear(){const a=this.#a.actualOptions.backgroundMask;return!!a?.enable&&this.canvasPaint()}canvasPaint(){if(!this.#a.actualOptions.backgroundMask?.enable)return!1;const a=this.#a.canvas;return a.render.canvasClear(),this.#t?a.render.paintImage(this.#t.image,this.#t.opacity):a.render.paintBase(this.#e),!0}drawSettingsCleanup(a){this.#i&&(a.globalCompositeOperation=this.#i)}drawSettingsSetup(a){const e=a.globalCompositeOperation,t=this.#a.actualOptions.backgroundMask;this.#i=e,a.globalCompositeOperation=t?.enable?t.composite:e}async init(){await this.#o()}#o=async()=>{const a=this.#a.actualOptions,e=a.backgroundMask?.cover,t=e?.color;if(t){const a=(0,i.BN0)(this.#n,t);if(a){const t={...a,a:e.opacity};this.#e=(0,i.xxz)(t,this.#a.hdr,t.a)}}else await new Promise((a,t)=>{if(!e?.image)return;const n=(0,i.T5G)().createElement("img");n.addEventListener("load",()=>{this.#t={image:n,opacity:e.opacity},a()}),n.addEventListener("error",()=>{t(new Error("Error loading image"))}),n.src=e.image})}}}}]);