1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browserAll-Ds0Uwdkb.js","./webworkerAll-CwGDTwF3.js","./colorToUniform-3MxHuUz8.js","./i18n-BlwlR3g4.js","./index-B5CnGmTK.js","./index-bt_TDFDJ.css","./i18n-BttlJ49B.css","./misc-CU3tEKfW.js","./utils.svelte-Cn7aBojF.js","./clone-CePNcxlk.js","./ImagePreview-DfaXtt2p.js","./ScrollFade.svelte_svelte_type_style_lang-3SfI1hia.js","./snippet-qnvrkjTU.js","./ScrollFade-DV-0xzhB.css","./BlockLabel-DkQ_PBVA.js","./DownloadLink-SGczcHXg.js","./Empty-3XAyBxo6.js","./ShareButton-5LhuFKf9.js","./Download-UBHarVKf.js","./Image-CPn5WpR2.js","./IconButtonWrapper-D8MDVsLy.js","./FullscreenButton-D4JR0m4Y.js","./Maximize-D-TYJFey.js","./Image-4OmLu9if.js","./Image-Da_XA0w6.css","./ImagePreview-CCVfwC4m.css","./Block-CimeBYgM.js","./index-pSSnyPc8.js","./StreamingBar.svelte_svelte_type_style_lang-lroHh1Vk.js","./html-Dw1CmxWF.js","./index-B_pwUImq.js","./StreamingBar-CMuqaV2j.css","./Clear-DNBmcX61.js","./Upload-C2T78fLZ.js","./actions-B4qJajJp.js","./Upload-C2I0h_eD.css","./Webcam-BnEjgocL.js","./DropdownArrow-DsE4n_6d.js","./Square-DbD8EEsD.js","./Spinner-DrXJCBbl.js","./StreamingBar-DdMN5Gtq.js","./ImageUploader-Dpdel1G9.css","./window-_x_xJ--7.js","./tinycolor-BSMjThy7.js","./Plus-Dg_fpcsF.js","./input-2DWUN4z0.js","./Check-CLEdriM2.js","./event-modifiers-CdEA5IGF.js","./ArrowUp-DmS-MKv0.js","./Trash-B1YPdl8H.js","./Undo-CdECZ7AS.js","./Example-CZSJmqDf.css","./WebGPURenderer-CWjfA0-A.js","./SharedSystems-CEwDYeNJ.js","./WebGLRenderer-PxdhROBO.js"])))=>i.map(i=>d[i]); 2import{w as ai,p as z,e as ve,i as Q,a as Ue,b as re,f as Ie,G as Uo,d as Qe,k as Bi,u as Li,t as No,F as Fh,j as Ne,m as Bh,q as Lh,s as Oh,r as Gh,g as yn}from"./i18n-BlwlR3g4.js";import{a as H,f as ne,aj as Dh,R as ce,a1 as yt,x as W,G as Y,a2 as Le,V as it,X as q,Y as tt,t as Wt,w as m,T as ue,a3 as Z,U as I,a0 as Fe,W as nt,af as ps,aa as Wo,Z as jt,aw as xn,S as qt,z as Rt,M as xr,a4 as Oe,ad as Gt,a5 as de,at as Ho,a6 as ci,au as Os,u as Uh,av as Gs}from"./index-B5CnGmTK.js";import{b as fe}from"./misc-CU3tEKfW.js";import{G as Nh}from"./utils.svelte-Cn7aBojF.js";import{I as Wh}from"./ImagePreview-DfaXtt2p.js";import{B as bn}from"./Block-CimeBYgM.js";import{U as Hh,a as Vh,W as Xh,I as ie}from"./ScrollFade.svelte_svelte_type_style_lang-3SfI1hia.js";import{s as Ds,S as vn}from"./index-pSSnyPc8.js";import"./StreamingBar.svelte_svelte_type_style_lang-lroHh1Vk.js";/* empty css */import{c as Yh}from"./Upload-C2T78fLZ.js";/* empty css *//* empty css */import{C as wn,b as si,W as jh}from"./Webcam-BnEjgocL.js";import{a as As}from"./actions-B4qJajJp.js";import{I as Vo}from"./Image-CPn5WpR2.js";import{b as kn}from"./window-_x_xJ--7.js";import{t as he,E as qh}from"./tinycolor-BSMjThy7.js";import{P as Xo}from"./Plus-Dg_fpcsF.js";import{b as $h}from"./input-2DWUN4z0.js";import{C as Yo}from"./Check-CLEdriM2.js";/* empty css */import{s as gs}from"./event-modifiers-CdEA5IGF.js";import{A as Kh}from"./ArrowUp-DmS-MKv0.js";import{C as Zh}from"./Clear-DNBmcX61.js";import{D as Qh}from"./Download-UBHarVKf.js";import{T as Jh}from"./Trash-B1YPdl8H.js";import{U as tl}from"./Undo-CdECZ7AS.js";import{I as el}from"./IconButtonWrapper-D8MDVsLy.js";import{B as il}from"./BlockLabel-DkQ_PBVA.js";var sl=ne('<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><polyline points="19 12 12 19 5 12"></polyline></svg>');function rl(s){var t=sl();H(s,t)}var nl=ne('<svg width="100%" height="100%" viewBox="0 0 32 32"><path 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" fill="currentColor"></path><path 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
20l4.024-4.024L13 9.95l-4.025 4.024A3.475 3.475 0 0 1 6.5 15z" fill="currentColor"></path></svg>');function ol(s){var t=nl();H(s,t)}var al=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24"><path fill="currentColor" 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-.638-.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"></path></svg>');function hl(s){var t=al();H(s,t)}var ll=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24"><path fill="currentColor" 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"></path></svg>');function cl(s){var t=ll();H(s,t)}var ul=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 256 256"><path fill="currentColor" 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"></path></svg>');function dl(s){var t=ul();H(s,t)}var _l=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24"><g fill="none"><path fill="currentColor" 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
2-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"></path><path stroke="currentColor" stroke-linecap="round" stroke-width="1.5" d="M9 21h12"></path></g></svg>');function fl(s){var t=_l();H(s,t)}var pl=ne('<svg width="100%" height="100%" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg"><path 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" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path><path 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" stroke="currentColor" stroke-width="1.5"></path></svg>');function gl(s){var t=pl();H(s,t)}var ml=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24"><path fill="currentColor" 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 11V2q0-.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"></path></svg>');function yl(s){var t=ml();H(s,t)}var xl=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-rotate-ccw" style="transform: rotateY(180deg);"><polyline points="1 4 1 10 7 10"></polyline><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"></path></svg>');function bl(s){var t=xl();H(s,t)}var vl=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24"><path fill="currentColor" 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"></path></svg>');function wl(s){var t=vl();H(s,t)}var kl=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24"><path fill="currentColor" 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"></path></svg>');function Al(s){var t=kl();H(s,t)}var Sl=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 256 256"><path fill="currentColor" 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"></path></svg>');function Cl(s){var t=Sl();H(s,t)}var Ml=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewB
2ox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 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"></path></svg>');function Tl(s){var t=Ml();H(s,t)}var Pl=ne('<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 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"></path></svg>');function zl(s){var t=Pl();H(s,t)}class ms{command;next;previous;constructor(t){this.command=t||null,this.next=null,this.previous=null}push(t){this.next=null;const e=new ms(t);e.previous=this,this.next=e}}class Il{history=new ms;current_history=ai(this.history);undo(){this.history.previous&&(this.history.command?.undo(),this.history=this.history.previous,this.current_history.update(()=>this.history))}redo(t){this.history.next&&(this.history=this.history.next,this.history.command?.execute(t),this.current_history.update(()=>this.history))}async execute(t,e){await t.execute(e),this.history.push(t),this.history=this.history.next,this.current_history.update(()=>this.history)}async wait_for_next_frame(){return new Promise(t=>{requestAnimationFrame(()=>{t()})})}async replay(t,e){for(;t.previous;)t=t.previous;for(;t.next;)await t.next.command.execute(e),t=t.next;this.history=t,this.current_history.update(()=>this.history)}contains(t){let e=this.history;for(;e;){if(e.command?.name===t)return!0;e=e.next}return!1}reset(){this.history=new ms,this.current_history.update(()=>this.history)}}var El=nt('<span style="margin-left: 4px;" class="svelte-1lrnmgy"> </span>'),Rl=nt('<span style="margin-right: 4px;" class="svelte-1lrnmgy"> </span>'),Fl=nt("<button><!> <div><!></div> <!></button>");function ae(s,t){ce(t,!1);const e=Z();let i=z(t,"Icon",12),r=z(t,"label",12,""),n=z(t,"show_label",12,!1),o=z(t,"pending",12,!1),a=z(t,"size",12,"small"),h=z(t,"padded",12,!0),l=z(t,"highlight",12,!1),c=z(t,"disabled",12,!1),u=z(t,"hasPopup",12,!1),_=z(t,"color",12,"var(--block-label-text-color)"),d=z(t,"transparent",12,!1),f=z(t,"background",12,"var(--background-fill-primary)"),g=z(t,"offset",12,0),p=z(t,"label_position",12,"left"),y=z(t,"roundedness",12,"quite"),x=z(t,"onclick",12,void 0);yt(()=>(Y(l()),Y(_())),()=>{W(e,l()?"var(--color-accent)":_().toString())}),Le();var v={get Icon(){return i()},set Icon(B){i(B),I()},get label(){return r()},set label(B){r(B),I()},get show_label(){return n()},set show_label(B){n(B),I()},get pending(){return o()},set pending(B){o(B),I()},get size(){return a()},set size(B){a(B),I()},get padded(){return h()},set padded(B){h(B),I()},get highlight(){return l()},set highlight(B){l(B),I()},get disabled(){return c()},set disabled(B){c(B),I()},get hasPopup(){return u()},set hasPopup(B){u(B),I()},get color(){return _()},set color(B){_(B),I()},get transparent(){return d()},set transparent(B){d(B),I()},get background(){return f()},set background(B){f(B),I()},get offset(){return g()},set offset(B){g(B),I()},get label_position(){return p()},set label_position(B){p(B),I()},get roundedness(){return y()},set roundedness(B){y(B),I()},get onclick(){return x()},set onclick(B){x(B),I()}};ve();var b=Fl();b.__click=function(...B){x()?.apply(this,B)};let C,w;var k=it(b);{var R=B=>{var V=El(),L=it(V,!0);tt(V),Wt(()=>Fe(L,r())),H(B,V)};Q(k,B=>{n()&&p()==="left"&&B(R)})}var S=q(k,2);let P;var F=it(S);i()(F,{}),tt(S);var G=q(S,2);{var N=B=>{var V=Rl(),L=it(V,!0);tt(V),Wt(()=>Fe(L,r())),H(B,V)};Q(G,B=>{n()&&p()==="right"&&B(N)})}return tt(b),Wt(()=>{b.disabled=c(),Ue(b,"aria-label",r()),Ue(b,"aria-haspopup",u()),Ue(b,"title",r()),C=re(b,1,`${y()??""}-round`,"svelte-1lrnmgy",C,{pending:o(),padded:h(),highlight:l(),transparent:d()}),w=Ie(b,"",w,{color:!c()&&m(e)?m(e):"var(--block-label-text-color)","--bg-color":c()?"auto":f(),"margin-left":g()+"px"}),P=re(S,1,"svelte-1lrnmgy",null,P,{small:a()==="small",large:a()==="large",medium:a()==="medium"})}),H(s,b),ue(v)}Dh(["click"]);function Kr(s,t){const e=i=>{s&&!s.contains(i.target)&&!i.defaultPrevented&&t(i)};return document.addEventListener("mousedown",e,!0),{destroy(){document.removeEventListener("mousedown",e,!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 br=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},ji=(s,t)=>br(s).priority??t,$t={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(br).forEach(t=>
vendor: 8,308 bytes, line 2
2{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...s){return s.map(br).forEach(t=>{t.type.forEach(e=>{const i=this._addHandlers,r=this._queue;i[e]?i[e]?.(t):(r[e]=r[e]||[],r[e]?.push(t))})}),this},handle(s,t,e){const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&(n[s]?.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,o)=>ji(o.value,e)-ji(n.value,e)))},i=>{const r=t.findIndex(n=>n.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>ji(n,e)-ji(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})},mixin(s,...t){for(const e of t)Object.defineProperties(s.prototype,Object.getOwnPropertyDescriptors(e))}},Bl={extension:{type:$.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await ps(()=>import("./browserAll-Ds0Uwdkb.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,46,47,48,49,50,51]),import.meta.url)}},Ll={extension:{type:$.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await ps(()=>import("./webworkerAll-CwGDTwF3.js"),__vite__mapDeps([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,46,47,48,49,50,51]),import.meta.url)}};class Kt{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new Kt(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}var Us={exports:{}},An;function Ol(){return An||(An=1,(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,u,_){if(typeof c!="function")throw new TypeError("The listener must be a function");var d=new r(c,u||h,_),f=e?e+l:l;return h._events[f]?h._events[f].fn?h._events[f]=[h._events[f],d]:h._events[f].push(d):(h._events[f]=d,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var _=0,d=u.length,f=new Array(d);_<d;_++)f[_]=u[_].fn;return f},a.prototype.listenerCount=function(l){var c=e?e+l:l,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,c,u,_,d,f){var g=e?e+l:l;if(!this._events[g])return!1;var p=this._events[g],y=arguments.length,x,v;if(p.fn){switch(p.once&&this.removeListener(l,p.fn,void 0,!0),y){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,_),!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(v=1,x=new Array(y-1);v<y;v++)x[v-1]=arguments[v];p.fn.apply(p.context,x)}else{var b=p.length,C;for(v=0;v<b;v++)switch(p[v].once&&this.removeListener(l,p[v].fn,void 0,!0),y){case 1:p[v].fn.call(p[v].context);break;case 2:p[v].fn.call(p[v].context,c);break;case 3:p[v].fn.call(p[v].context,c,u);break;case 4:p[v].fn.call(p[v].context,c,u,_);break;default:if(!x)for(C=1,x=new Array(y-1);C<y;C++)x[C-1]=arguments[C];p[v].fn.apply(p[v].context,x)}}return!0},a.prototype.on=function(l,c,u){return n(this,l,c,u,!1)},a.prototype.once=function(l,c,u){return n(this,l,c,u,!0)},a.prototype.removeListener=function(l,c,u,_){var d=e?e+l:l;if(!this._events[d])return this;if(!c)return o(this,d),this;var f=this._events[d];if(f.fn)f.fn===c&&(!_||f.once)&&(!u||f.context===u)&&o(this,d);else{for(var g=0,p=[],y=f.length;g<y;g++)(f[g].fn!==c||_&&!f[g].once||u&&f[g].context!==u)&&p.push(f[g]);p.length?this._events[d]=p.length===1?p[0]:p:o(this,d)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,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=e,a.EventEmitter=a,s.exports=a})(Us)),Us.exports}var Gl=Ol();const we=Uo(Gl),Dl=Math.PI*2,Ul=180/Math.PI,Nl=Math.PI/180;class dt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new dt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Ns.x=0,Ns.y=0,Ns}}const Ns=new dt;class pt{constructor(t=1,e=0,i=0,r=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,r,n,o){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(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(t,e){e=e||new dt;const i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e}applyInverse(t,e){e=e||new dt;const i=this.a,r=this.b,n=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(i*o+n*-r),c=t.x,u=t.y;return e.x=o*l*c+-n*l*u+(h*n-a*o)*l,e.y=i*l*u+-r*l*c+(-h*i+a*r)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),r=this.a,n=this.c,o=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,r=t.b,n=t.c,o=t.d,a=t.tx,h=t.ty,l=e.a,c=e.b,u=e.c,_=e.d;return this.a=i*l+r*u,this.b=i*c+r*_,this.c=n*l+o*u,this.d=n*c+o*_,this.tx=a*l+h*u+e.tx,this.ty=a*c+h*_+e.ty,this}setTransform(t,e,i,r,n,o,a,h,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(i*this.a+r*this.c),this.ty=e-(i*this.b+r*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,r=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,r=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-r,n),h=Math.atan2(i,e),l=Math.abs(a+h);return l<1e-5||Math.abs(Dl-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(o.x*e+o.y*r),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,o=t*r-e*i;return this.a=r/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-r*n)/
vendor: 6,398 bytes, lines 2-5
2o,this.ty=-(t*this.ty-e*n)/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 t=new pt;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.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 Hl.identity()}static get shared(){return Wl.identity()}}const Wl=new pt,Hl=new pt,Xe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Ye=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],je=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],qe=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],vr=[],jo=[],qi=Math.sign;function Vl(){for(let s=0;s<16;s++){const t=[];vr.push(t);for(let e=0;e<16;e++){const i=qi(Xe[s]*Xe[e]+je[s]*Ye[e]),r=qi(Ye[s]*Xe[e]+qe[s]*Ye[e]),n=qi(Xe[s]*je[e]+je[s]*qe[e]),o=qi(Ye[s]*je[e]+qe[s]*qe[e]);for(let a=0;a<16;a++)if(Xe[a]===i&&Ye[a]===r&&je[a]===n&&qe[a]===o){t.push(a);break}}}for(let s=0;s<16;s++){const t=new pt;t.set(Xe[s],Ye[s],je[s],qe[s],0,0),jo.push(t)}}Vl();const Ct={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=>Xe[s],uY:s=>Ye[s],vX:s=>je[s],vY:s=>qe[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>vr[s][t],sub:(s,t)=>vr[s][Ct.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?Ct.S:Ct.N:Math.abs(t)*2<=Math.abs(s)?s>0?Ct.E:Ct.W:t>0?s>0?Ct.SE:Ct.SW:s>0?Ct.NE:Ct.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=jo[Ct.inv(t)];r.tx=e,r.ty=i,s.append(r)},transformRectCoords:(s,t,e,i)=>{const{x:r,y:n,width:o,height:a}=s,{x:h,y:l,width:c,height:u}=t;return e===Ct.E?(i.set(r+h,n+l,o,a),i):e===Ct.S?i.set(c-n-a+h,r+l,a,o):e===Ct.W?i.set(c-r-o+h,u-n-a+l,o,a):e===Ct.N?i.set(n+h,u-r-o+l,a,o):i.set(r+h,n+l,o,a)}},$i=[new dt,new dt,new dt,new dt];class Mt{constructor(t=0,e=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r)}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 Mt(0,0,0,0)}clone(){return new Mt(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,r=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,h=this.y,l=i*(1-r),c=i-l,u=a-l,_=a+n+l,d=h-l,f=h+o+l,g=a+c,p=a+n-c,y=h+c,x=h+o-c;return t>=u&&t<=_&&e>=d&&e<=f&&!(t>g&&t<p&&e>y&&e<x)}intersects(t,e){if(!e){const R=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=R)return!1;const P=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>P}const i=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=i||o<=n)return!1;const a=$i[0].set(t.left,t.top),h=$i[1].set(t.left,t.bottom),l=$i[2].set(t.right,t.top),c=$i[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=i||Math.min(a.x,h.x,l.x,c.x)>=r||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const _=u*(h.y-a.y),d=u*(a.x-h.x),f=_*i+d*n,g=_*r+d*n,p=_*i+d*o,y=_*r+d*o;if(Math.max(f,g,p,y)<=_*a.x+d*a.y||Math.min(f,g,p,y)>=_*c.x+d*c.y)return!1;const x=u*(a.y-l.y),v=u*(l.x-a.x),b=x*i+v*n,C=x*r+v*n,w=x*i+v*o,k=x*r+v*o;return!(Math.max(b,C,w,k)<=x*a.x+v*a.y||Math.min(b,C,w,k)>=x*c.x+v*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=r-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=n-r,this}getBounds(t){return t||(t=new Mt),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,r=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&r>=this.x&&r<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,i,r){return this.x=t,this.y=e,this.width=i,this.height=r,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Ws={default:-1};function Ot(s="default"){return Ws[s]===void 0&&(Ws[s]=-1),++Ws[s]}const Sn=new Set,wt="8.0.0",Xl="8.3.4",oi={quiet:!1,noColor:!1},ht=(s,t,e=3)=>{if(oi.quiet||Sn.has(t))return;let i=new Error().stack;const r=`${t} 3Deprecated since v${s}`,n=typeof console.groupCollapsed=="function"&&!oi.noColor;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",r):(i=i.split(` 4`).splice(e).join(` 5`),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",r),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",r),console.warn(i))),Sn.add(t)};Object.defineProperties(ht,{quiet:{get:()=>oi.quiet,set:s=>{oi.quiet=s},enumerable:!0,configurable:!1},noColor:{get:()=>oi.noColor,set:s=>{oi.noColor=s},enumerable:!0,configurable:!1}});const qo=()=>{};function ys(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}
vendor: 13,702 bytes, line 5
5function Cn(s){return!(s&s-1)&&!!s}function $o(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const Mn=Object.create(null);function Yl(s){const t=Mn[s];return t===void 0&&(Mn[s]=Ot("resource")),t}const Ko=class Zo extends we{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Zo.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){ht(wt,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Yl(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Ko.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let xs=Ko;const Qo=class Jo extends we{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=Ot("textureSource"),this._resourceType="textureSource",this._resourceId=Ot("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,t={...Jo.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.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=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new xs($o(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){this.style!==t&&(this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=Ot("resource"),this.emit("change",this),this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const r=Math.round(t*i),n=Math.round(e*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=Ot("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=Cn(this.pixelWidth)&&Cn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Qo.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let me=Qo;class Zr extends me{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}Zr.extension=$.TextureSource;const Tn=new pt;class jl{constructor(t,e){this.mapCoord=new pt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){this.texture!==t&&(this._texture?.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],o=t[r+1];e[r]=n*i.a+o*i.c+i.tx,e[r+1]=n*i.b+o*i.d+i.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,r=t.trim;r&&(Tn.set(i.width/r.width,0,0,i.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(Tn));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,h=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+h)/n.width,o[1]=(t.frame.y+a+h)/n.height,o[2]=(t.frame.x+t.frame.width-a+h)/n.width,o[3]=(t.frame.y+t.frame.height-a+h)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class _t extends we{constructor({source:t,label:e,frame:i,orig:r,trim:n,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=Ot("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Mt,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=t?.source??new me,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=r||this.frame,this.trim=n,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new jl(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:r}=this._source,n=e.x/i,o=e.y/r,a=e.width/i,h=e.height/r;let l=this.rotate;if(l){const c=a/2,u=h/2,_=n+c,d=o+u;l=Ct.add(l,Ct.NW),t.x0=_+c*Ct.uX(l),t.y0=d+u*Ct.uY(l),l=Ct.add(l,2),t.x1=_+c*Ct.uX(l),t.y1=d+u*Ct.uY(l),l=Ct.add(l,2),t.x2=_+c*Ct.uX(l),t.y2=d+u*Ct.uY(l),l=Ct.add(l,2),t.x3=_+c*Ct.uX(l),t.y3=d+u*Ct.uY(l)}else t.x0=n,t.y0=o,t.x1=n+a,t.y1=o,t.x2=n+a,t.y2=o+h,t.x3=n,t.y3=o+h}destroy(t=!1){this._source&&(this._source.off("resize",this.update,this),t&&(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 ht(wt,"Texture.baseTexture is now Texture.source"),this._source}}_t.EMPTY=new _t({label:"EMPTY",source:new me({label:"EMPTY"})});_t.EMPTY.destroy=qo;_t.WHITE=new _t({source:new Zr({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});_t.WHITE.destroy=qo;function ql(s,t,e){const{width:i,height:r}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;s.minX=n.x-t._x*i,s.maxX=s.minX+o,s.minY=n.y-t._y*r,s.maxY=s.minY+a}else s.minX=-t._x*i,s.maxX=s.minX+i,s.minY=-t._y*r,s.maxY=s.minY+r}const Pn=new pt;class be{constructor(t=1/0,e=1/0,i=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Pn,this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Mt);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Pn,this}set(t,e,i,r){this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}addFrame(t,e,i,r,n){n||(n=this.matrix);const o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,u=n.ty;let _=this.minX,d=this.minY,f=this.maxX,g=this.maxY,p=o*t+h*e+c,y=a*t+l*e+u;p<_&&(_=p),y<d&&(d=y),p>f&&(f=p),y>g&&(g=y),p=o*i+h*e+c,y=a*i+l*e+u,p<_&&(_=p),y<d&&(d=y),p>f&&(f=p),y>g&&(g=y),p=o*t+h*r+c,y=a*t+l*r+u,p<_&&(_=p),y<d&&(d=y),p>f&&(f=p),y>g&&(g=y),p=o*i+h*r+c,y=a*i+l*r+u,p<_&&(_=p),y<d&&(d=y),p>f&&(f=p),y>g&&(g=y),this.minX=_,this.minY=d,this.maxX=f,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,r=this.maxX,n=this.maxY,{a:o,b:a,c:h,d:l,tx:c,ty:u}=t;let _=o*e+h*i+c,d=a*e+l*i+u;this.minX=_,this.minY=d,this.maxX=_,this.maxY=d,_=o*r+h*i+c,d=a*r+l*i+u,this.minX=_<this.minX?_:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=_>this.maxX?_:this.maxX,this.maxY=d>this.maxY?d:this.maxY,_=o*e+h*n+c,d=a*e+l*n+u,this.minX=_<this.minX?_:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=_>this.maxX?_:this.maxX,this.maxY=d>this.maxY?d:this.maxY,_=o*r+h*n+c,d=a*r+l*n+u,this.minX=_<this.minX?_:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=_>this.maxX?_:this.maxX,this.maxY=d>this.maxY?d:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,r){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>r&&(this.maxY=r),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,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 be(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}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}
vendor: 6,344 bytes, line 5
5addVertexData(t,e,i,r){let n=this.minX,o=this.minY,a=this.maxX,h=this.maxY;r||(r=this.matrix);const l=r.a,c=r.b,u=r.c,_=r.d,d=r.tx,f=r.ty;for(let g=e;g<i;g+=2){const p=t[g],y=t[g+1],x=l*p+u*y+d,v=c*p+_*y+f;n=x<n?x:n,o=v<o?v:o,a=x>a?x:a,h=v>h?v:h}this.minX=n,this.minY=o,this.maxX=a,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var $l={grad:.9,turn:360,rad:360/(2*Math.PI)},ze=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},Yt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},pe=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},ta=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},zn=function(s){return{r:pe(s.r,0,255),g:pe(s.g,0,255),b:pe(s.b,0,255),a:pe(s.a)}},Hs=function(s){return{r:Yt(s.r),g:Yt(s.g),b:Yt(s.b),a:Yt(s.a,3)}},Kl=/^#([0-9a-f]{3,8})$/i,Ki=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},ea=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:r}},ia=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),l=n%6;return{r:255*[i,a,o,o,h,i][l],g:255*[h,i,i,a,o,o][l],b:255*[o,o,h,i,i,a][l],a:r}},In=function(s){return{h:ta(s.h),s:pe(s.s,0,100),l:pe(s.l,0,100),a:pe(s.a)}},En=function(s){return{h:Yt(s.h),s:Yt(s.s),l:Yt(s.l),a:Yt(s.a,3)}},Rn=function(s){return ia((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},zi=function(s){return{h:(t=ea(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},Zl=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ql=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jl=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wr={string:[[function(s){var t=Kl.exec(s);return t?(s=t[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?Yt(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?Yt(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=Jl.exec(s)||tc.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:zn({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=Zl.exec(s)||Ql.exec(s);if(!t)return null;var e,i,r=In({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*($l[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Rn(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return ze(t)&&ze(e)&&ze(i)?zn({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!ze(t)||!ze(e)||!ze(i))return null;var o=In({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Rn(o)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!ze(t)||!ze(e)||!ze(i))return null;var o=(function(a){return{h:ta(a.h),s:pe(a.s,0,100),v:pe(a.v,0,100),a:pe(a.a)}})({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return ia(o)},"hsv"]]},Fn=function(s,t){for(var e=0;e<t.length;e++){var i=t[e][0](s);if(i)return[i,t[e][1]]}return[null,void 0]},ec=function(s){return typeof s=="string"?Fn(s.trim(),wr.string):typeof s=="object"&&s!==null?Fn(s,wr.object):[null,void 0]},Vs=function(s,t){var e=zi(s);return{h:e.h,s:pe(e.s+100*t,0,100),l:e.l,a:e.a}},Xs=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},Bn=function(s,t){var e=zi(s);return{h:e.h,s:e.s,l:pe(e.l+100*t,0,100),a:e.a}},kr=(function(){function s(t){this.parsed=ec(t)[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 Yt(Xs(this.rgba),2)},s.prototype.isDark=function(){return Xs(this.rgba)<.5},s.prototype.isLight=function(){return Xs(this.rgba)>=.5},s.prototype.toHex=function(){return t=Hs(this.rgba),e=t.r,i=t.g,r=t.b,o=(n=t.a)<1?Ki(Yt(255*n)):"","#"+Ki(e)+Ki(i)+Ki(r)+o;var t,e,i,r,n,o},s.prototype.toRgb=function(){return Hs(this.rgba)},s.prototype.toRgbString=function(){return t=Hs(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return En(zi(this.rgba))},s.prototype.toHslString=function(){return t=En(zi(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=ea(this.rgba),{h:Yt(t.h),s:Yt(t.s),v:Yt(t.v),a:Yt(t.a,3)};var t},s.prototype.invert=function(){return Ae({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),Ae(Vs(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ae(Vs(this.rgba,-t))},s.prototype.grayscale=function(){return Ae(Vs(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),Ae(Bn(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),Ae(Bn(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?Ae({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Yt(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=zi(this.rgba);return typeof t=="number"?Ae({h:t,s:e.s,l:e.l,a:e.a}):Yt(e.h)},s.prototype.isEqual=function(t){return this.toHex()===Ae(t).toHex()},s})(),Ae=function(s){return s instanceof kr?s:new kr(s)}
vendor: 8,625 bytes, line 5
5,Ln=[],ic=function(s){s.forEach(function(t){Ln.indexOf(t)<0&&(t(kr,wr),Ln.push(t))})};function sc(s,t){var e={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 r in e)i[e[r]]=r;var n={};s.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=i[this.toHex()];if(l)return l;if(o?.closest){var c=this.toRgb(),u=1/0,_="black";if(!n.length)for(var d in e)n[d]=new s(e[d]).toRgb();for(var f in e){var g=(a=c,h=n[f],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));g<u&&(u=g,_=f)}return _}},t.string.push([function(o){var a=o.toLowerCase(),h=a==="transparent"?"#0000":e[a];return h?new s(h).toRgb():null},"name"])}ic([sc]);const ui=class Ci{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}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(t){return this.value=t,this}set value(t){if(t instanceof Ci)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((n,o)=>n===e[o]);if(t!==null&&e!==null){const n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=Ci._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,r=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Ci.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Ae(t);o.isValid()&&({r:e,g:i,b:r,a:n}=o.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Ci||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};ui.shared=new ui;ui._temp=new ui;ui.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Ht=ui;const rc={cullArea:null,cullable:!1,cullableChildren:!0};let Ys=0;const On=500;function zt(...s){Ys!==On&&(Ys++,Ys===On?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}const Wi={_registeredResources:new Set,register(s){this._registeredResources.add(s)},unregister(s){this._registeredResources.delete(s)}
5,release(){this._registeredResources.forEach(s=>s.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(s){return this._registeredResources.has(s)},reset(){this._registeredResources.clear()}};class nc{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){let e;return this._index>0?e=this._pool[--this._index]:(e=new this._classType,this._count++),e.init?.(t),e}return(t){t.reset?.(),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class oc{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new nc(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const ge=new oc;Wi.register(ge);const ac={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){ht("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(s)}};function hc(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r<n;++r)s[r]=s[r+e];s.length=n}const lc={allowChildren:!0,removeChildren(s=0,t){const e=t??this.children.length,i=e-s,r=[];if(i>0&&i<=e){for(let o=e-1;o>=s;o--){const a=this.children[o];a&&(r.push(a),a.parent=null)}hc(this.children,s,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let o=0;o<r.length;++o){const a=r[o];a.parentRenderLayer?.detach(a),this.emit("childRemoved",a,this,o),r[o].emit("removed",this)}return r.length>0&&this._didViewChangeTick++,r}else if(i===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const t=this.getChildAt(s);return this.removeChild(t)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||ht(wt,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const r=s.parent.children.indexOf(s);if(s.parent===this&&r===t)return s;r!==-1&&s.parent.children.splice(r,1)}t===e.length?e.push(s):e.splice(t,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,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;const e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),s.setFromMatrix(e),s},replaceChild(s,t){s.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(s)),t.setFromMatrix(s.localTransform),t.updateLocalTransform(),this.removeChild(s)}},cc={collectRenderables(s,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(s,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,s):this.collectRenderablesWithEffects(s,t,e))},collectRenderablesSimple(s,t,e){const i=this.children,r=i.length;for(let n=0;n<r;n++)i[n].collectRenderables(s,t,e)},collectRenderablesWithEffects(s,t,e){const{renderPipes:i}=t;
vendor: 9,469 bytes, line 5
5for(let r=0;r<this.effects.length;r++){const n=this.effects[r];i[n.pipe].push(n,this,s)}this.collectRenderablesSimple(s,t,e);for(let r=this.effects.length-1;r>=0;r--){const n=this.effects[r];i[n.pipe].pop(n,this,s)}}};class Gn{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class uc{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return ge.get(i.maskClass,t)}return t}returnMaskEffect(t){ge.return(t)}}const Ar=new uc;$t.handleByList($.MaskEffect,Ar._effectClasses);const dc={_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((e,i)=>e.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(s){const t=this._maskEffect;t?.mask!==s&&(t&&(this.removeEffect(t),Ar.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=Ar.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(s){this._maskOptions={...this._maskOptions,...s},s.mask&&(this.mask=s.mask),this._markStructureAsChanged()},set filters(s){!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new Gn);s=s;const e=s?.length>0,i=t.filters?.length>0,r=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){return this._filterEffect?.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new Gn),this._filterEffect.filterArea=s},get filterArea(){return this._filterEffect?.filterArea}},_c={label:null,get name(){return ht(wt,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){ht(wt,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i<e.length;i++){const r=e[i];if(r.label===s||s instanceof RegExp&&s.test(r.label))return r}if(t)for(let i=0;i<e.length;i++){const n=e[i].getChildByLabel(s,!0);if(n)return n}return null},getChildrenByLabel(s,t=!1,e=[]){const i=this.children;for(let r=0;r<i.length;r++){const n=i[r];(n.label===s||s instanceof RegExp&&s.test(n.label))&&e.push(n)}if(t)for(let r=0;r<i.length;r++)i[r].getChildrenByLabel(s,!0,e);return e}},te=ge.getPool(pt),Ee=ge.getPool(be),fc=new pt,pc={getFastGlobalBounds(s,t){t||(t=new be),t.clear(),this._getGlobalBoundsRecursive(!!s,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(s,t,e){let i=t;if(s&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const r=!!this.effects.length;if((this.renderGroup||r)&&(i=Ee.get().clear()),this.boundsArea)t.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 n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(s,i,e)}if(r){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));n&&i.applyMatrix(o.worldTransform.copyTo(fc).invert()),t.addBounds(i),Ee.return(i)}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),Ee.return(i))}};function sa(s,t,e){e.clear();let i,r;return s.parent?t?i=s.parent.worldTransform:(r=te.get().identity(),i=Qr(s,r)):i=pt.IDENTITY,ra(s,e,i,t),r&&te.return(r),e.isValid||e.set(0,0,0,0),e}function ra(s,t,e,i){if(!s.visible||!s.measurable)return;let r;i?r=s.worldTransform:(s.updateLocalTransform(),r=te.get(),r.appendFrom(s.localTransform,e));const n=t,o=!!s.effects.length;if(o&&(t=Ee.get().clear()),s.boundsArea)t.addRect(s.boundsArea,r);else{const a=s.bounds;a&&!a.isEmpty()&&(t.matrix=r,t.addBounds(a));for(let h=0;h<s.children.length;h++)ra(s.children[h],t,r,i)}if(o){for(let a=0;a<s.effects.length;a++)s.effects[a].addBounds?.(t);n.addBounds(t,pt.IDENTITY),Ee.return(t)}i||te.return(r)}function Qr(s,t){const e=s.parent;return e&&(Qr(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function na(s,t){if(s===16777215||!t)return t;if(t===16777215||!s)return s;const e=s>>16&255,i=s>>8&255,r=s&255,n=t>>16&255,o=t>>8&255,a=t&255,h=e*n/255|0,l=i*o/255|0,c=r*a/255|0;return(h<<16)+(l<<8)+c}const Dn=16777215;function Un(s,t){return s===Dn?t:t===Dn?s:na(s,t)}function cs(s){return((s&255)<<16)+(s&65280)+(s>>16&255)}const gc={getGlobalAlpha(s){if(s)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(s=new pt,t){if(t)return s.copyFrom(this.worldTransform);this.updateLocalTransform();const e=Qr(this,te.get().identity());return s.appendFrom(this.localTransform,e),te.return(e),s},getGlobalTint(s){if(s)return this.renderGroup?cs(this.renderGroup.worldColor):this.parentRenderGroup?cs(Un(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Un(t,e.localColor),e=e.parent;return cs(t)}};function oa(s,t,e){return t.clear(),e||(e=pt.IDENTITY),aa(s,t,e,s,!0),t.isValid||t.set(0,0,0,0),t}function aa(s,t,e,i,r){let n;if(r)n=te.get(),n=e.copyTo(n);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const h=s.localTransform;n=te.get(),n.appendFrom(h,e)}const o=t,a=!!s.effects.length;if(a&&(t=Ee.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else{s.renderPipeId&&(t.matrix=n,t.addBounds(s.bounds));const h=s.children;for(let l=0;l<h.length;l++)aa(h[l],t,n,i,!1)}if(a){for(let h=0;h<s.effects.length;h++)s.effects[h].addLocalBounds?.(t,i);o.addBounds(t,pt.IDENTITY),Ee.return(t)}te.return(n)}function ha(s,t){const e=s.children;for(let i=0;i<e.length;i++){const r=e[i],n=r.uid,o=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,a=t.index;(t.data[a]!==n||t.data[a+1]!==o)&&(t.data[t.index]=n,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,r.children.length&&ha(r,t)}return t.didChange}const mc=new pt,yc={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(s,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=s/t*e:this.scale.x=e},_setHeight(s,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=s/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new be});const s=this._localBoundsCacheData;return s.index=1,s.didChange=!1,s.data[0]!==this._didViewChangeTick&&(s.didChange=!0,s.data[0]=this._didViewChangeTick),ha(this,s),s.didChange&&oa(this,s.localBounds,mc),s.localBounds},getBounds(s,t){return sa(this,s,t||new be)}},xc={_onRender:null,set onRender(s){const t=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&t?.removeOnRender(this),this._onRender=null;return}this._onRender||t?.addOnRender(this),this._onRender=s},get onRender(){return this._onRender}},bc={_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(vc))}};function vc(s,t){return s._zIndex-t._zIndex}const wc={getGlobalPosition(s=new dt,t=!1){return this.parent?this.parent.toGlobal(this._position,s,t):(s.x=this._position.x,s.y=this._position.y),s},toGlobal(s,t,e=!1){const i=this.getGlobalTransform(te.get(),e);return t=i.apply(s,t),te.return(i),t},toLocal(s,t,e,i){t&&(s=t.toGlobal(s,e,i));const r=this.getGlobalTransform(te.get(),i);return e=r.applyInverse(s,e),te.return(r),e}};class la{constructor(){this.uid=Ot("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let kc=0;class Ac{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new xs(this.textureOptions)}createTexture(t,e,i){const r=new me({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1});return new _t({source:r,label:`texturePool_${kc++}`})}getOptimalTexture(t,e,i=1,r){let n=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);n=ys(n),o=ys(o);
5const a=(n<<17)+(o<<1)+(r?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(n,o,r)),h.source._resolution=i,h.source.width=n/i,h.source.height=o/i,h.source.pixelWidth=n,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0)}this._texturePool={}}}const di=new Ac;Wi.register(di);class Sc{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new pt,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 la,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++){const r=e[i];r._updateFlags=15,this.addChild(r)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(di.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.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(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}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(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let r=0;r<i.length;r++)this._getChildren(i[r],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new pt),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new pt),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new pt),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function Cc(s,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(s[i]=t[i])}const js=new Kt(null),Zi=new Kt(null),qs=new Kt(null,1,1),Qi=new Kt(null),Nn=1,Mc=2,$s=4;class lt extends we{constructor(t={}){super(),this.uid=Ot("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.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new pt,this.relativeGroupTransform=new pt,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Kt(this,0,0),this._scale=qs,this._pivot=Zi,this._origin=Qi,this._skew=js,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.localBlendM
vendor: 8,968 bytes, line 5
5ode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Cc(this,t,{children:!0,parent:!0,effects:!0}),t.children?.forEach(e=>this.addChild(e)),t.parent?.addChild(this)}static mixin(t){ht("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),$t.mixin(lt,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||ht(wt,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r<t.length;r++)this.addChild(t[r]);return t[0]}const e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let r=0;r<t.length;r++)this.removeChild(t[r]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),this.renderGroup=ge.get(Sc,this),this.groupTransform=pt.IDENTITY,t?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),ge.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new pt),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(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Ul}set angle(t){this.rotation=t*Nl}get pivot(){return this._pivot===Zi&&(this._pivot=new Kt(this,0,0)),this._pivot}set pivot(t){this._pivot===Zi&&(this._pivot=new Kt(this,0,0),this._origin!==Qi&&zt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===js&&(this._skew=new Kt(this,0,0)),this._skew}set skew(t){this._skew===js&&(this._skew=new Kt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===qs&&(this._scale=new Kt(this,1,1)),this._scale}set scale(t){this._scale===qs&&(this._scale=new Kt(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Qi&&(this._origin=new Kt(this,0,0)),this._origin}set origin(t){this._origin===Qi&&(this._origin=new Kt(this,0,0),this._pivot!==Zi&&zt("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,r=this._pivot,n=this._origin,o=this._position,a=i._x,h=i._y,l=r._x,c=r._y,u=-n._x,_=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*h,e.d=this._sy*h,e.tx=o._x-(l*e.a+c*e.c)+(u*e.a+_*e.c)-u,e.ty=o._y-(l*e.b+c*e.d)+(u*e.b+_*e.d)-_}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Nn,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=Ht.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=Nn,this._onUpdate())}get tint(){return cs(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Mc,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=$s,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=$s,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=$s,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){if(this.destroyed)return;this.destroyed=!0;let e;if(this.children.length&&(e=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._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t?.children)&&e)for(let r=0;r<e.length;++r)e[r].destroy(t);this.renderGroup?.destroy(),this.renderGroup=null}}$t.mixin(lt,lc,pc,wc,xc,yc,dc,_c,bc,rc,ac,gc,cc);class ca extends lt{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new be(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=t.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:r}=t;return i>=e.minX&&i<=e.maxX&&r>=e.minY&&r<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}
5unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,i){const{renderPipes:r}=e;r.blendMode.pushBlendMode(this,this.groupBlendMode,t),r[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const o=this.children,a=o.length;for(let h=0;h<a;h++)o[h].collectRenderables(t,e,i);r.blendMode.popBlendMode(t)}}class kt extends ca{constructor(t=_t.EMPTY){t instanceof _t&&(t={texture:t});const{texture:e=_t.EMPTY,anchor:i,roundPixels:r,width:n,height:o,...a}=t;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Kt({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=r??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof _t?new kt(t):new kt(_t.from(t,e))}set texture(t){t||(t=_t.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,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 ql(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return ht("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:r,height:n}=e.orig;i.minX=-t._x*r,i.maxX=i.minX+r,i.minY=-t._y*n,i.maxY=i.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t?.texture){const i=typeof t=="boolean"?t:t?.textureSource;this._texture.destroy(i)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const Tc=new be;function ua(s,t,e){const i=Tc;s.measurable=!0,sa(s,e,i),t.addBoundsMask(i),s.measurable=!1}function da(s,t,e){const i=Ee.get();s.measurable=!0;const r=te.get().identity(),n=_a(s,e,r);oa(s,i,n),s.measurable=!1,t.addBoundsMask(i),te.return(r),Ee.return(i)}function _a(s,t,e){return s?(s!==t&&(_a(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(zt("Mask bounds, renderable is not inside the root container"),e)}class fa{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof kt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||ua(this.mask,t,e)}addLocalBounds(t,e){da(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof kt}}fa.extension=$.MaskEffect;class pa{constructor(t){this.priority=0,this.pipe="colorMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}pa.extension=$.MaskEffect;class ga{constructor(t){this.priority=0,this.pipe="stencilMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){ua(this.mask,t,e)}addLocalBounds(t,e){da(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof lt}}ga.extension=$.MaskEffect;const Pc={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>
vendor: 18,266 bytes, line 5
5new DOMParser().parseFromString(s,"text/xml")};let Wn=Pc;const It={get(){return Wn},set(s){Wn=s}};class ma extends me{constructor(t){t.resource||(t.resource=It.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(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(t=this.width,e=this.height,i=this._resolution){const r=super.resize(t,e,i);return r&&this.resizeCanvas(),r}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}ma.extension=$.TextureSource;class Je extends me{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}Je.extension=$.TextureSource;var Sr=(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))(Sr||{});class Ks{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=r}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!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 e=this.next;return this.next=t?null:e,this.previous=null,e}}const ya=class oe{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 Ks(null,null,1/0),this.deltaMS=1/oe.targetFPMS,this.elapsedMS=1/oe.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),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(t,e,i=Sr.NORMAL){return this._addListener(new Ks(t,e,i))}addOnce(t,e,i=Sr.NORMAL){return this._addListener(new Ks(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*oe.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,oe.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!oe._shared){const t=oe._shared=new oe;t.autoStart=!0,t._protected=!0}return oe._shared}static get system(){if(!oe._system){const t=oe._system=new oe;t.autoStart=!0,t._protected=!0}return oe._system}};ya.targetFPMS=.06;let Ji=ya,Zs;async function xa(){return Zs??(Zs=(async()=>{const t=It.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=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(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(i),t.getExtension("WEBGL_lose_context")?.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Zs}const Ss=class ba extends me{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...ba.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.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),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Ji.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!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 t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await xa(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.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 t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.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 t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Ji.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||(Ji.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Ji.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ss.extension=$.TextureSource;Ss.defaultOptions={...me.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ss.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Ii=Ss;const xe=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class zc{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||zt(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=xe(t);let r;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(e)){r=l.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(r||{}));r||i.forEach(h=>{n.set(h,e)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&zt("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){zt(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const Pt=new zc,Cr=[];$t.handleByList($.TextureSource,Cr);function va(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r<Cr.length;r++){const n=Cr[r];if(n.test(e))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function Ic(s={},t=!1){const e=s&&s.resource,i=e?s.resource:s,r=e?s:{resource:s};if(!t&&Pt.has(i))return Pt.get(i);const n=new _t({source:va(r)});return n.on("destroy",()=>{Pt.has(i)&&Pt.remove(i)}),t||Pt.set(i,n),n}function Ec(s,t=!1){return typeof s=="string"?Pt.get(s):s instanceof me?new _t({source:s}):Ic(s,t)}_t.from=Ec;me.from=va;$t.add(fa,pa,ga,Ii,Je,ma,Zr);var He=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(He||{});function ye(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function xi(s){return s.split("?")[0].split("#")[0]}function Rc(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fc(s,t,e){return s.replace(new RegExp(Rc(t),"g"),e)}function Bc(s,t){let e="",i=0,r=-1,n=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(!(r===a-1||n===1))if(r!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=a,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,a)}`:e=s.slice(r+1,a),i=a-r-1;r=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const le={toPosix(s){return Fc(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){ye(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(ye(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=xi(this.toPosix(t??It.get().getBaseUrl())),r=xi(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?le.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(ye(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=Bc(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return ye(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){const i=s[e];if(ye(i),i.length>0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(ye(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),o=s;s=s.slice(n.length);for(let a=s.length-1;a>=1;--a)if(t=s.charCodeAt(a),t===47){if(!r){i=a;break}}else r=!1;return i===-1?e?"/":this.isUrl(o)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){ye(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){ye(s),t&&ye(t),s=xi(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let o=t.length-1,a=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else a===-1&&(r=!1,a=n+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){ye(s),s=xi(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let o=s.length-1;o>=0;--o){const a=s.charCodeAt(o);if(a===47){if(!r){e=o+1;break}continue}i===-1&&(r=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){ye(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=xi(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,o=0,a=-1,h=!0,l=s.length-1,c=0;for(;l>=r;--l){if(e=s.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?n===-1?n=l:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=s.slice(1,a):t.base=t.name=s.slice(o,a)):(o===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,a)):(t.name=s.slice(o,n),t.base=s.slice(o,a)),t.ext=s.slice(n,a)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function wa(s,t,e,i,r){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];
5e<t.length-1?wa(s.replace(i[e],a),t,e+1,i,r):r.push(s.replace(i[e],a))}}function Lc(s){const t=/\{(.*?)\}/g,e=s.match(t),i=[];if(e){const r=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");r.push(o)}),wa(s,r,0,e,i)}else i.push(s);return i}const bs=s=>!Array.isArray(s);class pi{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${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(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}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(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return xe(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>o?.src??o):n?.src?n.src:n,!0)}addManifest(t){this._manifest&&zt("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),r.forEach(n=>{const o=n.src,a=n.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);i.push(l),h=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(t,c));i.push(...l),h=[...a,...l]}this.add({...n,alias:h,src:o})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&zt(`[Resolver] already has key: ${n} overwriting`)},xe(e).forEach(n=>{const{src:o}=n;let{data:a,format:h,loadParser:l,parser:c}=n;const u=xe(o).map(g=>typeof g=="string"?Lc(g):Array.isArray(g)?g:[g]),_=this.getAlias(n);Array.isArray(_)?_.forEach(i):i(_);const d=[],f=g=>({...this._parsers.find(y=>y.test(g))?.parse(g),src:g});u.forEach(g=>{g.forEach(p=>{let y={};if(typeof p!="object"?y=f(p):(a=p.data??a,h=p.format??h,(p.loadParser||p.parser)&&(l=p.loadParser??l,c=p.parser??c),y={...f(p.src),...p}),!_)throw new Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this._buildResolvedAsset(y,{aliases:_,data:a,format:h,loadParser:l,parser:c,progressSize:n.progressSize}),d.push(y)})}),_.forEach(g=>{this._assetMap[g]=d})})}resolveBundle(t){const e=bs(t);t=xe(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(r,h)]=l}i[r]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=bs(t);t=xe(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const o=this._getPreferredOrder(n);o?.priority.forEach(a=>
vendor: 11,744 bytes, lines 5-23
5{o.params[a].forEach(h=>{const l=n.filter(c=>c[a]?c[a]===h:!1);l.length&&(n=l)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[e],r=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:i,data:r,loadParser:n,parser:o,format:a,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=le.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??Oc(t.src),h!==void 0&&(t.progressSize=h),t}}pi.RETINA_PREFIX=/@([0-9\.]+)x/;function Oc(s){return s.split(".").pop().split("?").shift().split("#").shift()}const Mr=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},ka=class Mi{constructor(t,e){this.linkedSheets=[];let i=t;t?.source instanceof me&&(i={texture:t,data:e});const{texture:r,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=r instanceof _t?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,r.source.resolution=this.resolution):this.resolution=r.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Mi.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Mi.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const r=this._frameKeys[e],n=this._frames[r],o=n.frame;if(o){let a=null,h=null;const l=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new Mt(0,0,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution);n.rotated?a=new Mt(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 Mt(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(h=new Mt(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[r]=new _t({source:this.textureSource,frame:a,orig:c,trim:h,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:r.toString()})}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const r=t[e][i];this.animations[e].push(this.textures[r])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Mi.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Mi.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(const e in this.textures)this.textures[e].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};ka.BATCH_SIZE=1e3;let Hn=ka;const Gc=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Aa(s,t,e){const i={};if(s.forEach(r=>{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[`${t.cachePrefix}${r}`]=t.textures[r]}),!e){const r=le.dirname(s[0]);t.linkedSheets.forEach((n,o)=>{const a=Aa([`${r}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const Dc={extension:$.Asset,cache:{test:s=>s instanceof Hn,getCacheableAssets:(s,t)=>Aa(s,t,!1)},resolver:{extension:{type:$.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&Gc.includes(r)},parse:s=>{const t=s.split(".");return{resolution:parseFloat(pi.RETINA_PREFIX.exec(s)?.[1]??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:$.LoadParser,priority:He.Normal,name:"spritesheetLoader"},async testParse(s,t){return le.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){const{texture:i,imageFilename:r,textureOptions:n,cachePrefix:o}=t?.data??{};let a=le.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(i instanceof _t)h=i;else{const u=Mr(a+(r??s.meta.image),t.src);h=(await e.load([{src:u,data:n}]))[u]}const l=new Hn({texture:h.source,data:s,cachePrefix:o});await l.parse();const c=s?.meta?.related_multi_packs;if(Array.isArray(c)){const u=[];for(const d of c){if(typeof d!="string")continue;let f=a+d;t.data?.ignoreMultiPack||(f=Mr(f,t.src),u.push(e.load({src:f,data:{textureOptions:n,ignoreMultiPack:!0}})))}const _=await Promise.all(u);l.linkedSheets=_,_.forEach(d=>{d.linkedSheets=[l].concat(l.linkedSheets.filter(f=>f!==d))})}return l},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};$t.add(Dc);const Qs=Object.create(null),Vn=Object.create(null);function Jr(s,t){let e=Vn[s];return e===void 0&&(Qs[t]===void 0&&(Qs[t]=1),Vn[s]=e=Qs[t]++),e}let ts;function Sa(){return(!ts||ts?.isContextLost())&&(ts=It.get().createCanvas().getContext("webgl",{})),ts}let es;function Uc(){if(!es){es="mediump";const s=Sa();s&&s.getShaderPrecisionFormat&&(es=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return es}function Nc(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),` 6 7 #ifdef GL_ES // This checks if it is WebGL1 8 #define in varying 9 #define finalColor gl_FragColor 10 #define texture texture2D 11 #endif 12 ${s} 13 `):` 14 15 #ifdef GL_ES // This checks if it is WebGL1 16 #define in attribute 17 #define out varying 18 #endif 19 ${s} 20 `}function Wc(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float; 21${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function Hc(s,t){return t?`#version 300 es 22${s}`:s}const Vc={},Xc={};function Yc(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?Vc:Xc;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`} 23${s}`}function jc(s,t){return t?s.replace("#version 300 es",""):s}const Js={stripVersion:jc,ensurePrecision:Wc,addProgramDefines:Nc,setProgramName:Yc,insertVersion:Hc},bi=Object.create(null),Ca=class Tr{constructor(t){t={...Tr.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Uc()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(Js).forEach(o=>{const a=i[o];r=Js[o](r,a,!0),n=Js[o](n,a,!1)}),this.fragment=r,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Jr(`${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,bi[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return bi[e]||(bi[e]=new Tr(t),bi[e]._cacheKey=e),bi[e]}};Ca.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let _i=Ca;const Xn={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 qc(s){return Xn[s]??Xn.float32}const $c={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 Kc({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const r=s.indexOf("->",i);if(r!==-1){const n=s.substring(i,r),o=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let a;for(;(a=o.exec(n))!==null;){const h=$c[a[3]]??"float32";e[a[2]]={location:parseInt(a[1],10),format:h,stride:qc(h).stride,offset:0,instance:!1,start:0}}}}return e}function tr(s){const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=s.match(t)?.map(u=>({group:parseInt(u.match(e)[1],10),binding:parseInt(u.match(i)[1],10),name:u.match(r)[2],isUniform:u.match(r)[1]==="<uniform>",type:u.match(n)[1]}));if(!l)return{groups:[],structs:[]};const c=s.match(o)?.map(u=>{const _=u.match(h)[1],d=u.match(a).reduce((f,g)=>{const[p,y]=g.split(":");return f[p.trim()]=y.trim(),f},{});return d?{name:_,members:d}:null}).filter(({name:u})=>l.some(_=>_.type===u))??[];return{groups:l,structs:c}}var Ti=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(Ti||{});function Zc({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:Ti.VERTEX|Ti.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:Ti.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&t[i.group].push({binding:i.binding,visibility:Ti.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function Qc({groups:s}){const t=[];for(let e=0;e<s.length;e++){const i=s[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}
23function Jc(s,t){const e=new Set,i=new Set,r=[...s.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),n=[...s.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:r,groups:n}}const vi=Object.create(null);class We{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=i,e.source===i.source){const a=tr(e.source);this.structsAndGroups=a}else{const a=tr(i.source),h=tr(e.source);this.structsAndGroups=Jc(a,h)}this.layout=r??Qc(this.structsAndGroups),this.gpuLayout=n??Zc(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Jr(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Kc(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,vi[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return vi[e]||(vi[e]=new We(t),vi[e]._cacheKey=e),vi[e]}}const Ma=["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>"],tu=Ma.reduce((s,t)=>(s[t]=!0,s),{});function eu(s,t){switch(s){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);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 Ta=class Pa{constructor(t,e){this._touched=0,this.uid=Ot("uniform"),this._resourceType="uniformGroup",this._resourceId=Ot("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Pa.defaultOptions,...e},this.uniformStructures=t;const i={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!tu[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Ma.join(", ")}`)}n.value??(n.value=eu(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Jr(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Ta.defaultOptions={ubo:!1,isStatic:!1};let za=Ta;class us{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const r=t[i];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){const i=this.resources[e];t!==i&&(i&&t.off?.("change",this.onResourceChange,this),t.on?.("change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){const i=this.resources;for(const r in i)i[r]._gcLastUsed=t,i[r]._touched=e}destroy(){const t=this.resources;for(const e in t)t[e]?.off?.("change",this.onResourceChange,this);this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Pr=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Pr||{});class Cs extends we{constructor(t){super(),this.uid=Ot("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=Pr.WEBGPU),i&&(o|=Pr.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");
vendor: 4,418 bytes, line 23
23if(!e&&r&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&a)for(const l in a)for(const c in a[l]){const u=a[l][c];h[u]={group:l,binding:c,name:u}}else if(e&&r&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c})}else if(n){r={},a={},e&&e.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,h[u.name]=u});let l=0;for(const c in n)h[c]||(r[99]||(r[99]=new us,this._ownedBindGroups.push(r[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const u=c;let _=n[c];!_.source&&!_._resourceType&&(_=new za(_));const d=h[u];d&&(r[d.group]||(r[d.group]=new us,this._ownedBindGroups.push(r[d.group])),r[d.group].setResource(_,d.binding))}}this.groups=r,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,i){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new us,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const r in e){const n=e[r];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return i}destroy(t=!1){this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(e=>{e.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const{gpu:e,gl:i,...r}=t;let n,o;return e&&(n=We.from(e)),i&&(o=_i.from(i)),new Cs({gpuProgram:n,glProgram:o,...r})}}const iu={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},er=0,ir=1,sr=2,rr=3,nr=4,or=5,zr=class Ia{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<er)}set blend(t){!!(this.data&1<<er)!==t&&(this.data^=1<<er)}get offsets(){return!!(this.data&1<<ir)}set offsets(t){!!(this.data&1<<ir)!==t&&(this.data^=1<<ir)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<sr)}set culling(t){!!(this.data&1<<sr)!==t&&(this.data^=1<<sr)}get depthTest(){return!!(this.data&1<<rr)}set depthTest(t){!!(this.data&1<<rr)!==t&&(this.data^=1<<rr)}get depthMask(){return!!(this.data&1<<or)}set depthMask(t){!!(this.data&1<<or)!==t&&(this.data^=1<<or)}get clockwiseFrontFace(){return!!(this.data&1<<nr)}set clockwiseFrontFace(t){!!(this.data&1<<nr)!==t&&(this.data^=1<<nr)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=iu[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new Ia;return t.depthTest=!1,t.blend=!0,t}};zr.default2d=zr.for2d();let su=zr;const Ea=class Ir extends Cs{constructor(t){t={...Ir.defaultOptions,...t},super(t),this.enabled=!0,this._state=su.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,i,r){t.applyFilter(this,e,i,r)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const{gpu:e,gl:i,...r}=t;let n,o;return e&&(n=We.from(e)),i&&(o=_i.from(i)),new Ir({gpuProgram:n,glProgram:o,...r})}};Ea.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Er=Ea;const Rr=[];$t.handleByNamedList($.Environment,Rr);async function ru(s){if(!s)for(let t=0;t<Rr.length;t++){const e=Rr[t];if(e.value.test()){await e.value.load();return}}}let wi;
vendor: 4,469 bytes, line 23
23function nu(){if(typeof wi=="boolean")return wi;try{wi=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{wi=!1}return wi}function Yn(s,t,e=2){const i=t&&t.length,r=i?t[0]*e:s.length;let n=Ra(s,0,r,e,!0);const o=[];if(!n||n.next===n.prev)return o;let a,h,l;if(i&&(n=cu(s,t,n,e)),s.length>80*e){a=s[0],h=s[1];let c=a,u=h;for(let _=e;_<r;_+=e){const d=s[_],f=s[_+1];d<a&&(a=d),f<h&&(h=f),d>c&&(c=d),f>u&&(u=f)}l=Math.max(c-a,u-h),l=l!==0?32767/l:0}return Oi(n,o,e,a,h,l,0),o}function Ra(s,t,e,i,r){let n;if(r===vu(s,t,e,i)>0)for(let o=t;o<e;o+=i)n=jn(o/i|0,s[o],s[o+1],n);else for(let o=e-i;o>=t;o-=i)n=jn(o/i|0,s[o],s[o+1],n);return n&&fi(n,n.next)&&(Di(n),n=n.next),n}function ti(s,t){if(!s)return s;t||(t=s);let e=s,i;do if(i=!1,!e.steiner&&(fi(e,e.next)||Bt(e.prev,e,e.next)===0)){if(Di(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Oi(s,t,e,i,r,n,o){if(!s)return;!o&&n&&pu(s,i,r,n);let a=s;for(;s.prev!==s.next;){const h=s.prev,l=s.next;if(n?au(s,i,r,n):ou(s)){t.push(h.i,s.i,l.i),Di(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=hu(ti(s),t),Oi(s,t,e,i,r,n,2)):o===2&&lu(s,t,e,i,r,n):Oi(ti(s),t,e,i,r,n,1);break}}}function ou(s){const t=s.prev,e=s,i=s.next;if(Bt(t,e,i)>=0)return!1;const r=t.x,n=e.x,o=i.x,a=t.y,h=e.y,l=i.y,c=Math.min(r,n,o),u=Math.min(a,h,l),_=Math.max(r,n,o),d=Math.max(a,h,l);let f=i.next;for(;f!==t;){if(f.x>=c&&f.x<=_&&f.y>=u&&f.y<=d&&Pi(r,a,n,h,o,l,f.x,f.y)&&Bt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function au(s,t,e,i){const r=s.prev,n=s,o=s.next;if(Bt(r,n,o)>=0)return!1;const a=r.x,h=n.x,l=o.x,c=r.y,u=n.y,_=o.y,d=Math.min(a,h,l),f=Math.min(c,u,_),g=Math.max(a,h,l),p=Math.max(c,u,_),y=Fr(d,f,t,e,i),x=Fr(g,p,t,e,i);let v=s.prevZ,b=s.nextZ;for(;v&&v.z>=y&&b&&b.z<=x;){if(v.x>=d&&v.x<=g&&v.y>=f&&v.y<=p&&v!==r&&v!==o&&Pi(a,c,h,u,l,_,v.x,v.y)&&Bt(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=d&&b.x<=g&&b.y>=f&&b.y<=p&&b!==r&&b!==o&&Pi(a,c,h,u,l,_,b.x,b.y)&&Bt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=y;){if(v.x>=d&&v.x<=g&&v.y>=f&&v.y<=p&&v!==r&&v!==o&&Pi(a,c,h,u,l,_,v.x,v.y)&&Bt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=d&&b.x<=g&&b.y>=f&&b.y<=p&&b!==r&&b!==o&&Pi(a,c,h,u,l,_,b.x,b.y)&&Bt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function hu(s,t){let e=s;do{const i=e.prev,r=e.next.next;!fi(i,r)&&Ba(i,e,e.next,r)&&Gi(i,r)&&Gi(r,i)&&(t.push(i.i,e.i,r.i),Di(e),Di(e.next),e=s=r),e=e.next}while(e!==s);return ti(e)}function lu(s,t,e,i,r,n){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&yu(o,a)){let h=La(o,a);o=ti(o,o.next),h=ti(h,h.next),Oi(o,t,e,i,r,n,0),Oi(h,t,e,i,r,n,0);return}a=a.next}o=o.next}while(o!==s)}function cu(s,t,e,i){const r=[];for(let n=0,o=t.length;n<o;n++){const a=t[n]*i,h=n<o-1?t[n+1]*i:s.length,l=Ra(s,a,h,i,!1);l===l.next&&(l.steiner=!0),r.push(mu(l))}r.sort(uu);for(let n=0;n<r.length;n++)e=du(r[n],e);return e}function uu(s,t){let e=s.x-t.x;if(e===0&&(e=s.y-t.y,e===0)){const i=(s.next.y-s.y)/(s.next.x-s.x),r=(t.next.y-t.y)/(t.next.x-t.x);e=i-r}return e}function du(s,t){const e=_u(s,t);if(!e)return t;const i=La(e,s);return ti(i,i.next),ti(e,e.next)}function _u(s,t){let e=t;const i=s.x,r=s.y;let n=-1/0,o;if(fi(s,e))return e;do{if(fi(s,e.next))return e.next;if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){const u=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=i&&u>n&&(n=u,o=e.x<e.next.x?e:e.next,u===i))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,h=o.x,l=o.y;let c=1/0;e=o;do{if(i>=e.x&&e.x>=h&&i!==e.x&&Fa(r<l?i:n,r,h,l,r<l?n:i,r,e.x,e.y)){const u=Math.abs(r-e.y)/(i-e.x);Gi(e,s)&&(u<c||u===c&&(e.x>o.x||e.x===o.x&&fu(o,e)))&&(o=e,c=u)}e=e.next}while(e!==a);return o}function fu(s,t){return Bt(s.prev,s,t.prev)<0&&Bt(t.next,s,s.next)<0}function pu(s,t,e,i){let r=s;do r.z===0&&(r.z=Fr(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,gu(r)}function gu(s){let t,e=1;do{let i=s,r;s=null;let n=null;for(t=0;i;){t++;let o=i,a=0;for(let l=0;l<e&&(a++,o=o.nextZ,!!o);l++);let h=e;for(;a>0||h>0&&o;)a!==0&&(h===0||!o||i.z<=o.z)?(r=i,i=i.nextZ,a--):(r=o,o=o.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;i=o}n.nextZ=null,e*=2}while(t>1);return s}function Fr(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function mu(s){let t=s,e=s;
vendor: 9,193 bytes, line 23
23do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function Fa(s,t,e,i,r,n,o,a){return(r-o)*(t-a)>=(s-o)*(n-a)&&(s-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(r-o)*(i-a)}function Pi(s,t,e,i,r,n,o,a){return!(s===o&&t===a)&&Fa(s,t,e,i,r,n,o,a)}function yu(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!xu(s,t)&&(Gi(s,t)&&Gi(t,s)&&bu(s,t)&&(Bt(s.prev,s,t.prev)||Bt(s,t.prev,t))||fi(s,t)&&Bt(s.prev,s,s.next)>0&&Bt(t.prev,t,t.next)>0)}function Bt(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function fi(s,t){return s.x===t.x&&s.y===t.y}function Ba(s,t,e,i){const r=ss(Bt(s,t,e)),n=ss(Bt(s,t,i)),o=ss(Bt(e,i,s)),a=ss(Bt(e,i,t));return!!(r!==n&&o!==a||r===0&&is(s,e,t)||n===0&&is(s,i,t)||o===0&&is(e,s,i)||a===0&&is(e,t,i))}function is(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function ss(s){return s>0?1:s<0?-1:0}function xu(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&Ba(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function Gi(s,t){return Bt(s.prev,s,s.next)<0?Bt(s,t,s.next)>=0&&Bt(s,s.prev,t)>=0:Bt(s,t,s.prev)<0||Bt(s,s.next,t)<0}function bu(s,t){let e=s,i=!1;const r=(s.x+t.x)/2,n=(s.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function La(s,t){const e=Br(s.i,s.x,s.y),i=Br(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function jn(s,t,e,i){const r=Br(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Di(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 Br(s,t,e){return{i:s,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function vu(s,t,e,i){let r=0;for(let n=t,o=e-i;n<e;n+=i)r+=(s[o]-s[n])*(s[n+1]+s[o+1]),o=n;return r}const wu=Yn.default||Yn;var Oa=(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))(Oa||{});class ku{constructor(t){this.items=[],this._name=t}emit(t,e,i,r,n,o,a,h){const{name:l,items:c}=this;for(let u=0,_=c.length;u<_;u++)c[u][l](t,e,i,r,n,o,a,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-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 Au=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Ga=class Da extends we{constructor(t){super(),this.tick=0,this.uid=Ot("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const e=[...Au,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await ru(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash)t={...this._systemsHash[i].constructor.defaultOptions,...t};t={...Da.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,e){this.tick++;let i=t;if(i instanceof lt&&(i={container:i},e&&(ht(wt,"passing a second argument is deprecated, please use render options instead"),i.target=e.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 r=Array.isArray(i.clearColor)&&i.clearColor.length===4;i.clearColor=r?i.clearColor:Ht.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.visible&&(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(t,e,i){const r=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==r&&this.runners.resolutionChange.emit(i)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=Oa.ALL);const{clear:i,clearColor:r,target:n}=t;Ht.shared.setValue(r??this.background.colorRgba),e.renderTarget.clear(n,i,Ht.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}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(...t){t.forEach(e=>{this.runners[e]=new ku(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,e){const i=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,o=r.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&Wi.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!nu())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()}};Ga.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Ua=Ga,rs;function Su(s){return rs!==void 0||(rs=(()=>{const t={stencil:!0,failIfMajorPerformanceCaveat:s??Ua.defaultOptions.failIfMajorPerformanceCaveat};try{if(!It.get().getWebGLRenderingContext())return!1;let i=It.get().createCanvas().getContext("webgl",t);const r=!!i?.getContextAttributes()?.stencil;if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,r}catch{return!1}})()),rs}let ns;async function Cu(s={}){return ns!==void 0||(ns=await(async()=>{const t=It.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),ns}const qn=["webgl","webgpu","canvas"];async function Mu(s){let t=[];s.preference?(t.push(s.preference),qn.forEach(n=>{n!==s.preference&&t.push(n)})):t=qn.slice();let e,i={};for(let n=0;n<t.length;n++){const o=t[n];if(o==="webgpu"&&await Cu()){const{WebGPURenderer:a}=await ps(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-CWjfA0-A.js");return{WebGPURenderer:h}},__vite__mapDeps([52,2,53,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,46,47,48,49,50,51]),import.meta.url);e=a,i={...s,...s.webgpu};break}else if(o==="webgl"&&Su(s.failIfMajorPerformanceCaveat??Ua.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await ps(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-PxdhROBO.js");return{WebGLRenderer:h}},__vite__mapDeps([54,2,53,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,46,47,48,49,50,51]),import.meta.url);e=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,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}const Na="8.15.0";class Wa{static init(){globalThis.__PIXI_APP_INIT__?.(this,Na)}static destroy(){}}Wa.extension=$.Application;class Tu{constructor(t){this._renderer=t}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,Na)}destroy(){this._renderer=null}}Tu.extension={type:[$.WebGLSystem,$.WebGPUSystem],name:"initHook",priority:-10};const Ha=class Lr{constructor(...t){this.stage=new lt,t[0]!==void 0&&ht(wt,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new lt),this.renderer=await Mu(t),Lr._plugins.forEach(e
23=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return ht(wt,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Lr._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Ha._plugins=[];let Va=Ha;$t.handleByList($.Application,Va._plugins);$t.add(Wa);class Xa extends we{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 ht(wt,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return ht(wt,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return ht(wt,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return ht(wt,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return ht(wt,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(const e in this.chars)this.chars[e].texture?.destroy();this.chars=null,t&&(this.pages.forEach(e=>e.texture.destroy(!0)),this.pages=null)}}class Pu{constructor(t=0,e=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){const e=new Array(t.length);for(let i=0;i<t.length;i++){const r=t[i];e[i]=[r,this.get(r)]}return e}evict(t=!1){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=new Array(this.size);let e=this.first,i=0;for(;e!==null;)t[i++]=e.key,e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let r=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(r={...this.first},this.evict(!0));let n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=n:this.last.next=n,this.last=n}return r}set(t,e,i=!1,r=this.resetTtl){let n=this.items[t];return i||n!==void 0?(n.value=e,i===!1&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){const e=new Array(t.length);for(let i=0;i<t.length;i++)e[i]=this.get(t[i]);return e}}function Ya(s=1e3,t=0,e=!1){if(isNaN(s)||s<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new Pu(s,t,e)}const zu=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Or(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!zu.includes(r)&&(r=`"${r}"`),e[i]=r}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const ar={willReadFrequently:!0},ke=class X{static get experimentalLetterSpacingSupported(){let t=X._experimentalLetterSpacingSupported;if(t===void 0){const e=It.get().getCanvasRenderingContext2D().prototype;t=X._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,o,a,h,l){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l}static measureText(t=" ",e,i=X._canvas,r=e.wordWrap){const n=`${t}-${e.styleKey}-wordWrap-${r}`;if(X._measurementCache.has(n))return X._measurementCache.get(n);const o=Or(e),a=X.measureFont(o);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const h=X.__context;h.font=o;const c=(r?X._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),u=new Array(c.length);let _=0;for(let x=0;x<c.length;x++){const v=X._measureText(c[x],e.letterSpacing,h);u[x]=v,_=Math.max(_,v)}const d=e._stroke?.width||0;let f=_+d;e.dropShadow&&(f+=e.dropShadow.distance);const g=e.lineHeight||a.fontSize;let p=Math.max(g,a.fontSize+d)+(c.length-1)*(g+e.leading);e.dropShadow&&(p+=e.dropShadow.distance);const y=new X(t,e,f,p,c,u,g+e.leading,_,a);return X._measurementCache.set(n,y),y}static _measureText(t,e,i){let r=!1;X.experimentalLetterSpacingSupported&&(X.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}
23px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(t);let o=n.width;const a=-n.actualBoundingBoxLeft;let l=n.actualBoundingBoxRight-a;if(o>0)if(r)o-=e,l-=e;else{const c=(X.graphemeSegmenter(t).length-1)*e;o+=c,l+=c}return Math.max(o,l)}static _wordWrap(t,e,i=X._canvas){const r=i.getContext("2d",ar);let n=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,u=X._collapseSpaces(c),_=X._collapseNewlines(c);let d=!u;const f=e.wordWrapWidth+l,g=X._tokenize(t);for(let p=0;p<g.length;p++){let y=g[p];if(X._isNewline(y)){if(!_){a+=X._addLine(o),d=!u,o="",n=0;continue}y=" "}if(u){const v=X.isBreakingSpace(y),b=X.isBreakingSpace(o[o.length-1]);if(v&&b)continue}const x=X._getFromCache(y,l,h,r);if(x>f)if(o!==""&&(a+=X._addLine(o),o="",n=0),X.canBreakWords(y,e.breakWords)){const v=X.wordWrapSplit(y);for(let b=0;b<v.length;b++){let C=v[b],w=C,k=1;for(;v[b+k];){const S=v[b+k];if(!X.canBreakChars(w,S,y,b,e.breakWords))C+=S;else break;w=S,k++}b+=k-1;const R=X._getFromCache(C,l,h,r);R+n>f&&(a+=X._addLine(o),d=!1,o="",n=0),o+=C,n+=R}}else{o.length>0&&(a+=X._addLine(o),o="",n=0);const v=p===g.length-1;a+=X._addLine(y,!v),d=!1,o="",n=0}else x+n>f&&(d=!1,a+=X._addLine(o),o="",n=0),(o.length>0||!X.isBreakingSpace(y)||d)&&(o+=y,n+=x)}return a+=X._addLine(o,!1),a}static _addLine(t,e=!0){return t=X._trimRight(t),t=e?`${t} 24`:t,t}static _getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=X._measureText(t,e,r)+e,i[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!X.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:X._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:X._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],o=t[r+1];if(X.isBreakingSpace(n,o)||X._isNewline(n)){i!==""&&(e.push(i),i=""),n==="\r"&&o===` 25`?(e.push(`\r 26`),r++):e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,r,n){return!0}static wordWrapSplit(t){return X.graphemeSegmenter(t)}static measureFont(t){if(X._fonts[t])return X._fonts[t];const e=X._context;e.font=t;const i=e.measureText(X.METRICS_STRING+X.BASELINE_SYMBOL),r={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return X._fonts[t]=r,r}static clearMetrics(t=""){t?delete X._fonts[t]:X._fonts={}}static get _canvas(){if(!X.__canvas){let t;try{const e=new OffscreenCanvas(0,0);if(e.getContext("2d",ar)?.measureText)return X.__canvas=e,e;t=It.get().createCanvas()}catch{t=It.get().createCanvas()}t.width=t.height=10,X.__canvas=t}return X.__canvas}static get _context(){return X.__context||(X.__context=X._canvas.getContext("2d",ar)),X.__context}};ke.METRICS_STRING="|ÉqÅ";ke.BASELINE_SYMBOL="M";ke.BASELINE_MULTIPLIER=1.4;ke.HEIGHT_MULTIPLIER=2;ke.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const s=new Intl.Segmenter;return t=>{const e=s.segment(t),i=[];let r=0;for(const n of e)i[r++]=n.segment;return i}}return s=>[...s]})();ke.experimentalLetterSpacing=!1;ke._fonts={};ke._newlines=[10,13];ke._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];ke._measurementCache=Ya(1e3);let ds=ke;const $n=[{offset:0,color:"white"},{offset:1,color:"black"}],tn=class Gr{constructor(...t){this.uid=Ot("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=Iu(t);e={...e.type==="radial"?Gr.defaultRadialOptions:Gr.defaultLinearOptions,...$o(e)},this._textureSize=e.textureSize,this._wrapMode=e.wrapMode,e.type==="radial"?(this.center=e.center,this.outerCenter=e.outerCenter??this.center,this.innerRadius=e.innerRadius,this.outerRadius=e.outerRadius,this.scale=e.scale,this.rotation=e.rotation):(this.start=e.start,this.end=e.end),this.textureSpace
26=e.textureSpace,this.type=e.type,e.colorStops.forEach(r=>{this.addColorStop(r.offset,r.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:Ht.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:r}=this.end,n=i-t,o=r-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const p=t;t=i,i=p,n*=-1}if(o<0){const p=e;e=r,r=p,o*=-1}}const h=this.colorStops.length?this.colorStops:$n,l=this._textureSize,{canvas:c,context:u}=Zn(l,1),_=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);Kn(_,h),u.fillStyle=_,u.fillRect(0,0,l,1),this.texture=new _t({source:new Je({resource:c,addressMode:this._wrapMode})});const d=Math.sqrt(n*n+o*o),f=Math.atan2(o,n),g=new pt;g.scale(d/l,1),g.rotate(f),g.translate(t,e),this.textureSpace==="local"&&g.scale(l,l),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:$n,e=this._textureSize,{canvas:i,context:r}=Zn(e,e),{x:n,y:o}=this.center,{x:a,y:h}=this.outerCenter,l=this.innerRadius,c=this.outerRadius,u=a-c,_=h-c,d=e/(c*2),f=(n-u)*d,g=(o-_)*d,p=r.createRadialGradient(f,g,l*d,(a-u)*d,(h-_)*d,c*d);Kn(p,t),r.fillStyle=t[t.length-1].color,r.fillRect(0,0,e,e),r.fillStyle=p,r.translate(f,g),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-f,-g),r.fillRect(0,0,e,e),this.texture=new _t({source:new Je({resource:i,addressMode:this._wrapMode})});const y=new pt;y.scale(1/d,1/d),y.translate(u,_),this.textureSpace==="local"&&y.scale(e,e),this.transform=y}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};tn.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};tn.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Be=tn;function Kn(s,t){for(let e=0;e<t.length;e++){const i=t[e];s.addColorStop(i.offset,i.color)}}function Zn(s,t){const e=It.get().createCanvas(s,t),i=e.getContext("2d");return{canvas:e,context:i}}function Iu(s){let t=s[0]??{};return(typeof t=="number"||s[1])&&(ht("8.5.2","use options object instead"),t={type:"linear",start:{x:s[0],y:s[1]},end:{x:s[2],y:s[3]},textureSpace:s[4],textureSize:s[5]??Be.defaultLinearOptions.textureSize}),t}const Qn={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 Ms{constructor(t,e){this.uid=Ot("fillPattern"),this._tick=0,this.transform=new pt,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Qn[e].addressModeU,t.source.style.addressModeV=Qn[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}var hr,Jn;function Eu(){if(Jn)return hr;Jn=1,hr=e;var s={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function e(n){var o=[];return n.replace(t,function(a,h,l){var c=h.toLowerCase();for(l=r(l),c=="m"&&l.length>2&&(o.push([h].concat(l.splice(0,2))),c="l",h=h=="m"?"l":"L");;){if(l.length==s[c])return l.unshift(h),o.push(l);if(l.length<s[c])throw new Error("malformed path data");o.push([h].concat(l.splice(0,s[c])))}}),o}var i=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function r(n){var o=n.match(i);return o?o.map(Number):[]}return hr}
vendor: 8,669 bytes, line 26
26var Ru=Eu();const Fu=Uo(Ru);function Bu(s,t){const e=Fu(s),i=[];let r=null,n=0,o=0;for(let a=0;a<e.length;a++){const h=e[a],l=h[0],c=h;switch(l){case"M":n=c[1],o=c[2],t.moveTo(n,o);break;case"m":n+=c[1],o+=c[2],t.moveTo(n,o);break;case"H":n=c[1],t.lineTo(n,o);break;case"h":n+=c[1],t.lineTo(n,o);break;case"V":o=c[1],t.lineTo(n,o);break;case"v":o+=c[1],t.lineTo(n,o);break;case"L":n=c[1],o=c[2],t.lineTo(n,o);break;case"l":n+=c[1],o+=c[2],t.lineTo(n,o);break;case"C":n=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],n,o);break;case"c":t.bezierCurveTo(n+c[1],o+c[2],n+c[3],o+c[4],n+c[5],o+c[6]),n+=c[5],o+=c[6];break;case"S":n=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],n,o);break;case"s":t.bezierCurveToShort(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"Q":n=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],n,o);break;case"q":t.quadraticCurveTo(n+c[1],o+c[2],n+c[3],o+c[4]),n+=c[3],o+=c[4];break;case"T":n=c[1],o=c[2],t.quadraticCurveToShort(n,o);break;case"t":n+=c[1],o+=c[2],t.quadraticCurveToShort(n,o);break;case"A":n=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"a":n+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],n,o);break;case"Z":case"z":t.closePath(),i.length>0&&(r=i.pop(),r?(n=r.startX,o=r.startY):(n=0,o=0)),r=null;break;default:zt(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&r===null&&(r={startX:n,startY:o},i.push(r))}return t}class en{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new en(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}strokeContains(t,e,i,r=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,h=(1-r)*i,l=Math.sqrt(n*n+o*o);return l<=a+h&&l>a-(i-h)}getBounds(t){return t||(t=new Mt),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class sn{constructor(t=0,e=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=r}clone(){return new sn(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,e,i,r=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-r),h=i-a,l=n-h,c=o-h,u=n+a,_=o+a,d=t-this.x,f=e-this.y,g=d*d/(l*l)+f*f/(c*c),p=d*d/(u*u)+f*f/(_*_);return g>1&&p<=1}getBounds(t){return t||(t=new Mt),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Lu(s,t,e,i,r,n){const o=s-e,a=t-i,h=r-e,l=n-i,c=o*h+a*l,u=h*h+l*l;let _=-1;u!==0&&(_=c/u);let d,f;_<0?(d=e,f=i):_>1?(d=r,f=n):(d=e+_*h,f=i+_*l);const g=s-d,p=t-f;return g*g+p*p}let Ou,Gu;class Ei{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;r<n;r++)i.push(e[r].x,e[r].y);e=i}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let r=0;r<i;r+=2){const n=e[r],o=e[r+1],a=e[(r+2)%i],h=e[(r+3)%i];t+=(a-n)*(h+o)}return t<0}containsPolygon(t){const e=this.getBounds(Ou),i=t.getBounds(Gu);if(!e.containsRect(i))return!1;const r=t.points;for(let n=0;n<r.length;n+=2){const o=r[n],a=r[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new Ei(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const r=this.points.length/2;for(let n=0,o=r-1;n<r;o=n++){const a=this.points[n*2],h=this.points[n*2+1],l=this.points[o*2],c=this.points[o*2+1];h>e!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(i=!i)}return i}strokeContains(t,e,i,r=.5){const n=i*i,o=n*(1-r),a=n-o,{points:h}=this,l=h.length-(this.closePath?0:2);for(let c=0;c<l;c+=2){const u=h[c],_=h[c+1],d=h[(c+2)%h.length],f=h[(c+3)%h.length],g=Lu(t,e,u,_,d,f),p=Math.sign((d-u)*(e-_)-(f-_)*(t-u));if(g<=(p<0?a:o))return!0}return!1}getBounds(t){t||(t=new Mt);const e=this.points;let i=1/0,r=-1/0,n=1/0,o=-1/0;for(let a=0,h=e.length;a<h;a+=2){const l=e[a],c=e[a+1];i=l<i?l:i,r=l>r?l:r,n=c<n?c:n,o=c>o?c:o}return t.x=i,t.width=r-i,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return ht("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return ht("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const os=(s,t,e,i,r,n,o)=>{const a=s-e,h=t-i,l=Math.sqrt(a*a+h*h);return l>=r-n&&l<=r+o};class rn{constructor(t=0,e=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n}getBounds(t){return t||(t=new Mt),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new rn(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(r*r+n*n<=o||(r=t-(this.x+this.width-i),r*r+n*n<=o)||(n=e-(this.y+this.height-i),r*r+n*n<=o)||(r=t-(this.x+i),r*r+n*n<=o))return!0}return!1}strokeContains(t,e,i,r=.5){const{x:n,y:o,width:a,height:h,radius:l}=this,c=i*(1-r),u=i-c,_=n+l,d=o+l,f=a-l*2,g=h-l*2,p=n+a,y=o+h;return(t>=n-c&&t<=n+u||t>=p-u&&t<=p+c)&&e>=d&&e<=d+g||(e>=o-c&&e<=o+u||e>=y-u&&e<=y+c)&&t>=_&&t<=_+f?!0:t<_&&e<d&&os(t,e,_,d,l,u,c)||t>p-l&&e<d&&os(t,e,p-l,d,l,u,c)||t>p-l&&e>y-l&&os(t,e,p-l,y-l,l,u,c)||t<_&&e>y-l&&os(t,e,_,y-l,l,u,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const ja={};function Du(s,t,e){let i=2166136261;for(let r=0;r<t;r++)i^=s[r].uid,i=Math.imul(i,16777619),i>>>=0;return ja[i]||Uu(s,t,i,e)}function Uu(s,t,e,i){const r={};let n=0;for(let a=0;a<i;a++){const h=a<t?s[a]:_t.EMPTY.source;r[n++]=h.source,r[n++]=h.style}const o=new us(r);return ja[e]=o,o}class to{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,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(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}function eo(s,t){const e=s.byteLength/8|0,i=new Float64Array(s,0,e);new Float64Array(t,0,e).set(i);const n=s.byteLength-e*8;if(n>0){const o=new Uint8Array(s,e*8,n);
26new Uint8Array(t,e*8,n).set(o)}}const Nu={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Wu=(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",s[s.NONE=5]="NONE",s))(Wu||{});function io(s,t){return t.alphaMode==="no-premultiply-alpha"&&Nu[s]||s}const Hu=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` 27`);function Vu(s){let t="";for(let e=0;e<s;++e)e>0&&(t+=` 28else `),e<s-1&&(t+=`if(test == ${e}.0){}`);return t}function Xu(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const i=Hu.replace(/%forloop%/gi,Vu(s));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))s=s/2|0;else break}}finally{t.deleteShader(e)}return s}let ii=null;function Yu(){if(ii)return ii;const s=Sa();return ii=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),ii=Xu(ii,s),s.getExtension("WEBGL_lose_context")?.loseContext(),ii}class ju{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class qu{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new ju,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const Ri=[];let vs=0;Wi.register({clear:()=>{if(Ri.length>0)for(const s of Ri)s&&s.destroy();Ri.length=0,vs=0}});function so(){return vs>0?Ri[--vs]:new qu}function ro(s){Ri[vs++]=s}let ki=0;const qa=class $a{constructor(t){this.uid=Ot("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...$a.defaultOptions,...t},t.maxTextures||(ht("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Yu());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:r}=t;this.attributeBuffer=new to(i*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)ro(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!i&&i!==0?!1:(t._textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=so(),r=i.textures;r.clear();const n=e[this.elementStart];let o=io(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const h=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let u=this._batchIndexSize,_=this._batchIndexStart,d="startBatch";const f=this.maxTextures;for(let g=this.elementStart;g<this.elementSize;++g){const p=e[g];e[g]=null;const x=p.texture._source,v=io(p.blendMode,x),b=o!==v||a!==p.topology;if(x._batchTick===ki&&!b){p._textureId=x._textureBindLocation,u+=p.indexSize,p.packAsQuad?(this.packQuadAttributes(p,h,l,p._attributeStart,p._textureId),this.packQuadIndex(c,p._indexStart,p._attributeStart/this.vertexSize)):(this.packAttributes(p,h,l,p._attributeStart,p._textureId),this.packIndex(p,c,p._indexStart,p._attributeStart/this.vertexSize)),p._batch=i;continue}x._batchTick=ki,(r.count>=f||b)&&(this._finishBatch(i,_,u-_,r,o,a,t,d),d="renderBatch",_=u,o=v,a=p.topology,i=so(),r=i.textures,r.clear(),++ki),p._textureId=x._textureBindLocation=r.count,r.ids[x.uid]=r.count,r.textures[r.count++]=x,p._batch=i,u+=p.indexSize,p.packAsQuad?(this.packQuadAttributes(p,h,l,p._attributeStart,p._textureId),this.packQuadIndex(c,p._indexStart,p._attributeStart/this.vertexSize)):(this.packAttributes(p,h,l,p._attributeStart,p._textureId),this.packIndex(p,c,p._indexStart,p._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(i,_,u-_,r,o,a,t,d),_=u,++ki),this.elementStart=this.elementSize,this._batchIndexStart=_,this._batchIndexSize=u}_finishBatch(t,e,i,r,n,o,a,h){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=r,t.blendMode=n,t.topology=o,t.start=e,t.size=i,++ki,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new to(e);eo(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)r[n]=e[n];else eo(e.buffer,r.buffer);this.indexBuffer=r}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}packIndex(t,e,i,r){const n=t.indices,o=t.indexSize,a=t.indexOffset,h=t.attributeOffset;for(let l=0;l<o;l++)e[i++]=r+n[l+a]-h}destroy(t={}){if(this.batches!==null){for(let e=0;e<this.batchIndex;e++)ro(this.batches[e]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&(this.shader?.destroy(),this.shader=null);for(let e=0;e<this._elements.length;e++)this._elements[e]&&(this._elements[e]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};qa.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let $u=qa;var se=(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))(se||{});class Ui extends we{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=Ot("buffer"),this._resourceType="buffer",this._resourceId=Ot("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i??(i=e?.byteLength);const a=!!e;this.descriptor={size:i,usage:r,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&se.STATIC)}set static(t){t?this.descriptor.usage|=se.STATIC:this.descriptor.usage&=~se.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit
vendor: 10,903 bytes, lines 28-212
28("update",this);return}const r=this._data;if(this._data=t,this._dataInt32=null,!r||r.length!==t.length){!this.shrinkToFit&&r&&t.byteLength<r.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=Ot("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function Ka(s,t){if(!(s instanceof Ui)){let e=t?se.INDEX:se.VERTEX;s instanceof Array&&(t?(s=new Uint32Array(s),e=se.INDEX|se.COPY_DST):(s=new Float32Array(s),e=se.VERTEX|se.COPY_DST)),s=new Ui({data:s,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return s}function Ku(s,t,e){const i=s.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const r=i.buffer.data;let n=1/0,o=1/0,a=-1/0,h=-1/0;const l=r.BYTES_PER_ELEMENT,c=(i.offset||0)/l,u=(i.stride||8)/l;for(let _=c;_<r.length;_+=u){const d=r[_],f=r[_+1];d>a&&(a=d),f>h&&(h=f),d<n&&(n=d),f<o&&(o=f)}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=h,e}function Zu(s){return(s instanceof Ui||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=Ka(s.buffer,!1),s}class Qu extends we{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Ot("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new be,this._boundsDirty=!0;const{attributes:e,indexBuffer:i,topology:r}=t;if(this.buffers=[],this.attributes={},e)for(const n in e)this.addAttribute(n,e[n]);this.instanceCount=t.instanceCount??1,i&&this.addIndex(i),this.topology=r||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const i=Zu(e);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[t]=i}addIndex(t){this.indexBuffer=Ka(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Ku(this,"aPosition",this._bounds)):this._bounds}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null)}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(e=>e.destroy()),this.unload(),this.indexBuffer?.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Ju=new Float32Array(1),td=new Uint32Array(1);class ed extends Qu{constructor(){const e=new Ui({data:Ju,label:"attribute-batch-buffer",usage:se.VERTEX|se.COPY_DST,shrinkToFit:!1}),i=new Ui({data:td,label:"index-batch-buffer",usage:se.INDEX|se.COPY_DST,shrinkToFit:!1}),r=24;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0},aUV:{buffer:e,format:"float32x2",stride:r,offset:8},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:16},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:20}},indexBuffer:i})}}function no(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let o=s[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}else zt(`${i} placement hook does not exist in shader`)}}const id=/\{\{(.*?)\}\}/g;function oo(s){const t={};return(s.match(id)?.map(i=>i.replace(/[{()}]/g,""))??[]).forEach(i=>{t[i]=[]}),t}function ao(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function ho(s,t,e=!1){const i=[];ao(t,i),s.forEach(a=>{a.header&&ao(a.header,i)});const r=i;e&&r.sort();const n=r.map((a,h)=>` @location(${h}) ${a},`).join(` 29`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",` 30${n} 31`),o}function lo(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function sd(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function rd(s){const t=/@.*?\s+/g;return s.replace(t,"")}function nd(s,t){const e=[];lo(t,e),s.forEach(h=>{h.header&&lo(h.header,e)});let i=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`, 32`),n=e.sort().map(h=>` var ${rd(h)};`).join(` 33`),o=`return VSOutput( 34 ${e.sort().map(h=>` ${sd(h)}`).join(`, 35`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",` 36${r} 37`),a=a.replace("{{start}}",` 38${n} 39`),a=a.replace("{{return}}",` 40${o} 41`),a}function co(s,t){let e=s;for(const i in t){const r=t[i];r.join(` 42`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----// 43${r.join(` 44`)} 45//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const De=Object.create(null),lr=new Map;let od=0;function ad({template:s,bits:t}){const e=Za(s,t);if(De[e])return De[e];const{vertex:i,fragment:r}=ld(s,t);return De[e]=Qa(i,r,t),De[e]}function hd({template:s,bits:t}){const e=Za(s,t);return De[e]||(De[e]=Qa(s.vertex,s.fragment,t)),De[e]}function ld(s,t){const e=t.map(o=>o.vertex).filter(o=>!!o),i=t.map(o=>o.fragment).filter(o=>!!o);let r=ho(e,s.vertex,!0);r=nd(e,r);const n=ho(i,s.fragment,!0);return{vertex:r,fragment:n}}function Za(s,t){return t.map(e=>(lr.has(e)||lr.set(e,od++),lr.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function Qa(s,t,e){const i=oo(s),r=oo(t);return e.forEach(n=>{no(n.vertex,i,n.name),no(n.fragment,r,n.name)}),{vertex:co(s,i),fragment:co(t,r)}}const cd=` 46 @in aPosition: vec2<f32>; 47 @in aUV: vec2<f32>; 48 49 @out @builtin(position) vPosition: vec4<f32>; 50 @out vUV : vec2<f32>; 51 @out vColor : vec4<f32>; 52 53 {{header}} 54 55 struct VSOutput { 56 {{struct}} 57 }; 58 59 @vertex 60 fn main( {{in}} ) -> VSOutput { 61 62 var worldTransformMatrix = globalUniforms.uWorldTransformMatrix; 63 var modelMatrix = mat3x3<f32>( 64 1.0, 0.0, 0.0, 65 0.0, 1.0, 0.0, 66 0.0, 0.0, 1.0 67 ); 68 var position = aPosition; 69 var uv = aUV; 70 71 {{start}} 72 73 vColor = vec4<f32>(1., 1., 1., 1.); 74 75 {{main}} 76 77 vUV = uv; 78 79 var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix; 80 81 vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0); 82 83 vColor *= globalUniforms.uWorldColorAlpha; 84 85 {{end}} 86 87 {{return}} 88 }; 89`,ud=` 90 @in vUV : vec2<f32>; 91 @in vColor : vec4<f32>; 92 93 {{header}} 94 95 @fragment 96 fn main( 97 {{in}} 98 ) -> @location(0) vec4<f32> { 99 100 {{start}} 101 102 var outColor:vec4<f32>; 103 104 {{main}} 105 106 var finalColor:vec4<f32> = outColor * vColor; 107 108 {{end}} 109 110 return finalColor; 111 }; 112`,dd=` 113 in vec2 aPosition; 114 in vec2 aUV; 115 116 out vec4 vColor; 117 out vec2 vUV; 118 119 {{header}} 120 121 void main(void){ 122 123 mat3 worldTransformMatrix = uWorldTransformMatrix; 124 mat3 modelMatrix = mat3( 125 1.0, 0.0, 0.0, 126 0.0, 1.0, 0.0, 127 0.0, 0.0, 1.0 128 ); 129 vec2 position = aPosition; 130 vec2 uv = aUV; 131 132 {{start}} 133 134 vColor = vec4(1.); 135 136 {{main}} 137 138 vUV = uv; 139 140 mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix; 141 142 gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 143 144 vColor *= uWorldColorAlpha; 145 146 {{end}} 147 } 148`,_d=` 149 150 in vec4 vColor; 151 in vec2 vUV; 152 153 out vec4 finalColor; 154 155 {{header}} 156 157 void main(void) { 158 159 {{start}} 160 161 vec4 outColor; 162 163 {{main}} 164 165 finalColor = outColor * vColor; 166 167 {{end}} 168 } 169`,fd={name:"global-uniforms-bit",vertex:{header:` 170 struct GlobalUniforms { 171 uProjectionMatrix:mat3x3<f32>, 172 uWorldTransformMatrix:mat3x3<f32>, 173 uWorldColorAlpha: vec4<f32>, 174 uResolution: vec2<f32>, 175 } 176 177 @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms; 178 `}},pd={name:"global-uniforms-bit",vertex:{header:` 179 uniform mat3 uProjectionMatrix; 180 uniform mat3 uWorldTransformMatrix; 181 uniform vec4 uWorldColorAlpha; 182 uniform vec2 uResolution; 183 `}};function gd({bits:s,name:t}){const e=ad({template:{fragment:ud,vertex:cd},bits:[fd,...s]});return We.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function md({bits:s,name:t}){return new _i({name:t,...hd({template:{vertex:dd,fragment:_d},bits:[pd,...s]})})}const yd={name:"color-bit",vertex:{header:` 184 @in aColor: vec4<f32>; 185 `,main:` 186 vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a); 187 `}},xd={name:"color-bit",vertex:{header:` 188 in vec4 aColor; 189 `,main:` 190 vColor *= vec4(aColor.rgb * aColor.a, aColor.a); 191 `}},cr={};function bd(s){const t=[];if(s===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i<s;i++)t.push(`@group(1) @binding(${e++}) var textureSource${i+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(` 192`)}function vd(s){const t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<s;e++)e===s-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(` 193`)}function wd(s){return cr[s]||(cr[s]={name:"texture-batch-bit",vertex:{header:` 194 @in aTextureIdAndRound: vec2<u32>; 195 @out @interpolate(flat) vTextureId : u32; 196 `,main:` 197 vTextureId = aTextureIdAndRound.y; 198 `,end:` 199 if(aTextureIdAndRound.x == 1) 200 { 201 vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); 202 } 203 `},fragment:{header:` 204 @in @interpolate(flat) vTextureId: u32; 205 206 ${bd(s)} 207 `,main:` 208 var uvDx = dpdx(vUV); 209 var uvDy = dpdy(vUV); 210 211 ${vd(s)} 212 `}}),cr[s]}const ur={};function kd(s){const t=[];for(let e=0;e<s;e++)e>0&&t.push("else"),e<s-1&&t.push(`if(vTextureId < ${e}
212.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(` 213`)}function Ad(s){return ur[s]||(ur[s]={name:"texture-batch-bit",vertex:{header:` 214 in vec2 aTextureIdAndRound; 215 out float vTextureId; 216 217 `,main:` 218 vTextureId = aTextureIdAndRound.y; 219 `,end:` 220 if(aTextureIdAndRound.x == 1.) 221 { 222 gl_Position.xy = roundPixels(gl_Position.xy, uResolution); 223 } 224 `},fragment:{header:` 225 in float vTextureId; 226 227 uniform sampler2D uTextures[${s}]; 228 229 `,main:` 230 231 ${kd(s)} 232 `}}),ur[s]}const Sd={name:"round-pixels-bit",vertex:{header:` 233 fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32> 234 { 235 return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; 236 } 237 `}},Cd={name:"round-pixels-bit",vertex:{header:` 238 vec2 roundPixels(vec2 position, vec2 targetSize) 239 { 240 return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; 241 } 242 `}},uo={};function Md(s){let t=uo[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i<s;i++)e[i]=i;return t=uo[s]=new za({uTextures:{value:e,type:"i32",size:s}},{isStatic:!0}),t}class _o extends Cs{constructor(t){const e=md({name:"batch",bits:[xd,Ad(t),Cd]}),i=gd({name:"batch",bits:[yd,wd(t),Sd]});super({glProgram:e,gpuProgram:i,resources:{batchSamplers:Md(t)}}),this.maxTextures=t}}let Ai=null;const Ja=class th extends $u{constructor(t){super(t),this.geometry=new ed,this.name=th.extension.name,this.vertexSize=6,Ai??(Ai=new _o(t.maxTextures)),this.shader=Ai}packAttributes(t,e,i,r,n){const o=n<<16|t.roundPixels&65535,a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,_=a.tx,d=a.ty,{positions:f,uvs:g}=t,p=t.color,y=t.attributeOffset,x=y+t.attributeSize;for(let v=y;v<x;v++){const b=v*2,C=f[b],w=f[b+1];e[r++]=h*C+c*w+_,e[r++]=u*w+l*C+d,e[r++]=g[b],e[r++]=g[b+1],i[r++]=p,i[r++]=o}}packQuadAttributes(t,e,i,r,n){const o=t.texture,a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,_=a.tx,d=a.ty,f=t.bounds,g=f.maxX,p=f.minX,y=f.maxY,x=f.minY,v=o.uvs,b=t.color,C=n<<16|t.roundPixels&65535;e[r+0]=h*p+c*x+_,e[r+1]=u*x+l*p+d,e[r+2]=v.x0,e[r+3]=v.y0,i[r+4]=b,i[r+5]=C,e[r+6]=h*g+c*x+_,e[r+7]=u*x+l*g+d,e[r+8]=v.x1,e[r+9]=v.y1,i[r+10]=b,i[r+11]=C,e[r+12]=h*g+c*y+_,e[r+13]=u*y+l*g+d,e[r+14]=v.x2,e[r+15]=v.y2,i[r+16]=b,i[r+17]=C,e[r+18]=h*p+c*y+_,e[r+19]=u*y+l*p+d,e[r+20]=v.x3,e[r+21]=v.y3,i[r+22]=b,i[r+23]=C}_updateMaxTextures(t){this.shader.maxTextures!==t&&(Ai=new _o(t),this.shader=Ai)}destroy(){this.shader=null,super.destroy()}};Ja.extension={type:[$.Batcher],name:"default"};let Td=Ja;class Pd{constructor(t){this.items=Object.create(null);const{renderer:e,type:i,onUnload:r,priority:n,name:o}=t;this._renderer=e,e.gc.addResourceHash(this,"items",i,n??0),this._onUnload=r,this.name=o}add(t){return this.items[t.uid]?!1:(this.items[t.uid]=t,t.once("unload",this.remove,this),t._gcLastUsed=this._renderer.gc.now,!0)}remove(t,...e){if(!this.items[t.uid])return;const i=t._gpuData[this._renderer.uid];i&&(this._onUnload?.(t,...e),i.destroy(),t._gpuData[this._renderer.uid]=null,this.items[t.uid]=null)}removeAll(...t){Object.values(this.items).forEach(e=>e&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function zd(s,t,e,i,r,n,o,a=null){let h=0;e*=t,r*=n;const l=a.a,c=a.b,u=a.c,_=a.d,d=a.tx,f=a.ty;for(;h<o;){const g=s[e],p=s[e+1];i[r]=l*g+u*p+d,i[r+1]=c*g+_*p+f,r+=n,e+=t,h++}}function Id(s,t,e,i){let r=0;for(t*=e;r<i;)s[t]=0,s[t+1]=0,t+=e,r++}function eh(s,t,e,i,r){const n=t.a,o=t.b,a=t.c,h=t.d,l=t.tx,c=t.ty;e||(e=0),i||(i=2),r||(r=s.length/i-e);let u=e*i;for(let _=0;_<r;_++){const d=s[u],f=s[u+1];s[u]=n*d+a*f+l,s[u+1]=o*d+h*f+c,u+=i}}const Ed=new pt;class ih{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.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,i=this.renderable;return i?na(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||Ed}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const Ni={extension:{type:$.ShapeBuilder,name:"circle"},build(s,t){let e,i,r,n,o,a;if(s.type==="circle"){const b=s;if(o=a=b.radius,o<=0)return!1;e=b.x,i=b.y,r=n=0}else if(s.type==="ellipse"){const b=s;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;e=b.x,i=b.y,r=n=0}else{const b=s,C=b.width/2,w=b.height/2;e=b.x+C,i=b.y+w,o=a=Math.max(0,Math.min(b.radius,Math.min(C,w))),r=C-o,n=w-a}if(r<0||n<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(r?4:0)+(n?4:0);if(l===0)return!1;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n,!0;let c=0,u=h*4+(r?2:0)+2,_=u,d=l,f=r+o,g=n,p=e+f,y=e-f,x=i+g;if(t[c++]=p,t[c++]=x,t[--u]=x,t[--u]=y,n){const b=i-g;t[_++]=y,t[_++]=b,t[--d]=b,t[--d]=p}for(let b=1;b<h;b++){const C=Math.PI/2*(b/h),w=r+Math.cos(C)*o,k=n+Math.sin(C)*a,R=e+w,S=e-w,P=i+k,F=i-k;t[c++]=R,t[c++]=P,t[--u]=P,t[--u]=S,t[_++]=S,t[_++]=F,t[--d]=F,t[--d]=R}f=r,g=n+a,p=e+f,y=e-f,x=i+g;const v=i-g;return t[c++]=p,t[c++]=x,t[--d]=v,t[--d]=p,r&&(t[c++]=y,t[c++]=x,t[--d]=v,t[--d]=y),!0},triangulate(s,t,e,i,r,n){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 h=i;t[h*e]=o,t[h*e+1]=a;const l=h++;for(let c=0;c<s.length;c+=2)t[h*e]=s[c],t[h*e+1]=s[c+1],c>0&&(r[n++]=h,r[n++]=l,r[n++]=h-1),h++;r[n++]=l+1,r[n++]=l,r[n++]=h-1}},Rd={...Ni,extension:{...Ni.extension,name:"ellipse"}},Fd={...Ni,extension:{...Ni.extension,name:"roundedRectangle"}},sh=1e-4,fo=1e-4;function Bd(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,r=s[t-2],n=s[t-1];i<t;i+=2){const o=s[i],a=s[i+1];e+=(o-r)*(a+n),r=o,n=a}return e<0?-1:1}function po(s,t,e,i,r,n,o,a){const h=s-e*r,l=t-i*r,c=s+e*n,u=t+i*n;let _,d;o?(_=i,d=-e):(_=-i,d=e);const f=h+_,g=l+d,p=c+_,y=u+d;return a.push(f,g),a.push(p,y),2}function Ve(s,t,e,i,r,n,o,a){const h=e-s,l=i-t;
vendor: 4,659 bytes, line 242
242let c=Math.atan2(h,l),u=Math.atan2(r-s,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let _=c;const d=u-c,f=Math.abs(d),g=Math.sqrt(h*h+l*l),p=(15*f*Math.sqrt(g)/Math.PI>>0)+1,y=d/p;if(_+=y,a){o.push(s,t),o.push(e,i);for(let x=1,v=_;x<p;x++,v+=y)o.push(s,t),o.push(s+Math.sin(v)*g,t+Math.cos(v)*g);o.push(s,t),o.push(r,n)}else{o.push(e,i),o.push(s,t);for(let x=1,v=_;x<p;x++,v+=y)o.push(s+Math.sin(v)*g,t+Math.cos(v)*g),o.push(s,t);o.push(r,n),o.push(s,t)}return p*2}function Ld(s,t,e,i,r,n){const o=sh;if(s.length===0)return;const a=t;let h=a.alignment;if(t.alignment!==.5){let M=Bd(s);h=(h-.5)*M+.5}const l=new dt(s[0],s[1]),c=new dt(s[s.length-2],s[s.length-1]),u=i,_=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(u){s=s.slice(),_&&(s.pop(),s.pop(),c.set(s[s.length-2],s[s.length-1]));const M=(l.x+c.x)*.5,T=(c.y+l.y)*.5;s.unshift(M,T),s.push(M,T)}const d=r,f=s.length/2;let g=s.length;const p=d.length/2,y=a.width/2,x=y*y,v=a.miterLimit*a.miterLimit;let b=s[0],C=s[1],w=s[2],k=s[3],R=0,S=0,P=-(C-k),F=b-w,G=0,N=0,B=Math.sqrt(P*P+F*F);P/=B,F/=B,P*=y,F*=y;const V=h,L=(1-V)*2,D=V*2;u||(a.cap==="round"?g+=Ve(b-P*(L-D)*.5,C-F*(L-D)*.5,b-P*L,C-F*L,b+P*D,C+F*D,d,!0)+2:a.cap==="square"&&(g+=po(b,C,P,F,L,D,!0,d))),d.push(b-P*L,C-F*L),d.push(b+P*D,C+F*D);for(let M=1;M<f-1;++M){b=s[(M-1)*2],C=s[(M-1)*2+1],w=s[M*2],k=s[M*2+1],R=s[(M+1)*2],S=s[(M+1)*2+1],P=-(C-k),F=b-w,B=Math.sqrt(P*P+F*F),P/=B,F/=B,P*=y,F*=y,G=-(k-S),N=w-R,B=Math.sqrt(G*G+N*N),G/=B,N/=B,G*=y,N*=y;const T=w-b,st=C-k,U=w-R,rt=S-k,xt=T*U+st*rt,K=st*U-rt*T,mt=K<0;if(Math.abs(K)<.001*Math.abs(xt)){d.push(w-P*L,k-F*L),d.push(w+P*D,k+F*D),xt>=0&&(a.join==="round"?g+=Ve(w,k,w-P*L,k-F*L,w-G*L,k-N*L,d,!1)+4:g+=2,d.push(w-G*D,k-N*D),d.push(w+G*L,k+N*L));continue}const ot=(-P+b)*(-F+k)-(-P+w)*(-F+C),ut=(-G+R)*(-N+k)-(-G+w)*(-N+S),O=(T*ut-U*ot)/K,J=(rt*ot-st*ut)/K,Tt=(O-w)*(O-w)+(J-k)*(J-k),E=w+(O-w)*L,et=k+(J-k)*L,ct=w-(O-w)*D,at=k-(J-k)*D,ft=Math.min(T*T+st*st,U*U+rt*rt),Et=mt?L:D,Ut=ft+Et*Et*x;Tt<=Ut?a.join==="bevel"||Tt/x>v?(mt?(d.push(E,et),d.push(w+P*D,k+F*D),d.push(E,et),d.push(w+G*D,k+N*D)):(d.push(w-P*L,k-F*L),d.push(ct,at),d.push(w-G*L,k-N*L),d.push(ct,at)),g+=2):a.join==="round"?mt?(d.push(E,et),d.push(w+P*D,k+F*D),g+=Ve(w,k,w+P*D,k+F*D,w+G*D,k+N*D,d,!0)+4,d.push(E,et),d.push(w+G*D,k+N*D)):(d.push(w-P*L,k-F*L),d.push(ct,at),g+=Ve(w,k,w-P*L,k-F*L,w-G*L,k-N*L,d,!1)+4,d.push(w-G*L,k-N*L),d.push(ct,at)):(d.push(E,et),d.push(ct,at)):(d.push(w-P*L,k-F*L),d.push(w+P*D,k+F*D),a.join==="round"?mt?g+=Ve(w,k,w+P*D,k+F*D,w+G*D,k+N*D,d,!0)+2:g+=Ve(w,k,w-P*L,k-F*L,w-G*L,k-N*L,d,!1)+2:a.join==="miter"&&Tt/x<=v&&(mt?(d.push(ct,at),d.push(ct,at)):(d.push(E,et),d.push(E,et)),g+=2),d.push(w-G*L,k-N*L),d.push(w+G*D,k+N*D),g+=2)}b=s[(f-2)*2],C=s[(f-2)*2+1],w=s[(f-1)*2],k=s[(f-1)*2+1],P=-(C-k),F=b-w,B=Math.sqrt(P*P+F*F),P/=B,F/=B,P*=y,F*=y,d.push(w-P*L,k-F*L),d.push(w+P*D,k+F*D),u||(a.cap==="round"?g+=Ve(w-P*(L-D)*.5,k-F*(L-D)*.5,w-P*L,k-F*L,w+P*D,k+F*D,d,!1)+2:a.cap==="square"&&(g+=po(w,k,P,F,L,D,!1,d)));const gt=fo*fo;for(let M=p;M<g+p-2;++M)b=d[M*2],C=d[M*2+1],w=d[(M+1)*2],k=d[(M+1)*2+1],R=d[(M+2)*2],S=d[(M+2)*2+1],!(Math.abs(b*(k-S)+w*(S-C)+R*(C-k))<gt)&&n.push(M,M+1,M+2)}function Od(s,t,e,i){const r=sh;if(s.length===0)return;const n=s[0],o=s[1],a=s[s.length-2],h=s[s.length-1],l=t||Math.abs(n-a)<r&&Math.abs(o-h)<r,c=e,u=s.length/2,_=c.length/2;for(let d=0;d<u;d++)c.push(s[d*2]),c.push(s[d*2+1]);for(let d=0;d<u-1;d++)i.push(_+d,_+d+1);l&&i.push(_+u-1,_)}function rh(s,t,e,i,r,n,o){const a=wu(s,t,2);if(!a)return;for(let l=0;l<a.length;l+=3)n[o++]=a[l]+r,n[o++]=a[l+1]+r,n[o++]=a[l+2]+r;let h=r*i;for(let l=0;l<s.length;l+=2)e[h]=s[l],e[h+1]=s[l+1],h+=i}const Gd=[],Dd={extension:{type:$.ShapeBuilder,name:"polygon"},build(s,t){for(let e=0;e<s.points.length;e++)t[e]=s.points[e];return!0},triangulate(s,t,e,i,r,n){rh(s,Gd,t,e,i,r,n)}},Ud={extension:{type:$.ShapeBuilder,name:"rectangle"},build(s,t){const e=s,i=e.x,r=e.y,n=e.width,o=e.height;return n>0&&o>0?(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+o,t[6]=i,t[7]=r+o,!0):!1},triangulate(s,t,e,i,r,n){let o=0;i*=e,t[i+o]=s[0],t[i+o+1]=s[1],o+=e,t[i+o]=s[2],t[i+o+1]=s[3],o+=e,t[i+o]=s[6],t[i+o+1]=s[7],o+=e,t[i+o]=s[4],t[i+o+1]=s[5],o+=e;const a=i/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2,r[n++]=a+1,r[n++]=a+3,r[n++]=a+2}},Nd={extension:{type:$.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,!0},triangulate(s,t,e,i,r,n){let o=0;i*=e,t[i+o]=s[0],t[i+o+1]=s[1],o+=e,t[i+o]=s[2],t[i+o+1]=s[3],o+=e,t[i+o]=s[4],t[i+o+1]=s[5];const a=i/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2}},Wd=new pt,Hd=new Mt;function Vd(s,t,e,i){const r=t.matrix?s.copyFrom(t.matrix).invert():s.identity();
242if(t.textureSpace==="local"){const o=e.getBounds(Hd);t.width&&o.pad(t.width);const{x:a,y:h}=o,l=1/o.width,c=1/o.height,u=-a*l,_=-h*c,d=r.a,f=r.b,g=r.c,p=r.d;r.a*=l,r.b*=l,r.c*=c,r.d*=c,r.tx=u*d+_*g+r.tx,r.ty=u*f+_*p+r.ty}else r.translate(t.texture.frame.x,t.texture.frame.y),r.scale(1/t.texture.source.width,1/t.texture.source.height);const n=t.texture.source.style;return!(t.fill instanceof Be)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),i&&r.append(Wd.copyFrom(i).invert()),r}const Ts={};$t.handleByMap($.ShapeBuilder,Ts);$t.add(Ud,Dd,Nd,Ni,Rd,Fd);const Xd=new Mt,Yd=new pt;function jd(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r<s.instructions.length;r++){const n=s.instructions[r];if(n.action==="texture")qd(n.data,i,e);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,h=n.data.style,l=n.data.hole;o&&l&&go(l.shapePath,h,!0,i,e),l&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=l.shapePath.shapePrimitives),go(a,h,o,i,e)}}}function qd(s,t,e){const i=[],r=Ts.rectangle,n=Xd;n.x=s.dx,n.y=s.dy,n.width=s.dw,n.height=s.dh;const o=s.transform;if(!r.build(n,i))return;const{vertices:a,uvs:h,indices:l}=e,c=l.length,u=a.length/2;o&&eh(i,o),r.triangulate(i,a,2,u,l,c);const _=s.image,d=_.uvs;h.push(d.x0,d.y0,d.x1,d.y1,d.x3,d.y3,d.x2,d.y2);const f=ge.get(ih);f.indexOffset=c,f.indexSize=l.length-c,f.attributeOffset=u,f.attributeSize=a.length/2-u,f.baseColor=s.style,f.alpha=s.alpha,f.texture=_,f.geometryData=e,t.push(f)}function go(s,t,e,i,r){const{vertices:n,uvs:o,indices:a}=r;s.shapePrimitives.forEach(({shape:h,transform:l,holes:c})=>{const u=[],_=Ts[h.type];if(!_.build(h,u))return;const d=a.length,f=n.length/2;let g="triangle-list";if(l&&eh(u,l),e){const v=h.closePath??!0,b=t;b.pixelLine?(Od(u,v,n,a),g="line-list"):Ld(u,b,!1,v,n,a)}else if(c){const v=[],b=u.slice();$d(c).forEach(w=>{v.push(b.length/2),b.push(...w)}),rh(b,v,n,2,f,a,d)}else _.triangulate(u,n,2,f,a,d);const p=o.length/2,y=t.texture;if(y!==_t.WHITE){const v=Vd(Yd,t,h,l);zd(n,2,f,o,p,2,n.length/2-f,v)}else Id(o,p,2,n.length/2-f);const x=ge.get(ih);x.indexOffset=d,x.indexSize=a.length-d,x.attributeOffset=f,x.attributeSize=n.length/2-f,x.baseColor=t.color,x.alpha=t.alpha,x.texture=y,x.geometryData=r,x.topology=g,i.push(x)})}function $d(s){const t=[];for(let e=0;e<s.length;e++){const i=s[e].shape,r=[];Ts[i.type].build(i,r)&&t.push(r)}return t}class Kd{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{ge.return(t)}),this.graphicsData&&ge.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Zd{constructor(){this.instructions=new la}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Td({maxTextures:e}),this.instructions.reset()}get geometry(){return ht(Xl,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const nn=class Dr{constructor(t){this._renderer=t,this._managedContexts=new Pd({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Dr.defaultOptions.bezierSmoothness=t?.bezierSmoothness??Dr.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],i=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&i.reset(),jd(t,i);const r=t.batchMode;t.customShader||r==="no-batch"?i.isBatchable=!1:r==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=!0,t.dirty=!1}return i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=ge.get(Zd,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=t._gpuData[this._renderer.uid],{batches:r,geometryData:n}=i;i.graphicsData=e;const o=n.vertices.length,a=n.indices.length;for(let u=0;u<r.length;u++)r[u].applyTransform=!1;const h=e.batcher;h.ensureAttributeBuffer(o),h.ensureIndexBuffer(a),h.begin();for(let u=0;u<r.length;u++){const _=r[u];h.add(_)}h.finish(e.instructions);const l=h.geometry;l.indexBuffer.setDataWithSize(h.indexBuffer,h.indexSize,!0),l.buffers[0].setDataWithSize(h.attributeBuffer.float32View,h.attributeSize,!0);const c=h.batches;for(let u=0;u<c.length;u++){const _=c[u];_.bindGroup=Du(_.textures.textures,_.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new Kd;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};nn.extension={type:[$.WebGLSystem,$.WebGPUSystem,$.CanvasSystem],name:"graphicsContext"};nn.defaultOptions={bezierSmoothness:.5};let nh=nn;const Qd=8,as=11920929e-14,Jd=1;function oh(s,t,e,i,r,n,o,a,h,l){const u=Math.min(.99,Math.max(0,l??nh.defaultOptions.bezierSmoothness));let _=(Jd-u)/1;return _*=_,t_(t,e,i,r,n,o,a,h,s,_),s}function t_(s,t,e,i,r,n,o,a,h,l){Ur(s,t,e,i,r,n,o,a,h,l,0),h.push(o,a)}function Ur(s,t,e,i,r,n,o,a,h,l,c){if(c>Qd)return;const u=(s+e)/2,_=(t+i)/2,d=(e+r)/2,f=(i+n)/2,g=(r+o)/2,p=(n+a)/2,y=(u+d)/2,x=(_+f)/2,v=(d+g)/2,b=(f+p)/2,C=(y+v)/2,w=(x+b)/2;if(c>0){let k=o-s,R=a-t;const S=Math.abs((e-o)*R-(i-a)*k),P=Math.abs((r-o)*R-(n-a)*k);if(S>as&&P>as){if((S+P)*(S+P)<=l*(k*k+R*R)){h.push(C,w);return}}else if(S>as){if(S*S<=l*(k*k+R*R)){h.push(C,w);return}}else if(P>as){if(P*P<=l*(k*k+R*R)){h.push(C,w);return}}else if(k=C-(s+o)/2,R=w-(t+a)/2,k*k+R*R<=l){h.push(C,w);return}}Ur(s,t,u,_,y,x,C,w,h,l,c+1),Ur(C,w,v,b,g,p,o,a,h,l,c+1)}const e_=8,i_=11920929e-14,s_=1;function r_(s,t,e,i,r,n,o,a){const l=Math.min(.99,Math.max(0,a??nh.defaultOptions.bezierSmoothness));let c=(s_-l)/1;return c*=c,n_(t,e,i,r,n,o,s,c),s}function n_(s,t,e,i,r,n,o,a){Nr(o,s,t,e,i,r,n,a,0),o.push(r,n)}function Nr(s,t,e,i,r,n,o,a,h){if(h>e_)return;const l=(t+i)/2,c=(e+r)/2,u=(i+n)/2,_=(r+o)/2,d=(l+u)/2,f=(c+_)/2;let g=n-t,p=o-e;const y=Math.abs((i-n)*p-(r-o)*g);if(y>i_){if(y*y<=a*(g*g+p*p)){s.push(d,f);return}}else if(g=d-(t+n)/2,p=f-(e+o)/2,g*g+p*p<=a){s.push(d,f);return}Nr(s,t,e,l,c,d,f,a,h+1),Nr(s,d,f,u,_,n,o,a,h+1)}function ah(s,t,e,i,r,n,o,a){let h=Math.abs(r-n);(!o&&r>n||o&&n>r)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI)))),a=Math.max(a,3);let l=h/a,c=r;l*=o?-1:1;for(let u=0;u<a+1;u++){const _=Math.cos(c),d=Math.sin(c),f=t+_*i,g=e+d*i;s.push(f,g),c+=l}}function o_(s,t,e,i,r,n){const o=s[s.length-2],h=s[s.length-1]-e,l=o-t,c=r-e,u=i-t,_=Math.abs(h*u-l*c);if(_<1e-8||n===0){(s[s.length-2]!==t||s[s.length-1]!==e)&&s.push(t,e);return}const d=h*h+l*l,f=c*c+u*u,g=h*c+l*u,p=n*Math.sqrt(d)/_,y=n*Math.sqrt(f)/_,x=p*g/d,v=y*g/f,b=p*u+y*l,C=p*c+y*h,w=l*(y+x),k=h*(y+x),R=u*(p+v),S=c*(p+v),P=Math.atan2(k-C,w-b),F=Math.atan2(S-C,R-b);ah(s,b+t,C+e,n,P,F,l*c>u*h)}const Fi=Math.PI*2,dr={centerX:0,centerY:0,ang1:0,ang2:0},_r=({x:s,y:t},e,i,r,n,o,a,h)=>{s*=e,t*=i;const l=r*s-n*t,c=n*s+r*t;return h.x=l+o,h.y=c+a,h};function a_(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,r=Math.cos(s),n=Math.sin(s),o=Math.cos(s+t),a=Math.sin(s+t);return[{x:r-n*i,y:n+r*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const mo=(s,t,e,i)=>{const r=s*i-t*e<0?-1:1;let n=s*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},h_=(s,t,e,i,r,n,o,a,h,l,c,u,_)=>{const d=Math.pow(r,2),f=Math.pow(n,2),g=Math.pow(c,2),p=Math.pow(u,2);let y=d*f-d*p-f*g;y<0&&(y=0),y/=d*p+f*g,y=Math.sqrt(y)*(o===a?-1:1);const x=y*r/n*u,v=y*-n/r*c,b=l*x-h*v+(s+e)/2,C=h*x+l*v+(t+i)/2,w=(c-x)/r,k=(u-v)/n,R=(-c-x)/r,S=(-u-v)/n,P=mo(1,0,w,k);let F=mo(w,k,R,S);a===0&&F>0&&(F-=Fi),a===1&&F<0&&(F+=Fi),_.centerX=b,_.centerY=C,_.ang1=P,_.ang2=F};function l_(s,t,e,i,r,n,o,a=0,h=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*Fi/360),u=Math.cos(a*Fi/360),_=u*(t-i)/2+c*(e-r)/2,d=-c*(t-i)/2+u*(e-r)/2;if(_===0&&d===0)return;n=Math.abs(n),o=Math.abs(o);const f=Math.pow(_,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(o,2);f>1&&(n*=Math.sqrt(f),o*=Math.sqrt(f)),h_(t,e,i,r,n,o,h,l,c,u,_,d,dr);let{ang1:g,ang2:p}=dr;const{centerX:y,centerY:x}=dr;let v=Math.abs(p)/(Fi/4);Math.abs(1-v)<1e-7&&(v=1);const b=Math.max(Math.ceil(v),1);p/=b;let C=s[s.length-2],w=s[s.length-1];const k={x:0,y:0};for(let R=0;R<b;R++){const S=a_(g,p),{x:P,y:F}=_r(S[0],n,o,u,c,y,x,k),{x:G,y:N}=_r(S[1],n,o,u,c,y,x,k),{x:B,y:V}=_r(S[2],n,o,u,c,y,x,k);
vendor: 7,788 bytes, line 242
242oh(s,C,w,P,F,G,N,B,V),C=B,w=V,g+=p}}function c_(s,t,e){const i=(o,a)=>{const h=a.x-o.x,l=a.y-o.y,c=Math.sqrt(h*h+l*l),u=h/c,_=l/c;return{len:c,nx:u,ny:_}},r=(o,a)=>{o===0?s.moveTo(a.x,a.y):s.lineTo(a.x,a.y)};let n=t[t.length-1];for(let o=0;o<t.length;o++){const a=t[o%t.length],h=a.radius??e;if(h<=0){r(o,a),n=a;continue}const l=t[(o+1)%t.length],c=i(a,n),u=i(a,l);if(c.len<1e-4||u.len<1e-4){r(o,a),n=a;continue}let _=Math.asin(c.nx*u.ny-c.ny*u.nx),d=1,f=!1;c.nx*u.nx-c.ny*-u.ny<0?_<0?_=Math.PI+_:(_=Math.PI-_,d=-1,f=!0):_>0&&(d=-1,f=!0);const g=_/2;let p,y=Math.abs(Math.cos(g)*h/Math.sin(g));y>Math.min(c.len/2,u.len/2)?(y=Math.min(c.len/2,u.len/2),p=Math.abs(y*Math.sin(g)/Math.cos(g))):p=h;const x=a.x+u.nx*y+-u.ny*p*d,v=a.y+u.ny*y+u.nx*p*d,b=Math.atan2(c.ny,c.nx)+Math.PI/2*d,C=Math.atan2(u.ny,u.nx)-Math.PI/2*d;o===0&&s.moveTo(x+Math.cos(b)*p,v+Math.sin(b)*p),s.arc(x,v,p,b,C,f),n=a}}function u_(s,t,e,i){const r=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),n=(a,h,l)=>({x:a.x+(h.x-a.x)*l,y:a.y+(h.y-a.y)*l}),o=t.length;for(let a=0;a<o;a++){const h=t[(a+1)%o],l=h.radius??e;if(l<=0){a===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y);continue}const c=t[a],u=t[(a+2)%o],_=r(c,h);let d;if(_<1e-4)d=h;else{const p=Math.min(_/2,l);d=n(h,c,p/_)}const f=r(u,h);let g;if(f<1e-4)g=h;else{const p=Math.min(f/2,l);g=n(h,u,p/f)}a===0?s.moveTo(d.x,d.y):s.lineTo(d.x,d.y),s.quadraticCurveTo(h.x,h.y,g.x,g.y,i)}}const d_=new Mt;class __{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new be,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,r=i[i.length-2],n=i[i.length-1];return(r!==t||n!==e)&&i.push(t,e),this}arc(t,e,i,r,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return ah(a,t,e,i,r,n,o),this}arcTo(t,e,i,r,n){this._ensurePoly();const o=this._currentPoly.points;return o_(o,t,e,i,r,n),this}arcToSvg(t,e,i,r,n,o,a){const h=this._currentPoly.points;return l_(h,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,i,r,n),this}bezierCurveTo(t,e,i,r,n,o,a){this._ensurePoly();const h=this._currentPoly;return oh(this._currentPoly.points,h.lastX,h.lastY,t,e,i,r,n,o,a),this}quadraticCurveTo(t,e,i,r,n){this._ensurePoly();const o=this._currentPoly;return r_(this._currentPoly.points,o.lastX,o.lastY,t,e,i,r,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));const i=this.shapePrimitives,r=i.length;for(let n=0;n<t.instructions.length;n++){const o=t.instructions[n];this[o.action](...o.data)}if(t.checkForHoles&&i.length-r>1){let n=null;for(let o=r;o<i.length;o++){const a=i[o];if(a.shape.type==="polygon"){const h=a.shape,l=n?.shape;l&&l.containsPolygon(h)?(n.holes||(n.holes=[]),n.holes.push(a),i.copyWithin(o,o+1),i.length--,o--):n=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,r,n){return this.drawShape(new Mt(t,e,i,r),n),this}circle(t,e,i,r){return this.drawShape(new en(t,e,i),r),this}poly(t,e,i){const r=new Ei(t);return r.closePath=e,this.drawShape(r,i),this}regularPoly(t,e,i,r,n=0,o){r=Math.max(r|0,3);const a=-1*Math.PI/2+n,h=Math.PI*2/r,l=[];for(let c=0;c<r;c++){const u=a-c*h;l.push(t+i*Math.cos(u),e+i*Math.sin(u))}return this.poly(l,!0,o),this}roundPoly(t,e,i,r,n,o=0,a){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(t,e,i,r,o);const h=i*Math.sin(Math.PI/r)-.001;n=Math.min(n,h);const l=-1*Math.PI/2+o,c=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let _=0;_<r;_++){const d=_*c+l,f=t+i*Math.cos(d),g=e+i*Math.sin(d),p=d+Math.PI+u,y=d-Math.PI-u,x=f+n*Math.cos(p),v=g+n*Math.sin(p),b=f+n*Math.cos(y),C=g+n*Math.sin(y);_===0?this.moveTo(x,v):this.lineTo(x,v),this.quadraticCurveTo(f,g,b,C,a)}return this.closePath()}roundShape(t,e,i=!1,r){return t.length<3?this:(i?u_(this,t,e,r):c_(this,t,e),this.closePath())}filletRect(t,e,i,r,n){if(n===0)return this.rect(t,e,i,r);const o=Math.min(i,r)/2,a=Math.min(o,Math.max(-o,n)),h=t+i,l=e+r,c=a<0?-a:0,u=Math.abs(a);return this.moveTo(t,e+u).arcTo(t+c,e+c,t+u,e,u).lineTo(h-u,e).arcTo(h-c,e+c,h,e+u,u).lineTo(h,l-u).arcTo(h-c,l-c,t+i-u,l,u).lineTo(t+u,l).arcTo(t+c,l-c,t,l-u,u).closePath()}chamferRect(t,e,i,r,n,o){if(n<=0)return this.rect(t,e,i,r);const a=Math.min(n,Math.min(i,r)/2),h=t+i,l=e+r,c=[t+a,e,h-a,e,h,e+a,h,l-a,h-a,l,t+a,l,t,l-a,t,e+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(t,e,i,r,n){return this.drawShape(new sn(t,e,i,r),n),this}roundRect(t,e,i,r,n,o){return this.drawShape(new rn(t,e,i,r,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new Ei,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new Ei,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=i;i=n.a*i+n.c*r+n.tx,r=n.b*o+n.d*r+n.ty}this._currentPoly.points.push(i,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const r=e[i],n=r.shape.getBounds(d_);r.transform?t.addRect(n,r.transform):t.addRect(n)}return t}}class Re{constructor(t,e=!1){this.instructions=[],this.uid=Ot("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?Bu(t,this):this.instructions=t?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new __(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,i,r,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(dt.shared);let h=0,l=0;if(!o||o.action!=="bezierCurveTo")h=a.x,l=a.y;else{h=o.data[2],l=o.data[3];const c=a.x,u=a.y;h=c+(c-h),l=u+(u-l)}return this.instructions.push({action:"bezierCurveTo",data:[h,l,t,e,i,r,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,i){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint(dt.shared);let o=0,a=0;if(!r||r.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=r.data[0],a=r.data[1];const h=n.x,l=n.y;o=h+(h-o),a=l+(l-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,i]}),this._dirty=!0,this}rect(t,e,i,r,n){return this.instructions.push({action:"rect",data:[t,e,i,r,n]}),this._dirty=!0,this}circle(t,e,i,r){return this.instructions.push({action:"circle",data:[t,e,i,r]}),this._dirty=!0,this}
242roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,i,r,n,o,a){n||(n=r/2);const h=-1*Math.PI/2+o,l=i*2,c=Math.PI*2/l,u=[];for(let _=0;_<l;_++){const d=_%2?n:r,f=_*c+h;u.push(t+d*Math.cos(f),e+d*Math.sin(f))}return this.poly(u,!0,a),this}clone(t=!1){const e=new Re;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const r=this.instructions[i];e.instructions.push({action:r.action,data:r.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,r=t.c,n=t.d,o=t.tx,a=t.ty;let h=0,l=0,c=0,u=0,_=0,d=0,f=0,g=0;for(let p=0;p<this.instructions.length;p++){const y=this.instructions[p],x=y.data;switch(y.action){case"moveTo":case"lineTo":h=x[0],l=x[1],x[0]=e*h+r*l+o,x[1]=i*h+n*l+a;break;case"bezierCurveTo":c=x[0],u=x[1],_=x[2],d=x[3],h=x[4],l=x[5],x[0]=e*c+r*u+o,x[1]=i*c+n*u+a,x[2]=e*_+r*d+o,x[3]=i*_+n*d+a,x[4]=e*h+r*l+o,x[5]=i*h+n*l+a;break;case"quadraticCurveTo":c=x[0],u=x[1],h=x[2],l=x[3],x[0]=e*c+r*u+o,x[1]=i*c+n*u+a,x[2]=e*h+r*l+o,x[3]=i*h+n*l+a;break;case"arcToSvg":h=x[5],l=x[6],f=x[0],g=x[1],x[0]=e*f+r*g,x[1]=i*f+n*g,x[5]=e*h+r*l+o,x[6]=i*h+n*l+a;break;case"circle":x[4]=Si(x[3],t);break;case"rect":x[4]=Si(x[4],t);break;case"ellipse":x[8]=Si(x[8],t);break;case"roundRect":x[5]=Si(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=Si(x[2],t);break;default:zt("unknown transform action",y.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;i.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t);break}return t}}function Si(s,t){return s?s.prepend(t):t.clone()}function Lt(s,t,e){const i=s.getAttribute(t);return i?Number(i):e}function f_(s,t){const e=s.querySelectorAll("defs");for(let i=0;i<e.length;i++){const r=e[i];for(let n=0;n<r.children.length;n++){const o=r.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=p_(o);break;case"radialgradient":t.defs[o.id]=g_();break}}}}function p_(s){const t=Lt(s,"x1",0),e=Lt(s,"y1",0),i=Lt(s,"x2",1),r=Lt(s,"y2",0),n=s.getAttribute("gradientUnits")||"objectBoundingBox",o=new Be(t,e,i,r,n==="objectBoundingBox"?"local":"global");for(let a=0;a<s.children.length;a++){const h=s.children[a],l=Lt(h,"offset",0),c=Ht.shared.setValue(h.getAttribute("stop-color")).toNumber();o.addColorStop(l,c)}return o}function g_(s){return zt("[SVG Parser] Radial gradients are not yet supported"),new Be(0,0,1,0)}function yo(s){const t=s.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const xo={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function hh(s,t){const e=s.getAttribute("style"),i={},r={},n={strokeStyle:i,fillStyle:r,useFill:!1,useStroke:!1};for(const o in xo){const a=s.getAttribute(o);a&&bo(t,n,o,a.trim())}if(e){const o=e.split(";");for(let a=0;a<o.length;a++){const h=o[a].trim(),[l,c]=h.split(":");xo[l]&&bo(t,n,l,c.trim())}}
242return{strokeStyle:n.useStroke?i:null,fillStyle:n.useFill?r:null,useFill:n.useFill,useStroke:n.useStroke}}function bo(s,t,e,i){switch(e){case"stroke":if(i!=="none"){if(i.startsWith("url(")){const r=yo(i);t.strokeStyle.fill=s.defs[r]}else t.strokeStyle.color=Ht.shared.setValue(i).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(i);break;case"fill":if(i!=="none"){if(i.startsWith("url(")){const r=yo(i);t.fillStyle.fill=s.defs[r]}else t.fillStyle.color=Ht.shared.setValue(i).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(i);break;case"stroke-opacity":t.strokeStyle.alpha=Number(i);break;case"opacity":t.fillStyle.alpha=Number(i),t.strokeStyle.alpha=Number(i);break}}function m_(s){if(s.length<=2)return!0;const t=s.map(a=>a.area).sort((a,h)=>h-a),[e,i]=t,r=t[t.length-1],n=e/i,o=i/r;return!(n>3&&o<2)}function y_(s){return s.split(/(?=[Mm])/).filter(i=>i.trim().length>0)}function x_(s){const t=s.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],r=[];for(let c=0;c<e.length;c+=2)c+1<e.length&&(i.push(e[c]),r.push(e[c+1]));if(i.length===0||r.length===0)return 0;const n=Math.min(...i),o=Math.max(...i),a=Math.min(...r),h=Math.max(...r);return(o-n)*(h-a)}function vo(s,t){const e=new Re(s,!1);for(const i of e.instructions)t.instructions.push(i)}function b_(s,t){if(typeof s=="string"){const o=document.createElement("div");o.innerHTML=s.trim(),s=o.querySelector("svg")}const e={context:t,defs:{},path:new Re};f_(s,e);const i=s.children,{fillStyle:r,strokeStyle:n}=hh(s,e);for(let o=0;o<i.length;o++){const a=i[o];a.nodeName.toLowerCase()!=="defs"&&lh(a,e,r,n)}return t}function lh(s,t,e,i){const r=s.children,{fillStyle:n,strokeStyle:o}=hh(s,t);n&&e?e={...e,...n}:n&&(e=n),o&&i?i={...i,...o}:o&&(i=o);const a=!e&&!i;a&&(e={color:0});let h,l,c,u,_,d,f,g,p,y,x,v,b,C,w,k,R;switch(s.nodeName.toLowerCase()){case"path":{C=s.getAttribute("d");const S=s.getAttribute("fill-rule"),P=y_(C),F=S==="evenodd",G=P.length>1;if(F&&G){const B=P.map(L=>({path:L,area:x_(L)}));if(B.sort((L,D)=>D.area-L.area),P.length>3||!m_(B))for(let L=0;L<B.length;L++){const D=B[L],gt=L===0;t.context.beginPath();const M=new Re(void 0,!0);vo(D.path,M),t.context.path(M),gt?(e&&t.context.fill(e),i&&t.context.stroke(i)):t.context.cut()}else for(let L=0;L<B.length;L++){const D=B[L],gt=L%2===1;t.context.beginPath();const M=new Re(void 0,!0);vo(D.path,M),t.context.path(M),gt?t.context.cut():(e&&t.context.fill(e),i&&t.context.stroke(i))}}else{const B=S?S==="evenodd":!0;w=new Re(C,B),t.context.path(w),e&&t.context.fill(e),i&&t.context.stroke(i)}break}case"circle":f=Lt(s,"cx",0),g=Lt(s,"cy",0),p=Lt(s,"r",0),t.context.ellipse(f,g,p,p),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"rect":h=Lt(s,"x",0),l=Lt(s,"y",0),k=Lt(s,"width",0),R=Lt(s,"height",0),y=Lt(s,"rx",0),x=Lt(s,"ry",0),y||x?t.context.roundRect(h,l,k,R,y||x):t.context.rect(h,l,k,R),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"ellipse":f=Lt(s,"cx",0),g=Lt(s,"cy",0),y=Lt(s,"rx",0),x=Lt(s,"ry",0),t.context.beginPath(),t.context.ellipse(f,g,y,x),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"line":c=Lt(s,"x1",0),u=Lt(s,"y1",0),_=Lt(s,"x2",0),d=Lt(s,"y2",0),t.context.beginPath(),t.context.moveTo(c,u),t.context.lineTo(_,d),i&&t.context.stroke(i);break;case"polygon":b=s.getAttribute("points"),v=b.match(/-?\d+/g).map(S=>parseInt(S,10)),t.context.poly(v,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":b=s.getAttribute("points"),v=b.match(/-?\d+/g).map(S=>parseInt(S,10)),t.context.poly(v,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{zt(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}a&&(e=null);for(let S=0;S<r.length;S++)lh(r[S],t,e,i)}function v_(s){return Ht.isColorLike(s)}function wo(s){return s instanceof Ms}function ko(s){return s instanceof Be}function w_(s){return s instanceof _t}function k_(s,t,e){const i=Ht.shared.setValue(t??0);return s.color=i.toNumber(),s.alpha=i.alpha===1?e.alpha:i.alpha,s.texture=_t.WHITE,{...e,...s}}function A_(s,t,e){return s.texture=t,{...e,...s}}function Ao(s,t,e){return s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,{...e,...s}}function So(s,t,e){return t.buildGradient(),s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,s.textureSpace
vendor: 4,913 bytes, line 242
242=t.textureSpace,{...e,...s}}function S_(s,t){const e={...t,...s},i=Ht.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e}function Ke(s,t){if(s==null)return null;const e={},i=s;return v_(s)?k_(e,s,t):w_(s)?A_(e,s,t):wo(s)?Ao(e,s,t):ko(s)?So(e,s,t):i.fill&&wo(i.fill)?Ao(i,i.fill,t):i.fill&&ko(i.fill)?So(i,i.fill,t):S_(i,t)}function ws(s,t){const{width:e,alignment:i,miterLimit:r,cap:n,join:o,pixelLine:a,...h}=t,l=Ke(s,h);return l?{width:e,alignment:i,miterLimit:r,cap:n,join:o,pixelLine:a,...l}:null}const C_=new dt,Co=new pt,on=class Se extends we{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Ot("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Re,this._transform=new pt,this._fillStyle={...Se.defaultFillStyle},this._strokeStyle={...Se.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new be,this._boundsDirty=!0}clone(){const t=new Se;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=Ke(t,Se.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=ws(t,Se.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Ke(t,Se.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Ke(t,Se.defaultStrokeStyle),this}texture(t,e,i,r,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:r||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?Ht.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Re,this}fill(t,e){let i;const r=this.instructions[this.instructions.length-1];return this._tick===0&&r?.action==="stroke"?i=r.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(ht(wt,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=Ke(t,Se.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(dt.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i?.action==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=ws(t,Se.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,r,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,i,r,n,o),this}arcTo(t,e,i,r,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*r+o.tx,o.b*i+o.d*r+o.ty,n),this}arcToSvg(t,e,i,r,n,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,i,r,n,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(t,e,i,r,n,o,a){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*i+h.c*r+h.tx,h.b*i+h.d*r+h.ty,h.a*n+h.c*o+h.tx,h.b*n+h.d*o+h.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,e,i,r){return this._tick++,this._activePath.ellipse(t,e,i,r,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,r=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,o=i.b*t+i.d*e+i.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,i,r,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*r+o.tx,o.b*i+o.d*r+o.ty,n),this}rect(t,e,i,r){return this._tick++,this._activePath.rect(t,e,i,r,this._transform.clone()),this}
242roundRect(t,e,i,r,n){return this._tick++,this._activePath.roundRect(t,e,i,r,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,r,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,i,r,n,o),this}roundPoly(t,e,i,r,n,o){return this._tick++,this._activePath.roundPoly(t,e,i,r,n,o),this}roundShape(t,e,i,r){return this._tick++,this._activePath.roundShape(t,e,i,r),this}filletRect(t,e,i,r,n){return this._tick++,this._activePath.filletRect(t,e,i,r,n),this}chamferRect(t,e,i,r,n,o){return this._tick++,this._activePath.chamferRect(t,e,i,r,n,o),this}star(t,e,i,r,n=0,o=0){return this._tick++,this._activePath.star(t,e,i,r,n,o,this._transform.clone()),this}svg(t){return this._tick++,b_(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.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(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,r,n,o){return t instanceof pt?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,r,n,o),this)}transform(t,e,i,r,n,o){return t instanceof pt?(this._transform.append(t),this):(Co.set(t,e,i,r,n,o),this._transform.append(Co),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,!this.dirty&&(this.emit("update",this,16),this.dirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],r=i.action;if(r==="fill"){const n=i.data;t.addBounds(n.path.bounds)}else if(r==="texture"){const n=i.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(r==="stroke"){const n=i.data,o=n.style.alignment,a=n.style.width*(1-o),h=n.path.bounds;t.addFrame(h.minX-a,h.minY-a,h.maxX+a,h.maxY+a)}}return t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let i=!1;for(let r=0;r<e.length;r++){const n=e[r],o=n.data,a=o.path;if(!n.action||!a)continue;const h=o.style,l=a.shapePath.shapePrimitives;for(let c=0;c<l.length;c++){const u=l[c].shape;if(!h||!u)continue;const _=l[c].transform,d=_?_.applyInverse(t,C_):t;if(n.action==="fill")i=u.contains(d.x,d.y);else{const g=h;i=u.strokeContains(d.x,d.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(d.x,d.y)&&(i=!1)}if(i)return!0}}return i}unload(){this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null)}destroy(t=!1){if(this.destroyed)return;if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t?.texture){const i=typeof t=="boolean"?t:t?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(i)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():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}};on.defaultFillStyle={color:16777215,alpha:1,texture:_t.WHITE,matrix:null,fill:null,textureSpace:"local"};on.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:_t.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let _e=on;const an=class ri extends we{constructor(t={}){super(),this.uid=Ot("textStyle"),this._tick=0,M_(t);const e={...ri.defaultTextStyle,...t};for(const i in e){const r=i;this[r]=e[i]}this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...ri.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...ri.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({..._e.defaultFillStyle,...t},()=>{this._fill=Ke({...this._originalFill},_e.defaultFillStyle)})),this._fill=Ke(t===0?"black":t,_e.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({..._e.defaultStrokeStyle,...t},()=>{this._stroke=ws({...this._originalStroke},_e.defaultStrokeStyle)}
242)),this._stroke=ws(t,_e.defaultStrokeStyle),this.update())}update(){this._tick++,this.emit("update",this)}reset(){const t=ri.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return`${this.uid}-${this._tick}`}clone(){return new ri({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,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){if(this.removeAllListeners(),typeof t=="boolean"?t:t?.texture){const i=typeof t=="boolean"?t:t?.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(t,e){return new Proxy(t,{set:(i,r,n)=>(i[r]===n||(i[r]=n,e?.(r,n),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Ht.isColorLike(t)||t instanceof Be||t instanceof Ms)}};an.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};an.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 ks=an;function M_(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=ks.defaultDropShadow;s.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){ht(wt,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(Ht.isColorLike(e))i.color=e;else if(e instanceof Be||e instanceof Ms)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");s.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(ht(wt,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&zt("The number of fill colors must match the number of fill gradient stops.");const e=new Be({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=t.fillGradientStops.slice(),r=t.fill.map(n=>Ht.shared.setValue(n).toNumber());i.forEach((n,o)=>{e.addColorStop(n,r[o])}),s.fill={fill:e}}}class T_{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=It.get().createCanvas();i.width=t,i.height=e;const r=i.getContext("2d");return{canvas:i,context:r}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=ys(t),e=ys(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:r}=e,n=(i<<17)+(r<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,r),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Wr=new T_;Wi.register(Wr);const Mo=1e5;function To(s,t,e,i=0){if(s.texture===_t.WHITE&&!s.fill)return Ht.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof Ms){const r=s.fill,n=t.createPattern(r.texture.source.resource,"repeat"),o=r.transform.copyTo(pt.shared);return o.scale(r.texture.frame.width,r.texture.frame.height),n.setTransform(o),n}else if(s.fill instanceof Be){const r=s.fill,n=r.type==="linear",o=r.textureSpace
242==="local";let a=1,h=1;o&&e&&(a=e.width+i,h=e.height+i);let l,c=!1;if(n){const{start:u,end:_}=r;l=t.createLinearGradient(u.x*a,u.y*h,_.x*a,_.y*h),c=Math.abs(_.x-u.x)<Math.abs((_.y-u.y)*.1)}else{const{center:u,innerRadius:_,outerCenter:d,outerRadius:f}=r;l=t.createRadialGradient(u.x*a,u.y*h,_*a,d.x*a,d.y*h,f*a)}if(c&&o&&e){const u=e.lineHeight/h;for(let _=0;_<e.lines.length;_++){const d=(_*e.lineHeight+i/2)/h;r.colorStops.forEach(f=>{const g=d+f.offset*u;l.addColorStop(Math.floor(g*Mo)/Mo,Ht.shared.setValue(f.color).toHex())})}}else r.colorStops.forEach(u=>{l.addColorStop(u.offset,Ht.shared.setValue(u.color).toHex())});return l}}else{const r=t.createPattern(s.texture.source.resource,"repeat"),n=s.matrix.copyTo(pt.shared);return n.scale(s.texture.frame.width,s.texture.frame.height),r.setTransform(n),r}return zt("FillStyle not recognised",s),"red"}const ch=class uh extends Xa{constructor(t){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const e={...uh.defaultOptions,...t};this._textureSize=e.textureSize,this._mipmap=e.mipmap;const i=e.style.clone();e.overrideFill&&(i._fill.color=16777215,i._fill.alpha=1,i._fill.texture=_t.WHITE,i._fill.fill=null),this.applyFillAsTint=e.overrideFill;const r=i.fontSize;i.fontSize=this.baseMeasurementFontSize;const n=Or(i);e.overrideSize?i._stroke&&(i._stroke.width*=this.baseRenderedFontSize/r):i.fontSize=this.baseRenderedFontSize=r,this._style=i,this._skipKerning=e.skipKerning??!1,this.resolution=e.resolution??1,this._padding=e.padding??4,e.textureStyle&&(this._textureStyle=e.textureStyle instanceof xs?e.textureStyle:new xs(e.textureStyle)),this.fontMetrics=ds.measureFont(n),this.lineHeight=i.lineHeight||this.fontMetrics.fontSize||i.fontSize}ensureCharacters(t){const e=ds.graphemeSegmenter(t).filter(p=>!this._currentChars.includes(p)).filter((p,y,x)=>x.indexOf(p)===y);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:r,context:n}=i.canvasAndContext,o=i.texture.source;const a=this._style;let h=this._currentX,l=this._currentY,c=this._currentMaxCharHeight;const u=this.baseRenderedFontSize/this.baseMeasurementFontSize,_=this._padding*u;let d=!1;const f=r.width/this.resolution,g=r.height/this.resolution;for(let p=0;p<e.length;p++){const y=e[p],x=ds.measureText(y,a,r,!1);x.lineHeight=x.height;const v=x.width*u,b=Math.ceil((a.fontStyle==="italic"?2:1)*v),C=x.height*u,w=b+_*2,k=C+_*2;if(d=!1,y!==` 243`&&y!=="\r"&&y!==" "&&y!==" "&&(d=!0,c=Math.ceil(Math.max(k,c))),h+w>f&&(l+=c,c=k,h=0,l+c>g)){o.update();const S=this._nextPage();r=S.canvasAndContext.canvas,n=S.canvasAndContext.context,o=S.texture.source,h=0,l=0,c=0}const R=v/u-(a.dropShadow?.distance??0)-(a._stroke?.width??0);if(this.chars[y]={id:y.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:R,kerning:{}},d){this._drawGlyph(n,x,h+_,l+_,u,a);const S=o.width*u,P=o.height*u,F=new Mt(h/S*o.width,l/P*o.height,w/S*o.width,k/P*o.height);this.chars[y].texture=new _t({source:o,frame:F}),h+=Math.ceil(w)}}o.update(),this._currentX=h,this._currentY=l,this._currentMaxCharHeight=c,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return ht(wt,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let r=0;r<t.length;r++){const n=t[r];for(let o=0;o<this._currentChars.length;o++){const a=this._currentChars[o];let h=i[n];h||(h=i[n]=e.measureText(n).width);let l=i[a];l||(l=i[a]=e.measureText(a).width);let c=e.measureText(n+a).width,u=c-(h+l);u&&(this.chars[n].kerning[a]=u),c=e.measureText(n+a).width,u=c-(h+l),u&&(this.chars[a].kerning[n]=u)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=Wr.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),r=new _t({source:new Je({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(r.source.style=this._textureStyle);const n={canvasAndContext:e,texture:r};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=Or(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const r=e._stroke,n=r?.width??0;if(r&&(t.lineWidth=n,t.lineJoin=r.join,t.miterLimit=r.miterLimit,t.strokeStyle=To(r,t)),e._fill&&(t.fillStyle=To(e._fill,t)),e.dropShadow){const o=e.dropShadow,a=Ht.shared.setValue(o.color).toArray(),h=o.blur*i,l=o.distance*i;t.shadowColor=`rgba(${a[0]*255},${a[1]*255},${a[2]*255},${o.alpha})`,t.shadowBlur=h,t.shadowOffsetX=Math.cos(o.angle)*l,t.shadowOffsetY=Math.sin(o.angle)*l}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,r,n,o){const a=e.text,h=e.fontProperties,c=(o._stroke?.width??0)*n,u=i+c/2,_=r-c/2,d=h.descent*n,f=e.lineHeight*n;let g=!1;o.stroke&&c&&(g=!0,t.strokeText(a,u,_+f-d));const{shadowBlur:p,shadowOffsetX:y,shadowOffsetY:x}=t;o._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(a,u,_+f-d)),g&&(t.shadowBlur=p,t.shadowOffsetX=y,t.shadowOffsetY=x)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];Wr.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};ch.defaultOptions={textureSize:512,style:new ks,mipmap:!0};let Po=ch;function P_(s,t,e,i){const r={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};r.offsetY=e.baseLineOffset;let n=r.lines[0],o=null,a=!0;const h={width:0,start:0,index:0,positions:[],chars:[]},l=e.baseMeasurementFontSize/t.fontSize,c=t.letterSpacing*l,u=t.wordWrapWidth*l,_=t.lineHeight?t.lineHeight*l:e.lineHeight,d=t.wordWrap&&t.breakWords,f=y=>{const x=n.width;for(let v=0;v<h.index;v++){const b=y.positions[v];n.chars.push(y.chars[v]),n.charPositions.push(b+x)}n.width+=y.width,a=!1,h.width=0,h.index=0,h.chars.length=0},g=()=>{let y=n.chars.length-1;if(i){let x=n.chars[y];for(;x===" ";)n.width-=e.chars[x].xAdvance,x=n.chars[--y]}r.width=Math.max(r.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,r.lines.push(n),r.height+=_},p=y=>y-c>u;for(let y=0;y<s.length+1;y++){let x;const v=y===s.length;v||(x=s[y]);const b=e.chars[x]||e.chars[" "];if(/(?:\s)/.test(x)||x==="\r"||x===` 244`||v){if(!a&&t.wordWrap&&p(n.width+h.width)?(g(),f(h),v||n.charPositions.push(0)):(h.start=n.width,f(h),v||n.charPositions.push(0)),x==="\r"||x===` 245`)g();else if(!v){const R=b.xAdvance+(b.kerning[o]||0)+c;n.width+=R,n.spaceWidth=R,n.spacesIndex.push(n.charPositions.length),n.chars.push(x)}}
245else{const k=b.kerning[o]||0,R=b.xAdvance+k+c;d&&p(n.width+h.width+R)&&(f(h),g()),h.positions[h.index++]=h.width+k,h.chars.push(x),h.width+=R}o=x}return g(),t.align==="center"?z_(r):t.align==="right"?I_(r):t.align==="justify"&&E_(r),r}function z_(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width/2-e.width/2;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=i}}function I_(s){for(let t=0;t<s.lines.length;t++){const e=s.lines[t],i=s.width-e.width;for(let r=0;r<e.charPositions.length;r++)e.charPositions[r]+=i}}function E_(s){const t=s.width;for(let e=0;e<s.lines.length;e++){const i=s.lines[e];let r=0,n=i.spacesIndex[r++],o=0;const a=i.spacesIndex.length,l=(t-i.width)/a;for(let c=0;c<i.charPositions.length;c++)c===n&&(n=i.spacesIndex[r++],o+=l),i.charPositions[c]+=o}}function R_(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e<i;e++){const r=s[e];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);if(r[0].length===0||r[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=r[0].charCodeAt(0),o=r[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,h=o;a<=h;a++)t.push(String.fromCharCode(a))}else t.push(...Array.from(r))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}let hs=0;class F_{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,textureStyle:null},this.measureCache=Ya(1e3)}getFont(t,e){let i=`${e.fontFamily}-bitmap`,r=!0;if(e._fill.fill&&!e._stroke?(i+=e._fill.fill.styleKey,r=!1):(e._stroke||e.dropShadow)&&(i=`${e.styleKey}-bitmap`,r=!1),!Pt.has(i)){const o=Object.create(e);o.lineHeight=0;const a=new Po({style:o,overrideFill:r,overrideSize:!0,...this.defaultOptions});hs++,hs>50&&zt("BitmapText",`You have dynamically created ${hs} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),a.once("destroy",()=>{hs--,Pt.remove(i)}),Pt.set(i,a)}const n=Pt.get(i);return n.ensureCharacters?.(t),n}getLayout(t,e,i=!0){const r=this.getFont(t,e),n=`${t}-${e.styleKey}-${i}`;if(this.measureCache.has(n))return this.measureCache.get(n);const o=ds.graphemeSegmenter(t),a=P_(o,e,r,i);return this.measureCache.set(n,a),a}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},ht(wt,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e?.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof ks?r:new ks(r),o=e.dynamicFill??this._canUseTintForStyle(n),a=new Po({style:n,overrideFill:o,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1,textureStyle:e.textureStyle}),h=R_(e.chars);return a.ensureCharacters(h.join("")),Pt.set(`${i}-bitmap`,a),a.once("destroy",()=>Pt.remove(`${i}-bitmap`)),a}uninstall(t){const e=`${t}-bitmap`,i=Pt.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}}const zo=new F_;class dh extends Xa{constructor(t,e){super();const{textures:i,data:r}=t;Object.keys(r.pages).forEach(n=>{const o=r.pages[parseInt(n,10)],a=i[o.id];this.pages.push({texture:a})}),Object.keys(r.chars).forEach(n=>{const o=r.chars[n],{frame:a,source:h,rotate:l}=i[o.page],c=Ct.transformRectCoords(o,a,l,new Mt),u=new _t({frame:c,orig:new Mt(0,0,o.width,o.height),source:h,rotate:l});this.chars[n]={id:n.codePointAt(0),xOffset:o.xOffset,yOffset:o.yOffset,xAdvance:o.xAdvance,kerning:o.kerning??{},texture:u}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){zo.install(t)}static uninstall(t){zo.uninstall(t)}}const fr={test(s){return typeof s=="string"&&s.startsWith("info face=")},parse(s){const t=s.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const u in t){const _=t[u].match(/^[a-z]+/gm)[0],d=t[u].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),f={};for(const g in d){const p=d[g].split("="),y=p[0],x=p[1].replace(/"/gm,""),v=parseFloat(x),b=isNaN(v)?x:v;f[y]=b}e[_].push(f)}const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[r]=e.info,[n]=e.common,[o]=e.distanceField??[];o&&(i.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),i.fontSize=parseInt(r.size,10),i.fontFamily=r.face,i.lineHeight=parseInt(n.lineHeight,10);const a=e.page;for(let u=0;u<a.length;u++)i.pages.push({id:parseInt(a[u].id,10)||0,file:a[u].file});const h={};i.baseLineOffset=i.lineHeight-parseInt(n.base,10);const l=e.char;for(let u=0;u<l.length;u++){const _=l[u],d=parseInt(_.id,10);let f=_.letter??_.char??String.fromCharCode(d);f==="space"&&(f=" "),h[d]=f,i.chars[f]={id:d,page:parseInt(_.page,10)||0,x:parseInt(_.x,10),y:parseInt(_.y,10),width:parseInt(_.width,10),height:parseInt(_.height,10),xOffset:parseInt(_.xoffset,10),yOffset:parseInt(_.yoffset,10),xAdvance:parseInt(_.xadvance,10),kerning:{}}}const c=e.kerning||[];for(let u=0;u<c.length;u++){const _=parseInt(c[u].first,10),d=parseInt(c[u].second,10),f=parseInt(c[u].amount,10);i.chars[h[d]].kerning[h[_]]=f}return i}},Io={test(s){const t=s;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(s){const t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=s.getElementsByTagName("info")[0],i=s.getElementsByTagName("common")[0],r=s.getElementsByTagName("distanceField")[0];r&&(t.distanceField={type:r.getAttribute("fieldType"),range:parseInt(r.getAttribute("distanceRange"),10)});const n=s.getElementsByTagName("page"),o=s.getElementsByTagName("char"),a=s.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(i.getAttribute("lineHeight"),10);for(let l=0;l<n.length;l++)t.pages.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});const h={};
vendor: 5,847 bytes, line 245
245t.baseLineOffset=t.lineHeight-parseInt(i.getAttribute("base"),10);for(let l=0;l<o.length;l++){const c=o[l],u=parseInt(c.getAttribute("id"),10);let _=c.getAttribute("letter")??c.getAttribute("char")??String.fromCharCode(u);_==="space"&&(_=" "),h[u]=_,t.chars[_]={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 l=0;l<a.length;l++){const c=parseInt(a[l].getAttribute("first"),10),u=parseInt(a[l].getAttribute("second"),10),_=parseInt(a[l].getAttribute("amount"),10);t.chars[h[u]].kerning[h[c]]=_}return t}},Eo={test(s){return typeof s=="string"&&s.match(/<font(\s|>)/)?Io.test(It.get().parseXML(s)):!1},parse(s){return Io.parse(It.get().parseXML(s))}},B_=[".xml",".fnt"],L_={extension:{type:$.CacheParser,name:"cacheBitmapFont"},test:s=>s instanceof dh,getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},O_={extension:{type:$.LoadParser,priority:He.Normal},name:"loadBitmapFont",id:"bitmap-font",test(s){return B_.includes(le.extname(s).toLowerCase())},async testParse(s){return fr.test(s)||Eo.test(s)},async parse(s,t,e){const i=fr.test(s)?fr.parse(s):Eo.parse(s),{src:r}=t,{pages:n}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;u<n.length;++u){const _=n[u].file;let d=le.join(le.dirname(r),_);d=Mr(d,r),o.push({src:d,data:a})}const h=await e.load(o),l=o.map(u=>h[u.src]);return new dh({data:i,textures:l},r)},async load(s,t){return await(await It.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),s.destroy()}};class G_{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),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 t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const D_={extension:{type:$.CacheParser,name:"cacheTextureArray"},test:s=>Array.isArray(s)&&s.every(t=>t instanceof _t),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};async function _h(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const U_={extension:{type:$.DetectionParser,priority:1},test:async()=>_h("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},Ro=["png","jpg","jpeg"],N_={extension:{type:$.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Ro],remove:async s=>s.filter(t=>!Ro.includes(t))},W_="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ps(s){return W_?!1:document.createElement("video").canPlayType(s)!==""}const H_={extension:{type:$.DetectionParser,priority:0},test:async()=>Ps("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},V_={extension:{type:$.DetectionParser,priority:0},test:async()=>Ps("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},X_={extension:{type:$.DetectionParser,priority:0},test:async()=>Ps("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},Y_={extension:{type:$.DetectionParser,priority:0},test:async()=>_h("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")},fh=class _s{constructor(){this.loadOptions={..._s.defaultOptions},this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{let r=null,n=null;if((e.parser||e.loadParser)&&(n=this._parserHash[e.parser||e.loadParser],e.loadParser&&zt(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),n||zt(`[Assets] specified load parser "${e.parser||e.loadParser}" not found while loading ${t}`)),!n){for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];if(a.load&&a.test?.(t,e,this)){n=a;break}}if(!n)return zt(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}r=await n.load(t,e,this),i.parser=n;for(let o=0;o<this.parsers.length;o++){const a=this.parsers[o];a.parse&&a.parse&&await a.testParse?.(r,e,this)&&(r=await a.parse(r,e,this)||r,i.parser=a)}return r})(),i}
245async load(t,e){this._parsersValidated||this._validateParsers();const i=typeof e=="function"?{..._s.defaultOptions,...this.loadOptions,onProgress:e}:{..._s.defaultOptions,...this.loadOptions,...e||{}},{onProgress:r,onError:n,strategy:o,retryCount:a,retryDelay:h}=i;let l=0;const c={},u=bs(t),_=xe(t,g=>({alias:[g],src:g,data:{}})),d=_.reduce((g,p)=>g+(p.progressSize||1),0),f=_.map(async g=>{const p=le.toAbsolute(g.src);c[g.src]||(await this._loadAssetWithRetry(p,g,{onProgress:r,onError:n,strategy:o,retryCount:a,retryDelay:h},c),l+=g.progressSize||1,r&&r(l/d))});return await Promise.all(f),u?c[_[0].src]:c}async unload(t){const i=xe(t,r=>({alias:[r],src:r})).map(async r=>{const n=le.toAbsolute(r.src),o=this.promiseCache[n];if(o){const a=await o.promise;delete this.promiseCache[n],await o.parser?.unload?.(a,r,this)}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id?zt("[Assets] parser should have an id"):(t[e.name]||t[e.id])&&zt(`[Assets] parser id conflict "${e.id}"`),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,r){let n=0;const{onError:o,strategy:a,retryCount:h,retryDelay:l}=i,c=u=>new Promise(_=>setTimeout(_,u));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),r[e.src]=await this.promiseCache[t].promise;return}catch(u){delete this.promiseCache[t],delete r[e.src],n++;const _=a!=="retry"||n>h;if(a==="retry"&&!_){o&&o(u,e),await c(l);continue}if(a==="skip"){o&&o(u,e);return}o&&o(u,e);const d=new Error(`[Loader.load] Failed to load ${t}. 246${u}`);
vendor: 4,306 bytes, lines 246-250
246throw u instanceof Error&&u.stack&&(d.stack=u.stack),d}}};fh.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let j_=fh;function gi(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function mi(s,t){const e=s.split("?")[0],i=le.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const q_=".json",$_="application/json",K_={extension:{type:$.LoadParser,priority:He.Low},name:"loadJson",id:"json",test(s){return gi(s,$_)||mi(s,q_)},async load(s){return await(await It.get().fetch(s)).json()}},Z_=".txt",Q_="text/plain",J_={name:"loadTxt",id:"text",extension:{type:$.LoadParser,priority:He.Low,name:"loadTxt"},test(s){return gi(s,Q_)||mi(s,Z_)},async load(s){return await(await It.get().fetch(s)).text()}},tf=["normal","bold","100","200","300","400","500","600","700","800","900"],ef=[".ttf",".otf",".woff",".woff2"],sf=["font/ttf","font/otf","font/woff","font/woff2"],rf=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function nf(s){const t=le.extname(s),r=le.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1));let n=r.length>0;for(const a of r)if(!a.match(rf)){n=!1;break}let o=r.join(" ");return n||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}const of=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function af(s){return of.test(s)?s:encodeURI(s)}const hf={extension:{type:$.LoadParser,priority:He.Low},name:"loadWebFont",id:"web-font",test(s){return gi(s,sf)||mi(s,ef)},async load(s,t){const e=It.get().getFontFaceSet();if(e){const i=[],r=t.data?.family??nf(s),n=t.data?.weights?.filter(a=>tf.includes(a))??["normal"],o=t.data??{};for(let a=0;a<n.length;a++){const h=n[a],l=new FontFace(r,`url(${af(s)})`,{...o,weight:h});await l.load(),e.add(l),i.push(l)}return Pt.has(`${r}-and-url`)?Pt.get(`${r}-and-url`).entries.push({url:s,faces:i}):Pt.set(`${r}-and-url`,{entries:[{url:s,faces:i}]}),i.length===1?i[0]:i}return zt("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){const t=Array.isArray(s)?s:[s],e=t[0].family,i=Pt.get(`${e}-and-url`),r=i.entries.find(n=>n.faces.some(o=>t.indexOf(o)!==-1));r.faces=r.faces.filter(n=>t.indexOf(n)===-1),r.faces.length===0&&(i.entries=i.entries.filter(n=>n!==r)),t.forEach(n=>{It.get().getFontFaceSet().delete(n)}),i.entries.length===0&&Pt.remove(`${e}-and-url`)}};function hn(s,t=1){const e=pi.RETINA_PREFIX?.exec(s);return e?parseFloat(e[1]):t}function ln(s,t,e){s.label=e,s._sourceOrigin=e;const i=new _t({source:s,label:e}),r=()=>{delete t.promiseCache[e],Pt.has(e)&&Pt.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&(zt("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),i.once("destroy",()=>{s.destroyed||(zt("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const lf=".svg",cf="image/svg+xml",uf={extension:{type:$.LoadParser,priority:He.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return gi(s,cf)||mi(s,lf)},async load(s,t,e){return t.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?_f(s):df(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function df(s,t,e,i){const r=await It.get().fetch(s),n=It.get().createImage();n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await r.text())}`,n.crossOrigin=i,await n.decode();const o=t.data?.width??n.width,a=t.data?.height??n.height,h=t.data?.resolution||hn(s),l=Math.ceil(o*h),c=Math.ceil(a*h),u=It.get().createCanvas(l,c),_=u.getContext("2d");_.imageSmoothingEnabled=!0,_.imageSmoothingQuality="high",_.drawImage(n,0,0,o*h,a*h);const{parseAsGraphicsContext:d,...f}=t.data??{},g=new Je({resource:u,alphaMode:"premultiply-alpha-on-upload",resolution:h,...f});return ln(g,e,s)}async function _f(s){const e=await(await It.get().fetch(s)).text(),i=new _e;return i.svg(e),i}const ff=`(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 hi=null,Hr=class{constructor(){hi||(hi=URL.createObjectURL(new Blob([ff],{type:"application/javascript"}))),this.worker=new Worker(hi)}};Hr.revokeObjectURL=function(){hi&&(URL.revokeObjectURL(hi),hi=null)};const pf=`(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 li=null;class ph{constructor(){li||(li=URL.createObjectURL(new Blob([pf],{type:"application/javascript"}))),this.worker=new Worker(li)}}ph.revokeObjectURL=function(){li&&(URL.revokeObjectURL(li),li=null)};let Fo=0,pr;class gf{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(t=>{const{worker:e}=new Hr;e.addEventListener("message",i=>{e.terminate(),Hr.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){pr===void 0&&(pr=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<pr&&(this._createdWorkers++,t=new ph().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){this._resolveHash[t.uuid]&&(t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),delete this._resolveHash[t.uuid])}async _run(t,e){await this._initWorkers();const i=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[Fo]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Fo++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t?.(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}}const Bo=new gf,mf=[".jpeg",".jpg",".png",".webp",".avif"],yf=["image/jpeg","image/png","image/webp","image/avif"];async function xf(s,t){const e=await It.get().fetch(s);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${e.status} ${e.statusText}`);const i=await e.blob();return t?.data?.alphaMode==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const gh={name:"loadTextures",id:"texture",extension:{type:$.LoadParser,priority:He.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return gi(s,yf)||mi(s,mf)},async load(s,t,e){let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Bo.isImageBitmapSupported()?i=await Bo.loadImageBitmap(s,t):i=await xf(s,t):i=await new Promise((n,o)=>{i=It.get().createImage(),i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?n(i):(i.onload=()=>{n(i)},i.onerror=o)});const r=new Je({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:t.data?.resolution||hn(s),...t.data});return ln(r,e,s)},unload(s){s.destroy(!0)}},bf=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let gr,mr;function vf(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=kf(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function wf(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",r),s.load();function i(){n(),t()}function r(o){n(),e(o)}function n(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",r)}})}function kf(s,t=globalThis.location){if(s.startsWith("data:"))return"";t||(t=globalThis.location);const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function Af(){const s=[],t=[];for(const e of bf){const i=Ii.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;Ps(i)&&(s.push(e),t.includes(i)||t.push(i))}return{validVideoExtensions:s,validVideoMime:t}}const Sf={name:"loadVideo",id:"video",extension:{type:$.LoadParser,name:"loadVideo"},test(s){if(!gr||!mr){const{validVideoExtensions:i,validVideoMime:r}=Af();gr=i,mr=r}const t=gi(s,mr),e=mi(s,gr);return t||e},async load(s,t,e){const i={...Ii.defaultOptions,resolution:t.data?.resolution||hn(s),alph
296aMode:t.data?.alphaMode||await xa(),...t.data},r=document.createElement("video"),n={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(n).forEach(h=>{const l=n[h];l!==void 0&&r.setAttribute(h,l)}),i.muted===!0&&(r.muted=!0),vf(r,s,i.crossorigin);const o=document.createElement("source");let a;if(i.mime)a=i.mime;else if(s.startsWith("data:"))a=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const h=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();a=Ii.MIME_TYPES[h]||`video/${h}`}return o.src=s,a&&(o.type=a),new Promise(h=>{const l=async()=>{const c=new Ii({...i,resource:r});r.removeEventListener("canplay",l),t.data.preload&&await wf(r),h(ln(c,e,s))};i.preload&&!i.autoPlay&&r.load(),r.addEventListener("canplay",l),r.appendChild(o)})},unload(s){s.destroy(!0)}},mh={extension:{type:$.ResolveParser,name:"resolveTexture"},test:gh.test,parse:s=>({resolution:parseFloat(pi.RETINA_PREFIX.exec(s)?.[1]??"1"),format:s.split(".").pop(),src:s})},Cf={extension:{type:$.ResolveParser,priority:-2,name:"resolveJson"},test:s=>pi.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:mh.parse};class Mf{constructor(){this._detections=[],this._initialized=!1,this.resolver=new pi,this.loader=new j_,this.cache=Pt,this._backgroundLoader=new G_(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized){zt("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let n=t.manifest;typeof n=="string"&&(n=await this.load(n)),this.resolver.addManifest(n)}const e=t.texturePreference?.resolution??1,i=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...t.loadOptions})}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=bs(t),r=xe(t).map(a=>{if(typeof a!="string"){const h=this.resolver.getAlias(a);return h.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(r),o=await this._mapLoadToResolve(n,e);return i?o[r[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},o=Object.keys(r);let a=0;const h=[],l=()=>{e?.(h.reduce((u,_)=>u+_,0)/a)},c=o.map((u,_)=>{const d=r[u],f=Object.values(d),p=[...new Set(f.flat())].reduce((y,x)=>y+(x.progressSize||1),0);return h.push(0),a+=p,this._mapLoadToResolve(d,y=>{h[_]=y*p,l()}).then(y=>{n[u]=y})});return await Promise.all(c),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Pt.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Pt.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const r=await this.loader.load(i,e);this._backgroundLoader.active=!0;const n={};return i.forEach(o=>{const a=r[o.src],h=[o.src];o.alias&&h.push(...o.alias),h.forEach(l=>{n[l]=a}),Pt.set(h,a)}),n}async unload(t){this._initialized||await this.init();const e=xe(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=xe(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>
296{Pt.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Ze=new Mf;$t.handleByList($.LoadParser,Ze.loader.parsers).handleByList($.ResolveParser,Ze.resolver.parsers).handleByList($.CacheParser,Ze.cache.parsers).handleByList($.DetectionParser,Ze.detections);$t.add(D_,N_,U_,Y_,H_,V_,X_,K_,J_,hf,uf,gh,Sf,O_,L_,mh,Cf);const Lo={loader:$.LoadParser,resolver:$.ResolveParser,cache:$.CacheParser,detection:$.DetectionParser};$t.handle($.Asset,s=>{const t=s.ref;Object.entries(Lo).filter(([e])=>!!t[e]).forEach(([e,i])=>$t.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(Lo).filter(e=>!!t[e]).forEach(e=>$t.remove(t[e]))});class Dt extends ca{constructor(t){t instanceof _e&&(t={context:t});const{context:e,roundPixels:i,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this.context=e:(this.context=this._ownedContext=new _e,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i??!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||t?.context===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=t}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new Dt(this._context.clone()):(this._ownedContext=null,new Dt(this._context))}lineStyle(t,e,i){ht(wt,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(t,e){ht(wt,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t!==void 0&&(i.color=t),e!==void 0&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){ht(wt,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==_e.defaultStrokeStyle.width||t.color!==_e.defaultStrokeStyle.color||t.alpha!==_e.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return ht(wt,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return ht(wt,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return ht(wt,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return ht(wt,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return ht(wt,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return ht(wt,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class Jt extends _t{static create(t){const{dynamic:e,...i}=t;return new Jt({source:new me(i),dynamic:e??!1})}resize(t,e,i){return this.source.resize(t,e,i),this}}var Vr=(s=>(s.CLAMP="clamp-to-edge",s.REPEAT="repeat",s.MIRRORED_REPEAT="mirror-repeat",s))(Vr||{});new Proxy(Vr,{get(s,t){return ht(wt,`DRAW_MODES.${t} is deprecated, use '${Vr[t]}' instead`),s[t]}});var Xr=(s=>(s.NEAREST="nearest",s.LINEAR="linear",s))(Xr||{});const Oo=new Proxy(Xr,{get(s,t){return ht(wt,`DRAW_MODES.${t} is deprecated, use '${Xr[t]}' instead`),s[t]}});$t.add(Bl,Ll);function ls(s,t,e){return s<t?t:s>e?e:s}function fs(s,t,e){return new Promise(i=>{if(!t){i(null);return}const r=t.getLocalBounds(),n=e?new Mt(e.x,e.y,e.width,e.height):new Mt(0,0,r.width,r.height);s.extract.canvas({target:t,resolution:1,frame:n}).toBlob?.(a=>{a||i(null),i(a)})})}var Tf=nt('<div class="color-gradient svelte-qx84u5"><div class="marker svelte-qx84u5"></div></div> <div class="opacity-slider svelte-qx84u5"><div class="opacity-marker svelte-qx84u5"></div></div> <div class="hue-slider svelte-qx84u5"><div class="marker svelte-qx84u5"></div></div>',1);function Pf(s,t){ce(t,!1);let e=z(t,"color",12,"rgb(255, 255, 255)"),i=Z([0,0]),r=null,n=!1,o=[0,0],a=Z(0),h=Z(0),l=null,c=!1,u=!1;function _(U){l=U.currentTarget.getBoundingClientRect(),c=!0,d(U.clientX)}function d(U){if(!l)return;const rt=ls(U-l.left,0,l.width);W(h,rt);const xt=rt/l.width*360;W(a,xt),e(f({h:xt,s:o[0],v:o[1],a:1}))}function f(U){const rt=U.s,xt=U.v;let K=rt*xt;const mt=U.h/60;let ot=K*(1-Math.abs(mt%2-1));const ut=xt-K;K=K+ut,ot=ot+ut;const O=Math.floor(mt)%6,J=[K,ot,ut,ut,ot,K][O],Tt=[ot,K,K,ot,ut,ut][O],E=[ut,ut,ot,K,K,ot][O];return`rgba(${J*255}, ${Tt*255}, ${E*255}, ${U.a})`}function g(U,rt){if(!r)return;
296const xt=ls(U-r.left,0,r.width),K=ls(rt-r.top,0,r.height);W(i,[xt,K]);const mt={h:m(a)*1,s:xt/r.width,v:1-K/r.height,a:1};o=[mt.s,mt.v],e(f(mt))}function p(U){n=!0,r=U.currentTarget.getBoundingClientRect(),g(U.clientX,U.clientY)}function y(U){n&&g(U.clientX,U.clientY),c&&d(U.clientX),u&&P(U.clientX)}function x(){n&&(n=!1),c&&(c=!1),u&&(u=!1)}async function v(U){if(n||c||(await xr(),!U))return;r||(r=m(b).getBoundingClientRect()),l||(l=m(C).getBoundingClientRect());const rt=he(U).toHsv(),xt=rt.s*r.width,K=(1-rt.v)*r.height;W(i,[xt,K]),o=[rt.s,rt.v],W(a,rt.h),W(h,rt.h/360*l.width)}let b=Z(),C=Z(),w=z(t,"opacity",12,1),k=Z();function R(U){W(S,U.currentTarget.getBoundingClientRect()),u=!0,P(U.clientX)}let S=Z(null);function P(U){if(!m(S))return;const rt=ls(U-m(S).left,0,m(S).width);w(rt/m(S).width)}Wo(()=>{W(S,m(k).getBoundingClientRect())}),yt(()=>Y(e()),()=>{v(e())}),Le();var F={get color(){return e()},set color(U){e(U),I()},get opacity(){return w()},set opacity(U){w(U),I()}};ve();var G=Tf();jt("mousemove",xn,y),jt("mouseup",xn,x);var N=qt(G),B=it(N);let V;tt(N),Qe(N,U=>W(b,U),()=>m(b));var L=q(N,2),D=it(L);let gt;tt(L),Qe(L,U=>W(k,U),()=>m(k));var M=q(L,2),T=it(M);let st;return tt(M),Qe(M,U=>W(C,U),()=>m(C)),Wt(()=>{Ie(N,`--hue:${m(a)??""}`),V=Ie(B,"",V,{transform:`translate(${m(i),Rt(()=>m(i)[0])??""}px,${m(i),Rt(()=>m(i)[1])??""}px)`,background:e()}),Ie(L,`--color:${(e()==="auto"?"transparent":e())??""}`),gt=Ie(D,"",gt,{background:"white",transform:`translateX(${Y(w()),m(S),Rt(()=>w()*(m(S)?.width??1))??""}px)`}),st=Ie(T,"",st,{background:"hsl("+m(a)+", 100%, 50%)",transform:`translateX(${m(h)??""}px)`})}),jt("mousedown",N,p),jt("mousedown",L,R),jt("mousedown",M,_),H(s,G),ue(F)}var zf=nt("<span></span>"),If=nt("<button></button>"),Ef=nt('<div class="swatch svelte-q8yof7"><!> <!> <button></button></div>'),Rf=nt("<button></button>"),Ff=nt('<!> <div class="swatch-wrap svelte-q8yof7"><div class="swatch-container svelte-q8yof7"><!> <menu class="swatch svelte-q8yof7"></menu></div></div>',1);function Bf(s,t){ce(t,!1);const e=Z(),i=Z();let r=z(t,"selected_color",12),n=z(t,"colors",12),o=z(t,"user_colors",28,()=>[]),a=z(t,"show_empty",12,!1),h=z(t,"current_mode",12,"hex"),l=z(t,"color_picker",12,!1);const c=Oe();function u(S){return Array.isArray(S)?S[0]:S}function _(S){return Array.isArray(S)?S[1]:he(S).getAlpha()}function d(S,P){const F=u(S);return P==="hex"?he(F).toHexString():P==="rgb"?he(F).toRgbString():he(F).toHslString()}`${n().findIndex(S=>d(S,h())===d(r(),h()))}`;function f(S,P){`${S}${P.index}`,c(S,P)}function g(){c("select",{index:null,color:r()}),l(!l())}yt(()=>
296(Y(a()),Y(n())),()=>{W(e,a()?n():n().filter(S=>S))}),yt(()=>Y(r()),()=>{W(i,_(r()))}),Le();var p={get selected_color(){return r()},set selected_color(S){r(S),I()},get colors(){return n()},set colors(S){n(S),I()},get user_colors(){return o()},set user_colors(S){o(S),I()},get show_empty(){return a()},set show_empty(S){a(S),I()},get current_mode(){return h()},set current_mode(S){h(S),I()},get color_picker(){return l()},set color_picker(S){l(S),I()}};ve();var y=Ff(),x=qt(y);{var v=S=>{var P=zf();let F;Wt(()=>F=re(P,1,"svelte-q8yof7",null,F,{lg:o()})),H(S,P)};Q(x,S=>{l()||S(v)})}var b=q(x,2),C=it(b),w=it(C);{var k=S=>{var P=Ef(),F=it(P);{var G=L=>{{let D=Gt(()=>(Y(r()),Rt(()=>u(r()))));ae(L,{get Icon(){return Xo},onclick:()=>c("add_color"),roundedness:"very",get background(){return m(D)},color:"white"})}};Q(F,L=>{l()&&L(G)})}var N=q(F,2);Bi(N,1,o,Li,(L,D,gt)=>{const M=Gt(()=>(m(D),Rt(()=>u(m(D))))),T=Gt(()=>(m(D),Rt(()=>_(m(D)))));var st=If();let U,rt;Wt(()=>{U=re(st,1,"color svelte-q8yof7",null,U,{empty:m(D)===null,selected:`${m(M)}-${m(T)}`==`${r()}-${m(i)}`}),rt=Ie(st,`background-color: ${m(M)??""}`,rt,{opacity:m(T)})}),jt("click",st,()=>f("edit",{index:gt,color:m(M),opacity:m(T)})),H(L,st)});var B=q(N,2);let V;tt(P),Wt(()=>V=re(B,1,"color colorpicker svelte-q8yof7",null,V,{hidden:!l()})),jt("click",B,g),H(S,P)};Q(w,S=>{o()&&S(k)})}var R=q(w,2);return Bi(R,5,()=>m(e),Li,(S,P,F)=>{const G=Gt(()=>(m(P),Rt(()=>u(m(P))))),N=Gt(()=>(m(P),Rt(()=>_(m(P)))));var B=Rf();let V,L;Wt(()=>{V=re(B,1,"color svelte-q8yof7",null,V,{empty:m(P)===null,selected:`${m(G)}-${m(N)}`==`${r()}-${m(i)}`}),L=Ie(B,`background-color: ${m(G)??""}`,L,{opacity:m(N)})}),jt("click",B,()=>f("select",{index:F,color:m(G),opacity:m(N)})),H(S,B)}),tt(R),tt(C),tt(b),H(s,y),ue(p)}var Lf=nt("<button> </button>"),Of=nt('<div class="input svelte-yn52fn"><button class="swatch svelte-yn52fn"></button> <div><div class="input-wrap svelte-yn52fn"><input type="text" class="svelte-yn52fn"/> <button class="eyedropper svelte-yn52fn"><!></button></div> <div class="buttons svelte-yn52fn"></div></div></div>');function Gf(s,t){ce(t,!1);const e=Z();let i=z(t,"color",12),r=z(t,"current_mode",12,"hex");const n=Oe(),o=[["Hex","hex"],["RGB","rgb"],["HSL","hsl"]];function a(w,k){return k==="hex"?he(w).toHexString():k==="rgb"?he(w).toRgbString():he(w).toHslString()}function h(){new EyeDropper().open().then(k=>{i(k.sRGBHex)})}const l=!!window.EyeDropper;function c(){n("selected",m(e)),n("close")}yt(()=>(Y(i()),Y(r())),()=>
296{W(e,a(i(),r()))}),yt(()=>m(e),()=>{m(e)&&n("selected",m(e))}),Le();var u={get color(){return i()},set color(w){i(w),I()},get current_mode(){return r()},set current_mode(w){r(w),I()}};ve();var _=Of(),d=it(_);let f;var g=q(d,2),p=it(g),y=it(p);No(y);var x=q(y,2),v=it(x);{var b=w=>{qh(w)};Q(v,w=>{l&&w(b)})}tt(x),tt(p);var C=q(p,2);return Bi(C,5,()=>o,Li,(w,k)=>{var R=de(()=>Ho(m(k),2));let S=()=>m(R)[0],P=()=>m(R)[1];var F=Lf();let G;var N=it(F,!0);tt(F),Wt(()=>{G=re(F,1,"button svelte-yn52fn",null,G,{active:r()===P()}),Fe(N,S())}),jt("click",F,()=>r(P())),H(w,F)}),tt(C),tt(g),tt(_),Wt(()=>{f=Ie(d,"",f,{background:i()}),Fh(y,m(e))}),jt("click",d,c),jt("change",y,w=>i(w.currentTarget.value)),jt("click",x,h),H(s,_),ue(u)}var Df=nt('<div class="wrap svelte-1y25b79"><span class="svelte-1y25b79"><!></span> <input type="range" class="svelte-1y25b79"/></div>');function Uf(s,t){ce(t,!1);let e=z(t,"selected_size",12),i=z(t,"min",12),r=z(t,"max",12);const n=Oe();var o={get selected_size(){return e()},set selected_size(u){e(u),I()},get min(){return i()},set min(u){i(u),I()},get max(){return r()},set max(u){r(u),I()}};ve();var a=Df(),h=it(a),l=it(h);hl(l),tt(h);var c=q(h,2);return No(c),Ue(c,"step",1),tt(a),As(a,(u,_)=>Kr?.(u,_),()=>()=>n("click_outside")),Wt(()=>{Ue(c,"min",i()),Ue(c,"max",r())}),$h(c,e),H(s,a),ue(o)}var Nf=nt("<!> <!>",1),Wf=nt("<div><!> <!> <!></div>");function Go(s,t){ce(t,!1);let e=z(t,"colors",12),i=z(t,"selected_color",12),r=z(t,"color_mode",12,void 0),n=z(t,"recent_colors",28,()=>[]),o=z(t,"selected_size",12),a=z(t,"selected_opacity",12),h=z(t,"show_swatch",12),l=z(t,"show_size",12),c=z(t,"mode",12,"brush"),u=Z(!1),_=Z("hex"),d=null;const f=Oe();function g({index:M,color:T,opacity:st},U){U==="user"&&!T&&(d=M,W(u,!0)),T&&(i(T),st!==void 0&&a(st),U==="core"&&W(u,!1))}function p(M){d!==null&&n(n()[d]=M,!0)}let y=Z(0),x=Z(0);function v(M,T){let st;return function(...U){clearTimeout(st),st=setTimeout(()=>M(...U),T)}}let b=z(t,"preview",12,!1);function C(){b()||b(!0),k()}function w(){b(!1)}const k=v(w,1e3);function R(M){i(M)}function S(){n().length>=5&&n().pop(),!n().some(M=>Array.isArray(M)?M[0]===i()&&M[1]===a():M===i())&&(n().push([i(),a()]),n(n()))}yt(()=>Y(i()),()=>{p(i())}),yt(()=>(Y(o()),Y(i())),()=>{o(),i(),C()}),Le();var P={get colors(){return e()},set colors(M){e(M),I()},get selected_color(){return i()},set selected_color(M){i(M),I()},get color_mode(){return r()},set color_mode(M){r(M),I()},get recent_colors(){return n()},set recent_colors(M){n(M),I()},get selected_size(){return o()},set selected_size(M){o(M),I()},get selected_opacity(){return a()},set selected_opacity(M){a(M),I()},get show_swatch(){return h()},set show_swatch(M){h(M),I()},get show_size(){return l()},set show_size(M){l(M),I()},get mode(){return c()},set mode(M){c(M),I()},get preview(){return b()},set preview(M){b(M),I()}};ve();var F=Wf();let G;var N=it(F);{var B=M=>{var T=ci(),st=qt(T);{var U=rt=>{var xt=Nf(),K=qt(xt);Pf(K,{get color(){return i()},set color(ot){i(ot)},get opacity(){return a()},set opacity(ot){a(ot)},$$legacy:!0});var mt=q(K,2);Gf(mt,{get color(){return i()},get current_mode(){return m(_)},set current_mode(ot){W(_,ot)},$$events:{close:()=>W(u,!1),selected:({detail:ot})=>R(ot)},$$legacy:!0}),H(rt,xt)};Q(st,rt=>{m(u)&&rt(U)})}H(M,T)};Q(N,M=>{r()==="defaults"&&M(B)})}var V=q(N,2);{var L=M=>{{let T=Gt(()=>r()==="defaults"?n():null);Bf(M,{get colors(){return e()},get user_colors(){return m(T)},get selected_color(){return i()},get current_mode(){return m(_)},get color_picker(){return m(u)},set color_picker(st){W(u,st)},$$events:{select:({detail:st})=>g(st,"core"),edit:({detail:st})=>g(st,"user"),add_color:S},$$legacy:!0})}};Q(V,M=>{h()&&M(L)})}var D=q(V,2);{var gt=M=>{Uf(M,{max:100,min:1,get selected_size(){return o()},set selected_size(T){o(T)},$$legacy:!0})};Q(D,M=>{l()&&M(gt)})}return tt(F),As(F,(M,T)=>Kr?.(M,T),()=>()=>f("click_outside")),Wt(()=>G=re(F,1,"wrap svelte-1l3f0ck",null,G,{padded:!m(u),color_picker:m(u),size_picker:l()&&c()==="brush",eraser_picker:c()==="eraser"})),kn("innerHeight",M=>W(x,M)),kn("innerWidth",M=>W(y,M)),H(s,F),ue(P)}var Hf=nt("<!> <!>",1),Vf=nt("<!> <!> <!>",1),Xf=nt("<!> <!> <!>",1),Yf=nt('<div class="toolbar-wrap svelte-1uf24la"><div class="half-container svelte-1uf24la"><!> <!> <!></div> <div><!> <!> <!> <!></div></div>');function jf(s,t){ce(t,!1);const e=Z(),i=Z(),r=Z(),n=Z(),o=Z();let a=z(t,"tool",12,"image"),h=z(t,"subtool",12,null),l=z(t,"background",12,!1),c=z(t,"brush_options",12),u=z(t,"selected_size",28,()=>c()&&typeof c().default_size=="number"?c().default_size:25),_=z(t,"eraser_options",12),d=z(t,"selected_eraser_size",28,()=>_()&&typeof _().default_size=="number"?_().default_size:25),f=z(t,"selected_color",28,()=>c()&&(()=>{const O=c().default_color;return Array.isArray(O)?O[0]:O})()),g=z(t,"selected_opacity",28,()=>c()&&(()=>{const O=c().default_color;if(Array.isArray(O))return O[1];const J=he(O);return J.getAlpha()<1?J.getAlpha():1})()),p=z(t,"preview",12,!1),y=z(t,"show_brush_color",12,!1),x=z(t,"show_brush_size",12,!1),v=z(t,"show_eraser_size",12,!1),b=z(t,"sources",12),C=z(t,"transforms",12),w=[];const k=Oe();function R(O,J){O.stopPropagation(),k("tool_change",{tool:J})}function S(O,J){O.stopPropagation(),k("subtool_change",{tool:a(),subtool:J})}yt(()=>(Y(a()),Y(h())),()=>{x(a()==="draw"&&h()==="size")}),yt(()=>(Y(a()),Y(h())),()=>{y(a()==="draw"&&h()==="color")}),yt(()=>(Y(a()),Y(h())),()=>{v(a()==="erase"&&h()==="size")}),yt(()=>Y(C()),()=>{W(e,C().includes("crop"))}),yt(()=>Y(C()),()=>{W(i,C().includes("resize"))}),yt(()=>Y(b()),()=>{W(r,b().includes("upload"))}),yt(()=>Y(b()),()=>{W(n,b().includes("webcam"))}),yt(()=>Y(b()),()=>{W(o,b().includes("clipboard"))}),Le();var P={get tool(){return a()},set tool(O){a(O),I()},get subtool(){return h()},set subtool(O){h(O),I()},get background(){return l()},set background(O){l(O),I()},get brush_options(){return c()},set brush_options(O){c(O),I()},get selected_size(){return u()},set selected_size(O){u(O),I()},get eraser_options(){return _()},set eraser_options(O){_(O),I()},get selected_eraser_size(){return d()},set selected_eraser_size(O){d(O),I()},get selected_color(){return f()},set selected_color(O){f(O),I()},get selected_opacity(){return g()},set selected_opacity(O){g(O),I()},get preview(){return p()},set preview(O){p(O),I()},get show_brush_color(){return y()},set show_brush_color(O){y(O),I()},get show_brush_size(){return x()},set show_brush_size(O){x(O),I()},get show_eraser_size(){return v()},set show_eraser_size(O){v(O),I()},get sources(){return b()},set sources(O){b(O),I()},get transforms(){return C()},set transforms(O){C(O),I()}};ve();var F=Yf(),G=it(F),N=it(G);{var B=O=>{{let J=Gt(()=>a()==="image");ae(O,{get Icon(){return Vo},label:"Image",get highlight(){return m(J)},onclick:Tt=>R(Tt,"image"),size:"medium",padded:!1,transparent:!0})}};Q(N,O=>{Y(b()),Rt(()=>b().length>0)&&O(B)})}var V=q(N,2);{var L=O=>{{let J=Gt(()=>a()==="draw");ae(O,{get Icon(){return ol},label:"Brush",onclick:Tt=>R(Tt,"draw"),get highlight(){return m(J)},size:"medium",padded:!1,transparent:!0})}};Q(V,O=>{c()&&O(L)})}var D=q(V,2);{var gt=O=>{{let J=Gt(()=>a()==="erase");ae(O,{get Icon(){return fl},label:"Erase",onclick:Tt=>R(Tt,"erase"),get highlight(){return m(J)},size:"medium",padded:!1,transparent:!0})}};Q(D,O=>{_()&&O(gt)})}tt(G);var M=q(G,2);let T;var st=it(M);{var U=O=>{var J=ci(),Tt=qt(J);{var E=ct=>{var at=Hf(),ft=qt(at);{var Et=Nt=>{{let Ft=Gt(()=>h()==="crop");ae(Nt,{get Icon(){return dl},label:"Crop",onclick:vt=>S(vt,"crop"),get highlight(){return m(Ft)},size:"medium",padded:!1,transparent:!0,offset:0})}};Q(ft,Nt=>{m(e)&&Nt(Et)})}var Ut=q(ft,2);{var bt=Nt=>{{let Ft=Gt(()=>h()==="size");ae(Nt,{get Icon(){return Cl}
296,label:"Resize",onclick:vt=>S(vt,"size"),get highlight(){return m(Ft)},size:"medium",padded:!1,transparent:!0,offset:0})}};Q(Ut,Nt=>{m(i)&&Nt(bt)})}H(ct,at)},et=ct=>{var at=Vf(),ft=qt(at);{var Et=vt=>{{let ee=Gt(()=>h()==="upload");ae(vt,{get Icon(){return Hh},label:"Upload",onclick:Zt=>S(Zt,"upload"),get highlight(){return m(ee)},size:"medium",padded:!1,transparent:!0,offset:0})}};Q(ft,vt=>{m(r)&&vt(Et)})}var Ut=q(ft,2);{var bt=vt=>{{let ee=Gt(()=>h()==="paste");ae(vt,{get Icon(){return Vh},label:"Paste",onclick:Zt=>S(Zt,"paste"),get highlight(){return m(ee)},size:"large",padded:!1,transparent:!0,offset:0})}};Q(Ut,vt=>{m(o)&&vt(bt)})}var Nt=q(Ut,2);{var Ft=vt=>{{let ee=Gt(()=>h()==="webcam");ae(vt,{get Icon(){return Xh},label:"Webcam",onclick:Zt=>S(Zt,"webcam"),get highlight(){return m(ee)},size:"medium",padded:!1,transparent:!0,offset:0})}};Q(Nt,vt=>{m(n)&&vt(Ft)})}H(ct,at)};Q(Tt,ct=>{l()?ct(E):ct(et,!1)})}H(O,J)};Q(st,O=>{a()==="image"&&O(U)})}var rt=q(st,2);{var xt=O=>{var J=Xf(),Tt=qt(J);ae(Tt,{get Icon(){return cl},label:"Color",get color(){return f()},onclick:at=>S(at,"color"),size:"medium",padded:!1,transparent:!0,offset:0});var E=q(Tt,2);{let at=Gt(()=>h()==="size");ae(E,{get Icon(){return wn},label:"Brush Size",onclick:ft=>S(ft,"size"),get highlight(){return m(at)},size:"medium",padded:!1,transparent:!0,offset:0})}var et=q(E,2);{var ct=at=>{Go(at,{get colors(){return Y(c()),Rt(()=>c().colors)},get color_mode(){return Y(c()),Rt(()=>c().color_mode)},get recent_colors(){return w},get show_swatch(){return y()},get show_size(){return x()},mode:"brush",get selected_size(){return u()},set selected_size(ft){u(ft)},get selected_color(){return f()},set selected_color(ft){f(ft)},get selected_opacity(){return g()},set selected_opacity(ft){g(ft)},get preview(){return p()},set preview(ft){p(ft)},$$events:{click_outside:ft=>{ft.stopPropagation(),p(!1),y(!1),x(!1),S(ft,null)}},$$legacy:!0})};Q(et,at=>{(y()||x())&&at(ct)})}H(O,J)};Q(rt,O=>{a()==="draw"&&c()&&O(xt)})}var K=q(rt,2);{var mt=O=>{{let J=Gt(()=>h()==="size");ae(O,{get Icon(){return wn},label:"Eraser Size",onclick:Tt=>S(Tt,"size"),get highlight(){return m(J)},size:"medium",padded:!1,transparent:!0,offset:0})}};Q(K,O=>{a()==="erase"&&_()&&O(mt)})}var ot=q(K,2);{var ut=O=>{Go(O,{colors:[],show_swatch:!1,show_size:!0,mode:"eraser",get selected_size(){return d()},set selected_size(J){d(J)},get selected_color(){return f()},set selected_color(J){f(J)},get selected_opacity(){return g()},set selected_opacity(J){g(J)},get preview(){return p()},set preview(J){p(J)},$$events:{click_outside:J=>{J.stopPropagation(),p(!1),v(!1),S(J,null)}},$$legacy:!0})};Q(ot,O=>{v()&&O(ut)})}return tt(M),tt(F),Wt(()=>T=re(M,1,"half-container right svelte-1uf24la",null,T,{hide:a()==="pan"||a()==="image"&&!l()&&b().length===0||a()==="image"&&l()&&C().length===0})),H(s,F),ue(P)}var Yr=`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`,jr=`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}`,qf=` 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}`,$f=`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}`,Kf=` 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`,Zf=`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}`,Qf=Object.defineProperty,Jf=(s,t,e)=>t in s?Qf(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,$e=(s,t,e)=>(Jf(s,typeof t!="symbol"?t+"":t,e),e);
497const yh=class xh extends Er{constructor(...t){let e=t[0]??{};(typeof e=="number"||Array.isArray(e))&&(ht("6.0.0","KawaseBlurFilter constructor params are now options object. See params: { strength, quality, clamp, pixelSize }"),e={strength:e},t[1]!==void 0&&(e.quality=t[1]),t[2]!==void 0&&(e.clamp=t[2])),e={...xh.DEFAULT_OPTIONS,...e};const i=We.from({vertex:{source:jr,entryPoint:"mainVertex"},fragment:{source:e?.clamp?Zf:$f,entryPoint:"mainFragment"}}),r=_i.from({vertex:Yr,fragment:e?.clamp?Kf:qf,name:"kawase-blur-filter"});super({gpuProgram:i,glProgram:r,resources:{kawaseBlurUniforms:{uOffset:{value:new Float32Array(2),type:"vec2<f32>"}}}}),$e(this,"uniforms"),$e(this,"_pixelSize",{x:0,y:0}),$e(this,"_clamp"),$e(this,"_kernels",[]),$e(this,"_blur"),$e(this,"_quality"),this.uniforms=this.resources.kawaseBlurUniforms.uniforms,this.pixelSize=e.pixelSize??{x:1,y:1},Array.isArray(e.strength)?this.kernels=e.strength:typeof e.strength=="number"&&(this._blur=e.strength,this.quality=e.quality??3),this._clamp=!!e.clamp}apply(t,e,i,r){const n=this.pixelSizeX/e.source.width,o=this.pixelSizeY/e.source.height;let a;if(this._quality===1||this._blur===0)a=this._kernels[0]+.5,this.uniforms.uOffset[0]=a*n,this.uniforms.uOffset[1]=a*o,t.applyFilter(this,e,i,r);else{const h=di.getSameSizeTexture(e);let l=e,c=h,u;const _=this._quality-1;for(let d=0;d<_;d++)a=this._kernels[d]+.5,this.uniforms.uOffset[0]=a*n,this.uniforms.uOffset[1]=a*o,t.applyFilter(this,l,c,!0),u=l,l=c,c=u;a=this._kernels[_]+.5,this.uniforms.uOffset[0]=a*n,this.uniforms.uOffset[1]=a*o,t.applyFilter(this,l,i,r),di.returnTexture(h)}}get strength(){return this._blur}set strength(t){this._blur=t,this._generateKernels()}get quality(){return this._quality}set quality(t){this._quality=Math.max(1,Math.round(t)),this._generateKernels()}get kernels(){return this._kernels}set kernels(t){Array.isArray(t)&&t.length>0?(this._kernels=t,this._quality=t.length,this._blur=Math.max(...t)):(this._kernels=[0],this._quality=1)}get pixelSize(){return this._pixelSize}set pixelSize(t){if(typeof t=="number"){this.pixelSizeX=this.pixelSizeY=t;return}if(Array.isArray(t)){this.pixelSizeX=t[0],this.pixelSizeY=t[1];return}this._pixelSize=t}get pixelSizeX(){return this.pixelSize.x}set pixelSizeX(t){this.pixelSize.x=t}get pixelSizeY(){return this.pixelSize.y}set pixelSizeY(t){this.pixelSize.y=t}get clamp(){return this._clamp}_updatePadding(){this.padding=Math.ceil(this._kernels.reduce((t,e)=>t+e+.5,0))}_generateKernels(){const t=this._blur,e=this._quality,i=[t];if(t>0){let r=t;const n=t/e;for(let o=1;o<e;o++)r-=n,i.push(r)}this._kernels=i,this._updatePadding()}};$e(yh,"DEFAULT_OPTIONS",{strength:4,quality:3,clamp:!1,pixelSize:{x:1,y:1}});let tp=yh;var ep=`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}`,ip=`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}`,sp=Object.defineProperty,rp=(s,t,e)=>t in s?sp(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,ni=(s,t,e)=>(rp(s,typeof t!="symbol"?t+"":t,e),e);
552const bh=class vh extends Er{constructor(t){t={...vh.DEFAULT_OPTIONS,...t};const e=We.from({vertex:{source:jr,entryPoint:"mainVertex"},fragment:{source:ip,entryPoint:"mainFragment"}}),i=_i.from({vertex:Yr,fragment:ep,name:"drop-shadow-filter"});super({gpuProgram:e,glProgram:i,resources:{dropShadowUniforms:{uAlpha:{value:t.alpha,type:"f32"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uOffset:{value:t.offset,type:"vec2<f32>"}}},resolution:t.resolution}),ni(this,"uniforms"),ni(this,"shadowOnly",!1),ni(this,"_color"),ni(this,"_blurFilter"),ni(this,"_basePass"),this.uniforms=this.resources.dropShadowUniforms.uniforms,this._color=new Ht,this.color=t.color??0,this._blurFilter=new tp({strength:t.kernels??t.blur,quality:t.kernels?void 0:t.quality}),this._basePass=new Er({gpuProgram:We.from({vertex:{source:jr,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:_i.from({vertex:Yr,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,t)}
570apply(t,e,i,r){const n=di.getSameSizeTexture(e);t.applyFilter(this,e,n,!0),this._blurFilter.apply(t,n,i,r),this.shadowOnly||t.applyFilter(this._basePass,e,i,!1),di.returnTexture(n)}get offset(){return this.uniforms.uOffset}set offset(t){this.uniforms.uOffset=t,this._updatePadding()}get offsetX(){return this.offset.x}set offsetX(t){this.offset.x=t,this._updatePadding()}get offsetY(){return this.offset.y}set offsetY(t){this.offset.y=t,this._updatePadding()}get color(){return this._color.value}set color(t){this._color.setValue(t);const[e,i,r]=this._color.toArray();this.uniforms.uColor[0]=e,this.uniforms.uColor[1]=i,this.uniforms.uColor[2]=r}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}get blur(){return this._blurFilter.strength}set blur(t){this._blurFilter.strength=t,this._updatePadding()}get quality(){return this._blurFilter.quality}set quality(t){this._blurFilter.quality=t,this._updatePadding()}get kernels(){return this._blurFilter.kernels}set kernels(t){this._blurFilter.kernels=t}get pixelSize(){return this._blurFilter.pixelSize}set pixelSize(t){typeof t=="number"&&(t={x:t,y:t}),Array.isArray(t)&&(t={x:t[0],y:t[1]}),this._blurFilter.pixelSize=t}get pixelSizeX(){return this._blurFilter.pixelSizeX}set pixelSizeX(t){this._blurFilter.pixelSizeX=t}get pixelSizeY(){return this._blurFilter.pixelSizeY}set pixelSizeY(t){this._blurFilter.pixelSizeY=t}_updatePadding(){const t=Math.max(Math.abs(this.offsetX),Math.abs(this.offsetY));this.padding=t+this.blur*2+this.quality*4}};ni(bh,"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 np=bh;class op{name="image";context;current_tool;current_subtool;async setup(t,e,i){this.context=t,this.current_tool=e,this.current_subtool=i}cleanup(){}async add_image({image:t,fixed_canvas:e,border_region:i=0}){const r=new ap(this.context,t,e,i);await this.context.execute_command(r)}set_tool(t,e){this.current_tool=t,this.current_subtool=e}}class ap{sprite=null;fixed_canvas;context;background;current_canvas_size;computed_dimensions;current_scale;current_position;border_region;scaled_width;scaled_height;previous_image=null;name;constructor(t,e,i,r=0){if(this.name="AddImage",this.context=t,this.background=e,this.fixed_canvas=i,this.border_region=r,this.current_canvas_size=Ne(this.context.dimensions),this.current_scale=Ne(this.context.scale),this.current_position=Ne(this.context.position),this.computed_dimensions={width:0,height:0},this.context.background_image&&this.context.background_image.texture){const n=this.context.background_image,o=n.borderRegion||0;this.previous_image={texture:this.clone_texture(n.texture),width:n.width,height:n.height,x:n.position.x,y:n.position.y,border_region:o}}}clone_texture(t){const e=Jt.create({width:t.width,height:t.height,resolution:window.devicePixelRatio||1}),i=new kt(t),r=new lt;return r.addChild(i),this.context.app.renderer.render(r,{renderTexture:e}),r.destroy({children:!0}),e}async start(){let t;if(this.background instanceof _t)t=this.background;else{const r=await createImageBitmap(this.background);t=_t.from(r)}this.sprite=new kt(t);const[e,i]=this.handle_image();this.computed_dimensions={width:e,height:i}}handle_image(){if(this.sprite===null)return[0,0];if(this.fixed_canvas){const t=Math.max(this.current_canvas_size.width-this.border_region*2,10),e=Math.max(this.current_canvas_size.height-this.border_region*2,10),{width:i,height:r,x:n,y:o}=hp(this.sprite.width,this.sprite.height,t,e);this.sprite.width=i,this.sprite.height=r,this.sprite.x=n+this.border_region,this.sprite.y=o+this.border_region}else{const t=this.sprite.width,e=this.sprite.height;return this.sprite.x=this.border_region,this.sprite.y=this.border_region,[t+this.border_region*2,e+this.border_region*2]}return[this.current_canvas_size.width,this.current_canvas_size.height]}async execute(t){if(t&&(this.context=t),await this.start(),this.sprite===null)return;const{width:e,height:i}=this.computed_dimensions;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:i});const r=this.context.layer_manager.create_background_layer(this.fixed_canvas?this.current_canvas_size.width:e,this.fixed_canvas?this.current_canvas_size.height:i);this.sprite.zIndex=0,r.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:i,!0),this.border_region>0&&(this.sprite.borderRegion=this.border_region),this.context.set_background_image(this.sprite),this.context.reset()}async undo(){if(this.sprite){if(this.sprite.destroy(),this.previous_image){const t=new kt(this.previous_image.texture);t.width=this.previous_image.width,t.height=this.previous_image.height,t.position.set(this.previous_image.x,this.previous_image.y),this.previous_image.border_region>0&&(t.borderRegion=this.previous_image.border_region),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.previous_image.width,height:this.previous_image.height});const e=this.context.layer_manager.create_background_layer(this.previous_image.width,this.previous_image.height);t.zIndex=0,e.addChild(t),this.context.layer_manager.reset_layers(this.previous_image.width,this.previous_image.height,!0),this.context.set_background_image(t)}else 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.current_canvas_size.width,height:this.current_canvas_size.height}),this.context.layer_manager.create_background_layer(this.current_canvas_size.width,this.current_canvas_size.height),this.context.layer_manager.reset_layers(this.current_canvas_size.width,this.current_canvas_size.height);this.context.reset()}}}function hp(s,t,e,i){const r=s/t,n=e/i;let o,a;r>n?(o=e,a=e/r):(a=i,o=i*r);const h=Math.round((e-o)/2),l=Math.round((i-a)/2);return{width:Math.round(o),height:Math.round(a),x:h,y:l}}class qr{name="zoom";min_zoom=ai(!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 dt;current_tool;current_subtool;local_scale=1;local_dimensions={width:0,height:0};local_position={x:0,y:0};prevent_default(t){t.preventDefault(),t.stopPropagation()}set_tool(t,e){this.current_tool=t,this.current_subtool=e}set_zoom(t){const e=this.calculate_min_zoom(this.local_dimensions.width,this.local_dimensions.height);let i;const r=t==="fit";r?i=e:i=Math.max(0,Math.min(this.max_zoom,t));const n=this.image_editor_context.app.screen,o=n.width,a=n.height;let h;h={x:o/2,y:a/2},this.zoom_to_point(i,h,!0,r)}async setup(t,e,i){this.image_editor_context=t,this.current_tool=e,this.current_subtool=i,this.pad_bottom=t.pad_bottom;const{width:r,height:n}=await this.get_container_dimensions(),o=this.calculate_min_zoom(r,n),a=Math.min(o,1);this.local_scale=a;const h=this.image_editor_context.app.screen,l=h.width/2,c=h.height/2,u=r*a,_=n*a,d=l-u/2,f=c-_/2;this.local_position={x:d,y:f},this.setup_event_listeners(),await this.image_editor_context.set_image_properties({scale:a,position:{x:d,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 t=this.image_editor_context.app.stage;this.image_editor_context.app.canvas.addEventListener("wheel",this.prevent_default,{passive:!1}),t.eventMode="static",t.hitArea=this.image_editor_context.app.screen;const i=this.handle_wheel.bind(this);t.addEventListener("wheel",i,{passive:!1}),"ontouchstart"in window?(t.addEventListener("touchstart",this.handle_touch_start.bind(this)),t.addEventListener("touchmove",this.handle_touch_move.bind(this)),t.addEventListener("touchend",this.handle_touch_end.bind(this))):(t.addEventListener("pointerdown",this.handle_pointer_down.bind(this)),t.addEventListener("pointermove",this.handle_pointer_move.bind(this)),t.addEventListener("pointerup",this.handle_pointer_up.bind(this)),t.addEventListener("pointerupoutside",this.handle_pointer_up.bind(this)))}handle_wheel(t){const e=t.deltaMode===0&&Math.abs(t.deltaY)<50,i=e?30:10;if(t.altKey||t.metaKey){const r=this.image_editor_context.app.stage.toLocal(t.global),n=-t.deltaY*(e?.001:5e-4),o=this.local_scale*(1+n);this.zoom_to_point(o,r,!0)}else{const r=t.deltaX,n=t.deltaY,o={x:this.local_position.x-r/100*i,y:this.local_position.y-n/100*i},a=this.image_editor_context.app.screen,h=this.local_dimensions.width*this.local_scale,l=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 _={...o};if(h<=c)_.x=(a.width-h)/2;else{const d=a.width/2,f=d,g=a.width-d-h;_.x=Math.min(Math.max(o.x,g),f)}if(l<=u)_.y=(a.height-this.pad_bottom-l)/2;else{const d=(a.height-this.pad_bottom)/2,f=d,g=a.height-this.pad_bottom-d-l;_.y=Math.min(Math.max(o.y,g),f)}this.image_editor_context.set_image_properties({scale:this.local_scale,position:_})}}cleanup(){const t=this?.image_editor_context?.app?.stage;t&&(t.removeEventListener("wheel",this.handle_wheel.bind(this)),"ontouchstart"in window?(t.removeEventListener("touchstart",this.handle_touch_start.bind(this)),t.removeEventListener("touchmove",this.handle_touch_move.bind(this)),t.removeEventListener("touchend",this.handle_touch_end.bind(this))):(t.removeEventListener("pointerdown",this.handle_pointer_down.bind(this)),t.removeEventListener("pointermove",this.handle_pointer_move.bind(this)),t.removeEventListener("pointerup",this.handle_pointer_up.bind(this)),t.removeEventListener("pointerupoutside",this.handle_pointer_up.bind(this))))}async get_container_dimensions(){const t=this.image_editor_context.
570image_container.getLocalBounds();return{width:t.width,height:t.height}}calculate_min_zoom(t,e){const i=this.image_editor_context.app.screen,r=i.width,n=i.height;if(!t||!r||!e||!n)return 1;const o=r-this.border_padding*2,a=n-this.border_padding*2-this.pad_bottom,h=o/t,l=a/e;return Math.min(h,l)}handle_touch_start(t){t.preventDefault();const e=t;if(e.touches&&e.touches.length===2)this.is_pinching=!0,this.last_pinch_distance=Math.hypot(e.touches[0].pageX-e.touches[1].pageX,e.touches[0].pageY-e.touches[1].pageY);else if(e.touches&&e.touches.length===1){this.is_dragging=!0;const i=this.image_editor_context.app.view.getBoundingClientRect();this.last_touch_position=new dt(e.touches[0].pageX-i.left,e.touches[0].pageY-i.top)}}handle_touch_move(t){t.preventDefault();const e=t;if(this.is_pinching&&e.touches&&e.touches.length===2){const i=this.image_editor_context.app.view.getBoundingClientRect(),r=Math.hypot(e.touches[0].pageX-e.touches[1].pageX,e.touches[0].pageY-e.touches[1].pageY),n={x:(e.touches[0].pageX+e.touches[1].pageX)/2-i.left,y:(e.touches[0].pageY+e.touches[1].pageY)/2-i.top},o=r/this.last_pinch_distance;this.last_pinch_distance=r,this.zoom_to_point(this.local_scale*o,n)}else if(this.is_dragging&&e.touches&&e.touches.length===1&&this.last_touch_position){const i=this.image_editor_context.app.view.getBoundingClientRect(),r=new dt(e.touches[0].pageX-i.left,e.touches[0].pageY-i.top),n=r.x-this.last_touch_position.x,o=r.y-this.last_touch_position.y;this.image_editor_context.set_image_properties({position:{x:this.local_position.x+n,y:this.local_position.y+o}}),this.last_touch_position=r}}handle_touch_end(t){t.preventDefault();const e=t;if(e.touches&&e.touches.length<2&&(this.is_pinching=!1,e.touches&&e.touches.length===1)){const i=this.image_editor_context.app.view.getBoundingClientRect();this.last_touch_position=new dt(e.touches[0].pageX-i.left,e.touches[0].pageY-i.top),this.is_dragging=!0}e.touches&&e.touches.length===0&&(this.is_dragging=!1,this.last_touch_position=null,this.last_pinch_distance=0)}get_bounded_position(t){const e=this.image_editor_context.app.screen,i=this.local_dimensions.width*this.local_scale,r=this.local_dimensions.height*this.local_scale,n={x:(e.width-i)/2,y:(e.height-r-this.pad_bottom)/2};if(i<=e.width&&r<=e.height)return n;let o=t.x,a=t.y;if(i<=e.width)o=n.x;else{const h=e.width-i;o=Math.max(h,Math.min(0,t.x))}if(r<=e.height-this.pad_bottom)a=n.y;else{const h=e.height-r-this.pad_bottom;a=Math.max(h,Math.min(0,t.y))}return{x:o,y:a}}zoom_to_point(t,e,i,r){const n=this.image_editor_context.image_container,o=n.getGlobalPosition(),a=n.scale.x,h={x:(e.x-o.x)/a,y:(e.y-o.y)/a},l=this.calculate_min_zoom(this.local_dimensions.width,this.local_dimensions.height),c=Math.min(l,1);t=Math.min(Math.max(t,c),this.max_zoom);const u={x:e.x-h.x*t,y:e.y-h.y*t};if(t===c||r){const _=this.image_editor_context.app.screen.width,d=this.image_editor_context.app.screen.height,f=this.local_dimensions.width*t,g=this.local_dimensions.height*t;u.x=(_-f)/2,u.y=(d-this.pad_bottom-g)/2}this.image_editor_context.set_image_properties({scale:t,position:u,animate:typeof i=="boolean"?!i:t===c}),this.min_zoom.set(t===c)}handle_pointer_down(t){t.button===0&&this.current_tool==="pan"&&(this.is_pointer_dragging=!0,this.drag_start.copyFrom(t.global),this.drag_start.x-=this.local_position.x,this.drag_start.y-=this.local_position.y)}handle_pointer_move(t){if(this.is_pointer_dragging&&this.current_tool==="pan"){const e={x:t.global.x-this.drag_start.x,y:t.global.y-this.drag_start.y},i=this.image_editor_context.app.screen,r=this.local_dimensions.width*this.local_scale,n=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 h={...e};r<=o?h.x=(i.width-r)/2:h.x=e.x,n<=a?h.y=(i.height-this.pad_bottom-n)/2:h.y=e.y,this.image_editor_context.set_image_properties({scale:this.local_scale,position:h})}}handle_pointer_up(t){if(this.is_pointer_dragging&&this.current_tool==="pan"){this.is_pointer_dragging=!1;const e={x:t.global.x-this.drag_start.x,y:t.global.y-this.drag_start.y},i=this.image_editor_context.app.screen,r=this.local_dimensions.width*this.local_scale,n=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 h={...e};if(r<=o)h.x=(i.width-r)/2;else{const l=i.width/2,c=l,u=i.width-l-r;h.x=Math.min(Math.max(e.x,u),c)}if(n<=a)h.y=(i.height-this.pad_bottom-n)/2;else{const l=(i.height-this.pad_bottom)/2,c=l,u=i.height-this.pad_bottom-l-n;h.y=Math.min(Math.max(e.y,u),c)}this.image_editor_context.set_image_properties({scale:this.local_scale,position:h,animate:!0})}}}class lp{layers=[];active_layer=null;active_layer_id=null;draw_textures=new Map;layer_store=ai({active_layer:"",layers:[]});background_layer=null;image_container;app;fixed_canvas;dark;border_region;layer_options;constructor(t,e,i,r,n,o){this.image_container=t,this.app=e,this.fixed_canvas=i,this.dark=r,this.border_region=n,this.layer_options=o}toggle_layer_visibility(t){const e=this.layers.find(i=>i.id===t);e&&(e.container.visible=!e.container.visible,e.visible=e.container.visible,this.layer_store.update(i=>({active_layer:i.active_layer,layers:this.layers})))}create_background_layer(t,e){this.background_layer&&this.background_layer.destroy();const i=new lt;this.background_layer=i;const r=Jt.create({width:t,height:e,resolution:window.devicePixelRatio,antialias:!0,scaleMode:Oo.NEAREST}),n=new kt(r);i.addChild(n);const o=new Dt;return o.clear(),o.rect(0,0,t,e).fill({color:this.dark?3355443:16777215,alph
570a:1}),this.app.renderer.render({container:o,target:r,clear:!0}),this.image_container.addChild(i),i.zIndex=-1,this.update_layer_order(),i}set_layer_options(t,e,i){this.layer_options=t,this.reset_layers(e,i)}async create_background_layer_from_url(t,e,i){const r=this.create_background_layer(e||this.image_container.width,i||this.image_container.height);try{const n=await _t.from(t),o=new kt(n),a=o.texture.width,h=o.texture.height,l=e||this.image_container.width,c=i||this.image_container.height;if(this.fixed_canvas){const u=Math.max(l-this.border_region*2,10),_=Math.max(c-this.border_region*2,10),d=a/h,f=u/_;let g,p,y=this.border_region,x=this.border_region;a<=u&&h<=_?(g=a,p=h):d>f?(g=u,p=u/d):(p=_,g=_*d),y+=Math.round((u-g)/2),x+=Math.round((_-p)/2),o.width=g,o.height=p,o.position.set(y,x)}else{o.position.set(this.border_region,this.border_region),this.background_layer&&this.background_layer.destroy();const u=a+this.border_region*2,_=h+this.border_region*2,d=this.create_background_layer(u,_);return o.width=a,o.height=h,d.addChild(o),d}return r.addChild(o),r}catch(n){return console.error("Error loading image from URL:",n),r}}create_layer({width:t,height:e,layer_name:i,user_created:r,layer_id:n=void 0,make_active:o=!1}){const a=new lt,h=n||Math.random().toString(36).substring(2,15),l=i||`Layer ${this.layers.length+1}`;this.layers.push({name:l,id:h,container:a,user_created:r,visible:!0}),this.image_container.addChild(a);const c=Jt.create({width:t,height:e,resolution:window.devicePixelRatio,antialias:!0,scaleMode:Oo.NEAREST}),u=new kt(c);a.addChild(u);const _=new Dt;return _.clear(),_.beginFill(0,0),_.drawRect(0,0,t,e),_.endFill(),this.app.renderer.render({container:_,target:c,clear:!0}),this.draw_textures.set(a,c),this.update_layer_order(),o&&this.set_active_layer(h),this.layer_store.set({active_layer:this.active_layer_id||"",layers:this.layers}),a}async add_layer_from_url(t){const{width:e,height:i}=this.image_container.getLocalBounds(),r=this.create_layer({width:e,height:i,layer_name:"Layer 1",user_created:!0}),n=this.layers.findIndex(a=>a.container===r);if(n===-1)return console.error("Could not find newly created layer"),"";const o=this.layers[n].id;try{const a=await Ze.load(t),h=this.draw_textures.get(r);if(!h)return console.error("No draw texture found for layer"),o;const l=new kt(a),c=l.width,u=l.height;let _=this.border_region,d=this.border_region;const f=this.fixed_canvas?e-this.border_region*2:e,g=this.fixed_canvas?i-this.border_region*2:i;if((c<f||u<g)&&(_=Math.floor((f-c)/2),d=Math.floor((g-u)/2)),l.position.set(_,d),c>f||u>g){const p=c/u,y=f/g;let x,v;p>y?(x=f,v=f/p):(v=g,x=g*p),l.width=x,l.height=v,_=this.border_region+Math.floor((f-x)/2),d=this.border_region+Math.floor((g-v)/2),l.position.set(_,d)}return this.app.renderer.render(l,{renderTexture:h}),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(t){this.layers.some(e=>e.id===t)&&(this.active_layer=this.layers.find(e=>e.id===t)?.container||this.layers[0]?.container||null,this.active_layer_id=t,this.layer_store.set({active_layer:t,layers:this.layers}))}get_layers(){return this.layers}get_layer_textures(t){const e=this.layers.find(i=>i.id===t);if(e){const i=this.draw_textures.get(e.container);if(i)return{draw:i}}return null}delete_layer(t){const e=this.layers.findIndex(i=>i.id===t);if(e>-1){const i=this.draw_textures.get(this.layers[e].container);if(i&&(i.destroy(),this.draw_textures.delete(this.layers[e].container)),this.layers[e].container.destroy(),this.active_layer===this.layers[e].container){const r=this.layers[Math.max(0,e-1)]||null;this.active_layer=r?.container||null,this.active_layer_id=r?.id||null}this.layers=this.layers.filter(r=>r.id!==t),this.layer_store.update(r=>({active_layer:r.active_layer===t?this.layers[this.layers.length-1]?.id:r.active_layer,layers:this.layers})),this.update_layer_order()}}update_layer_order(){this.background_layer&&(this.background_layer.zIndex=-1),this.layers.forEach((t,e)=>{t.container.zIndex=e})}move_layer(t,e){const i=this.layers.findIndex(r=>
570r.id===t);if(i>-1){const r=e==="up"?i-1:i+1;this.layers=this.layers.map((n,o)=>o===i?this.layers[r]:o===r?this.layers[i]:n),this.update_layer_order(),this.layer_store.update(n=>({active_layer:t,layers:this.layers}))}}resize_all_layers(t,e,i,r,n,o){new Map(this.layers.map(d=>[d.id,d]));const a=this.background_layer,h=()=>{let d=0,f=0;const g=t-n,p=e-o;return r.includes("left")?d=0:r.includes("right")?d=g:d=Math.floor(g/2),r.includes("top")?f=0:r.includes("bottom")?f=p:f=Math.floor(p/2),{offsetX:d,offsetY:f}};this.background_layer=this._resize_background_layer(a,t,e,i,h);const l=[],c=this.layers.map(d=>({id:d.id,name:d.name,user_created:d.user_created,texture:this.draw_textures.get(d.container),container:d.container}));this.layers=[],this.draw_textures.clear();for(const d of c){const f=this._resize_single_layer(d,t,e,i,h);f&&l.push(f)}const u=Ne(this.layer_store).active_layer;!l.some(d=>d.id===u)&&l.length>0?this.set_active_layer(l[0].id):l.length===0?this.layer_store.update(d=>({...d,active_layer:""})):this.layer_store.update(d=>({...d})),this.update_layer_order(),setTimeout(()=>{Ze.cache.reset(),this.app.renderer.textureGC.run()},100)}_resize_background_layer(t,e,i,r,n){if(!t)return this.create_background_layer(e,i);let o=t.children.find(h=>h instanceof kt&&h.texture!==t.children[0]?.texture);const a=this.create_background_layer(e,i);if(o){const h=new kt(o.texture);if(h.width=o.width,h.height=o.height,r)h.width=e,h.height=i,h.position.set(0,0);else{const{offsetX:l,offsetY:c}=n();h.position.set(o.x+l,o.y+c)}a.addChild(h)}return a}_resize_single_layer(t,e,i,r,n){if(!t.texture)return console.warn(`No texture found for layer ${t.id}, skipping cleanup.`),t.container&&!t.container.destroyed&&(this.image_container.children.includes(t.container)&&this.image_container.removeChild(t.container),t.container.destroy({children:!0})),null;const o=this.create_layer({width:e,height:i,layer_name:t.name,user_created:t.user_created}),a=this.layers[this.layers.length-1];a.id=t.id;const h=this.draw_textures.get(o);if(!h){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 t.texture&&!t.texture.destroyed&&t.texture.destroy(!0),t.container&&!t.container.destroyed&&t.container.destroy({children:!0}),null}this.app.renderer.clear({target:h,clearColor:[0,0,0,0]});const l=new kt(t.texture);if(r)l.width=e,l.height=i,l.position.set(0,0);else{const{offsetX:c,offsetY:u}=n();l.position.set(c,u)}return this.app.renderer.render(l,{renderTexture:h}),l.destroy(),t.texture&&!t.texture.destroyed&&t.texture.destroy(!0),t.container&&!t.container.destroyed&&(this.image_container.children.includes(t.container)&&this.image_container.removeChild(t.container),t.container.destroy({children:!0})),a}async get_blobs(t,e){return{background:await fs(this.app.renderer,this.background_layer,{width:t,height:e,x:0,y:0}),layers:await Promise.all(this.layers.map(async r=>{const n=await fs(this.app.renderer,r.container,{width:t,height:e,x:0,y:0});return n||null})),composite:await fs(this.app.renderer,this.image_container,{width:t,height:e,x:0,y:0})}}reset_layers(t,e,i=!1){const r=i?this.layers.map(n=>[n.name,n.id]):this.layer_options.layers.map(n=>[n,void 0]);this.layers.forEach(n=>{this.delete_layer(n.id)});for(const[n,o]of r)this.create_layer({width:t,height:e,layer_name:n,user_created:!this.layer_options.layers.find(a=>a===n),layer_id:o});
570if(!i)this.active_layer=this.layers[0].container,this.active_layer_id=this.layers[0].id;else if(this.active_layer=this.layers.find(n=>n.id===this.active_layer_id)?.container||this.layers[0]?.container,!this.active_layer)return;this.layer_store.update(n=>({active_layer:this.active_layer_id||this.layers[0].id,layers:this.layers}))}init_layers(t,e){for(const r of this.layers)this.delete_layer(r.id);let i=0;for(const r of this.layer_options.layers)this.create_layer({width:t,height:e,layer_name:r,user_created:!1,layer_id:`layer-${i}`}),i++;this.active_layer=this.layers[0].container,this.active_layer_id=this.layers[0].id,this.layer_store.update(r=>({active_layer:this.layers[0].id,layers:this.layers}))}}class cp{constructor(t,e){this.context=t,this.width=e.width,this.height=e.height,this.layer_name=e.layer_name||`Layer ${this.context.layer_manager.get_layers().length+1}`,this.user_created=e.user_created,this.layer_id=e.layer_id||Math.random().toString(36).substring(2,15),this.make_active=e.make_active||!1,this.name="AddLayer";const r=this.context.layer_manager.get_layers().find(n=>n.container===this.context.layer_manager.get_active_layer());this.previous_active_layer=r?.id||null}layer_id;layer_name;width;height;user_created;make_active;previous_active_layer=null;name;async execute(t){t&&(this.context=t),this.context.layer_manager.create_layer({width:this.width,height:this.height,layer_name:this.layer_name,user_created:this.user_created,layer_id:this.layer_id,make_active:this.make_active})}async undo(){this.context.layer_manager.delete_layer(this.layer_id),this.previous_active_layer&&this.context.layer_manager.set_active_layer(this.previous_active_layer)}}class up{constructor(t,e){this.context=t,this.name="RemoveLayer";const i=this.context.layer_manager.get_layers(),r=i.find(a=>a.id===e);if(!r)throw new Error(`Layer with ID ${e} not found`);const n=this.context.layer_manager.get_active_layer(),o=r.container===n;if(o){const a=i.findIndex(l=>l.id===e),h=i[Math.max(0,a-1)];this.previous_active_layer=h?.id||null}this.layer_data={id:r.id,name:r.name,user_created:r.user_created,visible:r.visible,was_active:o},this.captureTextureData(e)}layer_data;previous_active_layer=null;texture_copy=null;name;captureTextureData(t){const e=this.context.layer_manager.get_layer_textures(t);if(e)try{const i=e.draw,r=Jt.create({width:i.width,height:i.height,resolution:window.devicePixelRatio||1}),n=new kt(i);this.context.app.renderer.render(n,{renderTexture:r}),this.texture_copy=r,n.destroy()}catch(i){console.error("Failed to copy layer texture:",i),this.texture_copy=null}}async execute(t){t&&(this.context=t),this.context.layer_manager.delete_layer(this.layer_data.id)}async undo(){const t=Ne(this.context.dimensions);if(this.context.layer_manager.create_layer({width:t.width,height:t.height,layer_name:this.layer_data.name,user_created:this.layer_data.user_created,layer_id:this.layer_data.id,make_active:this.layer_data.was_active}),this.texture_copy)try{const e=this.context.layer_manager.get_layer_textures(this.layer_data.id);if(e){const i=new kt(this.texture_copy);this.context.app.renderer.render(i,{renderTexture:e.draw}),i.destroy()}}catch(e){console.error("Failed to restore layer content:",e)}this.layer_data.visible||this.context.layer_manager.toggle_layer_visibility(this.layer_data.id),!this.layer_data.was_active&&this.previous_active_layer&&this.context.layer_manager.set_active_layer(this.previous_active_layer)}destroy(){this.texture_copy&&(this.texture_copy.destroy(),this.texture_copy=null)}}class dp{constructor(t,e,i){this.context=t,this.layer_id=e,this.direction=i,this.name="ReorderLayer";const r=this.context.layer_manager.get_layers();this.original_order=r.map(a=>a.id);const n=r.findIndex(a=>a.id===e);if(n===-1)throw new Error(`Layer with ID ${e} not found`);const o=i==="up"?n-1:n+1;o<0||o>=r.length?this.new_order=[...this.original_order]:(this.new_order=[...this.original_order],[this.new_order[n],this.new_order[o]]=[this.new_order[o],this.new_order[n]])}original_order;new_order;layer_id;direction;name;async execute(t){t&&(this.context=t),this.context.layer_manager.move_layer(this.layer_id,this.direction)}async undo(){const t=this.context.layer_manager.get_layers();if(this.original_order.join(",")===t.map(n=>n.id).join(","))return;const e=t.findIndex(n=>n.id===this.layer_id);if(e===-1)return;const i=this.original_order.indexOf(this.layer_id),r=e>i?"up":"down";this.context.layer_manager.move_layer(this.layer_id,r)}}const _p={image:()=>new op,zoom:()=>new qr},yr={stiffness:.45,damping:.8};class fp{state;scale;position;subscribers;constructor(t){if(!(t instanceof $r))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(t,e){const i={...this.position};this.position={x:t,y:e},this._notify_subscribers("position",i,this.position)}_set_scale(t){const e=this.scale;this.scale=t,this._notify_subscribers("scale",e,t)}
570_notify_subscribers(t,e,i){this.subscribers.forEach(r=>{r({property:t,oldValue:e,newValue:i,timestamp:Date.now()})})}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}}class $r{ready;background_image_present=ai(!1);min_zoom=ai(!0);app;ui_container;image_container;command_manager;layer_manager;tools=new Map;current_tool;current_subtool;target_element;width;height;original_width;original_height;dimensions;scale;position;state;scale_value=1;position_value={x:0,y:0};dimensions_value={width:0,height:0};layers=ai({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(t){this.pad_bottom=t.pad_bottom||0,this.dark=t.dark||!1,this.theme_mode=t.theme_mode||"dark",this.target_element=t.target_element,this.width=t.width,this.height=t.height,this.original_width=t.width,this.original_height=t.height,this.command_manager=new Il,this.ready=new Promise(e=>{this.ready_resolve=e}),this.fixed_canvas=t.fixed_canvas||!1,this.tools=new Map(t.tools.map(e=>typeof e=="string"?[e,_p[e]()]:[e.name,e]));for(const e of this.tools.values())e?.on&&e.on("change",()=>{this.notify("change")});this.dimensions=Ds({width:this.width,height:this.height},yr),this.scale=Ds(1,yr),this.position=Ds({x:0,y:0},yr),this.state=new fp(this),this.border_region=t.border_region||0,this.layer_options=t.layer_options||{allow_additional_layers:!0,layers:["Layer 1"],disabled:!1},this.scale.subscribe(e=>{this.state._set_scale(e)}),this.position.subscribe(e=>{this.state._set_position(e.x,e.y)}),this.init()}get context(){const t=this;return{app:this.app,ui_container:this.ui_container,image_container:this.image_container,get background_image(){return t.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 t=this.target_element.getBoundingClientRect();new ResizeObserver(r=>{r.forEach(n=>{this.resize_canvas(n.contentBoxSize[0].inlineSize,n.contentBoxSize[0].blockSize)})}).observe(this.target_element),this.app=new Va,this.dark||(globalThis.__PIXI_APP__=this.app),await this.app.init({width:t.width,height:t.height,backgroundAlpha:this.dark?0:1,backgroundColor:this.theme_mode==="dark"?"#27272a":"#ffffff",resolution:window.devicePixelRatio,autoDensity:!0,antialias:!0,powerPreference:"high-performance"});const e=this.app.canvas;e.style.background="transparent",this.setup_containers(),this.layer_manager.create_background_layer(this.width,this.height),this.layer_manager.init_layers(this.width,this.height);for(const r of this.tools.values())await r.setup(this.context,this.current_tool,this.current_subtool);const i=this.tools.get("zoom");i&&i.min_zoom.subscribe(r=>{this.min_zoom.set(r)}),this.target_element.appendChild(e),this.target_element.style.background="transparent",this.dimensions.subscribe(r=>{this.dimensions_value=r,this.image_container.width=r.width,this.image_container.height=r.height}),this.scale.subscribe(r=>{this.scale_value=r}),this.position.subscribe(r=>{this.position_value=r}),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 r=this.dimensions_value.width*this.scale_value,n=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,r,n).fill({color:this.dark?3355443:16777215,alpha:1}),this.border_region>0){const h=this.border_region*this.scale_value,l=o+h-1,c=a+h-1,u=r-h*2+1,_=n-h*2+1;this.overlay_graphics.clear(),this.overlay_graphics.rect(l,c,u,_).stroke({color:10066329,width:1,alpha:0,pixelLine:!0});const d=5,g=d+5,p=10066329;for(let y=l;y<l+u;y+=g)this.overlay_graphics.rect(y,c,Math.min(d,l+u-y),1).fill({color:p,alph
570a:.7}),this.overlay_graphics.rect(y,c+_,Math.min(d,l+u-y),1).fill({color:p,alpha:.7});for(let y=c;y<c+_;y+=g)this.overlay_graphics.rect(l,y,1,Math.min(d,c+_-y)).fill({color:p,alpha:.7}),this.overlay_graphics.rect(l+u,y,1,Math.min(d,c+_-y)).fill({color:p,alpha:.7})}else this.overlay_graphics.clear()}),this.ready_resolve()}setup_containers(){if(this.image_container=new lt({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 lt({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 lt,this.outline_container.zIndex=-10,this.outline_graphics=new Dt,this.outline_graphics.rect(0,0,this.width,this.height).fill({color:this.dark?3355443:16777215,alpha:0}),!this.dark){const i=new np({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 lt,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 Dt,this.overlay_container.addChild(this.overlay_graphics),this.overlay_graphics.rect(0,0,this.width,this.height).fill({color:0,alpha:0});const t=this.app.screen.width/2,e=this.app.screen.height/2;this.image_container.position.set(t,e),this.outline_container.position.set(t,e),this.layer_manager=new lp(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(t,e){this.app.renderer&&this.app.renderer.resize(t,e);const i=t/2,r=e/2;this.image_container&&this.image_container.position.set(i,r),this.outline_container&&this.outline_container.position.set(i,r)}reset(){const t=this.tools.get("zoom");t&&(t.cleanup(),t.setup(this.context,this.current_tool,this.current_subtool)),this.tools.get("brush")&&this.set_tool("draw")}async set_image_properties(t){let e=typeof t.animate<"u"?!t.animate:!0;if(t.position){const i=this.position.set(t.position,{hard:e});e&&await i}if(t.scale){const i=this.scale.set(t.scale,{hard:e});e&&await i}if(t.width&&t.height){this.width=t.width,this.height=t.height;const i=this.dimensions.set({width:t.width,height:t.height},{hard:e});e&&await i}}async execute_command(t){await this.command_manager.execute(t,this.context)}undo(){this.command_manager.undo(),this.notify("change")}redo(){this.command_manager.redo(this.context),this.notify("change")}async add_image({image:t,resize:e=!0}){await this.tools.get("image").add_image({image:t,fixed_canvas:this.fixed_canvas,border_region:this.border_region})}async add_image_from_url(t){const e=this.tools.get("image"),i=await Ze.load(t);await e.add_image({image:i,fixed_canvas:this.fixed_canvas,border_region:this.border_region});const r=this.tools.get("resize");r&&typeof r.set_border_region=="function"&&r.set_border_region(this.border_region)}set_tool(t){this.current_tool=t;for(const e of this.tools.values())e.set_tool(this.current_tool,this.current_subtool)}set_subtool(t){this.current_subtool=t;for(const e of this.tools.values())e.set_tool(this.current_tool,this.current_subtool)}set_background_image(t){this.background_image=t}async reset_canvas(){this.width=this.original_width,this.height=this.original_height,this.layer_manager.reset_layers(this.width,this.height),this.background_image=void 0,this.background_image_present.set(!1),this.command_manager.reset(),await this.set_image_properties({width:this.width,height:this.height,scale:1,position:{x:0,y:0},animate:!1}),this.layer_manager.create_background_layer(this.width,this.height);for(const e of this.tools.values())e.cleanup(),e.setup(this.context,this.current_tool,this.current_subtool);const t=this.tools.get("zoom");t&&t.min_zoom.subscribe(e=>{this.min_zoom.set(e)}),this.notify("change")}add_layer(){const t=new cp(this.context,{width:this.width,height:this.height,user_created:!0,make_active:!0});this.execute_command(t),this.notify("change")}async add_layers_from_url(t){if(this.command_manager.reset(),this.layer_manager.get_layers().forEac
570h(n=>this.layer_manager.delete_layer(n.id)),t===void 0||t.length===0){this.layer_manager.create_layer({width:this.width,height:this.height,layer_name:void 0,user_created:!1});return}const i=[];for await(const n of t){const o=await this.layer_manager.add_layer_from_url(n);o&&i.push(o)}i.length>0&&this.layer_manager.set_active_layer(i[0]);const r=this.tools.get("resize");r&&typeof r.set_border_region=="function"&&r.set_border_region(this.border_region),this.notify("change"),this.notify("input")}set_layer(t){this.layer_manager.set_active_layer(t),this.notify("change")}move_layer(t,e){const i=new dp(this.context,t,e);this.execute_command(i),this.notify("change")}delete_layer(t){const e=new up(this.context,t);this.execute_command(e),this.notify("change")}modify_canvas_size(t,e,i,r){const n=this.width,o=this.height;this.layer_manager.resize_all_layers(t,e,r,i,n,o),this.width=t,this.height=e,this.set_image_properties({width:t,height:e,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(t,e){this.event_callbacks.set(t,[...this.event_callbacks.get(t)||[],e])}off(t,e){this.event_callbacks.set(t,this.event_callbacks.get(t)?.filter(i=>i!==e)||[])}notify(t){for(const e of this.event_callbacks.get(t)||[])e()}destroy(){this.app&&this.app?.destroy()}resize(t,e){this.set_image_properties({width:t,height:e}),this.reset()}async get_crop_bounds(){const t=this.tools.get("crop"),e=t.get_crop_bounds();return{image:await t.get_image(),...e}}get background_image_sprite(){return this.background_image}set_layer_options(t){this.layer_options=t,this.layer_manager.set_layer_options(t,this.width,this.height)}toggle_layer_visibility(t){this.layer_manager.toggle_layer_visibility(t)}}class pp{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(t,e,i){this.image_editor_context=t,this.current_tool=e,this.current_subtool=i,t.dimensions.subscribe(n=>{this.dimensions=n,this.crop_bounds={x:0,y:0,width:n.width,height:n.height},this.crop_ui_container&&this.update_crop_ui(),this.set_crop_mask(),this.update_crop_mask()}),t.position.subscribe(n=>{this.position=n}),t.scale.subscribe(n=>{this.scale=n}),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 r=e==="image"&&i==="crop";this.crop_ui_container&&(this.crop_ui_container.visible=r)}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.image_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(t,e){this.current_tool=t,this.current_subtool=e;const i=t==="image"&&e==="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.
570image_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 Dt,this.image_editor_context.image_container.addChild(this.crop_mask)}async init_crop_ui(){const{width:t,height:e}=this.image_editor_context.background_image?.getLocalBounds()||{width:!1,height:!1};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(t,e){const i=new lt;i.eventMode="static",i.interactiveChildren=!0;const r=new Dt().rect(0,0,t,e).stroke({width:1,color:0,alignment:0,alpha:.5});return r.eventMode="static",r.cursor="move",r.hitArea=new Mt(0,0,t,e),r.on("pointerdown",this.handle_window_drag_start.bind(this)),i.addChild(r),this.create_corner_handles(i,t,e),this.create_edge_handles(i,t,e),i}create_handle(t=!1){const e=new lt;e.eventMode="static";const i=new Dt;t?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),e.addChild(i);const r=t?this.HIT_AREA_SIZE*1.5:this.HIT_AREA_SIZE;return e.hitArea=new Mt(-r/2+this.LINE_THICKNESS,-r/2+this.LINE_THICKNESS,r,r),e}create_edge_handles(t,e,i){[-1,1].forEach((r,n)=>{const o=this.create_handle(!0);o.rotation=0,o.on("pointerdown",a=>{this.handle_pointer_down(a,o,-1,n)}),o.x=e/2-this.CORNER_SIZE*3/2,o.y=r<0?-this.LINE_THICKNESS:i,o.cursor="ns-resize",t.addChild(o)}),[-1,1].forEach((r,n)=>{const o=this.create_handle(!0);o.rotation=Math.PI/2,o.on("pointerdown",a=>{this.handle_pointer_down(a,o,-1,n+2)}),o.x=r<0?-this.LINE_THICKNESS:e,o.y=i/2-this.CORNER_SIZE*3/2,o.cursor="ew-resize",t.addChild(o)})}create_corner_handles(t,e,i){[{x:0,y:0,xScale:1,yScale:1,cursor:"nwse-resize"},{x:e,y:0,xScale:-1,yScale:1,cursor:"nesw-resize"},{x:0,y:i,xScale:1,yScale:-1,cursor:"nesw-resize"},{x:e,y:i,xScale:-1,yScale:-1,cursor:"nwse-resize"}].forEach(({x:n,y:o,xScale:a,yScale:h,cursor:l},c)=>{const u=this.create_handle(!1);u.x=n-(a<0?-this.LINE_THICKNESS:this.LINE_THICKNESS),u.y=o-(h<0?-this.LINE_THICKNESS:this.LINE_THICKNESS),u.scale.set(a,h),u.on("pointerdown",_=>{this.handle_pointer_down(_,u,c,-1)}),u.cursor=l,t.addChild(u)})}handle_pointer_down(t,e,i,r){if(this.current_subtool!=="crop")return;t.stopPropagation(),this.is_dragging=!0,this.selected_handle=e,this.active_corner_index=i,this.active_edge_index=r;const n=this.image_editor_context.image_container.toLocal(t.global);this.last_pointer_position=new dt(n.x,n.y)}update_crop_bounds(t){this.has_been_manually_changed=!0;const e=new dt(t.x,t.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 r=Math.max(20,i.width-e.x),n=i.width-r;this.crop_bounds.width=r,this.crop_bounds.x=i.x+n;const o=Math.max(20,i.height-e.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+e.x);const h=Math.max(20,i.height-e.y),l=i.height-h;this.crop_bounds.height=h,this.crop_bounds.y=i.y+l;break;case 2:const c=Math.max(20,i.width-e.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+e.y);break;case 3:this.crop_bounds.width=Math.max(20,i.width+e.x),this.crop_bounds.height=Math.max(20,i.height+e.y);break}else if(this.active_edge_index!==-1)switch(this.active_edge_index){case 0:const r=Math.max(20,i.height-e.y),n=i.height-r;this.crop_bounds.height=r,this.crop_bounds.y=i.y+n;break;case 1:this.crop_bounds.height=Math.max(20,i.height+e.y);break;case 2:const o=Math.max(20,i.width-e.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+e.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 t=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!==t&&this.active_corner_index===0||this.active_edge_index===2){const i=this.crop_bounds.x-t;this.crop_bounds.width-=i}const e=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!==e&&(this.active_corner_index===0||this.active_corner_index===1||this.active_edge_index===0)){const i=this.crop_bounds.y-e;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:t,height:e}=this.image_editor_context.background_image?.getLocalBounds()??{width:0,height:0};this.crop_mask.rect(0,0,t,e).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 t=this.crop_bounds.width*this.scale,e=this.crop_bounds.height*this.scale,i=this.crop_ui_container.getChildAt(0);i.clear().rect(0,0,t,e).stroke({width:1,color:0,alignment:0,alpha:.5}),i.hitArea=new Mt(0,0,t,e),this.update_handle_positions(t,e)}update_handle_positions(t,e){if(!this.crop_ui_container)return;const i=this.crop_ui_container.children.slice(1),r=i.slice(0,4),n=[{x:0,y:0},{x:t,y:0},{x:0,y:e},{x:t,y:e}];r.forEach((a,h)=>{const l=h%2===0?1:-1,c=h<2?1:-1;a.position.set(n[h].x-(l<0?-this.LINE_THICKNESS:this.LINE_THICKNESS),n[h].y-(c<0?-this.LINE_THICKNESS:this.LINE_THICKNESS))}),i.slice(4).forEach((a,h)=>{h<2?a.position.set(t/2-this.CORNER_SIZE*1.5/2,h===0?-this.LINE_THICKNESS:e):a.position.set(h===2?0:t+this.LINE_THICKNESS,e/2-this.CORNER_SIZE*1.5/2)})}setup_event_listeners(){const t=this.image_editor_context.app.stage;t.eventMode="static",t.on("pointermove",this.handle_pointer_move.bind(this)),t.on("pointerup",this.handle_pointer_up.bind(this)),t.on("pointerupoutside",this.handle_pointer_up.bind(this))}cleanup_event_listeners(){const t=this.image_editor_context.app.stage;t.off("pointermove",this.handle_pointer_move.bind(this)),t.off("pointerup",this.handle_pointer_up.bind(this)),t.off("pointerupoutside",this.handle_pointer_up.bind(this))}handle_pointer_move(t){if(this.current_subtool==="crop"){if(this.is_dragging_window&&this.drag_start_position&&this.drag_start_bounds){const e=this.image_editor_context.image_container.toLocal(t.global),i=new dt(e.x-this.drag_start_position.x,e.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 e=this.image_editor_context.image_container.toLocal(t.global),i=new dt(e.x,e.y),r=new dt(i.x-this.last_pointer_position.x,i.y-this.last_pointer_position.y);this.update_crop_bounds(r),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(t){if(this.current_subtool!=="crop")return;t.stopPropagation(),this.is_dragging_window=!0,this.has_been_manually_changed=!0;const e=this.image_editor_context.image_container.toLocal(t.global);this.drag_start_position=new dt(e.x,e.y),this.drag_start_bounds={...this.crop_bounds}}get crop_manually_changed(){return this.has_been_manually_changed}on(t,e){this.event_callbacks.set(t,[...this.event_callbacks.get(t)||[],e])}off(t,e){this.event_callbacks.set(t,this.event_callbacks.get(t)?.filter(i=>i!==e)||[])}notify(t){for(const e of this.event_callbacks.get(t)||[])e()}get_crop_bounds(){const{width:t,height:e}=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:t,height:e}}}get_image(){if(!this.image_editor_context.background_image)return Promise.resolve(null);const t=new lt,e=new kt(this.image_editor_context.background_image.texture);return t.addChild(e),fs(this.image_editor_context.app.renderer,t,this.crop_bounds)}}class gp{constructor(t,e,i,r){this.context=t,this.name="Resize",this.original_width=e.width,this.original_height=e.height,this.original_x=e.x,this.original_y=e.y,this.new_width=i.width,this.new_height=i.height,this.new_x=i.x,this.new_y=i.y,this.reset_ui=r}original_width;original_height;original_x;original_y;new_width;new_height;new_x;new_y;reset_ui;name;async execute(t){t&&(this.context=t),this.context.background_image&&(this.context.background_image.width=this.new_width,this.context.background_image.height=this.new_height,this.context.background_image.position.set(this.new_x,this.new_y),this.reset_ui())}async undo(){this.context.background_image&&(this.context.background_image.width=this.original_width,this.context.background_image.height=this.original_height,this.context.background_image.position.set(this.original_x,this.original_y),this.reset_ui())}}class mp{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;original_state=null;async setup(t,e,i){if(this.image_editor_context=t,this.current_tool=e,this.current_subtool=i,t.background_image)if(t.background_image.borderRegion!==void 0)this.borderRegion=t.background_image.borderRegion;else{const r=t.background_image,n=t.image_container,o=Math.abs(r.position.x-(n.width-r.width)/2)<2,a=Math.abs(r.position.y-(n.height-r.height)/2)<2;(!o||!a)&&(this.borderRegion=Math.max(r.position.x,r.position.y),t.background_image.borderRegion=this.borderRegion)}if(t.dimensions.subscribe(r=>{this.dimensions=r,this.resize_ui_container&&this.update_resize_ui()}),t.position.subscribe(r=>{this.position=r,this.resize_ui_container&&this.current_tool==="image"&&this.current_subtool==="size"&&this.update_resize_ui()}),t.scale.subscribe(r=>{this.scale=r,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 r=this.image_editor_context.background_image,n=this.image_editor_context.image_container,o=r.width,a=r.height,h=n.getLocalBounds(),l=h.width,c=h.height,u=-(o-l),_=-(a-c),d=0,f=0,g=o>l&&(r.position.x<u||r.position.x>d),p=a>c&&(r.position.y<_||r.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(t,e){if(this.current_tool=t,this.current_subtool=e,t==="image"&&e==="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,r=this.image_editor_context.image_container,n=i.width,o=i.height,a=r.getLocalBounds(),h=a.width,l=a.height,c=h-this.borderRegion*2,u=l-this.borderRegion*2,_=n>c?-(n-c)+this.borderRegion:this.borderRegion,d=n>c?this.borderRegion:h-n-this.borderRegion,f=o>u?-(o-u)+this.borderRegion:this.borderRegion,g=o>u?this.borderRegion:l-o-this.borderRegion,p=i.position.x<_||i.position.x>d,y=i.position.y<f||i.position.y>g;(p||y)&&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(t,e){const i=new lt;i.eventMode="static",i.interactiveChildren=!0;const r=new Dt().rect(0,0,t,e).stroke({width:1,color:0,alignment:0,alpha:.3}),n=new Dt;n.rect(0,0,t,e).stroke({width:1,color:0,alpha:.7,pixelLine:!0});const o=5,h=o+5;for(let c=0;c<t;c+=h*2)n.rect(c,0,Math.min(o,t-c),1).fill(0),n.rect(c,e-1,Math.min(o,t-c),1).fill(0);for(let c=0;c<e;c+=h*2)n.rect(0,c,1,Math.min(o,e-c)).fill(0),n.rect(t-1,c,1,Math.min(o,e-c)).fill(0);i.addChild(r),i.addChild(n);const l=new Dt().rect(0,0,t,e).fill(16777215,0);return l.eventMode="static",l.cursor="move",i.addChild(l),this.create_corner_handles(i,t,e),this.create_edge_handles(i,t,e),i}create_handle(t=!1){const e=new lt;e.eventMode="static",e.cursor="pointer";const i=new Dt,r=t?8:10;i.rect(-r/2,-r/2,r,r).fill(16777215).stroke({width:1,color:this.HANDLE_COLOR}),e.addChild(i);const n=t?this.HIT_AREA_SIZE*1.5:this.HIT_AREA_SIZE;return e.hitArea=new Mt(-n/2,-n/2,n,n),e}create_edge_handles(t,e,i){[-1,1].forEach((r,n)=>{const o=this.create_handle(!0);o.rotation=0,o.on("pointerdown",a=>{this.handle_pointer_down(a,o,-1,n)}),o.x=e/2,o.y=r<0?0:i,o.cursor="ns-resize",t.addChild(o)}),[-1,1].forEach((r,n)=>{const o=this.create_handle(!0);o.rotation=0,o.on("pointerdown",a=>{this.handle_pointer_down(a,o,-1,n+2)}),o.x=r<0?0:e,o.y=i/2,o.cursor="ew-resize",t.addChild(o)})}create_corner_handles(t,e,i){[{x:0,y:0,cursor:"nwse-resize"},{x:e,y:0,cursor:"nesw-resize"},{x:0,y:i,cursor:"nesw-resize"},{x:e,y:i,cursor:"nwse-resize"}
570].forEach(({x:n,y:o,cursor:a},h)=>{const l=this.create_handle(!1);l.x=n,l.y=o,l.on("pointerdown",c=>{this.handle_pointer_down(c,l,h,-1)}),l.cursor=a,t.addChild(l)})}handle_pointer_down(t,e,i,r){if(this.current_subtool!=="size")return;t.stopPropagation(),this.is_dragging=!0,this.selected_handle=e,this.active_corner_index=i,this.active_edge_index=r;const n=this.image_editor_context.image_container.toLocal(t.global);if(this.last_pointer_position=new dt(n.x,n.y),this.image_editor_context.background_image){const o=this.image_editor_context.background_image;this.original_state={width:o.width,height:o.height,x:o.position.x,y:o.position.y}}}maintain_aspect_ratio(t,e,i,r){const n=Math.abs(r.x),o=Math.abs(r.y);return n>o*1.2?e=t/i:o>n*1.2?t=e*i:t/i>e?e=t/i:t=e*i,{width:t,height:e}}limit_dimensions(t,e,i){const r=this.dimensions.width,n=this.dimensions.height;let o=t,a=e;return o>r&&(i&&this.active_corner_index!==-1&&(a=r/o*a),o=r),a>n&&(i&&this.active_corner_index!==-1&&(o=n/a*o),a=n),o=Math.max(20,o),a=Math.max(20,a),{width:o,height:a}}calculate_position_deltas(t,e,i,r){let n=0,o=0;return this.active_corner_index===0||this.active_edge_index===2?n=t-i:this.active_corner_index===2&&(n=t-i,o=0),(this.active_corner_index===0||this.active_corner_index===1||this.active_edge_index===0)&&(o=e-r),{x:n,y:o}}apply_boundary_constraints(){if(!this.image_editor_context.background_image)return;const t=this.image_editor_context.background_image,e=this.image_editor_context.image_container;let i=t.position.x,r=t.position.y;const n=e.width,o=e.height,a=t.width,h=t.height,l=n-this.borderRegion*2,c=o-this.borderRegion*2;if(a>l){const u=-(a-l)+this.borderRegion,_=this.borderRegion;i=Math.max(u,Math.min(_,i))}else{const u=this.borderRegion,_=n-a-this.borderRegion;(i<u||i>_)&&(i=Math.max(u,Math.min(_,i)))}if(h>c){const u=-(h-c)+this.borderRegion,_=this.borderRegion;r=Math.max(u,Math.min(_,r))}else{const u=this.borderRegion,_=o-h-this.borderRegion;(r<u||r>_)&&(r=Math.max(u,Math.min(_,r)))}if(t.position.set(i,r),this.resize_ui_container){const u=e.position.x+i*this.scale,_=e.position.y+r*this.scale;this.resize_ui_container.position.set(u,_)}}update_resize_bounds(t,e=!1){const i=this.image_editor_context.background_image;if(!i)return;const r=i.width,n=i.height,o=i.position.x,a=i.position.y,h=r/n;let l;if(this.active_corner_index!==-1){switch(this.active_corner_index){case 0:l=new dt(o-t.x,a-t.y);break;case 1:l=new dt(o+r+t.x,a-t.y);break;case 2:l=new dt(o-t.x,a+n+t.y);break;case 3:l=new dt(o+r+t.x,a+n+t.y);break;default:return}const c=this.handle_direct_corner_resize(l,r,n,o,a,h,e);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:l=new dt(o+r/2,a-t.y);break;case 1:l=new dt(o+r/2,a+n+t.y);break;case 2:l=new dt(o-t.x,a+n/2);break;case 3:l=new dt(o+r+t.x,a+n/2);break;default:return}const c=this.handle_direct_edge_resize(l,r,n,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 t=this.image_editor_context.background_image,i=this.image_editor_context.image_container.getGlobalPosition(),r=t.position.x*this.scale,n=t.position.y*this.scale;this.resize_ui_container.position.set(i.x+r,i.y+n);const o=t.width*this.scale,a=t.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 l=this.resize_ui_container.getChildAt(1);if(l.clear(),l.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+=20)l.rect(f,0,Math.min(5,o-f),1).fill(0),l.rect(f,a-1,Math.min(5,o-f),1).fill(0);for(let f=0;f<a;f+=20)l.rect(0,f,1,Math.min(5,a-f)).fill(0),l.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(t,e){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,t,e).fill(16777215,0
570);const n=i.slice(0,4),o=[{x:0,y:0},{x:t,y:0},{x:0,y:e},{x:t,y:e}];n.forEach((h,l)=>{h.position.set(o[l].x,o[l].y)}),i.slice(4).forEach((h,l)=>{l<2?h.position.set(t/2,l===0?0:e):h.position.set(l===2?0:t,e/2)})}setup_event_listeners(){const t=this.image_editor_context.app.stage;t.eventMode="static",t.on("pointermove",this.handle_pointer_move.bind(this)),t.on("pointerup",this.handle_pointer_up.bind(this)),t.on("pointerupoutside",this.handle_pointer_up.bind(this)),this.setup_dom_event_listeners()}setup_dom_event_listeners(){this.cleanup_dom_event_listeners();const t=this.image_editor_context.app.canvas;this.dom_mousedown_handler=e=>{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,n=this.image_editor_context.image_container.getBounds(),o=t.getBoundingClientRect(),a=e.clientX-o.left,h=e.clientY-o.top,l=(a-n.x)/this.scale,c=(h-n.y)/this.scale;l>=i.position.x&&l<=i.position.x+i.width&&c>=i.position.y&&c<=i.position.y+i.height&&(this.is_moving=!0,this.last_pointer_position=new dt(l,c),this.original_state={width:i.width,height:i.height,x:i.position.x,y:i.position.y},e.preventDefault(),e.stopPropagation())},this.dom_mousemove_handler=e=>{if(this.current_subtool!=="size"||!this.is_moving||!this.last_pointer_position||!this.image_editor_context.background_image)return;const r=this.image_editor_context.image_container.getBounds(),n=t.getBoundingClientRect(),o=e.clientX-n.left,a=e.clientY-n.top,h=(o-r.x)/this.scale,l=(a-r.y)/this.scale,c=new dt(h,l);this.handle_image_dragging(c),this.last_pointer_position=c,e.preventDefault(),e.stopPropagation()},this.dom_mouseup_handler=e=>{if(this.current_subtool==="size"){if(this.original_state&&this.image_editor_context.background_image){const i=this.image_editor_context.background_image,r={width:i.width,height:i.height,x:i.position.x,y:i.position.y};if(this.original_state.width!==r.width||this.original_state.height!==r.height||this.original_state.x!==r.x||this.original_state.y!==r.y){const n=new gp(this.image_editor_context,this.original_state,r,this.update_resize_ui.bind(this));this.image_editor_context.execute_command(n)}this.original_state=null}this.is_moving=!1,this.last_pointer_position=null,this.update_resize_ui(),e.preventDefault(),e.stopPropagation()}},t.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 t=this.image_editor_context.app.canvas;this.dom_mousedown_handler&&(t.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 t=this.image_editor_context.app.stage;t.off("pointermove",this.handle_pointer_move.bind(this)),t.off("pointerup",this.handle_pointer_up.bind(this)),t.off("pointerupoutside",this.handle_pointer_up.bind(this)),this.cleanup_dom_event_listeners()}handle_pointer_move(t){if(this.current_subtool!=="size")return;const e=this.image_editor_context.image_container.toLocal(t.global),i=new dt(e.x,e.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 r=this.image_editor_context.background_image,n=this.active_corner_index!==-1&&!t.shiftKey,o=r.width,a=r.height,h=r.position.x,l=r.position.y,c=o/a;let u;if(this.active_corner_index!==-1)u=this.handle_direct_corner_resize(i,o,a,h,l,c,n);else if(this.active_edge_index!==-1)u=this.handle_direct_edge_resize(i,o,a,h,l);else return;u=this.limit_dimensions_to_container(u,h,l,o,a,n),r.width=u.width,r.height=u.height,r.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(t){if(!this.last_pointer_position||!this.image_editor_context.background_image)return;const e=this.image_editor_context.background_image,i=this.image_editor_context.
570image_container.getLocalBounds(),r=t.x-this.last_pointer_position.x,n=t.y-this.last_pointer_position.y;let o=e.position.x+r,a=e.position.y+n;const h=i.width,l=i.height,c=e.width,u=e.height,_=h-this.borderRegion*2,d=l-this.borderRegion*2;if(c>_){const f=-(c-_)+this.borderRegion,g=this.borderRegion;o=Math.max(f,Math.min(g,o))}else{const f=this.borderRegion,g=h-c-this.borderRegion;o=Math.max(f,Math.min(g,o))}if(u>d){const f=-(u-d)+this.borderRegion,g=this.borderRegion;a=Math.max(f,Math.min(g,a))}else{const f=this.borderRegion,g=l-u-this.borderRegion;a=Math.max(f,Math.min(g,a))}e.position.set(o,a),this.update_resize_ui()}handle_direct_corner_resize(t,e,i,r,n,o,a){let h=0,l=0,c=r,u=n;switch(this.active_corner_index){case 0:h=r+e-t.x,l=n+i-t.y;break;case 1:h=t.x-r,l=n+i-t.y;break;case 2:h=r+e-t.x,l=t.y-n;break;case 3:h=t.x-r,l=t.y-n;break}h=Math.max(20,h),l=Math.max(20,l);let _=h,d=l;if(a){const f={x:t.x-(r+e/2),y:t.y-(n+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=r+e-_,u=n+i-d;break;case 1:u=n+i-d;break;case 2:c=r+e-_;break}return{width:_,height:d,x:c,y:u}}handle_direct_edge_resize(t,e,i,r,n){let o=e,a=i,h=r,l=n;switch(this.active_edge_index){case 0:a=Math.max(20,n+i-t.y),l=t.y;break;case 1:a=Math.max(20,t.y-n);break;case 2:o=Math.max(20,r+e-t.x),h=t.x;break;case 3:o=Math.max(20,t.x-r);break}return{width:o,height:a,x:h,y:l}}limit_dimensions_to_container(t,e,i,r,n,o){let{width:a,height:h,x:l,y:c}=t;const u=this.dimensions.width-this.borderRegion*2,_=this.dimensions.height-this.borderRegion*2,d=a,f=h,g=this.apply_size_limits(a,h,u,_,o,d/f);a=g.width,h=g.height;const p=this.adjust_position_for_resizing(a,h,e,i,r,n);return l=p.x,c=p.y,this.apply_border_constraints(a,h,l,c,o,d/f)}apply_size_limits(t,e,i,r,n,o){let a=t,h=e;const l=a>i,c=h>r;if(l&&c){const u=i/a,_=r/h;u<_?(a=i,n&&(h=a/o)):(h=r,n&&(a=h*o))}else l?(a=i,n&&(h=a/o)):c&&(h=r,n&&(a=h*o));return{width:a,height:h}}adjust_position_for_resizing(t,e,i,r,n,o){let a=i,h=r;switch(this.active_corner_index){case 0:a=i+n-t,h=r+o-e;break;case 1:h=r+o-e;break;case 2:a=i+n-t;break}if(this.active_edge_index!==-1)switch(this.active_edge_index){case 0:h=r+o-e;break;case 2:a=i+n-t;break}return{x:a,y:h}}apply_border_constraints(t,e,i,r,n,o){const a=this.apply_top_left_constraints(t,e,i,r,n,o),h=this.apply_bottom_right_constraints(a.width,a.height,a.x,a.y,n,o);return h.width=Math.max(20,h.width),h.height=Math.max(20,h.height),h}apply_top_left_constraints(t,e,i,r,n,o){let a=t,h=e,l=i,c=r;return l<this.borderRegion&&((this.active_corner_index===0||this.active_corner_index===2||this.active_edge_index===2)&&(a-=this.borderRegion-l,n&&(h=a/o)),l=this.borderRegion),c<this.borderRegion&&((this.active_corner_index===0||this.active_corner_index===1||this.active_edge_index===0)&&(h-=this.borderRegion-c,n&&(a=h*o)),c=this.borderRegion),{width:a,height:h,x:l,y:c}}apply_bottom_right_constraints(t,e,i,r,n,o){let a=t,h=e,l=i,c=r;if(l+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-l,n&&(h=a/o);else{const _=l+a-(this.dimensions.width-this.borderRegion);l=Math.max(this.borderRegion,l-_)}if(c+h>this.dimensions.height-this.borderRegion)if(this.active_corner_index===2||this.active_corner_index===3||this.active_edge_index===1)h=this.dimensions.height-this.borderRegion-c,n&&(a=h*o);else{const _=c+h-(this.dimensions.height-this.borderRegion);c=Math.max(this.borderRegion,c-_)}return{width:a,height:h,x:l,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 t=this.image_editor_context.background_image;this.current_cursor=t.cursor,t.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 t=this.image_editor_context.background_image;t.cursor=this.current_cursor}this.cleanup_dom_event_listeners()}on(t,e){this.event_callbacks.set(t,[...this.event_callbacks.get(t)||[],e])}off(t,e){this.event_callbacks.set(t,this.event_callbacks.get(t)?.filter(i=>i!==e)||[])}notify(t){for(const e of this.event_callbacks.get(t)||[])e()}set_border_region(t){this.borderRegion=t,this.image_editor_context?.background_image&&(this.image_editor_context.background_image.borderRegion=t),this.resize_ui_container&&this.update_resize_ui(),this.current_subtool==="size"&&this.image_editor_context?.background_image&&this.apply_boundary_constraints()}}
570function yp(s,t){(s instanceof lt||"cursor"in s)&&(s.cursor=t)}function wh(s,t){for(const e of s)yp(e,t),e instanceof lt&&e.children.length>0&&wh(e.children,t)}function xp(s){return s!==null&&window.clearTimeout(s),null}class bp{constructor(t,e,i){this.image_editor_context=t,this.state=e,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 t=this.image_editor_context.app.stage;t.on("pointermove",this._bound_update_cursor),t.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 t=this.image_editor_context.app.stage;this._bound_update_cursor&&(t.off("pointermove",this._bound_update_cursor),this._bound_update_cursor=null),this._bound_check_cursor_over_image&&(t.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=xp(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 lt,this.image_editor_context.ui_container.addChild(this.cursor_container),this.cursor_graphics=new Dt,this.cursor_container.addChild(this.cursor_graphics),this.update_cursor_appearance()}update_cursor_appearance(){if(!this.cursor_graphics)return;this.cursor_graphics.clear();const t=this.state.mode==="draw"?he(this.state.color).toString():16777215;this.cursor_graphics.circle(0,0,this.state.brush_size*this.scale).stroke({width:1.5,color:t,alpha:.8}),this.cursor_graphics.circle(0,0,1).fill({color:t,alpha:.8})}update_cursor_position(t){if(!this.cursor_container)return;const e=this.image_editor_context.image_container.toLocal(t.global),i=this.image_editor_context.ui_container.toLocal(this.image_editor_context.image_container.toGlobal(e));this.cursor_container.position.set(i.x,i.y)}check_cursor_over_image(t){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(),r=this.is_cursor_over_image;this.is_cursor_over_image=t.global.x>=i.x&&t.global.x<=i.x+i.width&&t.global.y>=i.y&&t.global.y<=i.y+i.height,r!==this.is_cursor_over_image&&this.update_cursor_and_preview_visibility()}update_cursor_size(){this.update_cursor_appearance()}set_active(t){this.is_brush_or_erase_active=t,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(t){this.is_preview_visible=t,this.brush_preview_container&&(this.brush_preview_container.visible=t&&this.is_brush_or_erase_active),t&&(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 lt,this.image_editor_context.ui_container.addChild(this.brush_preview_container),this.brush_preview_graphics=new Dt,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 t=this.state.brush_size*this.scale,e=this.state.mode==="draw"?he(this.state.color).setAlpha(this.state.opacity).toString():16777215;this.brush_preview_graphics.circle(0,0,t).fill({color:e,alpha:this.state.mode==="draw"?this.state.opacity:.3}),this.brush_preview_graphics.circle(0,0,t+1).stroke({width:1,color:0,alpha:.5})}update_brush_preview_position(){if(!this.brush_preview_container)return;
570const t=this.image_editor_context.image_container,e=t.width/2,i=t.height/2,r=t.toGlobal({x:e,y:i}),n=this.image_editor_context.ui_container.toLocal(r);this.brush_preview_container.position.set(n.x,n.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(t,e){this.state=t,this.scale=e,this.update_cursor_appearance(),this.is_preview_visible&&this.update_brush_preview()}}class vp{stroke_data;context;original_texture=null;name;constructor(t,e,i){this.name="Draw",this.stroke_data=e,this.context=t,i&&(this.original_texture=this.create_texture_from(i))}create_texture_from(t){const e=Jt.create({width:t.width,height:t.height,resolution:window.devicePixelRatio||1}),i=new kt(t),r=new lt;return r.addChild(i),this.context.app.renderer.render(r,{renderTexture:e}),r.destroy({children:!0}),e}render_stroke_from_data(t,e){const i=t.segments.filter(n=>n.mode==="draw"),r=t.segments.filter(n=>n.mode==="erase");if(i.length>0){const n=new Dt,o=new lt;o.addChild(n);let a=1;for(const c of i){c.opacity<a&&(a=c.opacity);let u=16777215;c.color.startsWith("#")&&(u=parseInt(c.color.replace("#","0x"),16)),n.setFillStyle({color:u,alpha:1}),this.render_segment_to_graphics(n,c)}const h=Jt.create({width:e.width,height:e.height,resolution:window.devicePixelRatio||1}),l=new kt(h);this.context.app.renderer.render({container:o,target:h}),l.alpha=a,this.context.app.renderer.render({container:l,target:e,clear:!1}),o.destroy({children:!0}),l.destroy(),h.destroy()}if(r.length>0){const n=Jt.create({width:e.width,height:e.height,resolution:window.devicePixelRatio||1}),o=new kt(e),a=new lt;a.addChild(o),this.context.app.renderer.render({container:a,target:n,clear:!0});const h=new Dt,l=new lt;l.addChild(h),h.setFillStyle({color:16777215,alpha:1});for(const f of r)this.render_segment_to_graphics(h,f);const c=Jt.create({width:e.width,height:e.height,resolution:window.devicePixelRatio||1});this.context.app.renderer.render({container:l,target:c,clear:!0});const u=new kt(n),_=new kt(c),d=new lt;d.addChild(u),d.setMask({mask:_,inverse:!0}),this.context.app.renderer.render({container:d,target:e,clear:!0}),a.destroy({children:!0}),l.destroy({children:!0}),d.destroy({children:!0}),n.destroy(),c.destroy()}}render_segment_to_graphics(t,e){const i=Math.sqrt(Math.pow(e.to_x-e.from_x,2)+Math.pow(e.to_y-e.from_y,2));if(i<.1)t.circle(e.from_x,e.from_y,e.size).fill();else{const r=Math.max(e.size/3,2),n=Math.max(Math.ceil(i/r),2);for(let o=0;o<n;o++){const a=o/(n-1),h=e.from_x+(e.to_x-e.from_x)*a,l=e.from_y+(e.to_y-e.from_y)*a;t.circle(h,l,e.size).fill()}}}async execute(t){t&&(this.context=t);let e=this.context.layer_manager.get_layer_textures(this.stroke_data.layer_id);if(!e){const h=this.context.layer_manager.get_layers(),l=h[h.length-1];e=this.context.layer_manager.get_layer_textures(l.id)}if(!e)return;const i=Jt.create({width:e.draw.width,height:e.draw.height,resolution:window.devicePixelRatio||1}),r=new kt(e.draw),n=new lt;n.addChild(r),this.context.app.renderer.render({container:n,target:i,clear:!0}),n.destroy({children:!0}),this.render_stroke_from_data(this.stroke_data,i);const o=new kt(i),a=new lt;a.addChild(o),this.context.app.renderer.render({container:a,target:e.draw,clear:!0}),a.destroy({children:!0}),i.destroy()}async undo(){if(!this.original_texture)return;const t=this.context.layer_manager.get_layer_textures(this.stroke_data.layer_id);if(!t)return;const e=new kt(this.original_texture),i=new lt;i.addChild(e),this.context.app.renderer.render({container:i,target:t.draw,clear:!0}),i.destroy({children:!0})}}class wp{stroke_texture=null;erase_texture=null;display_container=null;stroke_container=null;stroke_graphics=null;preview_sprite=null;erase_graphics=null;dimensions;image_editor_context;app;is_new_stroke=!0;current_opacity=1;original_layer_texture=null;active_layer_id=null;current_stroke_segments=[];constructor(t,e){this.image_editor_context=t,this.app=e,this.dimensions={width:this.image_editor_context.
570image_container.width,height:this.image_editor_context.image_container.height}}initialize_textures(){this.cleanup_textures();const t=this.image_editor_context.image_container.getLocalBounds();this.dimensions={width:t.width,height:t.height},this.stroke_texture=Jt.create({width:this.dimensions.width,height:this.dimensions.height,resolution:window.devicePixelRatio||1}),this.erase_texture=Jt.create({width:this.dimensions.width,height:this.dimensions.height,resolution:window.devicePixelRatio||1}),this.display_container=new lt,this.image_editor_context.image_container.addChild(this.display_container),this.stroke_container=new lt,this.stroke_graphics=new Dt,this.stroke_container.addChild(this.stroke_graphics),this.erase_graphics=new Dt,this.preview_sprite=new kt(this.stroke_texture),this.preview_sprite.alpha=0,this.display_container.addChild(this.preview_sprite);const e=new lt;this.app.renderer.render(e,{renderTexture:this.stroke_texture}),this.app.renderer.render(e,{renderTexture:this.erase_texture}),e.destroy(),this.is_new_stroke=!0,this.current_opacity=1}reinitialize(){const t=this.image_editor_context.image_container.getLocalBounds();(Math.round(t.width)!==Math.round(this.dimensions.width)||Math.round(t.height)!==Math.round(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.original_layer_texture&&(this.original_layer_texture.destroy(),this.original_layer_texture=null),this.stroke_container=null,this.stroke_graphics=null,this.preview_sprite=null,this.erase_graphics=null,this.active_layer_id=null}preserve_canvas_state(){const t=this.image_editor_context.layer_manager.get_active_layer();if(!t)return;const i=this.image_editor_context.layer_manager.get_layers().find(a=>a.container===t);if(!i)return;this.active_layer_id=i.id;const r=this.image_editor_context.layer_manager.get_layer_textures(i.id);if(!r)return;this.original_layer_texture&&this.original_layer_texture.destroy(),this.original_layer_texture=Jt.create({width:this.dimensions.width,height:this.dimensions.height,resolution:window.devicePixelRatio||1});const n=new kt(r.draw),o=new lt;o.addChild(n),this.app.renderer.render(o,{renderTexture:this.original_layer_texture}),o.destroy({children:!0}),this.is_new_stroke=!0}reset_eraser_mask(){!this.erase_graphics||!this.erase_texture||(this.erase_graphics.clear(),this.erase_graphics.setFillStyle({color:16777215,alpha:1}),this.erase_graphics.rect(0,0,this.dimensions.width,this.dimensions.height).fill(),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||!this.original_layer_texture||!this.active_layer_id)return;this.preview_sprite.visible=!1;const t=this.image_editor_context.layer_manager.get_active_layer();if(!t)return;const i=this.image_editor_context.layer_manager.get_layers().find(h=>h.container===t);if(!i||i.id!==this.active_layer_id||!this.image_editor_context.layer_manager.get_layer_textures(i.id))return;const n={segments:[...this.current_stroke_segments],layer_id:this.active_layer_id},o=new vp(this.image_editor_context,n,this.original_layer_texture);this.stroke_graphics&&this.stroke_graphics.clear();const a=new lt;this.app.renderer.render(a,{renderTexture:this.stroke_texture}),a.destroy(),this.is_new_stroke=!0,this.original_layer_texture=null,this.active_layer_id=null,this.current_stroke_segments=[],this.image_editor_context.command_manager.execute(o,this.image_editor_context)}calculate_distance(t,e,i,r){return Math.sqrt(Math.pow(i-t,2)+Math.pow(r-e,2))}draw_segment(t,e,i,r,n,o,a,h){if(!this.stroke_graphics||!this.stroke_texture||!this.stroke_container||!this.preview_sprite)return;this.is_new_stroke&&!this.original_layer_texture&&this.preserve_canvas_state(),this.current_opacity=h==="draw"?Math.min(Math.max(a,0),1):.5;const l=n;if(this.is_new_stroke){this.stroke_graphics.clear(),this.current_stroke_segments=[];const u=new lt;this.app.renderer.render(u,{renderTexture:this.stroke_texture}),u.destroy(),this.is_new_stroke=!1}if(this.current_stroke_segments.push({from_x:t,from_y:e,to_x:i,to_y:r,size:l,color:o,opacity:this.current_opacity,mode:h}),h==="draw"){let u=16777215;try{o.startsWith("#")&&(u=parseInt(o.replace("#","0x"),16))}catch{u=16777215}this.stroke_graphics.setFillStyle({color:u,alpha:1})}
570else this.stroke_graphics.setFillStyle({color:16777215,alpha:1});const c=this.calculate_distance(t,e,i,r);if(c<.1)this.stroke_graphics.circle(t,e,l).fill();else{const u=Math.max(l/3,2),_=Math.max(Math.ceil(c/u),2);for(let d=0;d<_;d++){const f=d/(_-1),g=t+(i-t)*f,p=e+(r-e)*f;this.stroke_graphics.circle(g,p,l).fill()}}if(this.stroke_graphics.endFill(),this.app.renderer.render(this.stroke_container,{renderTexture:this.stroke_texture}),h==="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 d=this.image_editor_context.layer_manager.get_layers().find(C=>C.container===u);if(!d)return;const f=this.image_editor_context.layer_manager.get_layer_textures(d.id);if(!f)return;const g=Jt.create({width:this.dimensions.width,height:this.dimensions.height,resolution:window.devicePixelRatio||1}),p=new lt,y=new kt(f.draw);p.addChild(y),this.app.renderer.render(p,{renderTexture:g}),p.destroy({children:!0});const x=new lt,v=new kt(this.stroke_texture),b=new Dt;b.setFillStyle({color:16777215,alpha:.5}),b.rect(0,0,this.dimensions.width,this.dimensions.height).fill(),b.setMask({mask:v,inverse:!1}),x.addChild(b),this.app.renderer.render(x,{renderTexture:g}),this.preview_sprite.texture=g,this.preview_sprite.alpha=1,x.destroy({children:!0}),g.destroy()}this.preview_sprite.visible=!0}get_dimensions(){return this.dimensions}get textures_initialized(){return!!(this.stroke_texture&&this.display_container&&this.preview_sprite)}cleanup(){this.cleanup_textures()}}class kp{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(t,e,i){this.image_editor_context=t,this.current_tool=e,this.current_subtool=i,this.state.mode=e==="erase"?"erase":"draw",this.state.mode==="draw"?this.state.brush_size=this.brush_size:this.state.brush_size=this.eraser_size,t.scale.subscribe(r=>{this.scale=r,this.brush_cursor&&this.brush_cursor.update_state(this.state,this.scale)}),this.brush_cursor=new bp(this.image_editor_context,this.state,this.scale),this.brush_cursor.set_active(e==="draw"||e==="erase"),this.brush_textures=new wp(this.image_editor_context,t.app),this.brush_textures.initialize_textures(),this.setup_event_listeners(),this.handle_cursors(e)}handle_cursors(t){wh(this.image_editor_context.image_container.children,"none")}set_tool(t,e){if(this.current_tool=t,this.current_subtool=e,this.current_tool!=="erase"&&this.current_tool!=="draw"&&this.commit_pending_changes(),this.brush_cursor){const h=t==="draw"||t==="erase";this.brush_cursor.set_active(h)}const i=t==="erase"?"erase":"draw",r=this.state.mode!==i,n=t==="erase"||t==="draw",o=this.brush_textures?.textures_initialized??!1;let a=!1;if(this.brush_textures&&o){const h=this.image_editor_context.image_container.getLocalBounds(),l=this.brush_textures.get_dimensions();a=Math.round(h.width)!==Math.round(l.width)||Math.round(h.height)!==Math.round(l.height)}n&&(r||!o||a)&&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(t){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(t.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)}
570on_pointer_move(t){if(this.brush_cursor&&this.brush_cursor.update_cursor_position(t),!this.is_drawing)return;const e=this.image_editor_context.image_container.toLocal(t.global);this.brush_textures&&this.brush_textures.draw_segment(this.last_x,this.last_y,e.x,e.y,this.state.brush_size,this.state.color,this.state.opacity,this.state.mode),this.last_x=e.x,this.last_y=e.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 t=this.image_editor_context.image_container;t.eventMode="static",t.interactiveChildren=!0;const e=this.image_editor_context.app.stage;e.eventMode="static",e.on("pointerdown",this._bound_pointer_down),e.on("pointermove",this._bound_pointer_move),e.on("pointerup",this._bound_pointer_up),e.on("pointerupoutside",this._bound_pointer_up),this.brush_cursor&&this.brush_cursor.setup_event_listeners()}cleanup_event_listeners(){const t=this.image_editor_context.app.stage;this._bound_pointer_down&&(t.off("pointerdown",this._bound_pointer_down),this._bound_pointer_down=null),this._bound_pointer_move&&(t.off("pointermove",this._bound_pointer_move),this._bound_pointer_move=null),this._bound_pointer_up&&(t.off("pointerup",this._bound_pointer_up),t.off("pointerupoutside",this._bound_pointer_up),this._bound_pointer_up=null),this.brush_cursor&&this.brush_cursor.cleanup_event_listeners()}set_brush_size(t){this.brush_size=t,this.state.mode==="draw"&&(this.state.brush_size=t,this.brush_cursor&&this.brush_cursor.update_state(this.state,this.scale))}set_brush_color(t){const e=he(t).toHexString();this.state.color=e,this.brush_cursor&&this.brush_cursor.update_state(this.state,this.scale)}set_brush_opacity(t){const e=Math.max(0,Math.min(1,t));this.state.opacity=e,this.brush_cursor&&this.brush_cursor.update_state(this.state,this.scale)}set_eraser_size(t){this.eraser_size=t,this.state.mode==="erase"&&(this.state.brush_size=t,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(t){this.brush_cursor&&this.brush_cursor.preview_brush(t)}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(t,e){this.event_callbacks.set(t,[...this.event_callbacks.get(t)||[],e])}off(t,e){this.event_callbacks.set(t,this.event_callbacks.get(t)?.filter(i=>i!==e)||[])}notify(t){for(const e of this.event_callbacks.get(t)||[])e()}}var Ap=nt('<div class="svelte-189k4ah"><!> <!> <!></div>'),Sp=nt('<li class="svelte-189k4ah"><!> <button> </button> <!></li>'),Cp=nt('<li class="add-layer svelte-189k4ah"><!></li>'),Mp=nt('<ul class="svelte-189k4ah"><!> <!></ul>'),Tp=nt('<div><button class="layer-title-button svelte-189k4ah" aria-label="Show Layers"> <span class="icon svelte-189k4ah"><!></span></button> <!></div>');function Pp(s,t){ce(t,!1);const e=()=>Lh(o(),"$layers",i),[i,r]=Bh(),n=Oe();let o=z(t,"layers",12),a=z(t,"enable_additional_layers",12,!0),h=z(t,"enable_layers",12,!0),l=z(t,"show_layers",12,!1);function c(){n("new_layer")}function u(v){n("change_layer",v),l(!1)}function _(v,b){n("move_layer",{id:v,direction:b})}function d(v){n("delete_layer",v)}var f={get layers(){return o()},set layers(v){o(v),I()},get enable_additional_layers(){return a()},set enable_additional_layers(v){a(v),I()},get enable_layers(){return h()},set enable_layers(v){h(v),I()},get show_layers(){return l()},set show_layers(v){l(v),I()}};ve();var g=ci(),p=qt(g);{var y=v=>{var b=Tp();let C;var w=it(b),k=it(w),R=q(k),S=it(R);gl(S),tt(R),tt(w);var P=q(w,2);{var F=G=>{var N=Mp(),B=it(N);Bi(B,1,()=>(e(),Rt(()=>e().layers)),Li,(D,gt,M)=>{let T=()=>m(gt).id,st=()=>m(gt).name,U=()=>m(gt).user_created,rt=()=>m(gt).visible;var xt=Sp(),K=it(xt);{var mt=et=>{ie(et,{get Icon(){return Al},size:"small",onclick:ct=>{ct.stopPropagation(),n("toggle_layer_visibility",T())}})}
570,ot=et=>{ie(et,{get Icon(){return wl},size:"small",onclick:ct=>{ct.stopPropagation(),n("toggle_layer_visibility",T())}})};Q(K,et=>{rt()?et(ot,!1):et(mt)})}var ut=q(K,2);Ue(ut,"aria-label",`layer-${M+1}`);let O;var J=it(ut,!0);tt(ut);var Tt=q(ut,2);{var E=et=>{var ct=Ap(),at=it(ct);{var ft=Ft=>{ie(Ft,{onclick:vt=>{vt.stopPropagation(),_(T(),"up")},get Icon(){return Kh},size:"x-small"})};Q(at,Ft=>{M>0&&Ft(ft)})}var Et=q(at,2);{var Ut=Ft=>{ie(Ft,{onclick:vt=>{vt.stopPropagation(),_(T(),"down")},get Icon(){return rl},size:"x-small"})};Q(Et,Ft=>{e(),Rt(()=>M<e().layers.length-1)&&Ft(Ut)})}var bt=q(Et,2);{var Nt=Ft=>{ie(Ft,{onclick:vt=>{vt.stopPropagation(),d(T())},get Icon(){return Zh},size:"x-small"})};Q(bt,Ft=>{e(),U(),Rt(()=>e().layers.length>1&&U())&&Ft(Nt)})}tt(ct),H(et,ct)};Q(Tt,et=>{e(),Rt(()=>e().layers.length>1)&&et(E)})}tt(xt),Wt(()=>{O=re(ut,1,"svelte-189k4ah",null,O,{selected_layer:e().active_layer===T()}),Fe(J,st())}),jt("click",ut,gs(()=>u(T()))),H(D,xt)});var V=q(B,2);{var L=D=>{var gt=Cp(),M=it(gt);ie(M,{get Icon(){return Xo},label:"Add Layer",onclick:T=>{T.stopPropagation(),c()},size:"x-small"}),tt(gt),H(D,gt)};Q(V,D=>{a()&&D(L)})}tt(N),H(G,N)};Q(P,G=>{l()&&G(F)})}tt(b),As(b,(G,N)=>Kr?.(G,N),()=>()=>l(!1)),Wt(G=>{C=re(b,1,"layer-wrap svelte-189k4ah",null,C,{closed:!l()}),Fe(k,`${G??""} `)},[()=>(Y(l()),e(),Rt(()=>l()?"Layers":e().layers.find(G=>G.id===e().active_layer)?.name))]),jt("click",w,gs(()=>l(!l()))),H(v,b)};Q(p,v=>{h()&&v(y)})}H(s,g);var x=ue(f);return r(),x}var zp=nt('<div class="toolbar-wrap-wrap svelte-1357rcu"><div class="toolbar-wrap svelte-1357rcu"><!></div></div>');function Ip(s,t){ce(t,!1);let e=z(t,"layers",12),i=z(t,"enable_additional_layers",12,!0),r=z(t,"enable_layers",12,!0),n=z(t,"show_layers",12,!1);var o={get layers(){return e()},set layers(u){e(u),I()},get enable_additional_layers(){return i()},set enable_additional_layers(u){i(u),I()},get enable_layers(){return r()},set enable_layers(u){r(u),I()},get show_layers(){return n()},set show_layers(u){n(u),I()}},a=zp(),h=it(a),l=it(h);{var c=u=>{Pp(u,{get layers(){return e()},get enable_additional_layers(){return i()},get enable_layers(){return r()},get show_layers(){return n()},$$events:{new_layer(_){fe.call(this,t,_)},change_layer(_){fe.call(this,t,_)},move_layer(_){fe.call(this,t,_)},delete_layer(_){fe.call(this,t,_)},toggle_layer_visibility(_){fe.call(this,t,_)}}})};Q(l,u=>{r()&&u(c)})}return tt(h),tt(a),H(s,a),ue(o)}var Ep=nt('<li class="svelte-o0h5ih"><button class="svelte-o0h5ih"> </button></li>'),Rp=nt('<div class="zoom-controls svelte-o0h5ih"><ul class="svelte-o0h5ih"><li class="svelte-o0h5ih"><button class="svelte-o0h5ih">Fit to screen</button></li> <!></ul></div>'),Fp=nt('<!> <!> <!> <!> <div class="zoom-number svelte-o0h5ih"><span role="button" tabindex="0" class="svelte-o0h5ih"> </span> <!></div> <div class="separator svelte-o0h5ih"></div> <!> <!> <!> <!>',1);function Bp(s,t){ce(t,!1);const e=Z();let i=z(t,"can_save",12,!1),r=z(t,"changeable",12,!1),n=z(t,"current_zoom",12,1),o=z(t,"tool",12),a=z(t,"min_zoom",12,!0),h=z(t,"enable_download",12,!1),l=z(t,"can_undo",12),c=z(t,"can_redo",12);const u=Oe();let _=Z(!1);function d(y){y.stopPropagation(),W(_,!m(_))}function f(y){u("set_zoom",y),W(_,!1)}function g(y){y.key==="Enter"&&f(n())}yt(()=>Y(n()),()=>{W(e,Math.round(n()*100))}),Le();var p={get can_save(){return i()},set can_save(y){i(y),I()},get changeable(){return r()},set changeable(y){r(y),I()},get current_zoom(){return n()},set current_zoom(y){n(y),I()},get tool(){return o()},set tool(y){o(y),I()},get min_zoom(){return a()},set min_zoom(y){a(y),I()},get enable_download(){return h()},set enable_download(y){h(y),I()},get can_undo(){return l()},set can_undo(y){l(y),I()},get can_redo(){return c()},set can_redo(y){c(y),I()}};return ve(),el(s,{children:(y,x)=>{var v=Fp(),b=qt(v);{var C=M=>{ie(M,{get Icon(){return Qh},label:"Download",onclick:T=>{u("download"),T.stopPropagation()}})};Q(b,M=>{h()&&M(C)})}var w=q(b,2);{let M=Gt(()=>o()==="pan");ie(w,{get Icon(){return yl},label:"Pan",onclick:T=>{T.stopPropagation(),u("pan")},get highlight(){return m(M)},size:"small",padded:!1,transparent:!0,get disabled(){return a()}})}var k=q(w,2);ie(k,{get Icon(){return zl},label:"Zoom out",onclick:M=>{u("zoom_out"),M.stopPropagation()}});var R=q(k,2);ie(R,{get Icon(){return Tl},label:"Zoom in",onclick:M=>{u("zoom_in"),M.stopPropagation()}});var S=q(R,2),P=it(S),F=it(P);tt(P);var G=q(P,2);{var N=M=>{var T=Rp(),st=it(T),U=it(st),rt=it(U);tt(U);var xt=q(U,2);Bi(xt,0,()=>[.25,.5,1,2,4],Li,(K,mt)=>{var ot=Ep(),ut=it(ot),O=it(ut);tt(ut),tt(ot),Wt(()=>Fe(O,`${mt*100}%`)),jt("click",ut,gs(()=>f(mt))),H(K,ot)}),tt(st),tt(T),jt("click",rt,gs(()=>f("fit"))),H(M,T)};Q(G,M=>{m(_)&&M(N)})}tt(S);var B=q(S,4);{let M=Gt(()=>!l());ie(B,{get Icon(){return tl},label:"Undo",onclick:T=>{u("undo"),T.stopPropagation()},get disabled(){return m(M)}})}var V=q(B,2);{let M=Gt(()=>!c());ie(V,{get Icon(){return bl},label:"Redo",onclick:T=>{u("redo"),T.stopPropagation()},get disabled(){return m(M)}})}var L=q(V,2);{var D=M=>{{let T=Gt(()=>!i());ie(M,{get disabled(){return m(T)},get Icon(){return Yo},label:"Save changes",onclick:st=>{u("save"),st.stopPropagation()},color:"var(--color-accent)"})}};Q(L,M=>{r()&&M(D)})}var gt=q(L,2);ie(gt,{get Icon(){return Jh},label:"Clear canvas",onclick:M=>{u("remove_image"),M.stopPropagation()}}),Wt(()=>Fe(F,`${m(e)??""}%`)),jt("click",P,d),jt("keydown",P,g),H(y,v)},$$slots:{default:!0}}),ue(p)}var Lp=nt('<div class="modal svelte-6fnl1z"><div class="modal-inner svelte-6fnl1z"><!></div></div>'),Op=nt("<!> <!> <!> <!>",1),Gp=nt('<div class="crop-confirm-button svelte-6fnl1z"><!></div>'),Dp=nt('<div data-testid="image" aria-dropeffect="copy"><!> <div></div> <div></div> <!> <!></div>');function Up(s,t){ce(t,!1);const e=Z(),{drag:i,open_file_upload:r}=Yh(),n=Oe(),o=!0;let a=z(t,"changeable",12,!1),h=z(t,"sources",28,()=>["upload","webcam","clipboard"]),l=z(t,"transforms",28,()=>["crop","resize"]),c=z(t,"canvas_size",12),u=z(t,"is_dragging",12,!1),_=z(t,"background_image",12,!1),d=z(t,"brush_options",12),f=z(t,"eraser_options",12),g=z(t,"fixed_canvas",12,!1),p=z(t,"root",12),y=z(t,"i18n",12),x=z(t,"upload",12),v=z(t,"composite",12),b=z(t,"layers",12),C=z(t,"background",12),w=z(t,"border_region",12,0),k=z(t,"layer_options",12),R=z(t,"current_tool",12),S=z(t,"webcam_options",12),P=z(t,"show_download_button",12,!1),F=z(t,"theme_mode",12),G=z(t,"full_history",12,null),N=Z(),B=Z();function V(){!m(T)||!m(ut)||(m(T).set_tool(R()),m(T).set_subtool(m(At)))}function L(A){!m(T)||!m(ut)||(A.layers.length>0&&!A.active_layer&&m(T).set_layer(A.layers[0].id),R()&&(m(T).set_tool(R()),m(At)&&m(T).set_subtool(m(At))),m(K)&&(R()==="draw"||R()==="erase")&&m(K).set_tool(R(),m(At)))}function D(){return k()&&m(T)&&m(ut)}let gt=z(t,"has_drawn",12,!1);async function M(){return m(T)?!_()&&!gt()&&!b().length?{background:null,layers:[],composite:null}:await m(T).get_blobs():{background:null,layers:[],composite:null}}let T=Z();function st(A){m(T).add_image({image:A})}let U;async function rt(A){if(!m(T)||!A||!D())return;let j;if(typeof A=="string")j=A;else if(A?.meta?._type==="gradio.FileData"&&A?.url)j=A.url;else{console.warn("Invalid source provided to add_image_from_url:",A);return}try{U=m(T).add_image_from_url(j);let Xt=et.add_image_from_url(j);await Promise.all([U,Xt]),et.set_tool("image"),et.set_subtool("crop"),_(!0),m(mt).set_zoom("fit"),n("upload"),n("input")}catch(Xt){console.error("Error adding image from URL:",Xt)}}async function xt(A){if(!(!m(T)||!A.length||!D())&&Array.isArray(A)&&A.every(j=>j?.meta?._type==="gradio.FileData"))try{await U,await m(T).add_layers_from_url(A.map(j=>j.url)),n("change"),n("input")}catch(j){console.error("Error adding layer from URL:",j)}}let K=Z(),mt=Z(),ot=Z(1),ut=Z(!1),O=Z(!0),J={width:0,height:0};
570async function Tt(){if(!m(T)||!m(ut)||!m(mt))return;if(await xr(),m(N).offsetParent!==null){const j=m(N).getBoundingClientRect();(j.width!==J.width||j.height!==J.height)&&(m(mt).set_zoom("fit"),J={width:j.width,height:j.height})}}Wo(()=>{let A,j;return Et().then(()=>{A=new IntersectionObserver(()=>{Tt()}),j=new ResizeObserver(()=>{Tt()}),A.observe(m(N)),j.observe(m(N)),setTimeout(()=>{G()&&m(T)&&m(T).command_manager.replay(G(),m(T).context).then(()=>{E()})},0)}),typeof window<"u"&&(window.editor=m(T)),()=>{A&&A.disconnect(),j&&j.disconnect(),m(T)&&m(T).destroy()}});function E(){if(!m(T)||!m(ut))return;const A=Ne(m(T).layers);A.layers.length>0&&!A.active_layer&&m(T).set_layer(A.layers[0].id),R()&&(m(T).set_tool(R()),m(At)&&m(T).set_subtool(m(At))),m(K)&&(R()==="draw"||R()==="erase")&&m(K).set_tool(R(),m(At)),G(m(T).command_manager.history)}let et,ct=Z(),at=z(t,"can_undo",12,!1),ft=Z(!1);async function Et(){W(K,new kp),W(mt,new qr),W(T,new $r({target_element:m(N),width:c()[0],height:c()[1],tools:["image",m(mt),new mp,m(K)],fixed_canvas:g(),border_region:w(),layer_options:k(),theme_mode:F()})),m(K).on("change",()=>{gt(!0)}),W(ct,new qr),et=new $r({target_element:m(B),width:c()[0],height:c()[1],tools:["image",m(ct),new pp],dark:!0,fixed_canvas:!1,border_region:0,pad_bottom:40}),m(T).scale.subscribe(A=>{W(ot,A)}),m(T).min_zoom.subscribe(A=>{W(O,A)}),m(T).dimensions.subscribe(A=>{J={...A}}),m(T).command_manager.current_history.subscribe(A=>{at(A.previous!==null),W(ft,A.next!==null)}),await Promise.all([m(T).ready,et.ready]).then(()=>{bt({tool:"image"}),W(ut,!0),h().length>0?bt({tool:"image"}):bt({tool:"draw"}),et.set_subtool("crop")}),m(T).on("change",()=>{n("change"),n("input"),G(m(T).command_manager.history)}),C()||b().length>0?(C()&&await rt(C()),b().length>0&&await xt(b()),bt({tool:"draw"})):v()&&(await rt(v()),bt({tool:"draw"})),V()}async function Ut(A){if(A==null||!h().includes("upload"))return;m(T).reset_canvas();const j=Array.isArray(A)?A[0]:A;await m(T).add_image({image:j}),await et.add_image({image:j}),et.reset(),_(!0),m(mt).set_zoom("fit"),bt({tool:"draw"}),n("upload")}function bt({tool:A}){m(T).set_tool(A),R(A),A==="image"&&(et.set_tool("image"),et.set_subtool("crop"))}function Nt({tool:A,subtool:j}){m(T).set_subtool(j),W(At,j),j!==null&&(A==="draw"&&(j==="size"?W(Hi,!0):j==="color"&&W(Vi,!0)),A==="erase"&&j==="size"&&W(Ft,!0),A==="image"&&j==="paste"&&Is(),A==="image"&&j==="upload"&&xr().then(()=>{W(e,!1),r()}))}let Ft=Z(!1),vt=Z(),ee=Z(),Zt=Z(1),Vt=Z();function Ge(){const A=d().default_color==="auto"?d().colors[0]:d().default_color;if(Array.isArray(A))W(vt,A[0]),W(Zt,A[1]);else{W(vt,A);const j=he(A);j.getAlpha()<1?W(Zt,j.getAlpha()):W(Zt,1)}W(ee,typeof d().default_size=="number"?d().default_size:25)}function zs(){W(Vt,f().default_size==="auto"?25:f().default_size)}let Hi=Z(!1),Vi=Z(!1),At=Z(null),Ce=Z(!1);function Xi(A){m(mt).set_zoom(A)}function Yi(A){m(mt).set_zoom(A==="in"?m(ot)+(m(ot)<1?.1:m(ot)*.1):m(ot)-(m(ot)<1?.1:m(ot)*.1))}async function Is(){const A=await navigator.clipboard.read();for(let j=0;j<A.length;j++){const Xt=A[j].types.find(Pe=>Pe.startsWith("image/"));if(Xt){const Pe=await A[j].getType(Xt);Ut(Pe)}}}function Es(A){A.detail!==null&&Ut(A.detail),Nt({tool:R(),subtool:null})}function Me(){n("save")}async function Te(){const{image:A}=await et.get_crop_bounds();A&&(await m(T).add_image({image:A,resize:!1}),Nt({tool:"image",subtool:null}),n("change"),n("input"))}async function yi(){const j=(await m(T).get_blobs()).composite;if(!j){n("download_error","Unable to generate image to download.");return}const Xt=URL.createObjectURL(j),Pe=document.createElement("a");Pe.href=Xt,Pe.download="image.png",Pe.click(),URL.revokeObjectURL(Xt)}function kh(){m(T).undo()}function Ah(){m(T).redo()}let Rs=Z(C());yt(()=>(Y(k()),m(T)),()=>{k()&&D()&&(m(T).set_layer_options(k()),V())}),yt(()=>(m(T),m(ut),Ne),()=>{if(m(T)&&m(ut)&&m(T).layers){const A=Ne(m(T).layers);A.layers.length>0&&!A.active_layer&&L(A)}}),yt(()=>(Y(C()),Y(b()),Y(v()),m(T),m(ut),m(mt)),()=>{C()==null&&b().length==0&&v()==null&&m(T)&&m(ut)&&(m(T).reset_canvas(),m(mt).set_zoom("fit"),bt({tool:"image"}),_(!1),gt(!1))}),yt(()=>(m(Rs),Y(C())),()=>{m(Rs)!==C()&&(bt({tool:"draw"}),Nt({tool:"draw",subtool:null}),R("draw"),W(Rs,C()))}),yt(()=>(Y(R()),m(At),m(ct)),()=>{R()==="image"&&m(At)==="crop"&&m(ct).set_zoom("fit")}),yt(()=>(Y(at()),m(T)),()=>{_(at()&&m(T).command_manager.contains("AddImage"))}),yt(()=>(Y(d()),Y(f())),()=>{d()&&Ge(),f()&&zs()}),yt(()=>(m(K),m(vt),Y(d())),()=>{m(K)?.set_brush_color((()=>{let A;if(m(vt)==="auto"){const j=d().colors.find(Xt=>Array.isArray(Xt)?Xt[0]===d().default_color:Xt===d().default_color)||d().colors[0];A=Array.isArray(j)?j[0]:j}else A=m(vt);return A})())}),yt(()=>(m(K),m(ee)),()=>{m(K)?.set_brush_size(typeof m(ee)=="number"?m(ee):25)}),yt(()=>(m(K),m(Vt)),()=>{m(K)?.set_eraser_size(typeof m(Vt)=="number"?m(Vt):25)}),yt(()=>(Y(R()),Y(_()),m(At),Y(h())),()=>{W(e,R()!=="image"||R()==="image"&&_()||R()==="image"&&m(At)==="webcam"||!h().includes("upload"))}),yt(()=>(m(K),m(Ce)),()=>{m(K)?.preview_brush(m(Ce))}),yt(()=>(m(K),m(Zt)),()=>{m(K)?.set_brush_opacity(m(Zt))}),yt(()=>(Y(v()),Y(C())),()=>{rt(v()||C())}),yt(()=>Y(b()),()=>{xt(b())}),Le();var Sh={antialias:o,get_blobs:M,add_image:st,add_image_from_url:rt,add_layers_from_url:xt,get changeable(){return a()},set changeable(A){a(A),I()},get sources(){return h()},set sources(A){h(A),I()},get transforms(){return l()},set transforms(A){l(A),I()},get canvas_size(){return c()},set canvas_size(A){c(A),I()},get is_dragging(){return u()},set is_dragging(A){u(A),I()},get background_image(){return _()},set background_image(A){_(A),I()},get brush_options(){return d()},set brush_options(A){d(A),I()},get eraser_options(){return f()},set eraser_options(A){f(A),I()},get fixed_canvas(){return g()},set fixed_canvas(A){g(A),I()},get root(){return p()},set root(A){p(A),I()},get i18n(){return y()},set i18n(A){y(A),I()},get upload(){return x()},set upload(A){x(A),I()},get composite(){return v()},set composite(A){v(A),I()},get layers(){return b()},set layers(A){b(A),I()},get background(){return C()},set background(A){C(A),I()},get border_region(){return w()},set border_region(A){w(A),I()},get layer_options(){return k()},set layer_options(A){k(A),I()},get current_tool(){return R()},set current_tool(A){R(A),I()},get webcam_options(){return S()},set webcam_options(A){S(A),I()},get show_download_button(){return P()},set show_download_button(A){P(A),I()},get theme_mode(){return F()},set theme_mode(A){F(A),I()},get full_history(){return G()},set full_history(A){G(A),I()},get has_drawn(){return gt()},set has_drawn(A){gt(A),I()},get can_undo(){return at()},set can_undo(A){at(A),I()}};ve();var ei=Dp();let cn;Ue(ei,"aria-label","Click to upload or drop files");var un=it(ei);{var Ch=A=>{var j=Op(),Xt=qt(j);{var Pe=Qt=>{Bp(Qt,{get changeable(){return a()},get min_zoom(){return m(O)},get current_zoom(){return m(ot)},get tool(){return R()},can_save:!0,get enable_download(){return P()},get can_undo(){return at()},get can_redo(){return m(ft)},$$events:{set_zoom:St=>Xi(St.detail),zoom_in:()=>Yi("in"),zoom_out:()=>Yi("out"),remove_image:()=>{n("clear"),m(T).reset_canvas(),bt({tool:"image"}),_(!1),gt(!1)},save:Me,pan:St=>{bt({tool:"pan"})},download:()=>yi(),undo:kh,redo:Ah}})};Q(Xt,Qt=>{m(At)!=="crop"&&Qt(Pe)})}var pn=q(Xt,2);{var Ph=Qt=>
570{jf(Qt,{get sources(){return h()},get transforms(){return l()},get background(){return _()},get show_brush_size(){return m(Hi)},get show_brush_color(){return m(Vi)},get show_eraser_size(){return m(Ft)},get brush_options(){return d()},get eraser_options(){return f()},get tool(){return R()},get subtool(){return m(At)},get selected_color(){return m(vt)},set selected_color(St){W(vt,St)},get selected_size(){return m(ee)},set selected_size(St){W(ee,St)},get selected_eraser_size(){return m(Vt)},set selected_eraser_size(St){W(Vt,St)},get selected_opacity(){return m(Zt)},set selected_opacity(St){W(Zt,St)},get preview(){return m(Ce)},set preview(St){W(Ce,St)},$$events:{tool_change:St=>bt(St.detail),subtool_change:St=>Nt(St.detail)},$$legacy:!0})};Q(pn,Qt=>{m(At)!=="crop"&&Qt(Ph)})}var gn=q(pn,2);{var zh=Qt=>{var St=Lp(),mn=it(St),Rh=it(mn);jh(Rh,{get upload(){return x()},get root(){return p()},streaming:!1,mode:"image",include_audio:!1,get i18n(){return y()},get mirror_webcam(){return Y(S()),Rt(()=>S().mirror)},get webcam_constraints(){return Y(S()),Rt(()=>S().constraints)},$$events:{capture:Es,error(Ls){fe.call(this,t,Ls)},drag(Ls){fe.call(this,t,Ls)}}}),tt(mn),tt(St),H(Qt,St)};Q(gn,Qt=>{R()==="image"&&m(At)==="webcam"&&Qt(zh)})}var Ih=q(gn,2);{var Eh=Qt=>{Ip(Qt,{get enable_additional_layers(){return Y(k()),Rt(()=>k().allow_additional_layers)},get layers(){return m(T),Rt(()=>m(T).layers)},$$events:{new_layer:()=>{m(T).add_layer()},change_layer:St=>{m(T).set_layer(St.detail),R()==="draw"&&bt({tool:"draw"})},move_layer:St=>{m(T).move_layer(St.detail.id,St.detail.direction)},delete_layer:St=>{m(T).delete_layer(St.detail)},toggle_layer_visibility:St=>{m(T).toggle_layer_visibility(St.detail)}}})};Q(Ih,Qt=>{m(At),Y(k()),Rt(()=>m(At)!=="crop"&&!k().disabled)&&Qt(Eh)})}H(A,j)};Q(un,A=>{m(ut)&&A(Ch)})}var Fs=q(un,2);let dn;Qe(Fs,A=>W(N,A),()=>m(N));var Bs=q(Fs,2);let _n;Qe(Bs,A=>W(B,A),()=>m(B));var fn=q(Bs,2);{var Mh=A=>{var j=Gp(),Xt=it(j);ae(Xt,{get Icon(){return Yo},label:"Confirm crop",show_label:!0,size:"large",padded:!0,color:"white",background:"var(--color-green-500)",label_position:"right",onclick:Te}),tt(j),H(A,j)};Q(fn,A=>{m(At)==="crop"&&A(Mh)})}var Th=q(fn,2);return Oh(Th,t,"default",{}),tt(ei),As(ei,(A,j)=>i?.(A,j),()=>({on_drag_change:A=>u(A),on_files:Ut,accepted_types:"image/*",disable_click:m(e)})),Wt(()=>{cn=re(ei,1,"image-container svelte-6fnl1z",null,cn,{"dark-bg":m(At)==="crop"}),dn=re(Fs,1,"pixi-target svelte-6fnl1z",null,dn,{visible:m(At)!=="crop"}),_n=re(Bs,1,"pixi-target-crop svelte-6fnl1z",null,_n,{visible:m(At)==="crop"})}),H(s,ei),si(t,"antialias",o),si(t,"get_blobs",M),si(t,"add_image",st),si(t,"add_image_from_url",rt),si(t,"add_layers_from_url",xt),ue(Sh)}const Np=/^(#\s*)(.+)$/m;function Do(s){const t=s.trim(),e=t.match(Np);if(!e)return[!1,t||!1];const[i,,r]=e,n=r.trim();if(t===i)return[n,!1];const o=e.index!==void 0?e.index+i.length:0,h=t.substring(o).trim()||!1;return[n,h]}var Wp=nt('<h2 class="svelte-b4yllx"> </h2>'),Hp=nt('<p class="svelte-b4yllx"> </p>'),Vp=nt("<!> <!>",1),Xp=nt("<div>Upload an image</div>"),Yp=nt('<div class="or svelte-b4yllx">or</div>'),jp=nt("<div>select the draw tool to start</div>"),qp=nt('<div class="empty wrap svelte-b4yllx"><!> <!> <!></div>'),$p=nt("<!> <!>",1);function Kp(s,t){ce(t,!1);const e=Z(),i=Z();let r=z(t,"brush",12),n=z(t,"eraser",12),o=z(t,"sources",12),a=z(t,"i18n",12),h=z(t,"root",12),l=z(t,"label",12,void 0),c=z(t,"show_label",12),u=z(t,"changeable",12,!1),_=z(t,"theme_mode",12),d=z(t,"layers",12),f=z(t,"composite",12),g=z(t,"background",12),p=z(t,"layer_options",12),y=z(t,"transforms",12),x=z(t,"accept_blobs",12),v=z(t,"canvas_size",12),b=z(t,"fixed_canvas",12,!1),C=z(t,"realtime",12),w=z(t,"upload",12),k=z(t,"is_dragging",12),R=z(t,"placeholder",12,void 0),S=z(t,"border_region",12),P=z(t,"full_history",12,null),F=z(t,"webcam_options",12),G=z(t,"show_download_button",12,!1);const N=Oe();let B=Z(),V=Z(!1);function L(E){return!!E}function D(E){return!!E}async function gt(){let E;try{E=await m(B).get_blobs()}catch{return{background:null,layers:[],composite:null}}
570const et=E.background?w()(await Os([new File([E.background],"background.png")]),h()):Promise.resolve(null),ct=E.layers.filter(L).map(async(bt,Nt)=>w()(await Os([new File([bt],`layer_${Nt}.png`)]),h())),at=E.composite?w()(await Os([new File([E.composite],"composite.png")]),h()):Promise.resolve(null),[ft,Et,...Ut]=await Promise.all([et,at,...ct]);return{background:Array.isArray(ft)?ft[0]:ft,layers:Ut.flatMap(bt=>Array.isArray(bt)?bt:[bt]).filter(D),composite:Array.isArray(Et)?Et[0]:Et}}function M(E){m(B)&&E==null&&(m(B).handle_remove(),N("receive_null"))}let T=Z(!1),st=Z(),U=z(t,"image_id",12,null);function rt(){return new Promise(E=>setTimeout(()=>E(),30))}let xt=!1,K=!1;async function mt(E){if(!C())return;if(xt){K=!0;return}xt=!0,await rt();const et=await m(B).get_blobs(),ct=[];let at=Math.random().toString(36).substring(2);et.background&&ct.push([at,"background",new File([et.background],"background.png"),null]),et.composite&&ct.push([at,"composite",new File([et.composite],"composite.png"),null]),et.layers.forEach((ft,Et)=>{ft&&ct.push([at,"layer",new File([ft],`layer_${Et}.png`),Et])}),await Promise.all(ct.map(async([ft,Et,Ut,bt])=>x()({binary:!0,data:{file:Ut,id:ft,type:Et,index:bt}}))),U(at),N("change"),await rt(),xt=!1,K&&(K=!1,xt=!1,mt())}let ot=Z();yt(()=>m(T),()=>{m(T)&&N("upload")}),yt(()=>(Y(d()),Y(f()),Y(g())),()=>{M({layers:d(),composite:f(),background:g()})}),yt(()=>(m(e),m(i),Y(R()),Do),()=>{(E=>{var et=Ho(E,2);W(e,et[0]),W(i,et[1])})(R()?Do(R()):[!1,!1])}),Le();var ut={get_data:gt,get brush(){return r()},set brush(E){r(E),I()},get eraser(){return n()},set eraser(E){n(E),I()},get sources(){return o()},set sources(E){o(E),I()},get i18n(){return a()},set i18n(E){a(E),I()},get root(){return h()},set root(E){h(E),I()},get label(){return l()},set label(E){l(E),I()},get show_label(){return c()},set show_label(E){c(E),I()},get changeable(){return u()},set changeable(E){u(E),I()},get theme_mode(){return _()},set theme_mode(E){_(E),I()},get layers(){return d()},set layers(E){d(E),I()},get composite(){return f()},set composite(E){f(E),I()},get background(){return g()},set background(E){g(E),I()},get layer_options(){return p()},set layer_options(E){p(E),I()},get transforms(){return y()},set transforms(E){y(E),I()},get accept_blobs(){return x()},set accept_blobs(E){x(E),I()},get canvas_size(){return v()},set canvas_size(E){v(E),I()},get fixed_canvas(){return b()},set fixed_canvas(E){b(E),I()},get realtime(){return C()},set realtime(E){C(E),I()},get upload(){return w()},set upload(E){w(E),I()},get is_dragging(){return k()},set is_dragging(E){k(E),I()},get placeholder(){return R()},set placeholder(E){R(E),I()},get border_region(){return S()},set border_region(E){S(E),I()},get full_history(){return P()},set full_history(E){P(E),I()},get webcam_options(){return F()},set webcam_options(E){F(E),I()},get show_download_button(){return G()},set show_download_button(E){G(E),I()},get image_id(){return U()},set image_id(E){U(E),I()}};ve();var O=$p(),J=qt(O);{let E=Gt(()=>(Y(l()),Y(a()),Rt(()=>l()||a()("image.image"))));il(J,{get show_label(){return c()},get Icon(){return Vo},get label(){return m(E)}})}var Tt=q(J,2);return Qe(Up(Tt,{get transforms(){return y()},get composite(){return f()},get layers(){return d()},get background(){return g()},get canvas_size(){return v()},get changeable(){return u()},get sources(){return o()},get brush_options(){return r()},get eraser_options(){return n()},get fixed_canvas(){return b()},get border_region(){return S()},get layer_options(){return p()},get i18n(){return a()},get root(){return h()},get upload(){return w()},get webcam_options(){return F()},get show_download_button(){return G()},get theme_mode(){return _()},get background_image(){return m(T)},set background_image(E){W(T,E)},get current_tool(){return m(ot)},set current_tool(E){W(ot,E)},get is_dragging(){return k()},set is_dragging(E){k(E)},get has_drawn(){return m(V)},set has_drawn(E){W(V,E)},get can_undo(){return m(st)},set can_undo(E){W(st,E)},get full_history(){return P()},set full_history(E){P(E)},$$events:{history(E){fe.call(this,t,E)},save(E){fe.call(this,t,E)},input(E){fe.call(this,t,E)},change:mt,clear:()=>N("clear"),download_error(E){fe.call(this,t,E)}},children:(E,et)=>{var ct=ci(),at=qt(ct);{var ft=Et=>{var Ut=qp(),bt=it(Ut);{var Nt=Vt=>{var Ge=ci(),zs=qt(Ge);{var Hi=At=>{var Ce=Vp(),Xi=qt(Ce);{var Yi=Me=>{var Te=Wp(),yi=it(Te,!0);tt(Te),Wt(()=>Fe(yi,m(e))),H(Me,Te)};Q(Xi,Me=>{m(e)&&Me(Yi)})}var Is=q(Xi,2);{var Es=Me=>{var Te=Hp(),yi=it(Te,!0);tt(Te),Wt(()=>Fe(yi,m(i))),H(Me,Te)};Q(Is,Me=>{m(i)&&Me(Es)})}H(At,Ce)},Vi=At=>{var Ce=Xp();H(At,Ce)};Q(zs,At=>{m(e)||m(i)?At(Hi):At(Vi,!1)})}H(Vt,Ge)};Q(bt,Vt=>{Y(o()),Rt(()=>o()&&o().length)&&Vt(Nt)})}var Ft=q(bt,2);{var vt=Vt=>{var Ge=Yp();H(Vt,Ge)};Q(Ft,Vt=>{Y(o()),Y(r()),Y(R()),Rt(()=>
570o()&&o().length&&r()&&!R())&&Vt(vt)})}var ee=q(Ft,2);{var Zt=Vt=>{var Ge=jp();H(Vt,Ge)};Q(ee,Vt=>{r()&&!R()&&Vt(Zt)})}tt(Ut),H(Et,Ut)};Q(at,Et=>{m(ot)==="image"&&!m(st)&&Et(ft)})}H(E,ct)},$$slots:{default:!0},$$legacy:!0}),E=>W(B,E),()=>m(B)),H(s,O),si(t,"get_data",gt),ue(ut)}var Zp=nt("<!> <!>",1),Qp=nt("<!> <!>",1);function Jp(s,t){ce(t,!0);let e=Gh(t,["$$slots","$$events","$$legacy"]);class i extends Nh{async get_data(){const C=await super.get_data(),w=await l();return{...C,value:w}}}const r=new i(e,{server:{accept_blobs:()=>{}},buttons:[],height:350,border_region:0});let n,o=Uh(null),a=!1,h=!1;async function l(){if(m(o)){const C={id:m(o)};return W(o,null),C}return await n.get_data()}let c;function u(){r.dispatch("apply")}let _=de(()=>r.props.value?.background||r.props.value?.layers?.length||r.props.value?.composite),d=de(()=>r.props.value?.background?new Gs(r.props.value.background):null),f=de(()=>r.props.value?.composite?new Gs(r.props.value.composite):null),g=de(()=>r.props.value?.layers?.map(b=>new Gs(b))||[]);var p=ci(),y=qt(p);{var x=b=>{{let C=de(()=>c?"focus":"base");bn(b,{get visible(){return r.shared.visible},variant:"solid",get border_mode(){return m(C)},padding:!1,get elem_id(){return r.shared.elem_id},get elem_classes(){return r.shared.elem_classes},get height(){return r.props.height},get width(){return r.props.width},allow_overflow:!0,overflow_behavior:"visible",get container(){return r.shared.container},get scale(){return r.shared.scale},get min_width(){return r.shared.min_width},children:(w,k)=>{var R=Zp(),S=qt(R);vn(S,yn({get autoscroll(){return r.shared.autoscroll},get i18n(){return r.i18n}},()=>r.shared.loading_status,{on_clear_status:()=>r.dispatch("clear_status",r.shared.loading_status)}));var P=q(S,2);{let F=de(()=>r.props.value?.composite||null);Wh(P,{get value(){return m(F)},get label(){return r.shared.label},get show_label(){return r.shared.show_label},get buttons(){return r.props.buttons},get selectable(){return r.props._selectable},get i18n(){return r.i18n},$$events:{select:({detail:G})=>r.dispatch("select",G),share:({detail:G})=>r.dispatch("share",G),error:({detail:G})=>r.dispatch("error",G)}})}H(w,R)},$$slots:{default:!0}})}},v=b=>{{let C=de(()=>m(_)?"solid":"dashed"),w=de(()=>c?"focus":"base");bn(b,{get visible(){return r.shared.visible},get variant(){return m(C)},get border_mode(){return m(w)},padding:!1,get elem_id(){return r.shared.elem_id},get elem_classes(){return r.shared.elem_classes},get height(){return r.props.height},get width(){return r.props.width},allow_overflow:!0,overflow_behavior:"visible",get container(){return r.shared.container},get scale(){return r.shared.scale},get min_width(){return r.shared.min_width},children:(k,R)=>{var S=Qp(),P=qt(S);vn(P,yn({get autoscroll(){return r.shared.autoscroll},get i18n(){return r.i18n}},()=>r.shared.loading_status,{on_clear_status:()=>r.dispatch("clear_status",r.shared.loading_status)}));var F=q(P,2);{let G=de(()=>r.shared.attached_events.includes("apply")),N=de(()=>r.shared.attached_events.includes("change")||r.shared.attached_events.includes("input")),B=de(()=>r.props.buttons===null?!0:r.props.buttons.includes("download"));Qe(Kp(F,{get border_region(){return r.props.border_region},get canvas_size(){return r.props.canvas_size},get layers(){return m(g)},get composite(){return m(f)},get background(){return m(d)},get root(){return r.shared.root},get sources(){return r.props.sources},get label(){return r.shared.label},get show_label(){return r.shared.show_label},get fixed_canvas(){return r.props.fixed_canvas},get brush(){return r.props.brush},get eraser(){return r.props.eraser},get changeable(){return m(G)},get realtime(){return m(N)},get i18n(){return r.i18n},get transforms(){return r.props.transforms},get accept_blobs(){return r.shared.server.accept_blobs},get layer_options(){return r.props.layers},upload:(...V)=>r.shared.client.upload(...V),get placeholder(){return r.props.placeholder},get webcam_options(){return r.props.webcam_options},get show_download_button(){return m(B)},get theme_mode(){return r.shared.theme_mode},get is_dragging(){return c},set is_dragging(V){c=V},get image_id(){return m(o)},set image_id(V){W(o,V,!0)},$$events:{input:()=>
570{h?r.dispatch("input"):h=!0},save:V=>u(),edit:()=>r.dispatch("edit"),clear:()=>r.dispatch("clear"),drag:({detail:V})=>c=V,upload:()=>r.dispatch("upload"),share:({detail:V})=>r.dispatch("share",V),error:[({detail:V})=>{r.shared.loading_status=r.shared.loading_status||{},r.shared.loading_status.status="error",r.dispatch("error",V)},function(V){fe.call(this,t,V)}],receive_null:()=>r.props.value={background:null,layers:[],composite:null},change:()=>{a?r.dispatch("change"):a=!0},download_error:V=>r.dispatch("error",V.detail)}}),V=>n=V,()=>n)}H(k,S)},$$slots:{default:!0}})}};Q(y,b=>{r.shared.interactive?b(v,!1):b(x)})}H(s,p),ue()}const Ig=Object.freeze(Object.defineProperty({__proto__:null,default:Jp},Symbol.toStringTag,{value:"Module"}));export{Mc as $,Ua as A,se as B,lt as C,It as D,$ as E,Er as F,Pd as G,ge as H,sa as I,be as J,di as K,Gn as L,pt as M,kt as N,qc as O,dt as P,nu as Q,Pr as R,su as S,Ji as T,Sr as U,Wi as V,Mt as W,ku as X,Un as Y,$s as Z,Nn as _,we as a,xs as a0,Ht as a1,Sc as a2,oa as a3,Jt as a4,Na as a5,ht as a6,wt as a7,Tu as a8,Qu as a9,Xu as aa,md as ab,xd as ac,Cd as ad,Ad as ae,Md as af,ys as ag,ds as ah,Or as ai,To as aj,ih as ak,io as al,to as am,zo as an,P_ as ao,Pt as ap,Dt as aq,ql as ar,ks as as,nh as at,Ig as au,Wu as b,Ui as c,us as d,$t as e,eo as f,Du as g,Jr as h,Oa as i,ma as j,me as k,za as l,Wr as m,gd as n,yd as o,Sd as p,wd as q,hc as r,Cs as s,_t as t,Ot as u,jl as v,zt as w,We as x,_i as y,Td as z};
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.