PageSourceSearch

https://teamup-tech-chord-extractor.hf.space/assets/Index-BpOBH0lB.js

js teamup-tech-chord-extractor.hf.space collected 2026-10-03 17:26:57 UTC 463,491 bytes, 571 lines download raw bytes

1const __vite__fileDeps=["./browserAll-CViobIBh.js","./init-B2O0WK0N.js","./colorToUniform-KTpA7KSL.js","./index-BL1Z-Foy.js","./index-fBnC7CZV.css","./ImagePreview-D9E8NxoB.js","./IconButtonWrapper.svelte_svelte_type_style_lang-Dn324h3u.js","./IconButtonWrapper-BoUZMnMb.css","./utils-BsGrhMNe.js","./MarkdownCode.svelte_svelte_type_style_lang-D96FH13R.js","./prism-python-BRDN3PNV.js","./MarkdownCode-DDNRNM05.css","./BlockLabel-8WtM61r3.js","./IconButton-DSs-aBrk.js","./Empty-AVq7jL0F.js","./ShareButton-CuWfx-Ef.js","./Community-Dw1micSV.js","./Download-DVtk-Jv3.js","./FullscreenButton-CZXRKqXs.js","./IconButtonWrapper-jknaAjP6.js","./utils-Gtzs_Zla.js","./Image-CnqB5dbD.js","./file-url-DoxvUUVV.js","./DownloadLink.svelte_svelte_type_style_lang-C_5UIfol.js","./DownloadLink-CqD3Uu0l.css","./Image-B8dFOee4.css","./DownloadLink-QIttOhoR.js","./ImagePreview-C_qhEOxI.css","./ImageUploader-BS_ouPDJ.js","./Clear-By3xiIwg.js","./SelectSource-CKfu_LoW.js","./Upload-DFn3To6N.js","./Upload-L7mprsyN.css","./DropdownArrow-CFmkDyPW.js","./Square-oAGqOwsh.js","./StreamingBar.svelte_svelte_type_style_lang-CDNxkBIr.js","./StreamingBar-DOagx4HU.css","./index-DfebmzpM.js","./StreamingBar-BU9S4hA7.js","./ImageUploader-DMdYP1a9.css","./Block-CygNNd5z.js","./index-CQBmOxAf.js","./tinycolor-DhRrpXkc.js","./Check-CEkiXcyC.js","./Trash-RbZEwH-j.js","./Example-DikqVAPo.css","./webworkerAll-CFHrejbB.js","./WebGPURenderer-C5fANo1j.js","./SharedSystems-C1oIi1nq.js","./WebGLRenderer-OGv4ygO6.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
2import{_ as Gn,g as ra,o as Pn,w as $s,h as dr,F as _r}from"./index-BL1Z-Foy.js";import e_ from"./ImagePreview-D9E8NxoB.js";import{C as Cc,W as t_}from"./ImageUploader-BS_ouPDJ.js";import{B as Mc}from"./Block-CygNNd5z.js";import"./MarkdownCode.svelte_svelte_type_style_lang-D96FH13R.js";import"./IconButtonWrapper.svelte_svelte_type_style_lang-Dn324h3u.js";
2import{s as fr,S as Tc}from"./index-CQBmOxAf.js";import"./StreamingBar.svelte_svelte_type_style_lang-CDNxkBIr.js";import"./DownloadLink.svelte_svelte_type_style_lang-C_5UIfol.js";import"./Image-CnqB5dbD.js";/* empty css                                              */import{I as Pc}from"./FullscreenButton-CZXRKqXs.js";import{U as i_,I as s_,c as n_}from"./Upload-DFn3To6N.js";import{W as r_}from"./SelectSource-CKfu_LoW.js";import{t as je,E as o_}from"./tinycolor-DhRrpXkc.js";import{C as zc}from"./Check-CEkiXcyC.js";/* empty css                                                   *//* empty css                                             */import{C as a_}from"./Clear-By3xiIwg.js";import{I as at}from"./IconButton-DSs-aBrk.js";import{D as l_}from"./Download-DVtk-Jv3.js";import{T as h_}from"./Trash-RbZEwH-j.js";import{I as c_}from"./IconButtonWrapper-jknaAjP6.js";import{B as u_}from"./BlockLabel-8WtM61r3.js";const{SvelteComponent:d_,append:Pa,attr:Ge,detach:__,init:f_,insert:g_,noop:gr,safe_not_equal:p_,svg_element:pr}=window.__gradio__svelte__internal;function m_(s){let e,t,i;return{c(){e=pr("svg"),t=pr("line"),i=pr("polyline"),Ge(t,"x1","12"),Ge(t,"y1","19"),Ge(t,"x2","12"),Ge(t,"y2","5"),Ge(i,"points","5 12 12 5 19 12"),Ge(e,"width","100%"),Ge(e,"height","100%"),Ge(e,"xmlns","http://www.w3.org/2000/svg"),Ge(e,"viewBox","0 0 24 24"),Ge(e,"fill","none"),Ge(e,"stroke","currentColor"),Ge(e,"stroke-width","2"),Ge(e,"stroke-linecap","round"),Ge(e,"stroke-linejoin","round")},m(n,r){g_(n,e,r),Pa(e,t),Pa(e,i)},p:gr,i:gr,o:gr,d(n){n&&__(e)}}}class b_ extends d_{constructor(e){super(),f_(this,e,null,m_,p_,{})}}const{SvelteComponent:y_,append:za,attr:Ne,detach:w_,init:x_,insert:v_,noop:mr,safe_not_equal:k_,svg_element:br}=window.__gradio__svelte__internal;function A_(s){let e,t,i;return{c(){e=br("svg"),t=br("line"),i=br("polyline"),Ne(t,"x1","12"),Ne(t,"y1","5"),Ne(t,"x2","12"),Ne(t,"y2","19"),Ne(i,"points","19 12 12 19 5 12"),Ne(e,"width","100%"),Ne(e,"height","100%"),Ne(e,"xmlns","http://www.w3.org/2000/svg"),Ne(e,"viewBox","0 0 24 24"),Ne(e,"fill","none"),Ne(e,"stroke","currentColor"),Ne(e,"stroke-width","2"),Ne(e,"stroke-linecap","round"),Ne(e,"stroke-linejoin","round")},m(n,r){v_(n,e,r),za(e,t),za(e,i)},p:mr,i:mr,o:mr,d(n){n&&w_(e)}}}class S_ extends y_{constructor(e){super(),x_(this,e,null,A_,k_,{})}}const{SvelteComponent:C_,append:Ia,attr:fi,detach:M_,init:T_,insert:P_,noop:yr,safe_not_equal:z_,svg_element:wr}=window.__gradio__svelte__internal;function I_(s){let e,t,i;return{c(){e=wr("svg"),t=wr("path"),i=wr("path"),fi(t,"d","M28.828 3.172a4.094 4.094 0 0 0-5.656 0L4.05 22.292A6.954 6.954 0 0 0 2 27.242V30h2.756a6.952 6.952 0 0 0 4.95-2.05L28.828 8.829a3.999 3.999 0 0 0 0-5.657zM10.91 18.26l2.829 2.829l-2.122 2.121l-2.828-2.828zm-2.619 8.276A4.966 4.966 0 0 1 4.756 28H4v-.759a4.967 4.967 0 0 1 1.464-3.535l1.91-1.91l2.829 2.828zM27.415 7.414l-12.261 12.26l-2.829-2.828l12.262-12.26a2.047 2.047 0 0 1 2.828 0a2 2 0 0 1 0 2.828z"),fi(t,"fill","currentColor"),fi(i,"d","M6.5 15a3.5 3.5 0 0 1-2.475-5.974l3.5-3.5a1.502 1.502 0 0 0 0-2.121a1.537 1.537 0 0 0-2.121 0L3.415 5.394L2 3.98l1.99-1.988a3.585 3.585 0 0 1 4.95 0a3.504 3.504 0 0 1 0 4.949L5.439 10.44a1.502 1.502 0 0 0 0 2.121a1.537 1.537 0 0 0 2.122 0l4.024-4.024L13 9.95l-4.025 4.024A3.475 3.475 0 0 1 6.5 15z"),fi(i,"fill","currentColor"),fi(e,"width","100%"),fi(e,"height","100%"),fi(e,"viewBox","0 0 32 32")},m(n,r){P_(n,e,r),Ia(e,t),Ia(e,i)},p:yr,i:yr,o:yr,d(n){n&&M_(e)}}}class E_ extends C_{constructor(e){super(),T_(this,e,null,I_,z_,{})}}const{SvelteComponent:R_,append:F_,attr:Gi,detach:B_,init:L_,insert:$_,noop:xr,safe_not_equal:O_,svg_element:Ea}=window.__gradio__svelte__internal;function G_(s){let e,t;return{c(){e=Ea("svg"),t=Ea("path"),Gi(t,"fill","currentColor"),Gi(t,"d","M2.753 2.933a.75.75 0 0 1 .814-.68l3.043.272c2.157.205 4.224.452 5.922.732c1.66.273 3.073.594 3.844.983c.197.1.412.233.578.415c.176.192.352.506.28.9c-.067.356-.304.59-.487.729a3.001 3.001 0 0 1-.695.369c-1.02.404-2.952.79-5.984 1.169c-1.442.18-2.489.357-3.214.522c.205.045.43.089.674.132c.992.174 2.241.323 3.568.437a31.21 31.21 0 0 1 3.016.398c.46.087.893.186 1.261.296c.352.105.707.236.971.412c.13.086.304.225.42.437a.988.988 0 0 1 .063.141A1.75 1.75 0 0 0 14.5 12.25v.158c-.758.154-1.743.302-2.986.444c-2.124.243-3.409.55-4.117.859c-.296.128-.442.236-.508.3c.026.037.073.094.156.17c.15.138.369.29.65.45c.56.316 1.282.61 1.979.838l2.637.814a.75.75 0 1 1-.443 1.433l-2.655-.819c-.754-.247-1.58-.578-2.257-.96a5.082 5.082 0 0 1-.924-.65c-.255-.233-.513-.544-.62-.935c-.12-.441-.016-.88.274-1.244c.261-.328.656-.574 1.113-.773c.92-.4 2.387-.727 4.545-.974c1.366-.156 2.354-.313 3.041-.462a16.007 16.007 0 0 0-.552-.114a29.716 29.716 0 0 0-2.865-.378c-1.352-.116-2.649-.27-3.7-.454c-.524-.092-1-.194-1.395-.307c-.376-.106-.75-.241-1.021-.426a1.186 1.186 0 0 1-.43-.49a.934.934 0 0 1 .059-.873c.13-.213.32-.352.472-.442a3.23 3.23 0 0 1 .559-.251c.807-.287 2.222-.562 4.37-.83c2.695-.338 4.377-.666 5.295-.962c-.
2638-.21-1.623-.427-2.89-.635c-1.65-.273-3.679-.515-5.816-.718l-3.038-.272a.75.75 0 0 1-.68-.814M17 12.25a.75.75 0 0 0-1.5 0v4.19l-.72-.72a.75.75 0 1 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l2-2a.75.75 0 1 0-1.06-1.06l-.72.72z"),Gi(e,"xmlns","http://www.w3.org/2000/svg"),Gi(e,"width","100%"),Gi(e,"height","100%"),Gi(e,"viewBox","0 0 24 24")},m(i,n){$_(i,e,n),F_(e,t)},p:xr,i:xr,o:xr,d(i){i&&B_(e)}}}class N_ extends R_{constructor(e){super(),L_(this,e,null,G_,O_,{})}}const{SvelteComponent:D_,append:U_,attr:Ni,detach:W_,init:H_,insert:q_,noop:vr,safe_not_equal:V_,svg_element:Ra}=window.__gradio__svelte__internal;function X_(s){let e,t;return{c(){e=Ra("svg"),t=Ra("path"),Ni(t,"fill","currentColor"),Ni(t,"d","M12 22q-2.05 0-3.875-.788t-3.187-2.15t-2.15-3.187T2 12q0-2.075.813-3.9t2.2-3.175T8.25 2.788T12.2 2q2 0 3.775.688t3.113 1.9t2.125 2.875T22 11.05q0 2.875-1.75 4.413T16 17h-1.85q-.225 0-.312.125t-.088.275q0 .3.375.863t.375 1.287q0 1.25-.687 1.85T12 22m-5.5-9q.65 0 1.075-.425T8 11.5t-.425-1.075T6.5 10t-1.075.425T5 11.5t.425 1.075T6.5 13m3-4q.65 0 1.075-.425T11 7.5t-.425-1.075T9.5 6t-1.075.425T8 7.5t.425 1.075T9.5 9m5 0q.65 0 1.075-.425T16 7.5t-.425-1.075T14.5 6t-1.075.425T13 7.5t.425 1.075T14.5 9m3 4q.65 0 1.075-.425T19 11.5t-.425-1.075T17.5 10t-1.075.425T16 11.5t.425 1.075T17.5 13"),Ni(e,"xmlns","http://www.w3.org/2000/svg"),Ni(e,"width","100%"),Ni(e,"height","100%"),Ni(e,"viewBox","0 0 24 24")},m(i,n){q_(i,e,n),U_(e,t)},p:vr,i:vr,o:vr,d(i){i&&W_(e)}}}class Y_ extends D_{constructor(e){super(),H_(this,e,null,X_,V_,{})}}const{SvelteComponent:j_,append:K_,attr:Di,detach:Z_,init:Q_,insert:J_,noop:kr,safe_not_equal:ef,svg_element:Fa}=window.__gradio__svelte__internal;function tf(s){let e,t;return{c(){e=Fa("svg"),t=Fa("path"),Di(t,"fill","currentColor"),Di(t,"d","M240 192a8 8 0 0 1-8 8h-32v32a8 8 0 0 1-16 0v-32H64a8 8 0 0 1-8-8V72H24a8 8 0 0 1 0-16h32V24a8 8 0 0 1 16 0v160h160a8 8 0 0 1 8 8M96 72h88v88a8 8 0 0 0 16 0V64a8 8 0 0 0-8-8H96a8 8 0 0 0 0 16"),Di(e,"xmlns","http://www.w3.org/2000/svg"),Di(e,"width","100%"),Di(e,"height","100%"),Di(e,"viewBox","0 0 256 256")},m(i,n){J_(i,e,n),K_(e,t)},p:kr,i:kr,o:kr,d(i){i&&Z_(e)}}}class sf extends j_{constructor(e){super(),Q_(this,e,null,tf,ef,{})}}const{SvelteComponent:nf,append:Ar,attr:ct,detach:rf,init:of,insert:af,noop:Sr,safe_not_equal:lf,svg_element:hn}=window.__gradio__svelte__internal;function hf(s){let e,t,i,n;return{c(){e=hn("svg"),t=hn("g"),i=hn("path"),n=hn("path"),ct(i,"fill","currentColor"),ct(i,"d","m5.505 11.41l.53.53l-.53-.53ZM3 14.952h-.75H3ZM9.048 21v.75V21ZM11.41 5.505l-.53-.53l.53.53Zm1.831 12.34a.75.75 0 0 0 1.06-1.061l-1.06 1.06ZM7.216 9.697a.75.75 0 1 0-1.06 1.061l1.06-1.06Zm10.749 2.362l-5.905 5.905l1.06 1.06l5.905-5.904l-1.06-1.06Zm-11.93-.12l5.905-5.905l-1.06-1.06l-5.905 5.904l1.06 1.06Zm0 6.025c-.85-.85-1.433-1.436-1.812-1.933c-.367-.481-.473-.79-.473-1.08h-1.5c0 .749.312 1.375.78 1.99c.455.596 1.125 1.263 1.945 2.083l1.06-1.06Zm-1.06-7.086c-.82.82-1.49 1.488-1.945 2.084c-.468.614-.78 1.24-.78 1.99h1.5c0-.29.106-.6.473-1.08c.38-.498.962-1.083 1.812-1.933l-1.06-1.06Zm7.085 7.086c-.85.85-1.435 1.433-1.933 1.813c-.48.366-.79.472-1.08.472v1.5c.75 0 1.376-.312 1.99-.78c.596-.455 1.264-1.125 2.084-1.945l-1.06-1.06Zm-7.085 1.06c.82.82 1.487 1.49 2.084 1.945c.614.468 1.24.78 1.989.78v-1.5c-.29 0-.599-.106-1.08-.473c-.497-.38-1.083-.962-1.933-1.812l-1.06 1.06Zm12.99-12.99c.85.85 1.433 1.436 1.813 1.933c.366.481.472.79.472 1.08h1.5c0-.749-.312-1.375-.78-1.99c-.455-.596-1.125-1.263-1.945-2.083l-1.06 1.06Zm1.06 7.086c.82-.82 1.49-1.488 1.945-2.084c.468-.614.78-1.24.78-1.99h-1.5c0 .29-.106.6-.473 1.08c-.38.498-.962 1.083-1.812 1.933l1.06 1.06Zm0-8.146c-.82-.82-1.487-1.49-2.084-1.945c-.614-.468-1.24-.78-1.989-.78v1.5c.29 0 .599.106 1.08.473c.497.38 1.083.962 1.933 1.812l1.06-1.06Zm-7.085 1.06c.85-.85 1.435-1.433 1.933-1.812c.48-.367.79-.473 1.08-.473v-1.5c-.75 0-1.376.312-1.99.78c-.596.455-1.264 1.125-2.084 1.945l1.06 1.06Zm2.362 10.749L7.216 9.698l-1.06 1.061l7.085 7.085l1.06-1.06Z"),ct(n,"stroke","currentColor"),ct(n,"stroke-linecap","round"),ct(n,"stroke-width","1.5"),ct(n,"d","M9 21h12"),ct(t,"fill","none"),ct(e,"xmlns","http://www.w3.org/2000/svg"),ct(e,"width","100%"),ct(e,"height","100%"),ct(e,"viewBox","0 0 24 24")},m(r,o){af(r,e,o),Ar(e,t),Ar(t,i),Ar(t,n)},p:Sr,i:Sr,o:Sr,d(r){r&&rf(e)}}}class cf extends nf{constructor(e){super(),of(this,e,null,hf,lf,{})}}const{SvelteComponent:uf,append:Ba,attr:st,detach:df,init:_f,insert:ff,noop:Cr,safe_not_equal:gf,svg_element:Mr}=window.__gradio__svelte__internal;function pf(s){let e,t,i;return{c(){e=Mr("svg"),t=Mr("path"),i=Mr("path"),st(t,"d","M1.35327 10.9495L6.77663 15.158C7.12221 15.4229 7.50051 15.5553 7.91154 15.5553C8.32258 15.5553 8.70126 15.4229 9.0476 15.158L14.471 10.9495"),st(t,"stroke","currentColor"),st(t,"stroke-width","1.5"),st(t,"stroke-linecap","round"),st(i,"d","M7.23461 11.4324C7.23406 11.432 7.2335 11.4316 7.23295 11.4312L1.81496 7.2268C1.81471 7.22661 1.81446 7.22641 1.8142 7.22621C1.52269 6.99826 1.39429 6.73321 1.39429 6.37014C1.39429 6.00782 1.52236 5.74301 1.81325 5.51507C1.8136 5.5148 1.81394 5.51453 1.81428 5.51426L7.2331 1.30812C7.45645 1.13785 7.67632 1.06653 7.91159 1.06653C8.14692 1.06653 8.36622 1.13787 8.58861 1.30787C8.58915 1.30828 8.58969 1.30869 8.59023 1.30911L14.0082 5.51462C14.0085 5.51485 14.0088 5.51507 14.0091 5.51529C14.3008 5.74345 14.4289 6.00823 14.4289 6.37014C14.4289 6.73356 14.3006 6.99862 14.01 7.22634C14.0096 7.22662 14.0093 7.22689 14.0089 7.22717L8.59007 11.4322C8.36672 11.6024 8.14686 11.6738 7.91159 11.6738C7.67628 11.6738 7.45699 11.6024 7.23461 11.4324Z"),st(i,"stroke","currentColor"),st(i,"stroke-width","1.5"),st(e,"width","100%"),st(e,"height","100%"),st(e,"viewBox","0 0 17 17"),st(e,"fill","none"),st(e,"xmlns","http://www.w3.org/2000/svg")},m(n,r){ff(n,e,r),Ba(e,t),Ba(e,i)},p:Cr,i:Cr,o:Cr,d(n){n&&df(e)}}}class mf extends uf{constructor(e){super(),_f(this,e,null,pf,gf,{})}}const{SvelteComponent:bf,append:yf,attr:Ui,detach:wf,init:xf,insert:vf,noop:Tr,safe_not_equal:kf,svg_element:La}=window.__gradio__svelte__internal;function Af(s){let e,t;return{c(){e=La("svg"),t=La("path"),Ui(t,"fill","currentColor"),Ui(t,"d","M10.05 23q-.75 0-1.4-.337T7.575 21.7l-5.9-8.65q-.2-.3-.175-.65t.3-.6q.475-.475 1.125-.55t1.175.3L7 13.575V4q0-.425.288-.712T8 3t.713.288T9 4v11.5q0 .6-.537.888t-1.038-.063l-2.125-1.5l3.925 5.725q.125.2.35.325t.475.125H17q.825 0 1.413-.587T19 19V5q0-.425.288-.712T20 4t.713.288T21 5v14q0 1.65-1.175 2.825T17 23zM12 1q.425 0 .713.288T13 2v9q0 .425-.288.713T12 12t-.712-.288T11 11V2q
20-.425.288-.712T12 1m4 1q.425 0 .713.288T17 3v8q0 .425-.288.713T16 12t-.712-.288T15 11V3q0-.425.288-.712T16 2m-3.85 14.5"),Ui(e,"xmlns","http://www.w3.org/2000/svg"),Ui(e,"width","100%"),Ui(e,"height","100%"),Ui(e,"viewBox","0 0 24 24")},m(i,n){vf(i,e,n),yf(e,t)},p:Tr,i:Tr,o:Tr,d(i){i&&wf(e)}}}class Sf extends bf{constructor(e){super(),xf(this,e,null,Af,kf,{})}}const{SvelteComponent:Cf,append:Mf,attr:Mt,detach:Tf,init:Pf,insert:zf,noop:Pr,safe_not_equal:If,svg_element:$a}=window.__gradio__svelte__internal;function Ef(s){let e,t;return{c(){e=$a("svg"),t=$a("path"),Mt(t,"d","M6 12H12M18 12H12M12 12V6M12 12V18"),Mt(t,"stroke","currentColor"),Mt(t,"stroke-width","1.5"),Mt(t,"stroke-linecap","round"),Mt(t,"stroke-linejoin","round"),Mt(e,"width","100%"),Mt(e,"height","100%"),Mt(e,"viewBox","0 0 24 24"),Mt(e,"fill","none"),Mt(e,"xmlns","http://www.w3.org/2000/svg")},m(i,n){zf(i,e,n),Mf(e,t)},p:Pr,i:Pr,o:Pr,d(i){i&&Tf(e)}}}class Ic extends Cf{constructor(e){super(),Pf(this,e,null,Ef,If,{})}}const{SvelteComponent:Rf,append:Ff,attr:Wi,detach:Bf,init:Lf,insert:$f,noop:zr,safe_not_equal:Of,svg_element:Oa}=window.__gradio__svelte__internal;function Gf(s){let e,t;return{c(){e=Oa("svg"),t=Oa("path"),Wi(t,"fill","currentColor"),Wi(t,"d","M12 16q1.875 0 3.188-1.312T16.5 11.5t-1.312-3.187T12 7T8.813 8.313T7.5 11.5t1.313 3.188T12 16m0-1.8q-1.125 0-1.912-.788T9.3 11.5t.788-1.912T12 8.8t1.913.788t.787 1.912t-.787 1.913T12 14.2m0 4.8q-3.65 0-6.65-2.037T1 11.5q1.35-3.425 4.35-5.462T12 4t6.65 2.038T23 11.5q-1.35 3.425-4.35 5.463T12 19"),Wi(e,"xmlns","http://www.w3.org/2000/svg"),Wi(e,"width","100%"),Wi(e,"height","100%"),Wi(e,"viewBox","0 0 24 24")},m(i,n){$f(i,e,n),Ff(e,t)},p:zr,i:zr,o:zr,d(i){i&&Bf(e)}}}class Nf extends Rf{constructor(e){super(),Lf(this,e,null,Gf,Of,{})}}const{SvelteComponent:Df,append:Uf,attr:Hi,detach:Wf,init:Hf,insert:qf,noop:Ir,safe_not_equal:Vf,svg_element:Ga}=window.__gradio__svelte__internal;function Xf(s){let e,t;return{c(){e=Ga("svg"),t=Ga("path"),Hi(t,"fill","currentColor"),Hi(t,"d","m19.8 22.6l-4.2-4.15q-.875.275-1.762.413T12 19q-3.775 0-6.725-2.087T1 11.5q.525-1.325 1.325-2.463T4.15 7L1.4 4.2l1.4-1.4l18.4 18.4zM12 16q.275 0 .513-.025t.512-.1l-5.4-5.4q-.075.275-.1.513T7.5 11.5q0 1.875 1.313 3.188T12 16m7.3.45l-3.175-3.15q.175-.425.275-.862t.1-.938q0-1.875-1.312-3.187T12 7q-.5 0-.937.1t-.863.3L7.65 4.85q1.025-.425 2.1-.637T12 4q3.775 0 6.725 2.088T23 11.5q-.575 1.475-1.513 2.738T19.3 16.45m-4.625-4.6l-3-3q.7-.125 1.288.113t1.012.687t.613 1.038t.087 1.162"),Hi(e,"xmlns","http://www.w3.org/2000/svg"),Hi(e,"width","100%"),Hi(e,"height","100%"),Hi(e,"viewBox","0 0 24 24")},m(i,n){qf(i,e,n),Uf(e,t)},p:Ir,i:Ir,o:Ir,d(i){i&&Wf(e)}}}class Yf extends Df{constructor(e){super(),Hf(this,e,null,Xf,Vf,{})}}const{SvelteComponent:jf,append:Kf,attr:qi,detach:Zf,init:Qf,insert:Jf,noop:Er,safe_not_equal:eg,svg_element:Na}=window.__gradio__svelte__internal;function tg(s){let e,t;return{c(){e=Na("svg"),t=Na("path"),qi(t,"fill","currentColor"),qi(t,"d","M144 120v88a8 8 0 0 1-8 8H48a8 8 0 0 1-8-8v-88a8 8 0 0 1 8-8h88a8 8 0 0 1 8 8m64 56a8 8 0 0 0-8 8v16h-24a8 8 0 0 0 0 16h24a16 16 0 0 0 16-16v-16a8 8 0 0 0-8-8m0-72a8 8 0 0 0-8 8v32a8 8 0 0 0 16 0v-32a8 8 0 0 0-8-8m-8-64h-16a8 8 0 0 0 0 16h16v16a8 8 0 0 0 16 0V56a16 16 0 0 0-16-16m-56 0h-32a8 8 0 0 0 0 16h32a8 8 0 0 0 0-16M48 88a8 8 0 0 0 8-8V56h16a8 8 0 0 0 0-16H56a16 16 0 0 0-16 16v24a8 8 0 0 0 8 8"),qi(e,"xmlns","http://www.w3.org/2000/svg"),qi(e,"width","100%"),qi(e,"height","100%"),qi(e,"viewBox","0 0 256 256")},m(i,n){Jf(i,e,n),Kf(e,t)},p:Er,i:Er,o:Er,d(i){i&&Zf(e)}}}class ig extends jf{constructor(e){super(),Qf(this,e,null,tg,eg,{})}}const{SvelteComponent:sg,append:ng,attr:Tt,detach:rg,init:og,insert:ag,noop:Rr,safe_not_equal:lg,svg_element:Da}=window.__gradio__svelte__internal;function hg(s){let e,t;return{c(){e=Da("svg"),t=Da("path"),Tt(t,"fill","none"),Tt(t,"stroke","currentColor"),Tt(t,"stroke-linecap","round"),Tt(t,"stroke-linejoin","round"),Tt(t,"stroke-width","2"),Tt(t,"d","m21 21l-4.343-4.343m0 0A8 8 0 1 0 5.343 5.343a8 8 0 0 0 11.314 11.314M11 8v6m-3-3h6"),Tt(e,"xmlns","http://www.w3.org/2000/svg"),Tt(e,"width","100%"),Tt(e,"height","100%"),Tt(e,"viewBox","0 0 24 24")},m(i,n){ag(i,e,n),ng(e,t)},p:Rr,i:Rr,o:Rr,d(i){i&&rg(e)}}}class cg extends sg{constructor(e){super(),og(this,e,null,hg,lg,{})}}const{SvelteComponent:ug,append:dg,attr:Pt,detach:_g,init:fg,insert:gg,noop:Fr,safe_not_equal:pg,svg_element:Ua}=window.__gradio__svelte__internal;function mg(s){let e,t;return{c(){e=Ua("svg"),t=Ua("path"),Pt(t,"fill","none"),Pt(t,"stroke","currentColor"),Pt(t,"stroke-linecap","round"),Pt(t,"stroke-linejoin","round"),Pt(t,"stroke-width","2"),Pt(t,"d","m21 21l-4.343-4.343m0 0A8 8 0 1 0 5.343 5.343a8 8 0 0 0 11.314 11.314M8 11h6"),Pt(e,"xmlns","http://www.w3.org/2000/svg"),Pt(e,"width","100%"),Pt(e,"height","100%"),Pt(e,"viewBox","0 0 24 24")},m(i,n){gg(i,e,n),dg(e,t)}
vendor: 124,061 bytes, lines 2-25
2,p:Fr,i:Fr,o:Fr,d(i){i&&_g(e)}}}class bg extends ug{constructor(e){super(),fg(this,e,null,mg,pg,{})}}const{SvelteComponent:yg,append:Os,attr:dt,bubble:wg,create_component:xg,destroy_component:vg,detach:oa,element:Nn,flush:Fe,init:kg,insert:aa,listen:Ag,mount_component:Sg,safe_not_equal:Cg,set_data:Ec,set_style:Jt,space:Wa,text:Rc,toggle_class:De,transition_in:Mg,transition_out:Tg}=window.__gradio__svelte__internal;function Ha(s){let e,t;return{c(){e=Nn("span"),t=Rc(s[1]),Jt(e,"margin-left","4px"),dt(e,"class","svelte-rrog8b")},m(i,n){aa(i,e,n),Os(e,t)},p(i,n){n&2&&Ec(t,i[1])},d(i){i&&oa(e)}}}function qa(s){let e,t;return{c(){e=Nn("span"),t=Rc(s[1]),Jt(e,"margin-right","4px"),dt(e,"class","svelte-rrog8b")},m(i,n){aa(i,e,n),Os(e,t)},p(i,n){n&2&&Ec(t,i[1])},d(i){i&&oa(e)}}}function Pg(s){let e,t,i,n,r,o,a,l,h,c=s[2]&&s[12]==="left"&&Ha(s);n=new s[0]({});let u=s[2]&&s[12]==="right"&&qa(s);return{c(){e=Nn("button"),c&&c.c(),t=Wa(),i=Nn("div"),xg(n.$$.fragment),r=Wa(),u&&u.c(),dt(i,"class","svelte-rrog8b"),De(i,"small",s[4]==="small"),De(i,"large",s[4]==="large"),De(i,"medium",s[4]==="medium"),e.disabled=s[7],dt(e,"aria-label",s[1]),dt(e,"aria-haspopup",s[8]),dt(e,"title",s[1]),dt(e,"class",o=s[13]+"-round svelte-rrog8b"),De(e,"pending",s[3]),De(e,"padded",s[5]),De(e,"highlight",s[6]),De(e,"transparent",s[9]),Jt(e,"color",!s[7]&&s[14]?s[14]:"var(--block-label-text-color)"),Jt(e,"--bg-color",s[7]?"auto":s[10]),Jt(e,"margin-left",s[11]+"px")},m(d,_){aa(d,e,_),c&&c.m(e,null),Os(e,t),Os(e,i),Sg(n,i,null),Os(e,r),u&&u.m(e,null),a=!0,l||(h=Ag(e,"click",s[16]),l=!0)},p(d,[_]){d[2]&&d[12]==="left"?c?c.p(d,_):(c=Ha(d),c.c(),c.m(e,t)):c&&(c.d(1),c=null),(!a||_&16)&&De(i,"small",d[4]==="small"),(!a||_&16)&&De(i,"large",d[4]==="large"),(!a||_&16)&&De(i,"medium",d[4]==="medium"),d[2]&&d[12]==="right"?u?u.p(d,_):(u=qa(d),u.c(),u.m(e,null)):u&&(u.d(1),u=null),(!a||_&128)&&(e.disabled=d[7]),(!a||_&2)&&dt(e,"aria-label",d[1]),(!a||_&256)&&dt(e,"aria-haspopup",d[8]),(!a||_&2)&&dt(e,"title",d[1]),(!a||_&8192&&o!==(o=d[13]+"-round svelte-rrog8b"))&&dt(e,"class",o),(!a||_&8200)&&De(e,"pending",d[3]),(!a||_&8224)&&De(e,"padded",d[5]),(!a||_&8256)&&De(e,"highlight",d[6]),(!a||_&8704)&&De(e,"transparent",d[9]),_&16512&&Jt(e,"color",!d[7]&&d[14]?d[14]:"var(--block-label-text-color)"),_&1152&&Jt(e,"--bg-color",d[7]?"auto":d[10]),_&2048&&Jt(e,"margin-left",d[11]+"px")},i(d){a||(Mg(n.$$.fragment,d),a=!0)},o(d){Tg(n.$$.fragment,d),a=!1},d(d){d&&oa(e),c&&c.d(),vg(n),u&&u.d(),l=!1,h()}}}function zg(s,e,t){let i,{Icon:n}=e,{label:r=""}=e,{show_label:o=!1}=e,{pending:a=!1}=e,{size:l="small"}=e,{padded:h=!0}=e,{highlight:c=!1}=e,{disabled:u=!1}=e,{hasPopup:d=!1}=e,{color:_="var(--block-label-text-color)"}=e,{transparent:f=!1}=e,{background:g="var(--background-fill-primary)"}=e,{offset:p=0}=e,{label_position:m="left"}=e,{roundedness:b="quite"}=e;function y(w){wg.call(this,s,w)}return s.$$set=w=>{"Icon"in w&&t(0,n=w.Icon),"label"in w&&t(1,r=w.label),"show_label"in w&&t(2,o=w.show_label),"pending"in w&&t(3,a=w.pending),"size"in w&&t(4,l=w.size),"padded"in w&&t(5,h=w.padded),"highlight"in w&&t(6,c=w.highlight),"disabled"in w&&t(7,u=w.disabled),"hasPopup"in w&&t(8,d=w.hasPopup),"color"in w&&t(15,_=w.color),"transparent"in w&&t(9,f=w.transparent),"background"in w&&t(10,g=w.background),"offset"in w&&t(11,p=w.offset),"label_position"in w&&t(12,m=w.label_position),"roundedness"in w&&t(13,b=w.roundedness)},s.$$.update=()=>{s.$$.dirty&32832&&t(14,i=c?"var(--color-accent)":_.toString())},[n,r,o,a,l,h,c,u,d,f,g,p,m,b,i,_,y]}class Ze extends yg{constructor(e){super(),kg(this,e,zg,Pg,Cg,{Icon:0,label:1,show_label:2,pending:3,size:4,padded:5,highlight:6,disabled:7,hasPopup:8,color:15,transparent:9,background:10,offset:11,label_position:12,roundedness:13})}get Icon(){return this.$$.ctx[0]}set Icon(e){this.$$set({Icon:e}),Fe()}get label(){return this.$$.ctx[1]}set label(e){this.$$set({label:e}),Fe()}get show_label(){return this.$$.ctx[2]}set show_label(e){this.$$set({show_label:e}),Fe()}get pending(){return this.$$.ctx[3]}set pending(e){this.$$set({pending:e}),Fe()}get size(){return this.$$.ctx[4]}set size(e){this.$$set({size:e}),Fe()}get padded(){return this.$$.ctx[5]}set padded(e){this.$$set({padded:e}),Fe()}get highlight(){return this.$$.ctx[6]}set highlight(e){this.$$set({highlight:e}),Fe()}get disabled(){return this.$$.ctx[7]}set disabled(e){this.$$set({disabled:e}),Fe()}get hasPopup(){return this.$$.ctx[8]}set hasPopup(e){this.$$set({hasPopup:e}),Fe()}get color(){return this.$$.ctx[15]}set color(e){this.$$set({color:e}),Fe()}get transparent(){return this.$$.ctx[9]}set transparent(e){this.$$set({transparent:e}),Fe()}get background(){return this.$$.ctx[10]}set background(e){this.$$set({background:e}),Fe()}get offset(){return this.$$.ctx[11]}set offset(e){this.$$set({offset:e}),Fe()}get label_position(){return this.$$.ctx[12]}set label_position(e){this.$$set({label_position:e}),Fe()}get roundedness(){return this.$$.ctx[13]}set roundedness(e){this.$$set({roundedness:e}),Fe()}}function la(s,e){const t=i=>{s&&!s.contains(i.target)&&!i.defaultPrevented&&e(i)};return document.addEventListener("mousedown",t,!0),{destroy(){document.removeEventListener("mousedown",t,!0)}}}var $=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))($||{});const So=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},cn=(s,e)=>So(s).priority??e,Oe={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(So).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...s){return s.map(So).forEach(e=>{e.type.forEach(t=>{const i=this._addHandlers,n=this._queue;i[t]?i[t]?.(e):(n[t]=n[t]||[],n[t]?.push(e))})}),this},handle(s,e,t){const i=this._addHandlers,n=this._removeHandlers;if(i[s]||n[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=e,n[s]=t;const r=this._queue;return r[s]&&(r[s]?.forEach(o=>e(o)),delete r[s]),this},handleByMap(s,e){return this.handle(s,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(s,e,t=-1){return this.handle(s,i=>{e.findIndex(r=>r.name===i.name)>=0||(e.push({name:i.name,value:i.ref}),e.sort((r,o)=>cn(o.value,t)-cn(r.value,t)))},i=>{const n=e.findIndex(r=>r.name===i.name);n!==-1&&e.splice(n,1)})},handleByList(s,e,t=-1){return this.handle(s,i=>{e.includes(i.ref)||(e.push(i.ref),e.sort((n,r)=>cn(r,t)-cn(n,t)))},i=>{const n=e.indexOf(i.ref);n!==-1&&e.splice(n,1)})}},Ig={extension:{type:$.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Gn(()=>import("./browserAll-CViobIBh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45]),import.meta.url)}},Eg={extension:{type:$.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Gn(()=>import("./webworkerAll-CFHrejbB.js"),__vite__mapDeps([46,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45]),import.meta.url)}};class Ye{constructor(e,t,i){this._x=t||0,this._y=i||0,this._observer=e}clone(e){return new Ye(e??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=0 y=0 scope=${this._observer}]`}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}var Fc={exports:{}};(function(s){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function n(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function r(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var _=new n(c,u||l,d),f=t?t+h:h;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],_]:l._events[f].push(_):(l._events[f]=_,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)e.call(c,u)&&h.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=t?t+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,_=u.length,f=new Array(_);d<_;d++)f[d]=u[d].fn;return f},a.prototype.listenerCount=function(h){var c=t?t+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,_,f){var g=t?t+h:h;if(!this._events[g])return!1;var p=this._events[g],m=arguments.length,b,y;if(p.fn){switch(p.once&&this.removeListener(h,p.fn,void 0,!0),m){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,c),!0;case 3:return p.fn.call(p.context,c,u),!0;case 4:return p.fn.call(p.context,c,u,d),!0;case 5:return p.fn.call(p.context,c,u,d,_),!0;case 6:return p.fn.call(p.context,c,u,d,_,f),!0}for(y=1,b=new Array(m-1);y<m;y++)b[y-1]=arguments[y];p.fn.apply(p.context,b)}else{var w=p.length,A;for(y=0;y<w;y++)switch(p[y].once&&this.removeListener(h,p[y].fn,void 0,!0),m){case 1:p[y].fn.call(p[y].context);break;case 2:p[y].fn.call(p[y].context,c);break;case 3:p[y].fn.call(p[y].context,c,u);break;case 4:p[y].fn.call(p[y].context,c,u,d);break;default:if(!b)for(A=1,b=new Array(m-1);A<m;A++)b[A-1]=arguments[A];p[y].fn.apply(p[y].context,b)}}return!0},a.prototype.on=function(h,c,u){return r(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return r(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var _=t?t+h:h;if(!this._events[_])return this;if(!c)return o(this,_),this;var f=this._events[_];if(f.fn)f.fn===c&&(!d||f.once)&&(!u||f.context===u)&&o(this,_);else{for(var g=0,p=[],m=f.length;g<m;g++)(f[g].fn!==c||d&&!f[g].once||u&&f[g].context!==u)&&p.push(f[g]);p.length?this._events[_]=p.length===1?p[0]:p:o(this,_)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=t?t+h:h,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,s.exports=a})(Fc);var Rg=Fc.exports;const kt=ra(Rg),Fg=Math.PI*2,Bg=180/Math.PI,Lg=Math.PI/180;class V{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new V(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Br.x=0,Br.y=0,Br}}const Br=new V;class Z{constructor(e=1,t=0,i=0,n=1,r=0,o=0){this.array=null,this.a=e,this.b=t,this.c=i,this.d=n,this.tx=r,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,i,n,r,o){return this.a=e,this.b=t,this.c=i,this.d=n,this.tx=r,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const i=t||this.array;return e?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(e,t){t=t||new V;const i=e.x,n=e.y;return t.x=this.a*i+this.c*n+this.tx,t.y=this.b*i+this.d*n+this.ty,t}applyInverse(e,t){t=t||new V;const i=this.a,n=this.b,r=this.c,o=this.d,a=this.tx,l=this.ty,h=1/(i*o+r*-n),c=e.x,u=e.y;return t.x=o*h*c+-r*h*u+(l*r-a*o)*h,t.y=i*h*u+-n*h*c+(-l*i+a*n)*h,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),n=this.a,r=this.c,o=this.tx;return this.a=n*t-this.b*i,this.b=n*i+this.b*t,this.c=r*t-this.d*i,this.d=r*i+this.d*t,this.tx=o*t-this.ty*i,this.ty=o*i+this.ty*t,this}append(e){const t=this.a,i=this.b,n=this.c,r=this.d;return this.a=e.a*t+e.b*n,this.b=e.a*i+e.b*r,this.c=e.c*t+e.d*n,this.d=e.c*i+e.d*r,this.tx=e.tx*t+e.ty*n+this.tx,this.ty=e.tx*i+e.ty*r+this.ty,this}appendFrom(e,t){const i=e.a,n=e.b,r=e.c,o=e.d,a=e.tx,l=e.ty,h=t.a,c=t.b,u=t.c,d=t.d;return this.a=i*h+n*u,this.b=i*c+n*d,this.c=r*h+o*u,this.d=r*c+o*d,this.tx=a*h+l*u+t.tx,this.ty=a*c+l*d+t.ty,this}setTransform(e,t,i,n,r,o,a,l,h){return this.a=Math.cos(a+h)*r,this.b=Math.sin(a+h)*r,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=e-(i*this.a+n*this.c),this.ty=t-(i*this.b+n*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const i=this.a,n=this.c;this.a=i*e.a+this.b*e.c,this.b=i*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,i=this.b,n=this.c,r=this.d,o=e.pivot,a=-Math.atan2(-n,r),l=Math.atan2(i,t),h=Math.abs(a+l);return h<1e-5||Math.abs(Fg-h)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=a,e.skew.y=l),e.scale.x=Math.sqrt(t*t+i*i),e.scale.y=Math.sqrt(n*n+r*r),e.position.x=this.tx+(o.x*t+o.y*n),e.position.y=this.ty+(o.x*i+o.y*r),e}invert(){const e=this.a,t=this.b,i=this.c,n=this.d,r=this.tx,o=e*n-t*i;return this.a=n/o,this.b=-t/o,this.c=-i/o,this.d=e/o,this.tx=(i*this.ty-n*r)/o,this.ty=-(e*this.ty-t*r)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new Z;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Og.identity()}static get shared(){return $g.identity()}}const $g=new Z,Og=new Z,pi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],mi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],bi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],yi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Co=[],Bc=[],un=Math.sign;function Gg(){for(let s=0;s<16;s++){const e=[];Co.push(e);for(let t=0;t<16;t++){const i=un(pi[s]*pi[t]+bi[s]*mi[t]),n=un(mi[s]*pi[t]+yi[s]*mi[t]),r=un(pi[s]*bi[t]+bi[s]*yi[t]),o=un(mi[s]*bi[t]+yi[s]*yi[t]);for(let a=0;a<16;a++)if(pi[a]===i&&mi[a]===n&&bi[a]===r&&yi[a]===o){e.push(a);break}}}for(let s=0;s<16;s++){const e=new Z;e.set(pi[s],mi[s],bi[s],yi[s],0,0),Bc.push(e)}}Gg();const oe={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:s=>pi[s],uY:s=>mi[s],vX:s=>bi[s],vY:s=>yi[s],inv:s=>s&8?s&15:-s&7,add:(s,e)=>Co[s][e],sub:(s,e)=>Co[s][oe.inv(e)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,e)=>Math.abs(s)*2<=Math.abs(e)?e>=0?oe.S:oe.N:Math.abs(e)*2<=Math.abs(s)?s>0?oe.E:oe.W:e>0?s>0?oe.SE:oe.SW:s>0?oe.NE:oe.NW,matrixAppendRotationInv:(s,e,t=0,i=0)=>{const n=Bc[oe.inv(e)];n.tx=t,n.ty=i,s.append(n)}},dn=[new V,new V,new V,new V];class se{constructor(e=0,t=0,i=0,n=0){this.type="rectangle",this.x=Number(e),this.y=Number(t),this.width=Number(i),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new se(0,0,0,0)}clone(){return new se(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,i,n=.5){const{width:r,height:o}=this;if(r<=0||o<=0)return!1;const a=this.x,l=this.y,h=i*(1-n),c=i-h,u=a-h,d=a+r+h,_=l-h,f=l+o+h,g=a+c,p=a+r-c,m=l+c,b=l+o-c;return e>=u&&e<=d&&t>=_&&t<=f&&!(e>g&&e<p&&t>m&&t<b)}intersects(e,t){if(!t){const C=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=C)return!1;const T=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>T}const i=this.left,n=this.right,r=this.top,o=this.bottom;if(n<=i||o<=r)return!1;const a=dn[0].set(e.left,e.top),l=dn[1].set(e.left,e.bottom),h=dn[2].set(e.right,e.top),c=dn[3].set(e.right,e.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const u=Math.sign(t.a*t.d-t.b*t.c);if(u===0||(t.apply(a,a),t.apply(l,l),t.apply(h,h),t.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=i||Math.min(a.x,l.x,h.x,c.x)>=n||Math.max(a.y,l.y,h.y,c.y)<=r||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),_=u*(a.x-l.x),f=d*i+_*r,g=d*n+_*r,p=d*i+_*o,m=d*n+_*o;if(Math.max(f,g,p,m)<=d*a.x+_*a.y||Math.min(f,g,p,m)>=d*c.x+_*c.y)return!1;const b=u*(a.y-h.y),y=u*(h.x-a.x),w=b*i+y*r,A=b*n+y*r,k=b*i+y*o,x=b*n+y*o;return!(Math.max(w,A,k,x)<=b*a.x+y*a.y||Math.min(w,A,k,x)>=b*c.x+y*c.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),i=Math.min(this.x+this.width,e.x+e.width),n=Math.max(this.y,e.y),r=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(i-t,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(e=1,t=.001){const i=Math.ceil((this.x+this.width-t)*e)/e,n=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=i-this.x,this.height=n-this.y,this}enlarge(e){const t=Math.min(this.x,e.x),i=Math.max(this.x+this.width,e.x+e.width),n=Math.min(this.y,e.y),r=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=i-t,this.y=n,this.height=r-n,this}getBounds(e){return e||(e=new se),e.copyFrom(this),e}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Lr={default:-1};function pe(s="default"){return Lr[s]===void 0&&(Lr[s]=-1),++Lr[s]}const Va={},J="8.0.0",Ng="8.3.4";function K(s,e,t=3){if(Va[e])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${e}
3Deprecated since v${s}`):(i=i.split(`
4`).splice(t).join(`
5`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e}
6Deprecated since v${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e}
7Deprecated since v${s}`),console.warn(i))),Va[e]=!0}const Lc=()=>{};function Dn(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Xa(s){return!(s&s-1)&&!!s}function Dg(s){const e={};for(const t in s)s[t]!==void 0&&(e[t]=s[t]);return e}const Ya=Object.create(null);function Ug(s){const e=Ya[s];return e===void 0&&(Ya[s]=pe("resource")),e}const $c=class Oc extends kt{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...Oc.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){K(J,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Ug(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};$c.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Wg=$c;const Gc=class Nc extends kt{constructor(e={}){super(),this.options=e,this.uid=pe("textureSource"),this._resourceType="textureSource",this._resourceId=pe("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,e={...Nc.defaultOptions,...e},this.label=e.label??"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,e.height?this.pixelHeight=e.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=e.format,this.dimension=e.dimensions,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=e.antialias,this.alphaMode=e.alphaMode,this.style=new Wg(Dg(e)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(e){this.style!==e&&(this._style?.off("change",this._onStyleChange,this),this._style=e,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=pe("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){const{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,t,i){i||(i=this._resolution),e||(e=this.width),t||(t=this.height);const n=Math.round(e*i),r=Math.round(t*i);return this.width=n/i,this.height=r/i,this._resolution=i,this.pixelWidth===n&&this.pixelHeight===r?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=pe("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(e){this._style.wrapMode=e}get wrapMode(){return this._style.wrapMode}set scaleMode(e){this._style.scaleMode=e}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=Xa(this.pixelWidth)&&Xa(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};Gc.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let At=Gc;class ha extends At{constructor(e){const t=e.resource||new Float32Array(e.width*e.height*4);let i=e.format;i||(t instanceof Float32Array?i="rgba32float":t instanceof Int32Array||t instanceof Uint32Array?i="rgba32uint":t instanceof Int16Array||t instanceof Uint16Array?i="rgba16uint":(t instanceof Int8Array,i="bgra8unorm")),super({...e,resource:t,format:i}),this.uploadMethodId="buffer"}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}ha.extension=$.TextureSource;const ja=new Z;class Hg{constructor(e,t){this.mapCoord=new Z,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof t>"u"?this.clampMargin=e.width<10?0:.5:this.clampMargin=t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){this.texture!==e&&(this._texture?.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(e,t){t===void 0&&(t=e);const i=this.mapCoord;for(let n=0;n<e.length;n+=2){const r=e[n],o=e[n+1];t[n]=r*i.a+o*i.c+i.tx,t[n+1]=r*i.b+o*i.d+i.ty}return t}update(){const e=this._texture;this._updateID++;const t=e.uvs;this.mapCoord.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0);const i=e.orig,n=e.trim;n&&(ja.set(i.width/n.width,0,0,i.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(ja));const r=e.source,o=this.uClampFrame,a=this.clampMargin/r._resolution,l=this.clampOffset/r._resolution;return o[0]=(e.frame.x+a+l)/r.width,o[1]=(e.frame.y+a+l)/r.height,o[2]=(e.frame.x+e.frame.width-a+l)/r.width,o[3]=(e.frame.y+e.frame.height-a+l)/r.height,this.uClampOffset[0]=this.clampOffset/r.pixelWidth,this.uClampOffset[1]=this.clampOffset/r.pixelHeight,this.isSimple=e.frame.width===r.width&&e.frame.height===r.height&&e.rotate===0,!0}}class Y extends kt{constructor({source:e,label:t,frame:i,orig:n,trim:r,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:h}={}){if(super(),this.uid=pe("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new se,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=e?.source??new At,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:c,height:u}=this._source;this.frame.width=c,this.frame.height=u}this.orig=n||this.frame,this.trim=r,this.rotate=l??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=h||!1,this.updateUvs()}set source(e){this._source&&this._source.off("resize",this.update,this),this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Hg(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:e,frame:t}=this,{width:i,height:n}=this._source,r=t.x/i,o=t.y/n,a=t.width/i,l=t.height/n;let h=this.rotate;if(h){const c=a/2,u=l/2,d=r+c,_=o+u;h=oe.add(h,oe.NW),e.x0=d+c*oe.uX(h),e.y0=_+u*oe.uY(h),h=oe.add(h,2),e.x1=d+c*oe.uX(h),e.y1=_+u*oe.uY(h),h=oe.add(h,2),e.x2=d+c*oe.uX(h),e.y2=_+u*oe.uY(h),h=oe.add(h,2),e.x3=d+c*oe.uX(h),e.y3=_+u*oe.uY(h)}else e.x0=r,e.y0=o,e.x1=r+a,e.y1=o,e.x2=r+a,e.y2=o+l,e.x3=r,e.y3=o+l}destroy(e=!1){this._source&&e&&(this._source.destroy(),this._source=null),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return K(J,"Texture.baseTexture is now Texture.source"),this._source}}Y.EMPTY=new Y({label:"EMPTY",source:new At({label:"EMPTY"})});Y.EMPTY.destroy=Lc;Y.WHITE=new Y({source:new ha({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});Y.WHITE.destroy=Lc;function qg(s,e,t){const{width:i,height:n}=t.orig,r=t.trim;if(r){const o=r.width,a=r.height;s.minX=r.x-e._x*i,s.maxX=s.minX+o,s.minY=r.y-e._y*n,s.maxY=s.minY+a}else s.minX=-e._x*i,s.maxX=s.minX+i,s.minY=-e._y*n,s.maxY=s.minY+n}const Ka=new Z;class wt{constructor(e=1/0,t=1/0,i=-1/0,n=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Ka,this.minX=e,this.minY=t,this.maxX=i,this.maxY=n}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new se);const e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Ka,this}set(e,t,i,n){this.minX=e,this.minY=t,this.maxX=i,this.maxY=n}addFrame(e,t,i,n,r){r||(r=this.matrix);const o=r.a,a=r.b,l=r.c,h=r.d,c=r.tx,u=r.ty;let d=this.minX,_=this.minY,f=this.maxX,g=this.maxY,p=o*e+l*t+c,m=a*e+h*t+u;p<d&&(d=p),m<_&&(_=m),p>f&&(f=p),m>g&&(g=m),p=o*i+l*t+c,m=a*i+h*t+u,p<d&&(d=p),m<_&&(_=m),p>f&&(f=p),m>g&&(g=m),p=o*e+l*n+c,m=a*e+h*n+u,p<d&&(d=p),m<_&&(_=m),p>f&&(f=p),m>g&&(g=m),p=o*i+l*n+c,m=a*i+h*n+u,p<d&&(d=p),m<_&&(_=m),p>f&&(f=p),m>g&&(g=m),this.minX=d,this.minY=_,this.maxX=f,this.maxY=g}addRect(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){const t=this.minX,i=this.minY,n=this.maxX,r=this.maxY,{a:o,b:a,c:l,d:h,tx:c,ty:u}=e;let d=o*t+l*i+c,_=a*t+h*i+u;this.minX=d,this.minY=_,this.maxX=d,this.maxY=_,d=o*n+l*i+c,_=a*n+h*i+u,this.minX=d<this.minX?d:this.minX,this.minY=_<this.minY?_:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=_>this.maxY?_:this.maxY,d=o*t+l*r+c,_=a*t+h*r+u,this.minX=d<this.minX?d:this.minX,this.minY=_<this.minY?_:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=_>this.maxY?_:this.maxY,d=o*n+l*r+c,_=a*n+h*r+u,this.minX=d<this.minX?d:this.minX,this.minY=_<this.minY?_:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=_>this.maxY?_:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,i,n){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<i&&(this.minY=i),this.maxY>n&&(this.maxY=n),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new wt(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){const t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){const t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(e,t,i,n){let r=this.minX,o=this.minY,a=this.maxX,l=this.maxY;n||(n=this.matrix);const h=n.a,c=n.b,u=n.c,d=n.d,_=n.tx,f=n.ty;for(let g=t;g<i;g+=2){const p=e[g],m=e[g+1],b=h*p+u*m+_,y=c*p+d*m+f;r=b<r?b:r,o=y<o?y:o,a=b>a?b:a,l=y>l?y:l}this.minX=r,this.minY=o,this.maxX=a,this.maxY=l}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}var Vg={grad:.9,turn:360,rad:360/(2*Math.PI)},Ot=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},Me=function(s,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*s)/t+0},lt=function(s,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),s>t?t:s>e?s:e},Dc=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Za=function(s){return{r:lt(s.r,0,255),g:lt(s.g,0,255),b:lt(s.b,0,255),a:lt(s.a)}},$r=function(s){return{r:Me(s.r),g:Me(s.g),b:Me(s.b),a:Me(s.a,3)}},Xg=/^#([0-9a-f]{3,8})$/i,_n=function(s){var e=s.toString(16);return e.length<2?"0"+e:e},Uc=function(s){var e=s.r,t=s.g,i=s.b,n=s.a,r=Math.max(e,t,i),o=r-Math.min(e,t,i),a=o?r===e?(t-i)/o:r===t?2+(i-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:r?o/r*100:0,v:r/255*100,a:n}},Wc=function(s){var e=s.h,t=s.s,i=s.v,n=s.a;e=e/360*6,t/=100,i/=100;var r=Math.floor(e),o=i*(1-t),a=i*(1-(e-r)*t),l=i*(1-(1-e+r)*t),h=r%6;return{r:255*[i,a,o,o,l,i][h],g:255*[l,i,i,a,o,o][h],b:255*[o,o,l,i,i,a][h],a:n}},Qa=function(s){return{h:Dc(s.h),s:lt(s.s,0,100),l:lt(s.l,0,100),a:lt(s.a)}},Ja=function(s){return{h:Me(s.h),s:Me(s.s),l:Me(s.l),a:Me(s.a,3)}},el=function(s){return Wc((t=(e=s).s,{h:e.h,s:(t*=((i=e.l)<50?i:100-i)/100)>0?2*t/(i+t)*100:0,v:i+t,a:e.a}));var e,t,i},Gs=function(s){return{h:(e=Uc(s)).h,s:(n=(200-(t=e.s))*(i=e.v)/100)>0&&n<200?t*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:e.a};var e,t,i,n},Yg=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,jg=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Kg=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zg=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Mo={string:[[function(s){var e=Xg.exec(s);return e?(s=e[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?Me(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?Me(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var e=Kg.exec(s)||Zg.exec(s);return e?e[2]!==e[4]||e[4]!==e[6]?null:Za({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(s){var e=Yg.exec(s)||jg.exec(s);if(!e)return null;var t,i,n=Qa({h:(t=e[1],i=e[2],i===void 0&&(i="deg"),Number(t)*(Vg[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return el(n)},"hsl"]],object:[[function(s){var e=s.r,t=s.g,i=s.b,n=s.a,r=n===void 0?1:n;return Ot(e)&&Ot(t)&&Ot(i)?Za({r:Number(e),g:Number(t),b:Number(i),a:Number(r)}):null},"rgb"],[function(s){var e=s.h,t=s.s,i=s.l,n=s.a,r=n===void 0?1:n;if(!Ot(e)||!Ot(t)||!Ot(i))return null;var o=Qa({h:Number(e),s:Number(t),l:Number(i),a:Number(r)});return el(o)},"hsl"],[function(s){var e=s.h,t=s.s,i=s.v,n=s.a,r=n===void 0?1:n;if(!Ot(e)||!Ot(t)||!Ot(i))return null;var o=function(a){return{h:Dc(a.h),s:lt(a.s,0,100),v:lt(a.v,0,100),a:lt(a.a)}}({h:Number(e),s:Number(t),v:Number(i),a:Number(r)});return Wc(o)},"hsv"]]},tl=function(s,e){for(var t=0;t<e.length;t++){var i=e[t][0](s);if(i)return[i,e[t][1]]}return[null,void 0]},Qg=function(s){return typeof s=="string"?tl(s.trim(),Mo.string):typeof s=="object"&&s!==null?tl(s,Mo.object):[null,void 0]},Or=function(s,e){var t=Gs(s);return{h:t.h,s:lt(t.s+100*e,0,100),l:t.l,a:t.a}},Gr=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},il=function(s,e){var t=Gs(s);return{h:t.h,s:t.s,l:lt(t.l+100*e,0,100),a:t.a}},To=function(){function s(e){this.parsed=Qg(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return Me(Gr(this.rgba),2)},s.prototype.isDark=function(){return Gr(this.rgba)<.5},s.prototype.isLight=function(){return Gr(this.rgba)>=.5},s.prototype.toHex=function(){return e=$r(this.rgba),t=e.r,i=e.g,n=e.b,o=(r=e.a)<1?_n(Me(255*r)):"","#"+_n(t)+_n(i)+_n(n)+o;var e,t,i,n,r,o},s.prototype.toRgb=function(){return $r(this.rgba)},s.prototype.toRgbString=function(){return e=$r(this.rgba),t=e.r,i=e.g,n=e.b,(r=e.a)<1?"rgba("+t+", "+i+", "+n+", "+r+")":"rgb("+t+", "+i+", "+n+")";var e,t,i,n,r},s.prototype.toHsl=function(){return Ja(Gs(this.rgba))},s.prototype.toHslString=function(){return e=Ja(Gs(this.rgba)),t=e.h,i=e.s,n=e.l,(r=e.a)<1?"hsla("+t+", "+i+"%, "+n+"%, "+r+")":"hsl("+t+", "+i+"%, "+n+"%)";var e,t,i,n,r},s.prototype.toHsv=function(){return e=Uc(this.rgba),{h:Me(e.h),s:Me(e.s),v:Me(e.v),a:Me(e.a,3)};var e},s.prototype.invert=function(){return It({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},s.prototype.saturate=function(e){return e===void 0&&(e=.1),It(Or(this.rgba,e))},s.prototype.desaturate=function(e){return e===void 0&&(e=.1),It(Or(this.rgba,-e))},s.prototype.grayscale=function(){return It(Or(this.rgba,-1))},s.prototype.lighten=function(e){return e===void 0&&(e=.1),It(il(this.rgba,e))},s.prototype.darken=function(e){return e===void 0&&(e=.1),It(il(this.rgba,-e))},s.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},s.prototype.alpha=function(e){return typeof e=="number"?It({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):Me(this.rgba.a,3);var t},s.prototype.hue=function(e){var t=Gs(this.rgba);return typeof e=="number"?It({h:e,s:t.s,l:t.l,a:t.a}):Me(t.h)},s.prototype.isEqual=function(e){return this.toHex()===It(e).toHex()},s}(),It=function(s){return s instanceof To?s:new To(s)},sl=[],Jg=function(s){s.forEach(function(e){sl.indexOf(e)<0&&(e(To,Mo),sl.push(e))})};function ep(s,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var n in t)i[t[n]]=n;var r={};s.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=i[this.toHex()];if(h)return h;if(o?.closest){var c=this.toRgb(),u=1/0,d="black";if(!r.length)for(var _ in t)r[_]=new s(t[_]).toRgb();for(var f in t){var g=(a=c,l=r[f],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));g<u&&(u=g,d=f)}return d}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new s(l).toRgb():null},"name"])}Jg([ep]);const as=class Rs{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(e){if(e instanceof Rs)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,e))&&(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}_isSourceEqual(e,t){const i=typeof e;if(i!==typeof t)return!1;if(i==="number"||i==="string"||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length!==t.length?!1:e.every((r,o)=>r===t[o]);if(e!==null&&t!==null){const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(a=>e[a]===t[a])}return e===t}toRgba(){const[e,t,i,n]=this._components;return{r:e,g:t,b:i,a:n}}toRgb(){const[e,t,i]=this._components;return{r:e,g:t,b:i}}toRgbaString(){const[e,t,i]=this.toUint8RgbArray();return`rgba(${e},${t},${i},${this.alpha})`}toUint8RgbArray(e){const[t,i,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb),e[0]=Math.round(t*255),e[1]=Math.round(i*255),e[2]=Math.round(n*255),e}toArray(e){this._arrayRgba||(this._arrayRgba=[]),e||(e=this._arrayRgba);const[t,i,n,r]=this._components;return e[0]=t,e[1]=i,e[2]=n,e[3]=r,e}toRgbArray(e){this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb);const[t,i,n]=this._components;return e[0]=t,e[1]=i,e[2]=n,e}toNumber(){return this._int}toBgrNumber(){const[e,t,i]=this.toUint8RgbArray();return(i<<16)+(t<<8)+e}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,i,n,r]=Rs._temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=i,this._components[2]*=n,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,r=this._int&255;return t&&(i=i*e+.5|0,n=n*e+.5|0,r=r*e+.5|0),(e*255<<24)+(i<<16)+(n<<8)+r}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(e){return this._components[3]=this._clamp(e),this}_normalize(e){let t,i,n,r;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;t=(o>>16&255)/255,i=(o>>8&255)/255,n=(o&255)/255,r=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,i,n,r=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,i,n,r=255]=e,t/=255,i/=255,n/=255,r/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=Rs.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=It(e);o.isValid()&&({r:t,g:i,b:n,a:r}=o.rgba,t/=255,i/=255,n/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=i,this._components[2]=n,this._components[3]=r,this._refreshInt();else throw new Error(`Unable to convert color ${e}`)}_refreshInt(){this._clamp(this._components);const[e,t,i]=this._components;this._int=(e*255<<16)+(t*255<<8)+(i*255|0)}_clamp(e,t=0,i=1){return typeof e=="number"?Math.min(Math.max(e,t),i):(e.forEach((n,r)=>{e[r]=Math.min(Math.max(n,t),i)}),e)}static isColorLike(e){return typeof e=="number"||typeof e=="string"||e instanceof Number||e instanceof Rs||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||e.r!==void 0&&e.g!==void 0&&e.b!==void 0||e.r!==void 0&&e.g!==void 0&&e.b!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0&&e.a!==void 0}};as.shared=new as;as._temp=new as;as.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let fe=as;const tp={cullArea:null,cullable:!1,cullableChildren:!0};class ca{constructor(e,t){this._pool=[],this._count=0,this._index=0,this._classType=e,t&&this.prepopulate(t)}prepopulate(e){for(let t=0;t<e;t++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){let t;return this._index>0?t=this._pool[--this._index]:t=new this._classType,t.init?.(e),t}return(e){e.reset?.(),this._pool[this._index++]=e}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class ip{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new ca(e)),this._poolsByClass.get(e)}stats(){const e={};return this._poolsByClass.forEach(t=>{const i=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[i]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}}const Wt=new ip,sp={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(s){typeof s=="boolean"&&s===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(s===!0?{}:s))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(s){K("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(s)}};function np(s,e,t){const i=s.length;let n;if(e>=i||t===0)return;t=e+t>i?i-e:t;const r=i-t;for(n=e;n<r;++n)s[n]=s[n+t];s.length=r}const rp={allowChildren:!0,removeChildren(s=0,e){const t=e??this.children.length,i=t-s,n=[];if(i>0&&i<=t){for(let o=t-1;o>=s;o--){const a=this.children[o];a&&(n.push(a),a.parent=null)}np(this.children,s,t);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let o=0;o<n.length;++o)this.emit("childRemoved",n[o],this,o),n[o].emit("removed",this);return n}else if(i===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const e=this.getChildAt(s);return this.removeChild(e)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,e)},getChildIndex(s){const e=this.children.indexOf(s);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(s,e){this.allowChildren||K(J,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:t}=this;if(e<0||e>t.length)throw new Error(`${s}addChildAt: The index ${e} supplied is out of bounds ${t.length}`);if(s.parent){const n=s.parent.children.indexOf(s);if(s.parent===this&&n===e)return s;n!==-1&&s.parent.children.splice(n,1)}e===t.length?t.push(s):t.splice(e,0,s),s.parent=this,s.didChange=!0,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,e),s.emit("added",this),s},swapChildren(s,e){if(s===e)return;const t=this.getChildIndex(s),i=this.getChildIndex(e);this.children[t]=e,this.children[i]=s;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(e=>this.reparentChildAt(e,this.children.length)),s[0])},reparentChildAt(s,e){if(s.parent===this)return this.setChildIndex(s,e),s;const t=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,e);const i=this.worldTransform.clone();return i.invert(),t.prepend(i),s.setFromMatrix(t),s}},op={collectRenderables(s,e,t){this.parentRenderLayer&&this.parentRenderLayer!==t||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(s,e,t):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,s):this.collectRenderablesWithEffects(s,e,t))},collectRenderablesSimple(s,e,t){const i=this.children,n=i.length;for(let r=0;r<n;r++)i[r].collectRenderables(s,e,t)},collectRenderablesWithEffects(s,e,t){const{renderPipes:i}=e;for(let n=0;n<this.effects.length;n++){const r=this.effects[n];i[r.pipe].push(r,this,s)}this.collectRenderablesSimple(s,e,t);for(let n=this.effects.length-1;n>=0;n--){const r=this.effects[n];i[r.pipe].pop(r,this,s)}}};class nl{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}class ap{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let t=0;t<this._tests.length;t++){const i=this._tests[t];if(i.test(e))return Wt.get(i.maskClass,e)}return e}returnMaskEffect(e){Wt.return(e)}}const Po=new ap;Oe.handleByList($.MaskEffect,Po._effectClasses);const lp={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0)},addEffect(s){this.effects.indexOf(s)===-1&&(this.effects.push(s),this.effects.sort((t,i)=>t.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(s){const e=this.effects.indexOf(s);e!==-1&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(s){const e=this._maskEffect;e?.mask!==s&&(e&&(this.removeEffect(e),Po.returnMaskEffect(e),this._maskEffect=null),s!=null&&(this._maskEffect=Po.getMaskEffect(s),this.addEffect(this._maskEffect)))},setMask(s){this._maskOptions={...this._maskOptions,...s},s.mask&&(this.mask=s.mask),this._markStructureAsChanged()},get mask(){return this._maskEffect?.mask},set filters(s){!Array.isArray(s)&&s&&(s=[s]);const e=this._filterEffect||(this._filterEffect=new nl);s=s;const t=s?.length>0,i=e.filters?.length>0,n=t!==i;s=Array.isArray(s)?s.slice(0):s,e.filters=Object.freeze(s),n&&(t?this.addEffect(e):(this.removeEffect(e),e.filters=s??null))},get filters(){return this._filterEffect?.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new nl),this._filterEffect.filterArea=s},get filterArea(){return this._filterEffect?.filterArea}},hp={label:null,get name(){return K(J,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){K(J,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,e=!1){return this.getChildByLabel(s,e)},getChildByLabel(s,e=!1){const t=this.children;for(let i=0;i<t.length;i++){const n=t[i];if(n.label===s||s instanceof RegExp&&s.test(n.label))return n}if(e)for(let i=0;i<t.length;i++){const r=t[i].getChildByLabel(s,!0);if(r)return r}return null},getChildrenByLabel(s,e=!1,t=[]){const i=this.children;for(let n=0;n<i.length;n++){const r=i[n];(r.label===s||s instanceof RegExp&&s.test(r.label))&&t.push(r)}if(e)for(let n=0;n<i.length;n++)i[n].getChildrenByLabel(s,!0,t);return t}},$e=new ca(Z),Ht=new ca(wt),cp=new Z,up={getFastGlobalBounds(s,e){e||(e=new wt),e.clear(),this._getGlobalBoundsRecursive(!!s,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const t=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(t.worldTransform),e},_getGlobalBoundsRecursive(s,e,t){let i=e;if(s&&this.parentRenderLayer!==t||this.localDisplayStatus!==7||!this.measurable)return;const n=!!this.effects.length;if((this.renderGroup||n)&&(i=Ht.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const r=this.children;for(let o=0;o<r.length;o++)r[o]._getGlobalBoundsRecursive(s,i,t)}if(n){let r=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(r||(r=!0,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));r&&(i.applyMatrix(o.worldTransform.copyTo(cp).invert()),e.addBounds(i,this.relativeGroupTransform)),e.addBounds(i),Ht.return(i)}else this.renderGroup&&(e.addBounds(i,this.relativeGroupTransform),Ht.return(i))}};function Hc(s,e,t){t.clear();let i,n;return s.parent?e?i=s.parent.worldTransform:(n=$e.get().identity(),i=ua(s,n)):i=Z.IDENTITY,qc(s,t,i,e),n&&$e.return(n),t.isValid||t.set(0,0,0,0),t}function qc(s,e,t,i){if(!s.visible||!s.measurable)return;let n;i?n=s.worldTransform:(s.updateLocalTransform(),n=$e.get(),n.appendFrom(s.localTransform,t));const r=e,o=!!s.effects.length;if(o&&(e=Ht.get().clear()),s.boundsArea)e.addRect(s.boundsArea,n);else{s.bounds&&(e.matrix=n,e.addBounds(s.bounds));for(let a=0;a<s.children.length;a++)qc(s.children[a],e,n,i)}if(o){for(let a=0;a<s.effects.length;a++)s.effects[a].addBounds?.(e);r.addBounds(e,Z.IDENTITY),Ht.return(e)}i||$e.return(n)}function ua(s,e){const t=s.parent;return t&&(ua(t,e),t.updateLocalTransform(),e.append(t.localTransform)),e}function Vc(s,e){if(s===16777215||!e)return e;if(e===16777215||!s)return s;const t=s>>16&255,i=s>>8&255,n=s&255,r=e>>16&255,o=e>>8&255,a=e&255,l=t*r/255|0,h=i*o/255|0,c=n*a/255|0;return(l<<16)+(h<<8)+c}const rl=16777215;function ol(s,e){return s===rl?e:e===rl?s:Vc(s,e)}function zn(s){return((s&255)<<16)+(s&65280)+(s>>16&255)}const dp={getGlobalAlpha(s){if(s)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,t=this.parent;for(;t;)e*=t.alpha,t=t.parent;return e},getGlobalTransform(s,e){if(e)return s.copyFrom(this.worldTransform);this.updateLocalTransform();const t=ua(this,$e.get().identity());return s.appendFrom(this.localTransform,t),$e.return(t),s},getGlobalTint(s){if(s)return this.renderGroup?zn(this.renderGroup.worldColor):this.parentRenderGroup?zn(ol(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,t=this.parent;for(;t;)e=ol(e,t.localColor),t=t.parent;return zn(e)}};let Nr=0;const al=500;function me(...s){Nr!==al&&(Nr++,Nr===al?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}function Xc(s,e,t){return e.clear(),t||(t=Z.IDENTITY),Yc(s,e,t,s,!0),e.isValid||e.set(0,0,0,0),e}function Yc(s,e,t,i,n){let r;if(n)r=$e.get(),r=t.copyTo(r);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const l=s.localTransform;r=$e.get(),r.appendFrom(l,t)}const o=e,a=!!s.effects.length;if(a&&(e=Ht.get().clear()),s.boundsArea)e.addRect(s.boundsArea,r);else{s.renderPipeId&&(e.matrix=r,e.addBounds(s.bounds));const l=s.children;for(let h=0;h<l.length;h++)Yc(l[h],e,r,i,!1)}if(a){for(let l=0;l<s.effects.length;l++)s.effects[l].addLocalBounds?.(e,i);o.addBounds(e,Z.IDENTITY),Ht.return(e)}$e.return(r)}function jc(s,e){const t=s.children;for(let i=0;i<t.length;i++){const n=t[i],r=n.uid,o=(n._didViewChangeTick&65535)<<16|n._didContainerChangeTick&65535,a=e.index;(e.data[a]!==r||e.data[a+1]!==o)&&(e.data[e.index]=r,e.data[e.index+1]=o,e.didChange=!0),e.index=a+2,n.children.length&&jc(n,e)}return e.didChange}const _p=new Z,fp={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(s,e){const t=Math.sign(this.scale.x)||1;e!==0?this.scale.x=s/e*t:this.scale.x=t},_setHeight(s,e){const t=Math.sign(this.scale.y)||1;e!==0?this.scale.y=s/e*t:this.scale.y=t},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new wt});const s=this._localBoundsCacheData;return s.index=1,s.didChange=!1,s.data[0]!==this._didViewChangeTick&&(s.didChange=!0,s.data[0]=this._didViewChangeTick),jc(this,s),s.didChange&&Xc(this,s.localBounds,_p),s.localBounds},getBounds(s,e){return Hc(this,s,e||new wt)}},gp={_onRender:null,set onRender(s){const e=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&e?.removeOnRender(this),this._onRender=null;return}this._onRender||e?.addOnRender(this),this._onRender=s},get onRender(){return this._onRender}},pp={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(s){this._zIndex!==s&&(this._zIndex=s,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(mp))}};function mp(s,e){return s._zIndex-e._zIndex}const bp={getGlobalPosition(s=new V,e=!1){return this.parent?this.parent.toGlobal(this._position,s,e):(s.x=this._position.x,s.y=this._position.y),s},toGlobal(s,e,t=!1){const i=this.getGlobalTransform($e.get(),t);return e=i.apply(s,e),$e.return(i),e},toLocal(s,e,t,i){e&&(s=e.toGlobal(s,t,i));const n=this.getGlobalTransform($e.get(),i);return t=n.applyInverse(s,t),$e.return(n),t}};class Kc{constructor(){this.uid=pe("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}add(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let yp=0;class wp{constructor(e){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1}createTexture(e,t,i){const n=new At({...this.textureOptions,width:e,height:t,resolution:1,antialias:i,autoGarbageCollect:!1});return new Y({source:n,label:`texturePool_${yp++}`})}getOptimalTexture(e,t,i=1,n){let r=Math.ceil(e*i-1e-6),o=Math.ceil(t*i-1e-6);r=Dn(r),o=Dn(o);const a=(r<<17)+(o<<1)+(n?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let l=this._texturePool[a].pop();return l||(l=this.createTexture(r,o,n)),l.source._resolution=i,l.source.width=r/i,l.source.height=o/i,l.source.pixelWidth=r,l.source.pixelHeight=o,l.frame.x=0,l.frame.y=0,l.frame.width=e,l.frame.height=t,l.updateUvs(),this._poolKeyHash[l.uid]=a,l}getSameSizeTexture(e,t=!1){const i=e.source;return this.getOptimalTexture(e.width,e.height,i._resolution,t)}returnTexture(e){const t=this._poolKeyHash[e.uid];this._texturePool[t].push(e)}clear(e){if(e=e!==!1,e)for(const t in this._texturePool){const i=this._texturePool[t];if(i)for(let n=0;n<i.length;n++)i[n].destroy(!0)}this._texturePool={}}}const qs=new wp;class xp{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new Z,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Kc,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;const t=e.children;for(let i=0;i<t.length;i++){const n=t[i];n._updateFlags=15,this.addChild(n)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(qs.returnTexture(this.texture),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0}reset(){this.renderGroupChildren.length=0;for(const e in this.childrenToUpdate){const t=this.childrenToUpdate[e];t.list.fill(null),t.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){const t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);const t=e.children;for(let i=0;i<t.length;i++)this.addChild(t[i])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}const t=e.children;for(let i=0;i<t.length;i++)this.removeChild(t[i])}removeChildren(e){for(let t=0;t<e.length;t++)this.removeChild(e[t])}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||(t=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]}),t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.push(e)}removeOnRender(e){this._onRenderContainers.splice(this._onRenderContainers.indexOf(e),1)}runOnRender(e){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender(e)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(e=[]){const t=this.root.children;for(let i=0;i<t.length;i++)this._getChildren(t[i],e);return e}_getChildren(e,t=[]){if(t.push(e),e.renderGroup)return t;const i=e.children;for(let n=0;n<i.length;n++)this._getChildren(i[n],t);return t}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new Z),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new Z),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new Z),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function vp(s,e,t={}){for(const i in e)!t[i]&&e[i]!==void 0&&(s[i]=e[i])}const Dr=new Ye(null),Ur=new Ye(null),Wr=new Ye(null,1,1),ll=1,kp=2,Hr=4;class U extends kt{constructor(e={}){super(),this.uid=pe("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.updateTick=-1,this.localTransform=new Z,this.relativeGroupTransform=new Z,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Ye(this,0,0),this._scale=Wr,this._pivot=Ur,this._skew=Dr,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],vp(this,e,{children:!0,parent:!0,effects:!0}),e.children?.forEach(t=>this.addChild(t)),e.parent?.addChild(this)}static mixin(e){Object.defineProperties(U.prototype,Object.getOwnPropertyDescriptors(e))}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||K(J,"addChild: Only Containers will be allowed to add children in v8.0.0"),e.length>1){for(let n=0;n<e.length;n++)this.addChild(e[n]);return e[0]}const t=e[0],i=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),i&&(i.structureDidChange=!0),t):(t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=15,i&&i.addChild(t),this.emit("childAdded",t,this,this.children.length-1),t.emit("added",this),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let n=0;n<e.length;n++)this.removeChild(e[n]);return e[0]}const t=e[0],i=this.children.indexOf(t);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parentRenderLayer&&t.parentRenderLayer.detach(t),t.parent=null,this.emit("childRemoved",t,this,i),t.emit("removed",this)),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const e=this.parentRenderGroup;e?.removeChild(this),this.renderGroup=Wt.get(xp,this),this.groupTransform=Z.IDENTITY,e?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const e=this.parentRenderGroup;e?.removeChild(this),Wt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new Z),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*Bg}set angle(e){this.rotation=e*Lg}get pivot(){return this._pivot===Ur&&(this._pivot=new Ye(this,0,0)),this._pivot}set pivot(e){this._pivot===Ur&&(this._pivot=new Ye(this,0,0)),typeof e=="number"?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){return this._skew===Dr&&(this._skew=new Ye(this,0,0)),this._skew}set skew(e){this._skew===Dr&&(this._skew=new Ye(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===Wr&&(this._scale=new Ye(this,1,1)),this._scale}set scale(e){this._scale===Wr&&(this._scale=new Ye(this,0,0)),typeof e=="number"?this._scale.set(e):this._scale.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){const t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){const t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){e||(e={});const t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){const i=this.getLocalBounds();typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,i.width),t!==void 0&&this._setHeight(t,i.height)}_updateSkew(){const e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x=="number"?e.x:this.position.x,typeof e.y=="number"?e.y:this.position.y),this.scale.set(typeof e.scaleX=="number"?e.scaleX||1:this.scale.x,typeof e.scaleY=="number"?e.scaleY||1:this.scale.y),this.rotation=typeof e.rotation=="number"?e.rotation:this.rotation,this.skew.set(typeof e.skewX=="number"?e.skewX:this.skew.x,typeof e.skewY=="number"?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX=="number"?e.pivotX:this.pivot.x,typeof e.pivotY=="number"?e.pivotY:this.pivot.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){const e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;const t=this.localTransform,i=this._scale,n=this._pivot,r=this._position,o=i._x,a=i._y,l=n._x,h=n._y;t.a=this._cx*o,t.b=this._sx*o,t.c=this._cy*a,t.d=this._sy*a,t.tx=r._x-(l*t.a+h*t.c),t.ty=r._y-(l*t.b+h*t.d)}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=ll,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const i=fe.shared.setValue(e??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=ll,this._onUpdate())}get tint(){return zn(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=kp,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){const t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Hr,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(e){const t=e?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Hr,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){const t=e?1:0;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=Hr,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length&&(t=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof e=="boolean"?e:e?.children)&&t)for(let n=0;n<t.length;++n)t[n].destroy(e);this.renderGroup?.destroy(),this.renderGroup=null}}U.mixin(rp);U.mixin(up);U.mixin(bp);U.mixin(gp);U.mixin(fp);U.mixin(lp);U.mixin(hp);U.mixin(pp);U.mixin(tp);U.mixin(sp);U.mixin(dp);U.mixin(op);class Zc extends U{constructor(){super(...arguments),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._bounds=new wt(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){const t=this.bounds,{x:i,y:n}=e;return i>=t.minX&&i<=t.maxX&&n>=t.minY&&n<=t.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}destroy(e){super.destroy(e),this._bounds=null}collectRenderablesSimple(e,t,i){const{renderPipes:n,renderableGC:r}=t;n.blendMode.setBlendMode(this,this.groupBlendMode,e),n[this.renderPipeId].addRenderable(this,e),r.addRenderable(this),this.didViewUpdate=!1;const a=this.children,l=a.length;for(let h=0;h<l;h++)a[h].collectRenderables(e,t,i)}}class ue extends Zc{constructor(e=Y.EMPTY){e instanceof Y&&(e={texture:e});const{texture:t=Y.EMPTY,anchor:i,roundPixels:n,width:r,height:o,...a}=e;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Ye({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:t.defaultAnchor&&(this.anchor=t.defaultAnchor),this.texture=t,this.allowChildren=!1,this.roundPixels=n??!1,r!==void 0&&(this.width=r),o!==void 0&&(this.height=o)}static from(e,t=!1){return e instanceof Y?new ue(e):new ue(Y.from(e,t))}set texture(e){e||(e=Y.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return qg(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return K("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const e=this._anchor,t=this._texture,i=this._bounds,{width:n,height:r}=t.orig;i.minX=-e._x*n,i.maxX=i.minX+n,i.minY=-e._y*r,i.maxY=i.minY+r}destroy(e=!1){if(super.destroy(e),typeof e=="boolean"?e:e?.texture){const i=typeof e=="boolean"?e:e?.textureSource;this._texture.destroy(i)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}}const Ap=new wt;function Qc(s,e,t){const i=Ap;s.measurable=!0,Hc(s,t,i),e.addBoundsMask(i),s.measurable=!1}function Jc(s,e,t){const i=Ht.get();s.measurable=!0;const n=$e.get().identity(),r=eu(s,t,n);Xc(s,i,r),s.measurable=!1,e.addBoundsMask(i),$e.return(n),Ht.return(i)}function eu(s,e,t){return s?(s!==e&&(eu(s.parent,e,t),s.updateLocalTransform(),t.append(s.localTransform)),t):(me("Mask bounds, renderable is not inside the root container"),t)}class tu{constructor(e){this.priority=0,this.inverse=!1,this.pipe="alphaMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof ue),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(e,t){this.inverse||Qc(this.mask,e,t)}addLocalBounds(e,t){Jc(this.mask,e,t)}containsPoint(e,t){const i=this.mask;return t(i,e)}destroy(){this.reset()}static test(e){return e instanceof ue}}tu.extension=$.MaskEffect;class iu{constructor(e){this.priority=0,this.pipe="colorMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e=="number"}}iu.extension=$.MaskEffect;class su{constructor(e){this.priority=0,this.pipe="stencilMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(e,t){Qc(this.mask,e,t)}addLocalBounds(e,t){Jc(this.mask,e,t)}containsPoint(e,t){const i=this.mask;return t(i,e)}destroy(){this.reset()}static test(e){return e instanceof U}}su.extension=$.MaskEffect;const Sp={createCanvas:(s,e)=>{const t=document.createElement("canvas");return t.width=s,t.height=e,t},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,e)=>fetch(s,e),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let hl=Sp;const _e={get(){return hl},set(s){hl=s}};class nu extends At{constructor(e){e.resource||(e.resource=_e.get().createCanvas()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(e=this.width,t=this.height,i=this._resolution){const n=super.resize(e,t,i);return n&&this.resizeCanvas(),n}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}nu.extension=$.TextureSource;class gs extends At{constructor(e){if(e.resource&&globalThis.HTMLImageElement&&e.resource instanceof HTMLImageElement){const t=_e.get().createCanvas(e.resource.width,e.resource.height);t.getContext("2d").drawImage(e.resource,0,0,e.resource.width,e.resource.height),e.resource=t,me("ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.")}super(e),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}}gs.extension=$.TextureSource;var zo=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(zo||{});class qr{constructor(e,t=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=i,this._once=n}match(e,t=null){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));const t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const t=this.next;return this.next=e?null:t,this.previous=null,t}}const ru=class Ve{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new qr(null,null,1/0),this.deltaMS=1/Ve.targetFPMS,this.elapsedMS=1/Ve.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,t,i=zo.NORMAL){return this._addListener(new qr(e,t,i))}addOnce(e,t,i=zo.NORMAL){return this._addListener(new qr(e,t,i,!0))}_addListener(e){let t=this._head.next,i=this._head;if(!t)e.connect(i);else{for(;t;){if(e.priority>t.priority){e.connect(i);break}i=t,t=t.next}e.previous||e.connect(i)}return this._startIfPossible(),this}remove(e,t){let i=this._head.next;for(;i;)i.match(e,t)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const r=e-this._lastFrame|0;if(r<this._minElapsedMS)return;this._lastFrame=e-r%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*Ve.targetFPMS;const i=this._head;let n=i.next;for(;n;)n=n.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const t=Math.min(this.maxFPS,e),i=Math.min(Math.max(0,t)/1e3,Ve.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){if(e===0)this._minElapsedMS=0;else{const t=Math.max(this.minFPS,e);this._minElapsedMS=1/(t/1e3)}}static get shared(){if(!Ve._shared){const e=Ve._shared=new Ve;e.autoStart=!0,e._protected=!0}return Ve._shared}static get system(){if(!Ve._system){const e=Ve._system=new Ve;e.autoStart=!0,e._protected=!0}return Ve._system}};ru.targetFPMS=.06;let fn=ru,Vr;async function ou(){return Vr??(Vr=(async()=>{const e=document.createElement("canvas").getContext("webgl");if(!e)return"premultiply-alpha-on-upload";const t=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!t)return"premultiply-alpha-on-upload";const i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i);const n=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,n),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);const r=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,r),e.deleteFramebuffer(n),e.deleteTexture(i),e.getExtension("WEBGL_lose_context")?.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Vr}const Jn=class au extends At{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...au.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this.alphaMode=e.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const e=fn.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const e=this.resource,t=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(t.preload||e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlayThrough),e.addEventListener("error",this._onError,!0)),this.alphaMode=await ou(),this._load=new Promise((i,n)=>{this.isValid?i(this):(this._resolve=i,this._reject=n,t.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${t.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const e=this.resource;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlayThrough),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(fn.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(fn.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(fn.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};Jn.extension=$.TextureSource;Jn.defaultOptions={...At.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Jn.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let In=Jn;const mt=(s,e,t=!1)=>(Array.isArray(s)||(s=[s]),e?s.map(i=>typeof i=="string"||t?e(i):i):s);class Cp{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||me(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const i=mt(e);let n;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.test(t)){n=h.getCacheableAssets(i,t);break}}const r=new Map(Object.entries(n||{}));n||i.forEach(l=>{r.set(l,t)});const o=[...r.keys()],a={cacheKeys:o,keys:i};i.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{const h=n?n[l]:t;this._cache.has(l)&&this._cache.get(l)!==h&&me("[Cache] already has key:",l),this._cache.set(l,r.get(l))})}remove(e){if(!this._cacheMap.has(e)){me(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(n=>{this._cache.delete(n)}),t.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const de=new Cp,Io=[];Oe.handleByList($.TextureSource,Io);function lu(s={}){const e=s&&s.resource,t=e?s.resource:s,i=e?s:{resource:s};for(let n=0;n<Io.length;n++){const r=Io[n];if(r.test(t))return new r(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Mp(s={},e=!1){const t=s&&s.resource,i=t?s.resource:s,n=t?s:{resource:s};if(!e&&de.has(i))return de.get(i);const r=new Y({source:lu(n)});return r.on("destroy",()=>{de.has(i)&&de.remove(i)}),e||de.set(i,r),r}function Tp(s,e=!1){return typeof s=="string"?de.get(s):s instanceof At?new Y({source:s}):Mp(s,e)}Y.from=Tp;At.from=lu;Oe.add(tu,iu,su,In,gs,nu,ha);var ui=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(ui||{});function ut(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function ks(s){return s.split("?")[0].split("#")[0]}function Pp(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zp(s,e,t){return s.replace(new RegExp(Pp(e),"g"),t)}function Ip(s,e){let t="",i=0,n=-1,r=0,o=-1;for(let a=0;a<=s.length;++a){if(a<s.length)o=s.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(n===a-1||r===1))if(n!==a-1&&r===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){const l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",i=0):(t=t.slice(0,l),i=t.length-1-t.lastIndexOf("/")),n=a,r=0;continue}}else if(t.length===2||t.length===1){t="",i=0,n=a,r=0;continue}}}else t.length>0?t+=`/${s.slice(n+1,a)}`:t=s.slice(n+1,a),i=a-n-1;n=a,r=0}else o===46&&r!==-1?++r:r=-1}return t}const Ke={toPosix(s){return zp(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){ut(s),s=this.toPosix(s);const e=/^file:\/\/\//.exec(s);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(s);return t?t[0]:""},toAbsolute(s,e,t){if(ut(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=ks(this.toPosix(e??_e.get().getBaseUrl())),n=ks(this.toPosix(t??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?Ke.join(n,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(ut(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let e="";const t=s.startsWith("/");this.hasProtocol(s)&&(e=this.rootname(s),s=s.slice(e.length));const i=s.endsWith("/");return s=Ip(s),s.length>0&&i&&(s+="/"),t?`/${s}`:e+s},isAbsolute(s){return ut(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let e;for(let t=0;t<s.length;++t){const i=s[t];if(ut(i),i.length>0)if(e===void 0)e=i;else{const n=s[t-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(s){if(ut(s),s.length===0)return".";s=this.toPosix(s);let e=s.charCodeAt(0);const t=e===47;let i=-1,n=!0;const r=this.getProtocol(s),o=s;s=s.slice(r.length);for(let a=s.length-1;a>=1;--a)if(e=s.charCodeAt(a),e===47){if(!n){i=a;break}}else n=!1;return i===-1?t?"/":this.isUrl(o)?r+s:r:t&&i===1?"//":r+s.slice(0,i)},rootname(s){ut(s),s=this.toPosix(s);let e="";if(s.startsWith("/")?e="/":e=this.getProtocol(s),this.isUrl(s)){const t=s.indexOf("/",e.length);t!==-1?e=s.slice(0,t):e=s,e.endsWith("/")||(e+="/")}return e},basename(s,e){ut(s),e&&ut(e),s=ks(this.toPosix(s));let t=0,i=-1,n=!0,r;if(e!==void 0&&e.length>0&&e.length<=s.length){if(e.length===s.length&&e===s)return"";let o=e.length-1,a=-1;for(r=s.length-1;r>=0;--r){const l=s.charCodeAt(r);if(l===47){if(!n){t=r+1;break}}else a===-1&&(n=!1,a=r+1),o>=0&&(l===e.charCodeAt(o)?--o===-1&&(i=r):(o=-1,i=a))}return t===i?i=a:i===-1&&(i=s.length),s.slice(t,i)}for(r=s.length-1;r>=0;--r)if(s.charCodeAt(r)===47){if(!n){t=r+1;break}}else i===-1&&(n=!1,i=r+1);return i===-1?"":s.slice(t,i)},extname(s){ut(s),s=ks(this.toPosix(s));let e=-1,t=0,i=-1,n=!0,r=0;for(let o=s.length-1;o>=0;--o){const a=s.charCodeAt(o);if(a===47){if(!n){t=o+1;break}continue}i===-1&&(n=!1,i=o+1),a===46?e===-1?e=o:r!==1&&(r=1):e!==-1&&(r=-1)}return e===-1||i===-1||r===0||r===1&&e===i-1&&e===t+1?"":s.slice(e,i)},parse(s){ut(s);const e={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return e;s=ks(this.toPosix(s));let t=s.charCodeAt(0);const i=this.isAbsolute(s);let n;e.root=this.rootname(s),i||this.hasProtocol(s)?n=1:n=0;let r=-1,o=0,a=-1,l=!0,h=s.length-1,c=0;for(;h>=n;--h){if(t=s.charCodeAt(h),t===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),t===46?r===-1?r=h:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||a===-1||c===0||c===1&&r===a-1&&r===o+1?a!==-1&&(o===0&&i?e.base=e.name=s.slice(1,a):e.base=e.name=s.slice(o,a)):(o===0&&i?(e.name=s.slice(1,r),e.base=s.slice(1,a)):(e.name=s.slice(o,r),e.base=s.slice(o,a)),e.ext=s.slice(r,a)),e.dir=this.dirname(s),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function hu(s,e,t,i,n){const r=e[t];for(let o=0;o<r.length;o++){const a=r[o];t<e.length-1?hu(s.replace(i[t],a),e,t+1,i,n):n.push(s.replace(i[t],a))}}function Ep(s){const e=/\{(.*?)\}/g,t=s.match(e),i=[];if(t){const n=[];t.forEach(r=>{const o=r.substring(1,r.length-1).split(",");n.push(o)}),hu(s,n,0,t,i)}else i.push(s);return i}const Un=s=>!Array.isArray(s);class ps{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(t[i])}`).join("&")}}getAlias(e){const{alias:t,src:i}=e;return mt(t||i,r=>typeof r=="string"?r:Array.isArray(r)?r.map(o=>o?.src??o):r?.src?r.src:r,!0)}addManifest(e){this._manifest&&me("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const i=[];let n=t;Array.isArray(t)||(n=Object.entries(t).map(([r,o])=>typeof o=="string"||Array.isArray(o)?{alias:r,src:o}:{alias:r,...o})),n.forEach(r=>{const o=r.src,a=r.alias;let l;if(typeof a=="string"){const h=this._createBundleAssetId(e,a);i.push(h),l=[a,h]}else{const h=a.map(c=>this._createBundleAssetId(e,c));i.push(...h),l=[...a,...h]}this.add({...r,alias:l,src:o})}),this._bundles[e]=i}add(e){const t=[];Array.isArray(e)?t.push(...e):t.push(e);let i;i=r=>{this.hasKey(r)&&me(`[Resolver] already has key: ${r} overwriting`)},mt(t).forEach(r=>{const{src:o}=r;let{data:a,format:l,loadParser:h}=r;const c=mt(o).map(_=>typeof _=="string"?Ep(_):Array.isArray(_)?_:[_]),u=this.getAlias(r);Array.isArray(u)?u.forEach(i):i(u);const d=[];c.forEach(_=>{_.forEach(f=>{let g={};if(typeof f!="object"){g.src=f;for(let p=0;p<this._parsers.length;p++){const m=this._parsers[p];if(m.test(f)){g=m.parse(f);break}}}else a=f.data??a,l=f.format??l,h=f.loadParser??h,g={...g,...f};if(!u)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this._buildResolvedAsset(g,{aliases:u,data:a,format:l,loadParser:h}),d.push(g)})}),u.forEach(_=>{this._assetMap[_]=d})})}resolveBundle(e){const t=Un(e);e=mt(e);const i={};return e.forEach(n=>{const r=this._bundles[n];if(r){const o=this.resolve(r),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(n,l)]=h}i[n]=a}}),t?i[e[0]]:i}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const i={};for(const n in t)i[n]=t[n].src;return i}return t.src}resolve(e){const t=Un(e);e=mt(e);const i={};return e.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let r=this._assetMap[n];const o=this._getPreferredOrder(r);o?.priority.forEach(a=>{o.params[a].forEach(l=>{const h=r.filter(c=>c[a]?c[a]===l:!1);h.length&&(r=h)})}),this._resolverHash[n]=r[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),t?i[e[0]]:i}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const i=e[t],n=this._preferredOrder.find(r=>r.params.format.includes(i.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}_buildResolvedAsset(e,t){const{aliases:i,data:n,loadParser:r,format:o}=t;return(this._basePath||this._rootPath)&&(e.src=Ke.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=i??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...n||{},...e.data},e.loadParser=r??e.loadParser,e.format=o??e.format??Rp(e.src),e}}ps.RETINA_PREFIX=/@([0-9\.]+)x/;function Rp(s){return s.split(".").pop().split("?").shift().split("#").shift()}const Eo=(s,e)=>{const t=e.split("?")[1];return t&&(s+=`?${t}`),s},cu=class Fs{constructor(e,t){this.linkedSheets=[],this._texture=e instanceof Y?e:null,this.textureSource=e.source,this.textures={},this.animations={},this.data=t;const i=parseFloat(t.meta.scale);i?(this.resolution=i,e.source.resolution=this.resolution):this.resolution=e.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=Fs.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let t=e;const i=Fs.BATCH_SIZE;for(;t-e<i&&t<this._frameKeys.length;){const n=this._frameKeys[t],r=this._frames[n],o=r.frame;if(o){let a=null,l=null;const h=r.trimmed!==!1&&r.sourceSize?r.sourceSize:r.frame,c=new se(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);r.rotated?a=new se(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new se(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),r.trimmed!==!1&&r.spriteSourceSize&&(l=new se(Math.floor(r.spriteSourceSize.x)/this.resolution,Math.floor(r.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[n]=new Y({source:this.textureSource,frame:a,orig:c,trim:l,rotate:r.rotated?2:0,defaultAnchor:r.anchor,defaultBorders:r.borders,label:n.toString()})}t++}}_processAnimations(){const e=this.data.animations||{};for(const t in e){this.animations[t]=[];for(let i=0;i<e[t].length;i++){const n=e[t][i];this.animations[t].push(this.textures[n])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Fs.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Fs.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){for(const t in this.textures)this.textures[t].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};cu.BATCH_SIZE=1e3;let cl=cu;const Fp=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function uu(s,e,t){const i={};if(s.forEach(n=>{i[n]=e}),Object.keys(e.textures).forEach(n=>{i[n]=e.textures[n]}),!t){const n=Ke.dirname(s[0]);e.linkedSheets.forEach((r,o)=>{const a=uu([`${n}/${e.data.meta.related_multi_packs[o]}`],r,!0);Object.assign(i,a)})}return i}const Bp={extension:$.Asset,cache:{test:s=>s instanceof cl,getCacheableAssets:(s,e)=>uu(s,e,!1)},resolver:{extension:{type:$.ResolveParser,name:"resolveSpritesheet"},test:s=>{const t=s.split("?")[0].split("."),i=t.pop(),n=t.pop();return i==="json"&&Fp.includes(n)},parse:s=>{const e=s.split(".");return{resolution:parseFloat(ps.RETINA_PREFIX.exec(s)?.[1]??"1"),format:e[e.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:$.LoadParser,priority:ui.Normal,name:"spritesheetLoader"},async testParse(s,e){return Ke.extname(e.src).toLowerCase()===".json"&&!!s.frames},async parse(s,e,t){const{texture:i,imageFilename:n,textureOptions:r}=e?.data??{};let o=Ke.dirname(e.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i instanceof Y)a=i;else{const c=Eo(o+(n??s.meta.image),e.src);a=(await t.load([{src:c,data:r}]))[c]}const l=new cl(a.source,s);await l.parse();const h=s?.meta?.related_multi_packs;if(Array.isArray(h)){const c=[];for(const d of h){if(typeof d!="string")continue;let _=o+d;e.data?.ignoreMultiPack||(_=Eo(_,e.src),c.push(t.load({src:_,data:{ignoreMultiPack:!0}})))}const u=await Promise.all(c);l.linkedSheets=u,u.forEach(d=>{d.linkedSheets=[l].concat(l.linkedSheets.filter(_=>_!==d))})}return l},async unload(s,e,t){await t.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};Oe.add(Bp);const Xr=Object.create(null),ul=Object.create(null);function da(s,e){let t=ul[s];return t===void 0&&(Xr[e]===void 0&&(Xr[e]=1),ul[s]=t=Xr[e]++),t}let gn;function du(){return(!gn||gn?.isContextLost())&&(gn=_e.get().createCanvas().getContext("webgl",{})),gn}let pn;function Lp(){if(!pn){pn="mediump";const s=du();s&&s.getShaderPrecisionFormat&&(pn=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return pn}function $p(s,e,t){return e?s:t?(s=s.replace("out vec4 finalColor;",""),`
8        
9        #ifdef GL_ES // This checks if it is WebGL1
10        #define in varying
11        #define finalColor gl_FragColor
12        #define texture texture2D
13        #endif
14        ${s}
15        `):`
16        
17        #ifdef GL_ES // This checks if it is WebGL1
18        #define in attribute
19        #define out varying
20        #endif
21        ${s}
22        `}function Op(s,e,t){const i=t?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let n=t?e.requestedFragmentPrecision:e.requestedVertexPrecision;return n==="highp"&&i!=="highp"&&(n="mediump"),`precision ${n} float;
23${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function Gp(s,e){return e?`#version 300 es
24${s}`:s}const Np={},Dp={};function Up(s,{name:e="pixi-program"},t=!0){e=e.replace(/\s+/g,"-"),e+=t?"-fragment":"-vertex";const i=t?Np:Dp;return i[e]?(i[e]++,e+=`-${i[e]}`):i[e]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${e}`}
25${s}`}function Wp(s,e){return e?s.replace("#version 300 es",""):s}const Yr={stripVersion:Wp,ensurePrecision:Op,addProgramDefines:$p,setProgramName:Up,insertVersion:Gp},jr=Object.create(null),_u=class Ro{constructor(e){e={...Ro.defaultOptions,...e};const t=e.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:t,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Lp()},setProgramName:{name:e.name},addProgramDefines:t,insertVersion:t};let n=e.fragment,r=e.vertex;Object.keys(Yr).forEach(o=>{const a=i[o];n=Yr[o](n,a,!0),r=Yr[o](r,a,!1)}),this.fragment=n,this.vertex=r,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=da(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(e){const t=`${e.vertex}:${e.fragment}`;return jr[t]||(jr[t]=new Ro(e)),jr[t]}};_u.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let ls=_u;const dl={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Hp(s){return dl[s]??dl.float32}const qp={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function Vp({source:s,entryPoint:e}){const t={},i=s.indexOf(`fn ${e}`);if(i!==-1){const n=s.indexOf("->",i);if(n!==-1){const r=s.substring(i,n),o=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let a;for(;(a=o.exec(r))!==null;){const l=qp[a[3]]??"float32";t[a[2]]={location:parseInt(a[1],10),format:l,stride:Hp(l).stride,offset:0,instance:!1,start:0}}}}return t}function Kr(s){const e=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,t=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,r=/:\s*(\w+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,l=/struct\s+(\w+)/,h=s.match(e)?.map(u=>({group:parseInt(u.match(t)[1],10),binding:parseInt(u.match(i)[1],10),name:u.match(n)[2],isUniform:u.match(n)[1]==="<uniform>",type:u.match(r)[1]}));if(!h)return{groups:[],structs:[]};const c=s.match(o)?.map(u=>{const d=u.match(l)[1],_=u.match(a).reduce((f,g)=>{const[p,m]=g.split(":");return f[p.trim()]=m.trim(),f},{});return _?{name:d,members:_}:null}).filter(({name:u})=>h.some(d=>d.type===u))??[];return{groups:h,structs:c}}var Bs=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(Bs||{});function Xp({groups:s}){const e=[];for(let t=0;t<s.length;t++){const i=s[t];e[i.group]||(e[i.group]=[]),i.isUniform?e[i.group].push({binding:i.binding,visibility:Bs.VERTEX|Bs.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?e[i.group].push({binding:i.binding,visibility:Bs.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&e[i.group].push({binding:i.binding,visibility:Bs.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return e}function Yp({groups:s}){const e=[];for(let t=0;t<s.length;t++){const i=s[t];e[i.group]||(e[i.group]={}),e[i.group][i.name]=i.binding}return e}function jp(s,e){const t=new Set,i=new Set,n=[...s.structs,...e.structs].filter(o=>t.has(o.name)?!1:(t.add(o.name),!0)),r=[...s.groups,...e.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:n,groups:r}}const Zr=Object.create(null);class li{constructor(e){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:t,vertex:i,layout:n,gpuLayout:r,name:o}=e;if(this.name=o,this.fragment=t,this.vertex=i,t.source===i.source){const a=Kr(t.source);this.structsAndGroups=a}else{const a=Kr(i.source),l=Kr(t.source);this.structsAndGroups=jp(a,l)}this.layout=n??Yp(this.structsAndGroups),this.gpuLayout=r??Xp(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:e,fragment:t}=this,i=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=da(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Vp(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(e){const t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;return Zr[t]||(Zr[t]=new li(e)),Zr[t]}}const fu=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],Kp=fu.reduce((s,e)=>(s[e]=!0,s),{});function Zp(s,e){switch(s){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const gu=class pu{constructor(e,t){this._touched=0,this.uid=pe("uniform"),this._resourceType="uniformGroup",this._resourceId=pe("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,t={...pu.defaultOptions,...t},this.uniformStructures=e;const i={};for(const n in e){const r=e[n];if(r.name=n,r.size=r.size??1,!Kp[r.type])throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${fu.join(", ")}`);r.value??(r.value=Zp(r.type,r.size)),i[n]=r.value}this.uniforms=i,this._dirtyId=1,this.ubo=t.ubo,this.isStatic=t.isStatic,this._signature=da(Object.keys(i).map(n=>`${n}-${e[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};gu.defaultOptions={ubo:!1,isStatic:!1};let mu=gu;class En{constructor(e){this.resources=Object.create(null),this._dirty=!0;let t=0;for(const i in e){const n=e[i];this.setResource(n,t++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const e=[];let t=0;for(const i in this.resources)e[t++]=this.resources[i]._resourceId;this._key=e.join("|")}setResource(e,t){const i=this.resources[t];e!==i&&(i&&e.off?.("change",this.onResourceChange,this),e.on?.("change",this.onResourceChange,this),this.resources[t]=e,this._dirty=!0)}getResource(e){return this.resources[e]}_touch(e){const t=this.resources;for(const i in t)t[i]._touched=e}destroy(){const e=this.resources;for(const t in e)e[t].off?.("change",this.onResourceChange,this);this.resources=null}onResourceChange(e){if(this._dirty=!0,e.destroyed){const t=this.resources;for(const i in t)t[i]===e&&(t[i]=null)}else this._updateKey()}}var Fo=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Fo||{});class er extends kt{constructor(e){super(),this.uid=pe("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:t,glProgram:i,groups:n,resources:r,compatibleRenderers:o,groupMap:a}=e;this.gpuProgram=t,this.glProgram=i,o===void 0&&(o=0,t&&(o|=Fo.WEBGPU),i&&(o|=Fo.WEBGL)),this.compatibleRenderers=o;const l={};if(!r&&!n&&(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!t&&n&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!t&&n&&a)for(const h in a)for(const c in a[h]){const u=a[h][c];l[u]={group:h,binding:c,name:u}}else if(t&&n&&!a){const h=t.structsAndGroups.groups;a={},h.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,l[c.name]=c})}else if(r){n={},a={},t&&t.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,l[u.name]=u});let h=0;for(const c in r)l[c]||(n[99]||(n[99]=new En,this._ownedBindGroups.push(n[99])),l[c]={group:99,binding:h,name:c},a[99]=a[99]||{},a[99][h]=c,h++);for(const c in r){const u=c;let d=r[c];!d.source&&!d._resourceType&&(d=new mu(d));const _=l[u];_&&(n[_.group]||(n[_.group]=new En,this._ownedBindGroups.push(n[_.group])),n[_.group].setResource(d,_.binding))}}this.groups=n,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(n,l)}addResource(e,t,i){var n,r;(n=this._uniformBindMap)[t]||(n[t]={}),(r=this._uniformBindMap[t])[i]||(r[i]=e),this.groups[t]||(this.groups[t]=new En,this._ownedBindGroups.push(this.groups[t]))}_buildResourceAccessor(e,t){const i={};for(const n in t){const r=t[n];Object.defineProperty(i,r.name,{get(){return e[r.group].getResource(r.binding)},set(o){e[r.group].setResource(o,r.binding)}})}return i}destroy(e=!1){this.emit("destroy",this),e&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(t=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(e){const{gpu:t,gl:i,...n}=e;let r,o;return t&&(r=li.from(t)),i&&(o=ls.from(i)),new er({gpuProgram:r,glProgram:o,...n})}}const Qp={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},Qr=0,Jr=1,eo=2,to=3,io=4,so=5,Bo=class bu{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Qr)}set blend(e){!!(this.data&1<<Qr)!==e&&(this.data^=1<<Qr)}get offsets(){return!!(this.data&1<<Jr)}set offsets(e){!!(this.data&1<<Jr)!==e&&(this.data^=1<<Jr)}set cullMode(e){if(e==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=e==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<eo)}set culling(e){!!(this.data&1<<eo)!==e&&(this.data^=1<<eo)}get depthTest(){return!!(this.data&1<<to)}set depthTest(e){!!(this.data&1<<to)!==e&&(this.data^=1<<to)}get depthMask(){return!!(this.data&1<<so)}set depthMask(e){!!(this.data&1<<so)!==e&&(this.data^=1<<so)}get clockwiseFrontFace(){return!!(this.data&1<<io)}set clockwiseFrontFace(e){!!(this.data&1<<io)!==e&&(this.data^=1<<io)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!=="none",this._blendMode=e,this._blendModeId=Qp[e]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const e=new bu;return e.depthTest=!1,e.blend=!0,e}};Bo.default2d=Bo.for2d();let Jp=Bo;const yu=class Lo extends er{constructor(e){e={...Lo.defaultOptions,...e},super(e),this.enabled=!0,this._state=Jp.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1)}apply(e,t,i,n){e.applyFilter(this,t,i,n)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:i,...n}=e;let r,o;return t&&(r=li.from(t)),i&&(o=ls.from(i)),new Lo({gpuProgram:r,glProgram:o,...n})}};yu.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let $o=yu;const Oo=[];Oe.handleByNamedList($.Environment,Oo);async function em(s){if(!s)for(let e=0;e<Oo.length;e++){const t=Oo[e];if(t.value.test()){await t.value.load();return}}}let As;function tm(){if(typeof As=="boolean")return As;try{As=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{As=!1}return As}var _a={exports:{}};_a.exports=tr;_a.exports.default=tr;function tr(s,e,t){t=t||2;var i=e&&e.length,n=i?e[0]*t:s.length,r=wu(s,0,n,t,!0),o=[];if(!r||r.next===r.prev)return o;var a,l,h,c,u,d,_;if(i&&(r=om(s,e,r,t)),s.length>80*t){a=h=s[0],l=c=s[1];for(var f=t;f<n;
vendor: 4,856 bytes, line 25
25f+=t)u=s[f],d=s[f+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);_=Math.max(h-a,c-l),_=_!==0?32767/_:0}return Vs(r,o,t,a,l,_,0),o}function wu(s,e,t,i,n){var r,o;if(n===Do(s,e,t,i)>0)for(r=e;r<t;r+=i)o=_l(r,s[r],s[r+1],o);else for(r=t-i;r>=e;r-=i)o=_l(r,s[r],s[r+1],o);return o&&ir(o,o.next)&&(Ys(o),o=o.next),o}function Ri(s,e){if(!s)return s;e||(e=s);var t=s,i;do if(i=!1,!t.steiner&&(ir(t,t.next)||ae(t.prev,t,t.next)===0)){if(Ys(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Vs(s,e,t,i,n,r,o){if(s){!o&&r&&um(s,i,n,r);for(var a=s,l,h;s.prev!==s.next;){if(l=s.prev,h=s.next,r?sm(s,i,n,r):im(s)){e.push(l.i/t|0),e.push(s.i/t|0),e.push(h.i/t|0),Ys(s),s=h.next,a=h.next;continue}if(s=h,s===a){o?o===1?(s=nm(Ri(s),e,t),Vs(s,e,t,i,n,r,2)):o===2&&rm(s,e,t,i,n,r):Vs(Ri(s),e,t,i,n,r,1);break}}}}function im(s){var e=s.prev,t=s,i=s.next;if(ae(e,t,i)>=0)return!1;for(var n=e.x,r=t.x,o=i.x,a=e.y,l=t.y,h=i.y,c=n<r?n<o?n:o:r<o?r:o,u=a<l?a<h?a:h:l<h?l:h,d=n>r?n>o?n:o:r>o?r:o,_=a>l?a>h?a:h:l>h?l:h,f=i.next;f!==e;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=_&&es(n,a,r,l,o,h,f.x,f.y)&&ae(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function sm(s,e,t,i){var n=s.prev,r=s,o=s.next;if(ae(n,r,o)>=0)return!1;for(var a=n.x,l=r.x,h=o.x,c=n.y,u=r.y,d=o.y,_=a<l?a<h?a:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,g=a>l?a>h?a:h:l>h?l:h,p=c>u?c>d?c:d:u>d?u:d,m=Go(_,f,e,t,i),b=Go(g,p,e,t,i),y=s.prevZ,w=s.nextZ;y&&y.z>=m&&w&&w.z<=b;){if(y.x>=_&&y.x<=g&&y.y>=f&&y.y<=p&&y!==n&&y!==o&&es(a,c,l,u,h,d,y.x,y.y)&&ae(y.prev,y,y.next)>=0||(y=y.prevZ,w.x>=_&&w.x<=g&&w.y>=f&&w.y<=p&&w!==n&&w!==o&&es(a,c,l,u,h,d,w.x,w.y)&&ae(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;y&&y.z>=m;){if(y.x>=_&&y.x<=g&&y.y>=f&&y.y<=p&&y!==n&&y!==o&&es(a,c,l,u,h,d,y.x,y.y)&&ae(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;w&&w.z<=b;){if(w.x>=_&&w.x<=g&&w.y>=f&&w.y<=p&&w!==n&&w!==o&&es(a,c,l,u,h,d,w.x,w.y)&&ae(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function nm(s,e,t){var i=s;do{var n=i.prev,r=i.next.next;!ir(n,r)&&xu(n,i,i.next,r)&&Xs(n,r)&&Xs(r,n)&&(e.push(n.i/t|0),e.push(i.i/t|0),e.push(r.i/t|0),Ys(i),Ys(i.next),i=s=r),i=i.next}while(i!==s);return Ri(i)}function rm(s,e,t,i,n,r){var o=s;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&fm(o,a)){var l=vu(o,a);o=Ri(o,o.next),l=Ri(l,l.next),Vs(o,e,t,i,n,r,0),Vs(l,e,t,i,n,r,0);return}a=a.next}o=o.next}while(o!==s)}function om(s,e,t,i){var n=[],r,o,a,l,h;for(r=0,o=e.length;r<o;r++)a=e[r]*i,l=r<o-1?e[r+1]*i:s.length,h=wu(s,a,l,i,!1),h===h.next&&(h.steiner=!0),n.push(_m(h));for(n.sort(am),r=0;r<n.length;r++)t=lm(n[r],t);return t}function am(s,e){return s.x-e.x}function lm(s,e){var t=hm(s,e);if(!t)return e;var i=vu(t,s);return Ri(i,i.next),Ri(t,t.next)}function hm(s,e){var t=e,i=s.x,n=s.y,r=-1/0,o;do{if(n<=t.y&&n>=t.next.y&&t.next.y!==t.y){var a=t.x+(n-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(a<=i&&a>r&&(r=a,o=t.x<t.next.x?t:t.next,a===i))return o}t=t.next}while(t!==e);if(!o)return null;var l=o,h=o.x,c=o.y,u=1/0,d;t=o;do i>=t.x&&t.x>=h&&i!==t.x&&es(n<c?i:r,n,h,c,n<c?r:i,n,t.x,t.y)&&(d=Math.abs(n-t.y)/(i-t.x),Xs(t,s)&&(d<u||d===u&&(t.x>o.x||t.x===o.x&&cm(o,t)))&&(o=t,u=d)),t=t.next;while(t!==l);return o}function cm(s,e){return ae(s.prev,s,e.prev)<0&&ae(e.next,s,s.next)<0}function um(s,e,t,i){var n=s;do n.z===0&&(n.z=Go(n.x,n.y,e,t,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==s);n.prevZ.nextZ=null,n.prevZ=null,dm(n)}function dm(s){var e,t,i,n,r,o,a,l,h=1;do{for(t=s,s=null,r=null,o=0;t;){for(o++,i=t,a=0,e=0;e<h&&(a++,i=i.nextZ,!!i);e++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(n=t,t=t.nextZ,a--):(n=i,i=i.nextZ,l--),r?r.nextZ=n:s=n,n.prevZ=r,r=n;t=i}r.nextZ=null,h*=2}while(o>1);return s}function Go(s,e,t,i,n){return s=(s-t)*n|0,e=(e-i)*n|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function _m(s){var e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function es(s,e,t,i,n,r,o,a){return(n-o)*(e-a)>=(s-o)*(r-a)&&(s-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(n-o)*(i-a)}function fm(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!gm(s,e)&&(Xs(s,e)&&Xs(e,s)&&pm(s,e)&&(ae(s.prev,s,e.prev)||ae(s,e.prev,e))||ir(s,e)&&ae(s.prev,s,s.next)>0&&ae(e.prev,e,e.next)>0)}function ae(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function ir(s,e){return s.x===e.x&&s.y===e.y}function xu(s,e,t,i){var n=bn(ae(s,e,t)),r=bn(ae(s,e,i)),o=bn(ae(t,i,s)),a=bn(ae(t,i,e));return!!(n!==r&&o!==a||n===0&&mn(s,t,e)||r===0&&mn(s,i,e)||o===0&&mn(t,s,i)||a===0&&mn(t,e,i))}function mn(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function bn(s){return s>0?1:s<0?-1:0}function gm(s,e){var t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&xu(t,t.next,s,e))return!0;t=t.next}
vendor: 17,273 bytes, line 25
25while(t!==s);return!1}function Xs(s,e){return ae(s.prev,s,s.next)<0?ae(s,e,s.next)>=0&&ae(s,s.prev,e)>=0:ae(s,e,s.prev)<0||ae(s,s.next,e)<0}function pm(s,e){var t=s,i=!1,n=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&n<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==s);return i}function vu(s,e){var t=new No(s.i,s.x,s.y),i=new No(e.i,e.x,e.y),n=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=n,n.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function _l(s,e,t,i){var n=new No(s,e,t);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Ys(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function No(s,e,t){this.i=s,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}tr.deviation=function(s,e,t,i){var n=e&&e.length,r=n?e[0]*t:s.length,o=Math.abs(Do(s,0,r,t));if(n)for(var a=0,l=e.length;a<l;a++){var h=e[a]*t,c=a<l-1?e[a+1]*t:s.length;o-=Math.abs(Do(s,h,c,t))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*t,_=i[a+1]*t,f=i[a+2]*t;u+=Math.abs((s[d]-s[f])*(s[_+1]-s[d+1])-(s[d]-s[_])*(s[f+1]-s[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function Do(s,e,t,i){for(var n=0,r=e,o=t-i;r<t;r+=i)n+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return n}tr.flatten=function(s){for(var e=s[0][0].length,t={vertices:[],holes:[],dimensions:e},i=0,n=0;n<s.length;n++){for(var r=0;r<s[n].length;r++)for(var o=0;o<e;o++)t.vertices.push(s[n][r][o]);n>0&&(i+=s[n-1].length,t.holes.push(i))}return t};var mm=_a.exports;const bm=ra(mm);var ku=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(ku||{});class ym{constructor(e){this.items=[],this._name=e}emit(e,t,i,n,r,o,a,l){const{name:h,items:c}=this;for(let u=0,d=c.length;u<d;u++)c[u][h](e,t,i,n,r,o,a,l);return this}add(e){return e[this._name]&&(this.remove(e),this.items.push(e)),this}remove(e){const t=this.items.indexOf(e);return t!==-1&&this.items.splice(t,1),this}contains(e){return this.items.indexOf(e)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const wm=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Au=class Su extends kt{constructor(e){super(),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=e.type,this.name=e.name,this.config=e;const t=[...wm,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(e={}){const t=e.skipExtensionImports===!0?!0:e.manageImports===!1;await em(t),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)e={...this._systemsHash[i].constructor.defaultOptions,...e};e={...Su.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(e);this._initOptions=e}render(e,t){let i=e;if(i instanceof U&&(i={container:i},t&&(K(J,"passing a second argument is deprecated, please use render options instead"),i.target=t.renderTexture)),i.target||(i.target=this.view.renderTarget),i.target===this.view.renderTarget&&(this._lastObjectRendered=i.container,i.clearColor??(i.clearColor=this.background.colorRgba),i.clear??(i.clear=this.background.clearBeforeRender)),i.clearColor){const n=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=n?i.clearColor:fe.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.enableRenderGroup(),this.runners.prerender.emit(i),this.runners.renderStart.emit(i),this.runners.render.emit(i),this.runners.renderEnd.emit(i),this.runners.postrender.emit(i)}resize(e,t,i){const n=this.view.resolution;this.view.resize(e,t,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==n&&this.runners.resolutionChange.emit(i)}clear(e={}){const t=this;e.target||(e.target=t.renderTarget.renderTarget),e.clearColor||(e.clearColor=this.background.colorRgba),e.clear??(e.clear=ku.ALL);const{clear:i,clearColor:n,target:r}=e;fe.shared.setValue(n??this.background.colorRgba),t.renderTarget.clear(r,i,fe.shared.toArray())}get resolution(){return this.view.resolution}set resolution(e){this.view.resolution=e,this.runners.resolutionChange.emit(e)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...e){e.forEach(t=>{this.runners[t]=new ym(t)})}_addSystems(e){let t;for(t in e){const i=e[t];this._addSystem(i.value,i.name)}}_addSystem(e,t){const i=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=i,this._systemsHash[t]=i;for(const n in this.runners)this.runners[n].add(i);return this}_addPipes(e,t){const i=t.reduce((n,r)=>(n[r.name]=r.value,n),{});e.forEach(n=>{const r=n.value,o=n.name,a=i[o];this.renderPipes[o]=new r(this,a?new a:null)})}destroy(e=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(e),Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(e){return this.textureGenerator.generateTexture(e)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!tm())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};Au.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Cu=Au,yn;function xm(s){return yn!==void 0||(yn=(()=>{const e={stencil:!0,failIfMajorPerformanceCaveat:s??Cu.defaultOptions.failIfMajorPerformanceCaveat};try{if(!_e.get().getWebGLRenderingContext())return!1;let i=_e.get().createCanvas().getContext("webgl",e);const n=!!i?.getContextAttributes()?.stencil;if(i){const r=i.getExtension("WEBGL_lose_context");r&&r.loseContext()}return i=null,n}catch{return!1}})()),yn}let wn;async function vm(s={}){return wn!==void 0||(wn=await(async()=>{const e=_e.get().getNavigator().gpu;if(!e)return!1;try{return await(await e.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),wn}const fl=["webgl","webgpu","canvas"];async function km(s){let e=[];s.preference?(e.push(s.preference),fl.forEach(r=>{r!==s.preference&&e.push(r)})):e=fl.slice();let t,i={};for(let r=0;r<e.length;r++){const o=e[r];if(o==="webgpu"&&await vm()){const{WebGPURenderer:a}=await Gn(()=>import("./WebGPURenderer-C5fANo1j.js"),__vite__mapDeps([47,2,48,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45]),import.meta.url);t=a,i={...s,...s.webgpu};break}else if(o==="webgl"&&xm(s.failIfMajorPerformanceCaveat??Cu.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await Gn(()=>import("./WebGLRenderer-OGv4ygO6.js"),__vite__mapDeps([49,2,48,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45]),import.meta.url);t=a,i={...s,...s.webgl};break}else if(o==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!t)throw new Error("No available renderer for the current environment");const n=new t;return await n.init(i),n}const Mu="8.7.3";class Tu{static init(){globalThis.__PIXI_APP_INIT__?.(this,Mu)}static destroy(){}}Tu.extension=$.Application;class Am{constructor(e){this._renderer=e}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,Mu)}destroy(){this._renderer=null}}Am.extension={type:[$.WebGLSystem,$.WebGPUSystem],name:"initHook",priority:-10};const Pu=class Uo{constructor(...e){this.stage=new U,e[0]!==void 0&&K(J,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.renderer=await km(e),Uo._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return K(J,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(e=!1,t=!1){const i=Uo._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};Pu._plugins=[];let zu=Pu;Oe.handleByList($.Application,zu._plugins);Oe.add(Tu);class Iu extends kt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return K(J,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return K(J,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return K(J,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return K(J,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return K(J,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(e=!1){this.emit("destroy",this),this.removeAllListeners();for(const t in this.chars)this.chars[t].texture?.destroy();this.chars=null,e&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}const Eu=class Wo{constructor(e,t,i,n){this.uid=pe("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=e,this.y0=t,this.x1=i,this.y1=n}addColorStop(e,t){return this.gradientStops.push({offset:e,color:fe.shared.setValue(t).toHexa()}),this._styleKey=null,this}buildLinearGradient(){if(this.texture)return;const e=Wo.defaultTextureSize,{gradientStops:t}=this,i=_e.get().createCanvas();i.width=e,i.height=e;const n=i.getContext("2d"),r=n.createLinearGradient(0,0,Wo.defaultTextureSize,1);for(let g=0;g<t.length;g++){const p=t[g];r.addColorStop(p.offset,p.color)}n.fillStyle=r,n.fillRect(0,0,e,e),this.texture=new Y({source:new gs({resource:i,addressModeU:"clamp-to-edge",addressModeV:"repeat"})});const{x0:o,y0:a,x1:l,y1:h}=this,c=new Z,u=l-o,d=h-a,_=Math.sqrt(u*u+d*d),f=Math.atan2(d,u);c.translate(-o,-a),c.scale(1/e,1/e),c.rotate(-f),c.scale(256/_,1),this.transform=c,this._styleKey=null}get styleKey(){if(this._styleKey)return this._styleKey;const e=this.gradientStops.map(n=>`${n.offset}-${n.color}`).join("-"),t=this.texture.uid,i=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${e}-${t}-${i}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Eu.defaultTextureSize=256;let js=Eu;const gl={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class sr{constructor(e,t){this.uid=pe("fillPattern"),this.transform=new Z,this._styleKey=null,this.texture=e,this.transform.scale(1/e.frame.width,1/e.frame.height),t&&(e.source.style.addressModeU=gl[t].addressModeU,e.source.style.addressModeV=gl[t].addressModeV)}setTransform(e){const t=this.texture;this.transform.copyFrom(e),this.transform.invert(),this.transform.scale(1/t.frame.width,1/t.frame.height),this._styleKey=null}get styleKey(){return this._styleKey?this._styleKey:(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`,this._styleKey)}}var Sm=Mm,no={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Cm=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Mm(s){var e=[];return s.replace(Cm,function(t,i,n){var r=i.toLowerCase();for(n=Pm(n),r=="m"&&n.length>2&&(e.push([i].concat(n.splice(0,2))),r="l",i=i=="m"?"l":"L");;){if(n.length==no[r])return n.unshift(i),e.push(n);if(n.length<no[r])throw new Error("malformed path data");e.push([i].concat(n.splice(0,no[r])))}}),e}var Tm=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function Pm(s){var e=s.match(Tm);return e?e.map(Number):[]}const zm=ra(Sm);function Im(s,e){const t=zm(s),i=[];let n=null,r=0,o=0;for(let a=0;a<t.length;a++){const l=t[a],h=l[0],c=l;switch(h){case"M":r=c[1],o=c[2],e.moveTo(r,o);break;case"m":r+=c[1],o+=c[2],e.moveTo(r,o);break;case"H":r=c[1],e.lineTo(r,o);break;case"h":r+=c[1],e.lineTo(r,o);break;case"V":o=c[1],e.lineTo(r,o);break;case"v":o+=c[1],e.lineTo(r,o);break;case"L":r=c[1],o=c[2],e.lineTo(r,o);break;case"l":r+=c[1],o+=c[2],e.lineTo(r,o);break;case"C":r=c[5],o=c[6],e.bezierCurveTo(c[1],c[2],c[3],c[4],r,o);break;case"c":e.bezierCurveTo(r+c[1],o+c[2],r+c[3],o+c[4],r+c[5],o+c[6]),r+=c[5],o+=c[6];break;case"S":r=c[3],o=c[4],e.bezierCurveToShort(c[1],c[2],r,o);break;case"s":e.bezierCurveToShort(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"Q":r=c[3],o=c[4],e.quadraticCurveTo(c[1],c[2],r,o);break;case"q":e.quadraticCurveTo(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"T":r=c[1],o=c[2],e.quadraticCurveToShort(r,o);break;case"t":r+=c[1],o+=c[2],e.quadraticCurveToShort(r,o);break;case"A":r=c[6],o=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"a":r+=c[6],o+=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"Z":case"z":e.closePath(),i.length>0&&(n=i.pop(),n?(r=n.startX,o=n.startY):(r=0,o=0)),n=null;break;default:me(`Unknown SVG path command: ${h}`)}h!=="Z"&&h!=="z"&&n===null&&(n={startX:r,startY:o},i.push(n))}return e}class fa{constructor(e=0,t=0,i=0){this.type="circle",this.x=e,this.y=t,this.radius=i}clone(){return new fa(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-e,r=this.y-t;return n*=n,r*=r,n+r<=i}strokeContains(e,t,i,n=.5){if(this.radius===0)return!1;const r=this.x-e,o=this.y-t,a=this.radius,l=(1-n)*i,h=Math.sqrt(r*r+o*o);return h<=a+l&&h>a-(i-l)}getBounds(e){return e||(e=new se),e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class ga{constructor(e=0,t=0,i=0,n=0){this.type="ellipse",this.x=e,this.y=t,this.halfWidth=i,this.halfHeight=n}clone(){return new ga(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(e-this.x)/this.halfWidth,n=(t-this.y)/this.halfHeight;return i*=i,n*=n,i+n<=1}strokeContains(e,t,i,n=.5){const{halfWidth:r,halfHeight:o}=this;if(r<=0||o<=0)return!1;const a=i*(1-n),l=i-a,h=r-l,c=o-l,u=r+a,d=o+a,_=e-this.x,f=t-this.y,g=_*_/(h*h)+f*f/(c*c),p=_*_/(u*u)+f*f/(d*d);return g>1&&p<=1}getBounds(e){return e||(e=new se),e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Em(s,e,t,i,n,r){const o=s-t,a=e-i,l=n-t,h=r-i,c=o*l+a*h,u=l*l+h*h;let d=-1;u!==0&&(d=c/u);let _,f;d<0?(_=t,f=i):d>1?(_=n,f=r):(_=t+d*l,f=i+d*h);const g=s-_,p=e-f;return g*g+p*p}class Ns{constructor(...e){this.type="polygon";let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const i=[];for(let n=0,r=t.length;n<r;n++)i.push(t[n].x,t[n].y);t=i}this.points=t,this.closePath=!0}clone(){const e=this.points.slice(),t=new Ns(e);return t.closePath=this.closePath,t}contains(e,t){let i=!1;const n=this.points.length/2;for(let r=0,o=n-1;r<n;o=r++){const a=this.points[r*2],l=this.points[r*2+1],h=this.points[o*2],c=this.points[o*2+1];l>t!=c>t&&e<(h-a)*((t-l)/(c-l))+a&&(i=!i)}return i}strokeContains(e,t,i,n=.5){const r=i*i,o=r*(1-n),a=r-o,{points:l}=this,h=l.length-(this.closePath?0:2);for(let c=0;c<h;c+=2){const u=l[c],d=l[c+1],_=l[(c+2)%l.length],f=l[(c+3)%l.length],g=Em(e,t,u,d,_,f),p=Math.sign((_-u)*(t-d)-(f-d)*(e-u));if(g<=(p<0?a:o))return!0}return!1}getBounds(e){e||(e=new se);const t=this.points;let i=1/0,n=-1/0,r=1/0,o=-1/0;for(let a=0,l=t.length;a<l;a+=2){const h=t[a],c=t[a+1];i=h<i?h:i,n=h>n?h:n,r=c<r?c:r,o=c>o?c:o}return e.x=i,e.width=n-i,e.y=r,e.height=o-r,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,t)=>
25`${e}, ${t}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const xn=(s,e,t,i,n,r,o)=>{const a=s-t,l=e-i,h=Math.sqrt(a*a+l*l);return h>=n-r&&h<=n+o};class pa{constructor(e=0,t=0,i=0,n=0,r=20){this.type="roundedRectangle",this.x=e,this.y=t,this.width=i,this.height=n,this.radius=r}getBounds(e){return e||(e=new se),e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new pa(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+i&&t<=this.y+this.height-i||e>=this.x+i&&e<=this.x+this.width-i)return!0;let n=e-(this.x+i),r=t-(this.y+i);const o=i*i;if(n*n+r*r<=o||(n=e-(this.x+this.width-i),n*n+r*r<=o)||(r=t-(this.y+this.height-i),n*n+r*r<=o)||(n=e-(this.x+i),n*n+r*r<=o))return!0}return!1}strokeContains(e,t,i,n=.5){const{x:r,y:o,width:a,height:l,radius:h}=this,c=i*(1-n),u=i-c,d=r+h,_=o+h,f=a-h*2,g=l-h*2,p=r+a,m=o+l;return(e>=r-c&&e<=r+u||e>=p-u&&e<=p+c)&&t>=_&&t<=_+g||(t>=o-c&&t<=o+u||t>=m-u&&t<=m+c)&&e>=d&&e<=d+f?!0:e<d&&t<_&&xn(e,t,d,_,h,u,c)||e>p-h&&t<_&&xn(e,t,p-h,_,h,u,c)||e>p-h&&t>m-h&&xn(e,t,p-h,m-h,h,u,c)||e<d&&t>m-h&&xn(e,t,d,m-h,h,u,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const Rm=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
26`);function Fm(s){let e="";for(let t=0;t<s;++t)t>0&&(e+=`
27else `),t<s-1&&(e+=`if(test == ${t}.0){}`);return e}function Bm(s,e){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const t=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const i=Rm.replace(/%forloop%/gi,Fm(s));if(e.shaderSource(t,i),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS))s=s/2|0;else break}}finally{e.deleteShader(t)}return s}let Vi=null;function Ru(){if(Vi)return Vi;const s=du();return Vi=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),Vi=Bm(Vi,s),s.getExtension("WEBGL_lose_context")?.loseContext(),Vi}const Fu={};function Lm(s,e){let t=2166136261;for(let i=0;i<e;i++)t^=s[i].uid,t=Math.imul(t,16777619),t>>>=0;return Fu[t]||$m(s,e,t)}let ro=0;function $m(s,e,t){const i={};let n=0;ro||(ro=Ru());for(let o=0;o<ro;o++){const a=o<e?s[o]:Y.EMPTY.source;i[n++]=a.source,i[n++]=a.style}const r=new En(i);return Fu[t]=r,r}class pl{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}function ml(s,e){const t=s.byteLength/8|0,i=new Float64Array(s,0,t);new Float64Array(e,0,t).set(i);const r=s.byteLength-t*8;if(r>0){const o=new Uint8Array(s,t*8,r);new Uint8Array(e,t*8,r).set(o)}}const Om={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Gm=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",
vendor: 65,999 bytes, lines 27-241
27s[s.NONE=5]="NONE",s))(Gm||{});function bl(s,e){return e.alphaMode==="no-premultiply-alpha"&&Om[s]||s}class Nm{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e<this.count;e++){const t=this.textures[e];this.textures[e]=null,this.ids[t.uid]=null}this.count=0}}class Dm{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Nm,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const Bu=[];let Ho=0;function yl(){return Ho>0?Bu[--Ho]:new Dm}function wl(s){Bu[Ho++]=s}let Ss=0;const Lu=class Rn{constructor(e={}){this.uid=pe("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],Rn.defaultOptions.maxTextures=Rn.defaultOptions.maxTextures??Ru(),e={...Rn.defaultOptions,...e};const{maxTextures:t,attributesInitialSize:i,indicesInitialSize:n}=e;this.attributeBuffer=new pl(i*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=t}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let e=0;e<this.batchIndex;e++)wl(this.batches[e]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(e){this._elements[this.elementSize++]=e,e._indexStart=this.indexSize,e._attributeStart=this.attributeSize,e._batcher=this,this.indexSize+=e.indexSize,this.attributeSize+=e.attributeSize*this.vertexSize}checkAndUpdateTexture(e,t){const i=e._batch.textures.ids[t._source.uid];return!i&&i!==0?!1:(e._textureId=i,e.texture=t,!0)}updateElement(e){this.dirty=!0;const t=this.attributeBuffer;e.packAsQuad?this.packQuadAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId):this.packAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId)}break(e){const t=this._elements;if(!t[this.elementStart])return;let i=yl(),n=i.textures;n.clear();const r=t[this.elementStart];let o=bl(r.blendMode,r.texture._source),a=r.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const l=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,c=this.indexBuffer;let u=this._batchIndexSize,d=this._batchIndexStart,_="startBatch";const f=this.maxTextures;for(let g=this.elementStart;g<this.elementSize;++g){const p=t[g];t[g]=null;const b=p.texture._source,y=bl(p.blendMode,b),w=o!==y||a!==p.topology;if(b._batchTick===Ss&&!w){p._textureId=b._textureBindLocation,u+=p.indexSize,p.packAsQuad?(this.packQuadAttributes(p,l,h,p._attributeStart,p._textureId),this.packQuadIndex(c,p._indexStart,p._attributeStart/this.vertexSize)):(this.packAttributes(p,l,h,p._attributeStart,p._textureId),this.packIndex(p,c,p._indexStart,p._attributeStart/this.vertexSize)),p._batch=i;continue}b._batchTick=Ss,(n.count>=f||w)&&(this._finishBatch(i,d,u-d,n,o,a,e,_),_="renderBatch",d=u,o=y,a=p.topology,i=yl(),n=i.textures,n.clear(),++Ss),p._textureId=b._textureBindLocation=n.count,n.ids[b.uid]=n.count,n.textures[n.count++]=b,p._batch=i,u+=p.indexSize,p.packAsQuad?(this.packQuadAttributes(p,l,h,p._attributeStart,p._textureId),this.packQuadIndex(c,p._indexStart,p._attributeStart/this.vertexSize)):(this.packAttributes(p,l,h,p._attributeStart,p._textureId),this.packIndex(p,c,p._indexStart,p._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(i,d,u-d,n,o,a,e,_),d=u,++Ss),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=u}_finishBatch(e,t,i,n,r,o,a,l){e.gpuBindGroup=null,e.bindGroup=null,e.action=l,e.batcher=this,e.textures=n,e.blendMode=r,e.topology=o,e.start=t,e.size=i,++Ss,this.batches[this.batchIndex++]=e,a.add(e)}finish(e){this.break(e)}ensureAttributeBuffer(e){e*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(e*4)}ensureIndexBuffer(e){e<=this.indexBuffer.length||this._resizeIndexBuffer(e)}_resizeAttributeBuffer(e){const t=Math.max(e,this.attributeBuffer.size*2),i=new pl(t);ml(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(e){const t=this.indexBuffer;let i=Math.max(e,t.length*1.5);i+=i%2;const n=i>65535?new Uint32Array(i):new Uint16Array(i);if(n.BYTES_PER_ELEMENT!==t.BYTES_PER_ELEMENT)for(let r=0;r<t.length;r++)n[r]=t[r];else ml(t.buffer,n.buffer);this.indexBuffer=n}packQuadIndex(e,t,i){e[t]=i+0,e[t+1]=i+1,e[t+2]=i+2,e[t+3]=i+0,e[t+4]=i+2,e[t+5]=i+3}packIndex(e,t,i,n){const r=e.indices,o=e.indexSize,a=e.indexOffset,l=e.attributeOffset;for(let h=0;h<o;h++)t[i++]=n+r[h+a]-l}destroy(){for(let e=0;e<this.batches.length;e++)wl(this.batches[e]);this.batches=null;for(let e=0;e<this._elements.length;e++)this._elements[e]._batch=null;this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}};Lu.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Um=Lu;var He=(s=>(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(He||{});class Ks extends kt{constructor(e){let{data:t,size:i}=e;const{usage:n,label:r,shrinkToFit:o}=e;super(),this.uid=pe("buffer"),this._resourceType="buffer",this._resourceId=pe("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,t instanceof Array&&(t=new Float32Array(t)),this._data=t,i??(i=t?.byteLength);const a=!!t;this.descriptor={size:i,usage:n,mappedAtCreation:a,label:r},this.shrinkToFit=o??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&He.STATIC)}set static(e){e?this.descriptor.usage|=He.STATIC:this.descriptor.usage&=~He.STATIC}setDataWithSize(e,t,i){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._data===e){i&&this.emit("update",this);return}const n=this._data;if(this._data=e,this._dataInt32=null,!n||n.length!==e.length){!this.shrinkToFit&&n&&e.byteLength<n.byteLength?i&&this.emit("update",this):(this.descriptor.size=e.byteLength,this._resourceId=pe("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(e){this._updateSize=e??this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function $u(s,e){if(!(s instanceof Ks)){let t=e?He.INDEX:He.VERTEX;s instanceof Array&&(e?(s=new Uint32Array(s),t=He.INDEX|He.COPY_DST):(s=new Float32Array(s),t=He.VERTEX|He.COPY_DST)),s=new Ks({data:s,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:t})}return s}function Wm(s,e,t){const i=s.getAttribute(e);if(!i)return t.minX=0,t.minY=0,t.maxX=0,t.maxY=0,t;const n=i.buffer.data;let r=1/0,o=1/0,a=-1/0,l=-1/0;const h=n.BYTES_PER_ELEMENT,c=(i.offset||0)/h,u=(i.stride||2*4)/h;for(let d=c;d<n.length;d+=u){const _=n[d],f=n[d+1];_>a&&(a=_),f>l&&(l=f),_<r&&(r=_),f<o&&(o=f)}return t.minX=r,t.minY=o,t.maxX=a,t.maxY=l,t}function Hm(s){return(s instanceof Ks||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=$u(s.buffer,!1),s}class qm extends kt{constructor(e={}){super(),this.uid=pe("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new wt,this._boundsDirty=!0;const{attributes:t,indexBuffer:i,topology:n}=e;if(this.buffers=[],this.attributes={},t)for(const r in t)this.addAttribute(r,t[r]);this.instanceCount=e.instanceCount??1,i&&this.addIndex(i),this.topology=n||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(e){return this.attributes[e]}getIndex(){return this.indexBuffer}getBuffer(e){return this.getAttribute(e).buffer}getSize(){for(const e in this.attributes){const t=this.attributes[e];return t.buffer.data.length/(t.stride/4||t.size)}return 0}addAttribute(e,t){const i=Hm(t);this.buffers.indexOf(i.buffer)===-1&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[e]=i}addIndex(e){this.indexBuffer=$u(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Wm(this,"aPosition",this._bounds)):this._bounds}destroy(e=!1){this.emit("destroy",this),this.removeAllListeners(),e&&this.buffers.forEach(t=>t.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Vm=new Float32Array(1),Xm=new Uint32Array(1);class Ym extends qm{constructor(){const t=new Ks({data:Vm,label:"attribute-batch-buffer",usage:He.VERTEX|He.COPY_DST,shrinkToFit:!1}),i=new Ks({data:Xm,label:"index-batch-buffer",usage:He.INDEX|He.COPY_DST,shrinkToFit:!1}),n=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:n,offset:0},aUV:{buffer:t,format:"float32x2",stride:n,offset:2*4},aColor:{buffer:t,format:"unorm8x4",stride:n,offset:4*4},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:n,offset:5*4}},indexBuffer:i})}}function xl(s,e,t){if(s)for(const i in s){const n=i.toLocaleLowerCase(),r=e[n];if(r){let o=s[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),t&&r.push(`//----${t}----//`),r.push(o)}else me(`${i} placement hook does not exist in shader`)}}const jm=/\{\{(.*?)\}\}/g;function vl(s){const e={};return(s.match(jm)?.map(i=>i.replace(/[{()}]/g,""))??[]).forEach(i=>{e[i]=[]}),e}function kl(s,e){let t;const i=/@in\s+([^;]+);/g;for(;(t=i.exec(s))!==null;)e.push(t[1])}function Al(s,e,t=!1){const i=[];kl(e,i),s.forEach(a=>{a.header&&kl(a.header,i)});const n=i;t&&n.sort();const r=n.map((a,l)=>`       @location(${l}) ${a},`).join(`
28`);let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
29${r}
30`),o}function Sl(s,e){let t;const i=/@out\s+([^;]+);/g;for(;(t=i.exec(s))!==null;)e.push(t[1])}function Km(s){const t=/\b(\w+)\s*:/g.exec(s);return t?t[1]:""}function Zm(s){const e=/@.*?\s+/g;return s.replace(e,"")}function Qm(s,e){const t=[];Sl(e,t),s.forEach(l=>{l.header&&Sl(l.header,t)});let i=0;const n=t.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${i++}) ${l}`).join(`,
31`),r=t.sort().map(l=>`       var ${Zm(l)};`).join(`
32`),o=`return VSOutput(
33            ${t.sort().map(l=>` ${Km(l)}`).join(`,
34`)});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
35${n}
36`),a=a.replace("{{start}}",`
37${r}
38`),a=a.replace("{{return}}",`
39${o}
40`),a}function Cl(s,e){let t=s;for(const i in e){const n=e[i];n.join(`
41`).length?t=t.replace(`{{${i}}}`,`//-----${i} START-----//
42${n.join(`
43`)}
44//----${i} FINISH----//`):t=t.replace(`{{${i}}}`,"")}return t}const ei=Object.create(null),oo=new Map;let Jm=0;function e1({template:s,bits:e}){const t=Ou(s,e);if(ei[t])return ei[t];const{vertex:i,fragment:n}=i1(s,e);return ei[t]=Gu(i,n,e),ei[t]}function t1({template:s,bits:e}){const t=Ou(s,e);return ei[t]||(ei[t]=Gu(s.vertex,s.fragment,e)),ei[t]}function i1(s,e){const t=e.map(o=>o.vertex).filter(o=>!!o),i=e.map(o=>o.fragment).filter(o=>!!o);let n=Al(t,s.vertex,!0);n=Qm(t,n);const r=Al(i,s.fragment,!0);return{vertex:n,fragment:r}}function Ou(s,e){return e.map(t=>(oo.has(t)||oo.set(t,Jm++),oo.get(t))).sort((t,i)=>t-i).join("-")+s.vertex+s.fragment}function Gu(s,e,t){const i=vl(s),n=vl(e);return t.forEach(r=>{xl(r.vertex,i,r.name),xl(r.fragment,n,r.name)}),{vertex:Cl(s,i),fragment:Cl(e,n)}}const s1=`
45    @in aPosition: vec2<f32>;
46    @in aUV: vec2<f32>;
47
48    @out @builtin(position) vPosition: vec4<f32>;
49    @out vUV : vec2<f32>;
50    @out vColor : vec4<f32>;
51
52    {{header}}
53
54    struct VSOutput {
55        {{struct}}
56    };
57
58    @vertex
59    fn main( {{in}} ) -> VSOutput {
60
61        var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
62        var modelMatrix = mat3x3<f32>(
63            1.0, 0.0, 0.0,
64            0.0, 1.0, 0.0,
65            0.0, 0.0, 1.0
66          );
67        var position = aPosition;
68        var uv = aUV;
69
70        {{start}}
71        
72        vColor = vec4<f32>(1., 1., 1., 1.);
73
74        {{main}}
75
76        vUV = uv;
77
78        var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
79
80        vPosition =  vec4<f32>((modelViewProjectionMatrix *  vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
81       
82        vColor *= globalUniforms.uWorldColorAlpha;
83
84        {{end}}
85
86        {{return}}
87    };
88`,n1=`
89    @in vUV : vec2<f32>;
90    @in vColor : vec4<f32>;
91   
92    {{header}}
93
94    @fragment
95    fn main(
96        {{in}}
97      ) -> @location(0) vec4<f32> {
98        
99        {{start}}
100
101        var outColor:vec4<f32>;
102      
103        {{main}}
104        
105        var finalColor:vec4<f32> = outColor * vColor;
106
107        {{end}}
108
109        return finalColor;
110      };
111`,r1=`
112    in vec2 aPosition;
113    in vec2 aUV;
114
115    out vec4 vColor;
116    out vec2 vUV;
117
118    {{header}}
119
120    void main(void){
121
122        mat3 worldTransformMatrix = uWorldTransformMatrix;
123        mat3 modelMatrix = mat3(
124            1.0, 0.0, 0.0,
125            0.0, 1.0, 0.0,
126            0.0, 0.0, 1.0
127          );
128        vec2 position = aPosition;
129        vec2 uv = aUV;
130        
131        {{start}}
132        
133        vColor = vec4(1.);
134        
135        {{main}}
136        
137        vUV = uv;
138        
139        mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
140
141        gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
142
143        vColor *= uWorldColorAlpha;
144
145        {{end}}
146    }
147`,o1=`
148   
149    in vec4 vColor;
150    in vec2 vUV;
151
152    out vec4 finalColor;
153
154    {{header}}
155
156    void main(void) {
157        
158        {{start}}
159
160        vec4 outColor;
161      
162        {{main}}
163        
164        finalColor = outColor * vColor;
165        
166        {{end}}
167    }
168`,a1={name:"global-uniforms-bit",vertex:{header:`
169        struct GlobalUniforms {
170            uProjectionMatrix:mat3x3<f32>,
171            uWorldTransformMatrix:mat3x3<f32>,
172            uWorldColorAlpha: vec4<f32>,
173            uResolution: vec2<f32>,
174        }
175
176        @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
177        `}},l1={name:"global-uniforms-bit",vertex:{header:`
178          uniform mat3 uProjectionMatrix;
179          uniform mat3 uWorldTransformMatrix;
180          uniform vec4 uWorldColorAlpha;
181          uniform vec2 uResolution;
182        `}};function h1({bits:s,name:e}){const t=e1({template:{fragment:n1,vertex:s1},bits:[a1,...s]});return li.from({name:e,vertex:{source:t.vertex,entryPoint:"main"},fragment:{source:t.fragment,entryPoint:"main"}})}function c1({bits:s,name:e}){return new ls({name:e,...t1({template:{vertex:r1,fragment:o1},bits:[l1,...s]})})}const u1={name:"color-bit",vertex:{header:`
183            @in aColor: vec4<f32>;
184        `,main:`
185            vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
186        `}},d1={name:"color-bit",vertex:{header:`
187            in vec4 aColor;
188        `,main:`
189            vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
190        `}},ao={};function _1(s){const e=[];if(s===1)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let t=0;for(let i=0;i<s;i++)e.push(`@group(1) @binding(${t++}) var textureSource${i+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${t++}) var textureSampler${i+1}: sampler;`)}return e.join(`
191`)}function f1(s){const e=[];if(s===1)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let t=0;t<s;t++)t===s-1?e.push("  default:{"):e.push(`  case ${t}:{`),e.push(`      outColor = textureSampleGrad(textureSource${t+1}, textureSampler${t+1}, vUV, uvDx, uvDy);`),e.push("      break;}");e.push("}")}return e.join(`
192`)}function g1(s){return ao[s]||(ao[s]={name:"texture-batch-bit",vertex:{header:`
193                @in aTextureIdAndRound: vec2<u32>;
194                @out @interpolate(flat) vTextureId : u32;
195            `,main:`
196                vTextureId = aTextureIdAndRound.y;
197            `,end:`
198                if(aTextureIdAndRound.x == 1)
199                {
200                    vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
201                }
202            `},fragment:{header:`
203                @in @interpolate(flat) vTextureId: u32;
204
205                ${_1(s)}
206            `,main:`
207                var uvDx = dpdx(vUV);
208                var uvDy = dpdy(vUV);
209
210                ${f1(s)}
211            `}}),ao[s]}const lo={};function p1(s){const e=[];for(let t=0;t<s;t++)t>0&&e.push("else"),t<s-1&&e.push(`if(vTextureId < ${t}.5)`),e.push("{"),e.push(`	outColor = texture(uTextures[${t}], vUV);`),e.push("}");return e.join(`
212`)}function m1(s){return lo[s]||(lo[s]={name:"texture-batch-bit",vertex:{header:`
213                in vec2 aTextureIdAndRound;
214                out float vTextureId;
215
216            `,main:`
217                vTextureId = aTextureIdAndRound.y;
218            `,end:`
219                if(aTextureIdAndRound.x == 1.)
220                {
221                    gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
222                }
223            `},fragment:{header:`
224                in float vTextureId;
225
226                uniform sampler2D uTextures[${s}];
227
228            `,main:`
229
230                ${p1(s)}
231            `}}),lo[s]}const b1={name:"round-pixels-bit",vertex:{header:`
232            fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32> 
233            {
234                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
235            }
236        `}},y1={name:"round-pixels-bit",vertex:{header:`   
237            vec2 roundPixels(vec2 position, vec2 targetSize)
238            {       
239                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
240            }
241        `}},Ml={};function w1(s){let e=Ml[s];if(e)return e;const t=new Int32Array(s);for(let i=0;i<s;i++)t[i]=i;return e=Ml[s]=new mu({uTextures:{value:t,type:"i32",size:s}},{isStatic:!0}),e}class x1 extends er{constructor(e){const t=c1({name:"batch",bits:[d1,m1(e),y1]}),i=h1({name:"batch",bits:[u1,g1(e),b1]});super({glProgram:t,gpuProgram:i,resources:{batchSamplers:w1(e)}})}}let Tl=null;const Nu=class Du extends Um{constructor(){super(...arguments),this.geometry=new Ym,this.shader=Tl||(Tl=new x1(this.maxTextures)),this.name=Du.extension.name,this.vertexSize=6}packAttributes(e,t,i,n,r){const o=r<<16|e.roundPixels&65535,a=e.transform,l=a.a,h=a.b,c=a.c,u=a.d,d=a.tx,_=a.ty,{positions:f,uvs:g}=e,p=e.color,m=e.attributeOffset,b=m+e.attributeSize;for(let y=m;y<b;y++){const w=y*2,A=f[w],k=f[w+1];t[n++]=l*A+c*k+d,t[n++]=u*k+h*A+_,t[n++]=g[w],t[n++]=g[w+1],i[n++]=p,i[n++]=o}}packQuadAttributes(e,t,i,n,r){const o=e.texture,a=e.transform,l=a.a,h=a.b,c=a.c,u=a.d,d=a.tx,_=a.ty,f=e.bounds,g=f.maxX,p=f.minX,m=f.maxY,b=f.minY,y=o.uvs,w=e.color,A=r<<16|e.roundPixels&65535;t[n+0]=l*p+c*b+d,t[n+1]=u*b+h*p+_,t[n+2]=y.x0,t[n+3]=y.y0,i[n+4]=w,i[n+5]=A,t[n+6]=l*g+c*b+d,t[n+7]=u*b+h*g+_,t[n+8]=y.x1,t[n+9]=y.y1,i[n+10]=w,i[n+11]=A,t[n+12]=l*g+c*m+d,t[n+13]=u*m+h*g+_,t[n+14]=y.x2,t[n+15]=y.y2,i[n+16]=w,i[n+17]=A,t[n+18]=l*p+c*m+d,t[n+19]=u*m+h*p+_,t[n+20]=y.x3,t[n+21]=y.y3,i[n+22]=w,i[n+23]=A}};Nu.extension={type:[$.Batcher],name:"default"};let v1=Nu;function k1(s,e,t,i,n,r,o,a=null){let l=0;t*=e,n*=r;const h=a.a,c=a.b,u=a.c,d=a.d,_=a.tx,f=a.ty;for(;l<o;){const g=s[t],p=s[t+1];i[n]=h*g+u*p+_,i[n+1]=c*g+d*p+f,n+=r,t+=e,l++}}function A1(s,e,t,i){let n=0;for(e*=t;n<i;)s[e]=0,s[e+1]=0,e+=t,n++}function Uu(s,e,t,i,n){const r=e.a,o=e.b,a=e.c,l=e.d,h=e.tx,c=e.ty;t||(t=0),i||(i=2),n||(n=s.length/i-t);let u=t*i;for(let d=0;d<n;d++){const _=s[u],f=s[u+1];s[u]=r*_+a*f+h,s[u+1]=o*_+l*f+c,u+=i}}const S1=new Z;class Wu{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,i=this.renderable;return i?Vc(t,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):t+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||S1}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}}const Zs={extension:{type:$.ShapeBuilder,name:"circle"},build(s,e){let t,i,n,r,o,a;if(s.type==="circle"){const w=s;t=w.x,i=w.y,o=a=w.radius,n=r=0}else if(s.type==="ellipse"){const w=s;t=w.x,i=w.y,o=w.halfWidth,a=w.halfHeight,n=r=0}else{const w=s,A=w.width/2,k=w.height/2;t=w.x+A,i=w.y+k,o=a=Math.max(0,Math.min(w.radius,Math.min(A,k))),n=A-o,r=k-a}if(!(o>=0&&a>=0&&n>=0&&r>=0))return e;const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(n?4:0)+(r?4:0);if(h===0)return e;if(l===0)return e[0]=e[6]=t+n,e[1]=e[3]=i+r,e[2]=e[4]=t-n,e[5]=e[7]=i-r,e;let c=0,u=l*4+(n?2:0)+2,d=u,_=h,f=n+o,g=r,p=t+f,m=t-f,b=i+g;if(e[c++]=p,e[c++]=b,e[--u]=b,e[--u]=m,r){const w=i-g;e[d++]=m,e[d++]=w,e[--_]=w,e[--_]=p}for(let w=1;w<l;w++){const A=Math.PI/2*(w/l),k=n+Math.cos(A)*o,x=r+Math.sin(A)*a,C=t+k,S=t-k,T=i+x,E=i-x;e[c++]=C,e[c++]=T,e[--u]=T,e[--u]=S,e[d++]=S,e[d++]=E,e[--_]=E,e[--_]=C}f=n,g=r+a,p=t+f,m=t-f,b=i+g;const y=i-g;return e[c++]=p,e[c++]=b,e[--_]=y,e[--_]=p,n&&(e[c++]=m,e[c++]=b,e[--_]=y,e[--_]=m),e},triangulate(s,e,t,i,n,r){if(s.length===0)return;let o=0,a=0;for(let c=0;c<s.length;c+=2)o+=s[c],a+=s[c+1];o/=s.length/2,a/=s.length/2;let l=i;e[l*t]=o,e[l*t+1]=a;const h=l++;for(let c=0;c<s.length;c+=2)e[l*t]=s[c],e[l*t+1]=s[c+1],c>0&&(n[r++]=l,n[r++]=h,n[r++]=l-1),l++;n[r++]=h+1,n[r++]=h,n[r++]=l-1}},C1={...Zs,extension:{...Zs.extension,name:"ellipse"}},M1={...Zs,extension:{...Zs.extension,name:"roundedRectangle"}},Hu=1e-4,Pl=1e-4;function T1(s){const e=s.length;if(e<6)return 1;let t=0;for(let i=0,n=s[e-2],r=s[e-1];i<e;i+=2){const o=s[i],a=s[i+1];t+=(o-n)*(a+r),n=o,r=a}return t<0?-1:1}function zl(s,e,t,i,n,r,o,a){const l=s-t*n,h=e-i*n,c=s+t*r,u=e+i*r;let d,_;o?(d=i,_=-t):(d=-i,_=t);const f=l+d,g=h+_,p=c+d,m=u+_;return a.push(f,g),a.push(p,m),2}function gi(s,e,t,i,n,r,o,a){const l=t-s,h=i-e;let c=Math.atan2(l,h),u=Math.atan2(n-s,r-e);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const _=u-c,f=Math.abs(_),g=Math.sqrt(l*l+h*h),p=(15*f*Math.sqrt(g)/Math.PI>>0)+1,m=_/p;if(d+=m,a){o.push(s,e),o.push(t,i);for(let b=1,y=d;b<p;b++,y+=m)o.push(s,e),o.push(s+Math.sin(y)*g,e+Math.cos(y)*g);o.push(s,e),o.push(n,r)}else{o.push(t,i),o.push(s,e);for(let b=1,y=d;b<p;b++,y+=m)o.push(s+Math.sin(y)*g,e+Math.cos(y)*g),o.push(s,e);o.push(n,r),o.push(s,e)}return p*2}function P1(s,e,t,i,n,r){const o=Hu;if(s.length===0)return;const a=e;let l=a.alignment;if(e.alignment!==.5){let W=T1(s);l=(l-.5)*W+.5}const h=new V(s[0],s[1]),c=new V(s[s.length-2],s[s.length-1]),u=i,d=Math.abs(h.x-c.x)<o&&Math.abs(h.y-c.y)<o;if(u){s=s.slice(),d&&(s.pop(),s.pop(),c.set(s[s.length-2],s[s.length-1]));const W=(h.x+c.x)*.5,ee=(c.y+h.y)*.5;s.unshift(W,ee),s.push(W,ee)}const _=n,f=s.length/2;let g=s.length;const p=_.length/2,m=a.width/2,b=m*m,y=a.miterLimit*a.miterLimit;let w=s[0],A=s[1],k=s[2],x=s[3],C=0,S=0,T=-(A-x),E=w-k,D=0,X=0,F=Math.sqrt(T*T+E*E);T/=F,E/=F,T*=m,E*=m;const q=l,R=(1-q)*2,B=q*2;u||(a.cap==="round"?g+=gi(w-T*(R-B)*.5,A-E*(R-B)*.5,w-T*R,A-E*R,w+T*B,A+E*B,_,!0)+2:a.cap==="square"&&(g+=zl(w,A,T,E,R,B,!0,_))),_.push(w-T*R,A-E*R),_.push(w+T*B,A+E*B);for(let W=1;W<f-1;++W){w=s[(W-1)*2],A=s[(W-1)*2+1],k=s[W*2],x=s[W*2+1],C=s[(W+1)*2],S=s[(W+1)*2+1],T=-(A-x),E=w-k,F=Math.sqrt(T*T+E*E),T/=F,E/=F,T*=m,E*=m,D=-(x-S),X=k-C,F=Math.sqrt(D*D+X*X),D/=F,X/=F,D*=m,X*=m;const ee=k-w,I=A-x,G=k-C,ye=S-x,we=ee*G+I*ye,xe=I*G-ye*ee,ge=xe<0;if(Math.abs(xe)<.001*Math.abs(we)){_.push(k-T*R,x-E*R),_.push(k+T*B,x+E*B),we>=0&&(a.join==="round"?g+=gi(k,x,k-T*R,x-E*R,k-D*R,x-X*R,_,!1)+4:g+=2,_.push(k-D*B,x-X*B),_.push(k+D*R,x+X*R));continue}const ve=(-T+w)*(-E+x)-(-T+k)*(-E+A),ke=(-D+C)*(-X+x)-(-D+k)*(-X+S),Ae=(ee*ke-G*ve)/xe,Pe=(ye*ve-I*ke)/xe,tt=(Ae-k)*(Ae-k)+(Pe-x)*(Pe-x),P=k+(Ae-k)*R,le=x+(Pe-x)*R,z=k-(Ae-k)*B,he=x-(Pe-x)*B,it=Math.min(ee*ee+I*I,G*G+ye*ye),Re=ge?R:B,ie=it+Re*Re*b;tt<=ie?a.join==="bevel"||tt/b>y?(ge?(_.push(P,le),_.push(k+T*B,x+E*B),_.push(P,le),_.push(k+D*B,x+X*B)):(_.push(k-T*R,x-E*R),_.push(z,he),_.push(k-D*R,x-X*R),_.push(z,he)),g+=2):a.join==="round"?ge?(_.push(P,le),_.push(k+T*B,x+E*B),g+=gi(k,x,k+T*B,x+E*B,k+D*B,x+X*B,_,!0)+4,_.push(P,le),_.push(k+D*B,x+X*B)):(_.push(k-T*R,x-E*R),_.push(z,he),g+=gi(k,x,k-T*R,x-E*R,k-D*R,x-X*R,_,!1)+4,_.push(k-D*R,x-X*R),_.push(z,he)):(_.push(P,le),_.push(z,he)):(_.push(k-T*R,x-E*R),_.push(k+T*B,x+E*B),a.join==="round"?ge?g+=gi(k,x,k+T*B,x+E*B,k+D*B,x+X*B,_,!0)+2:g+=gi(k,x,k-T*R,x-E*R,k-D*R,x-X*R,_,!1)+2:a.join==="miter"&&tt/b<=y&&(ge?(_.push(z,he),_.push(z,he)):(_.push(P,le),_.push(P,le)),g+=2),_.push(k-D*R,x-X*R),_.push(k+D*B,x+X*B),g+=2)}w=s[(f-2)*2],A=s[(f-2)*2+1],k=s[(f-1)*2],x=s[(f-1)*2+1],T=-(A-x),E=w-k,F=Math.sqrt(T*T+E*E),T/=F,E/=F,T*=m,E*=m,_.push(k-T*R,x-E*R),_.push(k+T*B,x+E*B),u||(a.cap==="round"?g+=gi(k-T*(R-B)*.5,x-E*(R-B)*.5,k-T*R,x-E*R,k+T*B,x+E*B,_,!1)+2:a.cap==="square"&&(g+=zl(k,x,T,E,R,B,!1,_)));const ze=Pl*Pl;for(let W=p;W<g+p-2;++W)w=_[W*2],A=_[W*2+1],k=_[(W+1)*2],x=_[(W+1)*2+1],C=_[(W+2)*2],S=_[(W+2)*2+1],!(Math.abs(w*(x-S)+k*(S-A)+C*(A-x))<ze)&&r.push(W,W+1,W+2)}function z1(s,e,t,i){const n=Hu;if(s.length===0)return;const r=s[0],o=s[1],a=s[s.length-2],l=s[s.length-1],h=e||Math.abs(r-a)<n&&Math.abs(o-l)<n,c=t,u=s.length/2,d=c.length/2;for(let _=0;_<u;_++)c.push(s[_*2]),c.push(s[_*2+1]);for(let _=0;_<u-1;_++)i.push(d+_,d+_+1);h&&i.push(d+u-1,d)}function qu(s,e,t,i,n,r,o){const a=bm(s,e,2);if(!a)return;for(let h=0;h<a.length;h+=3)r[o++]=a[h]+n,r[o++]=a[h+1]+n,r[o++]=a[h+2]+n;let l=n*i;for(let h=0;h<s.length;h+=2)t[l]=s[h],t[l+1]=s[h+1],l+=i}const I1=[],E1={extension:{type:$.ShapeBuilder,name:"polygon"},build(s,e){for(let t=0;t<s.points.length;t++)e[t]=s.points[t];return e},triangulate(s,e,t,i,n,r){qu(s,I1,e,t,i,n,r)}},R1={extension:{type:$.ShapeBuilder,name:"rectangle"},build(s,e){const t=s,i=t.x,n=t.y,r=t.width,o=t.height;return r>=0&&o>=0&&(e[0]=i,e[1]=n,e[2]=i+r,e[3]=n,e[4]=i+r,e[5]=n+o,e[6]=i,e[7]=n+o),e},triangulate(s,e,t,i,n,r){let o=0;i*=t,e[i+o]=s[0],e[i+o+1]=s[1],o+=t,e[i+o]=s[2],e[i+o+1]=s[3],o+=t,e[i+o]=s[6],e[i+o+1]=s[7],o+=t,e[i+o]=s[4],e[i+o+1]=s[5],o+=t;const a=i/t;n[r++]=a,n[r++]=a+1,n[r++]=a+2,n[r++]=a+1,n[r++]=a+3,n[r++]=a+2}},F1={extension:{type:$.ShapeBuilder,name:"triangle"},build(s,e){return e[0]=s.x,e[1]=s.y,e[2]=s.x2,e[3]=s.y2,e[4]=s.x3,e[5]=s.y3,e},triangulate(s,e,t,i,n,r){let o=0;i*=t,e[i+o]=s[0],e[i+o+1]=s[1],o+=t,e[i+o]=s[2],e[i+o+1]=s[3],o+=t,e[i+o]=s[4],e[i+o+1]=s[5];const a=i/t;n[r++]=a,n[r++]=a+1,n[r++]=a+2}},nr={};Oe.handleByMap($.ShapeBuilder,nr);Oe.add(R1,E1,F1,Zs,C1,M1);const B1=new se;function L1(s,e){const{geometryData:t,batches:i}=e;i.length=0,t.indices.length=0,t.vertices.length=0,t.uvs.length=0;for(let n=0;n<s.instructions.length;n++){const r=s.instructions[n];if(r.action==="texture")$1(r.data,i,t);else if(r.action==="fill"||r.action==="stroke"){const o=r.action==="stroke",a=r.data.path.shapePath,l=r.data.style,h=r.data.hole;o&&h&&Il(h.shapePath,l,null,!0,i,t),Il(a,l,h,o,i,t)}}}function $1(s,e,t){const{vertices:i,uvs:n,indices:r}=t,o=r.length,a=i.length/2,l=[],h=nr.rectangle,c=B1,u=s.image;c.x=s.dx,c.y=s.dy,c.width=s.dw,c.height=s.dh;const d=s.transform;h.build(c,l),d&&Uu(l,d),h.triangulate(l,i,2,a,r,o);const _=u.uvs;n.push(_.x0,_.y0,_.x1,_.y1,_.x3,_.y3,_.x2,_.y2);const f=Wt.get(Wu);f.indexOffset=o,f.indexSize=r.length-o,f.attributeOffset=a,f.attributeSize=i.length/2-a,f.baseColor=s.style,f.alpha=s.alpha,f.texture=u,f.geometryData=t,e.push(f)}function Il(s,e,t,i,n,r){const{vertices:o,uvs:a,indices:l}=r,h=s.shapePrimitives.length-1;s.shapePrimitives.forEach(({shape:c,transform:u},d)=>{const _=l.length,f=o.length/2,g=[],p=nr[c.type];let m="triangle-list";if(p.build(c,g),u&&Uu(g,u),i){const A=c.closePath??!0,k=e;k.pixelLine?(z1(g,A,o,l),m="line-list"):P1(g,k,!1,A,o,l)}else if(t&&h===d){h!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const A=[],k=g.slice();O1(t.shapePath).forEach(C=>{A.push(k.length/2),k.push(...C)}),qu(k,A,o,2,f,l,_)}else p.triangulate(g,o,2,f,l,_);const b=a.length/2,y=e.texture;if(y!==Y.WHITE){const A=e.matrix;A&&(u&&A.append(u.clone().invert()),k1(o,2,f,a,b,2,o.length/2-f,A))}else A1(a,b,2,o.length/2-f);const w=Wt.get(Wu);w.indexOffset=_,w.indexSize=l.length-_,w.attributeOffset=f,w.attributeSize=o.length/2-f,w.baseColor=e.color,w.alpha=e.alpha,w.texture=y,w.geometryData=r,w.topology=m,n.push(w)})}function O1(s){if(!s)return[];const e=s.shapePrimitives,t=[];for(let i=0;i<e.length;i++){const n=e[i].shape,r=[];nr[n.type].build(n,r),t.push(r)}return t}class G1{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class N1{constructor(){this.batcher=new v1,this.instructions=new Kc}init(){this.instructions.reset()}get geometry(){return K(Ng,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const ma=class qo{constructor(e){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),e.renderableGC.addManagedHash(this,"_gpuContextHash"),e.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(e){qo.defaultOptions.bezierSmoothness=e?.bezierSmoothness??qo.defaultOptions.bezierSmoothness}getContextRenderData(e){return this._graphicsDataContextHash[e.uid]||this._initContextRenderData(e)}updateGpuContext(e){let t=this._gpuContextHash[e.uid]||this._initContext(e);if(e.dirty){t?this._cleanGraphicsContextData(e):t=this._initContext(e),L1(e,t);const i=e.batchMode;e.customShader||i==="no-batch"?t.isBatchable=!1:i==="auto"&&(t.isBatchable=t.geometryData.vertices.length<400),e.dirty=!1}return t}getGpuContext(e){return this._gpuContextHash[e.uid]||this._initContext(e)}_initContextRenderData(e){const t=Wt.get(N1),{batches:i,geometryData:n}=this._gpuContextHash[e.uid],r=n.vertices.length,o=n.indices.length;for(let c=0;c<i.length;c++)i[c].applyTransform=!1;const a=t.batcher;a.ensureAttributeBuffer(r),a.ensureIndexBuffer(o),a.begin();for(let c=0;c<i.length;c++){const u=i[c];a.add(u)}a.finish(t.instructions);const l=a.geometry;l.indexBuffer.setDataWithSize(a.indexBuffer,a.indexSize,!0),l.buffers[0].setDataWithSize(a.attributeBuffer.float32View,a.attributeSize,!0);const h=a.batches;for(let c=0;c<h.length;c++){const u=h[c];u.bindGroup=Lm(u.textures.textures,u.textures.count)}return this._graphicsDataContextHash[e.uid]=t,t}_initContext(e){const t=new G1;return t.context=e,this._gpuContextHash[e.uid]=t,e.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[e.uid]}onGraphicsContextDestroy(e){this._cleanGraphicsContextData(e),e.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[e.uid]=null}_cleanGraphicsContextData(e){const t=this._gpuContextHash[e.uid];t.isBatchable||this._graphicsDataContextHash[e.uid]&&(Wt.return(this.getContextRenderData(e)),this._graphicsDataContextHash[e.uid]=null),t.batches&&t.batches.forEach(i=>{Wt.return(i)})}destroy(){for(const e in this._gpuContextHash)this._gpuContextHash[e]&&this.onGraphicsContextDestroy(this._gpuContextHash[e].context)}};ma.extension={type:[$.WebGLSystem,$.WebGPUSystem,$.CanvasSystem],name:"graphicsContext"};ma.defaultOptions={bezierSmoothness:.5};let Vu=ma;const D1=8,vn=11920929e-14,U1=1;function Xu(s,e,t,i,n,r,o,a,l,h){const u=Math.min(.99,Math.max(0,h??Vu.defaultOptions.bezierSmoothness));let d=(U1-u)/1;return d*=d,W1(e,t,i,n,r,o,a,l,s,d),s}function W1(s,e,t,i,n,r,o,a,l,h){Vo(s,e,t,i,n,r,o,a,l,h,0),l.push(o,a)}function Vo(s,e,t,i,n,r,o,a,l,h,c){if(c>D1)return;const u=(s+t)/2,d=(e+i)/2,_=(t+n)/2,f=(i+r)/2,g=(n+o)/2,p=(r+a)/2,m=(u+_)/2,b=(d+f)/2,y=(_+g)/2,w=(f+p)/2,A=(m+y)/2,k=(b+w)/2;if(c>0){let x=o-s,C=a-e;const S=Math.abs((t-o)*C-(i-a)*x),T=Math.abs((n-o)*C-(r-a)*x);if(S>vn&&T>vn){if((S+T)*(S+T)<=h*(x*x+C*C)){l.push(A,k);return}}else if(S>vn){if(S*S<=h*(x*x+C*C)){l.push(A,k);return}}else if(T>vn){if(T*T<=h*(x*x+C*C)){l.push(A,k);return}}else if(x=A-(s+o)/2,C=k-(e+a)/2,x*x+C*C<=h){l.push(A,k);return}}Vo(s,e,u,d,m,b,A,k,l,h,c+1),Vo(A,k,y,w,g,p,o,a,l,h,c+1)}const H1=8,q1=11920929e-14,V1=1;function X1(s,e,t,i,n,r,o,a){const h=Math.min(.99,Math.max(0,a??Vu.defaultOptions.bezierSmoothness));let c=(V1-h)/1;return c*=c,Y1(e,t,i,n,r,o,s,c),s}function Y1(s,e,t,i,n,r,o,a){Xo(o,s,e,t,i,n,r,a,0),o.push(n,r)}function Xo(s,e,t,i,n,r,o,a,l){if(l>H1)return;const h=(e+i)/2,c=(t+n)/2,u=(i+r)/2,d=(n+o)/2,_=(h+u)/2,f=(c+d)/2;let g=r-e,p=o-t;const m=Math.abs((i-r)*p-(n-o)*g);if(m>q1){if(m*m<=a*(g*g+p*p)){s.push(_,f);return}}else if(g=_-(e+r)/2,p=f-(t+o)/2,g*g+p*p<=a){s.push(_,f);return}Xo(s,e,t,h,c,_,f,a,l+1),Xo(s,_,f,u,d,r,o,a,l+1)}function Yu(s,e,t,i,n,r,o,a){let l=Math.abs(n-r);(!o&&n>r||o&&r>n)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(i,1/3)*(l/Math.PI)))),a=Math.max(a,3);let h=l/a,c=n;h*=o?-1:1;for(let u=0;u<a+1;u++){const d=Math.cos(c),_=Math.sin(c),f=e+d*i,g=t+_*i;s.push(f,g),c+=h}}function j1(s,e,t,i,n,r){const o=s[s.length-2],l=s[s.length-1]-t,h=o-e,c=n-t,u=i-e,d=Math.abs(l*u-h*c);if(d<1e-8||r===0){(s[s.length-2]!==e||s[s.length-1]!==t)&&s.push(e,t);return}const _=l*l+h*h,f=c*c+u*u,g=l*c+h*u,p=r*Math.sqrt(_)/d,m=r*Math.sqrt(f)/d,b=p*g/_,y=m*g/f,w=p*u+m*h,A=p*c+m*l,k=h*(m+b),x=l*(m+b),C=u*(p+y),S=c*(p+y),T=Math.atan2(x-A,k-w),E=Math.atan2(S-A,C-w);Yu(s,w+e,A+t,r,T,E,h*c>u*l)}const Ds=Math.PI*2,ho={centerX:0,centerY:0,ang1:0,ang2:0},co=({x:s,y:e},t,i,n,r,o,a,l)=>{s*=t,e*=i;const h=n*s-r*e,c=r*s+n*e;return l.x=h+o,l.y=c+a,l};function K1(s,e){const t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),i=e===1.5707963267948966?.551915024494:t,n=Math.cos(s),r=Math.sin(s),o=Math.cos(s+e),a=Math.sin(s+e);return[{x:n-r*i,y:r+n*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const El=(s,e,t,i)=>{const n=s*i-e*t<0?-1:1;let r=s*t+e*i;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},Z1=(s,e,t,i,n,r,o,a,l,h,c,u,d)=>{const _=Math.pow(n,2),f=Math.pow(r,2),g=Math.pow(c,2),p=Math.pow(u,2);let m=_*f-_*p-f*g;m<0&&(m=0),m/=_*p+f*g,m=Math.sqrt(m)*(o===a?-1:1);const b=m*n/r*u,y=m*-r/n*c,w=h*b-l*y+(s+t)/2,A=l*b+h*y+(e+i)/2,k=(c-b)/n,x=(u-y)/r,C=(-c-b)/n,S=(-u-y)/r,T=El(1,0,k,x);let E=El(k,x,C,S);a===0&&E>0&&(E-=Ds),a===1&&E<0&&(E+=Ds),d.centerX=w,d.centerY=A,d.ang1=T,d.ang2=E};function Q1(s,e,t,i,n,r,o,a=0,l=0,h=0){if(r===0||o===0)return;const c=Math.sin(a*Ds/360),u=Math.cos(a*Ds/360),d=u*(e-i)/2+c*(t-n)/2,_=-c*(e-i)/2+u*(t-n)/2;if(d===0&&_===0)return;r=Math.abs(r),o=Math.abs(o);const f=Math.pow(d,2)/Math.pow(r,2)+Math.pow(_,2)/Math.pow(o,2);f>1&&(r*=Math.sqrt(f),o*=Math.sqrt(f)),Z1(e,t,i,n,r,o,l,h,c,u,d,_,ho);let{ang1:g,ang2:p}=ho;const{centerX:m,centerY:b}=ho;let y=Math.abs(p)/(Ds/4);Math.abs(1-y)<1e-7&&(y=1);const w=Math.max(Math.ceil(y),1);p/=w;let A=s[s.length-2],k=s[s.length-1];const x={x:0,y:0};for(let C=0;C<w;C++){const S=K1(g,p),{x:T,y:E}=co(S[0],r,o,u,c,m,b,x),{x:D,y:X}=co(S[1],r,o,u,c,m,b,x),{x:F,y:q}=co(S[2],r,o,u,c,m,b,x);Xu(s,A,k,T,E,D,X,F,q),A=F,k=q,g+=p}}function J1(s,e,t){const i=(o,a)=>{const l=a.x-o.x,h=a.y-o.y,c=Math.sqrt(l*l+h*h),u=l/c,d=h/c;return{len:c,nx:u,ny:d}},n=(o,a)=>{o===0?s.moveTo(a.x,a.y):s.lineTo(a.x,a.y)};let r=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],l=a.radius??t;if(l<=0){n(o,a),r=a;continue}const h=e[(o+1)%e.length],c=i(a,r),u=i(a,h);if(c.len<1e-4||u.len<1e-4){n(o,a),r=a;continue}let d=Math.asin(c.nx*u.ny-c.ny*u.nx),_=1,f=!1;c.nx*u.nx-c.ny*-u.ny<0?d<0?d=Math.PI+d:(d=Math.PI-d,_=-1,f=!0):d>0&&(_=-1,f=!0);const g=d/2;let p,m=Math.abs(Math.cos(g)*l/Math.sin(g));m>Math.min(c.len/2,u.len/2)?(m=Math.min(c.len/2,u.len/2),p=Math.abs(m*Math.sin(g)/Math.cos(g))):p=l;const b=a.x+u.nx*m+-u.ny*p*_,y=a.y+u.ny*m+u.nx*p*_,w=Math.atan2(c.ny,c.nx)+Math.PI/2*_,A=Math.atan2(u.ny,u.nx)-Math.PI/2*_;o===0&&s.moveTo(b+Math.cos(w)*p,y+Math.sin(w)*p),s.arc(b,y,p,w,A,f),r=a}}function eb(s,e,t,i){const n=(a,l)=>Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2),r=(a,l,h)=>({x:a.x+(l.x-a.x)*h,y:a.y+(l.y-a.y)*h}),o=e.length;for(let a=0;a<o;a++){const l=e[(a+1)%o],h=l.radius??t;if(h<=0){a===0?s.moveTo(l.x,l.y):s.lineTo(l.x,l.y);continue}const c=e[a],u=e[(a+2)%o],d=n(c,l);let _;if(d<1e-4)_=l;else{const p=Math.min(d/2,h);_=r(l,c,p/d)}const f=n(u,l);let g;if(f<1e-4)g=l;else{const p=Math.min(f/2,h);g=r(l,u,p/f)}a===0?s.moveTo(_.x,_.y):s.lineTo(_.x,_.y),s.quadraticCurveTo(l.x,l.y,g.x,g.y,i)}}const tb=new se;class ib{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new wt,this._graphicsPath2D=e}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();const i=this._currentPoly.points,n=i[i.length-2],r=i[i.length-1];return(n!==e||r!==t)&&i.push(e,t),this}arc(e,t,i,n,r,o){this._ensurePoly(!1);const a=this._currentPoly.points;return Yu(a,e,t,i,n,r,o),this}arcTo(e,t,i,n,r){this._ensurePoly();const o=this._currentPoly.points;return j1(o,e,t,i,n,r),this}arcToSvg(e,t,i,n,r,o,a){const l=this._currentPoly.points;return Q1(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,e,t,i,n,r),this}bezierCurveTo(e,t,i,n,r,o,a){this._ensurePoly();const l=this._currentPoly;return Xu(this._currentPoly.points,l.lastX,l.lastY,e,t,i,n,r,o,a),this}quadraticCurveTo(e,t,i,n,r){this._ensurePoly();const o=this._currentPoly;return X1(this._currentPoly.points,o.lastX,o.lastY,e,t,i,n,r),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));for(let i=0;i<e.instructions.length;i++){const n=e.instructions[i];this[n.action](...n.data)}return this}finish(e=!1){this.endPoly(e)}rect(e,t,i,n,r){return this.drawShape(new se(e,t,i,n),r),this}circle(e,t,i,n){return this.drawShape(new fa(e,t,i),n),this}poly(e,t,i){const n=new Ns(e);return n.closePath=t,this.drawShape(n,i),this}regularPoly(e,t,i,n,r=0,o){n=Math.max(n|0,3);const a=-1*Math.PI/2+r,l=Math.PI*2/n,h=[];for(let c=0;c<n;c++){const u=a-c*l;h.push(e+i*Math.cos(u),t+i*Math.sin(u))}return this.poly(h,!0,o),this}roundPoly(e,t,i,n,r,o=0,a){if(n=Math.max(n|0,3),r<=0)return this.regularPoly(e,t,i,n,o);const l=i*Math.sin(Math.PI/n)-.001;r=Math.min(r,l);const h=-1*Math.PI/2+o,c=Math.PI*2/n,u=(n-2)*Math.PI/n/2;for(let d=0;d<n;d++){const _=d*c+h,f=e+i*Math.cos(_),g=t+i*Math.sin(_),p=_+Math.PI+u,m=_-Math.PI-u,b=f+r*Math.cos(p),y=g+r*Math.sin(p),w=f+r*Math.cos(m),A=g+r*Math.sin(m);d===0?this.moveTo(b,y):this.lineTo(b,y),this.quadraticCurveTo(f,g,w,A,a)}return this.closePath()}roundShape(e,t,i=!1,n){return e.length<3?this:(i?eb(this,e,t,n):J1(this,e,t),this.closePath())}filletRect(e,t,i,n,r){if(r===0)return this.rect(e,t,i,n);const o=Math.min(i,n)/2,a=Math.min(o,Math.max(-o,r)),l=e+i,h=t+n,c=a<0?-a:0,u=Math.abs(a);return this.moveTo(e,t+u).arcTo(e+c,t+c,e+u,t,u).lineTo(l-u,t).arcTo(l-c,t+c,l,t+u,u).lineTo(l,h-u).arcTo(l-c,h-c,e+i-u,h,u).lineTo(e+u,h).arcTo(e+c,h-c,e,h-u,u).closePath()}chamferRect(e,t,i,n,r,o){if(r<=0)return this.rect(e,t,i,n);const a=Math.min(r,Math.min(i,n)/2),l=e+i,h=t+n,c=[e+a,t,l-a,t,l,t+a,l,h-a,l-a,h,e+a,h,e,h-a,e,t+a];for(let u=c.length-1;u>=2;u-=2)c[u]===c[u-2]&&c[u-1]===c[u-3]&&c.splice(u-1,2);return this.poly(c,!0,o)}ellipse(e,t,i,n,r){return this.drawShape(new ga(e,t,i,n),r),this}roundRect(e,t,i,n,r,o){return this.drawShape(new pa(e,t,i,n,r),o),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let i=this._currentPoly;return i&&this.endPoly(),i=new Ns,i.points.push(e,t),this._currentPoly=i,this}endPoly(e=!1){const t=this._currentPoly;return t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null,this}_ensurePoly(e=!0){if(!this._currentPoly&&(this._currentPoly=new Ns,e)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let i=t.shape.x,n=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const r=t.transform,o=i;i=r.a*i+r.c*n+r.tx,n=r.b*o+r.d*n+r.ty}this._currentPoly.points.push(i,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){const i=e.instructions[t];this[i.action](...i.data)}this.finish()}get bounds(){const e=this._bounds;e.clear();const t=this.shapePrimitives;for(let i=0;i<t.length;i++){const n=t[i],r=n.shape.getBounds(tb);n.transform?e.addRect(r,n.transform):e.addRect(r)}return e}}class hs{constructor(e){this.instructions=[],this.uid=pe("graphicsPath"),this._dirty=!0,typeof e=="string"?Im(e,this):this.instructions=e?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new ib(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,i,n,r){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(V.shared);let l=0,h=0;if(!o||o.action!=="bezierCurveTo")l=a.x,h=a.y;else{l=o.data[2],h=o.data[3];const c=a.x,u=a.y;l=c+(c-l),h=u+(u-h)}return this.instructions.push({action:"bezierCurveTo",data:[l,h,e,t,i,n,r]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,i){const n=this.instructions[this.instructions.length-1],r=this.getLastPoint(V.shared);let o=0,a=0;if(!n||n.action!=="quadraticCurveTo")o=r.x,a=r.y;else{o=n.data[0],a=n.data[1];const l=r.x,h=r.y;o=l+(l-o),a=h+(h-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,e,t,i]}),this._dirty=!0,this}rect(e,t,i,n,r){return this.instructions.push({action:"rect",data:[e,t,i,n,r]}),this._dirty=!0,this}circle(e,t,i,n){return this.instructions.push({action:"circle",data:[e,t,i,n]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,t,i,n,r,o,a){r||(r=n/2);const l=-1*Math.PI/2+o,h=i*2,c=Math.PI*2/h,u=[];for(let d=0;d<h;d++){const _=d%2?r:n,f=d*c+l;u.push(e+_*Math.cos(f),t+_*Math.sin(f))}return this.poly(u,!0,a),this}clone(e=!1){const t=new hs;if(!e)t.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const n=this.instructions[i];t.instructions.push({action:n.action,data:n.data.slice()})}return t}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;const t=e.a,i=e.b,n=e.c,r=e.d,o=e.tx,a=e.ty;let l=0,h=0,c=0,u=0,d=0,_=0,f=0,g=0;for(let p=0;p<this.instructions.length;p++){const m=this.instructions[p],b=m.data;switch(m.action){case"moveTo":case"lineTo":l=b[0],h=b[1],b[0]=t*l+n*h+o,b[1]=i*l+r*h+a;break;case"bezierCurveTo":c=b[0],u=b[1],d=b[2],_=b[3],l=b[4],h=b[5],b[0]=t*c+n*u+o,b[1]=i*c+r*u+a,b[2]=t*d+n*_+o,b[3]=i*d+r*_+a,b[4]=t*l+n*h+o,b[5]=i*l+r*h+a;break;case"quadraticCurveTo":c=b[0],u=b[1],l=b[2],h=b[3],b[0]=t*c+n*u+o,b[1]=i*c+r*u+a,b[2]=t*l+n*h+o,b[3]=i*l+r*h+a;break;case"arcToSvg":l=b[5],h=b[6],f=b[0],g=b[1],b[0]=t*f+n*g,b[1]=i*f+r*g,b[5]=t*l+n*h+o,b[6]=i*l+r*h+a;break;case"circle":b[4]=Cs(b[3],e);break;case"rect":b[4]=Cs(b[4],e);break;case"ellipse":b[8]=Cs(b[8],e);break;case"roundRect":b[5]=Cs(b[5],e);break;case"addPath":b[0].transform(e);break;case"poly":b[2]=Cs(b[2],e);break;default:me("unknown transform action",m.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,i=this.instructions[t];if(!i)return e.x=0,e.y=0,e;for(;i.action==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;i=this.instructions[t]}switch(i.action){case"moveTo":case"lineTo":e.x=i.data[0],e.y=i.data[1];break;case"quadraticCurveTo":e.x=i.data[2],e.y=i.data[3];break;case"bezierCurveTo":e.x=i.data[4],e.y=i.data[5];break;case"arc":case"arcToSvg":e.x=i.data[5],e.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(e);break}return e}}function Cs(s,e){return s?s.prepend(e):e.clone()}function sb(s,e){if(typeof s=="string"){const i=document.createElement("div");i.innerHTML=s.trim(),s=i.querySelector("svg")}const t={context:e,path:new hs};return ju(s,t,null,null),e}function ju(s,e,t,i){const n=s.children,{fillStyle:r,strokeStyle:o}=nb(s);r&&t?t={...t,...r}:r&&(t=r),o&&i?i={...i,...o}:o&&(i=o),e.context.fillStyle=t,e.context.strokeStyle=i;let a,l,h,c,u,d,_,f,g,p,m,b,y,w,A,k,x;switch(s.nodeName.toLowerCase()){case"path":w=s.getAttribute("d"),A=new hs(w),e.context.path(A),t&&e.context.fill(),i&&e.context.stroke();break;case"circle":_=Ce(s,"cx",0),f=Ce(s,"cy",0),g=Ce(s,"r",0),e.context.ellipse(_,f,g,g),t&&e.context.fill(),i&&e.context.stroke();break;case"rect":a=Ce(s,"x",0),l=Ce(s,"y",0),k=Ce(s,"width",0),x=Ce(s,"height",0),p=Ce(s,"rx",0),m=Ce(s,"ry",0),p||m?e.context.roundRect(a,l,k,x,p||m):e.context.rect(a,l,k,x),t&&e.context.fill(),i&&e.context.stroke();break;case"ellipse":_=Ce(s,"cx",0),f=Ce(s,"cy",0),p=Ce(s,"rx",0),m=Ce(s,"ry",0),e.context.beginPath(),e.context.ellipse(_,f,p,m),t&&e.context.fill(),i&&e.context.stroke();break;case"line":h=Ce(s,"x1",0),c=Ce(s,"y1",0),u=Ce(s,"x2",0),d=Ce(s,"y2",0),e.context.beginPath(),e.context.moveTo(h,c),e.context.lineTo(u,d),i&&e.context.stroke();break;case"polygon":y=s.getAttribute("points"),b=y.match(/\d+/g).map(C=>parseInt(C,10)),e.context.poly(b,!0),t&&e.context.fill(),i&&e.context.stroke();break;case"polyline":y=s.getAttribute("points"),b=y.match(/\d+/g).map(C=>parseInt(C,10)),e.context.poly(b,!1),i&&e.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}for(let C=0;C<n.length;C++)ju(n[C],e,t,i)}function Ce(s,e,t){const i=s.getAttribute(e);return i?Number(i):t}function nb(s){const e=s.getAttribute("style"),t={},i={};let n=!1,r=!1;if(e){const o=e.split(";");for(let a=0;a<o.length;a++){const l=o[a],[h,c]=l.split(":");switch(h){case"stroke":c!=="none"&&(t.color=fe.shared.setValue(c).toNumber(),r=!0);break;case"stroke-width":t.width=Number(c);break;case"fill":c!=="none"&&(n=!0,i.color=fe.shared.setValue(c).toNumber());break;case"fill-opacity":i.alpha=Number(c);break;case"stroke-opacity":t.alpha=Number(c);break;case"opacity":i.alpha=Number(c),t.alpha=Number(c);break}}}else{const o=s.getAttribute("stroke");o&&o!=="none"&&(r=!0,t.color=fe.shared.setValue(o).toNumber(),t.width=Ce(s,"stroke-width",1));const a=s.getAttribute("fill");a&&a!=="none"&&(n=!0,i.color=fe.shared.setValue(a).toNumber())}return{strokeStyle:r?t:null,fillStyle:n?i:null}}function rb(s){return fe.isColorLike(s)}function Rl(s){return s instanceof sr}function Fl(s){return s instanceof js}function ob(s,e,t){const i=fe.shared.setValue(e??0);return s.color=i.toNumber(),s.alpha=i.alpha===1?t.alpha:i.alpha,s.texture=Y.WHITE,{...t,...s}}function Bl(s,e,t){return s.fill=e,s.color=16777215,s.texture=e.texture,s.matrix=e.transform,{...t,...s}}function Ll(s,e,t){return e.buildLinearGradient(),s.fill=e,s.color=16777215,s.texture=e.texture,s.matrix=e.transform,{...t,...s}}function ab(s,e){const t={...e,...s};if(t.texture){if(t.texture!==Y.WHITE){const r=t.matrix?.clone().invert()||new Z;r.translate(t.texture.frame.x,t.texture.frame.y),r.scale(1/t.texture.source.width,1/t.texture.source.height),t.matrix=r}const n=t.texture.source.style;n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update())}const i=fe.shared.setValue(t.color);return t.alpha*=i.alpha,t.color=i.toNumber(),t.matrix=t.matrix?t.matrix.clone():null,t}function ki(s,e){if(s==null)return null;const t={},i=s;return rb(s)?ob(t,s,e):Rl(s)?Bl(t,s,e):Fl(s)?Ll(t,s,e):i.fill&&Rl(i.fill)?Bl(i,i.fill,e):i.fill&&Fl(i.fill)?Ll(i,i.fill,e):ab(i,e)}function Wn(s,e){const{width:t,alignment:i,miterLimit:n,cap:r,join:o,pixelLine:a,...l}=e,h=ki(s,l);return h?{width:t,alignment:i,miterLimit:n,cap:r,join:o,pixelLine:a,...h}:null}const lb=new V,$l=new Z,ba=class Et extends kt{constructor(){super(...arguments),this.uid=pe("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new hs,this._transform=new Z,this._fillStyle={...Et.defaultFillStyle},this._strokeStyle={...Et.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new wt,this._boundsDirty=!0}clone(){const e=new Et;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=ki(e,Et.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=Wn(e,Et.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=ki(e,Et.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=ki(e,Et.defaultStrokeStyle),this}texture(e,t,i,n,r,o){return this.instructions.push({action:"texture",data:{image:e,dx:i||0,dy:n||0,dw:r||e.frame.width,dh:o||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t?fe.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new hs,this}fill(e,t){let i;const n=this.instructions[this.instructions.length-1];return this._tick===0&&n&&n.action==="stroke"?i=n.data.path:i=this._activePath.clone(),i?(e!=null&&(t!==void 0&&typeof e=="number"&&(K(J,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:t}),this._fillStyle=ki(e,Et.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:e,y:t}=this._activePath.getLastPoint(V.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(e){let t;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&i.action==="fill"?t=i.data.path:t=this._activePath.clone(),t?(e!=null&&(this._strokeStyle=Wn(e,Et.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:t}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){const t=this.instructions[this.instructions.length-1-e],i=this._activePath.clone();if(t&&(t.action==="stroke"||t.action==="fill"))if(t.data.hole)t.data.hole.addPath(i);else{t.data.hole=i;break}}return this._initNextPathLocation(),this}arc(e,t,i,n,r,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,i,n,r,o),this}arcTo(e,t,i,n,r){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*i+o.c*n+o.tx,o.b*i+o.d*n+o.ty,r),this}arcToSvg(e,t,i,n,r,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(e,t,i,n,r,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(e,t,i,n,r,o,a){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*e+l.c*t+l.tx,l.b*e+l.d*t+l.ty,l.a*i+l.c*n+l.tx,l.b*i+l.d*n+l.ty,l.a*r+l.c*o+l.tx,l.b*r+l.d*o+l.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(e,t,i,n){return this._tick++,this._activePath.ellipse(e,t,i,n,this._transform.clone()),this}circle(e,t,i){return this._tick++,this._activePath.circle(e,t,i,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*e+i.c*t+i.tx,i.b*e+i.d*t+i.ty),this}moveTo(e,t){this._tick++;const i=this._transform,n=this._activePath.instructions,r=i.a*e+i.c*t+i.tx,o=i.b*e+i.d*t+i.ty;return n.length===1&&n[0].action==="moveTo"?(n[0].data[0]=r,n[0].data[1]=o,this):(this._activePath.moveTo(r,o),this)}quadraticCurveTo(e,t,i,n,r){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*i+o.c*n+o.tx,o.b*i+o.d*n+o.ty,r),this}rect(e,t,i,n){return this._tick++,this._activePath.rect(e,t,i,n,this._transform.clone()),this}roundRect(e,t,i,n,r){return this._tick++,this._activePath.roundRect(e,t,i,n,r,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,i,n,r=0,o){return this._tick++,this._activePath.regularPoly(e,t,i,n,r,o),this}roundPoly(e,t,i,n,r,o){return this._tick++,this._activePath.roundPoly(e,t,i,n,r,o),this}roundShape(e,t,i,n){return this._tick++,this._activePath.roundShape(e,t,i,n),this}filletRect(e,t,i,n,r){return this._tick++,this._activePath.filletRect(e,t,i,n,r),this}chamferRect(e,t,i,n,r,o){return this._tick++,this._activePath.chamferRect(e,t,i,n,r,o),this}star(e,t,i,n,r=0,o=0){return this._tick++,this._activePath.star(e,t,i,n,r,o,this._transform.clone()),this}svg(e){return this._tick++,sb(e,this),this}restore(){const e=this._stateStack.pop();return e&&(this._transform=e.transform,this._fillStyle=e.fillStyle,this._strokeStyle=e.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(e){return this._transform.rotate(e),this}scale(e,t=e){return this._transform.scale(e,t),this}setTransform(e,t,i,n,r,o){return e instanceof Z?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,i,n,r,o),this)}transform(e,t,i,n,r,o){return e instanceof Z?(this._transform.append(e),this):($l.set(e,t,i,n,r,o),this._transform.append($l),this)}translate(e,t=e){return this._transform.translate(e,t),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){const i=this.instructions[t],n=i.action;if(n==="fill"){const r=i.data;e.addBounds(r.path.bounds)}else if(n==="texture"){const r=i.data;e.addFrame(r.dx,r.dy,r.dx+r.dw,r.dy+r.dh,r.transform)}if(n==="stroke"){const r=i.data,o=r.style.alignment,a=r.style.width*(1-o),l=r.path.bounds;e.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return e}containsPoint(e){if(!this.bounds.containsPoint(e.x,e.y))return!1;const t=this.instructions;let i=!1;for(let n=0;n<t.length;n++){const r=t[n],o=r.data,a=o.path;if(!r.action||!a)continue;const l=o.style,h=a.shapePath.shapePrimitives;for(let c=0;c<h.length;c++){const u=h[c].shape;if(!l||!u)continue;const d=h[c].transform,_=d?d.applyInverse(e,lb):e;if(r.action==="fill")i=u.contains(_.x,_.y);else{const g=l;i=u.strokeContains(_.x,_.y,g.width,g.alignment)}const f=o.hole;if(f){const g=f.shapePath?.shapePrimitives;if(g)for(let p=0;p<g.length;p++)g[p].shape.contains(_.x,_.y)&&(i=!1)}if(i)return!0}}return i}destroy(e=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof e=="boolean"?e:e?.texture){const i=typeof e=="boolean"?e:e?.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(i),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(i)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};ba.defaultFillStyle={color:16777215,alpha:1,texture:Y.WHITE,matrix:null,fill:null};ba.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:Y.WHITE,matrix:null,fill:null,pixelLine:!1};let nt=ba;const Ol=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function hb(s){const e=[];let t=0;for(let i=0;i<Ol.length;i++){const n=`_${Ol[i]}`;e[t++]=s[n]}return t=Ku(s._fill,e,t),t=cb(s._stroke,e,t),t=ub(s.dropShadow,e,t),e.join("-")}function Ku(s,e,t){return s&&(e[t++]=s.color,e[t++]=s.alpha,e[t++]=s.fill?.styleKey),t}function cb(s,e,t){return s&&(t=Ku(s,e,t),e[t++]=s.width,e[t++]=s.alignment,e[t++]=s.cap,e[t++]=s.join,e[t++]=s.miterLimit),t}function ub(s,e,t){return s&&(e[t++]=s.alpha,e[t++]=s.angle,e[t++]=s.blur,e[t++]=s.distance,e[t++]=fe.shared.setValue(s.color).toNumber()),t}const ya=class Qi extends kt{constructor(e={}){super(),db(e);const t={...Qi.defaultTextStyle,...e};for(const i in t){const n=i;this[n]=t[i]}this.update()}get align(){return this._align}set align(e){this._align=e,this.update()}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords=e,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(e){e!==null&&typeof e=="object"?this._dropShadow=this._createProxy({...Qi.defaultDropShadow,...e}):this._dropShadow=e?this._createProxy({...Qi.defaultDropShadow}):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily=e,this.update()}get fontSize(){return this._fontSize}set fontSize(e){typeof e=="string"?this._fontSize=parseInt(e,10):this._fontSize=e,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle=e.toLowerCase(),this.update()}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant=e,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight=e,this.update()}get leading(){return this._leading}set leading(e){this._leading=e,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing=e,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight=e,this.update()}get padding(){return this._padding}set padding(e){this._padding=e,this.update()}get trim(){return this._trim}set trim(e){this._trim=e,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline=e,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace=e,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap=e,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth=e,this.update()}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...nt.defaultFillStyle,...e},()=>{this._fill=ki({...this._originalFill},nt.defaultFillStyle)})),this._fill=ki(e===0?"black":e,nt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...nt.defaultStrokeStyle,...e},()=>{this._stroke=Wn({...this._originalStroke},nt.defaultStrokeStyle)})),this._stroke=Wn(e,nt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=hb(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const e=Qi.defaultTextStyle;for(const t in e)this[t]=e[t]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new Qi({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(e=!1){if(this.removeAllListeners(),typeof e=="boolean"?e:e?.texture){const i=typeof e=="boolean"?e:e?.textureSource;this._fill?.texture&&this._fill.texture.destroy(i),this._originalFill?.texture&&this._originalFill.texture.destroy(i),this._stroke?.texture&&this._stroke.texture.destroy(i),this._originalStroke?.texture&&this._originalStroke.texture.destroy(i)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(e,t){return new Proxy(e,{set:(i,n,r)=>(i[n]=r,t?.(n,r),this.update(),!0)})}_isFillStyle(e){return(e??null)!==null&&!(fe.isColorLike(e)||e instanceof js||e instanceof sr)}};ya.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};ya.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Qs=ya;function db(s){const e=s;if(typeof e.dropShadow=="boolean"&&e.dropShadow){const t=Qs.defaultDropShadow;s.dropShadow={alpha:e.dropShadowAlpha??t.alpha,angle:e.dropShadowAngle??t.angle,blur:e.dropShadowBlur??t.blur,color:e.dropShadowColor??t.color,distance:e.dropShadowDistance??t.distance}}if(e.strokeThickness!==void 0){K(J,"strokeThickness is now a part of stroke");const t=e.stroke;let i={};if(fe.isColorLike(t))i.color=t;else if(t instanceof js||t instanceof sr)i.fill=t;else if(Object.hasOwnProperty.call(t,"color")||Object.hasOwnProperty.call(t,"fill"))i=t;else throw new Error("Invalid stroke value.");s.stroke={...i,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){K(J,"gradient fill is now a fill pattern: `new FillGradient(...)`");let t;s.fontSize==null?s.fontSize=Qs.defaultTextStyle.fontSize:typeof s.fontSize=="string"?t=parseInt(s.fontSize,10):t=s.fontSize;const i=new js(0,0,0,t*1.7),n=e.fillGradientStops.map(r=>fe.shared.setValue(r).toNumber());n.forEach((r,o)=>{const a=o/(n.length-1);i.addColorStop(a,r)}),s.fill={fill:i}}}class _b{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){const i=_e.get().createCanvas();i.width=e,i.height=t;const n=i.getContext("2d");return{canvas:i,context:n}}getOptimalCanvasAndContext(e,t,i=1){e=Math.ceil(e*i-1e-6),t=Math.ceil(t*i-1e-6),e=Dn(e),t=Dn(t);const n=(e<<17)+(t<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(e,t)),r}returnCanvasAndContext(e){const t=e.canvas,{width:i,height:n}=t,r=(i<<17)+(n<<1);e.context.clearRect(0,0,i,n),this._canvasPool[r].push(e)}clear(){this._canvasPool={}}}const Gl=new _b,fb=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Yo(s){const e=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let t=s.fontFamily;Array.isArray(s.fontFamily)||(t=s.fontFamily.split(","));for(let i=t.length-1;i>=0;i--){let n=t[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!fb.includes(n)&&(n=`"${n}"`),t[i]=n}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${e} ${t.join(",")}`}const uo={willReadFrequently:!0},St=class L{static get experimentalLetterSpacingSupported(){let e=L._experimentalLetterSpacingSupported;if(e!==void 0){const t=_e.get().getCanvasRenderingContext2D().prototype;e=L._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,i,n,r,o,a,l,h){this.text=e,this.style=t,this.width=i,this.height=n,this.lines=r,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(e=" ",t,i=L._canvas,n=t.wordWrap){const r=`${e}:${t.styleKey}`;if(L._measurementCache[r])return L._measurementCache[r];const o=Yo(t),a=L.measureFont(o);a.fontSize===0&&(a.fontSize=t.fontSize,a.ascent=t.fontSize);const l=L.__context;l.font=o;const c=(n?L._wordWrap(e,t,i):e).split(/(?:\r\n|\r|\n)/),u=new Array(c.length);let d=0;for(let b=0;b<c.length;b++){const y=L._measureText(c[b],t.letterSpacing,l);u[b]=y,d=Math.max(d,y)}const _=t._stroke?.width||0;let f=d+_;t.dropShadow&&(f+=t.dropShadow.distance);const g=t.lineHeight||a.fontSize;let p=Math.max(g,a.fontSize+_)+(c.length-1)*(g+t.leading);return t.dropShadow&&(p+=t.dropShadow.distance),new L(e,t,f,p,c,u,g+t.leading,d,a)}static _measureText(e,t,i){let n=!1;L.experimentalLetterSpacingSupported&&(L.experimentalLetterSpacing?(i.letterSpacing=`${t}px`,i.textLetterSpacing=`${t}
241px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const r=i.measureText(e);let o=r.width;const a=-r.actualBoundingBoxLeft;let h=r.actualBoundingBoxRight-a;if(o>0)if(n)o-=t,h-=t;else{const c=(L.graphemeSegmenter(e).length-1)*t;o+=c,h+=c}return Math.max(o,h)}static _wordWrap(e,t,i=L._canvas){const n=i.getContext("2d",uo);let r=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:c}=t,u=L._collapseSpaces(c),d=L._collapseNewlines(c);let _=!u;const f=t.wordWrapWidth+h,g=L._tokenize(e);for(let p=0;p<g.length;p++){let m=g[p];if(L._isNewline(m)){if(!d){a+=L._addLine(o),_=!u,o="",r=0;continue}m=" "}if(u){const y=L.isBreakingSpace(m),w=L.isBreakingSpace(o[o.length-1]);if(y&&w)continue}const b=L._getFromCache(m,h,l,n);if(b>f)if(o!==""&&(a+=L._addLine(o),o="",r=0),L.canBreakWords(m,t.breakWords)){const y=L.wordWrapSplit(m);for(let w=0;w<y.length;w++){let A=y[w],k=A,x=1;for(;y[w+x];){const S=y[w+x];if(!L.canBreakChars(k,S,m,w,t.breakWords))A+=S;else break;k=S,x++}w+=x-1;const C=L._getFromCache(A,h,l,n);C+r>f&&(a+=L._addLine(o),_=!1,o="",r=0),o+=A,r+=C}}else{o.length>0&&(a+=L._addLine(o),o="",r=0);const y=p===g.length-1;a+=L._addLine(m,!y),_=!1,o="",r=0}else b+r>f&&(_=!1,a+=L._addLine(o),o="",r=0),(o.length>0||!L.isBreakingSpace(m)||_)&&(o+=m,r+=b)}return a+=L._addLine(o,!1),a}static _addLine(e,t=!0){return e=L._trimRight(e),e=t?`${e}
242`:e,e}static _getFromCache(e,t,i,n){let r=i[e];return typeof r!="number"&&(r=L._measureText(e,t,n)+t,i[e]=r),r}static _collapseSpaces(e){return e==="normal"||e==="pre-line"}static _collapseNewlines(e){return e==="normal"}static _trimRight(e){if(typeof e!="string")return"";for(let t=e.length-1;t>=0;t--){const i=e[t];if(!L.isBreakingSpace(i))break;e=e.slice(0,-1)}return e}static _isNewline(e){return typeof e!="string"?!1:L._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,t){return typeof e!="string"?!1:L._breakingSpaces.includes(e.charCodeAt(0))}static _tokenize(e){const t=[];let i="";if(typeof e!="string")return t;for(let n=0;n<e.length;n++){const r=e[n],o=e[n+1];if(L.isBreakingSpace(r,o)||L._isNewline(r)){i!==""&&(t.push(i),i=""),t.push(r);continue}i+=r}return i!==""&&t.push(i),t}static canBreakWords(e,t){return t}static canBreakChars(e,t,i,n,r){return!0}static wordWrapSplit(e){return L.graphemeSegmenter(e)}static measureFont(e){if(L._fonts[e])return L._fonts[e];const t=L._context;t.font=e;const i=t.measureText(L.METRICS_STRING+L.BASELINE_SYMBOL),n={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return L._fonts[e]=n,n}static clearMetrics(e=""){e?delete L._fonts[e]:L._fonts={}}static get _canvas(){if(!L.__canvas){let e;try{const t=new OffscreenCanvas(0,0);if(t.getContext("2d",uo)?.measureText)return L.__canvas=t,t;e=_e.get().createCanvas()}catch{e=_e.get().createCanvas()}e.width=e.height=10,L.__canvas=e}return L.__canvas}static get _context(){return L.__context||(L.__context=L._canvas.getContext("2d",uo)),L.__context}};St.METRICS_STRING="|ÉqÅ";St.BASELINE_SYMBOL="M";St.BASELINE_MULTIPLIER=1.4;St.HEIGHT_MULTIPLIER=2;St.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const s=new Intl.Segmenter;return e=>[...s.segment(e)].map(t=>t.segment)}return s=>[...s]})();St.experimentalLetterSpacing=!1;St._fonts={};St._newlines=[10,13];St._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];St._measurementCache={};let Nl=St;function Dl(s,e){if(s.texture===Y.WHITE&&!s.fill)return fe.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof sr){const t=s.fill,i=e.createPattern(t.texture.source.resource,"repeat"),n=t.transform.copyTo(Z.shared);return n.scale(t.texture.frame.width,t.texture.frame.height),i.setTransform(n),i}else if(s.fill instanceof js){const t=s.fill;if(t.type==="linear"){const i=e.createLinearGradient(t.x0,t.y0,t.x1,t.y1);return t.gradientStops.forEach(n=>{i.addColorStop(n.offset,fe.shared.setValue(n.color).toHex())}),i}}}else{const t=e.createPattern(s.texture.source.resource,"repeat"),i=s.matrix.copyTo(Z.shared);return i.scale(s.texture.frame.width,s.texture.frame.height),t.setTransform(i),t}return me("FillStyle not recognised",s),"red"}function Zu(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const e=[];for(let t=0,i=s.length;t<i;t++){const n=s[t];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);if(n[0].length===0||n[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");
vendor: 15,328 bytes, lines 242-245
242const r=n[0].charCodeAt(0),o=n[1].charCodeAt(0);if(o<r)throw new Error("[BitmapFont]: Invalid character range.");for(let a=r,l=o;a<=l;a++)e.push(String.fromCharCode(a))}else e.push(...Array.from(n))}if(e.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}const Qu=class Ju extends Iu{constructor(e){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;const t={...Ju.defaultOptions,...e};this._textureSize=t.textureSize,this._mipmap=t.mipmap;const i=t.style.clone();t.overrideFill&&(i._fill.color=16777215,i._fill.alpha=1,i._fill.texture=Y.WHITE,i._fill.fill=null),this.applyFillAsTint=t.overrideFill;const n=i.fontSize;i.fontSize=this.baseMeasurementFontSize;const r=Yo(i);t.overrideSize?i._stroke&&(i._stroke.width*=this.baseRenderedFontSize/n):i.fontSize=this.baseRenderedFontSize=n,this._style=i,this._skipKerning=t.skipKerning??!1,this.resolution=t.resolution??1,this._padding=t.padding??4,this.fontMetrics=Nl.measureFont(r),this.lineHeight=i.lineHeight||this.fontMetrics.fontSize||i.fontSize}ensureCharacters(e){const t=Zu(e).filter(p=>!this._currentChars.includes(p)).filter((p,m,b)=>b.indexOf(p)===m);if(!t.length)return;this._currentChars=[...this._currentChars,...t];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:n,context:r}=i.canvasAndContext,o=i.texture.source;const a=this._style;let l=this._currentX,h=this._currentY;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,u=this._padding*c;let d=0,_=!1;const f=n.width/this.resolution,g=n.height/this.resolution;for(let p=0;p<t.length;p++){const m=t[p],b=Nl.measureText(m,a,n,!1);b.lineHeight=b.height;const y=b.width*c,w=Math.ceil((a.fontStyle==="italic"?2:1)*y),A=b.height*c,k=w+u*2,x=A+u*2;if(_=!1,m!==`
243`&&m!=="\r"&&m!=="	"&&m!==" "&&(_=!0,d=Math.ceil(Math.max(x,d))),l+k>f&&(h+=d,d=x,l=0,h+d>g)){o.update();const S=this._nextPage();n=S.canvasAndContext.canvas,r=S.canvasAndContext.context,o=S.texture.source,h=0}const C=y/c-(a.dropShadow?.distance??0)-(a._stroke?.width??0);if(this.chars[m]={id:m.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:C,kerning:{}},_){this._drawGlyph(r,b,l+u,h+u,c,a);const S=o.width*c,T=o.height*c,E=new se(l/S*o.width,h/T*o.height,k/S*o.width,x/T*o.height);this.chars[m].texture=new Y({source:o,frame:E}),l+=Math.ceil(k)}}o.update(),this._currentX=l,this._currentY=h,this._skipKerning&&this._applyKerning(t,r)}get pageTextures(){return K(J,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(e,t){const i=this._measureCache;for(let n=0;n<e.length;n++){const r=e[n];for(let o=0;o<this._currentChars.length;o++){const a=this._currentChars[o];let l=i[r];l||(l=i[r]=t.measureText(r).width);let h=i[a];h||(h=i[a]=t.measureText(a).width);let c=t.measureText(r+a).width,u=c-(l+h);u&&(this.chars[r].kerning[a]=u),c=t.measureText(r+a).width,u=c-(l+h),u&&(this.chars[a].kerning[r]=u)}}}_nextPage(){this._currentPageIndex++;const e=this.resolution,t=Gl.getOptimalCanvasAndContext(this._textureSize,this._textureSize,e);this._setupContext(t.context,this._style,e);const i=e*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new Y({source:new gs({resource:t.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})}),r={canvasAndContext:t,texture:n};return this.pages[this._currentPageIndex]=r,r}_setupContext(e,t,i){t.fontSize=this.baseRenderedFontSize,e.scale(i,i),e.font=Yo(t),t.fontSize=this.baseMeasurementFontSize,e.textBaseline=t.textBaseline;const n=t._stroke,r=n?.width??0;if(n&&(e.lineWidth=r,e.lineJoin=n.join,e.miterLimit=n.miterLimit,e.strokeStyle=Dl(n,e)),t._fill&&(e.fillStyle=Dl(t._fill,e)),t.dropShadow){const o=t.dropShadow,a=fe.shared.setValue(o.color).toArray(),l=o.blur*i,h=o.distance*i;e.shadowColor=`rgba(${a[0]*255},${a[1]*255},${a[2]*255},${o.alpha})`,e.shadowBlur=l,e.shadowOffsetX=Math.cos(o.angle)*h,e.shadowOffsetY=Math.sin(o.angle)*h}else e.shadowColor="black",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0}_drawGlyph(e,t,i,n,r,o){const a=t.text,l=t.fontProperties,c=(o._stroke?.width??0)*r,u=i+c/2,d=n-c/2,_=l.descent*r,f=t.lineHeight*r;o.stroke&&c&&e.strokeText(a,u,d+f-_),o._fill&&e.fillText(a,u,d+f-_)}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){const{canvasAndContext:t,texture:i}=this.pages[e];Gl.returnCanvasAndContext(t),i.destroy(!0)}this.pages=null}};Qu.defaultOptions={textureSize:512,style:new Qs,mipmap:!0};let Ul=Qu;function gb(s,e,t,i){const n={width:0,height:0,offsetY:0,scale:e.fontSize/t.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};n.offsetY=t.baseLineOffset;let r=n.lines[0],o=null,a=!0;const l={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},h=f=>{const g=r.width;for(let p=0;p<l.index;p++){const m=f.positions[p];r.chars.push(f.chars[p]),r.charPositions.push(m+g)}r.width+=f.width,a=!1,l.width=0,l.index=0,l.chars.length=0},c=()=>{let f=r.chars.length-1;if(i){let g=r.chars[f];for(;g===" ";)r.width-=t.chars[g].xAdvance,g=r.chars[--f]}n.width=Math.max(n.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,n.lines.push(r),n.height+=t.lineHeight},u=t.baseMeasurementFontSize/e.fontSize,d=e.letterSpacing*u,_=e.wordWrapWidth*u;for(let f=0;f<s.length+1;f++){let g;const p=f===s.length;p||(g=s[f]);const m=t.chars[g]||t.chars[" "];if(/(?:\s)/.test(g)||g==="\r"||g===`
244`||p){if(!a&&e.wordWrap&&r.width+l.width-d>_?(c(),h(l),p||r.charPositions.push(0)):(l.start=r.width,h(l),p||r.charPositions.push(0)),g==="\r"||g===`
245`)r.width!==0&&c();else if(!p){const A=m.xAdvance+(m.kerning[o]||0)+d;r.width+=A,r.spaceWidth=A,r.spacesIndex.push(r.charPositions.length),r.chars.push(g)}}else{const w=m.kerning[o]||0,A=m.xAdvance+w+d;l.positions[l.index++]=l.width+w,l.chars.push(g),l.width+=A}o=g}return c(),e.align==="center"?pb(n):e.align==="right"?mb(n):e.align==="justify"&&bb(n),n}function pb(s){for(let e=0;e<s.lines.length;e++){const t=s.lines[e],i=s.width/2-t.width/2;for(let n=0;n<t.charPositions.length;n++)t.charPositions[n]+=i}}function mb(s){for(let e=0;e<s.lines.length;e++){const t=s.lines[e],i=s.width-t.width;for(let n=0;n<t.charPositions.length;n++)t.charPositions[n]+=i}}function bb(s){const e=s.width;for(let t=0;t<s.lines.length;t++){const i=s.lines[t];let n=0,r=i.spacesIndex[n++],o=0;const a=i.spacesIndex.length,h=(e-i.width)/a;for(let c=0;c<i.charPositions.length;c++)c===r&&(r=i.spacesIndex[n++],o+=h),i.charPositions[c]+=o}}let kn=0;class yb{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(e,t){let i=`${t.fontFamily}-bitmap`,n=!0;if(t._fill.fill&&!t._stroke)i+=t._fill.fill.styleKey,n=!1;else if(t._stroke||t.dropShadow){let o=t.styleKey;o=o.substring(0,o.lastIndexOf("-")),i=`${o}-bitmap`,n=!1}if(!de.has(i)){const o=new Ul({style:t,overrideFill:n,overrideSize:!0,...this.defaultOptions});kn++,kn>50&&me("BitmapText",`You have dynamically created ${kn} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{kn--,de.remove(i)}),de.set(i,o)}const r=de.get(i);return r.ensureCharacters?.(e),r}getLayout(e,t,i=!0){const n=this.getFont(e,t);return gb([...e],t,n,i)}measureText(e,t,i=!0){return this.getLayout(e,t,i)}install(...e){let t=e[0];typeof t=="string"&&(t={name:t,style:e[1],chars:e[2]?.chars,resolution:e[2]?.resolution,padding:e[2]?.padding,skipKerning:e[2]?.skipKerning},K(J,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=t?.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");t={...this.defaultOptions,...t};const n=t.style,r=n instanceof Qs?n:new Qs(n),o=r._fill.fill!==null&&r._fill.fill!==void 0,a=new Ul({style:r,overrideFill:o,skipKerning:t.skipKerning,padding:t.padding,resolution:t.resolution,overrideSize:!1}),l=Zu(t.chars);return a.ensureCharacters(l.join("")),de.set(`${i}-bitmap`,a),a.once("destroy",()=>de.remove(`${i}-bitmap`)),a}uninstall(e){const t=`${e}-bitmap`,i=de.get(t);i&&i.destroy()}}const Wl=new yb;class ed extends Iu{constructor(e,t){super();const{textures:i,data:n}=e;Object.keys(n.pages).forEach(r=>{const o=n.pages[parseInt(r,10)],a=i[o.id];this.pages.push({texture:a})}),Object.keys(n.chars).forEach(r=>{const o=n.chars[r],{frame:a,source:l}=i[o.page],h=new se(o.x+a.x,o.y+a.y,o.width,o.height),c=new Y({source:l,frame:h});this.chars[r]={id:r.codePointAt(0),xOffset:o.xOffset,yOffset:o.yOffset,xAdvance:o.xAdvance,kerning:o.kerning??{},texture:c}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=n.distanceField??{type:"none",range:0},this.url=t}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){const{texture:t}=this.pages[e];t.destroy(!0)}this.pages=null}static install(e){Wl.install(e)}static uninstall(e){Wl.uninstall(e)}}const _o={test(s){return typeof s=="string"&&s.startsWith("info face=")},parse(s){const e=s.match(/^[a-z]+\s+.+$/gm),t={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const u in e){const d=e[u].match(/^[a-z]+/gm)[0],_=e[u].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),f={};for(const g in _){const p=_[g].split("="),m=p[0],b=p[1].replace(/"/gm,""),y=parseFloat(b),w=isNaN(y)?b:y;f[m]=w}t[d].push(f)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[n]=t.info,[r]=t.common,[o]=t.distanceField??[];o&&(i.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),i.fontSize=parseInt(n.size,10),i.fontFamily=n.face,i.lineHeight=parseInt(r.lineHeight,10);const a=t.page;for(let u=0;u<a.length;u++)i.pages.push({id:parseInt(a[u].id,10)||0,file:a[u].file});const l={};i.baseLineOffset=i.lineHeight-parseInt(r.base,10);const h=t.char;for(let u=0;u<h.length;u++){const d=h[u],_=parseInt(d.id,10);let f=d.letter??d.char??String.fromCharCode(_);f==="space"&&(f=" "),l[_]=f,i.chars[f]={id:_,page:parseInt(d.page,10)||0,x:parseInt(d.x,10),y:parseInt(d.y,10),width:parseInt(d.width,10),height:parseInt(d.height,10),xOffset:parseInt(d.xoffset,10),yOffset:parseInt(d.yoffset,10),xAdvance:parseInt(d.xadvance,10),kerning:{}}}const c=t.kerning||[];for(let u=0;u<c.length;u++){const d=parseInt(c[u].first,10),_=parseInt(c[u].second,10),f=parseInt(c[u].amount,10);i.chars[l[_]].kerning[l[d]]=f}return i}},Hl={test(s){const e=s;return typeof e!="string"&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(s){const e={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},t=s.getElementsByTagName("info")[0],i=s.getElementsByTagName("common")[0],n=s.getElementsByTagName("distanceField")[0];n&&(e.distanceField={type:n.getAttribute("fieldType"),range:parseInt(n.getAttribute("distanceRange"),10)});const r=s.getElementsByTagName("page"),o=s.getElementsByTagName("char"),a=s.getElementsByTagName("kerning");e.fontSize=parseInt(t.getAttribute("size"),10),e.fontFamily=t.getAttribute("face"),e.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let h=0;h<r.length;h++)e.pages.push({id:parseInt(r[h].getAttribute("id"),10)||0,file:r[h].getAttribute("file")});const l={};e.baseLineOffset=e.lineHeight-parseInt(i.getAttribute("base"),10);for(let h=0;h<o.length;h++){const c=o[h],u=parseInt(c.getAttribute("id"),10);let d=c.getAttribute("letter")??c.getAttribute("char")??String.fromCharCode(u);d==="space"&&(d=" "),l[u]=d,e.chars[d]={id:u,page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xOffset:parseInt(c.getAttribute("xoffset"),10),yOffset:parseInt(c.getAttribute("yoffset"),10),xAdvance:parseInt(c.getAttribute("xadvance"),10),kerning:{}}}for(let h=0;h<a.length;h++){const c=parseInt(a[h].getAttribute("first"),10),u=parseInt(a[h].getAttribute("second"),10),d=parseInt(a[h].getAttribute("amount"),10);e.chars[l[u]].kerning[l[c]]=d}return e}},ql={test(s){return typeof s=="string"&&s.includes("<font>")?Hl.test(_e.get().parseXML(s)):!1},parse(s){return Hl.parse(_e.get().parseXML(s))}},wb=[".xml",".fnt"],xb={extension:{type:$.CacheParser,name:"cacheBitmapFont"},test:s=>s instanceof ed,getCacheableAssets(s,e){const t={};return s.forEach(i=>{t[i]=e,t[`${i}-bitmap`]=e}),t[`${e.fontFamily}-bitmap`]=e,t}},vb={extension:{type:$.LoadParser,priority:ui.Normal},name:"loadBitmapFont",test(s){return wb.includes(Ke.extname(s).toLowerCase())},async testParse(s){return _o.test(s)||ql.test(s)},async parse(s,e,t){const i=_o.test(s)?_o.parse(s):ql.parse(s),{src:n}=e,{pages:r}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;u<r.length;++u){const d=r[u].file;let _=Ke.join(Ke.dirname(n),d);_=Eo(_,n),o.push({src:_,data:a})}const l=await t.load(o),h=o.map(u=>l[u.src]);return new ed({data:i,textures:h},n)},async load(s,e){return await(await _e.get().fetch(s)).text()},async unload(s,e,t){await Promise.all(s.pages.map(i=>t.unload(i.texture.source._sourceOrigin))),s.destroy()}};class kb{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<t;i++)e.push(this._assetList.pop());await this._loader.load(e),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(e){this._isActive!==e&&(this._isActive=e,e&&!this._isLoading&&this._next())}}const Ab={extension:{type:$.CacheParser,name:"cacheTextureArray"},test:s=>Array.isArray(s)&&s.every(e=>e instanceof Y),getCacheableAssets:(s,e)=>{const t={};return s.forEach(i=>{e.forEach((n,r)=>{t[i+(r===0?"":r+1)]=n})}),t}};async function td(s){if("Image"in globalThis)return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=await(await fetch(s)).blob();await createImageBitmap(e)}catch{return!1}return!0}return!1}const Sb={extension:{type:$.DetectionParser,priority:1},test:async()=>td("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdj
245FDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(e=>e!=="avif")},Vl=["png","jpg","jpeg"],Cb={extension:{type:$.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Vl],remove:async s=>s.filter(e=>!Vl.includes(e))},Mb="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function wa(s){return Mb?!1:document.createElement("video").canPlayType(s)!==""}const Tb={extension:{type:$.DetectionParser,priority:0},test:async()=>wa("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(e=>e!=="mp4"&&e!=="m4v")},Pb={extension:{type:$.DetectionParser,priority:0},test:async()=>wa("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(e=>e!=="ogv")},zb={extension:{type:$.DetectionParser,priority:0},test:async()=>wa("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(e=>e!=="webm")},Ib={extension:{type:$.DetectionParser,priority:0},test:async()=>td("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(e=>e!=="webp")};class Eb{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,i)=>(this._parsersValidated=!1,e[t]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){const i={promise:null,parser:null};return i.promise=(async()=>{let n=null,r=null;if(t.loadParser&&(r=this._parserHash[t.loadParser],r||me(`[Assets] specified load parser "${t.loadParser}" not found while loading ${e}`)),!r){for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];if(a.load&&a.test?.(e,t,this)){r=a;break}}if(!r)return me(`[Assets] ${e} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}n=await r.load(e,t,this),i.parser=r;for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];a.parse&&a.parse&&await a.testParse?.(n,t,this)&&(n=await a.parse(n,t,this)||n,i.parser=a)}return n})(),i}async load(e,t){this._parsersValidated||this._validateParsers();let i=0;const n={},r=Un(e),o=mt(e,h=>({alias:[h],src:h,data:{}})),a=o.length,l=o.map(async h=>{const c=Ke.toAbsolute(h.src);if(!n[h.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,h)),n[h.src]=await this.promiseCache[c].promise,t&&t(++i/a)}catch(u){throw delete this.promiseCache[c],delete n[h.src],new Error(`[Loader.load] Failed to load ${c}.
246${u}`)}});return await Promise.all(l),r?n[o[0].src]:n}async unload(e){const i=mt(e,n=>({alias:[n],src:n})).map(async n=>{const r=Ke.toAbsolute(n.src),o=this.promiseCache[r];if(o){const a=await o.promise;delete this.promiseCache[r],await o.parser?.unload?.(a,n,this)}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(e=>e.name).reduce((e,t)=>(t.name?e[t.name]&&me(`[Assets] loadParser name conflict "${t.name}"`):me("[Assets] loadParser should have a name"),{...e,[t.name]:t}),{})}}function ms(s,e){if(Array.isArray(e)){for(const t of e)if(s.startsWith(`data:${t}`))return!0;return!1}return s.startsWith(`data:${e}`)}function bs(s,e){const t=s.split("?")[0],i=Ke.extname(t).toLowerCase();return Array.isArray(e)?e.includes(i):i===e}const Rb=".json",Fb="application/json",Bb={extension:{type:$.LoadParser,priority:ui.Low},name:"loadJson",test(s){return ms(s,Fb)||bs(s,Rb)},async load(s){return await(await _e.get().fetch(s)).json()}},Lb=".txt",$b="text/plain",Ob={name:"loadTxt",extension:{type:$.LoadParser,priority:ui.Low,name:"loadTxt"},test(s){return ms(s,$b)||bs(s,Lb)},async load(s){return await(await _e.get().fetch(s)).text()}},Gb=["normal","bold","100","200","300","400","500","600","700","800","900"],Nb=[".ttf",".otf",".woff",".woff2"],Db=["font/ttf","font/otf","font/woff","font/woff2"],Ub=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Wb(s){const e=Ke.extname(s),n=Ke.basename(s,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1));let r=n.length>0;for(const a of n)if(!a.match(Ub)){r=!1;break}let o=n.join(" ");return r||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}const Hb=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function qb(s){return Hb.test(s)?s:encodeURI(s)}const Vb={extension:{type:$.LoadParser,priority:ui.Low},name:"loadWebFont",test(s){return ms(s,Db)||bs(s,Nb)},async load(s,e){const t=_e.get().getFontFaceSet();if(t){const i=[],n=e.data?.family??Wb(s),r=e.data?.weights?.filter(a=>Gb.includes(a))??["normal"],o=e.data??{};for(let a=0;a<r.length;a++){const l=r[a],h=new FontFace(n,`url(${qb(s)})`,{...o,weight:l});await h.load(),t.add(h),i.push(h)}return de.set(`${n}-and-url`,{url:s,fontFaces:i}),i.length===1?i[0]:i}return me("[loadWebFont] FontFace API is not supported. Skipping loading font"),null}
246,unload(s){(Array.isArray(s)?s:[s]).forEach(e=>{de.remove(`${e.family}-and-url`),_e.get().getFontFaceSet().delete(e)})}};function xa(s,e=1){const t=ps.RETINA_PREFIX?.exec(s);return t?parseFloat(t[1]):e}function va(s,e,t){s.label=t,s._sourceOrigin=t;const i=new Y({source:s,label:t}),n=()=>{delete e.promiseCache[t],de.has(t)&&de.remove(t)};return i.source.once("destroy",()=>{e.promiseCache[t]&&(me("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),n())}),i.once("destroy",()=>{s.destroyed||(me("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),i}const Xb=".svg",Yb="image/svg+xml",jb={extension:{type:$.LoadParser,priority:ui.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return ms(s,Yb)||bs(s,Xb)},async load(s,e,t){return e.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Zb(s):Kb(s,e,t,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function Kb(s,e,t,i){const r=await(await _e.get().fetch(s)).blob(),o=URL.createObjectURL(r),a=new Image;a.src=o,a.crossOrigin=i,await a.decode(),URL.revokeObjectURL(o);const l=document.createElement("canvas"),h=l.getContext("2d"),c=e.data?.resolution||xa(s),u=e.data?.width??a.width,d=e.data?.height??a.height;l.width=u*c,l.height=d*c,h.drawImage(a,0,0,u*c,d*c);const{parseAsGraphicsContext:_,...f}=e.data??{},g=new gs({resource:l,alphaMode:"premultiply-alpha-on-upload",resolution:c,...f});return va(g,t,s)}async function Zb(s){const t=await(await _e.get().fetch(s)).text(),i=new nt;return i.svg(t),i}const Qb=`(function () {
247    'use strict';
248
249    const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
250    async function checkImageBitmap() {
251      try {
252        if (typeof createImageBitmap !== "function")
253          return false;
254        const response = await fetch(WHITE_PNG);
255        const imageBlob = await response.blob();
256        const imageBitmap = await createImageBitmap(imageBlob);
257        return imageBitmap.width === 1 && imageBitmap.height === 1;
258      } catch (_e) {
259        return false;
260      }
261    }
262    void checkImageBitmap().then((result) => {
263      self.postMessage(result);
264    });
265
266})();
267`;let ss=null,jo=class{constructor(){ss||(ss=URL.createObjectURL(new Blob([Qb],{type:"application/javascript"}))),this.worker=new Worker(ss)}};jo.revokeObjectURL=function(){ss&&(URL.revokeObjectURL(ss),ss=null)};const Jb=`(function () {
268    'use strict';
269
270    async function loadImageBitmap(url, alphaMode) {
271      const response = await fetch(url);
272      if (!response.ok) {
273        throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
274      }
275      const imageBlob = await response.blob();
276      return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
277    }
278    self.onmessage = async (event) => {
279      try {
280        const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);
281        self.postMessage({
282          data: imageBitmap,
283          uuid: event.data.uuid,
284          id: event.data.id
285        }, [imageBitmap]);
286      } catch (e) {
287        self.postMessage({
288          error: e,
289          uuid: event.data.uuid,
290          id: event.data.id
291        });
292      }
293    };
294
295})();
296`;let ns=null;class id{constructor(){ns||(ns=URL.createObjectURL(new Blob([Jb],{type:"application/javascript"}))),this.worker=new Worker(ns)}}id.revokeObjectURL=function(){ns&&(URL.revokeObjectURL(ns),ns=null)};let Xl=0,fo;class e0{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(e=>{const{worker:t}=new jo;t.addEventListener("message",i=>{t.terminate(),jo.revokeObjectURL(),e(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(e,t){return this._run("loadImageBitmap",[e,t?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){fo===void 0&&(fo=navigator.hardwareConcurrency||4);let e=this._workerPool.pop();return!e&&this._createdWorkers<fo&&(this._createdWorkers++,e=new id().worker,e.addEventListener("message",t=>{this._complete(t.data),this._returnWorker(t.target),this._next()})),e}_returnWorker(e){this._workerPool.push(e)}_complete(e){e.error!==void 0?this._resolveHash[e.uuid].reject(e.error):this._resolveHash[e.uuid].resolve(e.data),this._resolveHash[e.uuid]=null}async _run(e,t){await this._initWorkers();const i=new Promise((n,r)=>{this._queue.push({id:e,arguments:t,resolve:n,reject:r})});return this._next(),i}_next(){if(!this._queue.length)return;const e=this._getWorker();if(!e)return;const t=this._queue.pop(),i=t.id;this._resolveHash[Xl]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:Xl++,id:i})}}const Yl=new e0,t0=[".jpeg",".jpg",".png",".webp",".avif"],i0=["image/jpeg","image/png","image/webp","image/avif"];async function s0(s,e){const t=await _e.get().fetch(s);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${t.status} ${t.statusText}`);const i=await t.blob();return e?.data?.alphaMode==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const sd={name:"loadTextures",extension:{type:$.LoadParser,priority:ui.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return ms(s,i0)||bs(s,t0)},async load(s,e,t){let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Yl.isImageBitmapSupported()?i=await Yl.loadImageBitmap(s,e):i=await s0(s,e):i=await new Promise((r,o)=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?r(i):(i.onload=()=>{r(i)},i.onerror=o)});const n=new gs({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:e.data?.resolution||xa(s),...e.data});return va(n,t,s)},unload(s){s.destroy(!0)}},nd=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],n0=nd.map(s=>`video/${s.substring(1)}`);function r0(s,e,t){t===void 0&&!e.startsWith("data:")?s.crossOrigin=a0(e):t!==!1&&(s.crossOrigin=typeof t=="string"?t:"anonymous")}function o0(s){return new Promise((e,t)=>
296{s.addEventListener("canplaythrough",i),s.addEventListener("error",n),s.load();function i(){r(),e()}function n(o){r(),t(o)}function r(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",n)}})}function a0(s,e=globalThis.location){if(s.startsWith("data:"))return"";e||(e=globalThis.location);const t=new URL(s,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}const l0={name:"loadVideo",extension:{type:$.LoadParser,name:"loadVideo"},test(s){const e=ms(s,n0),t=bs(s,nd);return e||t},async load(s,e,t){const i={...In.defaultOptions,resolution:e.data?.resolution||xa(s),alphaMode:e.data?.alphaMode||await ou(),...e.data},n=document.createElement("video"),r={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(r).forEach(l=>{const h=r[l];h!==void 0&&n.setAttribute(l,h)}),i.muted===!0&&(n.muted=!0),r0(n,s,i.crossorigin);const o=document.createElement("source");let a;if(s.startsWith("data:"))a=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const l=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();a=In.MIME_TYPES[l]||`video/${l}`}return o.src=s,a&&(o.type=a),new Promise(l=>{const h=async()=>{const c=new In({...i,resource:n});n.removeEventListener("canplay",h),e.data.preload&&await o0(n),l(va(c,t,s))};n.addEventListener("canplay",h),n.appendChild(o)})},unload(s){s.destroy(!0)}},rd={extension:{type:$.ResolveParser,name:"resolveTexture"},test:sd.test,parse:s=>({resolution:parseFloat(ps.RETINA_PREFIX.exec(s)?.[1]??"1"),format:s.split(".").pop(),src:s})},h0={extension:{type:$.ResolveParser,priority:-2,name:"resolveJson"},test:s=>ps.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:rd.parse};class c0{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ps,this.loader=new Eb,this.cache=de,this._backgroundLoader=new kb(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){if(this._initialized){me("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let r=e.manifest;typeof r=="string"&&(r=await this.load(r)),this.resolver.addManifest(r)}const t=e.texturePreference?.resolution??1,i=typeof t=="number"?[t]:t,n=await this._detectFormats({preferredFormats:e.texturePreference?.format,skipDetections:e.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:i}}),e.preferences&&this.setPreferences(e.preferences)}add(e){this.resolver.add(e)}async load(e,t){this._initialized||await this.init();const i=Un(e),n=mt(e).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),r=this.resolver.resolve(n),o=await this._mapLoadToResolve(r,t);return i?o[n[0]]:o}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let i=!1;typeof e=="string"&&(i=!0,e=[e]);const n=this.resolver.resolveBundle(e),r={},o=Object.keys(n);let a=0,l=0;const h=()=>{t?.(++a/l)},c=o.map(u=>{const d=n[u];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(_=>{r[u]=_})});return await Promise.all(c),i?r[e[0]]:r}async backgroundLoad(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e=="string")return de.get(e);const t={};for(let i=0;i<e.length;i++)t[i]=de.get(e[i]);return t}async _mapLoadToResolve(e,t){const i=[...new Set(Object.values(e))];this._backgroundLoader.active=!1;const n=await this.loader.load(i,t);this._backgroundLoader.active=!0;const r={};
296return i.forEach(o=>{const a=n[o.src],l=[o.src];o.alias&&l.push(...o.alias),l.forEach(h=>{r[h]=a}),de.set(l,a)}),r}async unload(e){this._initialized||await this.init();const t=mt(e).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(t);await this._unloadFromResolved(i)}async unloadBundle(e){this._initialized||await this.init(),e=mt(e);const t=this.resolver.resolveBundle(e),i=Object.keys(t).map(n=>this._unloadFromResolved(t[n]));await Promise.all(i)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach(i=>{de.remove(i.src)}),await this.loader.unload(t)}async _detectFormats(e){let t=[];e.preferredFormats&&(t=Array.isArray(e.preferredFormats)?e.preferredFormats:[e.preferredFormats]);for(const i of e.detections)e.skipDetections||await i.test()?t=await i.add(t):e.skipDetections||(t=await i.remove(t));return t=t.filter((i,n)=>t.indexOf(i)===n),t}get detections(){return this._detections}setPreferences(e){this.loader.parsers.forEach(t=>{t.config&&Object.keys(t.config).filter(i=>i in e).forEach(i=>{t.config[i]=e[i]})})}}const Ai=new c0;Oe.handleByList($.LoadParser,Ai.loader.parsers).handleByList($.ResolveParser,Ai.resolver.parsers).handleByList($.CacheParser,Ai.cache.parsers).handleByList($.DetectionParser,Ai.detections);Oe.add(Ab,Cb,Sb,Ib,Tb,Pb,zb,Bb,Ob,Vb,jb,sd,l0,vb,xb,rd,h0);const jl={loader:$.LoadParser,resolver:$.ResolveParser,cache:$.CacheParser,detection:$.DetectionParser};Oe.handle($.Asset,s=>{const e=s.ref;Object.entries(jl).filter(([t])=>!!e[t]).forEach(([t,i])=>Oe.add(Object.assign(e[t],{extension:e[t].extension??i})))},s=>{const e=s.ref;Object.keys(jl).filter(t=>!!e[t]).forEach(t=>Oe.remove(e[t]))});class be extends Zc{constructor(e){e instanceof nt&&(e={context:e});const{context:t,roundPixels:i,...n}=e||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",t?this._context=t:this._context=this._ownedContext=new nt,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i??!1}set context(e){e!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=e,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(e){return this._context.containsPoint(e)}destroy(e){this._ownedContext&&!e?this._ownedContext.destroy(e):(e===!0||e?.context===!0)&&this._context.destroy(e),this._ownedContext=null,this._context=null,super.destroy(e)}_callContextMethod(e,t){return this.context[e](...t),this}setFillStyle(...e){return this._callContextMethod("setFillStyle",e)}setStrokeStyle(...e){return this._callContextMethod("setStrokeStyle",e)}fill(...e){return this._callContextMethod("fill",e)}stroke(...e){return this._callContextMethod("stroke",e)}texture(...e){return this._callContextMethod("texture",e)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...e){return this._callContextMethod("arc",e)}arcTo(...e){return this._callContextMethod("arcTo",e)}arcToSvg(...e){return this._callContextMethod("arcToSvg",e)}bezierCurveTo(...e){return this._callContextMethod("bezierCurveTo",e)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...e){return this._callContextMethod("ellipse",e)}circle(...e){return this._callContextMethod("circle",e)}path(...e){return this._callContextMethod("path",e)}lineTo(...e){return this._callContextMethod("lineTo",e)}moveTo(...e){return this._callContextMethod("moveTo",e)}quadraticCurveTo(...e){return this._callContextMethod("quadraticCurveTo",e)}rect(...e){return this._callContextMethod("rect",e)}roundRect(...e){return this._callContextMethod("roundRect",e)}poly(...e){return this._callContextMethod("poly",e)}regularPoly(...e){return this._callContextMethod("regularPoly",e)}roundPoly(...e){return this._callContextMethod("roundPoly",e)}roundShape(...e){return this._callContextMethod("roundShape",e)}filletRect(...e){return this._callContextMethod("filletRect",e)}chamferRect(...e){return this._callContextMethod("chamferRect",e)}star(...e){return this._callContextMethod("star",e)}svg(...e){return this._callContextMethod("svg",e)}restore(...e){return this._callContextMethod("restore",e)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...e){return this._callContextMethod("rotate",e)}scaleTransform(...e){return this._callContextMethod("scale",e)}setTransform(...e){return this._callContextMethod("setTransform",e)}transform(...e){return this._callContextMethod("transform",e)}translateTransform(...e){return this._callContextMethod("translate",e)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(e=!1){return e?new be(this._context.clone()):(this._ownedContext=null,new be(this._context))}lineStyle(e,t,i){K(J,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return e&&(n.width=e),t&&(n.color=t),i&&(n.alpha=i),this.context.strokeStyle=n,this}beginFill(e,t){K(J,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return e!==void 0&&(i.color=e),t!==void 0&&(i.alpha=t),this.context.fillStyle=i,this}endFill(){K(J,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const e=this.context.strokeStyle;return(e.width!==nt.defaultStrokeStyle.width||e.color!==nt.defaultStrokeStyle.color||e.alpha!==nt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return K(J,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}
296drawEllipse(...e){return K(J,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return K(J,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return K(J,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return K(J,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return K(J,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}class Ii extends Y{static create(e){return new Ii({source:new At(e)})}resize(e,t,i){return this.source.resize(e,t,i),this}}var Ko=(s=>(s.CLAMP="clamp-to-edge",s.REPEAT="repeat",s.MIRRORED_REPEAT="mirror-repeat",s))(Ko||{});new Proxy(Ko,{get(s,e){return K(J,`DRAW_MODES.${e} is deprecated, use '${Ko[e]}' instead`),s[e]}});var Zo=(s=>(s.NEAREST="nearest",s.LINEAR="linear",s))(Zo||{});const Kl=new Proxy(Zo,{get(s,e){return K(J,`DRAW_MODES.${e} is deprecated, use '${Zo[e]}' instead`),s[e]}});Oe.add(Ig,Eg);function An(s,e,t){return s<e?e:s>t?t:s}function Fn(s,e,t){return new Promise(i=>{if(!e){i(null);return}const n=e.getLocalBounds(),r=t?new se(t.x,t.y,t.width,t.height):new se(0,0,n.width,n.height);s.extract.canvas({target:e,resolution:1,frame:r}).toBlob?.(a=>{a||i(null),i(a)})})}const{SvelteComponent:u0,append:go,attr:Xi,binding_callbacks:po,detach:Ms,element:Yi,flush:Zl,init:d0,insert:Ts,listen:Ps,noop:Ql,run_all:_0,safe_not_equal:f0,set_style:Be,space:Jl}=window.__gradio__svelte__internal,{onMount:g0,tick:p0}=window.__gradio__svelte__internal;function m0(s){let e,t,i=`translate(${s[2][0]}px,${s[2][1]}px)`,n,r,o,a=`translateX(${s[1]*(s[8]?.width??1)}px)`,l,h,c,u=`translateX(${s[4]}px)`,d,_;return{c(){e=Yi("div"),t=Yi("div"),n=Jl(),r=Yi("div"),o=Yi("div"),l=Jl(),h=Yi("div"),c=Yi("div"),Xi(t,"class","marker svelte-9hvvq8"),Be(t,"transform",i),Be(t,"background",s[0]),Xi(e,"class","color-gradient svelte-9hvvq8"),Be(e,"--hue",s[3]),Xi(o,"class","opacity-marker svelte-9hvvq8"),Be(o,"background","white"),Be(o,"transform",a),Xi(r,"class","opacity-slider svelte-9hvvq8"),Be(r,"--color",s[0]==="auto"?"transparent":s[0]),Xi(c,"class","marker svelte-9hvvq8"),Be(c,"background","hsl("+s[3]+", 100%, 50%)"),Be(c,"transform",u),Xi(h,"class","hue-slider svelte-9hvvq8")},m(f,g){Ts(f,e,g),go(e,t),s[14](e),Ts(f,n,g),Ts(f,r,g),go(r,o),s[15](r),Ts(f,l,g),Ts(f,h,g),go(h,c),s[16](h),d||(_=[Ps(window,"mousemove",s[11]),Ps(window,"mouseup",s[12]),Ps(e,"mousedown",s[10]),Ps(r,"mousedown",s[13]),Ps(h,"mousedown",s[9])],d=!0)},p(f,[g]){g&4&&i!==(i=`translate(${f[2][0]}px,${f[2][1]}px)`)&&Be(t,"transform",i),g&1&&Be(t,"background",f[0]),g&8&&Be(e,"--hue",f[3]),g&258&&a!==(a=`translateX(${f[1]*(f[8]?.width??1)}px)`)&&Be(o,"transform",a),g&1&&Be(r,"--color",f[0]==="auto"?"transparent":f[0]),g&8&&Be(c,"background","hsl("+f[3]+", 100%, 50%)"),g&16&&u!==(u=`translateX(${f[4]}px)`)&&Be(c,"transform",u)},i:Ql,o:Ql,d(f){f&&(Ms(e),Ms(n),Ms(r),Ms(l),Ms(h)),s[14](null),s[15](null),s[16](null),d=!1,_0(_)}}}function eh(s){const e=s.s,t=s.v;let i=e*t;const n=s.h/60;let r=i*(1-Math.abs(n%2-1));const o=t-i;i=i+o,r=r+o;const a=Math.floor(n)%6,l=[i,r,o,o,r,i][a],h=[r,i,i,r,o,o][a],c=[o,o,r,i,i,r][a];return`rgba(${l*255}, ${h*255}, ${c*255}, ${s.a})`}function b0(s,e,t){let{color:i="rgb(255, 255, 255)"}=e,n=[0,0],r=null,o=!1,a=[0,0],l=0,h=0,c=null,u=!1,d=!1;function _(F){c=F.currentTarget.getBoundingClientRect(),u=!0,f(F.clientX)}function f(F){if(!c)return;const q=An(F-c.left,0,c.width);t(4,h=q);const R=q/c.width*360;t(3,l=R),t(0,i=eh({h:R,s:a[0],v:a[1],a:1}))}function g(F,q){if(!r)return;const R=An(F-r.left,0,r.width),B=An(q-r.top,0,r.height);t(2,n=[R,B]);const ze={h:l*1,s:R/r.width,v:1-B/r.height,a:1};a=[ze.s,ze.v],t(0,i=eh(ze))}function p(F){o=!0,r=F.currentTarget.getBoundingClientRect(),g(F.clientX,F.clientY)}function m(F){o&&g(F.clientX,F.clientY),u&&f(F.clientX),d&&T(F.clientX)}function b(){o&&(o=!1),u&&(u=!1),d&&(d=!1)}async function y(F){if(o||u||(await p0(),!F))return;r||(r=w.getBoundingClientRect()),c||(c=A.getBoundingClientRect());const q=je(F).toHsv(),R=q.s*r.width,B=(1-q.v)*r.height;t(2,n=[R,B]),a=[q.s,q.v],t(3,l=q.h),t(4,h=q.h/360*c.width)}let w,A,{opacity:k=1}=e,x;function C(F){t(8,S=F.currentTarget.getBoundingClientRect()),d=!0,T(F.clientX)}let S=null;function T(F){if(!S)return;const q=An(F-S.left,0,S.width);t(1,k=q/S.width)}g0(()=>{t(8,S=x.getBoundingClientRect())});function E(F){po[F?"unshift":"push"](()=>{w=F,t(5,w)})}function D(F){po[F?"unshift":"push"](()=>{x=F,t(7,x)})}function X(F){po[F?"unshift":"push"](()=>{A=F,t(6,A)})}return s.$$set=F=>{"color"in F&&t(0,i=F.color),"opacity"in F&&t(1,k=F.opacity)},s.$$.update=()=>{s.$$.dirty&1&&y(i)},[i,k,n,l,h,w,A,x,S,_,p,m,b,C,E,D,X]}class y0 extends u0{constructor(e){super(),d0(this,e,b0,m0,f0,{color:0,op
296acity:1})}get color(){return this.$$.ctx[0]}set color(e){this.$$set({color:e}),Zl()}get opacity(){return this.$$.ctx[1]}set opacity(e){this.$$set({opacity:e}),Zl()}}const{SvelteComponent:w0,append:rs,attr:ri,check_outros:od,create_component:x0,destroy_component:v0,destroy_each:ad,detach:cs,element:oi,ensure_array_like:Hn,flush:ji,group_outros:ld,init:k0,insert:us,listen:ka,mount_component:A0,safe_not_equal:S0,set_style:ti,space:qn,toggle_class:ht,transition_in:Ei,transition_out:Js}=window.__gradio__svelte__internal,{createEventDispatcher:C0}=window.__gradio__svelte__internal;function th(s,e,t){const i=s.slice();i[17]=e[t],i[21]=t;const n=en(i[17]);i[18]=n;const r=i[6](i[17]);return i[19]=r,i}function ih(s,e,t){const i=s.slice();i[22]=e[t],i[21]=t;const n=en(i[22]);i[18]=n;const r=i[6](i[22]);return i[19]=r,i}function sh(s){let e;return{c(){e=oi("span"),ri(e,"class","svelte-1ngpqve"),ht(e,"lg",s[2])},m(t,i){us(t,e,i)},p(t,i){i&4&&ht(e,"lg",t[2])},d(t){t&&cs(e)}}}function nh(s){let e,t,i,n,r,o,a,l=s[0]&&rh(s),h=Hn(s[2]),c=[];for(let u=0;u<h.length;u+=1)c[u]=oh(ih(s,h,u));return{c(){e=oi("div"),l&&l.c(),t=qn();for(let u=0;u<c.length;u+=1)c[u].c();i=qn(),n=oi("button"),ri(n,"class","color colorpicker svelte-1ngpqve"),ht(n,"hidden",!s[0]),ri(e,"class","swatch svelte-1ngpqve")},m(u,d){us(u,e,d),l&&l.m(e,null),rs(e,t);for(let _=0;_<c.length;_+=1)c[_]&&c[_].m(e,null);rs(e,i),rs(e,n),r=!0,o||(a=ka(n,"click",s[8]),o=!0)},p(u,d){if(u[0]?l?(l.p(u,d),d&1&&Ei(l,1)):(l=rh(u),l.c(),Ei(l,1),l.m(e,t)):l&&(ld(),Js(l,1,1,()=>{l=null}),od()),d&206){h=Hn(u[2]);let _;for(_=0;_<h.length;_+=1){const f=ih(u,h,_);c[_]?c[_].p(f,d):(c[_]=oh(f),c[_].c(),c[_].m(e,i))}for(;_<c.length;_+=1)c[_].d(1);c.length=h.length}(!r||d&1)&&ht(n,"hidden",!u[0])},i(u){r||(Ei(l),r=!0)},o(u){Js(l),r=!1},d(u){u&&cs(e),l&&l.d(),ad(c,u),o=!1,a()}}}function rh(s){let e,t;return e=new Ze({props:{Icon:Ic,roundedness:"very",background:en(s[1]),color:"white"}}),e.$on("click",s[12]),{c(){x0(e.$$.fragment)},m(i,n){A0(e,i,n),t=!0},p(i,n){const r={};n&2&&(r.background=en(i[1])),e.$set(r)},i(i){t||(Ei(e.$$.fragment,i),t=!0)},o(i){Js(e.$$.fragment,i),t=!1},d(i){v0(e,i)}}}function oh(s){let e,t,i;function n(){return s[13](s[21],s[18],s[19])}return{c(){e=oi("button"),ri(e,"class","color svelte-1ngpqve"),ti(e,"background-color",s[18]),ht(e,"empty",s[22]===null),ht(e,"selected",`${s[18]}-${s[19]}`==`${s[1]}-${s[3]}`),ti(e,"opacity",s[19])},m(r,o){us(r,e,o),t||(i=ka(e,"click",n),t=!0)},p(r,o){s=r,o&4&&ti(e,"background-color",s[18]),o&4&&ht(e,"empty",s[22]===null),o&78&&ht(e,"selected",`${s[18]}-${s[19]}`==`${s[1]}-${s[3]}`);const a=o&4;(o&4||a)&&ti(e,"opacity",s[19])},d(r){r&&cs(e),t=!1,i()}}}function ah(s){let e,t,i;function n(){return s[14](s[21],s[18],s[19])}return{c(){e=oi("button"),ri(e,"class","color svelte-1ngpqve"),ti(e,"background-color",s[18]),ht(e,"empty",s[17]===null),ht(e,"selected",`${s[18]}-${s[19]}`==`${s[1]}-${s[3]}`),ti(e,"opacity",s[19])},m(r,o){us(r,e,o),t||(i=ka(e,"click",n),t=!0)},p(r,o){s=r,o&16&&ti(e,"background-color",s[18]),o&16&&ht(e,"empty",s[17]===null),o&90&&ht(e,"selected",`${s[18]}-${s[19]}`==`${s[1]}-${s[3]}`);const a=o&16;(o&16||a)&&ti(e,"opacity",s[19])},d(r){r&&cs(e),t=!1,i()}}}function M0(s){let e,t,i,n,r,o,a=!s[0]&&sh(s),l=s[2]&&nh(s),h=Hn(s[4]),c=[];for(let u=0;u<h.length;u+=1)c[u]=ah(th(s,h,u));return{c(){a&&a.c(),e=qn(),t=oi("div"),i=oi("div"),l&&l.c(),n=qn(),r=oi("menu");for(let u=0;u<c.length;u+=1)c[u].c();ri(r,"class","swatch svelte-1ngpqve"),ri(i,"class","swatch-container svelte-1ngpqve"),ri(t,"class","swatch-wrap svelte-1ngpqve")},m(u,d){a&&a.m(u,d),us(u,e,d),us(u,t,d),rs(t,i),l&&l.m(i,null),rs(i,n),rs(i,r);for(let _=0;_<c.length;_+=1)c[_]&&c[_].m(r,null);o=!0},p(u,[d]){if(u[0]?a&&(a.d(1),a=null):a?a.p(u,d):(a=sh(u),a.c(),a.m(e.parentNode,e)),u[2]?l?(l.p(u,d),d&4&&Ei(l,1)):(l=nh(u),l.c(),Ei(l,1),l.m(i,n)):l&&(ld(),Js(l,1,1,()=>{l=null}),od()),d&218){h=Hn(u[4]);let _;for(_=0;_<h.length;_+=1){const f=th(u,h,_);c[_]?c[_].p(f,d):(c[_]=ah(f),c[_].c(),c[_].m(r,null))}for(;_<c.length;_+=1)c[_].d(1);c.length=h.length}},i(u){o||(Ei(l),o=!0)},o(u){Js(l),o=!1},d(u){u&&(cs(e),cs(t)),a&&a.d(u),l&&l.d(),ad(c,u)}}}function en(s){return Array.isArray(s)?s[0]:s}function T0(s,e,t){let i,n,{selected_color:r}=e,{colors:o}=e,{user_colors:a=[]}=e,{show_empty:l=!1}=e,{current_mode:h="hex"}=e,{color_picker:c=!1}=e;const u=C0();function d(y){return Array.isArray(y)?y[1]:je(y).getAlpha()}function _(y,w){const A=en(y);return w==="hex"?je(A).toHexString():w==="rgb"?je(A).toRgbString():je(A).toHslString()}`${o.findIndex(y=>_(y,h)===_(r,h))}`;function f(y,w){`${y}${w.index}`,u(y,w)}function g(){u("select",{index:null,color:r}),t(0,c=!c)}const p=()=>u("add_color"),m=(y,w,A)=>
296f("edit",{index:y,color:w,opacity:A}),b=(y,w,A)=>f("select",{index:y,color:w,opacity:A});return s.$$set=y=>{"selected_color"in y&&t(1,r=y.selected_color),"colors"in y&&t(9,o=y.colors),"user_colors"in y&&t(2,a=y.user_colors),"show_empty"in y&&t(10,l=y.show_empty),"current_mode"in y&&t(11,h=y.current_mode),"color_picker"in y&&t(0,c=y.color_picker)},s.$$.update=()=>{s.$$.dirty&1536&&t(4,i=l?o:o.filter(y=>y)),s.$$.dirty&2&&t(3,n=d(r))},[c,r,a,n,i,u,d,f,g,o,l,h,p,m,b]}class P0 extends w0{constructor(e){super(),k0(this,e,T0,M0,S0,{selected_color:1,colors:9,user_colors:2,show_empty:10,current_mode:11,color_picker:0})}get selected_color(){return this.$$.ctx[1]}set selected_color(e){this.$$set({selected_color:e}),ji()}get colors(){return this.$$.ctx[9]}set colors(e){this.$$set({colors:e}),ji()}get user_colors(){return this.$$.ctx[2]}set user_colors(e){this.$$set({user_colors:e}),ji()}get show_empty(){return this.$$.ctx[10]}set show_empty(e){this.$$set({show_empty:e}),ji()}get current_mode(){return this.$$.ctx[11]}set current_mode(e){this.$$set({current_mode:e}),ji()}get color_picker(){return this.$$.ctx[0]}set color_picker(e){this.$$set({color_picker:e}),ji()}}const{SvelteComponent:z0,append:Gt,attr:Zt,create_component:I0,destroy_component:E0,destroy_each:R0,detach:hd,element:Qt,ensure_array_like:lh,flush:hh,init:F0,insert:cd,listen:Bn,mount_component:B0,run_all:L0,safe_not_equal:$0,set_style:ch,space:mo,toggle_class:uh,transition_in:ud,transition_out:dd}=window.__gradio__svelte__internal,{createEventDispatcher:O0}=window.__gradio__svelte__internal;function dh(s,e,t){const i=s.slice();return i[11]=e[t][0],i[12]=e[t][1],i}function G0(s){let e,t;return e=new o_({}),{c(){I0(e.$$.fragment)},m(i,n){B0(e,i,n),t=!0},i(i){t||(ud(e.$$.fragment,i),t=!0)},o(i){dd(e.$$.fragment,i),t=!1},d(i){E0(e,i)}}}function _h(s){let e,t,i;function n(){return s[8](s[12])}return{c(){e=Qt("button"),e.textContent=`${s[11]}`,Zt(e,"class","button svelte-w84deg"),uh(e,"active",s[1]===s[12])},m(r,o){cd(r,e,o),t||(i=Bn(e,"click",n),t=!0)},p(r,o){s=r,o&10&&uh(e,"active",s[1]===s[12])},d(r){r&&hd(e),t=!1,i()}}}function N0(s){let e,t,i,n,r,o,a,l,h,c,u,d,_,f=s[5]&&G0(),g=lh(s[3]),p=[];for(let m=0;m<g.length;m+=1)p[m]=_h(dh(s,g,m));return{c(){e=Qt("div"),t=Qt("button"),i=mo(),n=Qt("div"),r=Qt("div"),o=Qt("input"),a=mo(),l=Qt("button"),f&&f.c(),h=mo(),c=Qt("div");for(let m=0;m<p.length;m+=1)p[m].c();Zt(t,"class","swatch svelte-w84deg"),ch(t,"background",s[0]),Zt(o,"type","text"),o.value=s[2],Zt(o,"class","svelte-w84deg"),Zt(l,"class","eyedropper svelte-w84deg"),Zt(r,"class","input-wrap svelte-w84deg"),Zt(c,"class","buttons svelte-w84deg"),Zt(e,"class","input svelte-w84deg")},m(m,b){cd(m,e,b),Gt(e,t),Gt(e,i),Gt(e,n),Gt(n,r),Gt(r,o),Gt(r,a),Gt(r,l),f&&f.m(l,null),Gt(n,h),Gt(n,c);for(let y=0;y<p.length;y+=1)p[y]&&p[y].m(c,null);u=!0,d||(_=[Bn(t,"click",s[6]),Bn(o,"change",s[7]),Bn(l,"click",s[4])],d=!0)},p(m,[b]){if(b&1&&ch(t,"background",m[0]),(!u||b&4&&o.value!==m[2])&&(o.value=m[2]),b&10){g=lh(m[3]);let y;for(y=0;y<g.length;y+=1){const w=dh(m,g,y);p[y]?p[y].p(w,b):(p[y]=_h(w),p[y].c(),p[y].m(c,null))}for(;y<p.length;y+=1)p[y].d(1);p.length=g.length}},i(m){u||(ud(f),u=!0)},o(m){dd(f),u=!1},d(m){m&&hd(e),f&&f.d(),R0(p,m),d=!1,L0(_)}}}function D0(s,e,t){let i,{color:n}=e,{current_mode:r="hex"}=e;const o=O0(),a=[["Hex","hex"],["RGB","rgb"],["HSL","hsl"]];function l(f,g){return g==="hex"?je(f).toHexString():g==="rgb"?je(f).toRgbString():je(f).toHslString()}function h(){new EyeDropper().open().then(g=>{t(0,n=g.sRGBHex)})}const c=!!window.EyeDropper;function u(){o("selected",i),o("close")}const d=f=>t(0,n=f.currentTarget.value),_=f=>t(1,r=f);return s.$$set=f=>{"color"in f&&t(0,n=f.color),"current_mode"in f&&t(1,r=f.current_mode)},s.$$.update=()=>{s.$$.dirty&3&&t(2,i=l(n,r)),s.$$.dirty&4&&i&&o("selected",i)},[n,r,i,a,h,c,u,d,_]}class U0 extends z0{constructor(e){super(),F0(this,e,D0,N0,$0,{color:0,current_mode:1})}get color(){return this.$$.ctx[0]}set color(e){this.$$set({color:e}),hh()}get current_mode(){return this.$$.ctx[1]}set current_mode(e){this.$$set({current_mode:e}),hh()}}const{SvelteComponent:W0,action_destroyer:H0,append:bo,attr:Nt,create_component:q0,destroy_component:V0,detach:X0,element:yo,flush:wo,init:Y0,insert:j0,listen:fh,mount_component:K0,run_all:Z0,safe_not_equal:Q0,set_input_value:gh,space:J0,to_number:ey,transition_in:ty,transition_out:iy}=window.__gradio__svelte__internal,{createEventDispatcher:sy}=window.__gradio__svelte__internal;function ny(s){let e,t,i,n,r,o,a,l;return i=new N_({}),{c(){e=yo("div"),t=yo("span"),q0(i.$$.fragment),n=J0(),r=yo("input"),Nt(t,"class","svelte-1ktybyw"),Nt(r,"type","range"),Nt(r,"min",s[1]),Nt(r,"max",s[2]),Nt(r,"step",1),Nt(r,"class","svelte-1ktybyw"),Nt(e,"class","wrap svelte-1ktybyw")},m(h,c){j0(h,e,c),bo(e,t),K0(i,t,null),bo(e,n),bo(e,r),gh(r,s[0]),o=!0,a||(l=[fh(r,"change",s[4]),fh(r,"input",s[4]),H0(la.call(null,e,s[5]))],a=!0)},p(h,[c]){(!o||c&2)&&Nt(r,"min",h[1]),(!o||c&4)&&Nt(r,"max",h[2]),c&1&&gh(r,h[0])},i(h){o||(ty(i.$$.fragment,h),o=!0)},o(h){iy(i.$$.fragment,h),o=!1},d(h){h&&X0(e),V0(i),a=!1,Z0(l)}}}function ry(s,e,t){let{selected_size:i}=e,{min:n}=e,{max:r}=e;const o=sy();function a(){i=ey(this.value),t(0,i)}const l=()=>o("click_outside");return s.$$set=h=>{"selected_size"in h&&t(0,i=h.selected_size),"min"in h&&t(1,n=h.min),"max"in h&&t(2,r=h.max)},[i,n,r,o,a,l]}class oy extends W0{constructor(e){super(),Y0(this,e,ry,ny,Q0,{selected_size:0,min:1,max:2})}get selected_size(){return this.$$.ctx[0]}set selected_size(e){this.$$set({selected_size:e}),wo()}get min(){return this.$$.ctx[1]}set min(e){this.$$set({min:e}),wo()}get max(){return this.$$.ctx[2]}set max(e){this.$$set({max:e}),wo()}}const{SvelteComponent:ay,action_destroyer:ly,add_flush_callback:Us,add_render_callback:hy,append:ph,attr:cy,bind:Ws,binding_callbacks:Hs,check_outros:Ln,create_component:Vn,destroy_component:Xn,detach:Aa,element:uy,empty:dy,flush:zt,group_outros:$n,init:_y,insert:Sa,listen:fy,mount_component:Yn,run_all:gy,safe_not_equal:py,space:Qo,toggle_class:jt,transition_in:Ee,transition_out:rt}=window.__gradio__svelte__internal,{createEventDispatcher:my,tick:o2}=window.__gradio__svelte__internal;function mh(s){let e,t,i=s[9]&&bh(s);return{c(){i&&i.c(),e=dy()},m(n,r){i&&i.m(n,r),Sa(n,e,r),t=!0},p(n,r){n[9]?i?(i.p(n,r),r[0]&512&&Ee(i,1)):(i=bh(n),i.c(),Ee(i,1),i.m(e.parentNode,e)):i&&($n(),rt(i,1,1,()=>{i=null}),Ln())},i(n){t||(Ee(i),t=!0)},o(n){rt(i),t=!1},d(n){n&&Aa(e),i&&i.d(n)}}}function bh(s){let e,t,i,n,r,o,a;function l(_){s[19](_)}function h(_){s[20](_)}let c={};s[0]!==void 0&&(c.color=s[0]),s[3]!==void 0&&(c.opacity=s[3]),e=new y0({props:c}),Hs.push(()=>Ws(e,"color",l)),Hs.push(()=>Ws(e,"opacity",h));function u(_){s[21](_)}let d={color:s[0]};
296return s[10]!==void 0&&(d.current_mode=s[10]),r=new U0({props:d}),Hs.push(()=>Ws(r,"current_mode",u)),r.$on("close",s[22]),r.$on("selected",s[23]),{c(){Vn(e.$$.fragment),n=Qo(),Vn(r.$$.fragment)},m(_,f){Yn(e,_,f),Sa(_,n,f),Yn(r,_,f),a=!0},p(_,f){const g={};!t&&f[0]&1&&(t=!0,g.color=_[0],Us(()=>t=!1)),!i&&f[0]&8&&(i=!0,g.opacity=_[3],Us(()=>i=!1)),e.$set(g);const p={};f[0]&1&&(p.color=_[0]),!o&&f[0]&1024&&(o=!0,p.current_mode=_[10],Us(()=>o=!1)),r.$set(p)},i(_){a||(Ee(e.$$.fragment,_),Ee(r.$$.fragment,_),a=!0)},o(_){rt(e.$$.fragment,_),rt(r.$$.fragment,_),a=!1},d(_){_&&Aa(n),Xn(e,_),Xn(r,_)}}}function yh(s){let e,t,i;function n(o){s[24](o)}let r={colors:s[4],user_colors:s[5]==="defaults"?s[2]:null,selected_color:s[0],current_mode:s[10]};return s[9]!==void 0&&(r.color_picker=s[9]),e=new P0({props:r}),Hs.push(()=>Ws(e,"color_picker",n)),e.$on("select",s[25]),e.$on("edit",s[26]),e.$on("add_color",s[16]),{c(){Vn(e.$$.fragment)},m(o,a){Yn(e,o,a),i=!0},p(o,a){const l={};a[0]&16&&(l.colors=o[4]),a[0]&36&&(l.user_colors=o[5]==="defaults"?o[2]:null),a[0]&1&&(l.selected_color=o[0]),a[0]&1024&&(l.current_mode=o[10]),!t&&a[0]&512&&(t=!0,l.color_picker=o[9],Us(()=>t=!1)),e.$set(l)},i(o){i||(Ee(e.$$.fragment,o),i=!0)},o(o){rt(e.$$.fragment,o),i=!1},d(o){Xn(e,o)}}}function wh(s){let e,t,i;function n(o){s[27](o)}let r={max:100,min:1};return s[1]!==void 0&&(r.selected_size=s[1]),e=new oy({props:r}),Hs.push(()=>Ws(e,"selected_size",n)),{c(){Vn(e.$$.fragment)},m(o,a){Yn(e,o,a),i=!0},p(o,a){const l={};!t&&a[0]&2&&(t=!0,l.selected_size=o[1],Us(()=>t=!1)),e.$set(l)},i(o){i||(Ee(e.$$.fragment,o),i=!0)},o(o){rt(e.$$.fragment,o),i=!1},d(o){Xn(e,o)}}}function by(s){let e,t,i,n,r,o;hy(s[18]);let a=s[5]==="defaults"&&mh(s),l=s[6]&&yh(s),h=s[7]&&wh(s);return{c(){e=uy("div"),a&&a.c(),t=Qo(),l&&l.c(),i=Qo(),h&&h.c(),cy(e,"class","wrap svelte-qigu2l"),jt(e,"padded",!s[9]),jt(e,"color_picker",s[9]),jt(e,"size_picker",s[7]&&s[8]==="brush"),jt(e,"eraser_picker",s[8]==="eraser")},m(c,u){Sa(c,e,u),a&&a.m(e,null),ph(e,t),l&&l.m(e,null),ph(e,i),h&&h.m(e,null),n=!0,r||(o=[fy(window,"resize",s[18]),ly(la.call(null,e,s[28]))],r=!0)},p(c,u){c[5]==="defaults"?a?(a.p(c,u),u[0]&32&&Ee(a,1)):(a=mh(c),a.c(),Ee(a,1),a.m(e,t)):a&&($n(),rt(a,1,1,()=>{a=null}),Ln()),c[6]?l?(l.p(c,u),u[0]&64&&Ee(l,1)):(l=yh(c),l.c(),Ee(l,1),l.m(e,i)):l&&($n(),rt(l,1,1,()=>{l=null}),Ln()),c[7]?h?(h.p(c,u),u[0]&128&&Ee(h,1)):(h=wh(c),h.c(),Ee(h,1),h.m(e,null)):h&&($n(),rt(h,1,1,()=>{h=null}),Ln()),(!n||u[0]&512)&&jt(e,"padded",!c[9]),(!n||u[0]&512)&&jt(e,"color_picker",c[9]),(!n||u[0]&384)&&jt(e,"size_picker",c[7]&&c[8]==="brush"),(!n||u[0]&256)&&jt(e,"eraser_picker",c[8]==="eraser")},i(c){n||(Ee(a),Ee(l),Ee(h),n=!0)},o(c){rt(a),rt(l),rt(h),n=!1},d(c){c&&Aa(e),a&&a.d(),l&&l.d(),h&&h.d(),r=!1,gy(o)}}}function yy(s,e){let t;return function(...i){clearTimeout(t),t=setTimeout(()=>s(...i),e)}}function wy(s,e,t){let{colors:i}=e,{selected_color:n}=e,{color_mode:r=void 0}=e,{recent_colors:o=[]}=e,{selected_size:a}=e,{selected_opacity:l}=e,{show_swatch:h}=e,{show_size:c}=e,{mode:u="brush"}=e,d=!1,_="hex",f=null;const g=my();function p({index:I,color:G,opacity:ye},we){we==="user"&&!G&&(f=I,t(9,d=!0)),G&&(t(0,n=G),ye!==void 0&&t(3,l=ye),we==="core"&&t(9,d=!1))}function m(I){f!==null&&t(2,o[f]=I,o)}let b=0,y=0,{preview:w=!1}=e;function A(){w||t(17,w=!0),x()}function k(){t(17,w=!1)}const x=yy(k,1e3);function C(I){t(0,n=I)}function S(){o.length>=5&&o.pop(),!o.some(I=>Array.isArray(I)?I[0]===n&&I[1]===l:I===n)&&(o.push([n,l]),t(2,o))}function T(){t(12,y=window.innerHeight),t(11,b=window.innerWidth)}function E(I){n=I,t(0,n)}function D(I){l=I,t(3,l)}function X(I){_=I,t(10,_)}const F=()=>t(9,d=!1),q=({detail:I})=>C(I);function R(I){d=I,t(9,d)}const B=({detail:I})=>p(I,"core"),ze=({detail:I})=>p(I,"user");function W(I){a=I,t(1,a)}const ee=()=>g("click_outside");return s.$$set=I=>{"colors"in I&&t(4,i=I.colors),"selected_color"in I&&t(0,n=I.selected_color),"color_mode"in I&&t(5,r=I.color_mode),"recent_colors"in I&&t(2,o=I.recent_colors),"selected_size"in I&&t(1,a=I.selected_size),"selected_opacity"in I&&t(3,l=I.selected_opacity),"show_swatch"in I&&t(6,h=I.show_swatch),"show_size"in I&&t(7,c=I.show_size),"mode"in I&&t(8,u=I.mode),"preview"in I&&t(17,w=I.preview)},s.$$.update=()=>{s.$$.dirty[0]&1&&m(n),s.$$.dirty[0]&3&&A()},[n,a,o,l,i,r,h,c,u,d,_,b,y,g,p,C,S,w,T,E,D,X,F,q,R,B,ze,W,ee]}class _d extends ay{constructor(e){super(),_y(this,e,wy,by,py,{colors:4,selected_color:0,color_mode:5,recent_colors:2,selected_size:1,selected_opacity:3,show_swatch:6,show_size:7,mode:8,preview:17},null,[-1,-1])}get colors(){return this.$$.ctx[4]}set colors(e){this.$$set({colors:e}),zt()}get selected_color(){return this.$$.ctx[0]}set selected_color(e){this.$$set({selected_color:e}),zt()}get color_mode(){return this.$$.ctx[5]}set color_mode(e){this.$$set({color_mode:e}),zt()}get recent_colors(){return this.$$.ctx[2]}set recent_colors(e){this.$$set({recent_colors:e}),zt()}get selected_size(){return this.$$.ctx[1]}set selected_size(e){this.$$set({selected_size:e}),zt()}get selected_opacity(){return this.$$.ctx[3]}set selected_opacity(e){this.$$set({selected_opacity:e}),zt()}get show_swatch(){return this.$$.ctx[6]}set show_swatch(e){this.$$set({show_swatch:e}),zt()}get show_size(){return this.$$.ctx[7]}set show_size(e){this.$$set({show_size:e}),zt()}get mode(){return this.$$.ctx[8]}set mode(e){this.$$set({mode:e}),zt()}get preview(){return this.$$.ctx[17]}set preview(e){this.$$set({preview:e}),zt()}}const{SvelteComponent:xy,add_flush_callback:ii,append:Kt,attr:xo,bind:si,binding_callbacks:ni,check_outros:Ue,create_component:Qe,destroy_component:Je,detach:Bt,element:vo,empty:rr,flush:Le,group_outros:We,init:vy,insert:Lt,mount_component:et,safe_not_equal:ky,space:pt,toggle_class:xh,transition_in:O,transition_out:H}=window.__gradio__svelte__internal,{createEventDispatcher:Ay}=window.__gradio__svelte__internal;function vh(s){let e,t;return e=new Ze({props:{Icon:Pc,label:"Image",highlight:s[8]==="image",size:"medium",padded:!1,transparent:!0}}
vendor: 4,416 bytes, line 296
296),e.$on("click",s[23]),{c(){Qe(e.$$.fragment)},m(i,n){et(e,i,n),t=!0},p(i,n){const r={};n[0]&256&&(r.highlight=i[8]==="image"),e.$set(r)},i(i){t||(O(e.$$.fragment,i),t=!0)},o(i){H(e.$$.fragment,i),t=!1},d(i){Je(e,i)}}}function kh(s){let e,t;return e=new Ze({props:{Icon:E_,label:"Brush",highlight:s[8]==="draw",size:"medium",padded:!1,transparent:!0}}),e.$on("click",s[24]),{c(){Qe(e.$$.fragment)},m(i,n){et(e,i,n),t=!0},p(i,n){const r={};n[0]&256&&(r.highlight=i[8]==="draw"),e.$set(r)},i(i){t||(O(e.$$.fragment,i),t=!0)},o(i){H(e.$$.fragment,i),t=!1},d(i){Je(e,i)}}}function Ah(s){let e,t;return e=new Ze({props:{Icon:cf,label:"Erase",highlight:s[8]==="erase",size:"medium",padded:!1,transparent:!0}}),e.$on("click",s[25]),{c(){Qe(e.$$.fragment)},m(i,n){et(e,i,n),t=!0},p(i,n){const r={};n[0]&256&&(r.highlight=i[8]==="erase"),e.$set(r)},i(i){t||(O(e.$$.fragment,i),t=!0)},o(i){H(e.$$.fragment,i),t=!1},d(i){Je(e,i)}}}function Sh(s){let e,t,i,n;const r=[Cy,Sy],o=[];function a(l,h){return l[10]?0:1}return e=a(s),t=o[e]=r[e](s),{c(){t.c(),i=rr()},m(l,h){o[e].m(l,h),Lt(l,i,h),n=!0},p(l,h){let c=e;e=a(l),e===c?o[e].p(l,h):(We(),H(o[c],1,1,()=>{o[c]=null}),Ue(),t=o[e],t?t.p(l,h):(t=o[e]=r[e](l),t.c()),O(t,1),t.m(i.parentNode,i))},i(l){n||(O(t),n=!0)},o(l){H(t),n=!1},d(l){l&&Bt(i),o[e].d(l)}}}function Sy(s){let e,t,i,n,r=s[17]&&Ch(s),o=s[15]&&Mh(s),a=s[16]&&Th(s);return{c(){r&&r.c(),e=pt(),o&&o.c(),t=pt(),a&&a.c(),i=rr()},m(l,h){r&&r.m(l,h),Lt(l,e,h),o&&o.m(l,h),Lt(l,t,h),a&&a.m(l,h),Lt(l,i,h),n=!0},p(l,h){l[17]?r?(r.p(l,h),h[0]&131072&&O(r,1)):(r=Ch(l),r.c(),O(r,1),r.m(e.parentNode,e)):r&&(We(),H(r,1,1,()=>{r=null}),Ue()),l[15]?o?(o.p(l,h),h[0]&32768&&O(o,1)):(o=Mh(l),o.c(),O(o,1),o.m(t.parentNode,t)):o&&(We(),H(o,1,1,()=>{o=null}),Ue()),l[16]?a?(a.p(l,h),h[0]&65536&&O(a,1)):(a=Th(l),a.c(),O(a,1),a.m(i.parentNode,i)):a&&(We(),H(a,1,1,()=>{a=null}),Ue())},i(l){n||(O(r),O(o),O(a),n=!0)},o(l){H(r),H(o),H(a),n=!1},d(l){l&&(Bt(e),Bt(t),Bt(i)),r&&r.d(l),o&&o.d(l),a&&a.d(l)}}}function Cy(s){let e,t,i,n=s[19]&&Ph(s),r=s[18]&&zh(s);return{c(){n&&n.c(),e=pt(),r&&r.c(),t=rr()},m(o,a){n&&n.m(o,a),Lt(o,e,a),r&&r.m(o,a),Lt(o,t,a),i=!0},p(o,a){o[19]?n?(n.p(o,a),a[0]&524288&&O(n,1)):(n=Ph(o),n.c(),O(n,1),n.m(e.parentNode,e)):n&&(We(),H(n,1,1,()=>{n=null}),Ue()),o[18]?r?(r.p(o,a),a[0]&262144&&O(r,1)):(r=zh(o),r.c(),O(r,1),r.m(t.parentNode,t)):r&&(We(),H(r,1,1,()=>{r=null}),Ue())},i(o){i||(O(n),O(r),i=!0)},o(o){H(n),H(r),i=!1},d(o){o&&(Bt(e),Bt(t)),n&&n.d(o),r&&r.d(o)}}}function Ch(s){let e,t;return e=new Ze({props:{Icon:i_,label:"Upload",highlight:s[9]==="upload",size:"medium",padded:!1,transparent:!0,offset:0}}),e.$on("click",s[28]),{c(){Qe(e.$$.fragment)},m(i,n){et(e,i,n),t=!0},p(i,n){const r={};n[0]&512&&(r.highlight=i[9]==="upload"),e.$set(r)},i(i){t||(O(e.$$.fragment,i),t=!0)},o(i){H(e.$$.fragment,i),t=!1},d(i){Je(e,i)}}}function Mh(s){let e,t;return e=new Ze({props:{Icon:s_,label:"Paste",highlight:s[9]==="paste",size:"large",padded:!1,transparent:!0,offset:0}}),e.$on("click",s[29]),{c(){Qe(e.$$.fragment)},m(i,n){et(e,i,n),t=!0},p(i,n){const r={};n[0]&512&&(r.highlight=i[9]==="paste"),e.$set(r)},i(i){t||(O(e.$$.fragment,i),t=!0)},o(i){H(e.$$.fragment,i),t=!1},d(i){Je(e,i)}}}function Th(s){let e,t;return e=new Ze({props:{Icon:r_,label:"Webcam",highlight:s[9]==="webcam",size:"medium",padded:!1,transparent:!0,offset:0}}),e.$on("click",s[30]),{c(){Qe(e.$$.fragment)},m(i,n){et(e,i,n),t=!0},p(i,n){const r={};n[0]&512&&(r.highlight=i[9]==="webcam"),e.$set(r)},i(i){t||(O(e.$$.fragment,i),t=!0)},o(i){H(e.$$.fragment,i),t=!1},d(i){Je(e,i)}}}function Ph(s){let e,t;return e=new Ze({props:{Icon:sf,label:"Crop",highlight:s[9]==="crop",size:"medium",padded:!1,transparent:!0,offset:0}}),e.$on("click",s[26]),{c(){Qe(e.$$.fragment)},m(i,n){et(e,i,n),t=!0},p(i,n){const r={};n[0]&512&&(r.highlight=i[9]==="crop"),e.$set(r)},i(i){t||(O(e.$$.fragment,i),t=!0)},o(i){H(e.$$.fragment,i),t=!1},d(i){Je(e,i)}}}function zh(s){let e,t;return e=new Ze({props:{Icon:ig,label:"Resize",highlight:s[9]==="size",size:"medium",padded:!1,transparent:!0,offset:0}}),e.$on("click",s[27]),{c(){Qe(e.$$.fragment)},m(i,n){et(e,i,n),t=!0},p(i,n){const r={};n[0]&512&&(r.highlight=i[9]==="size"),e.$set(r)},i(i){t||(O(e.$$.fragment,i),t=!0)},o(i){H(e.$$.fragment,i),t=!1},d(i){Je(e,i)}}}function Ih(s){let e,t,i,n,r,o;e=new Ze({props:{Icon:Y_,label:"Color",color:s[2],size:"medium",padded:!1,transparent:!0,offset:0}}
296),e.$on("click",s[31]),i=new Ze({props:{Icon:Cc,label:"Brush Size",highlight:s[9]==="size",size:"medium",padded:!1,transparent:!0,offset:0}}),i.$on("click",s[32]);let a=(s[5]||s[6])&&Eh(s);return{c(){Qe(e.$$.fragment),t=pt(),Qe(i.$$.fragment),n=pt(),a&&a.c(),r=rr()},m(l,h){et(e,l,h),Lt(l,t,h),et(i,l,h),Lt(l,n,h),a&&a.m(l,h),Lt(l,r,h),o=!0},p(l,h){const c={};h[0]&4&&(c.color=l[2]),e.$set(c);const u={};h[0]&512&&(u.highlight=l[9]==="size"),i.$set(u),l[5]||l[6]?a?(a.p(l,h),h[0]&96&&O(a,1)):(a=Eh(l),a.c(),O(a,1),a.m(r.parentNode,r)):a&&(We(),H(a,1,1,()=>{a=null}),Ue())},i(l){o||(O(e.$$.fragment,l),O(i.$$.fragment,l),O(a),o=!0)},o(l){H(e.$$.fragment,l),H(i.$$.fragment,l),H(a),o=!1},d(l){l&&(Bt(t),Bt(n),Bt(r)),Je(e,l),Je(i,l),a&&a.d(l)}}}function Eh(s){let e,t,i,n,r,o;function a(d){s[33](d)}function l(d){s[34](d)}function h(d){s[35](d)}function c(d){s[36](d)}let u={colors:s[11].colors,color_mode:s[11].color_mode,recent_colors:s[20],show_swatch:s[5],show_size:s[6],mode:"brush"};return s[0]!==void 0&&(u.selected_size=s[0]),s[2]!==void 0&&(u.selected_color=s[2]),s[3]!==void 0&&(u.selected_opacity=s[3]),s[4]!==void 0&&(u.preview=s[4]),e=new _d({props:u}),ni.push(()=>si(e,"selected_size",a)),ni.push(()=>si(e,"selected_color",l)),ni.push(()=>si(e,"selected_opacity",h)),ni.push(()=>si(e,"preview",c)),e.$on("click_outside",s[37]),{c(){Qe(e.$$.fragment)},m(d,_){et(e,d,_),o=!0},p(d,_){const f={};_[0]&2048&&(f.colors=d[11].colors),_[0]&2048&&(f.color_mode=d[11].color_mode),_[0]&32&&(f.show_swatch=d[5]),_[0]&64&&(f.show_size=d[6]),!t&&_[0]&1&&(t=!0,f.selected_size=d[0],ii(()=>t=!1)),!i&&_[0]&4&&(i=!0,f.selected_color=d[2],ii(()=>i=!1)),!n&&_[0]&8&&(n=!0,f.selected_opacity=d[3],ii(()=>n=!1)),!r&&_[0]&16&&(r=!0,f.preview=d[4],ii(()=>r=!1)),e.$set(f)},i(d){o||(O(e.$$.fragment,d),o=!0)},o(d){H(e.$$.fragment,d),o=!1},d(d){Je(e,d)}}}function Rh(s){let e,t;return e=new Ze({props:{Icon:Cc,label:"Eraser Size",highlight:s[9]==="size",size:"medium",padded:!1,transparent:!0,offset:0}}),e.$on("click",s[38]),{c(){Qe(e.$$.fragment)},m(i,n){et(e,i,n),t=!0},p(i,n){const r={};n[0]&512&&(r.highlight=i[9]==="size"),e.$set(r)},i(i){t||(O(e.$$.fragment,i),t=!0)},o(i){H(e.$$.fragment,i),t=!1},d(i){Je(e,i)}}}function Fh(s){let e,t,i,n,r,o;function a(d){s[39](d)}function l(d){s[40](d)}function h(d){s[41](d)}function c(d){s[42](d)}let u={colors:[],show_swatch:!1,show_size:!0,mode:"eraser"};return s[1]!==void 0&&(u.selected_size=s[1]),s[2]!==void 0&&(u.selected_color=s[2]),s[3]!==void 0&&(u.selected_opacity=s[3]),s[4]!==void 0&&(u.preview=s[4]),e=new _d({props:u}),ni.push(()=>si(e,"selected_size",a)),ni.push(()=>si(e,"selected_color",l)),ni.push(()=>si(e,"selected_opacity",h)),ni.push(()=>si(e,"preview",c)),e.$on("click_outside",s[43]),{c(){Qe(e.$$.fragment)},m(d,_){et(e,d,_),o=!0},p(d,_){const f={};!t&&_[0]&2&&(t=!0,f.selected_size=d[1],ii(()=>t=!1)),!i&&_[0]&4&&(i=!0,f.selected_color=d[2],ii(()=>i=!1)),!n&&_[0]&8&&(n=!0,f.selected_opacity=d[3],ii(()=>n=!1)),!r&&_[0]&16&&(r=!0,f.preview=d[4],ii(()=>r=!1)),e.$set(f)},i(d){o||(O(e.$$.fragment,d),o=!0)},o(d){H(e.$$.fragment,d),o=!1},d(d){Je(e,d)}}}function My(s){let e,t,i,n,r,o,a,l,h,c,u=s[13].length>0&&vh(s),d=s[11]&&kh(s),_=s[12]&&Ah(s),f=s[8]==="image"&&Sh(s),g=s[8]==="draw"&&s[11]&&Ih(s),p=s[8]==="erase"&&s[12]&&Rh(s),m=s[7]&&Fh(s);return{c(){e=vo("div"),t=vo("div"),u&&u.c(),i=pt(),d&&d.c(),n=pt(),_&&_.c(),r=pt(),o=vo("div"),f&&f.c(),a=pt(),g&&g.c(),l=pt(),p&&p.c(),h=pt(),m&&m.c(),xo(t,"class","half-container svelte-1m5h684"),xo(o,"class","half-container right svelte-1m5h684"),xh(o,"hide",s[8]==="pan"||s[8]==="image"&&!s[10]&&s[13].length===0||s[8]==="image"&&s[10]&&s[14].length===0),xo(e,"class","toolbar-wrap svelte-1m5h684")},m(b,y){Lt(b,e,y),Kt(e,t),u&&u.m(t,null),Kt(t,i),d&&d.m(t,null),Kt(t,n),_&&_.m(t,null),Kt(e,r),Kt(e,o),f&&f.m(o,null),Kt(o,a),g&&g.m(o,null),Kt(o,l),p&&p.m(o,null),Kt(o,h),m&&m.m(o,null),c=!0},p(b,y){b[13].length>0?u?(u.p(b,y),y[0]&8192&&O(u,1)):(u=vh(b),u.c(),O(u,1),u.m(t,i)):u&&(We(),H(u,1,1,()=>{u=null}),Ue()),b[11]?d?(d.p(b,y),y[0]&2048&&O(d,1)):(d=kh(b),d.c(),O(d,1),d.m(t,n)):d&&(We(),H(d,1,1,()=>{d=null}),Ue()),b[12]?_?(_.p(b,y),y[0]&4096&&O(_,1)):(_=Ah(b),_.c(),O(_,1),_.m(t,null)):_&&(We(),H(_,1,1,()=>{_=null}),Ue()),b[8]==="image"?f?(f.p(b,y),y[0]&256&&O(f,1)):(f=Sh(b),f.c(),O(f,1),f.m(o,a)):f&&(We(),H(f,1,1,()=>{f=null}),Ue()),b[8]==="draw"&&b[11]?g?(g.p(b,y),y[0]&2304&&O(g,1)):(g=Ih(b),g.c(),O(g,1),g.m(o,l)):g&&(We(),H(g,1,1,()=>{g=null}),Ue()),b[8]==="erase"&&b[12]?p?(p.p(b,y),y[0]&4352&&O(p,1)):(p=Rh(b),p.c(),O(p,1),p.m(o,h)):p&&(We(),H(p,1,1,()=>{p=null}),Ue()),b[7]?m?(m.p(b,y),y[0]&128&&O(m,1)):(m=Fh(b),m.c(),O(m,1),m.m(o,null)):m&&(We(),H(m,1,1,()=>{m=null}),Ue()),(!c||y[0]&25856)&&xh(o,"hide",b[8]==="pan"||b[8]==="image"&&!b[10]&&b[13].length===0||b[8]==="image"&&b[10]&&b[14].length===0)},i(b){c||(O(u),O(d),O(_),O(f),O(g),O(p),O(m),c=!0)},o(b){H(u),H(d),H(_),H(f),H(g),H(p),H(m),c=!1},d(b){b&&Bt(e),u&&u.d(),d&&d.d(),_&&_.d(),f&&f.d(),g&&g.d(),p&&p.d(),m&&m.d()}}}function Ty(s,e,t){let i,n,r,o,a,{tool:l="image"}=e,{subtool:h=null}=e,{background:c=!1}=e,{brush_options:u}=e,{selected_size:d=u&&typeof u.default_size=="number"?u.default_size:25}=e,{eraser_options:_}=e,{selected_eraser_size:f=_&&typeof _.default_size=="number"?_.default_size:25}=e,{selected_color:g=u&&(()=>{const P=u.default_color;return Array.isArray(P)?P[0]:P})()}=e,{selected_opacity:p=u&&(()=>{const P=u.default_color;if(Array.isArray(P))return P[1];const le=je(P);return le.getAlpha()<1?le.getAlpha():1})()}=e,{preview:m=!1}=e,{show_brush_color:b=!1}=e,{show_brush_size:y=!1}=e,{show_eraser_size:w=!1}=e,{sources:A}=e,{transforms:k}=e,x=[];const C=Ay();function S(P,le){P.stopPropagation(),C("tool_change",{tool:le})}function T(P,le){P.stopPropagation(),C("subtool_change",{tool:l,subtool:le})}const E=P=>S(P,"image"),D=P=>S(P,"draw"),X=P=>S(P,"erase"),F=P=>T(P,"crop"),q=P=>T(P,"size"),R=P=>T(P,"upload"),B=P=>T(P,"paste"),ze=P=>T(P,"webcam"),W=P=>T(P,"color"),ee=P=>T(P,"size");function I(P){d=P,t(0,d)}function G(P){g=P,t(2,g)}function ye(P){p=P,t(3,p)}function we(P){m=P,t(4,m)}const xe=P=>{P.stopPropagation(),t(4,m=!1),t(5,b=!1),t(6,y=!1),T(P,null)},ge=P=>T(P,"size");function ve(P){f=P,t(1,f)}function ke(P){g=P,t(2,g)}function Ae(P){p=P,t(3,p)}function Pe(P){m=P,t(4,m)}const tt=P=>{P.stopPropagation(),t(4,m=!1),t(7,w=!1),T(P,null)};return s.$$set=P=>{"tool"in P&&t(8,l=P.tool),"subtool"in P&&t(9,h=P.subtool),"background"in P&&t(10,c=P.background),"brush_options"in P&&t(11,u=P.brush_options),"selected_size"in P&&t(0,d=P.selected_size),"eraser_options"in P&&t(12,_=P.eraser_options),"selected_eraser_size"in P&&t(1,f=P.selected_eraser_size),"selected_color"in P&&t(2,g=P.selected_color),"selected_opacity"in P&&t(3,p=P.selected_opacity),"preview"in P&&t(4,m=P.preview),"show_brush_color"in P&&t(5,b=P.show_brush_color),"show_brush_size"in P&&t(6,y=P.show_brush_size),"show_eraser_size"in P&&t(7,w=P.show_eraser_size),"sources"in P&&t(13,A=P.sources),"transforms"in P&&t(14,k=P.transforms)},s.$$.update=()=>{s.$$.dirty[0]&768&&t(6,y=l==="draw"&&h==="size"),s.$$.dirty[0]&768&&t(5,b=l==="draw"&&h==="color"),s.$$.dirty[0]&768&&t(7,w=l==="erase"&&h==="size"),s.$$.dirty[0]&16384&&t(19,i=k.includes("crop")),s.$$.dirty[0]&16384&&t(18,n=k.includes("resize")),s.$$.dirty[0]&8192&&t(17,r=A.includes("upload")),s.$$.dirty[0]&8192&&t(16,o=A.includes("webcam")),s.$$.dirty[0]&8192&&t(15,a=A.includes("clipboard"))},[d,f,g,p,m,b,y,w,l,h,c,u,_,A,k,a,o,r,n,i,x,S,T,E,D,X,F,q,R,B,ze,W,ee,I,G,ye,we,xe,ge,ve,ke,Ae,Pe,tt]}class Py extends xy{constructor(e){super(),vy(this,e,Ty,My,ky,{tool:8,subtool:9,background:10,brush_options:11,selected_size:0,eraser_options:12,selected_eraser_size:1,selected_color:2,selected_opacity:3,preview:4,show_brush_color:5,show_brush_size:6,show_eraser_size:7,sources:13,transforms:14},null,[-1,-1])}get tool(){return this.$$.ctx[8]}set tool(e){this.$$set({tool:e}),Le()}get subtool(){return this.$$.ctx[9]}set subtool(e){this.$$set({subtool:e}),Le()}get background(){return this.$$.ctx[10]}set background(e){this.$$set({background:e}),Le()}get brush_options(){return this.$$.ctx[11]}set brush_options(e){this.$$set({brush_options:e}),Le()}get selected_size(){return this.$$.ctx[0]}set selected_size(e){this.$$set({selected_size:e}),Le()}get eraser_options(){return this.$$.ctx[12]}set eraser_options(e){this.$$set({eraser_options:e}),Le()}get selected_eraser_size(){return this.$$.ctx[1]}set selected_eraser_size(e){this.$$set({selected_eraser_size:e}),Le()}get selected_color(){return this.$$.ctx[2]}set selected_color(e){this.$$set({selected_color:e}),Le()}get selected_opacity(){return this.$$.ctx[3]}set selected_opacity(e){this.$$set({selected_opacity:e}),Le()}get preview(){return this.$$.ctx[4]}set preview(e){this.$$set({preview:e}),Le()}get show_brush_color(){return this.$$.ctx[5]}set show_brush_color(e){this.$$set({show_brush_color:e}),Le()}get show_brush_size(){return this.$$.ctx[6]}set show_brush_size(e){this.$$set({show_brush_size:e}),Le()}get show_eraser_size(){return this.$$.ctx[7]}set show_eraser_size(e){this.$$set({show_eraser_size:e}),Le()}get sources(){return this.$$.ctx[13]}set sources(e){this.$$set({sources:e}),Le()}get transforms(){return this.$$.ctx[14]}set transforms(e){this.$$set({transforms:e}),Le()}}var Jo=`in vec2 aPosition;
297out vec2 vTextureCoord;
298
299uniform vec4 uInputSize;
300uniform vec4 uOutputFrame;
301uniform vec4 uOutputTexture;
302
303vec4 filterVertexPosition( void )
304{
305    vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
306    
307    position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
308    position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
309
310    return vec4(position, 0.0, 1.0);
311}
312
313vec2 filterTextureCoord( void )
314{
315    return aPosition * (uOutputFrame.zw * uInputSize.zw);
316}
317
318void main(void)
319{
320    gl_Position = filterVertexPosition();
321    vTextureCoord = filterTextureCoord();
322}
323`,ea=`struct GlobalFilterUniforms {
324  uInputSize:vec4<f32>,
325  uInputPixel:vec4<f32>,
326  uInputClamp:vec4<f32>,
327  uOutputFrame:vec4<f32>,
328  uGlobalFrame:vec4<f32>,
329  uOutputTexture:vec4<f32>,
330};
331
332@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
333
334struct VSOutput {
335    @builtin(position) position: vec4<f32>,
336    @location(0) uv : vec2<f32>
337  };
338
339fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
340{
341    var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
342
343    position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
344    position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
345
346    return vec4(position, 0.0, 1.0);
347}
348
349fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
350{
351    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
352}
353
354fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
355{
356  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);  
357}
358
359fn getSize() -> vec2<f32>
360{
361  return gfu.uGlobalFrame.zw;
362}
363  
364@vertex
365fn mainVertex(
366  @location(0) aPosition : vec2<f32>, 
367) -> VSOutput {
368  return VSOutput(
369   filterVertexPosition(aPosition),
370   filterTextureCoord(aPosition)
371  );
372}`,zy=`
373in vec2 vTextureCoord;
374out vec4 finalColor;
375
376uniform sampler2D uTexture;
377uniform vec2 uOffset;
378
379void main(void)
380{
381    vec4 color = vec4(0.0);
382
383    // Sample top left pixel
384    color += texture(uTexture, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y));
385
386    // Sample top right pixel
387    color += texture(uTexture, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y));
388
389    // Sample bottom right pixel
390    color += texture(uTexture, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y));
391
392    // Sample bottom left pixel
393    color += texture(uTexture, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y));
394
395    // Average
396    color *= 0.25;
397
398    finalColor = color;
399}`,Iy=`struct KawaseBlurUniforms {
400  uOffset:vec2<f32>,
401};
402
403@group(0) @binding(1) var uTexture: texture_2d<f32>; 
404@group(0) @binding(2) var uSampler: sampler;
405@group(1) @binding(0) var<uniform> kawaseBlurUniforms : KawaseBlurUniforms;
406
407@fragment
408fn mainFragment(
409  @builtin(position) position: vec4<f32>,
410  @location(0) uv : vec2<f32>
411) -> @location(0) vec4<f32> {
412  let uOffset = kawaseBlurUniforms.uOffset;
413  var color: vec4<f32> = vec4<f32>(0.0);
414
415  // Sample top left pixel
416  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x - uOffset.x, uv.y + uOffset.y));
417  // Sample top right pixel
418  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x + uOffset.x, uv.y + uOffset.y));
419  // Sample bottom right pixel
420  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x + uOffset.x, uv.y - uOffset.y));
421  // Sample bottom left pixel
422  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x - uOffset.x, uv.y - uOffset.y));
423  // Average
424  color *= 0.25;
425
426  return color;
427}`,Ey=`
428precision highp float;
429in vec2 vTextureCoord;
430out vec4 finalColor;
431
432uniform sampler2D uTexture;
433uniform vec2 uOffset;
434
435uniform vec4 uInputClamp;
436
437void main(void)
438{
439    vec4 color = vec4(0.0);
440
441    // Sample top left pixel
442    color += texture(uTexture, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));
443
444    // Sample top right pixel
445    color += texture(uTexture, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));
446
447    // Sample bottom right pixel
448    color += texture(uTexture, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));
449
450    // Sample bottom left pixel
451    color += texture(uTexture, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));
452
453    // Average
454    color *= 0.25;
455
456    finalColor = color;
457}
458`,Ry=`struct KawaseBlurUniforms {
459  uOffset:vec2<f32>,
460};
461
462struct GlobalFilterUniforms {
463  uInputSize:vec4<f32>,
464  uInputPixel:vec4<f32>,
465  uInputClamp:vec4<f32>,
466  uOutputFrame:vec4<f32>,
467  uGlobalFrame:vec4<f32>,
468  uOutputTexture:vec4<f32>,
469};
470
471@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
472
473@group(0) @binding(1) var uTexture: texture_2d<f32>; 
474@group(0) @binding(2) var uSampler: sampler;
475@group(1) @binding(0) var<uniform> kawaseBlurUniforms : KawaseBlurUniforms;
476
477@fragment
478fn mainFragment(
479  @builtin(position) position: vec4<f32>,
480  @location(0) uv : vec2<f32>
481) -> @location(0) vec4<f32> {
482  let uOffset = kawaseBlurUniforms.uOffset;
483  var color: vec4<f32> = vec4(0.0);
484
485  // Sample top left pixel
486  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x - uOffset.x, uv.y + uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
487  // Sample top right pixel
488  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x + uOffset.x, uv.y + uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
489  // Sample bottom right pixel
490  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x + uOffset.x, uv.y - uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
491  // Sample bottom left pixel
492  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x - uOffset.x, uv.y - uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
493  // Average
494  color *= 0.25;
495    
496  return color;
497}`,Fy=Object.defineProperty,By=(s,e,t)=>e in s?Fy(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,wi=(s,e,t)=>(By(s,typeof e!="symbol"?e+"":e,t),t);const fd=class gd extends $o{constructor(...e){let t=e[0]??{};(typeof t=="number"||Array.isArray(t))&&(K("6.0.0","KawaseBlurFilter constructor params are now options object. See params: { strength, quality, clamp, pixelSize }"),t={strength:t},e[1]!==void 0&&(t.quality=e[1]),e[2]!==void 0&&(t.clamp=e[2])),t={...gd.DEFAULT_OPTIONS,...t};const i=li.from({vertex:{source:ea,entryPoint:"mainVertex"},fragment:{source:t?.clamp?Ry:Iy,entryPoint:"mainFragment"}}),n=ls.from({vertex:Jo,fragment:t?.clamp?Ey:zy,name:"kawase-blur-filter"});super({gpuProgram:i,glProgram:n,resources:{kawaseBlurUniforms:{uOffset:{value:new Float32Array(2),type:"vec2
497<f32>"}}}}),wi(this,"uniforms"),wi(this,"_pixelSize",{x:0,y:0}),wi(this,"_clamp"),wi(this,"_kernels",[]),wi(this,"_blur"),wi(this,"_quality"),this.uniforms=this.resources.kawaseBlurUniforms.uniforms,this.pixelSize=t.pixelSize??{x:1,y:1},Array.isArray(t.strength)?this.kernels=t.strength:typeof t.strength=="number"&&(this._blur=t.strength,this.quality=t.quality??3),this._clamp=!!t.clamp}apply(e,t,i,n){const r=this.pixelSizeX/t.source.width,o=this.pixelSizeY/t.source.height;let a;if(this._quality===1||this._blur===0)a=this._kernels[0]+.5,this.uniforms.uOffset[0]=a*r,this.uniforms.uOffset[1]=a*o,e.applyFilter(this,t,i,n);else{const l=qs.getSameSizeTexture(t);let h=t,c=l,u;const d=this._quality-1;for(let _=0;_<d;_++)a=this._kernels[_]+.5,this.uniforms.uOffset[0]=a*r,this.uniforms.uOffset[1]=a*o,e.applyFilter(this,h,c,!0),u=h,h=c,c=u;a=this._kernels[d]+.5,this.uniforms.uOffset[0]=a*r,this.uniforms.uOffset[1]=a*o,e.applyFilter(this,h,i,n),qs.returnTexture(l)}}get strength(){return this._blur}set strength(e){this._blur=e,this._generateKernels()}get quality(){return this._quality}set quality(e){this._quality=Math.max(1,Math.round(e)),this._generateKernels()}get kernels(){return this._kernels}set kernels(e){Array.isArray(e)&&e.length>0?(this._kernels=e,this._quality=e.length,this._blur=Math.max(...e)):(this._kernels=[0],this._quality=1)}get pixelSize(){return this._pixelSize}set pixelSize(e){if(typeof e=="number"){this.pixelSizeX=this.pixelSizeY=e;return}if(Array.isArray(e)){this.pixelSizeX=e[0],this.pixelSizeY=e[1];return}this._pixelSize=e}get pixelSizeX(){return this.pixelSize.x}set pixelSizeX(e){this.pixelSize.x=e}get pixelSizeY(){return this.pixelSize.y}set pixelSizeY(e){this.pixelSize.y=e}get clamp(){return this._clamp}_updatePadding(){this.padding=Math.ceil(this._kernels.reduce((e,t)=>e+t+.5,0))}_generateKernels(){const e=this._blur,t=this._quality,i=[e];if(e>0){let n=e;const r=e/t;for(let o=1;o<t;o++)n-=r,i.push(n)}this._kernels=i,this._updatePadding()}};wi(fd,"DEFAULT_OPTIONS",{strength:4,quality:3,clamp:!1,pixelSize:{x:1,y:1}});let Ly=fd;var $y=`precision highp float;
498in vec2 vTextureCoord;
499out vec4 finalColor;
500
501uniform sampler2D uTexture;
502uniform float uAlpha;
503uniform vec3 uColor;
504uniform vec2 uOffset;
505
506uniform vec4 uInputSize;
507
508void main(void){
509    vec4 sample = texture(uTexture, vTextureCoord - uOffset * uInputSize.zw);
510
511    // Premultiply alpha
512    sample.rgb = uColor.rgb * sample.a;
513
514    // alpha user alpha
515    sample *= uAlpha;
516
517    finalColor = sample;
518}`,Oy=`struct DropShadowUniforms {
519  uAlpha: f32,
520  uColor: vec3<f32>,
521  uOffset: vec2<f32>,
522};
523
524struct GlobalFilterUniforms {
525  uInputSize:vec4<f32>,
526  uInputPixel:vec4<f32>,
527  uInputClamp:vec4<f32>,
528  uOutputFrame:vec4<f32>,
529  uGlobalFrame:vec4<f32>,
530  uOutputTexture:vec4<f32>,
531};
532
533@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
534
535@group(0) @binding(1) var uTexture: texture_2d<f32>; 
536@group(0) @binding(2) var uSampler: sampler;
537@group(1) @binding(0) var<uniform> dropShadowUniforms : DropShadowUniforms;
538
539@fragment
540fn mainFragment(
541  @builtin(position) position: vec4<f32>,
542  @location(0) uv : vec2<f32>
543) -> @location(0) vec4<f32> {
544  var color: vec4<f32> = textureSample(uTexture, uSampler, uv - dropShadowUniforms.uOffset * gfu.uInputSize.zw);
545
546  // Premultiply alpha
547  color = vec4<f32>(vec3<f32>(dropShadowUniforms.uColor.rgb * color.a), color.a);
548  // alpha user alpha
549  color *= dropShadowUniforms.uAlpha;
550
551  return color;
552}`,Gy=Object.defineProperty,Ny=(s,e,t)=>e in s?Gy(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ji=(s,e,t)=>(Ny(s,typeof e!="symbol"?e+"":e,t),t);const pd=class md extends $o{constructor(e){e={...md.DEFAULT_OPTIONS,...e};const t=li.from({vertex:{source:ea,entryPoint:"mainVertex"},fragment:{source:Oy,entryPoint:"mainFragment"}}),i=ls.from({vertex:Jo,fragment:$y,name:"drop-shadow-filter"});super({gpuProgram:t,glProgram:i,resources:{dropShadowUniforms:{uAlpha:{value:e.alpha,type:"f32"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uOffset:{value:e.offset,type:"vec2<f32>"}}},resolution:e.resolution}),Ji(this,"uniforms"),Ji(this,"shadowOnly",!1),Ji(this,"_color"),Ji(this,"_blurFilter"),Ji(this,"_basePass"),this.uniforms=this.resources.dropShadowUniforms.uniforms,this._color=new fe,this.color=e.color??0,this._blurFilter=new Ly({strength:e.kernels??e.blur,quality:e.kernels?void 0:e.quality}),this._basePass=new $o({gpuProgram:li.from({vertex:{source:ea,entryPoint:"mainVertex"},fragment:{source:`
553                    @group(0) @binding(1) var uTexture: texture_2d<f32>; 
554                    @group(0) @binding(2) var uSampler: sampler;
555                    @fragment
556                    fn mainFragment(
557                        @builtin(position) position: vec4<f32>,
558                        @location(0) uv : vec2<f32>
559                    ) -> @location(0) vec4<f32> {
560                        return textureSample(uTexture, uSampler, uv);
561                    }
562                    `,entryPoint:"mainFragment"}}),glProgram:ls.from({vertex:Jo,fragment:`
563                in vec2 vTextureCoord;
564                out vec4 finalColor;
565                uniform sampler2D uTexture;
566
567                void main(void){
568                    finalColor = texture(uTexture, vTextureCoord);
569                }
570                `,name:"drop-shadow-filter"}),resources:{}}),Object.assign(this,e)}apply(e,t,i,n){const r=qs.getSameSizeTexture(t);e.applyFilter(this,t,r,!0),this._blurFilter.apply(e,r,i,n),this.shadowOnly||e.applyFilter(this._basePass,t,i,!1),qs.returnTexture(r)}get offset(){return this.uniforms.uOffset}set offset(e){this.uniforms.uOffset=e,this._updatePadding()}get offsetX(){return this.offset.x}set offsetX(e){this.offset.x=e,this._updatePadding()}get offsetY(){return this.offset.y}set offsetY(e){this.offset.y=e,this._updatePadding()}get color(){return this._color.value}set color(e){this._color.setValue(e);const[t,i,n]=this._color.toArray();this.uniforms.uColor[0]=t,this.uniforms.uColor[1]=i,this.uniforms.uColor[2]=n}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}get blur(){return this._blurFilter.strength}set blur(e){this._blurFilter.strength=e,this._updatePadding()}get quality(){return this._blurFilter.quality}set quality(e){this._blurFilter.quality=e,this._updatePadding()}get kernels(){return this._blurFilter.kernels}set kernels(e){this._blurFilter.kernels=e}get pixelSize(){return this._blurFilter.pixelSize}set pixelSize(e){typeof e=="number"&&(e={x:e,y:e}),Array.isArray(e)&&(e={x:e[0],y:e[1]}),this._blurFilter.pixelSize=e}get pixelSizeX(){return this._blurFilter.pixelSizeX}set pixelSizeX(e){this._blurFilter.pixelSizeX=e}get pixelSizeY(){return this._blurFilter.pixelSizeY}set pixelSizeY(e){this._blurFilter.pixelSizeY=e}_updatePadding(){const e=Math.max(Math.abs(this.offsetX),Math.abs(this.offsetY));
570this.padding=e+this.blur*2+this.quality*4}};Ji(pd,"DEFAULT_OPTIONS",{offset:{x:4,y:4},color:0,alpha:.5,shadowOnly:!1,kernels:void 0,blur:2,quality:3,pixelSize:{x:1,y:1},resolution:1});let Dy=pd;class Uy{name="image";context;current_tool;current_subtool;async setup(e,t,i){this.context=e,this.current_tool=t,this.current_subtool=i}cleanup(){}async add_image({image:e,fixed_canvas:t,border_region:i=0}){const n=new Wy(this.context,e,t,i);await this.context.execute_command(n)}set_tool(e,t){this.current_tool=e,this.current_subtool=t}}class Wy{sprite;fixed_canvas;context;background;current_canvas_size;current_scale;current_position;border_region;scaled_width;scaled_height;constructor(e,t,i,n=0){this.context=e,this.background=t,this.fixed_canvas=i,this.border_region=n,this.current_canvas_size=Pn(this.context.dimensions),this.current_scale=Pn(this.context.scale),this.current_position=Pn(this.context.position),this.sprite=new ue}async start(){let e;if(this.background instanceof Y)e=this.background;else{const t=await createImageBitmap(this.background);e=Y.from(t)}return this.sprite=new ue(e),this.handle_image()}handle_image(){if(this.fixed_canvas){const e=Math.max(this.current_canvas_size.width-this.border_region*2,10),t=Math.max(this.current_canvas_size.height-this.border_region*2,10),{width:i,height:n,x:r,y:o}=Hy(this.sprite.width,this.sprite.height,e,t);this.sprite.width=i,this.sprite.height=n,this.sprite.x=r+this.border_region,this.sprite.y=o+this.border_region}else{const e=this.sprite.width,t=this.sprite.height;return this.sprite.x=this.border_region,this.sprite.y=this.border_region,[e+this.border_region*2,t+this.border_region*2]}return[this.current_canvas_size.width,this.current_canvas_size.height]}async execute(){const[e,t]=await this.start();await this.context.set_image_properties({scale:1,position:{x:this.context.app.screen.width/2,y:this.context.app.screen.height/2},width:this.fixed_canvas?this.current_canvas_size.width:e,height:this.fixed_canvas?this.current_canvas_size.height:t});const i=this.context.layer_manager.create_background_layer(this.fixed_canvas?this.current_canvas_size.width:e,this.fixed_canvas?this.current_canvas_size.height:t);this.sprite.zIndex=0,i.addChild(this.sprite),this.context.layer_manager.reset_layers(this.fixed_canvas?this.current_canvas_size.width:e,this.fixed_canvas?this.current_canvas_size.height:t,!0),this.context.set_background_image(this.sprite),this.context.reset()}async undo(){this.sprite&&this.sprite.destroy()}}function Hy(s,e,t,i){const n=s/e,r=t/i;let o,a;n>r?(o=t,a=t/n):(a=i,o=i*n);const l=Math.round((t-o)/2),h=Math.round((i-a)/2);return{width:Math.round(o),height:Math.round(a),x:l,y:h}}class ta{name="zoom";min_zoom=$s(!0);image_editor_context;max_zoom=10;border_padding=30;pad_bottom=0;is_pinching=!1;is_dragging=!1;is_pointer_dragging=!1;last_touch_position=null;last_pinch_distance=0;drag_start=new V;current_tool;current_subtool;local_scale=1;local_dimensions={width:0,height:0};local_position={x:0,y:0};prevent_default(e){e.preventDefault(),e.stopPropagation()}set_tool(e,t){this.current_tool=e,this.current_subtool=t}set_zoom(e){const t=this.calculate_min_zoom(this.local_dimensions.width,this.local_dimensions.height);let i;const n=e==="fit";n?i=t:i=Math.max(0,Math.min(this.max_zoom,e));const r=this.image_editor_context.app.screen,o=r.width,a=r.height;let l;l={x:o/2,y:a/2},this.zoom_to_point(i,l,!0,n)}async setup(e,t,i){this.image_editor_context=e,this.current_tool=t,this.current_subtool=i,this.pad_bottom=e.pad_bottom;const{width:n,height:r}=await this.get_container_dimensions(),o=this.calculate_min_zoom(n,r),a=Math.min(o,1);this.local_scale=a;const l=this.image_editor_context.app.screen,h=l.width/2,c=l.height/2,u=n*a,d=r*a,_=h-u/2,f=c-d/2;this.local_position={x:_,y:f},this.setup_event_listeners(),await this.image_editor_context.set_image_properties({scale:a,position:{x:_,y:f}}),this.image_editor_context.dimensions.subscribe(g=>{this.local_dimensions=g}),this.image_editor_context.scale.subscribe(g=>{this.local_scale=g}),this.image_editor_context.position.subscribe(g=>{this.local_position=g})}setup_event_listeners(){const e=this.image_editor_context.app.stage;this.image_editor_context.app.canvas.addEventListener("wheel",this.prevent_default,{passive:!1}),e.eventMode="static",e.hitArea=this.image_editor_context.app.screen;const i=this.handle_wheel.bind(this);e.addEventListener("wheel",i,{passive:!1}),"ontouchstart"in window?(e.addEventListener("touchstart",this.handle_touch_start.bind(this)),e.addEventListener("touchmove",this.handle_touch_move.bind(this)),e.addEventListener("touchend",this.handle_touch_end.bind(this))):(e.addEventListener("pointerdown",this.handle_pointer_down.bind(this)),e.addEventListener("pointermove",this.handle_pointer_move.bind(this)),e.addEventListener("pointerup",this.handle_pointer_up.bind(this)),e.addEventListener("pointerupoutside",this.handle_pointer_up.bind(this)))}handle_wheel(e){const t=e.deltaMode===0&&Math.abs(e.deltaY)<50,i=t?30:10;if(e.altKey||e.metaKey){const n=this.image_editor_context.app.stage.toLocal(e.global),r=-e.deltaY*(t?.001:5e-4),o=this.local_scale*(1+r);this.zoom_to_point(o,n,!0)}else{const n=e.deltaX,r=e.deltaY,o={x:this.local_position.x-n/100*i,y:this.local_position.y-r/100*i},a=this.image_editor_context.app.screen,l=this.local_dimensions.width*this.local_scale,h=this.local_dimensions.height*this.local_scale,c=a.width-this.border_padding*2,u=a.height-this.border_padding*2-this.pad_bottom;let d={...o};if(l<=c)d.x=(a.width-l)/2;else{const _=a.width/2,f=_,g=a.width-_-l;d.x=Math.min(Math.max(o.x,g),f)}if(h<=u)d.y=(a.height-this.pad_bottom-h)/2;else{const _=(a.height-this.pad_bottom)/2,f=_,g=a.height-this.pad_bottom-_-h;d.y=Math.min(Math.max(o.y,g),f)}this.image_editor_context.set_image_properties({scale:this.local_scale,position:d})}}cleanup(){const e=this?.image_editor_context?.app?.stage;e&&(e.removeEventListener("wheel",this.handle_wheel.bind(this)),"ontouchstart"in window?(e.removeEventListener("touchstart",this.handle_touch_start.bind(this)),e.removeEventListener("touchmove",this.handle_touch_move.bind(this)),e.removeEventListener("touchend",this.handle_touch_end.bind(this))):(e.removeEventListener("pointerdown",this.handle_pointer_down.bind(this)),e.removeEventListener("pointermove",this.handle_pointer_move.bind(this)),e.removeEventListener("pointerup",this.handle_pointer_up.bind(this)),e.removeEventListener("pointerupoutside",this.handle_pointer_up.bind(this))))}async get_container_dimensions(){const e=this.image_editor_context.
570image_container.getLocalBounds();return{width:e.width,height:e.height}}calculate_min_zoom(e,t){const i=this.image_editor_context.app.screen,n=i.width,r=i.height;if(!e||!n||!t||!r)return 1;const o=n-this.border_padding*2,a=r-this.border_padding*2-this.pad_bottom,l=o/e,h=a/t;return Math.min(l,h)}handle_touch_start(e){e.preventDefault();const t=e;if(t.touches&&t.touches.length===2)this.is_pinching=!0,this.last_pinch_distance=Math.hypot(t.touches[0].pageX-t.touches[1].pageX,t.touches[0].pageY-t.touches[1].pageY);else if(t.touches&&t.touches.length===1){this.is_dragging=!0;const i=this.image_editor_context.app.view.getBoundingClientRect();this.last_touch_position=new V(t.touches[0].pageX-i.left,t.touches[0].pageY-i.top)}}handle_touch_move(e){e.preventDefault();const t=e;if(this.is_pinching&&t.touches&&t.touches.length===2){const i=this.image_editor_context.app.view.getBoundingClientRect(),n=Math.hypot(t.touches[0].pageX-t.touches[1].pageX,t.touches[0].pageY-t.touches[1].pageY),r={x:(t.touches[0].pageX+t.touches[1].pageX)/2-i.left,y:(t.touches[0].pageY+t.touches[1].pageY)/2-i.top},o=n/this.last_pinch_distance;this.last_pinch_distance=n,this.zoom_to_point(this.local_scale*o,r)}else if(this.is_dragging&&t.touches&&t.touches.length===1&&this.last_touch_position){const i=this.image_editor_context.app.view.getBoundingClientRect(),n=new V(t.touches[0].pageX-i.left,t.touches[0].pageY-i.top),r=n.x-this.last_touch_position.x,o=n.y-this.last_touch_position.y;this.image_editor_context.set_image_properties({position:{x:this.local_position.x+r,y:this.local_position.y+o}}),this.last_touch_position=n}}handle_touch_end(e){e.preventDefault();const t=e;if(t.touches&&t.touches.length<2&&(this.is_pinching=!1,t.touches&&t.touches.length===1)){const i=this.image_editor_context.app.view.getBoundingClientRect();this.last_touch_position=new V(t.touches[0].pageX-i.left,t.touches[0].pageY-i.top),this.is_dragging=!0}t.touches&&t.touches.length===0&&(this.is_dragging=!1,this.last_touch_position=null,this.last_pinch_distance=0)}get_bounded_position(e){const t=this.image_editor_context.app.screen,i=this.local_dimensions.width*this.local_scale,n=this.local_dimensions.height*this.local_scale,r={x:(t.width-i)/2,y:(t.height-n-this.pad_bottom)/2};if(i<=t.width&&n<=t.height)return r;let o=e.x,a=e.y;if(i<=t.width)o=r.x;else{const l=t.width-i;o=Math.max(l,Math.min(0,e.x))}if(n<=t.height-this.pad_bottom)a=r.y;else{const l=t.height-n-this.pad_bottom;a=Math.max(l,Math.min(0,e.y))}return{x:o,y:a}}zoom_to_point(e,t,i,n){const r={x:(t.x-this.local_position.x)/this.local_scale,y:(t.y-this.local_position.y)/this.local_scale},o={x:r.x/this.local_dimensions.width,y:r.y/this.local_dimensions.height},a=this.calculate_min_zoom(this.local_dimensions.width,this.local_dimensions.height),l=Math.min(a,1);e=Math.min(Math.max(e,l),this.max_zoom);const h=this.local_dimensions.width*e,c=this.local_dimensions.height*e;let u={x:t.x-h*o.x,y:t.y-c*o.y};if(e===l||n){const d=this.image_editor_context.app.screen.width,_=this.image_editor_context.app.screen.height;u={x:(d-h)/2,y:(_-this.pad_bottom-c)/2}}this.image_editor_context.set_image_properties({scale:e,position:u,animate:typeof i=="boolean"?!i:e===l}),this.min_zoom.set(e===l)}handle_pointer_down(e){e.button===0&&this.current_tool==="pan"&&(this.is_pointer_dragging=!0,this.drag_start.copyFrom(e.global),this.drag_start.x-=this.local_position.x,this.drag_start.y-=this.local_position.y)}handle_pointer_move(e){if(this.is_pointer_dragging&&this.current_tool==="pan"){const t={x:e.global.x-this.drag_start.x,y:e.global.y-this.drag_start.y},i=this.image_editor_context.app.screen,n=this.local_dimensions.width*this.local_scale,r=this.local_dimensions.height*this.local_scale,o=i.width-this.border_padding*2,a=i.height-this.border_padding*2-this.pad_bottom;let l={...t};n<=o?l.x=(i.width-n)/2:l.x=t.x,r<=a?l.y=(i.height-this.pad_bottom-r)/2:l.y=t.y,this.image_editor_context.set_image_properties({scale:this.local_scale,position:l})}}handle_pointer_up(e){if(this.is_pointer_dragging&&this.current_tool==="pan"){this.is_pointer_dragging=!1;const t={x:e.global.x-this.drag_start.x,y:e.global.y-this.drag_start.y},i=this.image_editor_context.app.screen,n=this.local_dimensions.width*this.local_scale,r=this.local_dimensions.height*this.local_scale,o=i.width-this.border_padding*2,a=i.height-this.border_padding*2-this.pad_bottom;let l={...t};if(n<=o)l.x=(i.width-n)/2;else{const h=i.width/2,c=h,u=i.width-h-n;l.x=Math.min(Math.max(t.x,u),c)}if(r<=a)l.y=(i.height-this.pad_bottom-r)/2;else{const h=(i.height-this.pad_bottom)/2,c=h,u=i.height-this.pad_bottom-h-r;l.y=Math.min(Math.max(t.y,u),c)}this.image_editor_context.set_image_properties({scale:this.local_scale,position:l,animate:!0})}}}class Bh{undo_stack=[];redo_stack=[];async execute(e){await e.execute(),this.undo_stack.push(e),this.redo_stack=[]}async undo(){const e=this.undo_stack.pop();e&&(await e.undo(),this.redo_stack.push(e))}async redo(){const e=this.redo_stack.pop();e&&(await e.execute(),this.undo_stack.push(e))}}class qy{layers=[];active_layer=null;active_layer_id=null;draw_textures=new Map;layer_store=$s({active_layer:"",layers:[]});background_layer=null;image_container;app;fixed_canvas;dark;border_region;layer_options;constructor(e,t,i,n,r,o){this.image_container=e,this.app=t,this.fixed_canvas=i,this.dark=n,this.border_region=r,this.layer_options=o}toggle_layer_visibility(e){const t=this.layers.find(i=>i.id===e);t&&(t.container.visible=!t.container.visible,t.visible=t.container.visible,this.layer_store.update(i=>({active_layer:i.active_layer,layers:this.layers})))}create_background_layer(e,t){this.background_layer&&this.background_layer.destroy();const i=new U;this.background_layer=i;const n=Ii.create({width:e,height:t,resolution:window.devicePixelRatio,antialias:!0,scaleMode:Kl.NEAREST}),r=new ue(n);i.addChild(r);const o=new be;return o.clear(),o.rect(0,0,e,t).fill({color:this.dark?3355443:16777215,alph
570a:1}),this.app.renderer.render({container:o,target:n,clear:!0}),this.image_container.addChild(i),i.zIndex=-1,this.update_layer_order(),i}set_layer_options(e,t,i){this.layer_options=e,this.reset_layers(t,i)}async create_background_layer_from_url(e,t,i){const n=this.create_background_layer(t||this.image_container.width,i||this.image_container.height);try{const r=await Y.from(e),o=new ue(r),a=o.texture.width,l=o.texture.height,h=t||this.image_container.width,c=i||this.image_container.height;if(this.fixed_canvas){const u=Math.max(h-this.border_region*2,10),d=Math.max(c-this.border_region*2,10),_=a/l,f=u/d;let g,p,m=this.border_region,b=this.border_region;a<=u&&l<=d?(g=a,p=l):_>f?(g=u,p=u/_):(p=d,g=d*_),m+=Math.round((u-g)/2),b+=Math.round((d-p)/2),o.width=g,o.height=p,o.position.set(m,b)}else{o.position.set(this.border_region,this.border_region),this.background_layer&&this.background_layer.destroy();const u=a+this.border_region*2,d=l+this.border_region*2,_=this.create_background_layer(u,d);return o.width=a,o.height=l,_.addChild(o),_}return n.addChild(o),n}catch(r){return console.error("Error loading image from URL:",r),n}}create_layer({width:e,height:t,layer_name:i,user_created:n,layer_id:r=void 0,make_active:o=!1}){const a=new U,l=r||Math.random().toString(36).substring(2,15),h=i||`Layer ${this.layers.length+1}`;this.layers.push({name:h,id:l,container:a,user_created:n,visible:!0}),this.image_container.addChild(a);const c=Ii.create({width:e,height:t,resolution:window.devicePixelRatio,antialias:!0,scaleMode:Kl.NEAREST}),u=new ue(c);a.addChild(u);const d=new be;return d.clear(),d.beginFill(0,0),d.drawRect(0,0,e,t),d.endFill(),this.app.renderer.render({container:d,target:c,clear:!0}),this.draw_textures.set(a,c),this.update_layer_order(),o&&this.set_active_layer(l),this.layer_store.set({active_layer:this.active_layer_id||"",layers:this.layers}),a}async add_layer_from_url(e){const{width:t,height:i}=this.image_container.getLocalBounds(),n=this.create_layer({width:t,height:i,layer_name:"Layer 1",user_created:!0}),r=this.layers.findIndex(a=>a.container===n);if(r===-1)return console.error("Could not find newly created layer"),"";const o=this.layers[r].id;try{const a=await Ai.load(e),l=this.draw_textures.get(n);if(!l)return console.error("No draw texture found for layer"),o;const h=new ue(a),c=h.width,u=h.height;let d=this.border_region,_=this.border_region;const f=this.fixed_canvas?t-this.border_region*2:t,g=this.fixed_canvas?i-this.border_region*2:i;if((c<f||u<g)&&(d=Math.floor((f-c)/2),_=Math.floor((g-u)/2)),h.position.set(d,_),c>f||u>g){const p=c/u,m=f/g;let b,y;p>m?(b=f,y=f/p):(y=g,b=g*p),h.width=b,h.height=y,d=this.border_region+Math.floor((f-b)/2),_=this.border_region+Math.floor((g-y)/2),h.position.set(d,_)}return this.app.renderer.render(h,{renderTexture:l}),this.set_active_layer(o),o}catch(a){return console.error("Error loading image from URL:",a),o}}get_active_layer(){return this.active_layer}set_active_layer(e){this.layers.some(t=>t.id===e)&&(this.active_layer=this.layers.find(t=>t.id===e)?.container||this.layers[0]?.container||null,this.active_layer_id=e,this.layer_store.set({active_layer:e,layers:this.layers}))}get_layers(){return this.layers}get_layer_textures(e){const t=this.layers.find(i=>i.id===e);if(t){const i=this.draw_textures.get(t.container);if(i)return{draw:i}}return null}delete_layer(e){const t=this.layers.findIndex(i=>i.id===e);if(t>-1){const i=this.draw_textures.get(this.layers[t].container);if(i&&(i.destroy(),this.draw_textures.delete(this.layers[t].container)),this.layers[t].container.destroy(),this.active_layer===this.layers[t].container){const n=this.layers[Math.max(0,t-1)]||null;this.active_layer=n?.container||null,this.active_layer_id=n?.id||null}this.layers=this.layers.filter(n=>n.id!==e),this.layer_store.update(n=>({active_layer:n.active_layer===e?this.layers[this.layers.length-1]?.id:n.active_layer,layers:this.layers})),this.update_layer_order()}}update_layer_order(){this.background_layer&&(this.background_layer.zIndex=-1),this.layers.forEach((e,t)=>{e.container.zIndex=t})}move_layer(e,t){const i=this.layers.findIndex(n=>n.id===e);if(i>-1){const n=t==="up"?i-1:i+1;this.layers=this.layers.map((r,o)=>o===i?this.layers[n]:o===n?this.layers[i]:r),this.update_layer_order(),this.layer_store.update(r=>({active_layer:e,layers:this.layers}))}}resize_all_layers(e,t,i,n,r,o){new Map(this.layers.map(_=>[_.id,_]));const a=this.background_layer,l=()=>{let _=0,f=0;const g=e-r,p=t-o;return n.includes("left")?_=0:n.includes("right")?_=g:_=Math.floor(g/2),n.includes("top")?f=0:n.includes("bottom")?f=p:f=Math.floor(p/2),{offsetX:_,offsetY:f}};this.background_layer=this._resize_background_layer(a,e,t,i,l);const h=[],c=this.layers.map(_=>
570({id:_.id,name:_.name,user_created:_.user_created,texture:this.draw_textures.get(_.container),container:_.container}));this.layers=[],this.draw_textures.clear();for(const _ of c){const f=this._resize_single_layer(_,e,t,i,l);f&&h.push(f)}const u=Pn(this.layer_store).active_layer;!h.some(_=>_.id===u)&&h.length>0?this.set_active_layer(h[0].id):h.length===0?this.layer_store.update(_=>({..._,active_layer:""})):this.layer_store.update(_=>({..._})),this.update_layer_order(),setTimeout(()=>{Ai.cache.reset(),this.app.renderer.textureGC.run()},100)}_resize_background_layer(e,t,i,n,r){if(!e)return this.create_background_layer(t,i);let o=e.children.find(l=>l instanceof ue&&l.texture!==e.children[0]?.texture);const a=this.create_background_layer(t,i);if(o){const l=new ue(o.texture);if(l.width=o.width,l.height=o.height,n)l.width=t,l.height=i,l.position.set(0,0);else{const{offsetX:h,offsetY:c}=r();l.position.set(o.x+h,o.y+c)}a.addChild(l)}return a}_resize_single_layer(e,t,i,n,r){if(!e.texture)return console.warn(`No texture found for layer ${e.id}, skipping cleanup.`),e.container&&!e.container.destroyed&&(this.image_container.children.includes(e.container)&&this.image_container.removeChild(e.container),e.container.destroy({children:!0})),null;const o=this.create_layer({width:t,height:i,layer_name:e.name,user_created:e.user_created}),a=this.layers[this.layers.length-1];a.id=e.id;const l=this.draw_textures.get(o);if(!l){if(console.error(`Failed to get texture for newly created layer ${a.id}. Cleaning up.`),o&&!o.destroyed){this.image_container.children.includes(o)&&this.image_container.removeChild(o),o.destroy({children:!0});const c=this.layers.findIndex(u=>u.container===o);c>-1&&this.layers.splice(c,1),this.draw_textures.delete(o)}return e.texture&&!e.texture.destroyed&&e.texture.destroy(!0),e.container&&!e.container.destroyed&&e.container.destroy({children:!0}),null}this.app.renderer.clear({target:l,clearColor:[0,0,0,0]});const h=new ue(e.texture);if(n)h.width=t,h.height=i,h.position.set(0,0);else{const{offsetX:c,offsetY:u}=r();h.position.set(c,u)}return this.app.renderer.render(h,{renderTexture:l}),h.destroy(),e.texture&&!e.texture.destroyed&&e.texture.destroy(!0),e.container&&!e.container.destroyed&&(this.image_container.children.includes(e.container)&&this.image_container.removeChild(e.container),e.container.destroy({children:!0})),a}async get_blobs(e,t){return{background:await Fn(this.app.renderer,this.background_layer,{width:e,height:t,x:0,y:0}),layers:await Promise.all(this.layers.map(async n=>{const r=await Fn(this.app.renderer,n.container,{width:e,height:t,x:0,y:0});return r||null})),composite:await Fn(this.app.renderer,this.image_container)}}reset_layers(e,t,i=!1){const n=i?this.layers.map(r=>[r.name,r.id]):this.layer_options.layers.map(r=>[r,void 0]);this.layers.forEach(r=>{this.delete_layer(r.id)});for(const[r,o]of n)this.create_layer({width:e,height:t,layer_name:r,user_created:!this.layer_options.layers.find(a=>a===r),layer_id:o});i?this.active_layer=this.layers.find(r=>
570r.id===this.active_layer_id)?.container||this.layers[0].container:(this.active_layer=this.layers[0].container,this.active_layer_id=this.layers[0].id),this.layer_store.update(r=>({active_layer:this.active_layer_id||this.layers[0].id,layers:this.layers}))}init_layers(e,t){for(const i of this.layers)this.delete_layer(i.id);for(const i of this.layer_options.layers)this.create_layer({width:e,height:t,layer_name:i,user_created:!1});this.active_layer=this.layers[0].container,this.active_layer_id=this.layers[0].id,this.layer_store.update(i=>({active_layer:this.layers[0].id,layers:this.layers}))}}const Vy={image:()=>new Uy,zoom:()=>new ta},ko={stiffness:.45,damping:.8};class Xy{state;scale;position;subscribers;constructor(e){if(!(e instanceof ia))throw new Error("EditorState must be created by ImageEditor");this.scale=1,this.position={x:0,y:0},this.subscribers=new Set,this.state=Object.freeze({get position(){return{...this.position}},get scale(){return this.scale},get current_tool(){return this.current_tool},get current_subtool(){return this.current_subtool},subscribe:this.subscribe.bind(this)})}_set_position(e,t){const i={...this.position};this.position={x:e,y:t},this._notify_subscribers("position",i,this.position)}_set_scale(e){const t=this.scale;this.scale=e,this._notify_subscribers("scale",t,e)}_notify_subscribers(e,t,i){this.subscribers.forEach(n=>{n({property:e,oldValue:t,newValue:i,timestamp:Date.now()})})}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}}class ia{ready;background_image_present=$s(!1);min_zoom=$s(!0);app;ui_container;image_container;command_manager;layer_manager;tools=new Map;current_tool;current_subtool;target_element;width;height;dimensions;scale;position;state;scale_value=1;position_value={x:0,y:0};dimensions_value={width:0,height:0};layers=$s({active_layer:"",layers:[]});outline_container;outline_graphics;background_image;ready_resolve;event_callbacks=new Map;fixed_canvas;dark;border_region;layer_options;overlay_container;overlay_graphics;pad_bottom;theme_mode;constructor(e){this.pad_bottom=e.pad_bottom||0,this.dark=e.dark||!1,this.theme_mode=e.theme_mode||"dark",this.target_element=e.target_element,this.width=e.width,this.height=e.height,this.command_manager=new Bh,this.ready=new Promise(t=>{this.ready_resolve=t}),this.fixed_canvas=e.fixed_canvas||!1,this.tools=new Map(e.tools.map(t=>typeof t=="string"?[t,Vy[t]()]:[t.name,t]));for(const t of this.tools.values())t?.on&&t.on("change",()=>{this.notify("change")});this.dimensions=fr({width:this.width,height:this.height},ko),this.scale=fr(1,ko),this.position=fr({x:0,y:0},ko),this.state=new Xy(this),this.border_region=e.border_region||0,this.layer_options=e.layer_options||{allow_additional_layers:!0,layers:["Layer 1"],disabled:!1},this.scale.subscribe(t=>{this.state._set_scale(t)}),this.position.subscribe(t=>{this.state._set_position(t.x,t.y)}),this.init()}get context(){const e=this;return{app:this.app,ui_container:this.ui_container,image_container:this.image_container,get background_image(){return e.background_image},pad_bottom:this.pad_bottom,command_manager:this.command_manager,layer_manager:this.layer_manager,dimensions:{subscribe:this.dimensions.subscribe},scale:{subscribe:this.scale.subscribe},position:{subscribe:this.position.subscribe},set_image_properties:this.set_image_properties.bind(this),execute_command:this.execute_command.bind(this),resize_canvas:this.resize_canvas.bind(this),reset:this.reset.bind(this),set_background_image:this.set_background_image.bind(this)}}
570async init(){const e=this.target_element.getBoundingClientRect();new ResizeObserver(n=>{n.forEach(r=>{this.resize_canvas(r.contentBoxSize[0].inlineSize,r.contentBoxSize[0].blockSize)})}).observe(this.target_element),this.app=new zu,await this.app.init({width:e.width,height:e.height,backgroundAlpha:this.dark?0:1,backgroundColor:this.theme_mode==="dark"?"#27272a":"#ffffff",resolution:window.devicePixelRatio,autoDensity:!0,antialias:!0,powerPreference:"high-performance"});const t=this.app.canvas;t.style.background="transparent",await this.setup_containers(),this.layer_manager.create_background_layer(this.width,this.height),this.layer_manager.init_layers(this.width,this.height);for(const n of this.tools.values())await n.setup(this.context,this.current_tool,this.current_subtool);const i=this.tools.get("zoom");i&&i.min_zoom.subscribe(n=>{this.min_zoom.set(n)}),this.target_element.appendChild(t),this.target_element.style.background="transparent",this.dimensions.subscribe(n=>{this.dimensions_value=n,this.image_container.width=n.width,this.image_container.height=n.height}),this.scale.subscribe(n=>{this.scale_value=n}),this.position.subscribe(n=>{this.position_value=n}),this.app.ticker.add(()=>{this.image_container.scale.set(this.scale_value),this.image_container.position.set(this.position_value.x,this.position_value.y);const n=this.dimensions_value.width*this.scale_value,r=this.dimensions_value.height*this.scale_value,o=Math.round(this.image_container.position.x-this.outline_container.position.x),a=Math.round(this.image_container.position.y-this.outline_container.position.y);if(this.overlay_container.position.set(this.outline_container.position.x,this.outline_container.position.y),this.outline_graphics.clear(),this.outline_graphics.rect(o,a,n,r).fill({color:this.dark?3355443:16777215,alpha:1}),this.border_region>0){const l=this.border_region*this.scale_value,h=o+l-1,c=a+l-1,u=n-l*2+1,d=r-l*2+1;this.overlay_graphics.clear(),this.overlay_graphics.rect(h,c,u,d).stroke({color:10066329,width:1,alpha:0,pixelLine:!0});const _=5,g=_+5,p=10066329;for(let m=h;m<h+u;m+=g)this.overlay_graphics.rect(m,c,Math.min(_,h+u-m),1).fill({color:p,alph
570a:.7}),this.overlay_graphics.rect(m,c+d,Math.min(_,h+u-m),1).fill({color:p,alpha:.7});for(let m=c;m<c+d;m+=g)this.overlay_graphics.rect(h,m,1,Math.min(_,c+d-m)).fill({color:p,alpha:.7}),this.overlay_graphics.rect(h+u,m,1,Math.min(_,c+d-m)).fill({color:p,alpha:.7})}else this.overlay_graphics.clear()}),this.ready_resolve()}async setup_containers(){if(this.image_container=new U({eventMode:"static",sortableChildren:!0}),this.image_container.width=this.width,this.image_container.height=this.height,this.app.stage.sortableChildren=!0,this.app.stage.alpha=1,this.app.stage.addChild(this.image_container),this.image_container.scale.set(1),this.ui_container=new U({eventMode:"static"}),this.app.stage.addChild(this.ui_container),this.ui_container.width=this.width,this.ui_container.height=this.height,this.outline_container=new U,this.outline_container.zIndex=-10,this.outline_graphics=new be,this.outline_graphics.rect(0,0,this.width,this.height).fill({color:this.dark?3355443:16777215,alpha:0}),!this.dark){const i=new Dy({alpha:.1,blur:2,color:0,offset:{x:0,y:0},quality:4,shadowOnly:!1});this.outline_graphics.filters=[i]}this.outline_container.addChild(this.outline_graphics),this.app.stage.addChild(this.outline_container),this.overlay_container=new U,this.app.stage.addChild(this.overlay_container),this.overlay_container.width=this.width,this.overlay_container.height=this.height,this.overlay_container.zIndex=999,this.overlay_container.eventMode="static",this.overlay_container.interactiveChildren=!0,this.overlay_graphics=new be,this.overlay_container.addChild(this.overlay_graphics),this.overlay_graphics.rect(0,0,this.width,this.height).fill({color:0,alpha:0});const e=this.app.screen.width/2,t=this.app.screen.height/2;this.image_container.position.set(e,t),this.outline_container.position.set(e,t),this.layer_manager=new qy(this.image_container,this.app,this.fixed_canvas,this.dark,this.border_region,this.layer_options),this.layers=this.layer_manager.layer_store}resize_canvas(e,t){this.app.renderer&&this.app.renderer.resize(e,t);const i=e/2,n=t/2;this.image_container&&this.image_container.position.set(i,n),this.outline_container&&this.outline_container.position.set(i,n)}reset(){const e=this.tools.get("zoom");e&&(e.cleanup(),e.setup(this.context,this.current_tool,this.current_subtool))}async set_image_properties(e){let t=typeof e.animate<"u"?!e.animate:!0;if(e.position){const i=this.position.set(e.position,{hard:t});t&&await i}if(e.scale){const i=this.scale.set(e.scale,{hard:t});t&&await i}if(e.width&&e.height){this.width=e.width,this.height=e.height;const i=this.dimensions.set({width:e.width,height:e.height},{hard:t});t&&await i}}async execute_command(e){await this.command_manager.execute(e)}undo(){this.command_manager.undo(),this.notify("change")}redo(){this.command_manager.redo(),this.notify("change")}async add_image({image:e,resize:t=!0}){await this.tools.get("image").add_image({image:e,fixed_canvas:this.fixed_canvas,border_region:this.border_region})}async add_image_from_url(e){const t=this.tools.get("image"),i=await Ai.load(e);await t.add_image({image:i,fixed_canvas:this.fixed_canvas,border_region:this.border_region});const n=this.tools.get("resize");n&&typeof n.set_border_region=="function"&&n.set_border_region(this.border_region),this.notify("change"),this.notify("input")}set_tool(e){this.current_tool=e;for(const t of this.tools.values())t.set_tool(this.current_tool,this.current_subtool)}set_subtool(e){this.current_subtool=e;for(const t of this.tools.values())t.set_tool(this.current_tool,this.current_subtool)}set_background_image(e){this.background_image=e}async reset_canvas(){this.layer_manager.reset_layers(this.width,this.height),this.background_image=void 0,this.background_image_present.set(!1),await this.set_image_properties({width:this.width,height:this.height,scale:1,position:{x:0,y:0},animate:!1}),this.command_manager=new Bh,this.layer_manager.create_background_layer(this.width,this.height);for(const t of this.tools.values())t.cleanup(),t.setup(this.context,this.current_tool,this.current_subtool);const e=this.tools.get("zoom");e&&e.min_zoom.subscribe(t=>{this.min_zoom.set(t)}),this.notify("change")}add_layer(){this.layer_manager.create_layer({width:this.width,height:this.height,layer_name:void 0,user_created:!0,layer_id:void 0,make_active:!0}),this.notify("change")}async add_layers_from_url(e){const t=this.layer_manager.get_layers();if(t.forEach(n=>this.layer_manager.delete_layer(n.id)),e===void 0||e.length===0){this.layer_manager.create_layer({width:this.width,height:this.height,layer_name:void 0,user_created:!1});return}for await(const n of e)await this.layer_manager.add_layer_from_url(n);this.layer_manager.set_active_layer(t[0].id);const i=this.tools.get("resize");i&&typeof i.set_border_region=="function"&&i.set_border_region(this.border_region),this.notify("change"),this.notify("input")}set_layer(e){this.layer_manager.set_active_layer(e),this.notify("change")}move_layer(e,t){this.layer_manager.move_layer(e,t),this.notify("change")}delete_layer(e){this.layer_manager.delete_layer(e),this.notify("change")}modify_canvas_size(e,t,i,n){const r=this.width,o=this.height;this.layer_manager.resize_all_layers(e,t,n,i,r,o),this.width=e,this.height=t,this.set_image_properties({width:e,height:t,scale:1,position:{x:0,y:0},animate:!1}),this.notify("change")}async get_blobs(){return await this.layer_manager.get_blobs(this.width,this.height)}on(e,t){this.event_callbacks.set(e,[...this.event_callbacks.get(e)||[],t])}off(e,t){this.event_callbacks.set(e,this.event_callbacks.get(e)?.filter(i=>i!==t)||[])}notify(e){for(const t of this.event_callbacks.get(e)||[])t()}destroy(){this.app&&this.app?.destroy()}resize(e,t){this.set_image_properties({width:e,height:t}),this.reset()}async get_crop_bounds(){const e=this.tools.get("crop"),t=e.get_crop_bounds();return{image:await e.get_image(),...t}}get background_image_sprite(){return this.background_image}set_layer_options(e){this.layer_options=e,this.layer_manager.set_layer_options(e,this.width,this.height)}toggle_layer_visibility(e){this.layer_manager.toggle_layer_visibility(e)}}class Yy{name="crop";image_editor_context;current_tool="image";current_subtool="crop";CORNER_SIZE=25;LINE_THICKNESS=5;HANDLE_COLOR=0;HIT_AREA_SIZE=40;is_dragging=!1;selected_handle=null;active_corner_index=-1;active_edge_index=-1;last_pointer_position=null;crop_bounds={x:0,y:0,width:0,height:0};crop_ui_container=null;crop_mask=null;dimensions={width:0,height:0};position={x:0,y:0};scale=1;is_dragging_window=!1;drag_start_position=null;drag_start_bounds=null;background_image_watcher=null;has_been_manually_changed=!1;event_callbacks=new Map;async setup(e,t,i){this.image_editor_context=e,this.current_tool=t,this.current_subtool=i,e.dimensions.subscribe(r=>{this.dimensions=r,this.crop_bounds={x:0,y:0,width:r.width,height:r.height},this.crop_ui_container&&this.update_crop_ui(),this.set_crop_mask(),this.update_crop_mask()}),e.position.subscribe(r=>{this.position=r}),e.scale.subscribe(r=>{this.scale=r}),this.background_image_watcher=()=>{this.crop_mask&&this.current_tool==="image"&&this.current_subtool==="crop"&&this.image_editor_context.background_image&&this.image_editor_context.background_image.setMask(this.crop_mask)},this.image_editor_context.app.ticker.add(this.background_image_watcher),await this.init_crop_ui(),this.setup_event_listeners();const n=t==="image"&&i==="crop";this.crop_ui_container&&(this.crop_ui_container.visible=n)}cleanup(){this.crop_ui_container&&this.image_editor_context.app.stage.removeChild(this.crop_ui_container),this.crop_mask&&(this.crop_mask.parent&&this.crop_mask.parent.removeChild(this.crop_mask),this.image_editor_context.background_image&&this.image_editor_context.background_image.mask===this.crop_mask&&(this.image_editor_context.background_image.mask=null),this.image_editor_context.
570image_container.mask===this.crop_mask&&(this.image_editor_context.image_container.mask=null)),this.crop_mask=null,this.crop_ui_container=null,this.background_image_watcher&&(this.image_editor_context.app.ticker.remove(this.background_image_watcher),this.background_image_watcher=null),this.cleanup_event_listeners()}set_tool(e,t){this.current_tool=e,this.current_subtool=t;const i=e==="image"&&t==="crop";this.crop_ui_container&&(this.crop_ui_container.visible=i),i&&this.crop_mask&&this.update_crop_mask()}set_crop_mask(){this.crop_mask&&(this.crop_mask.parent&&this.crop_mask.parent.removeChild(this.crop_mask),this.image_editor_context.image_container.mask===this.crop_mask&&(this.image_editor_context.image_container.mask=null),this.image_editor_context.background_image&&this.image_editor_context.background_image.mask===this.crop_mask&&(this.image_editor_context.background_image.mask=null)),this.crop_mask=new be,this.image_editor_context.image_container.addChild(this.crop_mask)}async init_crop_ui(){this.image_editor_context.background_image?.getLocalBounds(),this.crop_ui_container=this.make_crop_ui(this.dimensions.width*this.scale,this.dimensions.height*this.scale),this.crop_ui_container.position.set(this.position.x,this.position.y),this.crop_ui_container.visible=!1,this.image_editor_context.app.stage.addChild(this.crop_ui_container),this.set_crop_mask(),this.image_editor_context.app.ticker.add(this.update_crop_ui.bind(this)),this.update_crop_mask()}make_crop_ui(e,t){const i=new U;i.eventMode="static",i.interactiveChildren=!0;const n=new be().rect(0,0,e,t).stroke({width:1,color:0,alignment:0,alpha:.5});return n.eventMode="static",n.cursor="move",n.hitArea=new se(0,0,e,t),n.on("pointerdown",this.handle_window_drag_start.bind(this)),i.addChild(n),this.create_corner_handles(i,e,t),this.create_edge_handles(i,e,t),i}create_handle(e=!1){const t=new U;t.eventMode="static";const i=new be;e?i.rect(0,0,this.CORNER_SIZE*1.5,this.LINE_THICKNESS).fill(this.HANDLE_COLOR):i.rect(0,0,this.CORNER_SIZE,this.LINE_THICKNESS).rect(0,0,this.LINE_THICKNESS,this.CORNER_SIZE).fill(this.HANDLE_COLOR),t.addChild(i);const n=e?this.HIT_AREA_SIZE*1.5:this.HIT_AREA_SIZE;return t.hitArea=new se(-n/2+this.LINE_THICKNESS,-n/2+this.LINE_THICKNESS,n,n),t}create_edge_handles(e,t,i){[-1,1].forEach((n,r)=>{const o=this.create_handle(!0);o.rotation=0,o.on("pointerdown",a=>{this.handle_pointer_down(a,o,-1,r)}),o.x=t/2-this.CORNER_SIZE*3/2,o.y=n<0?-this.LINE_THICKNESS:i,o.cursor="ns-resize",e.addChild(o)}),[-1,1].forEach((n,r)=>{const o=this.create_handle(!0);o.rotation=Math.PI/2,o.on("pointerdown",a=>{this.handle_pointer_down(a,o,-1,r+2)}),o.x=n<0?-this.LINE_THICKNESS:t,o.y=i/2-this.CORNER_SIZE*3/2,o.cursor="ew-resize",e.addChild(o)})}create_corner_handles(e,t,i){[{x:0,y:0,xScale:1,yScale:1,cursor:"nwse-resize"},{x:t,y:0,xScale:-1,yScale:1,cursor:"nesw-resize"},{x:0,y:i,xScale:1,yScale:-1,cursor:"nesw-resize"},{x:t,y:i,xScale:-1,yScale:-1,cursor:"nwse-resize"}].forEach(({x:r,y:o,xScale:a,yScale:l,cursor:h},c)=>{const u=this.create_handle(!1);u.x=r-(a<0?-this.LINE_THICKNESS:this.LINE_THICKNESS),u.y=o-(l<0?-this.LINE_THICKNESS:this.LINE_THICKNESS),u.scale.set(a,l),u.on("pointerdown",d=>{this.handle_pointer_down(d,u,c,-1)}),u.cursor=h,e.addChild(u)})}handle_pointer_down(e,t,i,n){if(this.current_subtool!=="crop")return;e.stopPropagation(),this.is_dragging=!0,this.selected_handle=t,this.active_corner_index=i,this.active_edge_index=n;const r=this.image_editor_context.image_container.toLocal(e.global);this.last_pointer_position=new V(r.x,r.y)}update_crop_bounds(e){this.has_been_manually_changed=!0;const t=new V(e.x,e.y),i={x:this.crop_bounds.x,y:this.crop_bounds.y,width:this.crop_bounds.width,height:this.crop_bounds.height};if(this.active_corner_index!==-1)switch(this.active_corner_index){case 0:const n=Math.max(20,i.width-t.x),r=i.width-n;this.crop_bounds.width=n,this.crop_bounds.x=i.x+r;const o=Math.max(20,i.height-t.y),a=i.height-o;this.crop_bounds.height=o,this.crop_bounds.y=i.y+a;break;case 1:this.crop_bounds.width=Math.max(20,i.width+t.x);const l=Math.max(20,i.height-t.y),h=i.height-l;this.crop_bounds.height=l,this.crop_bounds.y=i.y+h;break;case 2:const c=Math.max(20,i.width-t.x),u=i.width-c;this.crop_bounds.width=c,this.crop_bounds.x=i.x+u,this.crop_bounds.height=Math.max(20,i.height+t.y);break;case 3:this.crop_bounds.width=Math.max(20,i.width+t.x),this.crop_bounds.height=Math.max(20,i.height+t.y);break}else if(this.active_edge_index!==-1)switch(this.active_edge_index){case 0:const n=Math.max(20,i.height-t.y),r=i.height-n;this.crop_bounds.height=n,this.crop_bounds.y=i.y+r;break;case 1:this.crop_bounds.height=Math.max(20,i.height+t.y);break;case 2:const o=Math.max(20,i.width-t.x),a=i.width-o;this.crop_bounds.width=o,this.crop_bounds.x=i.x+a;break;case 3:this.crop_bounds.width=Math.max(20,i.width+t.x);break}this.constrain_crop_bounds(),this.update_crop_ui(),this.update_crop_mask(),this.crop_mask&&this.image_editor_context.background_image&&this.image_editor_context.background_image.setMask(this.crop_mask)}constrain_crop_bounds(){this.crop_bounds.x,this.crop_bounds.y,this.crop_bounds.width,this.crop_bounds.height,this.crop_bounds.width=Math.max(20,Math.min(this.crop_bounds.width,this.dimensions.width)),this.crop_bounds.height=Math.max(20,Math.min(this.crop_bounds.height,this.dimensions.height));const e=this.crop_bounds.x;if(this.crop_bounds.x=Math.max(0,Math.min(this.crop_bounds.x,this.dimensions.width-this.crop_bounds.width)),this.crop_bounds.x!==e&&this.active_corner_index===0||this.active_edge_index===2){const i=this.crop_bounds.x-e;this.crop_bounds.width-=i}const t=this.crop_bounds.y;if(this.crop_bounds.y=Math.max(0,Math.min(this.crop_bounds.y,this.dimensions.height-this.crop_bounds.height)),this.crop_bounds.y!==t&&(this.active_corner_index===0||this.active_corner_index===1||this.active_edge_index===0)){const i=this.crop_bounds.y-t;this.crop_bounds.height-=i}this.crop_bounds.width=Math.max(20,Math.min(this.crop_bounds.width,this.dimensions.width-this.crop_bounds.x)),this.crop_bounds.height=Math.max(20,Math.min(this.crop_bounds.height,this.dimensions.height-this.crop_bounds.y))}update_crop_mask(){if(!this.crop_mask)return;this.crop_mask.clear();const{width:e,height:t}=this.image_editor_context.background_image?.getLocalBounds()??{width:0,height:0};this.crop_mask.rect(0,0,e,t).fill({color:0,alpha:.4}).rect(this.crop_bounds.x,this.crop_bounds.y,this.crop_bounds.width,this.crop_bounds.height).cut(),this.image_editor_context.background_image&&(this.image_editor_context.background_image.mask=null),this.image_editor_context.
570image_container.mask===this.crop_mask&&(this.image_editor_context.image_container.mask=null)}update_crop_ui(){if(!this.crop_mask||!this.crop_ui_container)return;this.crop_ui_container.position.set(this.position.x+this.crop_bounds.x*this.scale,this.position.y+this.crop_bounds.y*this.scale);const e=this.crop_bounds.width*this.scale,t=this.crop_bounds.height*this.scale,i=this.crop_ui_container.getChildAt(0);i.clear().rect(0,0,e,t).stroke({width:1,color:0,alignment:0,alpha:.5}),i.hitArea=new se(0,0,e,t),this.update_handle_positions(e,t)}update_handle_positions(e,t){if(!this.crop_ui_container)return;const i=this.crop_ui_container.children.slice(1),n=i.slice(0,4),r=[{x:0,y:0},{x:e,y:0},{x:0,y:t},{x:e,y:t}];n.forEach((a,l)=>{const h=l%2===0?1:-1,c=l<2?1:-1;a.position.set(r[l].x-(h<0?-this.LINE_THICKNESS:this.LINE_THICKNESS),r[l].y-(c<0?-this.LINE_THICKNESS:this.LINE_THICKNESS))}),i.slice(4).forEach((a,l)=>{l<2?a.position.set(e/2-this.CORNER_SIZE*1.5/2,l===0?-this.LINE_THICKNESS:t):a.position.set(l===2?0:e+this.LINE_THICKNESS,t/2-this.CORNER_SIZE*1.5/2)})}setup_event_listeners(){const e=this.image_editor_context.app.stage;e.eventMode="static",e.on("pointermove",this.handle_pointer_move.bind(this)),e.on("pointerup",this.handle_pointer_up.bind(this)),e.on("pointerupoutside",this.handle_pointer_up.bind(this))}cleanup_event_listeners(){const e=this.image_editor_context.app.stage;e.off("pointermove",this.handle_pointer_move.bind(this)),e.off("pointerup",this.handle_pointer_up.bind(this)),e.off("pointerupoutside",this.handle_pointer_up.bind(this))}handle_pointer_move(e){if(this.current_subtool==="crop"){if(this.is_dragging_window&&this.drag_start_position&&this.drag_start_bounds){const t=this.image_editor_context.image_container.toLocal(e.global),i=new V(t.x-this.drag_start_position.x,t.y-this.drag_start_position.y);this.crop_bounds={x:this.drag_start_bounds.x+i.x,y:this.drag_start_bounds.y+i.y,width:this.drag_start_bounds.width,height:this.drag_start_bounds.height},this.constrain_crop_bounds(),this.update_crop_mask(),this.crop_mask&&this.image_editor_context.background_image&&this.image_editor_context.background_image.setMask(this.crop_mask);return}if(this.is_dragging&&this.selected_handle&&this.last_pointer_position){const t=this.image_editor_context.image_container.toLocal(e.global),i=new V(t.x,t.y),n=new V(i.x-this.last_pointer_position.x,i.y-this.last_pointer_position.y);this.update_crop_bounds(n),this.last_pointer_position=i,this.update_crop_mask()}}}handle_pointer_up(){this.current_subtool==="crop"&&(this.is_dragging=!1,this.is_dragging_window=!1,this.selected_handle=null,this.last_pointer_position=null,this.drag_start_position=null,this.drag_start_bounds=null,this.active_corner_index=-1,this.active_edge_index=-1,this.notify("change"))}handle_window_drag_start(e){if(this.current_subtool!=="crop")return;e.stopPropagation(),this.is_dragging_window=!0,this.has_been_manually_changed=!0;const t=this.image_editor_context.image_container.toLocal(e.global);this.drag_start_position=new V(t.x,t.y),this.drag_start_bounds={...this.crop_bounds}}get crop_manually_changed(){return this.has_been_manually_changed}on(e,t){this.event_callbacks.set(e,[...this.event_callbacks.get(e)||[],t])}off(e,t){this.event_callbacks.set(e,this.event_callbacks.get(e)?.filter(i=>i!==t)||[])}notify(e){for(const t of this.event_callbacks.get(e)||[])t()}get_crop_bounds(){const{width:e,height:t}=this.image_editor_context.background_image?.getLocalBounds()??{width:0,height:0};return{x:this.crop_bounds.x,y:this.crop_bounds.y,crop_dimensions:{width:this.crop_bounds.width,height:this.crop_bounds.height},image_dimensions:{width:e,height:t}}}get_image(){if(!this.image_editor_context.background_image)return Promise.resolve(null);const e=new U,t=new ue(this.image_editor_context.background_image.texture);return e.addChild(t),Fn(this.image_editor_context.app.renderer,e,this.crop_bounds)}}class jy{name="resize";image_editor_context;current_tool="image";current_subtool="size";current_cursor="unset";CORNER_SIZE=25;LINE_THICKNESS=5;HANDLE_COLOR=0;HIT_AREA_SIZE=40;borderRegion=0;is_dragging=!1;selected_handle=null;active_corner_index=-1;active_edge_index=-1;last_pointer_position=null;resize_ui_container=null;dimensions={width:0,height:0};position={x:0,y:0};scale=1;is_moving=!1;dom_mousedown_handler=null;
570dom_mousemove_handler=null;dom_mouseup_handler=null;event_callbacks=new Map;last_scale=1;async setup(e,t,i){if(this.image_editor_context=e,this.current_tool=t,this.current_subtool=i,e.background_image)if(e.background_image.borderRegion!==void 0)this.borderRegion=e.background_image.borderRegion;else{const n=e.background_image,r=e.image_container,o=Math.abs(n.position.x-(r.width-n.width)/2)<2,a=Math.abs(n.position.y-(r.height-n.height)/2)<2;(!o||!a)&&(this.borderRegion=Math.max(n.position.x,n.position.y),e.background_image.borderRegion=this.borderRegion)}if(e.dimensions.subscribe(n=>{this.dimensions=n,this.resize_ui_container&&this.update_resize_ui()}),e.position.subscribe(n=>{this.position=n,this.resize_ui_container&&this.current_tool==="image"&&this.current_subtool==="size"&&this.update_resize_ui()}),e.scale.subscribe(n=>{this.scale=n,this.resize_ui_container&&this.current_tool==="image"&&this.current_subtool==="size"&&this.update_resize_ui()}),await this.init_resize_ui(),this.setup_event_listeners(),this.current_subtool==="size"&&this.image_editor_context.background_image){const n=this.image_editor_context.background_image,r=this.image_editor_context.image_container,o=n.width,a=n.height,l=r.getLocalBounds(),h=l.width,c=l.height,u=-(o-h),d=-(a-c),_=0,f=0,g=o>h&&(n.position.x<u||n.position.x>_),p=a>c&&(n.position.y<d||n.position.y>f);(g||p)&&this.apply_boundary_constraints()}}cleanup(){this.resize_ui_container&&this.image_editor_context.app.stage.removeChild(this.resize_ui_container),this.cleanup_event_listeners()}set_tool(e,t){if(this.current_tool=e,this.current_subtool=t,e==="image"&&t==="size"){if(this.image_editor_context.background_image){const i=this.image_editor_context.background_image.borderRegion;typeof i=="number"&&i>0&&(this.borderRegion=i)}if(this.show_resize_ui(),this.image_editor_context.background_image){const i=this.image_editor_context.background_image,n=this.image_editor_context.image_container,r=i.width,o=i.height,a=n.getLocalBounds(),l=a.width,h=a.height,c=l-this.borderRegion*2,u=h-this.borderRegion*2,d=r>c?-(r-c)+this.borderRegion:this.borderRegion,_=r>c?this.borderRegion:l-r-this.borderRegion,f=o>u?-(o-u)+this.borderRegion:this.borderRegion,g=o>u?this.borderRegion:h-o-this.borderRegion,p=i.position.x<d||i.position.x>_,m=i.position.y<f||i.position.y>g;(p||m)&&this.apply_boundary_constraints()}}else this.hide_resize_ui()}async init_resize_ui(){this.resize_ui_container=this.make_resize_ui(this.dimensions.width*this.scale,this.dimensions.height*this.scale),this.resize_ui_container.position.set(this.position.x,this.position.y),this.resize_ui_container.visible=!1,this.image_editor_context.app.stage.addChild(this.resize_ui_container)}make_resize_ui(e,t){const i=new U;i.eventMode="static",i.interactiveChildren=!0;const n=new be().rect(0,0,e,t).stroke({width:1,color:0,alignment:0,alpha:.3}),r=new be;r.rect(0,0,e,t).stroke({width:1,color:0,alpha:.7,pixelLine:!0});const o=5,l=o+5;for(let c=0;c<e;c+=l*2)r.rect(c,0,Math.min(o,e-c),1).fill(0),r.rect(c,t-1,Math.min(o,e-c),1).fill(0);for(let c=0;c<t;c+=l*2)r.rect(0,c,1,Math.min(o,t-c)).fill(0),r.rect(e-1,c,1,Math.min(o,t-c)).fill(0);i.addChild(n),i.addChild(r);const h=new be().rect(0,0,e,t).fill(16777215,0);return h.eventMode="static",h.cursor="move",i.addChild(h),this.create_corner_handles(i,e,t),this.create_edge_handles(i,e,t),i}create_handle(e=!1){const t=new U;t.eventMode="static",t.cursor="pointer";const i=new be,n=e?8:10;i.rect(-n/2,-n/2,n,n).fill(16777215).stroke({width:1,color:this.HANDLE_COLOR}),t.addChild(i);const r=e?this.HIT_AREA_SIZE*1.5:this.HIT_AREA_SIZE;return t.hitArea=new se(-r/2,-r/2,r,r),t}create_edge_handles(e,t,i){[-1,1].forEach((n,r)=>{const o=this.create_handle(!0);o.rotation=0,o.on("pointerdown",a=>{this.handle_pointer_down(a,o,-1,r)}),o.x=t/2,o.y=n<0?0:i,o.cursor="ns-resize",e.addChild(o)}),[-1,1].forEach((n,r)=>{const o=this.create_handle(!0);o.rotation=0,o.on("pointerdown",a=>{this.handle_pointer_down(a,o,-1,r+2)}),o.x=n<0?0:t,o.y=i/2,o.cursor="ew-resize",e.addChild(o)})}create_corner_handles(e,t,i){[{x:0,y:0,cursor:"nwse-resize"},{x:t,y:0,cursor:"nesw-resize"},{x:0,y:i,cursor:"nesw-resize"},{x:t,y:i,cursor:"nwse-resize"}
570].forEach(({x:r,y:o,cursor:a},l)=>{const h=this.create_handle(!1);h.x=r,h.y=o,h.on("pointerdown",c=>{this.handle_pointer_down(c,h,l,-1)}),h.cursor=a,e.addChild(h)})}handle_pointer_down(e,t,i,n){if(this.current_subtool!=="size")return;e.stopPropagation(),this.is_dragging=!0,this.selected_handle=t,this.active_corner_index=i,this.active_edge_index=n;const r=this.image_editor_context.image_container.toLocal(e.global);this.last_pointer_position=new V(r.x,r.y)}maintain_aspect_ratio(e,t,i,n){const r=Math.abs(n.x),o=Math.abs(n.y);return r>o*1.2?t=e/i:o>r*1.2?e=t*i:e/i>t?t=e/i:e=t*i,{width:e,height:t}}limit_dimensions(e,t,i){const n=this.dimensions.width,r=this.dimensions.height;let o=e,a=t;return o>n&&(i&&this.active_corner_index!==-1&&(a=n/o*a),o=n),a>r&&(i&&this.active_corner_index!==-1&&(o=r/a*o),a=r),o=Math.max(20,o),a=Math.max(20,a),{width:o,height:a}}calculate_position_deltas(e,t,i,n){let r=0,o=0;return this.active_corner_index===0||this.active_edge_index===2?r=e-i:this.active_corner_index===2&&(r=e-i,o=0),(this.active_corner_index===0||this.active_corner_index===1||this.active_edge_index===0)&&(o=t-n),{x:r,y:o}}apply_boundary_constraints(){if(!this.image_editor_context.background_image)return;const e=this.image_editor_context.background_image,t=this.image_editor_context.image_container;let i=e.position.x,n=e.position.y;const r=t.width,o=t.height,a=e.width,l=e.height,h=r-this.borderRegion*2,c=o-this.borderRegion*2;if(a>h){const u=-(a-h)+this.borderRegion,d=this.borderRegion;i=Math.max(u,Math.min(d,i))}else{const u=this.borderRegion,d=r-a-this.borderRegion;(i<u||i>d)&&(i=Math.max(u,Math.min(d,i)))}if(l>c){const u=-(l-c)+this.borderRegion,d=this.borderRegion;n=Math.max(u,Math.min(d,n))}else{const u=this.borderRegion,d=o-l-this.borderRegion;(n<u||n>d)&&(n=Math.max(u,Math.min(d,n)))}if(e.position.set(i,n),this.resize_ui_container){const u=t.position.x+i*this.scale,d=t.position.y+n*this.scale;this.resize_ui_container.position.set(u,d)}}update_resize_bounds(e,t=!1){const i=this.image_editor_context.background_image;if(!i)return;const n=i.width,r=i.height,o=i.position.x,a=i.position.y,l=n/r;let h;if(this.active_corner_index!==-1){switch(this.active_corner_index){case 0:h=new V(o-e.x,a-e.y);break;case 1:h=new V(o+n+e.x,a-e.y);break;case 2:h=new V(o-e.x,a+r+e.y);break;case 3:h=new V(o+n+e.x,a+r+e.y);break;default:return}const c=this.handle_direct_corner_resize(h,n,r,o,a,l,t);i.width=c.width,i.height=c.height,i.position.set(c.x,c.y)}else if(this.active_edge_index!==-1){switch(this.active_edge_index){case 0:h=new V(o+n/2,a-e.y);break;case 1:h=new V(o+n/2,a+r+e.y);break;case 2:h=new V(o-e.x,a+r/2);break;case 3:h=new V(o+n+e.x,a+r/2);break;default:return}const c=this.handle_direct_edge_resize(h,n,r,o,a);i.width=c.width,i.height=c.height,i.position.set(c.x,c.y)}this.update_resize_ui()}update_resize_ui(){if(!this.resize_ui_container||!this.image_editor_context.background_image||!this.image_editor_context.background_image.position)return;const e=this.image_editor_context.background_image,i=this.image_editor_context.image_container.getGlobalPosition(),n=e.position.x*this.scale,r=e.position.y*this.scale;this.resize_ui_container.position.set(i.x+n,i.y+r);const o=e.width*this.scale,a=e.height*this.scale;this.resize_ui_container.getChildAt(0).clear().rect(0,0,o,a).stroke({width:1,color:0,alignment:0,alpha:.3});const h=this.resize_ui_container.getChildAt(1);if(h.clear(),h.rect(0,0,o,a).stroke({width:1,color:0,alpha:.7,pixelLine:!0}),!this.is_dragging&&!this.is_moving&&Math.abs(this.scale-this.last_scale)<.001){for(let f=0;f<o;f+=10*2)h.rect(f,0,Math.min(5,o-f),1).fill(0),h.rect(f,a-1,Math.min(5,o-f),1).fill(0);for(let f=0;f<a;f+=10*2)h.rect(0,f,1,Math.min(5,a-f)).fill(0),h.rect(o-1,f,1,Math.min(5,a-f)).fill(0)}this.last_scale=this.scale,this.resize_ui_container.getChildAt(2).clear().rect(0,0,o,a).fill(16777215,0),this.update_handle_positions(o,a)}update_handle_positions(e,t){if(!this.resize_ui_container)return;const i=this.resize_ui_container.children.slice(3);this.resize_ui_container.getChildAt(2).clear().rect(0,0,e,t).fill(16777215,0);const r=i.slice(0,4),o=[{x:0,y:0},{x:e,y:0},{x:0,y:t},{x:e,y:t}];r.forEach((l,h)=>{l.position.set(o[h].x,o[h].y)}),i.slice(4).forEach((l,h)=>{h<2?l.position.set(e/2,h===0?0:t):l.position.set(h===2?0:e,t/2)})}setup_event_listeners(){const e=this.image_editor_context.app.stage;e.eventMode="static",e.on("pointermove",this.handle_pointer_move.bind(this)),e.on("pointerup",this.handle_pointer_up.bind(this)),e.on("pointerupoutside",this.handle_pointer_up.bind(this)),this.setup_dom_event_listeners()}setup_dom_event_listeners(){this.cleanup_dom_event_listeners();const e=this.image_editor_context.app.canvas;
570this.dom_mousedown_handler=t=>{if(this.current_subtool!=="size"||this.is_dragging||this.selected_handle||!this.image_editor_context.background_image)return;const i=this.image_editor_context.background_image,r=this.image_editor_context.image_container.getBounds(),o=e.getBoundingClientRect(),a=t.clientX-o.left,l=t.clientY-o.top,h=(a-r.x)/this.scale,c=(l-r.y)/this.scale;h>=i.position.x&&h<=i.position.x+i.width&&c>=i.position.y&&c<=i.position.y+i.height&&(this.is_moving=!0,this.last_pointer_position=new V(h,c),t.preventDefault(),t.stopPropagation())},this.dom_mousemove_handler=t=>{if(this.current_subtool!=="size"||!this.is_moving||!this.last_pointer_position||!this.image_editor_context.background_image)return;const n=this.image_editor_context.image_container.getBounds(),r=e.getBoundingClientRect(),o=t.clientX-r.left,a=t.clientY-r.top,l=(o-n.x)/this.scale,h=(a-n.y)/this.scale,c=new V(l,h);this.handle_image_dragging(c),this.last_pointer_position=c,t.preventDefault(),t.stopPropagation()},this.dom_mouseup_handler=t=>{this.current_subtool!=="size"||!this.is_moving||(this.is_moving=!1,this.last_pointer_position=null,this.update_resize_ui(),t.preventDefault(),t.stopPropagation())},e.addEventListener("mousedown",this.dom_mousedown_handler),window.addEventListener("mousemove",this.dom_mousemove_handler),window.addEventListener("mouseup",this.dom_mouseup_handler)}cleanup_dom_event_listeners(){const e=this.image_editor_context.app.canvas;this.dom_mousedown_handler&&(e.removeEventListener("mousedown",this.dom_mousedown_handler),this.dom_mousedown_handler=null),this.dom_mousemove_handler&&(window.removeEventListener("mousemove",this.dom_mousemove_handler),this.dom_mousemove_handler=null),this.dom_mouseup_handler&&(window.removeEventListener("mouseup",this.dom_mouseup_handler),this.dom_mouseup_handler=null)}cleanup_event_listeners(){const e=this.image_editor_context.app.stage;e.off("pointermove",this.handle_pointer_move.bind(this)),e.off("pointerup",this.handle_pointer_up.bind(this)),e.off("pointerupoutside",this.handle_pointer_up.bind(this)),this.cleanup_dom_event_listeners()}handle_pointer_move(e){if(this.current_subtool!=="size")return;const t=this.image_editor_context.image_container.toLocal(e.global),i=new V(t.x,t.y);if(this.is_moving&&this.last_pointer_position)this.handle_image_dragging(i),this.last_pointer_position=i;else if(this.is_dragging&&this.selected_handle){if(!this.image_editor_context.background_image)return;const n=this.image_editor_context.background_image,r=this.active_corner_index!==-1&&!e.shiftKey,o=n.width,a=n.height,l=n.position.x,h=n.position.y,c=o/a;let u;if(this.active_corner_index!==-1)u=this.handle_direct_corner_resize(i,o,a,l,h,c,r);else if(this.active_edge_index!==-1)u=this.handle_direct_edge_resize(i,o,a,l,h);else return;u=this.limit_dimensions_to_container(u,l,h,o,a,r),n.width=u.width,n.height=u.height,n.position.set(u.x,u.y),this.update_resize_ui(),this.last_pointer_position=i}}handle_pointer_up(){this.current_subtool==="size"&&(this.is_dragging=!1,this.is_moving=!1,this.selected_handle=null,this.last_pointer_position=null,this.active_corner_index=-1,this.active_edge_index=-1,this.update_resize_ui(),this.notify("change"))}handle_image_dragging(e){if(!this.last_pointer_position||!this.image_editor_context.background_image)return;const t=this.image_editor_context.background_image,i=this.image_editor_context.image_container.getLocalBounds(),n=e.x-this.last_pointer_position.x,r=e.y-this.last_pointer_position.y;let o=t.position.x+n,a=t.position.y+r;const l=i.width,h=i.height,c=t.width,u=t.height,d=l-this.borderRegion*2,_=h-this.borderRegion*2;if(c>d){const f=-(c-d)+this.borderRegion,g=this.borderRegion;o=Math.max(f,Math.min(g,o))}else{const f=this.borderRegion,g=l-c-this.borderRegion;o=Math.max(f,Math.min(g,o))}if(u>_){const f=-(u-_)+this.borderRegion,g=this.borderRegion;a=Math.max(f,Math.min(g,a))}else{const f=this.borderRegion,g=h-u-this.borderRegion;a=Math.max(f,Math.min(g,a))}t.position.set(o,a),this.update_resize_ui()}handle_direct_corner_resize(e,t,i,n,r,o,a){let l=0,h=0,c=n,u=r;switch(this.active_corner_index){case 0:l=n+t-e.x,h=r+i-e.y;break;case 1:l=e.x-n,h=r+i-e.y;break;case 2:l=n+t-e.x,h=e.y-r;break;case 3:l=e.x-n,h=e.y-r;break}l=Math.max(20,l),h=Math.max(20,h);let d=l,_=h;if(a){const f={x:e.x-(n+t/2),y:e.y-(r+i/2)},g=Math.abs(Math.atan2(f.y,f.x));g<Math.PI/4||g>3*Math.PI/4?_=d/o:d=_*o}switch(this.active_corner_index){case 0:c=n+t-d,u=r+i-_;break;case 1:u=r+i-_;break;case 2:c=n+t-d;break}return{width:d,height:_,x:c,y:u}}handle_direct_edge_resize(e,t,i,n,r){let o=t,a=i,l=n,h=r;switch(this.active_edge_index){case 0:a=Math.max(20,r+i-e.y),h=e.y;break;case 1:a=Math.max(20,e.y-r);break;case 2:o=Math.max(20,n+t-e.x),l=e.x;break;case 3:o=Math.max(20,e.x-n);break}return{width:o,height:a,x:l,y:h}}limit_dimensions_to_container(e,t,i,n,r,o){let{width:a,height:l,x:h,y:c}=e;const u=this.dimensions.width-this.borderRegion*2,d=this.dimensions.height-this.borderRegion*2,_=a,f=l,g=this.apply_size_limits(a,l,u,d,o,_/f);a=g.width,l=g.height;const p=this.adjust_position_for_resizing(a,l,t,i,n,r);return h=p.x,c=p.y,this.apply_border_constraints(a,l,h,c,o,_/f)}apply_size_limits(e,t,i,n,r,o){let a=e,l=t;const h=a>i,c=l>n;if(h&&c){const u=i/a,d=n/l;u<d?(a=i,r&&(l=a/o)):(l=n,r&&(a=l*o))}else h?(a=i,r&&(l=a/o)):c&&(l=n,r&&(a=l*o));return{width:a,height:l}}adjust_position_for_resizing(e,t,i,n,r,o){let a=i,l=n;switch(this.active_corner_index){case 0:a=i+r-e,l=n+o-t;break;case 1:l=n+o-t;break;case 2:a=i+r-e;break}if(this.active_edge_index!==-1)switch(this.active_edge_index){case 0:l=n+o-t;break;case 2:a=i+r-e;break}return{x:a,y:l}}apply_border_constraints(e,t,i,n,r,o){const a=this.apply_top_left_constraints(e,t,i,n,r,o),l=this.apply_bottom_right_constraints(a.width,a.height,a.x,a.y,r,o);return l.width=Math.max(20,l.width),l.height=Math.max(20,l.height),l}apply_top_left_constraints(e,t,i,n,r,o){let a=e,l=t,h=i,c=n;return h<this.borderRegion&&((this.active_corner_index===0||this.active_corner_index===2||this.active_edge_index===2)&&(a-=this.borderRegion-h,r&&(l=
570a/o)),h=this.borderRegion),c<this.borderRegion&&((this.active_corner_index===0||this.active_corner_index===1||this.active_edge_index===0)&&(l-=this.borderRegion-c,r&&(a=l*o)),c=this.borderRegion),{width:a,height:l,x:h,y:c}}apply_bottom_right_constraints(e,t,i,n,r,o){let a=e,l=t,h=i,c=n;if(h+a>this.dimensions.width-this.borderRegion)if(this.active_corner_index===1||this.active_corner_index===3||this.active_edge_index===3)a=this.dimensions.width-this.borderRegion-h,r&&(l=a/o);else{const d=h+a-(this.dimensions.width-this.borderRegion);h=Math.max(this.borderRegion,h-d)}if(c+l>this.dimensions.height-this.borderRegion)if(this.active_corner_index===2||this.active_corner_index===3||this.active_edge_index===1)l=this.dimensions.height-this.borderRegion-c,r&&(a=l*o);else{const d=c+l-(this.dimensions.height-this.borderRegion);c=Math.max(this.borderRegion,c-d)}return{width:a,height:l,x:h,y:c}}show_resize_ui(){if(this.resize_ui_container&&(this.resize_ui_container.visible=!0,this.update_resize_ui()),this.image_editor_context.background_image){const e=this.image_editor_context.background_image;this.current_cursor=e.cursor,e.cursor="move"}this.setup_dom_event_listeners()}hide_resize_ui(){if(this.resize_ui_container&&(this.resize_ui_container.visible=!1),this.image_editor_context.background_image){const e=this.image_editor_context.background_image;e.cursor=this.current_cursor}this.cleanup_dom_event_listeners()}on(e,t){this.event_callbacks.set(e,[...this.event_callbacks.get(e)||[],t])}off(e,t){this.event_callbacks.set(e,this.event_callbacks.get(e)?.filter(i=>i!==t)||[])}notify(e){for(const t of this.event_callbacks.get(e)||[])t()}set_border_region(e){this.borderRegion=e,this.image_editor_context?.background_image&&(this.image_editor_context.background_image.borderRegion=e),this.resize_ui_container&&this.update_resize_ui(),this.current_subtool==="size"&&this.image_editor_context?.background_image&&this.apply_boundary_constraints()}}function Ky(s,e){(s instanceof U||"cursor"in s)&&(s.cursor=e)}function bd(s,e){for(const t of s)Ky(t,e),t instanceof U&&t.children.length>0&&bd(t.children,e)}function Zy(s){return s!==null&&window.clearTimeout(s),null}class Qy{constructor(e,t,i){this.image_editor_context=e,this.state=t,this.scale=i,this.initialize_cursor(),this.initialize_brush_preview()}cursor_graphics=null;cursor_container=null;brush_preview_container=null;brush_preview_graphics=null;is_preview_visible=!1;is_cursor_over_image=!1;cursor_position_check_timeout=null;is_brush_or_erase_active=!1;_bound_update_cursor=null;_bound_check_cursor_over_image=null;is_over_image(){return this.is_cursor_over_image}setup_event_listeners(){this.cleanup_event_listeners(),this._bound_update_cursor=this.update_cursor_position.bind(this),this._bound_check_cursor_over_image=this.check_cursor_over_image.bind(this);const e=this.image_editor_context.app.stage;e.on("pointermove",this._bound_update_cursor),e.on("pointermove",this._bound_check_cursor_over_image),this.image_editor_context.image_container.on("pointerenter",this.on_image_container_pointer_enter.bind(this)),this.image_editor_context.image_container.on("pointerleave",this.on_image_container_pointer_leave.bind(this))}cleanup_event_listeners(){const e=this.image_editor_context.app.stage;this._bound_update_cursor&&(e.off("pointermove",this._bound_update_cursor),this._bound_update_cursor=null),this._bound_check_cursor_over_image&&(e.off("pointermove",this._bound_check_cursor_over_image),this._bound_check_cursor_over_image=null),this.image_editor_context.image_container.off("pointerenter"),this.image_editor_context.image_container.off("pointerleave"),this.cursor_position_check_timeout=Zy(this.cursor_position_check_timeout)}initialize_cursor(){this.cursor_container&&(this.cursor_container.parent&&this.cursor_container.parent.removeChild(this.cursor_container),this.cursor_container.destroy({children:!0}),this.cursor_container=null),this.cursor_container=new U,this.image_editor_context.ui_container.addChild(this.cursor_container),this.cursor_graphics=new be,this.cursor_container.addChild(this.cursor_graphics),this.update_cursor_appearance()}update_cursor_appearance(){if(!this.cursor_graphics)return;this.cursor_graphics.clear();const e=this.state.mode==="draw"?je(this.state.color).toString():16777215;this.cursor_graphics.circle(0,0,this.state.brush_size*this.scale).stroke({width:1.5,color:e,alpha:.8}),this.cursor_graphics.circle(0,0,1).fill({color:e,alpha:.8})}update_cursor_position(e){if(!this.cursor_container)return;
570const t=this.image_editor_context.image_container.toLocal(e.global),i=this.image_editor_context.ui_container.toLocal(this.image_editor_context.image_container.toGlobal(t));this.cursor_container.position.set(i.x,i.y)}check_cursor_over_image(e){this.cursor_position_check_timeout!==null&&(window.clearTimeout(this.cursor_position_check_timeout),this.cursor_position_check_timeout=null);const i=this.image_editor_context.image_container.getBounds(),n=this.is_cursor_over_image;this.is_cursor_over_image=e.global.x>=i.x&&e.global.x<=i.x+i.width&&e.global.y>=i.y&&e.global.y<=i.y+i.height,n!==this.is_cursor_over_image&&this.update_cursor_and_preview_visibility()}update_cursor_size(){this.update_cursor_appearance()}set_active(e){this.is_brush_or_erase_active=e,this.update_cursor_and_preview_visibility()}update_cursor_visibility(){this.cursor_container&&(this.cursor_container.visible=this.is_cursor_over_image&&this.is_brush_or_erase_active)}preview_brush(e){this.is_preview_visible=e,this.brush_preview_container&&(this.brush_preview_container.visible=e&&this.is_brush_or_erase_active),e&&(this.update_brush_preview(),this.update_brush_preview_position())}initialize_brush_preview(){this.brush_preview_container&&(this.brush_preview_container.parent&&this.brush_preview_container.parent.removeChild(this.brush_preview_container),this.brush_preview_container.destroy({children:!0}),this.brush_preview_container=null),this.brush_preview_container=new U,this.image_editor_context.ui_container.addChild(this.brush_preview_container),this.brush_preview_graphics=new be,this.brush_preview_container.addChild(this.brush_preview_graphics),this.brush_preview_container.visible=!1}update_brush_preview(){if(!this.brush_preview_graphics)return;this.brush_preview_graphics.clear();const e=this.state.brush_size*this.scale,t=this.state.mode==="draw"?je(this.state.color).setAlpha(this.state.opacity).toString():16777215;this.brush_preview_graphics.circle(0,0,e).fill({color:t,alpha:this.state.mode==="draw"?this.state.opacity:.3}),this.brush_preview_graphics.circle(0,0,e+1).stroke({width:1,color:0,alpha:.5})}update_brush_preview_position(){if(!this.brush_preview_container)return;const e=this.image_editor_context.image_container,t=e.width/2,i=e.height/2,n=e.toGlobal({x:t,y:i}),r=this.image_editor_context.ui_container.toLocal(n);this.brush_preview_container.position.set(r.x,r.y)}on_image_container_pointer_enter(){this.is_cursor_over_image=!0,this.update_cursor_and_preview_visibility()}on_image_container_pointer_leave(){this.is_cursor_over_image=!1,this.update_cursor_and_preview_visibility()}update_cursor_and_preview_visibility(){this.update_cursor_visibility(),this.brush_preview_container&&(this.brush_preview_container.visible=this.is_preview_visible&&this.is_brush_or_erase_active)}cleanup(){this.is_brush_or_erase_active=!1,this.cursor_container&&(this.cursor_container.parent&&this.cursor_container.parent.removeChild(this.cursor_container),this.cursor_container.destroy({children:!0}),this.cursor_container=null),this.brush_preview_container&&(this.brush_preview_container.parent&&this.brush_preview_container.parent.removeChild(this.brush_preview_container),this.brush_preview_container.destroy({children:!0}),this.brush_preview_container=null),this.cursor_position_check_timeout!==null&&(window.clearTimeout(this.cursor_position_check_timeout),this.cursor_position_check_timeout=null)}update_state(e,t){this.state=e,this.scale=t,this.update_cursor_appearance(),this.is_preview_visible&&this.update_brush_preview()}}class Jy{constructor(e,t){this.image_editor_context=e,this.app=t,this.dimensions={width:this.image_editor_context.image_container.width,height:this.image_editor_context.image_container.height}}stroke_texture=null;erase_texture=null;display_container=null;stroke_container=null;stroke_graphics=null;preview_sprite=null;erase_graphics=null;dimensions;is_new_stroke=!0;current_opacity=1;current_mode="draw";initialize_textures(){this.cleanup_textures();const e=this.image_editor_context.image_container.getLocalBounds();this.dimensions={width:e.width,height:e.height},this.stroke_texture=Ii.create({width:this.dimensions.width,height:this.dimensions.height,resolution:window.devicePixelRatio||1}),this.erase_texture=Ii.create({width:this.dimensions.width,height:this.dimensions.height,resolution:window.devicePixelRatio||1}),this.display_container=new U;const t=this.image_editor_context.layer_manager.get_active_layer();
570t?t.addChild(this.display_container):this.image_editor_context.image_container.addChild(this.display_container),this.stroke_container=new U,this.stroke_graphics=new be,this.stroke_container.addChild(this.stroke_graphics),this.erase_graphics=new be,this.preview_sprite=new ue(this.stroke_texture),this.preview_sprite.alpha=0,this.display_container.addChild(this.preview_sprite);const i=new U;this.app.renderer.render(i,{renderTexture:this.stroke_texture}),this.app.renderer.render(i,{renderTexture:this.erase_texture}),i.destroy(),this.is_new_stroke=!0,this.current_opacity=1}reinitialize(){(this.image_editor_context.image_container.width!==this.dimensions.width||this.image_editor_context.image_container.height!==this.dimensions.height)&&this.initialize_textures()}cleanup_textures(){this.stroke_texture&&(this.stroke_texture.destroy(),this.stroke_texture=null),this.erase_texture&&(this.erase_texture.destroy(),this.erase_texture=null),this.display_container&&(this.display_container.parent&&this.display_container.parent.removeChild(this.display_container),this.display_container.destroy({children:!0}),this.display_container=null),this.stroke_container=null,this.stroke_graphics=null,this.preview_sprite=null,this.erase_graphics=null}preserve_canvas_state(){this.is_new_stroke=!0}reset_eraser_mask(){!this.erase_graphics||!this.erase_texture||(this.erase_graphics.clear(),this.erase_graphics.beginFill(16777215,1),this.erase_graphics.drawRect(0,0,this.dimensions.width,this.dimensions.height),this.erase_graphics.endFill(),this.app.renderer.render(this.erase_graphics,{renderTexture:this.erase_texture}))}commit_stroke(){if(!this.stroke_texture||!this.preview_sprite||!this.stroke_graphics)return;this.preview_sprite.visible=!1;const e=this.image_editor_context.layer_manager.get_active_layer();if(!e)return;const i=this.image_editor_context.layer_manager.get_layers().find(a=>a.container===e);if(!i)return;const n=this.image_editor_context.layer_manager.get_layer_textures(i.id);if(!n)return;const r=this.current_opacity;if(this.current_mode==="draw"){const a=new U,l=new ue(n.draw);a.addChild(l);const h=new ue(this.stroke_texture);h.alpha=r,a.addChild(h),this.app.renderer.render(a,{renderTexture:n.draw}),a.destroy({children:!0})}else{if(!this.stroke_texture)return;const a=new U,l=new ue(n.draw);a.addChild(l);const h=new ue(this.stroke_texture);a.setMask({mask:h,inverse:!0}),this.app.renderer.render(a,{renderTexture:n.draw}),a.destroy({children:!0})}this.stroke_graphics&&this.stroke_graphics.clear();const o=new U;this.app.renderer.render(o,{renderTexture:this.stroke_texture}),o.destroy(),this.is_new_stroke=!0}calculateDistance(e,t,i,n){return Math.sqrt(Math.pow(i-e,2)+Math.pow(n-t,2))}draw_segment(e,t,i,n,r,o,a,l){if(!this.stroke_graphics||!this.stroke_texture||!this.stroke_container||!this.preview_sprite)return;this.current_mode=l,this.current_opacity=l==="draw"?Math.min(Math.max(a,0),1):.5;const h=r;if(this.is_new_stroke){this.stroke_graphics.clear();const u=new U;this.app.renderer.render(u,{renderTexture:this.stroke_texture}),u.destroy(),this.is_new_stroke=!1}if(l==="draw"){let u=16777215;try{o.startsWith("#")&&(u=parseInt(o.replace("#","0x"),16))}catch{u=16777215}this.stroke_graphics.setFillStyle({color:u,alpha:1})}else this.stroke_graphics.setFillStyle({color:16777215,alpha:1});const c=this.calculateDistance(e,t,i,n);if(c<.1)this.stroke_graphics.circle(e,t,h).fill();else{const u=Math.max(h/3,2),d=Math.max(Math.ceil(c/u),2);for(let _=0;_<d;_++){const f=_/(d-1),g=e+(i-e)*f,p=t+(n-t)*f;this.stroke_graphics.circle(g,p,h).fill()}}if(this.stroke_graphics.endFill(),this.app.renderer.render(this.stroke_container,{renderTexture:this.stroke_texture}),l==="draw")this.preview_sprite.texture=this.stroke_texture,this.preview_sprite.alpha=this.current_opacity,this.preview_sprite.tint=16777215;else{const u=this.image_editor_context.layer_manager.get_active_layer();if(!u)return;const _=this.image_editor_context.layer_manager.get_layers().find(A=>A.container===u);if(!_)return;const f=this.image_editor_context.layer_manager.get_layer_textures(_.id);if(!f)return;const g=Ii.create({width:this.dimensions.width,height:this.dimensions.height,resolution:window.devicePixelRatio||1}),p=new U,m=new ue(f.draw);p.addChild(m),this.app.renderer.render(p,{renderTexture:g}),p.destroy({children:!0});const b=new U,y=new ue(this.stroke_texture),w=new be;
570w.setFillStyle({color:16777215,alpha:.5}),w.rect(0,0,this.dimensions.width,this.dimensions.height).fill(),w.setMask({mask:y,inverse:!1}),b.addChild(w),this.app.renderer.render(b,{renderTexture:g}),this.preview_sprite.texture=g,this.preview_sprite.alpha=1,b.destroy({children:!0}),g.destroy()}this.preview_sprite.visible=!0}get_dimensions(){return this.dimensions}cleanup(){this.cleanup_textures()}}class ew{name="brush";image_editor_context;current_tool;current_subtool;state={opacity:1,brush_size:10,color:"#000000",mode:"draw"};brush_size=10;eraser_size=20;is_drawing=!1;last_x=0;last_y=0;scale=1;_bound_pointer_down=null;_bound_pointer_move=null;_bound_pointer_up=null;event_callbacks=new Map;brush_cursor=null;brush_textures=null;async setup(e,t,i){this.image_editor_context=e,this.current_tool=t,this.current_subtool=i,this.state.mode=t==="erase"?"erase":"draw",this.state.mode==="draw"?this.state.brush_size=this.brush_size:this.state.brush_size=this.eraser_size,e.scale.subscribe(n=>{this.scale=n,this.brush_cursor&&this.brush_cursor.update_state(this.state,this.scale)}),this.brush_cursor=new Qy(this.image_editor_context,this.state,this.scale),this.brush_cursor.set_active(t==="draw"||t==="erase"),this.brush_textures=new Jy(this.image_editor_context,e.app),this.brush_textures.initialize_textures(),this.setup_event_listeners(),this.handle_cursors(t)}handle_cursors(e){bd(this.image_editor_context.image_container.children,"none")}set_tool(e,t){this.current_tool=e,this.current_subtool=t,this.current_tool!=="erase"&&this.current_tool!=="draw"&&this.commit_pending_changes(),this.brush_cursor&&this.brush_cursor.set_active(e==="draw"||e==="erase");const i=e==="erase"?"erase":"draw";(e==="erase"||e==="draw")&&this.brush_textures?.initialize_textures(),this.state.mode!==i&&(this.state.mode=i,this.state.mode==="draw"?this.state.brush_size=this.brush_size:this.state.brush_size=this.eraser_size,this.brush_cursor&&this.brush_cursor.update_state(this.state,this.scale))}commit_pending_changes(){this.is_drawing&&this.on_pointer_up()}on_pointer_down(e){if(!this.image_editor_context.layer_manager.get_active_layer()?.visible||this.current_tool!=="erase"&&this.current_tool!=="draw"||this.brush_cursor&&!this.brush_cursor.is_over_image())return;this.brush_textures&&this.brush_textures.preserve_canvas_state();const i=this.image_editor_context.image_container.toLocal(e.global);this.is_drawing=!0,this.last_x=i.x,this.last_y=i.y,this.brush_textures&&this.brush_textures.draw_segment(i.x,i.y,i.x,i.y,this.state.brush_size,this.state.color,this.state.opacity,this.state.mode)}on_pointer_move(e){if(this.brush_cursor&&this.brush_cursor.update_cursor_position(e),!this.is_drawing)return;const t=this.image_editor_context.image_container.toLocal(e.global);this.brush_textures&&this.brush_textures.draw_segment(this.last_x,this.last_y,t.x,t.y,this.state.brush_size,this.state.color,this.state.opacity,this.state.mode),this.last_x=t.x,this.last_y=t.y}on_pointer_up(){this.is_drawing&&(this.is_drawing=!1,this.brush_textures&&this.brush_textures.commit_stroke(),this.notify("change"))}setup_event_listeners(){this.cleanup_event_listeners(),this._bound_pointer_down=this.on_pointer_down.bind(this),this._bound_pointer_move=this.on_pointer_move.bind(this),this._bound_pointer_up=this.on_pointer_up.bind(this);const e=this.image_editor_context.image_container;e.eventMode="static",e.interactiveChildren=!0;const t=this.image_editor_context.app.stage;t.eventMode="static",t.on("pointerdown",this._bound_pointer_down),t.on("pointermove",this._bound_pointer_move),t.on("pointerup",this._bound_pointer_up),t.on("pointerupoutside",this._bound_pointer_up),this.brush_cursor&&this.brush_cursor.setup_event_listeners()}cleanup_event_listeners(){const e=this.image_editor_context.app.stage;this._bound_pointer_down&&(e.off("pointerdown",this._bound_pointer_down),this._bound_pointer_down=null),this._bound_pointer_move&&(e.off("pointermove",this._bound_pointer_move),this._bound_pointer_move=null),this._bound_pointer_up&&(e.off("pointerup",this._bound_pointer_up),e.off("pointerupoutside",this._bound_pointer_up),this._bound_pointer_up=null),this.brush_curs
570or&&this.brush_cursor.cleanup_event_listeners()}set_brush_size(e){this.brush_size=e,this.state.mode==="draw"&&(this.state.brush_size=e,this.brush_cursor&&this.brush_cursor.update_state(this.state,this.scale))}set_brush_color(e){const t=je(e).toHexString();this.state.color=t,this.brush_cursor&&this.brush_cursor.update_state(this.state,this.scale)}set_brush_opacity(e){const t=Math.max(0,Math.min(1,e));this.state.opacity=t,this.brush_cursor&&this.brush_cursor.update_state(this.state,this.scale)}set_eraser_size(e){this.eraser_size=e,this.state.mode==="erase"&&(this.state.brush_size=e,this.brush_cursor&&this.brush_cursor.update_state(this.state,this.scale))}get_current_size(){return this.state.mode==="draw"?this.brush_size:this.eraser_size}preview_brush(e){this.brush_cursor&&this.brush_cursor.preview_brush(e)}cleanup(){this.commit_pending_changes(),this.cleanup_event_listeners(),this.brush_textures&&(this.brush_textures.cleanup(),this.brush_textures=null),this.brush_cursor&&(this.brush_cursor.cleanup(),this.brush_cursor=null)}on(e,t){this.event_callbacks.set(e,[...this.event_callbacks.get(e)||[],t])}off(e,t){this.event_callbacks.set(e,this.event_callbacks.get(e)?.filter(i=>i!==t)||[])}notify(e){for(const t of this.event_callbacks.get(e)||[])t()}}const{SvelteComponent:tw,action_destroyer:iw,append:ot,attr:yt,check_outros:qt,create_component:Bi,destroy_component:Li,detach:ys,element:ai,empty:sw,ensure_array_like:Lh,flush:Sn,group_outros:Vt,init:nw,insert:ws,is_function:rw,listen:yd,mount_component:$i,noop:wd,outro_and_destroy_block:ow,run_all:aw,safe_not_equal:lw,set_data:xd,space:Fi,stop_propagation:vd,subscribe:hw,text:kd,toggle_class:jn,transition_in:Q,transition_out:re,update_keyed_each:cw}=window.__gradio__svelte__internal,{createEventDispatcher:uw}=window.__gradio__svelte__internal;function $h(s,e,t){const i=s.slice();return i[20]=e[t].id,i[21]=e[t].name,i[22]=e[t].user_created,i[23]=e[t].visible,i[25]=t,i}function Oh(s){let e,t,i=(s[0]?"Layers":s[4].layers.find(s[10])?.name)+"",n,r,o,a,l,h,c,u,d;a=new mf({});let _=s[0]&&Gh(s);return{c(){e=ai("div"),t=ai("button"),n=kd(i),r=Fi(),o=ai("span"),Bi(a.$$.fragment),l=Fi(),_&&_.c(),yt(o,"class","icon svelte-1peog37"),yt(t,"class","layer-title-button svelte-1peog37"),yt(t,"aria-label","Show Layers"),yt(e,"class","layer-wrap svelte-1peog37"),jn(e,"closed",!s[0])},m(f,g){ws(f,e,g),ot(e,t),ot(t,n),ot(t,r),ot(t,o),$i(a,o,null),ot(e,l),_&&_.m(e,null),c=!0,u||(d=[yd(t,"click",vd(s[11])),iw(h=la.call(null,e,s[19]))],u=!0)},p(f,g){(!c||g&17)&&i!==(i=(f[0]?"Layers":f[4].layers.find(f[10])?.name)+"")&&xd(n,i),f[0]?_?(_.p(f,g),g&1&&Q(_,1)):(_=Gh(f),_.c(),Q(_,1),_.m(e,null)):_&&(Vt(),re(_,1,1,()=>{_=null}),qt()),h&&rw(h.update)&&g&1&&h.update.call(null,f[19]),(!c||g&1)&&jn(e,"closed",!f[0])},i(f){c||(Q(a.$$.fragment,f),Q(_),c=!0)},o(f){re(a.$$.fragment,f),re(_),c=!1},d(f){f&&ys(e),Li(a),_&&_.d(),u=!1,aw(d)}}}function Gh(s){let e,t=[],i=new Map,n,r,o=Lh(s[4].layers);const a=h=>h[25];for(let h=0;h<o.length;h+=1){let c=$h(s,o,h),u=a(c);i.set(u,t[h]=Hh(u,c))}let l=s[2]&&qh(s);return{c(){e=ai("ul");for(let h=0;h<t.length;h+=1)t[h].c();n=Fi(),l&&l.c(),yt(e,"class","svelte-1peog37")},m(h,c){ws(h,e,c);for(let u=0;u<t.length;u+=1)t[u]&&t[u].m(e,null);ot(e,n),l&&l.m(e,null),r=!0},p(h,c){c&944&&(o=Lh(h[4].layers),Vt(),t=cw(t,c,a,1,h,o,i,e,ow,Hh,n,$h),qt()),h[2]?l?(l.p(h,c),c&4&&Q(l,1)):(l=qh(h),l.c(),Q(l,1),l.m(e,null)):l&&(Vt(),re(l,1,1,()=>{l=null}),qt())},i(h){if(!r){for(let c=0;c<o.length;c+=1)Q(t[c]);Q(l),r=!0}},o(h){for(let c=0;c<t.length;c+=1)re(t[c]);re(l),r=!1},d(h){h&&ys(e);for(let c=0;c<t.length;c+=1)t[c].d();l&&l.d()}}}function dw(s){let e,t;function i(...n){return s[13](s[20],...n)}return e=new at({props:{Icon:Nf,size:"small"}}),e.$on("click",i),{c(){Bi(e.$$.fragment)},m(n,r){$i(e,n,r),t=!0},p(n,r){s=n},i(n){t||(Q(e.$$.fragment,n),t=!0)},o(n){re(e.$$.fragment,n),t=!1},d(n){Li(e,n)}}}function _w(s){let e,t;function i(...n){return s[12](s[20],...n)}return e=new at({props:{Icon:Yf,size:"small"}}),e.$on("click",i),{c(){Bi(e.$$.fragment)},m(n,r){$i(e,n,r),t=!0},p(n,r){s=n},i(n){t||(Q(e.$$.fragment,n),t=!0)},o(n){re(e.$$.fragment,n),t=!1},d(n){Li(e,n)}}}function Nh(s){let e,t,i,n,r=s[25]>0&&Dh(s),o=s[25]<s[4].layers.length-1&&Uh(s),a=s[4].layers.length>1&&s[22]&&Wh(s);return{c(){e=ai("div"),r&&r.c(),t=Fi(),o&&o.c(),i=Fi(),a&&a.c(),yt(e,"class","svelte-1peog37")},m(l,h){ws(l,e,h),r&&r.m(e,null),ot(e,t),o&&o.m(e,null),ot(e,i),a&&a.m(e,null),n=!0},p(l,h){l[25]>0?r?(r.p(l,h),h&16&&Q(r,1)):(r=Dh(l),r.c(),Q(r,1),r.m(e,t)):r&&(Vt(),re
570(r,1,1,()=>{r=null}),qt()),l[25]<l[4].layers.length-1?o?(o.p(l,h),h&16&&Q(o,1)):(o=Uh(l),o.c(),Q(o,1),o.m(e,i)):o&&(Vt(),re(o,1,1,()=>{o=null}),qt()),l[4].layers.length>1&&l[22]?a?(a.p(l,h),h&16&&Q(a,1)):(a=Wh(l),a.c(),Q(a,1),a.m(e,null)):a&&(Vt(),re(a,1,1,()=>{a=null}),qt())},i(l){n||(Q(r),Q(o),Q(a),n=!0)},o(l){re(r),re(o),re(a),n=!1},d(l){l&&ys(e),r&&r.d(),o&&o.d(),a&&a.d()}}}function Dh(s){let e,t;function i(...n){return s[15](s[20],...n)}return e=new at({props:{Icon:b_,size:"x-small"}}),e.$on("click",i),{c(){Bi(e.$$.fragment)},m(n,r){$i(e,n,r),t=!0},p(n,r){s=n},i(n){t||(Q(e.$$.fragment,n),t=!0)},o(n){re(e.$$.fragment,n),t=!1},d(n){Li(e,n)}}}function Uh(s){let e,t;function i(...n){return s[16](s[20],...n)}return e=new at({props:{Icon:S_,size:"x-small"}}),e.$on("click",i),{c(){Bi(e.$$.fragment)},m(n,r){$i(e,n,r),t=!0},p(n,r){s=n},i(n){t||(Q(e.$$.fragment,n),t=!0)},o(n){re(e.$$.fragment,n),t=!1},d(n){Li(e,n)}}}function Wh(s){let e,t;function i(...n){return s[17](s[20],...n)}return e=new at({props:{Icon:a_,size:"x-small"}}),e.$on("click",i),{c(){Bi(e.$$.fragment)},m(n,r){$i(e,n,r),t=!0},p(n,r){s=n},i(n){t||(Q(e.$$.fragment,n),t=!0)},o(n){re(e.$$.fragment,n),t=!1},d(n){Li(e,n)}}}function Hh(s,e){let t,i,n,r,o,a=e[21]+"",l,h,c,u,d,_;const f=[_w,dw],g=[];function p(y,w){return y[23]?1:0}i=p(e),n=g[i]=f[i](e);function m(){return e[14](e[20])}let b=e[4].layers.length>1&&Nh(e);return{key:s,first:null,c(){t=ai("li"),n.c(),r=Fi(),o=ai("button"),l=kd(a),c=Fi(),b&&b.c(),yt(o,"aria-label",h=`layer-${e[25]+1}`),yt(o,"class","svelte-1peog37"),jn(o,"selected_layer",e[4].active_layer===e[20]),yt(t,"class","svelte-1peog37"),this.first=t},m(y,w){ws(y,t,w),g[i].m(t,null),ot(t,r),ot(t,o),ot(o,l),ot(t,c),b&&b.m(t,null),u=!0,d||(_=yd(o,"click",vd(m)),d=!0)},p(y,w){e=y;let A=i;i=p(e),i===A?g[i].p(e,w):(Vt(),re(g[A],1,1,()=>{g[A]=null}),qt(),n=g[i],n?n.p(e,w):(n=g[i]=f[i](e),n.c()),Q(n,1),n.m(t,r)),(!u||w&16)&&a!==(a=e[21]+"")&&xd(l,a),(!u||w&16&&h!==(h=`layer-${e[25]+1}`))&&yt(o,"aria-label",h),(!u||w&16)&&jn(o,"selected_layer",e[4].active_layer===e[20]),e[4].layers.length>1?b?(b.p(e,w),w&16&&Q(b,1)):(b=Nh(e),b.c(),Q(b,1),b.m(t,null)):b&&(Vt(),re(b,1,1,()=>{b=null}),qt())},i(y){u||(Q(n),Q(b),u=!0)},o(y){re(n),re(b),u=!1},d(y){y&&ys(t),g[i].d(),b&&b.d(),d=!1,_()}}}function qh(s){let e,t,i;return t=new at({props:{Icon:Ic,label:"Add Layer",size:"x-small"}}),t.$on("click",s[18]),{c(){e=ai("li"),Bi(t.$$.fragment),yt(e,"class","add-layer svelte-1peog37")},m(n,r){ws(n,e,r),$i(t,e,null),i=!0},p:wd,i(n){i||(Q(t.$$.fragment,n),i=!0)},o(n){re(t.$$.fragment,n),i=!1},d(n){n&&ys(e),Li(t)}}}function fw(s){let e,t,i=s[3]&&Oh(s);return{c(){i&&i.c(),e=sw()},m(n,r){i&&i.m(n,r),ws(n,e,r),t=!0},p(n,[r]){n[3]?i?(i.p(n,r),r&8&&Q(i,1)):(i=Oh(n),i.c(),Q(i,1),i.m(e.parentNode,e)):i&&(Vt(),re(i,1,1,()=>{i=null}),qt())},i(n){t||(Q(i),t=!0)},o(n){re(i),t=!1},d(n){n&&ys(e),i&&i.d(n)}}}function gw(s,e,t){let i,n=wd,r=()=>(n(),n=hw(a,S=>t(4,i=S)),a);s.$$.on_destroy.push(()=>n());const o=uw();let{layers:a}=e;r();let{enable_additional_layers:l=!0}=e,{enable_layers:h=!0}=e,{show_layers:c=!1}=e;function u(){o("new_layer")}function d(S){o("change_layer",S),t(0,c=!1)}function _(S,T){o("move_layer",{id:S,direction:T})}function f(S){o("delete_layer",S)}const g=S=>S.id===i.active_layer,p=()=>t(0,c=!c),m=(S,T)=>{T.stopPropagation(),o("toggle_layer_visibility",S)},b=(S,T)=>{T.stopPropagation(),o("toggle_layer_visibility",S)},y=S=>d(S),w=(S,T)=>{T.stopPropagation(),_(S,"up")},A=(S,T)=>{T.stopPropagation(),_(S,"down")},k=(S,T)=>{T.stopPropagation(),f(S)},x=S=>{S.stopPropagation(),u()},C=()=>t(0,c=!1);return s.$$set=S=>{"layers"in S&&r(t(1,a=S.layers)),"enable_additional_layers"in S&&t(2,l=S.enable_additional_layers),"enable_layers"in S&&t(3,h=S.enable_layers),"show_layers"in S&&t(0,c=S.show_layers)},[c,a,l,h,i,o,u,d,_,f,g,p,m,b,y,w,A,k,x,C]}class pw extends tw{constructor(e){super(),nw(this,e,gw,fw,lw,{layers:1,enable_additional_layers:2,enable_layers:3,show_layers:0})}get layers(){return this.$$.ctx[1]}set layers(e){this.$$set({layers:e}),Sn()}get enable_additional_layers(){return this.$$.ctx[2]}set enable_additional_layers(e){this.$$set({enable_additional_layers:e}),Sn()}get enable_layers(){return this.$$.ctx[3]}set enable_layers(e){this.$$set({enable_layers:e}),Sn()}get show_layers(){return this.$$.ctx[0]}set show_layers(e){this.$$set({show_layers:e}),Sn()}}const{SvelteComponent:mw,append:bw,attr:Vh,bubble:zs,check_outros:yw,create_component:ww,destroy_component:xw,detach:vw,element:Xh,flush:Cn,group_outros:kw,init:Aw,insert:Sw,mount_component:Cw,safe_not_equal:Mw,transition_in:On,transition_out:sa}=window.__gradio__svelte__internal;function Yh(s){let e,t;return e=new pw({props:{layers:s[0],enable_additional_layers:s[1],enable_layers:s[2],show_layers:s[3]}}),e.$on("new_layer",s[4]),e.$on("change_layer",s[5]),e.$on("move_layer",s[6]),e.$on("delete_layer",s[7]),e.$on("toggle_layer_visibility",s[8]),{c(){ww(e.$$.fragment)},m(i,n){Cw(e,i,n),t=!0},p(i,n){const r={};n&1&&(r.layers=i[0]),n&2&&(r.enable_additional_layers=i[1]),n&4&&(r.enable_layers=i[2]),n&8&&(r.show_layers=i[3]),e.$set(r)},i(i){t||(On(e.$$.fragment,i),t=!0)},o(i){sa(e.$$.fragment,i),t=!1},d(i){xw(e,i)}}}function Tw(s){let e,t,i,n=s[2]&&Yh(s);return{c(){e=Xh("div"),t=Xh("div"),n&&n.c(),Vh(t,"class","toolbar-wrap svelte-nkklfl"),Vh(e,"class","toolbar-wrap-wrap svelte-nkklfl")},m(r,o){Sw(r,e,o),bw(e,t),n&&n.m(t,null),i=!0}
570,p(r,[o]){r[2]?n?(n.p(r,o),o&4&&On(n,1)):(n=Yh(r),n.c(),On(n,1),n.m(t,null)):n&&(kw(),sa(n,1,1,()=>{n=null}),yw())},i(r){i||(On(n),i=!0)},o(r){sa(n),i=!1},d(r){r&&vw(e),n&&n.d()}}}function Pw(s,e,t){let{layers:i}=e,{enable_additional_layers:n=!0}=e,{enable_layers:r=!0}=e,{show_layers:o=!1}=e;function a(d){zs.call(this,s,d)}function l(d){zs.call(this,s,d)}function h(d){zs.call(this,s,d)}function c(d){zs.call(this,s,d)}function u(d){zs.call(this,s,d)}return s.$$set=d=>{"layers"in d&&t(0,i=d.layers),"enable_additional_layers"in d&&t(1,n=d.enable_additional_layers),"enable_layers"in d&&t(2,r=d.enable_layers),"show_layers"in d&&t(3,o=d.show_layers)},[i,n,r,o,a,l,h,c,u]}class zw extends mw{constructor(e){super(),Aw(this,e,Pw,Tw,Mw,{layers:0,enable_additional_layers:1,enable_layers:2,show_layers:3})}get layers(){return this.$$.ctx[0]}set layers(e){this.$$set({layers:e}),Cn()}get enable_additional_layers(){return this.$$.ctx[1]}set enable_additional_layers(e){this.$$set({enable_additional_layers:e}),Cn()}get enable_layers(){return this.$$.ctx[2]}set enable_layers(e){this.$$set({enable_layers:e}),Cn()}get show_layers(){return this.$$.ctx[3]}set show_layers(e){this.$$set({show_layers:e}),Cn()}}const{SvelteComponent:Iw,append:Ft,attr:bt,check_outros:jh,create_component:Si,destroy_component:Ci,destroy_each:Ew,detach:_t,element:Ut,ensure_array_like:Kh,flush:Ki,group_outros:Zh,init:Rw,insert:ft,listen:Kn,mount_component:Mi,noop:Fw,run_all:Bw,safe_not_equal:Lw,set_data:$w,space:Rt,stop_propagation:Ad,text:Qh,transition_in:Xe,transition_out:gt}=window.__gradio__svelte__internal,{createEventDispatcher:Ow}=window.__gradio__svelte__internal;function Jh(s,e,t){const i=s.slice();return i[20]=e[t],i}function ec(s){let e,t;return e=new at({props:{Icon:l_,label:"Download"}}),e.$on("click",s[12]),{c(){Si(e.$$.fragment)},m(i,n){Mi(e,i,n),t=!0},p:Fw,i(i){t||(Xe(e.$$.fragment,i),t=!0)},o(i){gt(e.$$.fragment,i),t=!1},d(i){Ci(e,i)}}}function tc(s){let e,t,i,n,r,o,a,l=Kh([.25,.5,1,2,4]),h=[];for(let c=0;c<5;c+=1)h[c]=ic(Jh(s,l,c));return{c(){e=Ut("div"),t=Ut("ul"),i=Ut("li"),n=Ut("button"),n.textContent="Fit to screen",r=Rt();for(let c=0;c<5;c+=1)h[c].c();bt(n,"class","svelte-eqjom0"),bt(i,"class","svelte-eqjom0"),bt(t,"class","svelte-eqjom0"),bt(e,"class","zoom-controls svelte-eqjom0")},m(c,u){ft(c,e,u),Ft(e,t),Ft(t,i),Ft(i,n),Ft(t,r);for(let d=0;d<5;d+=1)h[d]&&h[d].m(t,null);o||(a=Kn(n,"click",Ad(s[16])),o=!0)},p(c,u){if(u&512){l=Kh([.25,.5,1,2,4]);let d;for(d=0;d<5;d+=1){const _=Jh(c,l,d);h[d]?h[d].p(_,u):(h[d]=ic(_),h[d].c(),h[d].m(t,null))}for(;
570d<5;d+=1)h[d].d(1)}},d(c){c&&_t(e),Ew(h,c),o=!1,a()}}}function ic(s){let e,t,i,n,r;function o(){return s[17](s[20])}return{c(){e=Ut("li"),t=Ut("button"),t.textContent=`${s[20]*100}%`,i=Rt(),bt(t,"class","svelte-eqjom0"),bt(e,"class","svelte-eqjom0")},m(a,l){ft(a,e,l),Ft(e,t),Ft(e,i),n||(r=Kn(t,"click",Ad(o)),n=!0)},p(a,l){s=a},d(a){a&&_t(e),n=!1,r()}}}function sc(s){let e,t;return e=new at({props:{disabled:!s[0],Icon:zc,label:"Save changes",color:"var(--color-accent)"}}),e.$on("click",s[18]),{c(){Si(e.$$.fragment)},m(i,n){Mi(e,i,n),t=!0},p(i,n){const r={};n&1&&(r.disabled=!i[0]),e.$set(r)},i(i){t||(Xe(e.$$.fragment,i),t=!0)},o(i){gt(e.$$.fragment,i),t=!1},d(i){Ci(e,i)}}}function Gw(s){let e,t,i,n,r,o,a,l,h,c,u,d,_,f,g,p,m,b,y,w,A=s[4]&&ec(s);t=new at({props:{Icon:Sf,label:"Pan",highlight:s[2]==="pan",size:"small",padded:!1,transparent:!0,disabled:s[3]}}),t.$on("click",s[13]),n=new at({props:{Icon:bg,label:"Zoom out"}}),n.$on("click",s[14]),o=new at({props:{Icon:cg,label:"Zoom in"}}),o.$on("click",s[15]);let k=s[5]&&tc(s),x=s[1]&&sc(s);return m=new at({props:{Icon:h_,label:"Clear canvas"}}),m.$on("click",s[19]),{c(){A&&A.c(),e=Rt(),Si(t.$$.fragment),i=Rt(),Si(n.$$.fragment),r=Rt(),Si(o.$$.fragment),a=Rt(),l=Ut("div"),h=Ut("span"),c=Qh(s[6]),u=Qh("%"),d=Rt(),k&&k.c(),_=Rt(),f=Ut("div"),g=Rt(),x&&x.c(),p=Rt(),Si(m.$$.fragment),bt(h,"role","button"),bt(h,"tabindex","0"),bt(h,"class","svelte-eqjom0"),bt(l,"class","zoom-number svelte-eqjom0"),bt(f,"class","separator svelte-eqjom0")},m(C,S){A&&A.m(C,S),ft(C,e,S),Mi(t,C,S),ft(C,i,S),Mi(n,C,S),ft(C,r,S),Mi(o,C,S),ft(C,a,S),ft(C,l,S),Ft(l,h),Ft(h,c),Ft(h,u),Ft(l,d),k&&k.m(l,null),ft(C,_,S),ft(C,f,S),ft(C,g,S),x&&x.m(C,S),ft(C,p,S),Mi(m,C,S),b=!0,y||(w=[Kn(h,"click",s[8]),Kn(h,"keydown",s[10])],y=!0)},p(C,S){C[4]?A?(A.p(C,S),S&16&&Xe(A,1)):(A=ec(C),A.c(),Xe(A,1),A.m(e.parentNode,e)):A&&(Zh(),gt(A,1,1,()=>{A=null}),jh());const T={};S&4&&(T.highlight=C[2]==="pan"),S&8&&(T.disabled=C[3]),t.$set(T),(!b||S&64)&&$w(c,C[6]),C[5]?k?k.p(C,S):(k=tc(C),k.c(),k.m(l,null)):k&&(k.d(1),k=null),C[1]?x?(x.p(C,S),S&2&&Xe(x,1)):(x=sc(C),x.c(),Xe(x,1),x.m(p.parentNode,p)):x&&(Zh(),gt(x,1,1,()=>{x=null}),jh())},i(C){b||(Xe(A),Xe(t.$$.fragment,C),Xe(n.$$.fragment,C),Xe(o.$$.fragment,C),Xe(x),Xe(m.$$.fragment,C),b=!0)},o(C){gt(A),gt(t.$$.fragment,C),gt(n.$$.fragment,C),gt(o.$$.fragment,C),gt(x),gt(m.$$.fragment,C),b=!1},d(C){C&&(_t(e),_t(i),_t(r),_t(a),_t(l),_t(_),_t(f),_t(g),_t(p)),A&&A.d(C),Ci(t,C),Ci(n,C),Ci(o,C),k&&k.d(),x&&x.d(C),Ci(m,C),y=!1,Bw(w)}}}function Nw(s){let e,t;return e=new c_({props:{$$slots:{default:[Gw]},$$scope:{ctx:s}}}),{c(){Si(e.$$.fragment)},m(i,n){Mi(e,i,n),t=!0},p(i,[n]){const r={};n&8388735&&(r.$$scope={dirty:n,ctx:i}),e.$set(r)},i(i){t||(Xe(e.$$.fragment,i),t=!0)},o(i){gt(e.$$.fragment,i),t=!1},d(i){Ci(e,i)}}}function Dw(s,e,t){let i,{can_save:n=!1}=e,{changeable:r=!1}=e,{current_zoom:o=1}=e,{tool:a}=e,{min_zoom:l=!0}=e,{enable_download:h=!1}=e;const c=Ow();let u=!1;function d(x){x.stopPropagation(),t(5,u=!u)}function _(x){c("set_zoom",x),t(5,u=!1)}function f(x){x.key==="Enter"&&_(o)}const g=x=>{c("download"),x.stopPropagation()},p=x=>{x.stopPropagation(),c("pan")},m=x=>{c("zoom_out"),x.stopPropagation()},b=x=>{c("zoom_in"),x.stopPropagation()},y=()=>_("fit"),w=x=>_(x),A=x=>{c("save"),x.stopPropagation()},k=x=>{c("remove_image"),x.stopPropagation()};return s.$$set=x=>{"can_save"in x&&t(0,n=x.can_save),"changeable"in x&&t(1,r=x.changeable),"current_zoom"in x&&t(11,o=x.current_zoom),"tool"in x&&t(2,a=x.tool),"min_zoom"in x&&t(3,l=x.min_zoom),"enable_download"in x&&t(4,h=x.enable_download)},s.$$.update=()=>{s.$$.dirty&2048&&t(6,i=Math.round(o*100))},[n,r,a,l,h,u,i,c,d,_,f,o,g,p,m,b,y,w,A,k]}class Uw extends Iw{constructor(e){super(),Rw(this,e,Dw,Nw,Lw,{can_save:0,changeable:1,current_zoom:11,tool:2,min_zoom:3,enable_download:4})}get can_save(){return this.$$.ctx[0]}set can_save(e){this.$$set({can_save:e}),Ki()}get changeable(){return this.$$.ctx[1]}set changeable(e){this.$$set({changeable:e}),Ki()}get current_zoom(){return this.$$.ctx[11]}set current_zoom(e){this.$$set({current_zoom:e}),Ki()}get tool(){return this.$$.ctx[2]}set tool(e){this.$$set({tool:e}),Ki()}get min_zoom(){return this.$$.ctx[3]}set min_zoom(e){this.$$set({min_zoom:e}),Ki()}get enable_download(){return this.$$.ctx[4]}set enable_download(e){this.$$set({enable_download:e}),Ki()}}const{SvelteComponent:Ww,action_destroyer:Hw,add_flush_callback:Is,append:xi,attr:Dt,bind:Es,binding_callbacks:vi,bubble:nc,check_outros:ts,create_component:tn,create_slot:qw,destroy_component:sn,detach:Ti,element:os,empty:Vw,flush:ce,get_all_dirty_from_scope:Xw,get_slot_changes:Yw,group_outros:is,init:jw,insert:Pi,is_function:Kw,mount_component:nn,noop:Zw,safe_not_equal:Qw,space:zi,toggle_class:Zi,transition_in:ne,transition_out:Te,update_slot_base:Jw}=window.__gradio__svelte__internal,{onMount:ex,createEventDispatcher:tx,tick:rc}=window.__gradio__svelte__internal;function oc(s){let e,t,i,n,r,o=s[21]!=="crop"&&ac(s),a=s[21]!=="crop"&&lc(s),l=s[1]==="image"&&s[21]==="webcam"&&hc(s),h=s[21]!=="crop"&&!s[12].disabled&&cc(s);return{c(){o&&o.c(),e=zi(),a&&a.c(),t=zi(),l&&l.c(),i=zi(),h&&h.c(),n=Vw()},m(c,u){o&&o.m(c,u),Pi(c,e,u),a&&a.m(c,u),Pi(c,t,u),l&&l.m(c,u),Pi(c,i,u),h&&h.m(c,u),Pi(c,n,u),r=!0},p(c,u){c[21]!=="crop"?o?(o.p(c,u),u[0]&2097152&&ne(o,1)):(o=ac(c),o.c(),ne(o,1),o.m(e.parentNode,e)):o&&(is(),Te(o,1,1,()=>{o=null}),ts()),c[21]!=="crop"?a?(a.p(c,u),u[0]&2097152&&ne(a,1)):(a=lc(c),a.c(),ne(a,1),a.m(t.parentNode,t)):a&&(is(),Te(a,1,1,()=>{a=null}),ts()),c[1]==="image"&&c[21]==="webcam"?l?(l.p(c,u),u[0]&2097154&&ne(l,1)):(l=hc(c),l.c(),ne(l,1),l.m(i.parentNode,i)):l&&(is(),Te(l,1,1,()=>{l=null}),ts()),c[21]!=="crop"&&!c[12].disabled?h?(h.p(c,u),u[0]&2101248&&ne(h,1)):(h=cc(c),h.c(),ne(h,1),h.m(n.parentNode,n)):h&&(is(),Te(h,1,1,()=>{h=null}),ts())},i(c){r||(ne(o),ne(a),ne(l),ne(h),r=!0)},o(c){Te(o),Te(a),Te(l),Te(h),r=!1},d(c){c&&(Ti(e),Ti(t),Ti(i),Ti(n)),o&&o.d(c),a&&a.d(c),l&&l.d(c),h&&h.d(c)}}}function ac(s){let e,t;return e=new Uw({props:{changeable:s[4],min_zoom:s[26],current_zoom:s[25],tool:s[1],can_save:!0,enable_download:s[14]}}),e.$on("set_zoom",s[59]),e.$on("zoom_in",s[60]),e.$on("zoom_out",s[61]),e.$on("remove_image",s[62]),e.$on("save",s[39]),e.$on("pan",s[63]),e.$on("download",s[64]),{c(){tn(e.$$.fragment)},m(i,n){nn(e,i,n),t=!0},p(i,n){const r={};n[0]&16&&(r.changeable=i[4]),n[0]&67108864&&(r.min_zoom=i[26]),n[0]&33554432&&(r.current_zoom=i[25]),n[0]&2&&(r.tool=i[1]),n[0]&16384&&(r.enable_download=i[14]),e.$set(r)},i(i){t||(ne(e.$$.fragment,i),t=!0)},o(i){Te(e.$$.fragment,i),t=!1},d(i){sn(e,i)}}}function lc(s){let e,t,i,n,r,o,a;function l(f){s[65](f)}function h(f){s[66](f)}function c(f){s[67](f)}function u(f){s[68](f)}function d(f){s[69](f)}let _={sources:s[5],transforms:s[6],background:s[0],show_brush_size:s[28],show_brush_color:s[29],show_eraser_size:s[27],brush_options:s[7],eraser_options:s[8],tool:s[1],subtool:s[21]};return s[17]!==void 0&&(_.selected_color=s[17]),s[18]!==void 0&&(_.selected_size=s[18]),s[20]!==void 0&&(_.selected_eraser_size=s[20]),s[19]!==void 0&&(_.selected_opacity=s[19]),s[22]!==void 0&&(_.preview=s[22]),e=new Py({props:_}),vi.push(()=>Es(e,"selected_color",l)),vi.push(()=>Es(e,"selected_size",h)),vi.push(()=>Es(e,"selected_eraser_size",c)),vi.push(()=>Es(e,"selected_opacity",u)),vi.push(()=>Es(e,"preview",d)),e.$on("tool_change",s[70]),e.$on("subtool_change",s[71]),{c(){tn(e.$$.fragment)},m(f,g){nn(e,f,g),a=!0},p(f,g){const p={};g[0]&32&&(p.sources=f[5]),g[0]&64&&(p.transforms=f[6]),g[0]&1&&(p.background=f[0]),g[0]&268435456&&(p.show_brush_size=f[28]),g[0]&536870912&&(p.show_brush_color=f[29]),g[0]&134217728&&(p.show_eraser_size=f[27]),g[0]&128&&(p.brush_options=f[7]),g[0]&256&&(p.eraser_options=f[8]),g[0]&2&&(p.tool=f[1]),g[0]&2097152&&(p.subtool=f[21]),!t&&g[0]&131072&&(t=!0,p.selected_color=f[17],Is(()=>t=!1)),!i&&g[0]&262144&&(i=!0,p.selected_size=f[18],Is(()=>i=!1)),!n&&g[0]&1048576&&(n=!0,p.selected_eraser_size=f[20],Is(()=>n=!1)),!r&&g[0]&524288&&(r=!0,p.selected_opacity=f[19],Is(()=>r=!1)),!o&&g[0]&4194304&&(o=!0,p.preview=f[22],Is(()=>o=!1)),e.$set(p)},i(f){a||(ne(e.$$.fragment,f),a=!0)},o(f){Te(e.$$.fragment,f),a=!1},d(f){sn(e,f)}}}function hc(s){let e,t,i,n;return i=new t_({props:{upload:s[11],root:s[9],streaming:!1,mode:"image",include_audio:!1,i18n:s[10],mirror_webcam:s[13].mirror,webcam_constraints:s[13].constraints}}),i.$on("capture",s[38]),i.$on("error",s[72]),i.$on("drag",s[73]),{c(){e=os("div"),t=os("div"),tn(i.$$.fragment),Dt(t,"class","modal-inner svelte-h6gdep"),Dt(e,"class","modal svelte-h6gdep")},m(r,o){Pi(r,e,o),xi(e,t),nn(i,t,null),n=!0},p(r,o){const a={};o[0]&2048&&(a.upload=r[11]),o[0]&512&&(a.root=r[9]),o[0]&1024&&(a.i18n=r[10]),o[0]&8192&&(a.mirror_webcam=r[13].mirror),o[0]&8192&&(a.webcam_constraints=r[13].constraints),i.$set(a)},i(r){n||(ne(i.$$.fragment,r),n=!0)},o(r){Te(i.$$.fragment,r),n=!1},d(r){r&&Ti(e),sn(i)}}}function cc(s){let e,t;return e=new zw({props:{enable_additional_layers:s[12].allow_additional_layers,layers:s[15].layers}}),e.$on("new_layer",s[74]),e.$on("change_layer",s[75]),e.$on("move_layer",s[76]),e.$on("delete_layer",s[77]),e.$on("toggle_layer_visibility",s[78]),{c(){tn(e.$$.fragment)},m(i,n){nn(e,i,n),t=!0},p(i,n){const r={};n[0]&4096&&(r.enable_additional_layers=i[12].allow_additional_layers),n[0]&32768&&(r.layers=i[15].layers),e.$set(r)},i(i){t||(ne(e.$$.fragment,i),t=!0)},o(i){Te(e.$$.fragment,i),t=!1},d(i){sn(e,i)}}}function uc(s){let e,t,i;return t=new Ze({props:{Icon:zc,label:"Confirm crop",show_label:!0,size:"large",padded:!0,color:"white",background:"var(--color-green-500)",label_position:"right"}}
570),t.$on("click",s[40]),{c(){e=os("div"),tn(t.$$.fragment),Dt(e,"class","crop-confirm-button svelte-h6gdep")},m(n,r){Pi(n,e,r),nn(t,e,null),i=!0},p:Zw,i(n){i||(ne(t.$$.fragment,n),i=!0)},o(n){Te(t.$$.fragment,n),i=!1},d(n){n&&Ti(e),sn(t)}}}function ix(s){let e,t,i,n,r,o,a,l,h,c,u,d=s[16]&&oc(s),_=s[21]==="crop"&&uc(s);const f=s[58].default,g=qw(f,s,s[57],null);return{c(){e=os("div"),d&&d.c(),t=zi(),i=os("div"),n=zi(),r=os("div"),o=zi(),_&&_.c(),a=zi(),g&&g.c(),Dt(i,"class","pixi-target svelte-h6gdep"),Zi(i,"visible",s[21]!=="crop"),Dt(r,"class","pixi-target-crop svelte-h6gdep"),Zi(r,"visible",s[21]==="crop"),Dt(e,"data-testid","image"),Dt(e,"class","image-container svelte-h6gdep"),Dt(e,"aria-label","Click to upload or drop files"),Dt(e,"aria-dropeffect","copy"),Zi(e,"dark-bg",s[21]==="crop")},m(p,m){Pi(p,e,m),d&&d.m(e,null),xi(e,t),xi(e,i),s[79](i),xi(e,n),xi(e,r),s[80](r),xi(e,o),_&&_.m(e,null),xi(e,a),g&&g.m(e,null),h=!0,c||(u=Hw(l=s[31].call(null,e,{on_drag_change:s[81],on_files:s[33],accepted_types:"image/*",disable_click:s[30]})),c=!0)},p(p,m){p[16]?d?(d.p(p,m),m[0]&65536&&ne(d,1)):(d=oc(p),d.c(),ne(d,1),d.m(e,t)):d&&(is(),Te(d,1,1,()=>{d=null}),ts()),(!h||m[0]&2097152)&&Zi(i,"visible",p[21]!=="crop"),(!h||m[0]&2097152)&&Zi(r,"visible",p[21]==="crop"),p[21]==="crop"?_?(_.p(p,m),m[0]&2097152&&ne(_,1)):(_=uc(p),_.c(),ne(_,1),_.m(e,a)):_&&(is(),Te(_,1,1,()=>{_=null}),ts()),g&&g.p&&(!h||m[1]&67108864)&&Jw(g,f,p,p[57],h?Yw(f,p[57],m,null):Xw(p[57]),null),l&&Kw(l.update)&&m[0]&1073741828&&l.update.call(null,{on_drag_change:p[81],on_files:p[33],accepted_types:"image/*",disable_click:p[30]}),(!h||m[0]&2097152)&&Zi(e,"dark-bg",p[21]==="crop")},i(p){h||(ne(d),ne(_),ne(g,p),h=!0)},o(p){Te(d),Te(_),Te(g,p),h=!1},d(p){p&&Ti(e),d&&d.d(),s[79](null),s[80](null),_&&_.d(),g&&g.d(p),c=!1,u()}}}function sx(s,e,t){let i,{$$slots:n={},$$scope:r}=e;const{drag:o,open_file_upload:a}=n_(),l=tx(),h=!0,c=null;let{changeable:u=!1}=e,{sources:d=["upload","webcam","clipboard"]}=e,{transforms:_=["crop","resize"]}=e,{canvas_size:f}=e,{is_dragging:g=!1}=e,{background_image:p=!1}=e,{brush_options:m}=e,{eraser_options:b}=e,{fixed_canvas:y=!1}=e,{root:w}=e,{i18n:A}=e,{upload:k}=e,{composite:x}=e,{layers:C}=e,{background:S}=e,{border_region:T=0}=e,{layer_options:E}=e,{current_tool:D}=e,{webcam_options:X}=e,{show_download_button:F=!1}=e,{theme_mode:q}=e,R,B;function ze(){G.set_tool(D),G.set_subtool(di)}function W(){return E&&G&&Pe}let{has_drawn:ee=!1}=e;async function I(){return G?!p&&!ee&&!C.length?{background:null,layers:[],composite:null}:await G.get_blobs():{background:null,layers:[],composite:null}}let G;function ye(v){G.add_image({image:v})}let we;async function xe(v){if(!G||!v||!W())return;let N;if(typeof v=="string")N=v;else if(v?.meta?._type==="gradio.FileData"&&v?.url)N=v.url;else{console.warn("Invalid source provided to add_image_from_url:",v);return}try{we=G.add_image_from_url(N);let qe=z.add_image_from_url(N);await Promise.all([we,qe]),z.set_tool("image"),z.set_subtool("crop"),t(0,p=!0),l("upload"),l("input")}catch(qe){console.error("Error adding image from URL:",qe)}}async function ge(v){if(!(!G||!v.length||!W())&&Array.isArray(v)&&v.every(N=>N?.meta?._type==="gradio.FileData"))try{await we,await G.add_layers_from_url(v.map(N=>N.url)),l("change"),l("input")}catch(N){console.error("Error adding layer from URL:",N)}}let ve,ke,Ae=1,Pe=!1,tt=!0,P={width:0,height:0};async function le(){if(!G||!Pe||!ke)return;if(await rc(),R.offsetParent!==null){const N=R.getBoundingClientRect();(N.width!==P.width||N.height!==P.height)&&(ke.set_zoom("fit"),P={width:N.width,height:N.height})}}ex(()=>{let v,N;return it().then(()=>{v=new IntersectionObserver(()=>{le()}),N=new ResizeObserver(()=>{le()}),v.observe(R),N.observe(R)}),()=>{v&&v.disconnect(),N&&N.disconnect(),G&&G.destroy()}});let z,he;async function it(){t(55,ve=new ew),ke=new ta,t(15,G=new ia({target_element:R,width:f[0],height:f[1],tools:["image",ke,new jy,ve],fixed_canvas:y,border_region:T,layer_options:E,theme_mode:q})),ve.on("change",()=>{t(3,ee=!0)}),t(56,he=new ta),z=new ia({target_element:B,width:f[0],height:f[1],tools:["image",he,new Yy],dark:!0,fixed_canvas:!1,border_region:0,pad_bottom:40}),G.scale.subscribe(v=>{t(25,Ae=v)}),G.min_zoom.subscribe(v=>{t(26,tt=v)}),G.dimensions.subscribe(v=>{P={...v}}),await Promise.all([G.ready,z.ready]).then(()=>{ie({tool:"image"}),t(16,Pe=!0),d.length>0?ie({tool:"image"}):ie({tool:"draw"}),z.set_subtool("crop")}),G.on("change",()=>{l("change")}),S||C.length>0?(S&&await xe(S),C.length>0&&await ge(C),ie({tool:"draw"})):x&&(await xe(x),ie({tool:"draw"}))}async function Re(v){if(v==null||!d.includes("upload"))return;const N=Array.isArray(v)?v[0]:v;await G.add_image({image:N}),await z.add_image({image:N}),z.reset(),t(0,p=!0),ie({tool:"draw"}),l("upload"),l("input"),l("change")}function ie({tool:v}){G.set_tool(v),t(1,D=v),v==="image"&&(z.set_tool("image"),z.set_subtool("crop"))}function Ie({tool:v,subtool:N}){G.set_subtool(N),t(21,di=N),N!==null&&(v==="draw"&&(N==="size"?t(28,rn=!0):N==="color"&&t(29,on=!0)),v==="erase"&&N==="size"&&t(27,Xt=!0),v==="image"&&N==="paste"&&hr(),v==="image"&&N==="upload"&&rc().then(()=>{t(30,i=!1),a()}))}let Xt=!1,Se,Ct,$t=1,Yt;function ar(){const v=m.default_color==="auto"?m.colors[0]:m.default_color;if(Array.isArray(v))t(17,Se=v[0]),t(19,$t=v[1]);else{t(17,Se=v);const N=je(v);N.getAlpha()<1?t(19,$t=N.getAlpha()):t(19,$t=1)}t(18,Ct=typeof m.default_size=="number"?m.default_size:25)}function lr(){t(20,Yt=b.default_size==="auto"?25:b.default_size)}let rn=!1,on=!1,di=null,Oi=!1;function an(v){ke.set_zoom(v)}function vs(v){ke.set_zoom(v==="in"?Ae+(Ae<1?.1:Ae*.1):Ae-(Ae<1?.1:Ae*.1))}async function hr(){const v=await navigator.clipboard.read();for(let N=0;N<v.length;N++){const qe=v[N].types.find(_i=>_i.startsWith("image/"));if(qe){const _i=await v[N].getType(qe);Re(_i)}}}function cr(v){v.detail!==null&&Re(v.detail),Ie({tool:D,subtool:null})}function ur(){l("save")}async function M(){const{image:v}=await z.get_crop_bounds();v&&(await G.add_image({image:v,resize:!1}),Ie({tool:"image",subtool:null}),l("change"),l("input"))}async function ln(){const N=(await G.get_blobs()).composite;if(!N){l("download_error","Unable to generate image to download.");return}const qe=URL.createObjectURL(N),_i=document.createElement("a");_i.href=qe,_i.download="image.png",_i.click(),URL.revokeObjectURL(qe)}const Id=v=>an(v.detail),Ed=()=>vs("in"),Rd=()=>vs("out"),Fd=()=>
570{l("clear"),G.reset_canvas(),ie({tool:"image"}),t(0,p=!1),t(3,ee=!1)},Bd=v=>{ie({tool:"pan"})},Ld=()=>ln();function $d(v){Se=v,t(17,Se)}function Od(v){Ct=v,t(18,Ct)}function Gd(v){Yt=v,t(20,Yt)}function Nd(v){$t=v,t(19,$t)}function Dd(v){Oi=v,t(22,Oi)}const Ud=v=>ie(v.detail),Wd=v=>Ie(v.detail);function Hd(v){nc.call(this,s,v)}function qd(v){nc.call(this,s,v)}const Vd=()=>{G.add_layer()},Xd=v=>{G.set_layer(v.detail),D==="draw"&&ie({tool:"draw"})},Yd=v=>{G.move_layer(v.detail.id,v.detail.direction)},jd=v=>{G.delete_layer(v.detail)},Kd=v=>{G.toggle_layer_visibility(v.detail)};function Zd(v){vi[v?"unshift":"push"](()=>{R=v,t(23,R)})}function Qd(v){vi[v?"unshift":"push"](()=>{B=v,t(24,B)})}const Jd=v=>t(2,g=v);return s.$$set=v=>{"changeable"in v&&t(4,u=v.changeable),"sources"in v&&t(5,d=v.sources),"transforms"in v&&t(6,_=v.transforms),"canvas_size"in v&&t(44,f=v.canvas_size),"is_dragging"in v&&t(2,g=v.is_dragging),"background_image"in v&&t(0,p=v.background_image),"brush_options"in v&&t(7,m=v.brush_options),"eraser_options"in v&&t(8,b=v.eraser_options),"fixed_canvas"in v&&t(45,y=v.fixed_canvas),"root"in v&&t(9,w=v.root),"i18n"in v&&t(10,A=v.i18n),"upload"in v&&t(11,k=v.upload),"composite"in v&&t(46,x=v.composite),"layers"in v&&t(47,C=v.layers),"background"in v&&t(48,S=v.background),"border_region"in v&&t(49,T=v.border_region),"layer_options"in v&&t(12,E=v.layer_options),"current_tool"in v&&t(1,D=v.current_tool),"webcam_options"in v&&t(13,X=v.webcam_options),"show_download_button"in v&&t(14,F=v.show_download_button),"theme_mode"in v&&t(50,q=v.theme_mode),"has_drawn"in v&&t(3,ee=v.has_drawn),"$$scope"in v&&t(57,r=v.$$scope)},s.$$.update=()=>{s.$$.dirty[0]&36864&&E&&W()&&(G.set_layer_options(E),ze()),s.$$.dirty[0]&98304|s.$$.dirty[1]&229376&&S==null&&C.length==0&&x==null&&G&&Pe&&(G.reset_canvas(),ie({tool:"image"}),t(0,p=!1),t(3,ee=!1)),s.$$.dirty[0]&2097154|s.$$.dirty[1]&33554432&&D==="image"&&di==="crop"&&he.set_zoom("fit"),s.$$.dirty[0]&384&&(m&&ar(),b&&lr()),s.$$.dirty[0]&131200|s.$$.dirty[1]&16777216&&ve?.set_brush_color((()=>{let v;if(Se==="auto"){const N=m.colors.find(qe=>Array.isArray(qe)?qe[0]===m.default_color:qe===m.default_color)||m.colors[0];
570v=Array.isArray(N)?N[0]:N}else v=Se;return v})()),s.$$.dirty[0]&262144|s.$$.dirty[1]&16777216&&ve?.set_brush_size(typeof Ct=="number"?Ct:25),s.$$.dirty[0]&1048576|s.$$.dirty[1]&16777216&&ve?.set_eraser_size(typeof Yt=="number"?Yt:25),s.$$.dirty[0]&2097187&&t(30,i=D!=="image"||D==="image"&&p||D==="image"&&di==="webcam"||!d.includes("upload")),s.$$.dirty[0]&4194304|s.$$.dirty[1]&16777216&&ve?.preview_brush(Oi),s.$$.dirty[0]&524288|s.$$.dirty[1]&16777216&&ve?.set_brush_opacity($t),s.$$.dirty[1]&163840&&xe(x||S),s.$$.dirty[1]&65536&&ge(C)},[p,D,g,ee,u,d,_,m,b,w,A,k,E,X,F,G,Pe,Se,Ct,$t,Yt,di,Oi,R,B,Ae,tt,Xt,rn,on,i,o,l,Re,ie,Ie,an,vs,cr,ur,M,ln,h,c,f,y,x,C,S,T,q,I,ye,xe,ge,ve,he,r,n,Id,Ed,Rd,Fd,Bd,Ld,$d,Od,Gd,Nd,Dd,Ud,Wd,Hd,qd,Vd,Xd,Yd,jd,Kd,Zd,Qd,Jd]}class nx extends Ww{constructor(e){super(),jw(this,e,sx,ix,Qw,{antialias:42,full_history:43,changeable:4,sources:5,transforms:6,canvas_size:44,is_dragging:2,background_image:0,brush_options:7,eraser_options:8,fixed_canvas:45,root:9,i18n:10,upload:11,composite:46,layers:47,background:48,border_region:49,layer_options:12,current_tool:1,webcam_options:13,show_download_button:14,theme_mode:50,has_drawn:3,get_blobs:51,add_image:52,add_image_from_url:53,add_layers_from_url:54},null,[-1,-1,-1,-1])}get antialias(){return this.$$.ctx[42]}get full_history(){return this.$$.ctx[43]}get changeable(){return this.$$.ctx[4]}set changeable(e){this.$$set({changeable:e}),ce()}get sources(){return this.$$.ctx[5]}set sources(e){this.$$set({sources:e}),ce()}get transforms(){return this.$$.ctx[6]}set transforms(e){this.$$set({transforms:e}),ce()}get canvas_size(){return this.$$.ctx[44]}set canvas_size(e){this.$$set({canvas_size:e}),ce()}get is_dragging(){return this.$$.ctx[2]}set is_dragging(e){this.$$set({is_dragging:e}),ce()}get background_image(){return this.$$.ctx[0]}set background_image(e){this.$$set({background_image:e}),ce()}get brush_options(){return this.$$.ctx[7]}set brush_options(e){this.$$set({brush_options:e}),ce()}get eraser_options(){return this.$$.ctx[8]}set eraser_options(e){this.$$set({eraser_options:e}),ce()}get fixed_canvas(){return this.$$.ctx[45]}set fixed_canvas(e){this.$$set({fixed_canvas:e}),ce()}get root(){return this.$$.ctx[9]}set root(e){this.$$set({root:e}),ce()}get i18n(){return this.$$.ctx[10]}set i18n(e){this.$$set({i18n:e}),ce()}get upload(){return this.$$.ctx[11]}set upload(e){this.$$set({upload:e}),ce()}get composite(){return this.$$.ctx[46]}set composite(e){this.$$set({composite:e}),ce()}get layers(){return this.$$.ctx[47]}set layers(e){this.$$set({layers:e}),ce()}get background(){return this.$$.ctx[48]}set background(e){this.$$set({background:e}),ce()}get border_region(){return this.$$.ctx[49]}set border_region(e){this.$$set({border_region:e}),ce()}get layer_options(){return this.$$.ctx[12]}set layer_options(e){this.$$set({layer_options:e}),ce()}get current_tool(){return this.$$.ctx[1]}set current_tool(e){this.$$set({current_tool:e}),ce()}get webcam_options(){return this.$$.ctx[13]}set webcam_options(e){this.$$set({webcam_options:e}),ce()}get show_download_button(){return this.$$.ctx[14]}set show_download_button(e){this.$$set({show_download_button:e}),ce()}get theme_mode(){return this.$$.ctx[50]}set theme_mode(e){this.$$set({theme_mode:e}),ce()}get has_drawn(){return this.$$.ctx[3]}set has_drawn(e){this.$$set({has_drawn:e}),ce()}get get_blobs(){return this.$$.ctx[51]}get add_image(){return this.$$.ctx[52]}get add_image_from_url(){return this.$$.ctx[53]}get add_layers_from_url(){return this.$$.ctx[54]}}const rx=/^(#\s*)(.+)$/m;function ox(s){const e=s.trim(),t=e.match(rx);if(!t)return[!1,e||!1];const[i,,n]=t,r=n.trim();if(e===i)return[r,!1];const o=t.index!==void 0?t.index+i.length:0,l=e.substring(o).trim()||!1;return[r,l]}const{SvelteComponent:ax,add_flush_callback:Mn,append:Zn,attr:or,bind:Tn,binding_callbacks:Ls,bubble:Ao,create_component:dc,destroy_component:_c,detach:xt,element:xs,empty:Ca,flush:te,init:lx,insert:vt,mount_component:fc,noop:hx,safe_not_equal:cx,set_data:Sd,space:Qn,text:Cd,transition_in:gc,transition_out:pc}=window.__gradio__svelte__internal,{createEventDispatcher:ux}=window.__gradio__svelte__internal;function mc(s){let e,t,i,n=s[3]&&s[3].length&&bc(s),r=s[3]&&s[3].length&&s[1]&&
570!s[18]&&xc(),o=s[1]&&!s[18]&&vc();return{c(){e=xs("div"),n&&n.c(),t=Qn(),r&&r.c(),i=Qn(),o&&o.c(),or(e,"class","empty wrap svelte-a0rsm5")},m(a,l){vt(a,e,l),n&&n.m(e,null),Zn(e,t),r&&r.m(e,null),Zn(e,i),o&&o.m(e,null)},p(a,l){a[3]&&a[3].length?n?n.p(a,l):(n=bc(a),n.c(),n.m(e,t)):n&&(n.d(1),n=null),a[3]&&a[3].length&&a[1]&&!a[18]?r||(r=xc(),r.c(),r.m(e,i)):r&&(r.d(1),r=null),a[1]&&!a[18]?o||(o=vc(),o.c(),o.m(e,null)):o&&(o.d(1),o=null)},d(a){a&&xt(e),n&&n.d(),r&&r.d(),o&&o.d()}}}function bc(s){let e;function t(r,o){return r[28]||r[27]?_x:dx}let i=t(s),n=i(s);return{c(){n.c(),e=Ca()},m(r,o){n.m(r,o),vt(r,e,o)},p(r,o){i===(i=t(r))&&n?n.p(r,o):(n.d(1),n=i(r),n&&(n.c(),n.m(e.parentNode,e)))},d(r){r&&xt(e),n.d(r)}}}function dx(s){let e;return{c(){e=xs("div"),e.textContent="Upload an image"},m(t,i){vt(t,e,i)},p:hx,d(t){t&&xt(e)}}}function _x(s){let e,t,i=s[28]&&yc(s),n=s[27]&&wc(s);return{c(){i&&i.c(),e=Qn(),n&&n.c(),t=Ca()},m(r,o){i&&i.m(r,o),vt(r,e,o),n&&n.m(r,o),vt(r,t,o)},p(r,o){r[28]?i?i.p(r,o):(i=yc(r),i.c(),i.m(e.parentNode,e)):i&&(i.d(1),i=null),r[27]?n?n.p(r,o):(n=wc(r),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(r){r&&(xt(e),xt(t)),i&&i.d(r),n&&n.d(r)}}}function yc(s){let e,t;return{c(){e=xs("h2"),t=Cd(s[28]),or(e,"class","svelte-a0rsm5")},m(i,n){vt(i,e,n),Zn(e,t)},p(i,n){n[0]&268435456&&Sd(t,i[28])},d(i){i&&xt(e)}}}function wc(s){let e,t;return{c(){e=xs("p"),t=Cd(s[27]),or(e,"class","svelte-a0rsm5")},m(i,n){vt(i,e,n),Zn(e,t)},p(i,n){n[0]&134217728&&Sd(t,i[27])},d(i){i&&xt(e)}}}function xc(s){let e;return{c(){e=xs("div"),e.textContent="or",or(e,"class","or svelte-a0rsm5")},m(t,i){vt(t,e,i)},d(t){t&&xt(e)}}}function vc(s){let e;return{c(){e=xs("div"),e.textContent="select the draw tool to start"},m(t,i){vt(t,e,i)},d(t){t&&xt(e)}}}function fx(s){let e,t=!s[23]&&s[26]==="image"&&!s[25]&&mc(s);return{c(){t&&t.c(),e=Ca()},m(i,n){t&&t.m(i,n),vt(i,e,n)},p(i,n){!i[23]&&i[26]==="image"&&!i[25]?t?t.p(i,n):(t=mc(i),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},d(i){i&&xt(e),t&&t.d(i)}}}function gx(s){let e,t,i,n,r,o,a,l;e=new u_({props:{show_label:s[7],Icon:Pc,label:s[6]||s[4]("image.image")}});function h(f){s[36](f)}function c(f){s[37](f)}function u(f){s[38](f)}function d(f){s[39](f)}let _={transforms:s[14],composite:s[11],layers:s[10],background:s[12],canvas_size:s[15],changeable:s[8],sources:s[3],full_history:s[20],brush_options:s[1],eraser_options:s[2],fixed_canvas:s[16],border_region:s[19],layer_options:s[13],i18n:s[4],root:s[5],upload:s[17],webcam_options:s[21],show_download_button:s[22],theme_mode:s[9],$$slots:{default:[fx]},$$scope:{ctx:s}};return s[23]!==void 0&&(_.background_image=s[23]),s[26]!==void 0&&(_.current_tool=s[26]),s[0]!==void 0&&(_.is_dragging=s[0]),s[25]!==void 0&&(_.has_drawn=s[25]),i=new nx({props:_}),s[35](i),Ls.push(()=>Tn(i,"background_image",h)),Ls.push(()=>Tn(i,"current_tool",c)),Ls.push(()=>Tn(i,"is_dragging",u)),Ls.push(()=>Tn(i,"has_drawn",d)),i.$on("history",s[40]),i.$on("save",s[41]),i.$on("change",s[30]),i.$on("clear",s[42]),i.$on("download_error",s[43]),{c(){dc(e.$$.fragment),t=Qn(),dc(i.$$.fragment)},m(f,g){fc(e,f,g),vt(f,t,g),fc(i,f,g),l=!0},p(f,g){const p={};g[0]&128&&(p.show_label=f[7]),g[0]&80&&(p.label=f[6]||f[4]("image.image")),e.$set(p);const m={};g[0]&16384&&(m.transforms=f[14]),g[0]&2048&&(m.composite=f[11]),g[0]&1024&&(m.layers=f[10]),g[0]&4096&&(m.background=f[12]),g[0]&32768&&(m.canvas_size=f[15]),g[0]&256&&(m.changeable=f[8]),g[0]&8&&(m.sources=f[3]),g[0]&1048576&&(m.full_history=f[20]),g[0]&2&&(m.brush_options=f[1]),g[0]&4&&(m.eraser_options=f[2]),g[0]&65536&&(m.fixed_canvas=f[16]),g[0]&524288&&(m.border_region=f[19]),g[0]&8192&&(m.layer_options=f[13]),g[0]&16&&(m.i18n=f[4]),g[0]&32&&(m.root=f[5]),g[0]&131072&&(m.upload=f[17]),g[0]&2097152&&(m.webcam_options=f[21]),g[0]&4194304&&(m.show_download_button=f[22]),g[0]&512&&(m.theme_mode=f[9]),g[0]&511967242|g[1]&65536&&(m.$$scope={dirty:g,ctx:f}),!n&&g[0]&8388608&&(n=!0,m.background_image=f[23],Mn(()=>n=!1)),!r&&g[0]&67108864&&(r=!0,m.current_tool=f[26],Mn(()=>r=!1)),!o&&g[0]&1&&(o=!0,m.is_dragging=f[0],Mn(()=>o=!1)),!a&&g[0]&33554432&&(a=!0,m.has_drawn=f[25],Mn(()=>a=!1)),i.$set(m)},i(f){l||(gc(e.$$.fragment,f),gc(i.$$.fragment,f),l=!0)},o(f){pc(e.$$.fragment,f),pc(i.$$.fragment,f),l=!1},d(f){f&&xt(t),_c(e,f),s[35](null),_c(i,f)}}}function px(s){return!!s}function mx(s){return!!s}function kc(){return new Promise(s=>setTimeout(()=>s(),30))}function bx(s,e,t){let i,n,{brush:r}=e,{eraser:o}=e,{sources:a}=e,{i18n:l}=e,{root:h}=e,{label:c=void 0}=e,{show_label:u}=e,{changeable:d=!1}=e,{theme_mode:_}=e,{layers:f}=e,{composite:g}=e,{background:p}=e,{layer_options:m}=e,{transforms:b}=e,{accept_blobs:y}=e,{canvas_size:w}=e,{fixed_canvas:A=!1}=e,{realtime:k}=e,{upload:x}=e,{is_dragging:C}=e,{placeholder:S=void 0}=e,{border_region:T}=e,{full_history:E=null}=e,{webcam_options:D}=e,{show_download_button:X=!1}=e;const F=ux();let q,R=!1;async function B(){let z;try{z=await q.get_blobs()}catch{return{background:null,layers:[],composite:null}}const he=z.background?x(await dr([new File([z.background],"background.png")]),h):Promise.resolve(null),it=z.layers.filter(px).map(async(Se,Ct)=>x(await dr([new File([Se],`layer_${Ct}.png`)]),h)),Re=z.composite?x(await dr([new File([z.composite],"composite.png")]),h):Promise.resolve(null),[ie,Ie,...Xt]=await Promise.all([he,Re,...it]);return{background:Array.isArray(ie)?ie[0]:ie,layers:Xt.flatMap(Se=>Array.isArray(Se)?Se:[Se]).filter(mx),composite:Array.isArray(Ie)?Ie[0]:Ie}}function ze(z){q&&z==null&&(q.handle_remove(),F("receive_null"))}let W=!1,{image_id:ee=null}=e,I=!1,G=!1;async function ye(z){if(!k)return;if(I){G=!0;return}I=!0,await kc();const he=await q.get_blobs(),it=[];let Re=Math.random().toString(36).substring(2);he.background&&it.push([Re,"background",new File([he.background],"background.png"),null]),he.composite&&it.push([Re,"composite",new File([he.composite],"composite.png"),null]),he.layers.forEac
570h((ie,Ie)=>{ie&&it.push([Re,"layer",new File([ie],`layer_${Ie}.png`),Ie])}),await Promise.all(it.map(async([ie,Ie,Xt,Se])=>y({binary:!0,data:{file:Xt,id:ie,type:Ie,index:Se}}))),t(31,ee=Re),F("change"),await kc(),I=!1,G&&(G=!1,I=!1,ye())}let we;function xe(z){Ls[z?"unshift":"push"](()=>{q=z,t(24,q)})}function ge(z){W=z,t(23,W)}function ve(z){we=z,t(26,we)}function ke(z){C=z,t(0,C)}function Ae(z){R=z,t(25,R)}function Pe(z){Ao.call(this,s,z)}function tt(z){Ao.call(this,s,z)}const P=()=>F("clear");function le(z){Ao.call(this,s,z)}return s.$$set=z=>{"brush"in z&&t(1,r=z.brush),"eraser"in z&&t(2,o=z.eraser),"sources"in z&&t(3,a=z.sources),"i18n"in z&&t(4,l=z.i18n),"root"in z&&t(5,h=z.root),"label"in z&&t(6,c=z.label),"show_label"in z&&t(7,u=z.show_label),"changeable"in z&&t(8,d=z.changeable),"theme_mode"in z&&t(9,_=z.theme_mode),"layers"in z&&t(10,f=z.layers),"composite"in z&&t(11,g=z.composite),"background"in z&&t(12,p=z.background),"layer_options"in z&&t(13,m=z.layer_options),"transforms"in z&&t(14,b=z.transforms),"accept_blobs"in z&&t(32,y=z.accept_blobs),"canvas_size"in z&&t(15,w=z.canvas_size),"fixed_canvas"in z&&t(16,A=z.fixed_canvas),"realtime"in z&&t(33,k=z.realtime),"upload"in z&&t(17,x=z.upload),"is_dragging"in z&&t(0,C=z.is_dragging),"placeholder"in z&&t(18,S=z.placeholder),"border_region"in z&&t(19,T=z.border_region),"full_history"in z&&t(20,E=z.full_history),"webcam_options"in z&&t(21,D=z.webcam_options),"show_download_button"in z&&t(22,X=z.show_download_button),"image_id"in z&&t(31,ee=z.image_id)},s.$$.update=()=>{s.$$.dirty[0]&8388608&&W&&F("upload"),s.$$.dirty[0]&7168&&ze({layers:f,composite:g,background:p}),s.$$.dirty[0]&262144&&t(28,[i,n]=S?ox(S):[!1,!1],i,(t(27,n),t(18,S)))},[C,r,o,a,l,h,c,u,d,_,f,g,p,m,b,w,A,x,S,T,E,D,X,W,q,R,we,n,i,F,ye,ee,y,k,B,xe,ge,ve,ke,Ae,Pe,tt,P,le]}class yx extends ax{constructor(e){super(),lx(this,e,bx,gx,cx,{brush:1,eraser:2,sources:3,i18n:4,root:5,label:6,show_label:7,changeable:8,theme_mode:9,layers:10,composite:11,background:12,layer_options:13,transforms:14,accept_blobs:32,canvas_size:15,fixed_canvas:16,realtime:33,upload:17,is_dragging:0,placeholder:18,border_region:19,full_history:20,webcam_options:21,show_download_button:22,get_data:34,image_id:31},null,[-1,-1])}get brush(){return this.$$.ctx[1]}set brush(e){this.$$set({brush:e}),te()}get eraser(){return this.$$.ctx[2]}set eraser(e){this.$$set({eraser:e}),te()}get sources(){return this.$$.ctx[3]}set sources(e){this.$$set({sources:e}),te()}get i18n(){return this.$$.ctx[4]}set i18n(e){this.$$set({i18n:e}),te()}get root(){return this.$$.ctx[5]}set root(e){this.$$set({root:e}),te()}get label(){return this.$$.ctx[6]}set label(e){this.$$set({label:e}),te()}get show_label(){return this.$$.ctx[7]}set show_label(e){this.$$set({show_label:e}),te()}get changeable(){return this.$$.ctx[8]}set changeable(e){this.$$set({changeable:e}),te()}get theme_mode(){return this.$$.ctx[9]}set theme_mode(e){this.$$set({theme_mode:e}),te()}get layers(){return this.$$.ctx[10]}set layers(e){this.$$set({layers:e}),te()}get composite(){return this.$$.ctx[11]}set composite(e){this.$$set({composite:e}),te()}get background(){return this.$$.ctx[12]}set background(e){this.$$set({background:e}),te()}get layer_options(){return this.$$.ctx[13]}set layer_options(e){this.$$set({layer_options:e}),te()}get transforms(){return this.$$.ctx[14]}set transforms(e){this.$$set({transforms:e}),te()}get accept_blobs(){return this.$$.ctx[32]}set accept_blobs(e){this.$$set({accept_blobs:e}),te()}get canvas_size(){return this.$$.ctx[15]}set canvas_size(e){this.$$set({canvas_size:e}),te()}get fixed_canvas(){return this.$$.ctx[16]}set fixed_canvas(e){this.$$set({fixed_canvas:e}),te()}get realtime(){return this.$$.ctx[33]}set realtime(e){this.$$set({realtime:e}),te()}get upload(){return this.$$.ctx[17]}set upload(e){this.$$set({upload:e}),te()}get is_dragging(){return this.$$.ctx[0]}set is_dragging(e){this.$$set({is_dragging:e}),te()}get placeholder(){return this.$$.ctx[18]}set placeholder(e){this.$$set({placeholder:e}),te()}get border_region(){return this.$$.ctx[19]}set border_region(e){this.$$set({border_region:e}),te()}get full_history(){return this.$$.ctx[20]}set full_history(e){this.$$set({full_history:e}),te()}get webcam_options(){return this.$$.ctx[21]}set webcam_options(e){this.$$set({webcam_options:e}),te()}get show_download_button(){return this.$$.ctx[22]}set show_download_button(e){this.$$set({show_download_button:e}),te()}get get_data(){return this.$$.ctx[34]}get image_id(){return this.$$.ctx[31]}set image_id(e){this.$$set({image_id:e}),te()}}const{SvelteComponent:wx,add_flush_callback:Ac,assign:Md,bind:Sc,binding_callbacks:na,bubble:xx,check_outros:vx,create_component:ds,destroy_component:_s,detach:Ma,empty:kx,flush:j,get_spread_object:Td,get_spread_update:Pd,group_outros:Ax,init:Sx,insert:Ta,mount_component:fs,not_equal:Cx,space:zd,transition_in:hi,transition_out:ci}=window.__gradio__svelte__internal,{tick:Mx}=window.__gradio__svelte__internal;function Tx(s){let e,t;return e=new Mc({props:{visible:s[5],variant:s[39]?"solid":"dashed",border_mode:s[35]?"focus":"base",padding:!1,elem_id:s[3],elem_classes:s[4],height:s[10],width:s[11],allow_overflow:!0,overflow_behavior:"visible",container:s[13],scale:s[14],min_width:s[15],$$slots:{default:[zx]},$$scope:{ctx:s}}}),{c(){ds(e.$$.fragment)},m(i,n){fs(e,i,n),t=!0},p(i,n){const r={};n[0]&32&&(r.visible=i[5]),n[1]&256&&(r.variant=i[39]?"solid":"dashed"),n[1]&16&&(r.border_mode=i[35]?"focus":"base"),n[0]&8&&(r.elem_id=i[3]),n[0]&16&&(r.elem_classes=i[4]),n[0]&1024&&(r.height=i[10]),n[0]&2048&&(r.width=i[11]),n[0]&8192&&(r.container=i[13]),n[0]&16384&&(r.scale=i[14]),n[0]&32768&&(r.min_width=i[15]),n[0]&1878655943|n[1]&255|n[2]&128&&(r.$$scope={dirty:n,ctx:i}),e.$set(r)},i(i){t||(hi(e.$$.fragment,i),t=!0)},o(i){ci(e.$$.fragment,i),t=!1},d(i){_s(e,i)}}}function Px(s){let e,t;return e=new Mc({props:{visible:s[5],variant:"solid",border_mode:s[35]?"focus":"base",padding:!1,elem_id:s[3],elem_classes:s[4],height:s[10],width:s[11],allow_overflow:!0,overflow_behavior:"visible",container:s[13],scale:s[14],min_width:s[15],$$slots:{default:[Ix]},$$scope:{ctx:s}}}),{c(){ds(e.$$.fragment)},m(i,n){fs(e,i,n),t=!0},p(i,n){const r={};n[0]&32&&(r.visible=i[5]),n[1]&16&&(r.border_mode=i[35]?"focus":"base"),n[0]&8&&(r.elem_id=i[3]),n[0]&16&&(r.elem_classes=i[4]),n[0]&1024&&(r.height=i[10]),n[0]&2048&&(r.width=i[11]),n[0]&8192&&(r.container=i[13]),n[0]&16384&&(r.scale=i[14]),n[0]&32768&&(r.min_width=i[15]),n[0]&805376451|
570n[2]&128&&(r.$$scope={dirty:n,ctx:i}),e.$set(r)},i(i){t||(hi(e.$$.fragment,i),t=!0)},o(i){ci(e.$$.fragment,i),t=!1},d(i){_s(e,i)}}}function zx(s){let e,t,i,n,r,o;const a=[{autoscroll:s[29].autoscroll},{i18n:s[29].i18n},s[1]];let l={};for(let d=0;d<a.length;d+=1)l=Md(l,a[d]);e=new Tc({props:l}),e.$on("clear_status",s[48]);function h(d){s[50](d)}function c(d){s[51](d)}let u={border_region:s[30],canvas_size:s[26],layers:s[36],composite:s[37],background:s[38],root:s[9],sources:s[17],label:s[6],show_label:s[7],fixed_canvas:s[27],brush:s[20],eraser:s[21],changeable:s[24].includes("apply"),realtime:s[24].includes("change")||s[24].includes("input"),i18n:s[29].i18n,transforms:s[22],accept_blobs:s[25].accept_blobs,layer_options:s[23],upload:s[49],placeholder:s[19],full_history:s[2],webcam_options:s[31],show_download_button:s[8],theme_mode:s[32]};return s[35]!==void 0&&(u.is_dragging=s[35]),s[34]!==void 0&&(u.image_id=s[34]),i=new yx({props:u}),na.push(()=>Sc(i,"is_dragging",h)),na.push(()=>Sc(i,"image_id",c)),s[52](i),i.$on("history",s[53]),i.$on("change",s[54]),i.$on("save",s[55]),i.$on("edit",s[56]),i.$on("clear",s[57]),i.$on("drag",s[58]),i.$on("upload",s[59]),i.$on("share",s[60]),i.$on("error",s[61]),i.$on("receive_null",s[62]),i.$on("error",s[63]),i.$on("download_error",s[64]),{c(){ds(e.$$.fragment),t=zd(),ds(i.$$.fragment)},m(d,_){fs(e,d,_),Ta(d,t,_),fs(i,d,_),o=!0},p(d,_){const f=_[0]&536870914?Pd(a,[_[0]&536870912&&{autoscroll:d[29].autoscroll},_[0]&536870912&&{i18n:d[29].i18n},_[0]&2&&Td(d[1])]):{};e.$set(f);const g={};_[0]&1073741824&&(g.border_region=d[30]),_[0]&67108864&&(g.canvas_size=d[26]),_[1]&32&&(g.layers=d[36]),_[1]&64&&(g.composite=d[37]),_[1]&128&&(g.background=d[38]),_[0]&512&&(g.root=d[9]),_[0]&131072&&(g.sources=d[17]),_[0]&64&&(g.label=d[6]),_[0]&128&&(g.show_label=d[7]),_[0]&134217728&&(g.fixed_canvas=d[27]),_[0]&1048576&&(g.brush=d[20]),_[0]&2097152&&(g.eraser=d[21]),_[0]&16777216&&(g.changeable=d[24].includes("apply")),_[0]&16777216&&(g.realtime=d[24].includes("change")||d[24].includes("input")),_[0]&536870912&&(g.i18n=d[29].i18n),_[0]&4194304&&(g.transforms=d[22]),_[0]&33554432&&(g.accept_blobs=d[25].accept_blobs),_[0]&8388608&&(g.layer_options=d[23]),_[0]&536870912&&(g.upload=d[49]),_[0]&524288&&(g.placeholder=d[19]),_[0]&4&&(g.full_history=d[2]),_[1]&1&&(g.webcam_options=d[31]),_[0]&256&&(g.show_download_button=d[8]),_[1]&2&&(g.theme_mode=d[32]),!n&&_[1]&16&&(n=!0,g.is_dragging=d[35],Ac(()=>n=!1)),!r&&_[1]&8&&(r=!0,g.image_id=d[34],Ac(()=>r=!1)),i.$set(g)},i(d){o||(hi(e.$$.fragment,d),hi(i.$$.fragment,d),o=!0)},o(d){ci(e.$$.fragment,d),ci(i.$$.fragment,d),o=!1},d(d){d&&Ma(t),_s(e,d),s[52](null),_s(i,d)}}}function Ix(s){let e,t,i,n;const r=[{autoscroll:s[29].autoscroll},{i18n:s[29].i18n},s[1]];let o={};for(let a=0;a<r.length;a+=1)o=Md(o,r[a]);return e=new Tc({props:o}),e.$on("clear_status",s[44]),i=new e_({props:{value:s[0]?.composite||null,label:s[6],show_label:s[7],show_download_button:s[8],selectable:s[12],show_share_button:s[16],i18n:s[29].i18n,show_fullscreen_button:s[28]}}),i.$on("select",s[45]),i.$on("share",s[46]),i.$on("error",s[47]),{c(){ds(e.$$.fragment),t=zd(),ds(i.$$.fragment)},m(a,l){fs(e,a,l),Ta(a,t,l),fs(i,a,l),n=!0},p(a,l){const h=l[0]&536870914?Pd(r,[l[0]&536870912&&{autoscroll:a[29].autoscroll},l[0]&536870912&&{i18n:a[29].i18n},l[0]&2&&Td(a[1])]):{};e.$set(h);const c={};l[0]&1&&(c.value=a[0]?.composite||null),l[0]&64&&(c.label=a[6]),l[0]&128&&(c.show_label=a[7]),l[0]&256&&(c.show_download_button=a[8]),l[0]&4096&&(c.selectable=a[12]),l[0]&65536&&(c.show_share_button=a[16]),l[0]&536870912&&(c.i18n=a[29].i18n),l[0]&268435456&&(c.show_fullscreen_button=a[28]),i.$set(c)},i(a){n||(hi(e.$$.fragment,a),hi(i.$$.fragment,a),n=!0)},o(a){ci(e.$$.fragment,a),ci(i.$$.fragment,a),n=!1},d(a){a&&Ma(t),_s(e,a),_s(i,a)}}}function Ex(s){let e,t,i,n;const r=[Px,Tx],o=[];function a(l,h){return l[18]?1:0}return e=a(s),t=o[e]=r[e](s),{c(){t.c(),i=kx()},m(l,h){o[e].m(l,h),Ta(l,i,h),n=!0},p(l,h){let c=e;e=a(l),e===c?o[e].p(l,h):(Ax(),ci(o[c],1,1,()=>{o[c]=null}),vx(),t=o[e],t?t.p(l,h):(t=o[e]=r[e](l),t.c()),hi(t,1),t.m(i.parentNode,i))},i(l){n||(hi(t),n=!0)},o(l){ci(t),n=!1},d(l){l&&Ma(i),o[e].d(l)}}}function Rx(s,e,t){let i,n,r,o,{elem_id:a=""}=e,{elem_classes:l=[]}=e,{visible:h=!0}=e,{value:c={background:null,layers:[],composite:null}}=e,{label:u}=e,{show_label:d}=e,{show_download_button:_}=e,{root:f}=e,{value_is_output:g=!1}=e,{height:p=350}=e,{width:m}=e,{_selectable:b=!1}=e,{container:y=!0}=e,{scale:w=null}=e,{min_width:A=void 0}=e,{loading_status:k}=e,{show_share_button:x=!1}=e,{sources:C=[]}=e,{interactive:S}=e,{placeholder:T}=e,{brush:E}=e,{eraser:D}=e,{transforms:X=[]}=e,{layers:F}=e,{attached_events:q=[]}=e,{server:R}=e,{canvas_size:B}=e,{fixed_canvas:ze=!1}=e,{show_fullscreen_button:W=!0}=e,{full_history:ee=null}=e,{gradio:I}=e,{border_region:G=0}=e,{webcam_options:ye}=e,{theme_mode:we}=e,xe,ge=null;async function ve(){if(ge){const ln={id:ge};return t(34,ge=null),ln}return await xe.get_data()}let ke;const Pe=typeof window<"u"?window.requestAnimationFrame:M=>M();function tt(){return new Promise(M=>{Pe(()=>Pe(()=>M()))})}async function P(){await tt(),c&&(c.background||c.layers?.length||c.composite)&&I.dispatch("change")}function le(){I.dispatch("apply")}function z(){I.dispatch("change"),g||(I.dispatch("input"),Mx().then(M=>t(42,g=!1)))}const he=()=>I.dispatch("clear_status",k),it=({detail:M})=>I.dispatch("select",M),Re=({detail:M})=>I.dispatch("share",M),ie=({detail:M})=>I.dispatch("error",M),Ie=()=>I.dispatch("clear_status",k),Xt=(...M)=>I.client.upload(...M);function Se(M){ke=M,t(35,ke)}function Ct(M){ge=M,t(34,ge)}function $t(M){na[M?"unshift":"push"](()=>{xe=M,t(33,xe)})}const Yt=M=>
570t(2,ee=M.detail),ar=()=>z(),lr=M=>le(),rn=()=>I.dispatch("edit"),on=()=>I.dispatch("clear"),di=({detail:M})=>t(35,ke=M),Oi=()=>I.dispatch("upload"),an=({detail:M})=>I.dispatch("share",M),vs=({detail:M})=>{t(1,k=k||{}),t(1,k.status="error",k),I.dispatch("error",M)},hr=()=>t(0,c={background:null,layers:[],composite:null});function cr(M){xx.call(this,s,M)}const ur=M=>I.dispatch("error",M.detail);return s.$$set=M=>{"elem_id"in M&&t(3,a=M.elem_id),"elem_classes"in M&&t(4,l=M.elem_classes),"visible"in M&&t(5,h=M.visible),"value"in M&&t(0,c=M.value),"label"in M&&t(6,u=M.label),"show_label"in M&&t(7,d=M.show_label),"show_download_button"in M&&t(8,_=M.show_download_button),"root"in M&&t(9,f=M.root),"value_is_output"in M&&t(42,g=M.value_is_output),"height"in M&&t(10,p=M.height),"width"in M&&t(11,m=M.width),"_selectable"in M&&t(12,b=M._selectable),"container"in M&&t(13,y=M.container),"scale"in M&&t(14,w=M.scale),"min_width"in M&&t(15,A=M.min_width),"loading_status"in M&&t(1,k=M.loading_status),"show_share_button"in M&&t(16,x=M.show_share_button),"sources"in M&&t(17,C=M.sources),"interactive"in M&&t(18,S=M.interactive),"placeholder"in M&&t(19,T=M.placeholder),"brush"in M&&t(20,E=M.brush),"eraser"in M&&t(21,D=M.eraser),"transforms"in M&&t(22,X=M.transforms),"layers"in M&&t(23,F=M.layers),"attached_events"in M&&t(24,q=M.attached_events),"server"in M&&t(25,R=M.server),"canvas_size"in M&&t(26,B=M.canvas_size),"fixed_canvas"in M&&t(27,ze=M.fixed_canvas),"show_fullscreen_button"in M&&t(28,W=M.show_fullscreen_button),"full_history"in M&&t(2,ee=M.full_history),"gradio"in M&&t(29,I=M.gradio),"border_region"in M&&t(30,G=M.border_region),"webcam_options"in M&&t(31,ye=M.webcam_options),"theme_mode"in M&&t(32,we=M.theme_mode)},s.$$.update=()=>{s.$$.dirty[0]&1&&c&&P(),s.$$.dirty[0]&1&&t(39,i=c?.background||c?.layers?.length||c?.composite),s.$$.dirty[0]&1&&t(38,n=c?.background?new _r(c.background):null),s.$$.dirty[0]&1&&t(37,r=c?.composite?new _r(c.composite):null),s.$$.dirty[0]&1&&t(36,o=c?.layers?.map(M=>new _r(M))||[])},[c,k,ee,a,l,h,u,d,_,f,p,m,b,y,w,A,x,C,S,T,E,D,X,F,q,R,B,ze,W,I,G,ye,we,xe,ge,ke,o,r,n,i,le,z,g,ve,he,it,Re,ie,Ie,Xt,Se,Ct,$t,Yt,ar,lr,rn,on,di,Oi,an,vs,hr,cr,ur]}class Fx extends wx{constructor(e){super(),Sx(this,e,Rx,Ex,Cx,{elem_id:3,elem_classes:4,visible:5,value:0,label:6,show_label:7,show_download_button:8,root:9,value_is_output:42,height:10,width:11,_selectable:12,container:13,scale:14,min_width:15,loading_status:1,show_share_button:16,sources:17,interactive:18,placeholder:19,brush:20,eraser:21,transforms:22,layers:23,attached_events:24,server:25,canvas_size:26,fixed_canvas:27,show_fullscreen_button:28,full_history:2,gradio:29,border_region:30,webcam_options:31,theme_mode:32,get_value:43},null,[-1,-1,-1])}get elem_id(){return this.$$.ctx[3]}set elem_id(e){this.$$set({elem_id:e}),j()}get elem_classes(){return this.$$.ctx[4]}set elem_classes(e){this.$$set({elem_classes:e}),j()}get visible(){return this.$$.ctx[5]}set visible(e){this.$$set({visible:e}),j()}get value(){return this.$$.ctx[0]}set value(e){this.$$set({value:e}),j()}get label(){return this.$$.ctx[6]}set label(e){this.$$set({label:e}),j()}get show_label(){return this.$$.ctx[7]}set show_label(e){this.$$set({show_label:e}),j()}get show_download_button(){return this.$$.ctx[8]}set show_download_button(e){this.$$set({show_download_button:e}),j()}get root(){return this.$$.ctx[9]}set root(e){this.$$set({root:e}),j()}get value_is_output(){return this.$$.ctx[42]}set value_is_output(e){this.$$set({value_is_output:e}),j()}get height(){return this.$$.ctx[10]}set height(e){this.$$set({height:e}),j()}get width(){return this.$$.ctx[11]}set width(e){this.$$set({width:e}),j()}get _selectable(){return this.$$.ctx[12]}set _selectable(e){this.$$set({_selectable:e}),j()}get container(){return this.$$.ctx[13]}set container(e){this.$$set({container:e}),j()}get scale(){return this.$$.ctx[14]}set scale(e){this.$$set({scale:e}),j()}get min_width(){return this.$$.ctx[15]}set min_width(e){this.$$set({min_width:e}),j()}get loading_status(){return this.$$.ctx[1]}set loading_status(e){this.$$set({loading_status:e}),j()}get show_share_button(){return this.$$.ctx[16]}set show_share_button(e){this.$$set({show_share_button:e}),j()}get sources(){return this.$$.ctx[17]}set sources(e){this.$$set({sources:e}),j()}get interactive(){return this.$$.ctx[18]}set interactive(e){this.$$set({interactive:e}),j()}get placeholder(){return this.$$.ctx[19]}set placeholder(e){this.$$set({placeholder:e}),j()}get brush(){return this.$$.ctx[20]}set brush(e){this.$$set({brush:e}),j()}get eraser(){return this.$$.ctx[21]}set eraser(e){this.$$set({eraser:e}),j()}get transforms(){return this.$$.ctx[22]}set transforms(e){this.$$set({transforms:e}),j()}get layers(){return this.$$.ctx[23]}set layers(e){this.$$set({layers:e}),j()}get attached_events(){return this.$$.ctx[24]}set attached_events(e){this.$$set({attached_events:e}),j()}get server(){return this.$$.ctx[25]}set server(e){this.$$set({server:e}),j()}get canvas_size(){return this.$$.ctx[26]}set canvas_size(e){this.$$set({canvas_size:e}),j()}get fixed_canvas(){return this.$$.ctx[27]}set fixed_canvas(e){this.$$set({fixed_canvas:e}),j()}get show_fullscreen_button(){return this.$$.ctx[28]}set show_fullscreen_button(e){this.$$set({show_fullscreen_button:e}),j()}get full_history(){return this.$$.ctx[2]}set full_history(e){this.$$set({full_history:e}),j()}get gradio(){return this.$$.ctx[29]}set gradio(e){this.$$set({gradio:e}),j()}get border_region(){return this.$$.ctx[30]}set border_region(e){this.$$set({border_region:e}),j()}get webcam_options(){return this.$$.ctx[31]}set webcam_options(e){this.$$set({webcam_options:e}),j()}get theme_mode(){return this.$$.ctx[32]}set theme_mode(e){this.$$set({theme_mode:e}),j()}get get_value(){return this.$$.ctx[43]}}const a2=Object.freeze(Object.defineProperty({__proto__:null,default:Fx},Symbol.toStringTag,{value:"Module"}));
570export{fe as $,Cu as A,He as B,U as C,_e as D,$ as E,$o as F,li as G,Hc as H,qs as I,wt as J,nl as K,ue as L,Z as M,Hp as N,tm as O,V as P,pe as Q,Fo as R,Jp as S,fn as T,zo as U,se as V,ym as W,ol as X,ll as Y,kp as Z,Hr as _,kt as a,Xc as a0,Ii as a1,Mu as a2,K as a3,J as a4,Am as a5,qm as a6,c1 as a7,d1 as a8,m1 as a9,y1 as aa,w1 as ab,Qs as ac,hb as ad,Wu as ae,bl as af,pl as ag,Wg as ah,Wl as ai,gb as aj,be as ak,de as al,qg as am,Nl as an,Yo as ao,Dl as ap,Dn as aq,Vu as ar,a2 as as,Gm as b,Ks as c,En as d,Oe as e,ml as f,Lm as g,da as h,ku as i,nu as j,At as k,mu as l,Gl as m,h1 as n,u1 as o,g1 as p,Ru as q,np as r,b1 as s,er as t,Y as u,Hg as v,me as w,ls as x,v1 as y,Wt as z};
571//# sourceMappingURL=Index-BpOBH0lB.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.