"use strict";(globalThis.webpackChunkwordpress_particles=globalThis.webpackChunkwordpress_particles||[]).push([[9030],{9030:(e,a,r)=>{r.r(a),r.d(a,{loadImageShape:()=>l});var o=r(1197);const t=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;async function s(e){return new Promise((a=>{e.loading=!0;const r=new Image;e.element=r,r.addEventListener("load",(()=>{e.loading=!1,a()})),r.addEventListener("error",(()=>{e.element=void 0,e.error=!0,e.loading=!1,console.error(`Error tsParticles - loading image: ${e.source}`),a()})),r.src=e.source}))}async function i(e){if("svg"!==e.type)return void await s(e);e.loading=!0;const a=await fetch(e.source);a.ok||(console.error("Error tsParticles - Image not found"),e.error=!0),e.error||(e.svgData=await a.text()),e.loading=!1}class n{constructor(){this._images=[]}addImage(e,a){const r=this.getImages(e);null==r||r.images.push(a)}destroy(){this._images=[]}draw(e,a,r,o){var t;const s=a.image,i=null==s?void 0:s.element;if(!i)return;const n=null!==(t=null==s?void 0:s.ratio)&&void 0!==t?t:1,l={x:-r,y:-r};e.globalAlpha=o,e.drawImage(i,l.x,l.y,2*r,2*r/n),e.globalAlpha=1}getImages(e){return this._images.find((a=>a.id===e.id))||(this._images.push({id:e.id,images:[]}),this.getImages(e))}getSidesCount(){return 12}loadShape(e){if("image"!==e.shape&&"images"!==e.shape)return;const a=e.container,r=this.getImages(a).images,o=e.shapeData;r.find((e=>e.source===o.src))||this.loadImageShape(a,o).then((()=>{this.loadShape(e)}))}particleInit(e,a){var r;if("image"!==a.shape&&"images"!==a.shape)return;const i=this.getImages(e).images,n=a.shapeData,l=a.getFillColor(),c=null!==(r=n.replaceColor)&&void 0!==r?r:n.replace_color,d=i.find((e=>e.source===n.src));d&&(d.loading?setTimeout((()=>{this.particleInit(e,a)})):(async()=>{var e,r;let i;i=d.svgData&&l?await function(e,a,r,i){var n,l,c;const d=function(e,a,r){const{svgData:s}=e;if(!s)return"";const i=(0,o.vz)(a,r);if(s.includes("fill"))return s.replace(t,(()=>i));const n=s.indexOf(">");return`${s.substring(0,n)} fill="${i}"${s.substring(n)}`}(e,r,null!==(l=null===(n=i.opacity)||void 0===n?void 0:n.value)&&void 0!==l?l:1),g={color:r,data:Object.assign(Object.assign({},e),{svgData:d}),loaded:!1,ratio:a.width/a.height,replaceColor:null!==(c=a.replaceColor)&&void 0!==c?c:a.replace_color,source:a.src};return new Promise((a=>{const r=new Blob([d],{type:"image/svg+xml"}),o=URL||window.URL||window.webkitURL||window,t=o.createObjectURL(r),i=new Image;i.addEventListener("load",(()=>{g.loaded=!0,g.element=i,a(g),o.revokeObjectURL(t)})),i.addEventListener("error",(async()=>{o.revokeObjectURL(t);const r=Object.assign(Object.assign({},e),{error:!1,loading:!0});await s(r),g.loaded=!0,g.element=r.element,a(g)})),i.src=t}))}(d,n,l,a):{color:l,data:d,element:d.element,loaded:!0,ratio:n.width/n.height,replaceColor:c,source:n.src},i.ratio||(i.ratio=1);const g={image:i,fill:null!==(e=n.fill)&&void 0!==e?e:a.fill,close:null!==(r=n.close)&&void 0!==r?r:a.close};a.image=g.image,a.fill=g.fill,a.close=g.close})())}async loadImageShape(e,a){var r;const o=a.src;if(!o)throw new Error("Error tsParticles - No image.src");try{const t={source:o,type:o.substring(o.length-3),error:!1,loading:!0};this.addImage(e,t);const n=(null!==(r=a.replaceColor)&&void 0!==r?r:a.replace_color)?i:s;await n(t)}catch(e){throw new Error(`tsParticles error - ${a.src} not found`)}}}async function l(e){await e.addShape(["image","images"],new n)}}}]);