@triiiceratops/plugin-annotation-editor 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/iife.js ADDED
@@ -0,0 +1,1273 @@
1
+ (function(){"use strict";function Dy(n,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in n)){const s=Object.getOwnPropertyDescriptor(i,r);s&&Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const My=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-.]+))?(?:\+[0-9A-Za-z-.]+)?$/;function Lo(n){const e=My.exec(n.trim());if(!e)return null;const[,t,i,r,s]=e,o=s?s.split(".").map(a=>/^\d+$/.test(a)?Number(a):a):[];return{major:Number(t),minor:Number(i),patch:Number(r),prerelease:o}}function Oy(n,e){return n.major-e.major||n.minor-e.minor||n.patch-e.patch}function Ly(n,e){if(n.prerelease.length===0&&e.prerelease.length===0)return 0;if(n.prerelease.length===0)return 1;if(e.prerelease.length===0)return-1;const t=Math.max(n.prerelease.length,e.prerelease.length);for(let i=0;i<t;i++){const r=n.prerelease[i],s=e.prerelease[i];if(r===void 0)return-1;if(s===void 0)return 1;if(r===s)continue;const o=typeof r=="number",a=typeof s=="number";return o&&a?r<s?-1:1:o?-1:a?1:String(r)<String(s)?-1:1}return 0}function By(n,e){return Oy(n,e)||Ly(n,e)}function Fy(n){return n.major>0?{major:n.major+1,minor:0,patch:0,prerelease:[]}:n.minor>0?{major:0,minor:n.minor+1,patch:0,prerelease:[]}:{major:0,minor:0,patch:n.patch+1,prerelease:[]}}function Ny(n){if(n===""||n==="*"||n==="x"||n==="X")return[];let e;if(e=/^\^\s*(.+)$/.exec(n)){const t=Lo(e[1]??"");return t?[{op:">=",ver:t},{op:"<",ver:Fy(t)}]:null}if(e=/^~\s*(.+)$/.exec(n)){const t=Lo(e[1]??"");return t?[{op:">=",ver:t},{op:"<",ver:{major:t.major,minor:t.minor+1,patch:0,prerelease:[]}}]:null}if(e=/^(>=|<=|>|<|=)?\s*(.+)$/.exec(n)){const t=Lo(e[2]??"");return t?[{op:e[1]??"=",ver:t}]:null}return null}function ky(n,e){const t=By(n,e.ver);switch(e.op){case"<":return t<0;case"<=":return t<=0;case">":return t>0;case">=":return t>=0;case"=":return t===0}}function Uy(n,e){const t=e.trim();if(t===""||t==="*"||t==="x")return!0;const i=t.split(/\s+/).filter(Boolean);for(const r of i){const s=Ny(r);if(s===null||!s.every(o=>ky(n,o)))return!1}return!0}function Bc(n,e){const t=Lo(n);if(!t)return!1;const i=e.split("||").map(r=>r.trim()).filter(r=>r.length>0);return i.length===0?!0:i.some(r=>Uy(t,r))}class Cl extends Error{code="PLUGIN_INCOMPATIBLE";pluginName;pluginVersion;reasons;constructor(e,t,i){super(Hy(e,t,i)),this.name="PluginCompatibilityError",this.pluginName=e,this.pluginVersion=t,this.reasons=i,Object.setPrototypeOf(this,Cl.prototype)}}function Hy(n,e,t){const i=t.map(r=>` - ${r.message}`).join(`
2
+ `);return`Plugin "${n}"@${e} cannot activate — incompatible with this viewer:
3
+ ${i}
4
+ Update the plugin or the core viewer so their declared ranges and capabilities overlap.`}function zy(n,e){const t=[];Bc(e.coreVersion,n.coreRange)||t.push({kind:"core",required:n.coreRange,actual:e.coreVersion,message:`requires core ${n.coreRange} but this viewer is core ${e.coreVersion}`}),Bc(e.pluginApiVersion,n.pluginApiRange)||t.push({kind:"pluginApi",required:n.pluginApiRange,actual:e.pluginApiVersion,message:`requires plugin API ${n.pluginApiRange} but this viewer provides plugin API ${e.pluginApiVersion}`});const i=new Set(e.capabilities);for(const r of n.requiredCapabilities)i.has(r)||t.push({kind:"capability",required:r,actual:e.capabilities.join(", ")||"(none)",message:`requires capability "${r}" which this viewer does not provide (has: ${e.capabilities.join(", ")||"none"})`});return t}function Gy(n,e){const t=zy(n,e);if(t.length>0)throw new Cl(n.name,n.version,t)}function Vy(n,e={}){let t=0,i=!1;const r=new Set,s=n.subscribe(()=>{t++;for(const a of[...r])a()},e.onListenerError);return{selectors:{select(a,l=Object.is){let h=-1,u;const c=()=>(h!==t&&(u=a(n),h=t),u);return{get:c,subscribe(d){if(i)return()=>{};let f=c();const p=()=>{let g;try{g=c()}catch(m){e.onProjectionError?.(m);return}l(f,g)||(f=g,d(g))};return r.add(p),()=>{r.delete(p)}}}}},dispose(){i||(i=!0,r.clear(),s())}}}const Pl=()=>{};function Wy(){return{install(n,e){return Pl}}}function jy(){return{current:"en",t(n,e){return n},subscribe(n){return Pl}}}function Xy(){return{renderIcon(n,e){return Pl}}}function Yy(n){const e=new Set;return{service:{install(t,i){const r=n.install(t,i);let s=!1;const o=()=>{s||(s=!0,e.delete(o),r())};return e.add(o),o}},releaseAll(){for(const t of[...e])t();e.clear()}}}function qy(n){const e=new Set;return{service:{get current(){return n.current},t(t,i){return n.t(t,i)},subscribe(t){const i=n.subscribe(t);let r=!1;const s=()=>{r||(r=!0,e.delete(s),i())};return e.add(s),s}},releaseAll(){for(const t of[...e])t();e.clear()}}}const Zy={deactivate(){}};function Ky(n,e){const t=e.reportError;let i,r,s,o;try{Gy(n,e),i=Vy(e.viewerState,{onProjectionError:t?d=>t({phase:"command",error:d}):void 0,onListenerError:t?d=>t({phase:"subscription",error:d}):void 0}),r=Yy(e.styles??Wy()),s=qy(e.locale??jy()),o={viewerState:e.viewerState,selectors:i.selectors,styles:r.service,locale:s.service,ui:e.ui??Xy()}}catch(d){if(i?.dispose(),r?.releaseAll(),s?.releaseAll(),t)return t({phase:"setup",error:d}),Zy;throw d}const a=[],l=r,h=s,u=i;try{const d=n.view.mount(e.container,o);typeof d=="function"&&a.push(d)}catch(d){if(!t)throw l.releaseAll(),h.releaseAll(),u.dispose(),d;t({phase:"mount",error:d})}a.push(()=>l.releaseAll()),a.push(()=>h.releaseAll()),a.push(()=>u.dispose());let c=!1;return{deactivate(){if(!c){c=!0;for(let d=a.length-1;d>=0;d--)try{a[d]?.()}catch(f){t?t({phase:"cleanup",error:f}):console.error(`[triiiceratops] Plugin "${n.name}" cleanup threw during deactivation; teardown continues.`,f)}a.length=0}}}}const Qy="triiiceratops-plugin";function Jy(n){const e={name:n.name,uiId:n.uiId,version:n.version,coreRange:n.coreRange,pluginApiRange:n.pluginApiRange,requiredCapabilities:n.requiredCapabilities??[],icon:n.icon,target:n.target??"panel",dismiss:n.dismiss,catalog:n.catalog,view:n.view};return{kind:Qy,...e,activate(t){return Ky(e,t)}}}class $y extends Error{name="SvgIconError";constructor(e){super(`svgIcon: ${e}`)}}const e_="0 0 24 24";function er(n,e){if(!n)throw new $y(e)}const t_=/<svg\b[^>]*>/i;function i_(n){er(typeof n=="string","expected an SVG string.");const e=n.trim();er(e.length>0,"received an empty string.");const t=t_.exec(e);er(t!==null,"the markup must contain an <svg> root element."),er(!/<script[\s/>]/i.test(e),"<script> elements are not allowed in plugin icons."),er(!/<foreignObject[\s/>]/i.test(e),"<foreignObject> is not allowed in plugin icons."),er(!/\son[a-z]+\s*=/i.test(e),"on* event-handler attributes (e.g. onload, onclick) are not allowed in plugin icons.");for(const a of e.matchAll(/(?:xlink:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi)){const l=(a[1]??a[2]??a[3]??"").trim();er(l.startsWith("#"),`external href/xlink:href URLs are not allowed in plugin icons (found "${l}"); only internal "#id" references are.`)}const i=t[0],r=/\bviewBox\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(i);let s=(r?.[1]??r?.[2])?.trim();if(!s){const a=/\bwidth\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(i),l=/\bheight\s*=\s*(?:"([^"]*)"|'([^']*)')/i.exec(i),h=parseFloat(a?.[1]??a?.[2]??""),u=parseFloat(l?.[1]??l?.[2]??"");s=Number.isFinite(h)&&Number.isFinite(u)?`0 0 ${h} ${u}`:e_}let o="";if(!/\/\s*>$/.test(i)){const a=t.index+i.length,l=e.lastIndexOf("</svg>");o=(l>=a?e.slice(a,l):e.slice(a)).trim()}return{kind:"svg",inner:o,viewBox:s}}function n_(n,e){return{STYLES:n,STYLE_ID:e}}const Fc={en:{annotation_editor_title:"Annotation Editor",annotation_editor_edit_mode:"Edit",annotation_editor_create_mode:"Create",annotation_editor_instruction_create:"Click to start annotating, click again to set shape",annotation_editor_instruction_edit:"Click on an annotation to select and edit it",annotation_editor_tool_label:"Drawing Tool",annotation_editor_undo:"Undo",annotation_editor_redo:"Redo",annotation_editor_edit_section:"Edit Annotation",annotation_editor_delete_tooltip:"Delete annotation",annotation_editor_tag_placeholder:"Tag value...",annotation_editor_link_placeholder:"https://...",annotation_editor_text_placeholder:"Enter text...",annotation_editor_add_content:"Add Content",annotation_editor_unknown_body_note:"This structured body is shown read-only and will be preserved when you save.",annotation_editor_hydrating:"Loading the full annotation text...",annotation_editor_save:"Save Changes",annotation_editor_delete_title:"Delete Annotation?",annotation_editor_delete_message:"Are you sure you want to delete this annotation? This action cannot be undone.",annotation_editor_cancel:"Cancel",annotation_editor_delete:"Delete",annotation_editor_error_load:"Couldn't load annotations. Please try again.",annotation_editor_error_create:"Couldn't save the new annotation. Please try again.",annotation_editor_error_update:"Couldn't save your changes. Please try again.",annotation_editor_error_delete:"Couldn't delete the annotation. Please try again.",annotation_editor_error_hydrate:"Couldn't load the full annotation. Please try again.",annotation_editor_error_dismiss:"Dismiss",annotation_tool_rectangle:"Rectangle",annotation_tool_polygon:"Polygon",annotation_tool_point:"Point"},de:{annotation_editor_title:"Anmerkungs-Editor",annotation_editor_edit_mode:"Bearbeiten",annotation_editor_create_mode:"Erstellen",annotation_editor_instruction_create:"Klicken zum Annotieren, erneut klicken zum Abschließen",annotation_editor_instruction_edit:"Anmerkung klicken zum Bearbeiten",annotation_editor_tool_label:"Zeichenwerkzeug",annotation_editor_undo:"Rückgängig",annotation_editor_redo:"Wiederholen",annotation_editor_edit_section:"Anmerkung bearbeiten",annotation_editor_delete_tooltip:"Anmerkung löschen",annotation_editor_tag_placeholder:"Tag eingeben...",annotation_editor_link_placeholder:"https://...",annotation_editor_text_placeholder:"Text eingeben...",annotation_editor_add_content:"Inhalt hinzufügen",annotation_editor_unknown_body_note:"Dieser strukturierte Inhalt wird schreibgeschützt angezeigt und beim Speichern beibehalten.",annotation_editor_hydrating:"Vollständiger Anmerkungstext wird geladen...",annotation_editor_save:"Speichern",annotation_editor_delete_title:"Anmerkung löschen?",annotation_editor_delete_message:"Anmerkung wirklich löschen? Dies kann nicht rückgängig gemacht werden.",annotation_editor_cancel:"Abbrechen",annotation_editor_delete:"Löschen",annotation_editor_error_load:"Anmerkungen konnten nicht geladen werden. Bitte erneut versuchen.",annotation_editor_error_create:"Neue Anmerkung konnte nicht gespeichert werden. Bitte erneut versuchen.",annotation_editor_error_update:"Änderungen konnten nicht gespeichert werden. Bitte erneut versuchen.",annotation_editor_error_delete:"Anmerkung konnte nicht gelöscht werden. Bitte erneut versuchen.",annotation_editor_error_hydrate:"Vollständige Anmerkung konnte nicht geladen werden. Bitte erneut versuchen.",annotation_editor_error_dismiss:"Schließen",annotation_tool_rectangle:"Rechteck",annotation_tool_polygon:"Polygon",annotation_tool_point:"Punkt"}},Il="0 0 256 256",Dl={PencilSimple:'<path d="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM92.69,208H48V163.31l88-88L180.69,120ZM192,108.68,147.31,64l24-24L216,84.68Z"/>',Warning:'<path d="M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z"/>',X:'<path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"/>',Rectangle:'<path d="M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,160H40V56H216V200Z"/>',Polygon:'<path d="M230.64,49.36a32,32,0,0,0-45.26,0h0a31.9,31.9,0,0,0-5.16,6.76L152,48.42A32,32,0,0,0,97.37,25.36h0a32.06,32.06,0,0,0-5.76,37.41L57.67,93.32a32.05,32.05,0,0,0-40.31,4.05h0a32,32,0,0,0,42.89,47.41l70,51.36a32,32,0,1,0,47.57-14.69l27.39-77.59q1.38.12,2.76.12a32,32,0,0,0,22.63-54.62Zm-122-12.69h0a16,16,0,1,1,0,22.64A16,16,0,0,1,108.68,36.67Zm-80,94.65a16,16,0,0,1,0-22.64h0a16,16,0,1,1,0,22.64Zm142.65,88a16,16,0,0,1-22.63-22.63h0a16,16,0,1,1,22.63,22.63Zm-8.55-43.18a32,32,0,0,0-23,7.08l-70-51.36a32.17,32.17,0,0,0-1.34-26.65l33.95-30.55a32,32,0,0,0,45.47-10.81L176,71.56a32,32,0,0,0,14.12,27Zm56.56-92.84A16,16,0,1,1,196.7,60.68h0a16,16,0,0,1,22.63,22.63Z"/>',Target:'<path d="M221.87,83.16A104.1,104.1,0,1,1,195.67,49l22.67-22.68a8,8,0,0,1,11.32,11.32l-96,96a8,8,0,0,1-11.32-11.32l27.72-27.72a40,40,0,1,0,17.87,31.09,8,8,0,1,1,16-.9,56,56,0,1,1-22.38-41.65L184.3,60.39a87.88,87.88,0,1,0,23.13,29.67,8,8,0,0,1,14.44-6.9Z"/>',ArrowCounterClockwise:'<path d="M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z"/>',ArrowClockwise:'<path d="M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z"/>',Trash:'<path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/>',Plus:'<path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/>',Check:'<path d="M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z"/>'},r_=i_(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${Il}">${Dl.PencilSimple}</svg>`),s_=1,o_=2,Nc=4,a_=8,l_=16,h_=1,u_=4,c_=8,d_=16,f_=1,p_=2,Mt=Symbol(),g_="http://www.w3.org/1999/xhtml",m_="@attach",Ml=!1;var Ol=Array.isArray,v_=Array.prototype.indexOf,Bo=Array.from,y_=Object.defineProperty,Fr=Object.getOwnPropertyDescriptor,__=Object.getOwnPropertyDescriptors,x_=Object.prototype,w_=Array.prototype,kc=Object.getPrototypeOf,Uc=Object.isExtensible;const tr=()=>{};function T_(n){for(var e=0;e<n.length;e++)n[e]()}function Hc(){var n,e,t=new Promise((i,r)=>{n=i,e=r});return{promise:t,resolve:n,reject:e}}const Ot=2,Ll=4,Bl=8,zc=1<<24,un=16,cn=32,Cn=64,Fo=128,Pi=512,Wt=1024,ri=2048,dn=4096,hi=8192,fn=16384,Fl=32768,Pn=65536,Gc=1<<17,Vc=1<<18,ir=1<<19,E_=1<<20,pn=1<<25,nr=32768,Nl=1<<21,kl=1<<22,In=1<<23,rr=Symbol("$state"),b_=Symbol("legacy props"),S_=Symbol(""),Nr=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function Ul(n){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function A_(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function R_(n){throw new Error("https://svelte.dev/e/effect_in_teardown")}function C_(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function P_(n){throw new Error("https://svelte.dev/e/effect_orphan")}function I_(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function D_(n){throw new Error("https://svelte.dev/e/props_invalid_value")}function M_(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function O_(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function L_(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function B_(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function F_(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function N_(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Wc(n){return n===this.v}function k_(n,e){return n!=n?e==e:n!==e||n!==null&&typeof n=="object"||typeof n=="function"}function jc(n){return!k_(n,this.v)}let U_=!1,Lt=null;function kr(n){Lt=n}function Xc(n){return H_().get(n)}function Ur(n,e=!1,t){Lt={p:Lt,i:!1,c:null,e:null,s:n,x:null,l:null}}function Hr(n){var e=Lt,t=e.e;if(t!==null){e.e=null;for(var i of t)gd(i)}return e.i=!0,Lt=e.p,{}}function Yc(){return!0}function H_(n){return Lt===null&&Ul(),Lt.c??=new Map(z_(Lt)||void 0)}function z_(n){let e=n.p;for(;e!==null;){const t=e.c;if(t!==null)return t;e=e.p}return null}let sr=[];function qc(){var n=sr;sr=[],T_(n)}function or(n){if(sr.length===0&&!Ns){var e=sr;queueMicrotask(()=>{e===sr&&qc()})}sr.push(n)}function G_(){for(;sr.length>0;)qc()}function Zc(n){var e=it;if(e===null)return Ke.f|=In,n;if((e.f&Fl)===0){if((e.f&Fo)===0)throw n;e.b.error(n)}else zr(n,e)}function zr(n,e){for(;e!==null;){if((e.f&Fo)!==0)try{e.b.error(n);return}catch(t){n=t}e=e.parent}throw n}const No=new Set;let Je=null,Fs=null,vi=null,yi=[],ko=null,Hl=!1,Ns=!1;class Ii{committed=!1;current=new Map;previous=new Map;#e=new Set;#t=new Set;#i=0;#n=0;#r=null;#s=[];#o=[];skipped_effects=new Set;is_fork=!1;is_deferred(){return this.is_fork||this.#n>0}process(e){yi=[],Fs=null,this.apply();var t={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const i of e)this.#a(i,t);this.is_fork||this.#u(),this.is_deferred()?(this.#l(t.effects),this.#l(t.render_effects),this.#l(t.block_effects)):(Fs=this,Je=null,Qc(t.render_effects),Qc(t.effects),Fs=null,this.#r?.resolve()),vi=null}#a(e,t){e.f^=Wt;for(var i=e.first;i!==null;){var r=i.f,s=(r&(cn|Cn))!==0,o=s&&(r&Wt)!==0,a=o||(r&hi)!==0||this.skipped_effects.has(i);if((i.f&Fo)!==0&&i.b?.is_pending()&&(t={parent:t,effect:i,effects:[],render_effects:[],block_effects:[]}),!a&&i.fn!==null){s?i.f^=Wt:(r&Ll)!==0?t.effects.push(i):Gs(i)&&((i.f&un)!==0&&t.block_effects.push(i),Vs(i));var l=i.first;if(l!==null){i=l;continue}}var h=i.parent;for(i=i.next;i===null&&h!==null;)h===t.effect&&(this.#l(t.effects),this.#l(t.render_effects),this.#l(t.block_effects),t=t.parent),i=h.next,h=h.parent}}#l(e){for(const t of e)((t.f&ri)!==0?this.#s:this.#o).push(t),this.#h(t.deps),jt(t,Wt)}#h(e){if(e!==null)for(const t of e)(t.f&Ot)===0||(t.f&nr)===0||(t.f^=nr,this.#h(t.deps))}capture(e,t){this.previous.has(e)||this.previous.set(e,t),(e.f&In)===0&&(this.current.set(e,e.v),vi?.set(e,e.v))}activate(){Je=this,this.apply()}deactivate(){Je===this&&(Je=null,vi=null)}flush(){if(this.activate(),yi.length>0){if(Kc(),Je!==null&&Je!==this)return}else this.#i===0&&this.process([]);this.deactivate()}discard(){for(const e of this.#t)e(this);this.#t.clear()}#u(){if(this.#n===0){for(const e of this.#e)e();this.#e.clear()}this.#i===0&&this.#c()}#c(){if(No.size>1){this.previous.clear();var e=vi,t=!0,i={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const s of No){if(s===this){t=!1;continue}const o=[];for(const[l,h]of this.current){if(s.current.has(l))if(t&&h!==s.current.get(l))s.current.set(l,h);else continue;o.push(l)}if(o.length===0)continue;const a=[...s.current.keys()].filter(l=>!this.current.has(l));if(a.length>0){var r=yi;yi=[];const l=new Set,h=new Map;for(const u of o)Jc(u,a,l,h);if(yi.length>0){Je=s,s.apply();for(const u of yi)s.#a(u,i);s.deactivate()}yi=r}}Je=null,vi=e}this.committed=!0,No.delete(this)}increment(e){this.#i+=1,e&&(this.#n+=1)}decrement(e){this.#i-=1,e&&(this.#n-=1),this.revive()}revive(){for(const e of this.#s)jt(e,ri),ar(e);for(const e of this.#o)jt(e,dn),ar(e);this.#s=[],this.#o=[],this.flush()}oncommit(e){this.#e.add(e)}ondiscard(e){this.#t.add(e)}settled(){return(this.#r??=Hc()).promise}static ensure(){if(Je===null){const e=Je=new Ii;No.add(Je),Ns||Ii.enqueue(()=>{Je===e&&e.flush()})}return Je}static enqueue(e){or(e)}apply(){}}function V_(n){var e=Ns;Ns=!0;try{for(var t;;){if(G_(),yi.length===0&&(Je?.flush(),yi.length===0))return ko=null,t;Kc()}}finally{Ns=e}}function Kc(){var n=hr;Hl=!0;var e=null;try{var t=0;for(Vo(!0);yi.length>0;){var i=Ii.ensure();if(t++>1e3){var r,s;W_()}i.process(yi),Dn.clear()}}finally{Hl=!1,Vo(n),ko=null}}function W_(){try{I_()}catch(n){zr(n,ko)}}let gn=null;function Qc(n){var e=n.length;if(e!==0){for(var t=0;t<e;){var i=n[t++];if((i.f&(fn|hi))===0&&Gs(i)&&(gn=new Set,Vs(i),i.deps===null&&i.first===null&&i.nodes===null&&(i.teardown===null&&i.ac===null?xd(i):i.fn=null),gn?.size>0)){Dn.clear();for(const r of gn){if((r.f&(fn|hi))!==0)continue;const s=[r];let o=r.parent;for(;o!==null;)gn.has(o)&&(gn.delete(o),s.push(o)),o=o.parent;for(let a=s.length-1;a>=0;a--){const l=s[a];(l.f&(fn|hi))===0&&Vs(l)}}gn.clear()}}gn=null}}function Jc(n,e,t,i){if(!t.has(n)&&(t.add(n),n.reactions!==null))for(const r of n.reactions){const s=r.f;(s&Ot)!==0?Jc(r,e,t,i):(s&(kl|un))!==0&&(s&ri)===0&&$c(r,e,i)&&(jt(r,ri),ar(r))}}function $c(n,e,t){const i=t.get(n);if(i!==void 0)return i;if(n.deps!==null)for(const r of n.deps){if(e.includes(r))return!0;if((r.f&Ot)!==0&&$c(r,e,t))return t.set(r,!0),!0}return t.set(n,!1),!1}function ar(n){for(var e=ko=n;e.parent!==null;){e=e.parent;var t=e.f;if(Hl&&e===it&&(t&un)!==0&&(t&Vc)===0)return;if((t&(Cn|cn))!==0){if((t&Wt)===0)return;e.f^=Wt}}yi.push(e)}function j_(n){let e=0,t=mn(0),i;return()=>{Us()&&(F(t),Vl(()=>(e===0&&(i=Mn(()=>n(()=>ui(t)))),e+=1,()=>{or(()=>{e-=1,e===0&&(i?.(),i=void 0,ui(t))})})))}}var X_=Pn|ir|Fo;function Y_(n,e,t){new q_(n,e,t)}class q_{parent;#e=!1;#t;#i=null;#n;#r;#s;#o=null;#a=null;#l=null;#h=null;#u=null;#c=0;#d=0;#p=!1;#f=null;#_=j_(()=>(this.#f=mn(this.#c),()=>{this.#f=null}));constructor(e,t,i){this.#t=e,this.#n=t,this.#r=i,this.parent=it.b,this.#e=!!this.#n.pending,this.#s=Hs(()=>{it.b=this;{var r=this.#v();try{this.#o=si(()=>i(r))}catch(s){this.error(s)}this.#d>0?this.#m():this.#e=!1}return()=>{this.#u?.remove()}},X_)}#x(){try{this.#o=si(()=>this.#r(this.#t))}catch(e){this.error(e)}this.#e=!1}#w(){const e=this.#n.pending;e&&(this.#a=si(()=>e(this.#t)),Ii.enqueue(()=>{var t=this.#v();this.#o=this.#g(()=>(Ii.ensure(),si(()=>this.#r(t)))),this.#d>0?this.#m():(lr(this.#a,()=>{this.#a=null}),this.#e=!1)}))}#v(){var e=this.#t;return this.#e&&(this.#u=vn(),this.#t.before(this.#u),e=this.#u),e}is_pending(){return this.#e||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#n.pending}#g(e){var t=it,i=Ke,r=Lt;qi(this.#s),oi(this.#s),kr(this.#s.ctx);try{return e()}catch(s){return Zc(s),null}finally{qi(t),oi(i),kr(r)}}#m(){const e=this.#n.pending;this.#o!==null&&(this.#h=document.createDocumentFragment(),this.#h.append(this.#u),Ed(this.#o,this.#h)),this.#a===null&&(this.#a=si(()=>e(this.#t)))}#y(e){if(!this.has_pending_snippet()){this.parent&&this.parent.#y(e);return}this.#d+=e,this.#d===0&&(this.#e=!1,this.#a&&lr(this.#a,()=>{this.#a=null}),this.#h&&(this.#t.before(this.#h),this.#h=null))}update_pending_count(e){this.#y(e),this.#c+=e,this.#f&&Gr(this.#f,this.#c)}get_effect_pending(){return this.#_(),F(this.#f)}error(e){var t=this.#n.onerror;let i=this.#n.failed;if(this.#p||!t&&!i)throw e;this.#o&&(St(this.#o),this.#o=null),this.#a&&(St(this.#a),this.#a=null),this.#l&&(St(this.#l),this.#l=null);var r=!1,s=!1;const o=()=>{if(r){N_();return}r=!0,s&&B_(),Ii.ensure(),this.#c=0,this.#l!==null&&lr(this.#l,()=>{this.#l=null}),this.#e=this.has_pending_snippet(),this.#o=this.#g(()=>(this.#p=!1,si(()=>this.#r(this.#t)))),this.#d>0?this.#m():this.#e=!1};var a=Ke;try{oi(null),s=!0,t?.(e,o),s=!1}catch(l){zr(l,this.#s&&this.#s.parent)}finally{oi(a)}i&&or(()=>{this.#l=this.#g(()=>{Ii.ensure(),this.#p=!0;try{return si(()=>{i(this.#t,()=>e,()=>o)})}catch(l){return zr(l,this.#s.parent),null}finally{this.#p=!1}})})}}function ed(n,e,t,i){const r=Ho;if(t.length===0&&n.length===0){i(e.map(r));return}var s=Je,o=it,a=Z_();function l(){Promise.all(t.map(h=>K_(h))).then(h=>{a();try{i([...e.map(r),...h])}catch(u){(o.f&fn)===0&&zr(u,o)}s?.deactivate(),Uo()}).catch(h=>{zr(h,o)})}n.length>0?Promise.all(n).then(()=>{a();try{return l()}finally{s?.deactivate(),Uo()}}):l()}function Z_(){var n=it,e=Ke,t=Lt,i=Je;return function(s=!0){qi(n),oi(e),kr(t),s&&i?.activate()}}function Uo(){qi(null),oi(null),kr(null)}function Ho(n){var e=Ot|ri,t=Ke!==null&&(Ke.f&Ot)!==0?Ke:null;return it!==null&&(it.f|=ir),{ctx:Lt,deps:null,effects:null,equals:Wc,f:e,fn:n,reactions:null,rv:0,v:Mt,wv:0,parent:t??it,ac:null}}function K_(n,e){let t=it;t===null&&A_();var i=t.b,r=void 0,s=mn(Mt),o=!Ke,a=new Map;return u0(()=>{var l=Hc();r=l.promise;try{Promise.resolve(n()).then(l.resolve,l.reject).then(()=>{h===Je&&h.committed&&h.deactivate(),Uo()})}catch(d){l.reject(d),Uo()}var h=Je;if(o){var u=!i.is_pending();i.update_pending_count(1),h.increment(u),a.get(h)?.reject(Nr),a.delete(h),a.set(h,l)}const c=(d,f=void 0)=>{if(h.activate(),f)f!==Nr&&(s.f|=In,Gr(s,f));else{(s.f&In)!==0&&(s.f^=In),Gr(s,d);for(const[p,g]of a){if(a.delete(p),p===h)break;g.reject(Nr)}}o&&(i.update_pending_count(-1),h.decrement(u))};l.promise.then(c,d=>c(null,d||"unknown"))}),pd(()=>{for(const l of a.values())l.reject(Nr)}),new Promise(l=>{function h(u){function c(){u===r?l(s):h(r)}u.then(c,c)}h(r)})}function $e(n){const e=Ho(n);return Sd(e),e}function td(n){const e=Ho(n);return e.equals=jc,e}function id(n){var e=n.effects;if(e!==null){n.effects=null;for(var t=0;t<e.length;t+=1)St(e[t])}}function Q_(n){for(var e=n.parent;e!==null;){if((e.f&Ot)===0)return(e.f&fn)===0?e:null;e=e.parent}return null}function zl(n){var e,t=it;qi(Q_(n));try{n.f&=~nr,id(n),e=Id(n)}finally{qi(t)}return e}function nd(n){var e=zl(n);if(n.equals(e)||(Je?.is_fork||(n.v=e),n.wv=Cd()),!ur)if(vi!==null)(Us()||Je?.is_fork)&&vi.set(n,e);else{var t=(n.f&Pi)===0?dn:Wt;jt(n,t)}}let Gl=new Set;const Dn=new Map;let rd=!1;function mn(n,e){var t={f:0,v:n,reactions:null,equals:Wc,rv:0,wv:0};return t}function Ge(n,e){const t=mn(n);return Sd(t),t}function J_(n,e=!1,t=!0){const i=mn(n);return e||(i.equals=jc),i}function _e(n,e,t=!1){Ke!==null&&(!Yi||(Ke.f&Gc)!==0)&&Yc()&&(Ke.f&(Ot|un|kl|Gc))!==0&&!yn?.includes(n)&&L_();let i=t?Wi(e):e;return Gr(n,i)}function Gr(n,e){if(!n.equals(e)){var t=n.v;ur?Dn.set(n,e):Dn.set(n,t),n.v=e;var i=Ii.ensure();i.capture(n,t),(n.f&Ot)!==0&&((n.f&ri)!==0&&zl(n),jt(n,(n.f&Pi)!==0?Wt:dn)),n.wv=Cd(),sd(n,ri),it!==null&&(it.f&Wt)!==0&&(it.f&(cn|Cn))===0&&(xi===null?d0([n]):xi.push(n)),!i.is_fork&&Gl.size>0&&!rd&&$_()}return e}function $_(){rd=!1;var n=hr;Vo(!0);const e=Array.from(Gl);try{for(const t of e)(t.f&Wt)!==0&&jt(t,dn),Gs(t)&&Vs(t)}finally{Vo(n)}Gl.clear()}function e0(n,e=1){var t=F(n),i=e===1?t++:t--;return _e(n,t),i}function ui(n){_e(n,n.v+1)}function sd(n,e){var t=n.reactions;if(t!==null)for(var i=t.length,r=0;r<i;r++){var s=t[r],o=s.f,a=(o&ri)===0;if(a&&jt(s,e),(o&Ot)!==0){var l=s;vi?.delete(l),(o&nr)===0&&(o&Pi&&(s.f|=nr),sd(l,dn))}else a&&((o&un)!==0&&gn!==null&&gn.add(s),ar(s))}}function Wi(n){if(typeof n!="object"||n===null||rr in n)return n;const e=kc(n);if(e!==x_&&e!==w_)return n;var t=new Map,i=Ol(n),r=Ge(0),s=Mi,o=a=>{if(Mi===s)return a();var l=Ke,h=Mi;oi(null),Rd(s);var u=a();return oi(l),Rd(h),u};return i&&t.set("length",Ge(n.length)),new Proxy(n,{defineProperty(a,l,h){(!("value"in h)||h.configurable===!1||h.enumerable===!1||h.writable===!1)&&M_();var u=t.get(l);return u===void 0?u=o(()=>{var c=Ge(h.value);return t.set(l,c),c}):_e(u,h.value,!0),!0},deleteProperty(a,l){var h=t.get(l);if(h===void 0){if(l in a){const u=o(()=>Ge(Mt));t.set(l,u),ui(r)}}else _e(h,Mt),ui(r);return!0},get(a,l,h){if(l===rr)return n;var u=t.get(l),c=l in a;if(u===void 0&&(!c||Fr(a,l)?.writable)&&(u=o(()=>{var f=Wi(c?a[l]:Mt),p=Ge(f);return p}),t.set(l,u)),u!==void 0){var d=F(u);return d===Mt?void 0:d}return Reflect.get(a,l,h)},getOwnPropertyDescriptor(a,l){var h=Reflect.getOwnPropertyDescriptor(a,l);if(h&&"value"in h){var u=t.get(l);u&&(h.value=F(u))}else if(h===void 0){var c=t.get(l),d=c?.v;if(c!==void 0&&d!==Mt)return{enumerable:!0,configurable:!0,value:d,writable:!0}}return h},has(a,l){if(l===rr)return!0;var h=t.get(l),u=h!==void 0&&h.v!==Mt||Reflect.has(a,l);if(h!==void 0||it!==null&&(!u||Fr(a,l)?.writable)){h===void 0&&(h=o(()=>{var d=u?Wi(a[l]):Mt,f=Ge(d);return f}),t.set(l,h));var c=F(h);if(c===Mt)return!1}return u},set(a,l,h,u){var c=t.get(l),d=l in a;if(i&&l==="length")for(var f=h;f<c.v;f+=1){var p=t.get(f+"");p!==void 0?_e(p,Mt):f in a&&(p=o(()=>Ge(Mt)),t.set(f+"",p))}if(c===void 0)(!d||Fr(a,l)?.writable)&&(c=o(()=>Ge(void 0)),_e(c,Wi(h)),t.set(l,c));else{d=c.v!==Mt;var g=o(()=>Wi(h));_e(c,g)}var m=Reflect.getOwnPropertyDescriptor(a,l);if(m?.set&&m.set.call(u,h),!d){if(i&&typeof l=="string"){var v=t.get("length"),_=Number(l);Number.isInteger(_)&&_>=v.v&&_e(v,_+1)}ui(r)}return!0},ownKeys(a){F(r);var l=Reflect.ownKeys(a).filter(c=>{var d=t.get(c);return d===void 0||d.v!==Mt});for(var[h,u]of t)u.v!==Mt&&!(h in a)&&l.push(h);return l},setPrototypeOf(){O_()}})}function od(n){try{if(n!==null&&typeof n=="object"&&rr in n)return n[rr]}catch{}return n}function t0(n,e){return Object.is(od(n),od(e))}var ad,ld,hd,ud;function i0(){if(ad===void 0){ad=window,ld=/Firefox/.test(navigator.userAgent);var n=Element.prototype,e=Node.prototype,t=Text.prototype;hd=Fr(e,"firstChild").get,ud=Fr(e,"nextSibling").get,Uc(n)&&(n.__click=void 0,n.__className=void 0,n.__attributes=null,n.__style=void 0,n.__e=void 0),Uc(t)&&(t.__t=void 0)}}function vn(n=""){return document.createTextNode(n)}function ji(n){return hd.call(n)}function ks(n){return ud.call(n)}function Ne(n,e){return ji(n)}function _i(n,e=!1){{var t=ji(n);return t instanceof Comment&&t.data===""?ks(t):t}}function Ze(n,e=1,t=!1){let i=n;for(;e--;)i=ks(i);return i}function n0(n){n.textContent=""}function cd(){return!1}function r0(n,e){if(e){const t=document.body;n.autofocus=!0,or(()=>{document.activeElement===t&&n.focus()})}}let dd=!1;function s0(){dd||(dd=!0,document.addEventListener("reset",n=>{Promise.resolve().then(()=>{if(!n.defaultPrevented)for(const e of n.target.elements)e.__on_r?.()})},{capture:!0}))}function zo(n){var e=Ke,t=it;oi(null),qi(null);try{return n()}finally{oi(e),qi(t)}}function fd(n,e,t,i=t){n.addEventListener(e,()=>zo(t));const r=n.__on_r;r?n.__on_r=()=>{r(),i(!0)}:n.__on_r=()=>i(!0),s0()}function o0(n){it===null&&(Ke===null&&P_(),C_()),ur&&R_()}function a0(n,e){var t=e.last;t===null?e.last=e.first=n:(t.next=n,n.prev=t,e.last=n)}function Di(n,e,t){var i=it;i!==null&&(i.f&hi)!==0&&(n|=hi);var r={ctx:Lt,deps:null,nodes:null,f:n|ri|Pi,first:null,fn:e,last:null,next:null,parent:i,b:i&&i.b,prev:null,teardown:null,wv:0,ac:null};if(t)try{Vs(r),r.f|=Fl}catch(a){throw St(r),a}else e!==null&&ar(r);var s=r;if(t&&s.deps===null&&s.teardown===null&&s.nodes===null&&s.first===s.last&&(s.f&ir)===0&&(s=s.first,(n&un)!==0&&(n&Pn)!==0&&s!==null&&(s.f|=Pn)),s!==null&&(s.parent=i,i!==null&&a0(s,i),Ke!==null&&(Ke.f&Ot)!==0&&(n&Cn)===0)){var o=Ke;(o.effects??=[]).push(s)}return r}function Us(){return Ke!==null&&!Yi}function pd(n){const e=Di(Bl,null,!1);return jt(e,Wt),e.teardown=n,e}function Xi(n){o0();var e=it.f,t=!Ke&&(e&cn)!==0&&(e&Fl)===0;if(t){var i=Lt;(i.e??=[]).push(n)}else return gd(n)}function gd(n){return Di(Ll|E_,n,!1)}function l0(n){Ii.ensure();const e=Di(Cn|ir,n,!0);return()=>{St(e)}}function h0(n){Ii.ensure();const e=Di(Cn|ir,n,!0);return(t={})=>new Promise(i=>{t.outro?lr(e,()=>{St(e),i(void 0)}):(St(e),i(void 0))})}function Go(n){return Di(Ll,n,!1)}function u0(n){return Di(kl|ir,n,!0)}function Vl(n,e=0){return Di(Bl|e,n,!0)}function st(n,e=[],t=[],i=[]){ed(i,e,t,r=>{Di(Bl,()=>n(...r.map(F)),!0)})}function Hs(n,e=0){var t=Di(un|e,n,!0);return t}function md(n,e=0){var t=Di(zc|e,n,!0);return t}function si(n){return Di(cn|ir,n,!0)}function vd(n){var e=n.teardown;if(e!==null){const t=ur,i=Ke;bd(!0),oi(null);try{e.call(null)}finally{bd(t),oi(i)}}}function yd(n,e=!1){var t=n.first;for(n.first=n.last=null;t!==null;){const r=t.ac;r!==null&&zo(()=>{r.abort(Nr)});var i=t.next;(t.f&Cn)!==0?t.parent=null:St(t,e),t=i}}function c0(n){for(var e=n.first;e!==null;){var t=e.next;(e.f&cn)===0&&St(e),e=t}}function St(n,e=!0){var t=!1;(e||(n.f&Vc)!==0)&&n.nodes!==null&&n.nodes.end!==null&&(_d(n.nodes.start,n.nodes.end),t=!0),yd(n,e&&!t),Wo(n,0),jt(n,fn);var i=n.nodes&&n.nodes.t;if(i!==null)for(const s of i)s.stop();vd(n);var r=n.parent;r!==null&&r.first!==null&&xd(n),n.next=n.prev=n.teardown=n.ctx=n.deps=n.fn=n.nodes=n.ac=null}function _d(n,e){for(;n!==null;){var t=n===e?null:ks(n);n.remove(),n=t}}function xd(n){var e=n.parent,t=n.prev,i=n.next;t!==null&&(t.next=i),i!==null&&(i.prev=t),e!==null&&(e.first===n&&(e.first=i),e.last===n&&(e.last=t))}function lr(n,e,t=!0){var i=[];wd(n,i,!0);var r=()=>{t&&St(n),e&&e()},s=i.length;if(s>0){var o=()=>--s||r();for(var a of i)a.out(o)}else r()}function wd(n,e,t){if((n.f&hi)===0){n.f^=hi;var i=n.nodes&&n.nodes.t;if(i!==null)for(const a of i)(a.is_global||t)&&e.push(a);for(var r=n.first;r!==null;){var s=r.next,o=(r.f&Pn)!==0||(r.f&cn)!==0&&(n.f&un)!==0;wd(r,e,o?t:!1),r=s}}}function Wl(n){Td(n,!0)}function Td(n,e){if((n.f&hi)!==0){n.f^=hi,(n.f&Wt)===0&&(jt(n,ri),ar(n));for(var t=n.first;t!==null;){var i=t.next,r=(t.f&Pn)!==0||(t.f&cn)!==0;Td(t,r?e:!1),t=i}var s=n.nodes&&n.nodes.t;if(s!==null)for(const o of s)(o.is_global||e)&&o.in()}}function Ed(n,e){if(n.nodes)for(var t=n.nodes.start,i=n.nodes.end;t!==null;){var r=t===i?null:ks(t);e.append(t),t=r}}let hr=!1;function Vo(n){hr=n}let ur=!1;function bd(n){ur=n}let Ke=null,Yi=!1;function oi(n){Ke=n}let it=null;function qi(n){it=n}let yn=null;function Sd(n){Ke!==null&&(yn===null?yn=[n]:yn.push(n))}let Qt=null,ci=0,xi=null;function d0(n){xi=n}let Ad=1,zs=0,Mi=zs;function Rd(n){Mi=n}function Cd(){return++Ad}function Gs(n){var e=n.f;if((e&ri)!==0)return!0;if(e&Ot&&(n.f&=~nr),(e&dn)!==0){var t=n.deps;if(t!==null)for(var i=t.length,r=0;r<i;r++){var s=t[r];if(Gs(s)&&nd(s),s.wv>n.wv)return!0}(e&Pi)!==0&&vi===null&&jt(n,Wt)}return!1}function Pd(n,e,t=!0){var i=n.reactions;if(i!==null&&!yn?.includes(n))for(var r=0;r<i.length;r++){var s=i[r];(s.f&Ot)!==0?Pd(s,e,!1):e===s&&(t?jt(s,ri):(s.f&Wt)!==0&&jt(s,dn),ar(s))}}function Id(n){var e=Qt,t=ci,i=xi,r=Ke,s=yn,o=Lt,a=Yi,l=Mi,h=n.f;Qt=null,ci=0,xi=null,Ke=(h&(cn|Cn))===0?n:null,yn=null,kr(n.ctx),Yi=!1,Mi=++zs,n.ac!==null&&(zo(()=>{n.ac.abort(Nr)}),n.ac=null);try{n.f|=Nl;var u=n.fn,c=u(),d=n.deps;if(Qt!==null){var f;if(Wo(n,ci),d!==null&&ci>0)for(d.length=ci+Qt.length,f=0;f<Qt.length;f++)d[ci+f]=Qt[f];else n.deps=d=Qt;if(Us()&&(n.f&Pi)!==0)for(f=ci;f<d.length;f++)(d[f].reactions??=[]).push(n)}else d!==null&&ci<d.length&&(Wo(n,ci),d.length=ci);if(Yc()&&xi!==null&&!Yi&&d!==null&&(n.f&(Ot|dn|ri))===0)for(f=0;f<xi.length;f++)Pd(xi[f],n);return r!==null&&r!==n&&(zs++,xi!==null&&(i===null?i=xi:i.push(...xi))),(n.f&In)!==0&&(n.f^=In),c}catch(p){return Zc(p)}finally{n.f^=Nl,Qt=e,ci=t,xi=i,Ke=r,yn=s,kr(o),Yi=a,Mi=l}}function f0(n,e){let t=e.reactions;if(t!==null){var i=v_.call(t,n);if(i!==-1){var r=t.length-1;r===0?t=e.reactions=null:(t[i]=t[r],t.pop())}}t===null&&(e.f&Ot)!==0&&(Qt===null||!Qt.includes(e))&&(jt(e,dn),(e.f&Pi)!==0&&(e.f^=Pi,e.f&=~nr),id(e),Wo(e,0))}function Wo(n,e){var t=n.deps;if(t!==null)for(var i=e;i<t.length;i++)f0(n,t[i])}function Vs(n){var e=n.f;if((e&fn)===0){jt(n,Wt);var t=it,i=hr;it=n,hr=!0;try{(e&(un|zc))!==0?c0(n):yd(n),vd(n);var r=Id(n);n.teardown=typeof r=="function"?r:null,n.wv=Ad;var s;Ml&&U_&&(n.f&ri)!==0&&n.deps}finally{hr=i,it=t}}}async function p0(){await Promise.resolve(),V_()}function F(n){var e=n.f,t=(e&Ot)!==0;if(Ke!==null&&!Yi){var i=it!==null&&(it.f&fn)!==0;if(!i&&!yn?.includes(n)){var r=Ke.deps;if((Ke.f&Nl)!==0)n.rv<zs&&(n.rv=zs,Qt===null&&r!==null&&r[ci]===n?ci++:Qt===null?Qt=[n]:Qt.includes(n)||Qt.push(n));else{(Ke.deps??=[]).push(n);var s=n.reactions;s===null?n.reactions=[Ke]:s.includes(Ke)||s.push(Ke)}}}if(ur){if(Dn.has(n))return Dn.get(n);if(t){var o=n,a=o.v;return((o.f&Wt)===0&&o.reactions!==null||Md(o))&&(a=zl(o)),Dn.set(o,a),a}}else t&&(!vi?.has(n)||Je?.is_fork&&!Us())&&(o=n,Gs(o)&&nd(o),hr&&Us()&&(o.f&Pi)===0&&Dd(o));if(vi?.has(n))return vi.get(n);if((n.f&In)!==0)throw n.v;return n.v}function Dd(n){if(n.deps!==null){n.f^=Pi;for(const e of n.deps)(e.reactions??=[]).push(n),(e.f&Ot)!==0&&(e.f&Pi)===0&&Dd(e)}}function Md(n){if(n.v===Mt)return!0;if(n.deps===null)return!1;for(const e of n.deps)if(Dn.has(e)||(e.f&Ot)!==0&&Md(e))return!0;return!1}function Mn(n){var e=Yi;try{return Yi=!0,n()}finally{Yi=e}}const g0=-7169;function jt(n,e){n.f=n.f&g0|e}const Od=new Set,jl=new Set;function m0(n,e,t,i={}){function r(s){if(i.capture||Ws.call(e,s),!s.cancelBubble)return zo(()=>t?.call(this,s))}return n.startsWith("pointer")||n.startsWith("touch")||n==="wheel"?or(()=>{e.addEventListener(n,r,i)}):e.addEventListener(n,r,i),r}function Xl(n){for(var e=0;e<n.length;e++)Od.add(n[e]);for(var t of jl)t(n)}let Ld=null;function Ws(n){var e=this,t=e.ownerDocument,i=n.type,r=n.composedPath?.()||[],s=r[0]||n.target;Ld=n;var o=0,a=Ld===n&&n.__root;if(a){var l=r.indexOf(a);if(l!==-1&&(e===document||e===window)){n.__root=e;return}var h=r.indexOf(e);if(h===-1)return;l<=h&&(o=l)}if(s=r[o]||n.target,s!==e){y_(n,"currentTarget",{configurable:!0,get(){return s||t}});var u=Ke,c=it;oi(null),qi(null);try{for(var d,f=[];s!==null;){var p=s.assignedSlot||s.parentNode||s.host||null;try{var g=s["__"+i];g!=null&&(!s.disabled||n.target===s)&&g.call(s,n)}catch(m){d?f.push(m):d=m}if(n.cancelBubble||p===e||p===null)break;s=p}if(d){for(let m of f)queueMicrotask(()=>{throw m});throw d}}finally{n.__root=e,delete n.currentTarget,oi(u),qi(c)}}}function Yl(n){var e=document.createElement("template");return e.innerHTML=n.replaceAll("<!>","<!---->"),e.content}function Vr(n,e){var t=it;t.nodes===null&&(t.nodes={start:n,end:e,a:null,t:null})}function rt(n,e){var t=(e&f_)!==0,i=(e&p_)!==0,r,s=!n.startsWith("<!>");return()=>{r===void 0&&(r=Yl(s?n:"<!>"+n),t||(r=ji(r)));var o=i||ld?document.importNode(r,!0):r.cloneNode(!0);if(t){var a=ji(o),l=o.lastChild;Vr(a,l)}else Vr(o,o);return o}}function v0(n,e,t="svg"){var i=!n.startsWith("<!>"),r=`<${t}>${i?n:"<!>"+n}</${t}>`,s;return()=>{if(!s){var o=Yl(r),a=ji(o);s=ji(a)}var l=s.cloneNode(!0);return Vr(l,l),l}}function Bd(n,e){return v0(n,e,"svg")}function jo(n=""){{var e=vn(n+"");return Vr(e,e),e}}function js(){var n=document.createDocumentFragment(),e=document.createComment(""),t=vn();return n.append(e,t),Vr(e,t),n}function Ve(n,e){n!==null&&n.before(e)}function y0(n){return n.endsWith("capture")&&n!=="gotpointercapture"&&n!=="lostpointercapture"}const _0=["beforeinput","click","change","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"];function x0(n){return _0.includes(n)}const w0={formnovalidate:"formNoValidate",ismap:"isMap",nomodule:"noModule",playsinline:"playsInline",readonly:"readOnly",defaultvalue:"defaultValue",defaultchecked:"defaultChecked",srcobject:"srcObject",novalidate:"noValidate",allowfullscreen:"allowFullscreen",disablepictureinpicture:"disablePictureInPicture",disableremoteplayback:"disableRemotePlayback"};function T0(n){return n=n.toLowerCase(),w0[n]??n}const E0=["touchstart","touchmove"];function b0(n){return E0.includes(n)}function mt(n,e){var t=e==null?"":typeof e=="object"?e+"":e;t!==(n.__t??=n.nodeValue)&&(n.__t=t,n.nodeValue=t+"")}function S0(n,e){return A0(n,e)}const Wr=new Map;function A0(n,{target:e,anchor:t,props:i={},events:r,context:s,intro:o=!0}){i0();var a=new Set,l=c=>{for(var d=0;d<c.length;d++){var f=c[d];if(!a.has(f)){a.add(f);var p=b0(f);e.addEventListener(f,Ws,{passive:p});var g=Wr.get(f);g===void 0?(document.addEventListener(f,Ws,{passive:p}),Wr.set(f,1)):Wr.set(f,g+1)}}};l(Bo(Od)),jl.add(l);var h=void 0,u=h0(()=>{var c=t??e.appendChild(vn());return Y_(c,{pending:()=>{}},d=>{if(s){Ur({});var f=Lt;f.c=s}r&&(i.$$events=r),h=n(d,i)||{},s&&Hr()}),()=>{for(var d of a){e.removeEventListener(d,Ws);var f=Wr.get(d);--f===0?(document.removeEventListener(d,Ws),Wr.delete(d)):Wr.set(d,f)}jl.delete(l),c!==t&&c.parentNode?.removeChild(c)}});return ql.set(h,u),h}let ql=new WeakMap;function R0(n,e){const t=ql.get(n);return t?(ql.delete(n),t(e)):Promise.resolve()}class Zl{anchor;#e=new Map;#t=new Map;#i=new Map;#n=new Set;#r=!0;constructor(e,t=!0){this.anchor=e,this.#r=t}#s=()=>{var e=Je;if(this.#e.has(e)){var t=this.#e.get(e),i=this.#t.get(t);if(i)Wl(i),this.#n.delete(t);else{var r=this.#i.get(t);r&&(this.#t.set(t,r.effect),this.#i.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),i=r.effect)}for(const[s,o]of this.#e){if(this.#e.delete(s),s===e)break;const a=this.#i.get(o);a&&(St(a.effect),this.#i.delete(o))}for(const[s,o]of this.#t){if(s===t||this.#n.has(s))continue;const a=()=>{if(Array.from(this.#e.values()).includes(s)){var h=document.createDocumentFragment();Ed(o,h),h.append(vn()),this.#i.set(s,{effect:o,fragment:h})}else St(o);this.#n.delete(s),this.#t.delete(s)};this.#r||!i?(this.#n.add(s),lr(o,a,!1)):a()}}};#o=e=>{this.#e.delete(e);const t=Array.from(this.#e.values());for(const[i,r]of this.#i)t.includes(i)||(St(r.effect),this.#i.delete(i))};ensure(e,t){var i=Je,r=cd();if(t&&!this.#t.has(e)&&!this.#i.has(e))if(r){var s=document.createDocumentFragment(),o=vn();s.append(o),this.#i.set(e,{effect:si(()=>t(o)),fragment:s})}else this.#t.set(e,si(()=>t(this.anchor)));if(this.#e.set(i,e),r){for(const[a,l]of this.#t)a===e?i.skipped_effects.delete(l):i.skipped_effects.add(l);for(const[a,l]of this.#i)a===e?i.skipped_effects.delete(l.effect):i.skipped_effects.add(l.effect);i.oncommit(this.#s),i.ondiscard(this.#o)}else this.#s()}}function Kl(n,e,...t){var i=new Zl(n);Hs(()=>{const r=e()??null;i.ensure(r,r&&(s=>r(s,...t)))},Pn)}function Fd(n){Lt===null&&Ul(),Xi(()=>{const e=Mn(n);if(typeof e=="function")return e})}function C0(n){Lt===null&&Ul(),Fd(()=>()=>Mn(n))}function Xt(n,e,t=!1){var i=new Zl(n),r=t?Pn:0;function s(o,a){i.ensure(o,a)}Hs(()=>{var o=!1;e((a,l=!0)=>{o=!0,s(l,a)}),o||s(!1,null)},r)}function P0(n,e){return e}function I0(n,e,t){for(var i=[],r=e.length,s,o=e.length,a=0;a<r;a++){let c=e[a];lr(c,()=>{if(s){if(s.pending.delete(c),s.done.add(c),s.pending.size===0){var d=n.outrogroups;Ql(Bo(s.done)),d.delete(s),d.size===0&&(n.outrogroups=null)}}else o-=1},!1)}if(o===0){var l=i.length===0&&t!==null;if(l){var h=t,u=h.parentNode;n0(u),u.append(h),n.items.clear()}Ql(e,!l)}else s={pending:new Set(e),done:new Set},(n.outrogroups??=new Set).add(s)}function Ql(n,e=!0){for(var t=0;t<n.length;t++)St(n[t],e)}var Nd;function Xo(n,e,t,i,r,s=null){var o=n,a=new Map,l=(e&Nc)!==0;if(l){var h=n;o=h.appendChild(vn())}var u=null,c=td(()=>{var v=t();return Ol(v)?v:v==null?[]:Bo(v)}),d,f=!0;function p(){m.fallback=u,D0(m,d,o,e,i),u!==null&&(d.length===0?(u.f&pn)===0?Wl(u):(u.f^=pn,Xs(u,null,o)):lr(u,()=>{u=null}))}var g=Hs(()=>{d=F(c);for(var v=d.length,_=new Set,y=Je,w=cd(),R=0;R<v;R+=1){var M=d[R],C=i(M,R),O=f?null:a.get(C);O?(O.v&&Gr(O.v,M),O.i&&Gr(O.i,R),w&&y.skipped_effects.delete(O.e)):(O=M0(a,f?o:Nd??=vn(),M,C,R,r,e,t),f||(O.e.f|=pn),a.set(C,O)),_.add(C)}if(v===0&&s&&!u&&(f?u=si(()=>s(o)):(u=si(()=>s(Nd??=vn())),u.f|=pn)),!f)if(w){for(const[N,X]of a)_.has(N)||y.skipped_effects.add(X.e);y.oncommit(p),y.ondiscard(()=>{})}else p();F(c)}),m={effect:g,items:a,outrogroups:null,fallback:u};f=!1}function D0(n,e,t,i,r){var s=(i&a_)!==0,o=e.length,a=n.items,l=n.effect.first,h,u=null,c,d=[],f=[],p,g,m,v;if(s)for(v=0;v<o;v+=1)p=e[v],g=r(p,v),m=a.get(g).e,(m.f&pn)===0&&(m.nodes?.a?.measure(),(c??=new Set).add(m));for(v=0;v<o;v+=1){if(p=e[v],g=r(p,v),m=a.get(g).e,n.outrogroups!==null)for(const X of n.outrogroups)X.pending.delete(m),X.done.delete(m);if((m.f&pn)!==0)if(m.f^=pn,m===l)Xs(m,null,t);else{var _=u?u.next:l;m===n.effect.last&&(n.effect.last=m.prev),m.prev&&(m.prev.next=m.next),m.next&&(m.next.prev=m.prev),On(n,u,m),On(n,m,_),Xs(m,_,t),u=m,d=[],f=[],l=u.next;continue}if((m.f&hi)!==0&&(Wl(m),s&&(m.nodes?.a?.unfix(),(c??=new Set).delete(m))),m!==l){if(h!==void 0&&h.has(m)){if(d.length<f.length){var y=f[0],w;u=y.prev;var R=d[0],M=d[d.length-1];for(w=0;w<d.length;w+=1)Xs(d[w],y,t);for(w=0;w<f.length;w+=1)h.delete(f[w]);On(n,R.prev,M.next),On(n,u,R),On(n,M,y),l=y,u=M,v-=1,d=[],f=[]}else h.delete(m),Xs(m,l,t),On(n,m.prev,m.next),On(n,m,u===null?n.effect.first:u.next),On(n,u,m),u=m;continue}for(d=[],f=[];l!==null&&l!==m;)(h??=new Set).add(l),f.push(l),l=l.next;if(l===null)continue}(m.f&pn)===0&&d.push(m),u=m,l=m.next}if(n.outrogroups!==null){for(const X of n.outrogroups)X.pending.size===0&&(Ql(Bo(X.done)),n.outrogroups?.delete(X));n.outrogroups.size===0&&(n.outrogroups=null)}if(l!==null||h!==void 0){var C=[];if(h!==void 0)for(m of h)(m.f&hi)===0&&C.push(m);for(;l!==null;)(l.f&hi)===0&&l!==n.fallback&&C.push(l),l=l.next;var O=C.length;if(O>0){var N=(i&Nc)!==0&&o===0?t:null;if(s){for(v=0;v<O;v+=1)C[v].nodes?.a?.measure();for(v=0;v<O;v+=1)C[v].nodes?.a?.fix()}I0(n,C,N)}}s&&or(()=>{if(c!==void 0)for(m of c)m.nodes?.a?.apply()})}function M0(n,e,t,i,r,s,o,a){var l=(o&s_)!==0?(o&l_)===0?J_(t,!1,!1):mn(t):null,h=(o&o_)!==0?mn(r):null;return{v:l,i:h,e:si(()=>(s(e,l??t,h??r,a),()=>{n.delete(i)}))}}function Xs(n,e,t){if(n.nodes)for(var i=n.nodes.start,r=n.nodes.end,s=e&&(e.f&pn)===0?e.nodes.start:t;i!==null;){var o=ks(i);if(s.before(i),i===r)return;i=o}}function On(n,e,t){e===null?n.effect.first=t:e.next=t,t===null?n.effect.last=e:t.prev=e}function kd(n,e,t=!1,i=!1,r=!1){var s=n,o="";st(()=>{var a=it;if(o!==(o=e()??"")&&(a.nodes!==null&&(_d(a.nodes.start,a.nodes.end),a.nodes=null),o!=="")){var l=o+"";t?l=`<svg>${l}</svg>`:i&&(l=`<math>${l}</math>`);var h=Yl(l);if((t||i)&&(h=ji(h)),Vr(ji(h),h.lastChild),t||i)for(;ji(h);)s.before(ji(h));else s.before(h)}})}function O0(n,e,t){var i=new Zl(n);Hs(()=>{var r=e()??null;i.ensure(r,r&&(s=>t(s,r)))},Pn)}function L0(n,e){var t=void 0,i;md(()=>{t!==(t=e())&&(i&&(St(i),i=null),t&&(i=si(()=>{Go(()=>t(n))})))})}function Ud(n){var e,t,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(e=0;e<r;e++)n[e]&&(t=Ud(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function B0(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=Ud(n))&&(i&&(i+=" "),i+=e);return i}function F0(n){return typeof n=="object"?B0(n):n??""}const Hd=[...`
5
+ \r\f \v\uFEFF`];function N0(n,e,t){var i=n==null?"":""+n;if(e&&(i=i?i+" "+e:e),t){for(var r in t)if(t[r])i=i?i+" "+r:r;else if(i.length)for(var s=r.length,o=0;(o=i.indexOf(r,o))>=0;){var a=o+s;(o===0||Hd.includes(i[o-1]))&&(a===i.length||Hd.includes(i[a]))?i=(o===0?"":i.substring(0,o))+i.substring(a+1):o=a}}return i===""?null:i}function zd(n,e=!1){var t=e?" !important;":";",i="";for(var r in n){var s=n[r];s!=null&&s!==""&&(i+=" "+r+": "+s+t)}return i}function Jl(n){return n[0]!=="-"||n[1]!=="-"?n.toLowerCase():n}function k0(n,e){if(e){var t="",i,r;if(Array.isArray(e)?(i=e[0],r=e[1]):i=e,n){n=String(n).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var s=!1,o=0,a=!1,l=[];i&&l.push(...Object.keys(i).map(Jl)),r&&l.push(...Object.keys(r).map(Jl));var h=0,u=-1;const g=n.length;for(var c=0;c<g;c++){var d=n[c];if(a?d==="/"&&n[c-1]==="*"&&(a=!1):s?s===d&&(s=!1):d==="/"&&n[c+1]==="*"?a=!0:d==='"'||d==="'"?s=d:d==="("?o++:d===")"&&o--,!a&&s===!1&&o===0){if(d===":"&&u===-1)u=c;else if(d===";"||c===g-1){if(u!==-1){var f=Jl(n.substring(h,u).trim());if(!l.includes(f)){d!==";"&&c++;var p=n.substring(h,c).trim();t+=" "+p+";"}}h=c+1,u=-1}}}}return i&&(t+=zd(i)),r&&(t+=zd(r,!0)),t=t.trim(),t===""?null:t}return n==null?null:String(n)}function Ln(n,e,t,i,r,s){var o=n.__className;if(o!==t||o===void 0){var a=N0(t,i,s);a==null?n.removeAttribute("class"):e?n.className=a:n.setAttribute("class",a),n.__className=t}else if(s&&r!==s)for(var l in s){var h=!!s[l];(r==null||h!==!!r[l])&&n.classList.toggle(l,h)}return s}function $l(n,e={},t,i){for(var r in t){var s=t[r];e[r]!==s&&(t[r]==null?n.style.removeProperty(r):n.style.setProperty(r,s,i))}}function eh(n,e,t,i){var r=n.__style;if(r!==e){var s=k0(e,i);s==null?n.removeAttribute("style"):n.style.cssText=s,n.__style=e}else i&&(Array.isArray(i)?($l(n,t?.[0],i[0]),$l(n,t?.[1],i[1],"important")):$l(n,t,i));return i}function Yo(n,e,t=!1){if(n.multiple){if(e==null)return;if(!Ol(e))return F_();for(var i of n.options)i.selected=e.includes(Ys(i));return}for(i of n.options){var r=Ys(i);if(t0(r,e)){i.selected=!0;return}}(!t||e!==void 0)&&(n.selectedIndex=-1)}function Gd(n){var e=new MutationObserver(()=>{Yo(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),pd(()=>{e.disconnect()})}function U0(n,e,t=e){var i=new WeakSet,r=!0;fd(n,"change",s=>{var o=s?"[selected]":":checked",a;if(n.multiple)a=[].map.call(n.querySelectorAll(o),Ys);else{var l=n.querySelector(o)??n.querySelector("option:not([disabled])");a=l&&Ys(l)}t(a),Je!==null&&i.add(Je)}),Go(()=>{var s=e();if(n===document.activeElement){var o=Fs??Je;if(i.has(o))return}if(Yo(n,s,r),r&&s===void 0){var a=n.querySelector(":checked");a!==null&&(s=Ys(a),t(s))}n.__value=s,r=!1}),Gd(n)}function Ys(n){return"__value"in n?n.__value:n.value}const Bn=Symbol("class"),qs=Symbol("style"),Vd=Symbol("is custom element"),Wd=Symbol("is html");function H0(n,e){e?n.hasAttribute("selected")||n.setAttribute("selected",""):n.removeAttribute("selected")}function Bt(n,e,t,i){var r=jd(n);r[e]!==(r[e]=t)&&(e==="loading"&&(n[S_]=t),t==null?n.removeAttribute(e):typeof t!="string"&&Yd(n).includes(e)?n[e]=t:n.setAttribute(e,t))}function z0(n,e,t,i,r=!1,s=!1){var o=jd(n),a=o[Vd],l=!o[Wd],h=e||{},u=n.tagName==="OPTION";for(var c in e)c in t||(t[c]=null);t.class?t.class=F0(t.class):(i||t[Bn])&&(t.class=null),t[qs]&&(t.style??=null);var d=Yd(n);for(const y in t){let w=t[y];if(u&&y==="value"&&w==null){n.value=n.__value="",h[y]=w;continue}if(y==="class"){var f=n.namespaceURI==="http://www.w3.org/1999/xhtml";Ln(n,f,w,i,e?.[Bn],t[Bn]),h[y]=w,h[Bn]=t[Bn];continue}if(y==="style"){eh(n,w,e?.[qs],t[qs]),h[y]=w,h[qs]=t[qs];continue}var p=h[y];if(!(w===p&&!(w===void 0&&n.hasAttribute(y)))){h[y]=w;var g=y[0]+y[1];if(g!=="$$")if(g==="on"){const R={},M="$$"+y;let C=y.slice(2);var m=x0(C);if(y0(C)&&(C=C.slice(0,-7),R.capture=!0),!m&&p){if(w!=null)continue;n.removeEventListener(C,h[M],R),h[M]=null}if(w!=null)if(m)n[`__${C}`]=w,Xl([C]);else{let O=function(N){h[y].call(this,N)};h[M]=m0(C,n,O,R)}else m&&(n[`__${C}`]=void 0)}else if(y==="style")Bt(n,y,w);else if(y==="autofocus")r0(n,!!w);else if(!a&&(y==="__value"||y==="value"&&w!=null))n.value=n.__value=w;else if(y==="selected"&&u)H0(n,w);else{var v=y;l||(v=T0(v));var _=v==="defaultValue"||v==="defaultChecked";if(w==null&&!a&&!_)if(o[y]=null,v==="value"||v==="checked"){let R=n;const M=e===void 0;if(v==="value"){let C=R.defaultValue;R.removeAttribute(v),R.defaultValue=C,R.value=R.__value=M?C:null}else{let C=R.defaultChecked;R.removeAttribute(v),R.defaultChecked=C,R.checked=M?C:!1}}else n.removeAttribute(y);else _||d.includes(v)&&(a||typeof w!="string")?(n[v]=w,v in o&&(o[v]=Mt)):typeof w!="function"&&Bt(n,v,w)}}}return h}function qo(n,e,t=[],i=[],r=[],s,o=!1,a=!1){ed(r,t,i,l=>{var h=void 0,u={},c=n.nodeName==="SELECT",d=!1;if(md(()=>{var p=e(...l.map(F)),g=z0(n,h,p,s,o,a);d&&c&&"value"in p&&Yo(n,p.value);for(let v of Object.getOwnPropertySymbols(u))p[v]||St(u[v]);for(let v of Object.getOwnPropertySymbols(p)){var m=p[v];v.description===m_&&(!h||m!==h[v])&&(u[v]&&St(u[v]),u[v]=si(()=>L0(n,()=>m))),g[v]=m}h=g}),c){var f=n;Go(()=>{Yo(f,h.value,!0),Gd(f)})}d=!0})}function jd(n){return n.__attributes??={[Vd]:n.nodeName.includes("-"),[Wd]:n.namespaceURI===g_}}var Xd=new Map;function Yd(n){var e=n.getAttribute("is")||n.nodeName,t=Xd.get(e);if(t)return t;Xd.set(e,t=[]);for(var i,r=n,s=Element.prototype;s!==r;){i=__(r);for(var o in i)i[o].set&&t.push(o);r=kc(r)}return t}function qd(n,e,t=e){var i=new WeakSet;fd(n,"input",async r=>{var s=r?n.defaultValue:n.value;if(s=th(n)?ih(s):s,t(s),Je!==null&&i.add(Je),await p0(),s!==(s=e())){var o=n.selectionStart,a=n.selectionEnd,l=n.value.length;if(n.value=s??"",a!==null){var h=n.value.length;o===a&&a===l&&h>l?(n.selectionStart=h,n.selectionEnd=h):(n.selectionStart=o,n.selectionEnd=Math.min(a,h))}}}),Mn(e)==null&&n.value&&(t(th(n)?ih(n.value):n.value),Je!==null&&i.add(Je)),Vl(()=>{var r=e();if(n===document.activeElement){var s=Fs??Je;if(i.has(s))return}th(n)&&r===ih(n.value)||n.type==="date"&&!r&&!n.value||r!==n.value&&(n.value=r??"")})}function th(n){var e=n.type;return e==="number"||e==="range"}function ih(n){return n===""?null:+n}function Zd(n,e){return n===e||n?.[rr]===e}function Zo(n={},e,t,i){return Go(()=>{var r,s;return Vl(()=>{r=s,s=[],Mn(()=>{n!==t(...s)&&(e(n,...s),r&&Zd(t(...r),n)&&e(null,...r))})}),()=>{or(()=>{s&&Zd(t(...s),n)&&e(null,...s)})}}),n}let Ko=!1;function G0(n){var e=Ko;try{return Ko=!1,[n(),Ko]}finally{Ko=e}}const V0={get(n,e){if(!n.exclude.includes(e))return n.props[e]},set(n,e){return!1},getOwnPropertyDescriptor(n,e){if(!n.exclude.includes(e)&&e in n.props)return{enumerable:!0,configurable:!0,value:n.props[e]}},has(n,e){return n.exclude.includes(e)?!1:e in n.props},ownKeys(n){return Reflect.ownKeys(n.props).filter(e=>!n.exclude.includes(e))}};function Qo(n,e,t){return new Proxy({props:n,exclude:e},V0)}function Le(n,e,t,i){var r=(t&c_)!==0,s=(t&d_)!==0,o=i,a=!0,l=()=>(a&&(a=!1,o=s?Mn(i):i),o),h;if(r){var u=rr in n||b_ in n;h=Fr(n,e)?.set??(u&&e in n?_=>n[e]=_:void 0)}var c,d=!1;r?[c,d]=G0(()=>n[e]):c=n[e],c===void 0&&i!==void 0&&(c=l(),h&&(D_(),h(c)));var f;if(f=()=>{var _=n[e];return _===void 0?l():(a=!0,_)},(t&u_)===0)return f;if(h){var p=n.$$legacy;return(function(_,y){return arguments.length>0?((!y||p||d)&&h(y?f():_),_):f()})}var g=!1,m=((t&h_)!==0?Ho:td)(()=>(g=!1,f()));r&&F(m);var v=it;return(function(_,y){if(arguments.length>0){const w=y?F(m):r?Wi(_):_;return _e(m,w),g=!0,o!==void 0&&(o=w),_}return ur&&g||(v.f&fn)!==0?m.v:F(m)})}const W0=".btn.svelte-sgoebi{display:inline-flex;flex-wrap:nowrap;flex-shrink:0;justify-content:center;align-items:center;gap:.375rem;cursor:pointer;text-align:center;vertical-align:middle;user-select:none;-webkit-user-select:none;touch-action:manipulation;font-weight:600;height:var(--size);padding-inline:var(--btn-p);font-size:var(--fontsize, .875rem);color:var(--btn-fg);background-color:var(--btn-bg);border-width:var(--tri-border);border-style:solid;border-color:var(--btn-border);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));outline-offset:2px;outline-color:var(--btn-color, var(--tri-content));text-shadow:0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * .15));box-shadow:0 .5px 0 .5px oklch(100% 0 0 / calc(var(--tri-depth) * 6%)) inset,var(--btn-shadow);transition-property:color,background-color,border-color,box-shadow;transition-duration:.2s;transition-timing-function:cubic-bezier(0,0,.2,1);--size: calc(var(--tri-size-field, .25rem) * 10);--btn-bg: var(--btn-color, var(--tri-toolbar-bg));--btn-fg: var(--tri-content);--btn-p: 1rem;--btn-border: color-mix( in oklab, var(--btn-bg), #000 calc(var(--tri-depth) * 5%) );--btn-shadow: 0 3px 2px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 ), 0 4px 3px -2px color-mix( in oklab, var(--btn-bg) calc(var(--tri-depth) * 30%), #0000 )}@media(hover:hover){.btn.svelte-sgoebi:hover{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}}.btn.svelte-sgoebi:focus-visible{isolation:isolate;outline-width:2px;outline-style:solid}.btn.svelte-sgoebi:active:not(.active){--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 5% );--btn-border: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% );--btn-shadow: 0 0 0 0 oklch(0% 0 0 / 0), 0 0 0 0 oklch(0% 0 0 / 0);translate:0 .5px}.btn.active.svelte-sgoebi{--btn-bg: color-mix( in oklab, var(--btn-color, var(--tri-toolbar-bg)), #000 7% )}.btn.svelte-sgoebi:disabled,.btn[disabled].svelte-sgoebi{pointer-events:none;--btn-border: #0000;--btn-fg: color-mix(in oklch, var(--tri-content) 20%, #0000)}.btn.svelte-sgoebi:disabled:not(.ghost):not(.outline),.btn[disabled].svelte-sgoebi:not(.ghost):not(.outline){background-color:color-mix(in oklab,var(--tri-content) 10%,transparent);box-shadow:none}.circle.svelte-sgoebi{width:var(--size);height:var(--size);border-radius:3.40282e38px;padding-inline:0}.square.svelte-sgoebi{width:var(--size);height:var(--size);padding-inline:0}.ghost.svelte-sgoebi{--btn-bg: transparent;--btn-border: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));box-shadow:none;text-shadow:none}@media(hover:hover){.ghost.svelte-sgoebi:hover{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent)}}.ghost.svelte-sgoebi:active:not(.active),.ghost.active.svelte-sgoebi{--btn-bg: color-mix(in oklab, var(--tri-content) 10%, transparent);--btn-border: transparent}.outline.svelte-sgoebi:not(:hover):not(:active):not(:focus-visible):not(.active):not(:disabled):not([disabled]){--btn-bg: transparent;--btn-fg: var(--btn-color-text, var(--btn-color, var(--tri-content)));--btn-border: var(--btn-color, var(--tri-content));box-shadow:none;text-shadow:none}.select-wrapper.svelte-1hwvamm{display:inline-flex;width:clamp(3rem,20rem,100%);max-width:100%}.native-select.svelte-1hwvamm{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;pointer-events:none}.select.svelte-1hwvamm{border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:100%;height:var(--size);touch-action:manipulation;white-space:nowrap;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);--size: calc(var(--tri-size-field, .25rem) * 10);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 20px) calc(1px + 50%),calc(100% - 16.1px) calc(1px + 50%);background-repeat:no-repeat;background-size:4px 4px,4px 4px;border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));align-items:center;gap:.375rem;padding-inline:.75rem 1.75rem;font-size:.875rem;display:inline-flex;position:relative;cursor:pointer;color:inherit;text-align:start}.select-label.svelte-1hwvamm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-label.placeholder.svelte-1hwvamm{color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.select.svelte-1hwvamm:hover:not(:disabled){--input-color: color-mix(in oklab, var(--tri-content) 40%, #0000)}.select.svelte-1hwvamm:focus-visible,.select.open.svelte-1hwvamm{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.select.svelte-1hwvamm:is(:where(.svelte-1hwvamm):disabled,[disabled]:where(.svelte-1hwvamm)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent)}.ghost.svelte-1hwvamm{box-shadow:none;background-color:#0000;border-color:#0000;transition:background-color .2s}.ghost.svelte-1hwvamm:hover:not(:disabled){background-color:color-mix(in oklab,var(--tri-content) 8%,transparent)}.ghost.svelte-1hwvamm:focus-visible,.ghost.open.svelte-1hwvamm{background-color:var(--tri-input-bg);color:var(--tri-content)}.listbox.svelte-1hwvamm{position:fixed;inset:auto;margin:0;padding:.1875rem;border:var(--tri-border) solid color-mix(in oklab,var(--tri-content) 20%,#0000);background-color:var(--tri-input-bg);color:var(--tri-content);border-radius:var(--tri-radius-buttons);box-shadow:0 8px 24px oklch(0 0 0 / calc(.12 + var(--tri-depth) * .06));max-height:16rem;overflow-y:auto;min-width:8rem;z-index:1}.listbox.svelte-1hwvamm:not(:popover-open){display:none}.option.svelte-1hwvamm{padding:.25rem .5rem;border-radius:calc(var(--tri-radius-buttons) * .6);cursor:pointer;font-size:.8125rem;line-height:1.3;white-space:nowrap;color:inherit}.option.active.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-content) 12%,#0000)}.option.selected.svelte-1hwvamm{background-color:color-mix(in oklab,var(--tri-color-primary) 90%,#0000);color:var(--tri-color-primary-content)}.option.selected.active.svelte-1hwvamm{background-color:var(--tri-color-primary)}.option[aria-disabled=true].svelte-1hwvamm{opacity:.5;cursor:not-allowed;color:color-mix(in oklab,var(--tri-content) 55%,transparent)}.input.svelte-4x2zrp{cursor:text;border:var(--tri-border) solid var(--input-color);appearance:none;background-color:var(--tri-input-bg);vertical-align:middle;width:clamp(3rem,20rem,100%);height:var(--size);font-size:max(var(--font-size, .875rem),.875rem);touch-action:manipulation;box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000) inset,0 -1px oklch(100% 0 0 / calc(var(--tri-depth) * .1)) inset;--size: calc(var(--tri-size-field, .25rem) * 10);--input-color: color-mix(in oklab, var(--tri-content) 20%, #0000);border-start-start-radius:var(--join-ss, var(--tri-radius-buttons));border-start-end-radius:var(--join-se, var(--tri-radius-buttons));border-end-end-radius:var(--join-ee, var(--tri-radius-buttons));border-end-start-radius:var(--join-es, var(--tri-radius-buttons));flex-shrink:1;align-items:center;gap:.5rem;padding-inline:.75rem;display:inline-flex;position:relative;color:inherit}.input.svelte-4x2zrp:focus,.input.svelte-4x2zrp:focus-within{--input-color: var(--tri-content);box-shadow:0 1px color-mix(in oklab,var(--input-color) calc(var(--tri-depth) * 10%),#0000);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate;z-index:1}.input.svelte-4x2zrp:is(:where(.svelte-4x2zrp):disabled,[disabled]:where(.svelte-4x2zrp)){cursor:not-allowed;border-color:var(--tri-panel-bg);background-color:var(--tri-panel-bg);color:color-mix(in oklab,var(--tri-content) 40%,transparent);box-shadow:none}.input.svelte-4x2zrp:is(:where(.svelte-4x2zrp):disabled,[disabled]:where(.svelte-4x2zrp))::placeholder{color:color-mix(in oklab,var(--tri-content) 20%,transparent)}.ghost.svelte-4x2zrp{box-shadow:none;background-color:#0000;border-color:#0000}.ghost.svelte-4x2zrp:focus,.ghost.svelte-4x2zrp:focus-within{background-color:var(--tri-input-bg);color:var(--tri-content);box-shadow:none;border-color:#0000}.tooltip.svelte-1cfjd3n{--tt-bg: var(--tri-color-neutral);--tt-fg: var(--tri-color-neutral-content);--tt-off: calc(100% + .5rem) ;--tt-tail: calc(100% + 1px + .25rem) ;display:inline-block;position:relative}.tooltip[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):before{border-radius:var(--tri-radius-buttons);text-align:center;white-space:normal;max-width:20rem;color:var(--tt-fg);opacity:0;background-color:var(--tt-bg);pointer-events:none;z-index:2;content:attr(data-tip);width:max-content;padding-block:.25rem;padding-inline:.5rem;font-size:.875rem;line-height:1.25;position:absolute}.tooltip[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):after{opacity:0;background-color:var(--tt-bg);content:\"\";pointer-events:none;--mask-tooltip: url(\"data:image/svg+xml,%3Csvg width='10' height='4' viewBox='0 0 8 4' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0.500009 1C3.5 1 3.00001 4 5.00001 4C7 4 6.5 1 9.5 1C10 1 10 0.499897 10 0H0C-1.99338e-08 0.5 0 1 0.500009 1Z' fill='black'/%3E%3C/svg%3E%0A\");width:.625rem;height:.25rem;mask-position:-1px 0;mask-repeat:no-repeat;mask-image:var(--mask-tooltip);display:block;position:absolute}@media(prefers-reduced-motion:no-preference){.tooltip[data-tip].svelte-1cfjd3n:before,.tooltip[data-tip].svelte-1cfjd3n:after{transition:opacity .2s cubic-bezier(.4,0,.2,1) 75ms,transform .2s cubic-bezier(.4,0,.2,1) 75ms}}.tooltip[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):hover:before,.tooltip[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):hover:after,.tooltip[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):has(:focus-visible):before,.tooltip[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):has(:focus-visible):after,.tooltip-open[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):before,.tooltip-open[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):after{opacity:1;--tt-pos: 0rem}@media(prefers-reduced-motion:no-preference){.tooltip[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):hover:before,.tooltip[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):hover:after,.tooltip[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):has(:focus-visible):before,.tooltip[data-tip].svelte-1cfjd3n:not([data-tip=\"\"]):has(:focus-visible):after{transition:opacity .2s cubic-bezier(.4,0,.2,1),transform .2s cubic-bezier(.4,0,.2,1)}}.top.svelte-1cfjd3n:before{transform:translate(-50%) translateY(var(--tt-pos, .25rem));inset:auto auto var(--tt-off) 50%}.top.svelte-1cfjd3n:after{transform:translate(-50%) translateY(var(--tt-pos, .25rem));inset:auto auto var(--tt-tail) 50%}.bottom.svelte-1cfjd3n:before{transform:translate(-50%) translateY(var(--tt-pos, -.25rem));inset:var(--tt-off) auto auto 50%}.bottom.svelte-1cfjd3n:after{transform:translate(-50%) translateY(var(--tt-pos, -.25rem)) rotate(180deg);inset:var(--tt-tail) auto auto 50%}.left.svelte-1cfjd3n:before{transform:translate(calc(var(--tt-pos, .25rem) - .25rem)) translateY(-50%);inset:50% var(--tt-off) auto auto}.left.svelte-1cfjd3n:after{transform:translate(var(--tt-pos, .25rem)) translateY(-50%) rotate(-90deg);inset:50% calc(var(--tt-tail) + 1px) auto auto}.right.svelte-1cfjd3n:before{transform:translate(calc(var(--tt-pos, -.25rem) + .25rem)) translateY(-50%);inset:50% auto auto var(--tt-off)}.right.svelte-1cfjd3n:after{transform:translate(var(--tt-pos, -.25rem)) translateY(-50%) rotate(90deg);inset:50% auto auto calc(var(--tt-tail) + 1px)}.card.svelte-u681vn{position:relative;display:flex;flex-direction:column;border-radius:var(--tri-radius-panels)}.tri-ae-glyph.svelte-u681vn{display:inline-block;vertical-align:middle;flex-shrink:0}.bodies.svelte-u681vn{display:flex;flex-direction:column;gap:.75rem;padding-right:.25rem}.bodies-scroll.svelte-u681vn{max-height:40vh;overflow-y:auto}.body-card.svelte-u681vn{background-color:var(--panel-surface);padding:.5rem;display:flex;flex-direction:column;gap:.5rem}.body-row.svelte-u681vn{display:flex;align-items:center;gap:.5rem}.body-row.svelte-u681vn .body-purpose{flex:1 1 0%}.body-row.svelte-u681vn .body-remove{color:var(--tri-color-error)}.purpose-option.svelte-u681vn{text-transform:capitalize}.body-card.svelte-u681vn .body-input{width:100%}.body-textarea.svelte-u681vn{border:var(--tri-border, 1px) solid #0000;border-color:var(--input-color);min-height:5rem;flex-shrink:1;appearance:none;border-radius:var(--tri-radius-buttons);background-color:var(--tri-input-bg);padding-block:.5rem;vertical-align:middle;width:100%;padding-inline-start:.75rem;padding-inline-end:.75rem;font-size:max(var(--font-size, .6875rem),.6875rem);touch-action:manipulation;color:inherit;--input-color: color-mix(in oklab, var(--panel-fg) 20%, #0000)}.body-textarea.svelte-u681vn:focus,.body-textarea.svelte-u681vn:focus-within{--input-color: var(--panel-fg);outline:2px solid var(--input-color);outline-offset:2px;isolation:isolate}.body-textarea.svelte-u681vn:is(:where(.svelte-u681vn):disabled,[disabled]:where(.svelte-u681vn)){cursor:not-allowed;border-color:var(--panel-surface);background-color:var(--panel-surface);color:color-mix(in oklab,var(--panel-fg) 40%,transparent);box-shadow:none}.unknown-body.svelte-u681vn{display:flex;flex-direction:column;gap:.5rem}.unknown-body-note.svelte-u681vn{font-size:.75rem;line-height:1rem;opacity:.7}.unknown-body-preview.svelte-u681vn{display:block;max-height:8rem;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;border-radius:var(--tri-radius-buttons);background-color:var(--tri-input-bg);padding:.5rem;font-size:.6875rem;line-height:1rem}.add-content{width:100%}.save-row.svelte-u681vn{padding-top:.5rem}.save-row.svelte-u681vn .save-btn{width:100%}.panel.svelte-1mu3tdt{min-height:0;display:flex;flex-direction:column}.panel.floating.svelte-1mu3tdt{height:100%;width:20rem;background-color:var(--panel-surface);border-right-width:1px;border-right-style:solid;border-right-color:var(--tri-surface-border);box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.panel.floating.svelte-1mu3tdt .content:where(.svelte-1mu3tdt){width:100%}.tri-ae-glyph.svelte-1mu3tdt{display:inline-block;vertical-align:middle;flex-shrink:0}.header.svelte-1mu3tdt{display:flex;align-items:center;padding:1rem;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:var(--tri-surface-border)}.title.svelte-1mu3tdt{font-size:1.125rem;line-height:1.75rem;font-weight:600;display:flex;align-items:center;gap:.5rem}.content.svelte-1mu3tdt{width:100%;padding:1rem;display:flex;flex-direction:column;gap:1.5rem}.content.scroll.svelte-1mu3tdt{flex:1 1 0%;overflow-y:auto}.error-line.svelte-1mu3tdt{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;border-radius:var(--tri-radius-buttons);background-color:color-mix(in oklab,var(--tri-color-error) 15%,var(--panel-surface));color:var(--tri-color-error);font-size:.75rem;line-height:1rem}.error-icon.svelte-1mu3tdt{flex-shrink:0;display:inline-flex}.error-text.svelte-1mu3tdt{flex:1 1 0%}.error-line.svelte-1mu3tdt .error-dismiss{flex-shrink:0;color:var(--tri-color-error)}.mode-section.svelte-1mu3tdt{display:flex;flex-direction:column;gap:.5rem}.mode-instruction.svelte-1mu3tdt{font-size:.75rem;line-height:1rem;opacity:.6;text-align:center}.mode-disabled-reason.svelte-1mu3tdt{font-size:.75rem;line-height:1rem;text-align:center;color:color-mix(in oklab,var(--panel-fg) 70%,transparent)}.tool-section.svelte-1mu3tdt{display:flex;flex-direction:column;gap:.5rem}.tool-label.svelte-1mu3tdt{font-size:.875rem;line-height:1.25rem;font-weight:500}.tool-section.svelte-1mu3tdt .tool-tip{display:inline-flex}.undo-redo.svelte-1mu3tdt{display:flex;gap:.5rem}.undo-redo.svelte-1mu3tdt .undo-redo-btn{flex:1 1 0%}.card.svelte-1mu3tdt{position:relative;display:flex;flex-direction:column;border-radius:var(--tri-radius-panels)}.editor-card.svelte-1mu3tdt{background-color:var(--tri-input-bg);padding:1rem;display:flex;flex-direction:column;gap:.75rem}.editor-header.svelte-1mu3tdt{display:flex;align-items:center;justify-content:space-between;margin-bottom:.5rem}.editor-title.svelte-1mu3tdt{font-weight:500;font-size:.875rem;line-height:1.25rem}.editor-actions.svelte-1mu3tdt{display:flex;gap:.25rem}.editor-actions.svelte-1mu3tdt .delete-btn{color:var(--tri-color-error)}.custom-body-editor.svelte-1mu3tdt{width:100%}.hydrating-note.svelte-1mu3tdt{font-size:.75rem;line-height:1rem;opacity:.6}.join.svelte-1mu3tdt{display:inline-flex;align-items:stretch;--join-ss: 0;--join-se: 0;--join-es: 0;--join-ee: 0}.join.svelte-1mu3tdt>.join-item:first-child{--join-ss: var(--tri-radius-buttons);--join-es: var(--tri-radius-buttons)}.join.svelte-1mu3tdt>.join-item:last-child{--join-se: var(--tri-radius-buttons);--join-ee: var(--tri-radius-buttons)}.join.svelte-1mu3tdt>.join-item:not(:first-child){margin-inline-start:calc(var(--tri-border, 1px) * -1)}.mode-toggle.svelte-1mu3tdt{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%}.modal.svelte-1mu3tdt{pointer-events:none;visibility:hidden;position:fixed;inset:0;margin:0;display:grid;height:100%;max-height:none;width:100%;max-width:none;align-items:center;justify-items:center;background-color:transparent;padding:0;color:inherit;overflow:clip;overscroll-behavior:contain;z-index:999}.modal.svelte-1mu3tdt::backdrop{display:none}.modal.modal-open.svelte-1mu3tdt{pointer-events:auto;visibility:visible;opacity:100%;background-color:#0006}.modal-box.svelte-1mu3tdt{grid-column-start:1;grid-row-start:1;max-height:100vh;width:calc(11 / 12 * 100%);max-width:32rem;background-color:var(--tri-input-bg);padding:1.5rem;border-radius:var(--tri-radius-panels);box-shadow:#00000040 0 25px 50px -12px;overflow-y:auto;overscroll-behavior:contain}.modal-title.svelte-1mu3tdt{font-weight:700;font-size:1.125rem;line-height:1.75rem;display:flex;align-items:center;gap:.5rem}.modal-warning-icon.svelte-1mu3tdt{color:var(--tri-color-warning);display:inline-flex}.modal-message.svelte-1mu3tdt{padding-block:1rem}.modal-action.svelte-1mu3tdt{margin-top:1.5rem;display:flex;justify-content:flex-end;gap:.5rem}.modal-backdrop.svelte-1mu3tdt{grid-column-start:1;grid-row-start:1;display:grid;align-self:stretch;justify-self:stretch;color:transparent;z-index:-1}.modal-backdrop.svelte-1mu3tdt button:where(.svelte-1mu3tdt){cursor:pointer}\n",j0="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(j0);const Kd=Symbol("triiiceratops:viewer-state");var X0=["forEach","isDisjointFrom","isSubsetOf","isSupersetOf"],Y0=["difference","intersection","symmetricDifference","union"],Qd=!1;class Jo extends Set{#e=new Map;#t=Ge(0);#i=Ge(0);#n=Mi||-1;constructor(e){if(super(),e){for(var t of e)super.add(t);this.#i.v=super.size}Qd||this.#s()}#r(e){return Mi===this.#n?Ge(e):mn(e)}#s(){Qd=!0;var e=Jo.prototype,t=Set.prototype;for(const i of X0)e[i]=function(...r){return F(this.#t),t[i].apply(this,r)};for(const i of Y0)e[i]=function(...r){F(this.#t);var s=t[i].apply(this,r);return new Jo(s)}}has(e){var t=super.has(e),i=this.#e,r=i.get(e);if(r===void 0){if(!t)return F(this.#t),!1;r=this.#r(!0),i.set(e,r)}return F(r),t}add(e){return super.has(e)||(super.add(e),_e(this.#i,super.size),ui(this.#t)),this}delete(e){var t=super.delete(e),i=this.#e,r=i.get(e);return r!==void 0&&(i.delete(e),_e(r,!1)),t&&(_e(this.#i,super.size),ui(this.#t)),t}clear(){if(super.size!==0){super.clear();var e=this.#e;for(var t of e.values())_e(t,!1);e.clear(),_e(this.#i,0),ui(this.#t)}}keys(){return this.values()}values(){return F(this.#t),super.values()}entries(){return F(this.#t),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return F(this.#i)}}class jr extends Map{#e=new Map;#t=Ge(0);#i=Ge(0);#n=Mi||-1;constructor(e){if(super(),e){for(var[t,i]of e)super.set(t,i);this.#i.v=super.size}}#r(e){return Mi===this.#n?Ge(e):mn(e)}has(e){var t=this.#e,i=t.get(e);if(i===void 0){var r=super.get(e);if(r!==void 0)i=this.#r(0),t.set(e,i);else return F(this.#t),!1}return F(i),!0}forEach(e,t){this.#s(),super.forEach(e,t)}get(e){var t=this.#e,i=t.get(e);if(i===void 0){var r=super.get(e);if(r!==void 0)i=this.#r(0),t.set(e,i);else{F(this.#t);return}}return F(i),super.get(e)}set(e,t){var i=this.#e,r=i.get(e),s=super.get(e),o=super.set(e,t),a=this.#t;if(r===void 0)r=this.#r(0),i.set(e,r),_e(this.#i,super.size),ui(a);else if(s!==t){ui(r);var l=a.reactions===null?null:new Set(a.reactions),h=l===null||!r.reactions?.every(u=>l.has(u));h&&ui(a)}return o}delete(e){var t=this.#e,i=t.get(e),r=super.delete(e);return i!==void 0&&(t.delete(e),_e(this.#i,super.size),_e(i,-1),ui(this.#t)),r}clear(){if(super.size!==0){super.clear();var e=this.#e;_e(this.#i,0);for(var t of e.values())_e(t,-1);ui(this.#t),e.clear()}}#s(){F(this.#t);var e=this.#e;if(this.#i.v!==e.size){for(var t of super.keys())if(!e.has(t)){var i=this.#r(0);e.set(t,i)}}for([,i]of this.#e)F(i)}keys(){return F(this.#t),super.keys()}values(){return this.#s(),super.values()}entries(){return this.#s(),super.entries()}[Symbol.iterator](){return this.entries()}get size(){return F(this.#i),super.size}}class Zs{id="localStorage";name="Local Storage";static KEY_PREFIX="@triiiceratops/plugin-annotation-editor:v1";storageKey(e,t){return`${Zs.KEY_PREFIX}:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}async load(e,t){const i=await this.loadFromStorage(e,t);for(const r of i)r.__fullBodyLoaded=!0;return i}async hydrate(e,t,i){const s=(await this.loadFromStorage(e,t)).find(o=>o.id===i)??null;return s?(s.__fullBodyLoaded=!0,s):null}async create(e,t,i){const r=await this.loadFromStorage(e,t);r.push(i),this.saveToStorage(e,t,r)}async update(e,t,i){const r=await this.loadFromStorage(e,t),s=r.findIndex(o=>o.id===i.id);s>=0&&(r[s]=i,this.saveToStorage(e,t,r))}async delete(e,t,i){const s=(await this.loadFromStorage(e,t)).filter(o=>o.id!==i);this.saveToStorage(e,t,s)}async loadFromStorage(e,t){const i=this.storageKey(e,t),r=localStorage.getItem(i);return r?JSON.parse(r):[]}saveToStorage(e,t,i){const r=this.storageKey(e,t);localStorage.setItem(r,JSON.stringify(i))}}class Xr{static W3C_CONTEXT="http://www.w3.org/ns/anno.jsonld";static DEFAULT_MOTIVATION="commenting";adapter;config;onReconcileId;onReplay;manifestId=null;canvasId=null;displayState=null;persistedAnnotations=new jr;hydrationState=new jr;saveQueue=new jr;loadSequence=0;injectedCanvases=new Jo;static UNDO_DEPTH=50;undoStack=[];redoStack=[];replaying=!1;lastCreateCanonical=null;#e=Ge(!1);get _canUndo(){return F(this.#e)}set _canUndo(e){_e(this.#e,e,!0)}#t=Ge(!1);get _canRedo(){return F(this.#t)}set _canRedo(e){_e(this.#t,e,!0)}#i=Ge(null);get _panelError(){return F(this.#i)}set _panelError(e){_e(this.#i,e,!0)}constructor(e){this.config=e,this.adapter=e.adapter??new Zs}setDisplayState(e){this.displayState=e}get currentManifestId(){return this.manifestId}get currentCanvasId(){return this.canvasId}get ready(){return this.manifestId!==null&&this.canvasId!==null}get hydrateSupported(){return typeof this.adapter.hydrate=="function"}get panelError(){return this._panelError}dismissError(){this._panelError=null}get canUndo(){return this._canUndo}get canRedo(){return this._canRedo}setCanvas(e,t){this.manifestId=e,this.canvasId=t,this.persistedAnnotations.clear(),this.hydrationState.clear(),this._panelError=null,this.clearHistory()}get(e){return this.persistedAnnotations.get(e)??null}has(e){return this.persistedAnnotations.has(e)}isSkeleton(e){return this.hydrationState.get(e)==="skeleton"}async load(){if(!this.ready)return[];const e=++this.loadSequence;let t;try{t=await this.adapter.load(this.manifestId,this.canvasId)}catch(i){return e!==this.loadSequence?[]:(this.reportError("load",void 0,i,()=>this.load().then(()=>{})),[])}return e!==this.loadSequence?[]:(this.cachePersistedAnnotations(t),this.syncDisplay(),this._panelError=null,t)}async persist(e){if(!this.ready)return!1;const t=this.manifestId,i=this.canvasId,r=e.id,s=this.stripInternalMarkers(e);let o=!1;const a=async()=>{if(this.persistedAnnotations.has(r)){const c=this.persistedAnnotations.get(r),d=this.stampForUpdate(s);try{const f=await this.adapter.update(t,i,d),p=f&&typeof f=="object"?this.stripInternalMarkers(f):d;this.persistedAnnotations.set(r,p),this.hydrationState.set(r,"full"),this.syncDisplay(),this._panelError=null,o=!0,this.recordForward({kind:"update",before:c,after:p})}catch(f){this.reportError("update",r,f,()=>this.persist(e).then(()=>{}))}}else{const c=this.stampForCreate(s);try{const d=await this.adapter.create(t,i,c),f=this.reconcileCreate(r,c,d);this.lastCreateCanonical=f,this.syncDisplay(),this._panelError=null,o=!0,this.recordForward({kind:"create",annotation:f})}catch(d){this.reportError("create",r,d,()=>this.persist(e).then(()=>{}))}}},h=(this.saveQueue.get(r)??Promise.resolve()).then(a,a);return this.saveQueue.set(r,h),await h,this.saveQueue.get(r)===h&&this.saveQueue.delete(r),o}async delete(e){if(!this.ready)return!1;const t=this.persistedAnnotations.get(e)??null;try{await this.adapter.delete(this.manifestId,this.canvasId,e)}catch(i){return this.reportError("delete",e,i,()=>this.delete(e).then(()=>{})),!1}return this.persistedAnnotations.delete(e),this.hydrationState.delete(e),this.syncDisplay(),this._panelError=null,t&&this.recordForward({kind:"delete",annotation:t}),!0}async hydrate(e,t){if(!this.ready||!this.adapter.hydrate)return null;const i=this.loadSequence;let r;try{r=await this.adapter.hydrate(this.manifestId,this.canvasId,e)}catch(o){return i!==this.loadSequence||this.reportError("hydrate",e,o,()=>this.hydrate(e,t).then(()=>{})),null}if(!r||i!==this.loadSequence||t&&!t())return null;const s=this.stripInternalMarkers(r);return this.persistedAnnotations.set(e,s),this.hydrationState.set(e,"full"),this._panelError=null,s}async resolve(e){const t=this.persistedAnnotations.get(e);if(t&&this.hydrationState.get(e)!=="skeleton")return t;if(t&&this.hydrateSupported&&this.ready)return await this.hydrate(e)??t;if(!t&&this.ready){const i=await this.adapter.load(this.manifestId,this.canvasId);return this.cachePersistedAnnotations(i),this.syncDisplay(),this.persistedAnnotations.get(e)??null}return t??null}async undo(){const e=this.undoStack.pop();if(this.refreshUndoRedoFlags(),!!e){this.replaying=!0;try{switch(e.kind){case"create":{await this.delete(e.annotation.id)?(this.pushRedo(e),this.onReplay?.(e.annotation.id,null)):this.restoreUndo(e);break}case"update":{await this.persist(e.before)?(this.pushRedo(e),this.onReplay?.(e.before.id,this.get(e.before.id))):this.restoreUndo(e);break}case"delete":{if(await this.persist(e.annotation)){const t=this.lastCreateCanonical??e.annotation;this.pushRedo({kind:"delete",annotation:t}),this.onReplay?.(t.id,this.get(t.id))}else this.restoreUndo(e);break}}}finally{this.replaying=!1}}}async redo(){const e=this.redoStack.pop();if(this.refreshUndoRedoFlags(),!!e){this.replaying=!0;try{switch(e.kind){case"create":{if(await this.persist(e.annotation)){const t=this.lastCreateCanonical??e.annotation;this.pushUndo({kind:"create",annotation:t}),this.onReplay?.(t.id,this.get(t.id))}else this.restoreRedo(e);break}case"update":{await this.persist(e.after)?(this.pushUndo(e),this.onReplay?.(e.after.id,this.get(e.after.id))):this.restoreRedo(e);break}case"delete":{await this.delete(e.annotation.id)?(this.pushUndo(e),this.onReplay?.(e.annotation.id,null)):this.restoreRedo(e);break}}}finally{this.replaying=!1}}}destroy(){this.clearHistory();for(const e of this.injectedCanvases){const[t,i]=e.split("::");this.displayState?.clearUserAnnotations(t,i)}this.injectedCanvases.clear(),this.persistedAnnotations.clear(),this.hydrationState.clear(),this.adapter.destroy?.()}recordForward(e){this.replaying||(this.pushCapped(this.undoStack,e),this.redoStack=[],this.refreshUndoRedoFlags())}pushUndo(e){this.pushCapped(this.undoStack,e),this.refreshUndoRedoFlags()}pushRedo(e){this.pushCapped(this.redoStack,e),this.refreshUndoRedoFlags()}restoreUndo(e){this.undoStack.push(e),this.refreshUndoRedoFlags()}restoreRedo(e){this.redoStack.push(e),this.refreshUndoRedoFlags()}pushCapped(e,t){e.push(t),e.length>Xr.UNDO_DEPTH&&e.shift()}clearHistory(){this.undoStack=[],this.redoStack=[],this.lastCreateCanonical=null,this.refreshUndoRedoFlags()}refreshUndoRedoFlags(){this._canUndo=this.undoStack.length>0,this._canRedo=this.redoStack.length>0}reportError(e,t,i,r){if(this.config.onPersistenceError){this.config.onPersistenceError({op:e,annotationId:t,manifestId:this.manifestId,canvasId:this.canvasId,cause:i,retry:r});return}console.error(`[AnnotationEditor] ${e} failed:`,i),this._panelError={op:e,annotationId:t}}reconcileCreate(e,t,i){let r=t,s=e;typeof i=="string"?(s=i,r={...t,id:i}):i&&typeof i=="object"&&(r=this.stripInternalMarkers(i),s=r.id);const o=s!==e;return o&&(this.persistedAnnotations.delete(e),this.hydrationState.delete(e)),this.persistedAnnotations.set(s,r),this.hydrationState.set(s,"full"),o&&this.onReconcileId?.(e,r),r}stampForCreate(e){const t={...e};return t["@context"]||(t["@context"]=Xr.W3C_CONTEXT),t.type||(t.type="Annotation"),!t.creator&&this.config.user&&(t.creator={id:this.config.user.id,name:this.config.user.name}),t.created||(t.created=new Date().toISOString()),t.motivation||(t.motivation=this.config.defaultMotivation??Xr.DEFAULT_MOTIVATION),t}stampForUpdate(e){return{...e,modified:new Date().toISOString()}}syncDisplay(){if(!this.ready)return;const e=this.manifestId,t=this.canvasId;this.injectedCanvases.add(`${e}::${t}`),this.displayState?.setUserAnnotations(e,t,[...this.persistedAnnotations.values()])}cachePersistedAnnotations(e){this.hydrationState.clear(),this.persistedAnnotations=new jr(e.map(t=>(this.hydrationState.set(t.id,t.__fullBodyLoaded===!1?"skeleton":"full"),[t.id,this.stripInternalMarkers(t)])))}stripInternalMarkers(e){if(e.__fullBodyLoaded===void 0&&e.__bodyPreview===void 0)return e;const t={...e};return delete t.__fullBodyLoaded,delete t.__bodyPreview,t}}function Yr(n){return n?.id||n?.["@id"]||n?.__jsonld?.id||n?.__jsonld?.["@id"]||(typeof n?.getId=="function"?n.getId():null)||null}function q0(n){return Yr(n)||(typeof n?.getCanvasId=="function"?n.getCanvasId():null)||(typeof n?.getId=="function"?n.getId():null)||""}function Jd(n,e){if(!n)return"";if(typeof n=="string")return n;if(typeof n=="object"&&!Array.isArray(n)){const t=n;if("@value"in t){const s=t["@value"];return Array.isArray(s)&&s.length>0?String(s[0]):s===void 0?"":String(s)}const i=Object.keys(t),r=s=>{const o=t[s];if(o!==void 0)return Array.isArray(o)&&o.length>0?String(o[0]):String(o)};for(const s of["en","none"]){const o=r(s);if(o!==void 0)return o}return i.length>0?r(i[0])??"":""}if(Array.isArray(n)&&n.length>0){if(typeof n[0]=="string")return n[0];const t=n,i=a=>a?.value??a?._value,s=(a=>t.find(l=>l.locale===a||l._locale===a||l.language===a))("en");{const a=i(s);if(a)return a}const o=t.find(a=>!a.locale&&!a._locale&&!a.language);{const a=i(o);if(a)return a}return i(t[0])??""}return String(n)}function nh(n){if(!n)return null;const e=n.match(/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/);return e?[Number(e[1]),Number(e[2]),Number(e[3]),Number(e[4])]:null}function Z0(n){const[e]=n.split("#");return e||null}function rh(n){if(!n)return null;if(typeof n=="string")return n;if(Array.isArray(n)){for(const t of n){const i=rh(t);if(i)return i}return null}if(typeof n!="object")return null;const e=n;return typeof e.id=="string"?e.id:typeof e["@id"]=="string"?e["@id"]:e.source?rh(e.source):null}function sh(n){if(!n)return[];if(Array.isArray(n))return n.flatMap(t=>sh(t));if(typeof n!="object")return[];const e=n;return e.item?sh(e.item):[e]}function K0(n){const e=n.find(i=>i?.type==="FragmentSelector"&&typeof i?.value=="string"&&i.value.includes("xywh="));if(e)return nh(e.value);const t=n.find(i=>typeof i?.value=="string"&&i.value.includes("xywh="));return t?nh(t.value):null}function $d(n){if(!n)return[];if(Array.isArray(n))return n.flatMap(r=>$d(r));const e=rh(n),t=typeof n=="object"&&n&&"selector"in n?sh(n.selector):[],i=K0(t)||(e?nh(e):null);return[{raw:n,targetId:e,canvasId:e?Z0(e):null,selectors:t,xywh:i}]}function Q0(n){return n.endsWith("/info.json")?n.slice(0,-10):n}function qr(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function J0(n){const e=n?.__jsonld||n;return{width:qr(n?.width)||qr(e?.width)||(typeof n?.getWidth=="function"?qr(n.getWidth()):null),height:qr(n?.height)||qr(e?.height)||(typeof n?.getHeight=="function"?qr(n.getHeight()):null)}}function ef(n){const e=n?.__jsonld||n;return e?.type==="SpecificResource"&&e?.source?e.source:null}function $0(n,e){return e?.type==="Choice"||e?.type==="oa:Choice"||!!n&&!Array.isArray(n)&&(n.type==="Choice"||n.type==="oa:Choice")}function tf(n,e){return e&&(e.items||e.item)?e.items||e.item:Array.isArray(n)?n:n&&(n.items||n.item)?n.items||n.item:[]}function ex({body:n,rawBody:e,canvasId:t,getSelectedChoice:i}){const r=Array.isArray(n)?n:tf(n,null),s=tf(null,e),o=i?.(t);if(o){const a=r.find(h=>Yr(h)===o);if(a)return a;const l=s.findIndex(h=>Yr(h)===o);if(l>=0)return r[l]||s[l]}return r[0]||s[0]||null}function tx(n){let e=n.getImages?.()||[];return(!e||!e.length)&&n.getContent&&(e=n.getContent()),e||[]}function ix(n){const e=n?.width||n?.__jsonld?.width||(typeof n?.getWidth=="function"?n.getWidth():null),t=n?.height||n?.__jsonld?.height||(typeof n?.getHeight=="function"?n.getHeight():null);return typeof e!="number"||typeof t!="number"?null:{width:e,height:t}}function nx(n){const e=$d(n?.target||n?.__jsonld?.target).find(t=>t.xywh)?.xywh;return e?{x:e[0],y:e[1],width:e[2],height:e[3]}:null}function rx(n,e){if(typeof n!="string"||!n.trim())return null;const t=n.trim(),i=t.startsWith("pct:"),s=(i?t.slice(4):t).split(",").map(o=>Number(o.trim()));return s.length!==4||s.some(o=>!Number.isFinite(o)||o<0)?null:i?typeof e.width!="number"||typeof e.height!="number"?null:{x:s[0]/100*e.width,y:s[1]/100*e.height,width:s[2]/100*e.width,height:s[3]/100*e.height}:{x:s[0],y:s[1],width:s[2],height:s[3]}}function sx(n,e){const t=n?.__jsonld||n;return rx(t?.selector?.type==="ImageApiSelector"?t.selector.region:null,e)}function ox(n){const e=n?.__jsonld||n,t=ef(n);return!!(n&&(n.id||n["@id"]||e?.service||t||e?.id||e?.["@id"]))}function ax(n,e,t){let i=n.getResource?n.getResource():null;if(!i&&n.getBody){const r=n.getBody(),s=n.__jsonld?.body||n.body;$0(r,s)?i=ex({body:r,rawBody:s,canvasId:e,getSelectedChoice:t}):Array.isArray(r)&&r.length>0?i=r[0]:r&&(i=r)}if(i&&!ox(i)&&(i=null),!i){const r=n.__jsonld||n;if(r.body){let s=r.body;if(s.type==="Choice"||s.type==="oa:Choice"){const o=s.items||s.item||[],a=t?.(e);s=(a?o.find(h=>Yr(h)===a):null)||o[0]||null}i=Array.isArray(s)?s[0]:s}}return i}function nf(n){return typeof n=="string"?/^https?:\/\/iiif\.io\/api\/image\//.test(n)||n==="level0"||n==="level1"||n==="level2":Array.isArray(n)?n.some(e=>nf(e)):!1}function lx(n){return typeof n=="string"?n||null:Array.isArray(n)&&n.find(t=>typeof t=="string")||null}function hx(n){let e=[];const t=n?.__jsonld||n;return t?.service&&(e=Array.isArray(t.service)?t.service:[t.service]),!e.length&&n?.getServices&&(e=n.getServices()),e.length&&e.find(i=>{const r=i.getType?i.getType():i.type||i["@type"]||"",s=i.getProfile?i.getProfile():i.profile||"";return r==="ImageService1"||r==="ImageService2"||r==="ImageService3"||nf(s)})||null}function ux(n,e){for(const t of[n,e]){if(!t)continue;try{const r=t.getLabel?.();if(Array.isArray(r)&&r.length>0){const s=Jd(r);if(s)return s}}catch{}const i=t.label||t.__jsonld?.label;if(i){const r=Jd(i);if(r)return r}}return null}function cx(n){const e=hx(n),t=Yr(e),i=e?e.getProfile?e.getProfile():e.profile||"":null;return{serviceId:t?Q0(t):null,serviceProfile:lx(i)}}function dx(n){if(!n||!n.includes("/iiif/"))return null;const e=n.split("/"),t=e.findIndex(i=>i==="full"||/^\d+,\d+,\d+,\d+$/.test(i));return t>0?e.slice(0,t).join("/"):null}function fx(n,e={}){return px(n,e)[0]||null}function px(n,e={}){const t=q0(n);if(!t)return[];const i=ix(n);if(!i)return[];const r=tx(n);return r.length?r.map(s=>{const o=ax(s,t,e.getSelectedChoice),a=ef(o)||o;if(!a)return null;const l=Yr(a),h=J0(a),u=cx(a),c=u.serviceId||dx(l),d=nx(s),f=sx(o,h);return{canvasId:t,annotation:s,resource:a,resourceId:l,label:ux(a,s),canvasWidth:i.width,canvasHeight:i.height,resourceWidth:f?.width||h.width,resourceHeight:f?.height||h.height,serviceId:c,serviceProfile:u.serviceProfile,imageApiRegion:f,x:d?d.x/i.width:0,y:d?d.y/i.width:0,width:d?d.width/i.width:1}}).filter(s=>s!==null):[]}function $o(n){return typeof n=="number"&&Number.isFinite(n)&&n>0}function oh(n,e){return!n||!$o(n.canvasWidth)||!$o(n.canvasHeight)||!$o(n.imageWidth)||!$o(n.imageHeight)?null:e==="canvas-to-image"?{scaleX:n.imageWidth/n.canvasWidth,scaleY:n.imageHeight/n.canvasHeight}:{scaleX:n.canvasWidth/n.imageWidth,scaleY:n.canvasHeight/n.imageHeight}}function ah(n,e,t){const i=oh(e,t);return i?{x:n.x*i.scaleX,y:n.y*i.scaleY}:n}function gx(n,e,t){const i=oh(e,t);return i?{x:n.x*i.scaleX,y:n.y*i.scaleY,width:n.width*i.scaleX,height:n.height*i.scaleY}:n}function mx(n,e,t){const i=oh(e,t);if(!i||typeof DOMParser>"u")return n;const s=new DOMParser().parseFromString(n,"image/svg+xml");if(s.documentElement.nodeName==="parsererror")return n;const o=(c,d)=>{const f=Number(c);return Number.isFinite(f)?String(f*(d==="x"?i.scaleX:i.scaleY)):c},a=c=>c&&c.replace(/(-?\d*\.?\d+),(-?\d*\.?\d+)/g,(d,f,p)=>`${o(f,"x")},${o(p,"y")}`),l=(c,d,f)=>{const p=c.getAttribute(d);p!==null&&c.setAttribute(d,o(p,f))};for(const c of Array.from(s.querySelectorAll("polygon, polyline"))){const d=a(c.getAttribute("points"));d!==null&&c.setAttribute("points",d)}for(const c of Array.from(s.querySelectorAll("rect")))l(c,"x","x"),l(c,"y","y"),l(c,"width","x"),l(c,"height","y"),l(c,"rx","x"),l(c,"ry","y");for(const c of Array.from(s.querySelectorAll("circle")))l(c,"cx","x"),l(c,"cy","y"),l(c,"r","x");for(const c of Array.from(s.querySelectorAll("ellipse")))l(c,"cx","x"),l(c,"cy","y"),l(c,"rx","x"),l(c,"ry","y");for(const c of Array.from(s.querySelectorAll("line")))l(c,"x1","x"),l(c,"y1","y"),l(c,"x2","x"),l(c,"y2","y");const h=s.documentElement,u=h.getAttribute("viewBox");if(u){const c=u.trim().split(/\s+/).map(d=>Number(d));c.length===4&&c.every(d=>Number.isFinite(d))&&h.setAttribute("viewBox",[c[0]*i.scaleX,c[1]*i.scaleY,c[2]*i.scaleX,c[3]*i.scaleY].join(" "))}return new XMLSerializer().serializeToString(s.documentElement)}function lh(n,e,t){const i=n.match(/xywh=(pixel:)?(-?\d*\.?\d+),(-?\d*\.?\d+),(-?\d*\.?\d+),(-?\d*\.?\d+)/);if(!i)return n;const r=gx({x:Number(i[2]),y:Number(i[3]),width:Number(i[4]),height:Number(i[5])},e,t);return n.replace(i[0],`xywh=${i[1]||""}${r.x},${r.y},${r.width},${r.height}`)}function ea(n,e,t){if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map(r=>ea(r,e,t));const i={...n};return i.item&&(i.item=ea(i.item,e,t)),i.selector&&(i.selector=ea(i.selector,e,t)),i.type==="PointSelector"?{...i,...ah({x:Number(i.x),y:Number(i.y)},e,t)}:(typeof i.value=="string"&&i.value.includes("xywh=")&&(i.value=lh(i.value,e,t)),i.type==="SvgSelector"&&typeof i.value=="string"&&(i.value=mx(i.value,e,t)),i)}function Zr(n,e,t){if(!n)return n;if(Array.isArray(n))return n.map(r=>Zr(r,e,t));if(typeof n=="string")return n.includes("xywh=")?lh(n,e,t):n;if(typeof n!="object")return n;const i={...n};return i.source&&(i.source=Zr(i.source,e,t)),i.selector&&(i.selector=ea(i.selector,e,t)),i.id&&typeof i.id=="string"&&i.id.includes("xywh=")&&(i.id=lh(i.id,e,t)),i}function rf(n,e){return ah(n,e,"canvas-to-image")}function sf(n,e){return ah(n,e,"image-to-canvas")}function vx(n,e){return{...n,...n.target?{target:Zr(n.target,e,"canvas-to-image")}:{},...n.on?{on:Zr(n.on,e,"canvas-to-image")}:{}}}function of(n,e){return{...n,...n.target?{target:Zr(n.target,e,"image-to-canvas")}:{},...n.on?{on:Zr(n.on,e,"image-to-canvas")}:{}}}const yx=5;function _x(n){const e=n?.radius;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:yx}const xx=["rectangle","polygon","point"];function af(n){const e=n.tools?.length?n.tools:xx,t=n.defaultTool&&e.includes(n.defaultTool)?n.defaultTool:e[0];return{tools:e,defaultTool:t}}class cr{static ACTIVE_EDIT_ID_EVENT="triiiceratops:annotation-editor:active-edit-id";static DEFAULT_POINT_FILL="#e5484d";static DEFAULT_POINT_STROKE="#e5484d";static DEFAULT_POINT_STROKE_WIDTH=2;static DEFAULT_DRAWING_STYLE={fill:"#1e90ff",fillOpacity:.25,stroke:"#1e90ff",strokeWidth:2};config;store;ownsStore;viewerState;annotorious=null;osdViewer=null;openHandler=null;canvasClickHandler=null;createOSDAnnotator=null;W3CImageFormat=null;OSD=null;editingPointOrigin=new jr;get currentManifestId(){return this.store.currentManifestId}get currentCanvasId(){return this.store.currentCanvasId}activeEditingAnnotationId=null;lastHandledCanvasKey=null;suppressedEchoIds=new jr;isDrawingEnabled=!1;activeTool="rectangle";selectedAnnotation=null;resolvedTools;resolvedDefaultTool;onSelectionChange;onAnnotationCreated;onAnnotationHydrationChange;onActiveEditingAnnotationChange;constructor(e,t,i){this.config=e,this.viewerState=i??null,this.ownsStore=!t,this.store=t??new Xr(e),this.viewerState&&this.store.setDisplayState(this.viewerState),this.store.onReconcileId=(o,a)=>this.handleIdReconciled(o,a),this.store.onReplay=(o,a)=>this.handleReplay(o,a);const{tools:r,defaultTool:s}=af(e);this.resolvedTools=r,this.resolvedDefaultTool=s,this.activeTool=s}init(e,t){if(!e)return;this.osdViewer=e,this.store.setCanvas(this.store.currentManifestId,t),(e.world?.getItemCount()??0)>0?this.initAnnotorious(e,t):(this.openHandler=()=>{requestAnimationFrame(()=>{this.initAnnotorious(e,t)})},e.addHandler("open",this.openHandler)),this.canvasClickHandler=r=>{this.isDrawingEnabled&&r.quick&&(r.preventDefaultAction=!0,this.activeTool==="point"&&this.annotorious&&this.handlePointClick(r))},e.addHandler("canvas-click",this.canvasClickHandler)}async initAnnotorious(e,t){if(!this.annotorious)try{if(!this.createOSDAnnotator||!this.W3CImageFormat){const a=await Promise.resolve().then(()=>ID);this.createOSDAnnotator=a.createOSDAnnotator,this.W3CImageFormat=a.W3CImageFormat}if(!this.OSD){const a=await Promise.resolve().then(()=>ww);this.OSD=a.default||a}const i=t??"",r=this.isDrawingEnabled&&this.activeTool!=="point",s={adapter:this.W3CImageFormat(i),drawingEnabled:r,autoSave:!1,drawingMode:"click",style:a=>this.styleForAnnotation(a)},o=this.createOSDAnnotator(e,s);this.annotorious=o,this.config.user&&o.setUser(this.config.user),this.activeTool!=="point"&&o.setDrawingTool(this.activeTool),this.setupEvents(),this.updateDrawingMode(this.isDrawingEnabled),o.setVisible(!0),this.currentManifestId&&this.currentCanvasId&&this.loadAnnotations()}catch{}}async handlePointClick(e){if(!this.osdViewer||!this.annotorious||this.currentCanvasId===null)return;const t=this.osdViewer.world.getItemAt(0);if(!t)return;const i=this.osdViewer.viewport.pointFromPixel(e.position),r=t.viewportToImageCoordinates(i),s=sf({x:r.x,y:r.y},this.getCurrentCanvasImageDimensions()),o=Math.round(s.x),a=Math.round(s.y),l={"@context":"http://www.w3.org/ns/anno.jsonld",id:`temp-${crypto.randomUUID()}`,type:"Annotation",body:[],target:{type:"SpecificResource",source:this.currentCanvasId,selector:{type:"PointSelector",x:o,y:a}}},h=this.prepareAnnotation(l,{canvasSpace:!0});if(this.onAnnotationCreated?.(h),this.setActiveEditingAnnotationId(h.id),!await this.persistCreate(h)){this.activeEditingAnnotationId===h.id&&this.clearSelectionState();return}await this.selectAnnotationById(this.activeEditingAnnotationId??h.id)}setEditing(e){this.isDrawingEnabled=e,this.annotorious&&(this.updateDrawingMode(e),this.annotorious.setVisible(!0))}updateDrawingMode(e){if(!this.annotorious||!this.osdViewer?.element)return;const t=e&&this.currentCanvasId!==null&&this.resolvedTools.includes(this.activeTool);this.activeTool==="point"?this.annotorious.setDrawingEnabled(!1):this.annotorious.setDrawingEnabled(t),e?this.osdViewer.element.classList.add("annotorious-drawing-mode"):this.osdViewer.element.classList.remove("annotorious-drawing-mode")}isPointAnnotation(e){const t=e?.target?.selector;return(t?.item??t)?.type==="PointSelector"}getPointCoordinates(e){const t=e?.target?.selector;if(t?.type==="PointSelector"&&typeof t.x=="number"&&typeof t.y=="number")return{x:t.x,y:t.y};if(t?.type==="FragmentSelector"&&typeof t.value=="string"){const i=t.value.match(/^xywh=([\d.-]+),([\d.-]+),([\d.-]+),([\d.-]+)$/);if(i){const[,r,s,o,a]=i;return{x:Number(r)+Number(o)/2,y:Number(s)+Number(a)/2}}}return null}toPointSelectorTarget(e){if(e?.target?.selector?.type==="PointSelector"||!this.isPointAnnotation(e))return e;const i=this.getPointCoordinates(e);return i?{...e,target:{type:"SpecificResource",source:e.target?.source??this.currentCanvasId,selector:{type:"PointSelector",x:i.x,y:i.y}}}:e}toAnnotoriousTarget(e){const t=this.getCurrentCanvasImageDimensions(),i=e?.target?.selector;if(i?.type!=="PointSelector")return vx(e,t);const r=rf({x:i.x,y:i.y},t),s=this.pointEditRectImageSize(),o=r.x-s/2,a=r.y-s/2;return{...e,target:{source:e.target?.source??this.currentCanvasId,selector:{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=${o},${a},${s},${s}`}}}}pointFromEditingRect(e){const t=this.getCurrentCanvasImageDimensions(),i=this.editingPointOrigin.get(e?.id),r=this.parseFragmentRect(e?.target?.selector?.value);let s=i??null;if(r){const o=sf({x:r.x+r.width/2,y:r.y+r.height/2},t),a={x:Math.round(o.x),y:Math.round(o.y)};(!i||a.x!==i.x||a.y!==i.y)&&(s=a)}return s?{...e,target:{type:"SpecificResource",source:e?.target?.source??this.currentCanvasId,selector:{type:"PointSelector",x:s.x,y:s.y}}}:e}parseFragmentRect(e){if(typeof e!="string")return null;const t=e.match(/xywh=(?:pixel:)?(-?[\d.]+),(-?[\d.]+),(-?[\d.]+),(-?[\d.]+)/);if(!t)return null;const[,i,r,s,o]=t;return{x:Number(i),y:Number(r),width:Number(s),height:Number(o)}}pointEditRectImageSize(){const e=2*_x(this.config.pointStyle),t=this.imageUnitsPerScreenPixel();if(t&&t>0)return t*e;const i=rf({x:e,y:0},this.getCurrentCanvasImageDimensions());return Math.abs(i.x)||e}imageUnitsPerScreenPixel(){const e=this.osdViewer?.viewport,t=this.osdViewer?.world?.getItemAt?.(0);if(!e||!t||!this.OSD?.Point)return null;const i=e.pointFromPixel(new this.OSD.Point(0,0)),r=e.pointFromPixel(new this.OSD.Point(1,0)),s=t.viewportToImageCoordinates(i),o=t.viewportToImageCoordinates(r),a=Math.abs(o.x-s.x);return Number.isFinite(a)&&a>0?a:null}styleForAnnotation(e){if(e?.id&&this.editingPointOrigin.has(e.id)){const t=this.config.pointStyle;return{fill:t?.fill??cr.DEFAULT_POINT_FILL,fillOpacity:1,stroke:t?.stroke??cr.DEFAULT_POINT_STROKE,strokeWidth:t?.strokeWidth??cr.DEFAULT_POINT_STROKE_WIDTH}}return this.config.drawingStyle??cr.DEFAULT_DRAWING_STYLE}getCurrentCanvasImageDimensions(){if(!this.currentManifestId||!this.currentCanvasId)return null;const e=(this.viewerState?.getCanvases(this.currentManifestId)??[]).find(i=>(i?.id||i?.["@id"]||i?.__jsonld?.id||i?.__jsonld?.["@id"]||i?.getCanvasId?.()||i?.getId?.())===this.currentCanvasId),t=e?fx(e):null;return!t||typeof t.resourceWidth!="number"||typeof t.resourceHeight!="number"?null:{canvasWidth:t.canvasWidth,canvasHeight:t.canvasHeight,imageWidth:t.resourceWidth,imageHeight:t.resourceHeight}}setTool(e){this.activeTool=e,this.updateDrawingMode(this.isDrawingEnabled),e!=="point"&&this.annotorious?.setDrawingTool(e)}get availableTools(){return this.resolvedTools}get persistenceError(){return this.store.panelError}dismissPersistenceError(){this.store.dismissError()}get canUndo(){return this.store.canUndo}get canRedo(){return this.store.canRedo}async undo(){await this.store.undo()}async redo(){await this.store.redo()}setupEvents(){this.annotorious&&(this.annotorious.on("createAnnotation",e=>{this.handleCreateAnnotation(e)}),this.annotorious.on("updateAnnotation",e=>{this.handleUpdateAnnotation(e)}),this.annotorious.on("deleteAnnotation",e=>{this.handleDeleteAnnotation(e)}),this.annotorious.on("selectionChanged",e=>{const t=e.length>0?this.annotationToCanvasSpace(e[0]):null;this.selectedAnnotation=t,this.setActiveEditingAnnotationId(t?.id??null),this.isPointAnnotation(t)?this.osdViewer.element.classList.add("point-selected"):this.osdViewer.element.classList.remove("point-selected"),this.onSelectionChange?.(t),this.notifyExtensionSelectionChange(t),t?.id?this.hydrateAnnotation(t.id):(this.clearAnnotoriousEditingAnnotation(),this.onAnnotationHydrationChange?.(!1))}))}setActiveEditingAnnotationId(e){this.activeEditingAnnotationId=e,this.onActiveEditingAnnotationChange?.(e),!(typeof window>"u")&&window.dispatchEvent(new CustomEvent(cr.ACTIVE_EDIT_ID_EVENT,{detail:{annotationId:e}}))}resetSelectionFields(){this.selectedAnnotation=null,this.osdViewer?.element?.classList.remove("point-selected"),this.setActiveEditingAnnotationId(null)}clearSelectionState(){this.resetSelectionFields(),this.onSelectionChange?.(null),this.notifyExtensionSelectionChange(null)}clearAnnotoriousEditingAnnotation(){this.resetSelectionFields(),this.clearAnnotationsSuppressed()}clearAnnotationsSuppressed(){if(!this.annotorious)return;const e=this.annotorious.getAnnotations()??[];if(e.length!==0){for(const t of e){const i=t?.id;i&&this.markSuppressedEcho(i)}this.annotorious.clearAnnotations()}}async handleCanvasChange(e,t){const i=`${e}::${t}`;i!==this.lastHandledCanvasKey&&(this.lastHandledCanvasKey=i,this.store.setCanvas(e,t),this.selectedAnnotation=null,this.editingPointOrigin.clear(),this.onSelectionChange?.(null),this.notifyExtensionSelectionChange(null),await this.loadAnnotations())}async loadAnnotations(){if(!(!this.annotorious||!this.store.ready)){this.clearAnnotoriousEditingAnnotation();try{await this.store.load()}catch{}}}async handleCreateAnnotation(e){const t=this.prepareAnnotation(e);if(this.onAnnotationCreated?.(t),await this.persistCreate(t))return;const r=t.id;this.annotorious&&r&&this.withSuppressedEcho(r,()=>{this.annotorious?.removeAnnotation(r)}),this.clearSelectionState()}async handleUpdateAnnotation(e){this.consumeSuppressedEcho(e?.id)||await this.saveAnnotation(e)}async handleDeleteAnnotation(e){const t=e?.id;this.consumeSuppressedEcho(t)||!t||!this.store.ready||!this.store.has(t)||!await this.store.delete(t)||this.activeEditingAnnotationId===t&&this.clearSelectionState()}async saveAnnotation(e){if(!this.store.ready)return!1;const t=await this.applyBeforeSave(this.annotationToCanvasSpace(this.forceTargetSource(e)));return await this.store.persist(t)}annotationToCanvasSpace(e){return this.editingPointOrigin.has(e?.id)?this.pointFromEditingRect(e):of(this.toPointSelectorTarget(e),this.getCurrentCanvasImageDimensions())}async persistCreate(e){if(!this.store.ready)return!1;const t=await this.applyBeforeSave(e);return await this.store.persist(t)}withSuppressedEcho(e,t){this.markSuppressedEcho(e),t()}markSuppressedEcho(e){this.suppressedEchoIds.set(e,(this.suppressedEchoIds.get(e)??0)+1)}consumeSuppressedEcho(e){if(!e)return!1;const t=this.suppressedEchoIds.get(e)??0;return t<=0?!1:(t===1?this.suppressedEchoIds.delete(e):this.suppressedEchoIds.set(e,t-1),!0)}forceTargetSource(e){const t=JSON.parse(JSON.stringify(e));return typeof t.target=="string"||!t.target?t.target={source:this.currentCanvasId}:t.target.source=this.currentCanvasId,t}prepareAnnotation(e,t){const i=this.forceTargetSource(e),r=this.config.extension?.prepareDraft?this.config.extension.prepareDraft(i,this.getRuntimeContext(null)):this.config.prepareAnnotation?this.config.prepareAnnotation(i):i,s=this.toPointSelectorTarget(JSON.parse(JSON.stringify(r)));return t?.canvasSpace?s:of(s,this.getCurrentCanvasImageDimensions())}async applyBeforeSave(e){return this.config.extension?.beforeSave?await this.config.extension.beforeSave(e,this.getRuntimeContext(e)):e}getRuntimeContext(e){return{manifestId:this.currentManifestId,canvasId:this.currentCanvasId,isEditing:this.isDrawingEnabled,selectedAnnotation:e,user:this.config.user,hostContext:this.config.extension?.getContext?.()??null}}notifyExtensionSelectionChange(e){this.config.extension?.onSelectionChange?.(e,this.getRuntimeContext(e))}async hydrateAnnotation(e){if(!(!this.annotorious||!this.store.ready||!this.store.hydrateSupported)){if(!this.store.isSkeleton(e)){this.onAnnotationHydrationChange?.(!1);return}this.onAnnotationHydrationChange?.(!0);try{const t=await this.store.hydrate(e,()=>(this.annotorious?.getAnnotations()??[]).some(r=>r.id===e));t&&this.onSelectionChange?.(t)}catch{}finally{this.onAnnotationHydrationChange?.(!1)}}}async deleteAnnotation(e){return!this.store.ready||!await this.store.delete(e)?!1:(this.annotorious?.removeAnnotation(e),this.activeEditingAnnotationId===e&&(this.clearAnnotoriousEditingAnnotation(),this.onSelectionChange?.(null),this.notifyExtensionSelectionChange(null)),!0)}async updateAnnotationBodies(e,t){const r=(this.annotorious?.getAnnotations()??[]).find(a=>a.id===e);if(!r)return!1;const s={...r,body:t};if(!await this.saveAnnotation(s)){const a=this.store.get(e);return a&&this.onSelectionChange?.(a),!1}return this.annotorious&&this.withSuppressedEcho(e,()=>{this.annotorious?.updateAnnotation(s)}),!0}handleIdReconciled(e,t){this.activeEditingAnnotationId===e&&this.selectAnnotationById(t.id)}handleReplay(e,t){this.activeEditingAnnotationId===e&&(t?this.selectAnnotationById(e):(this.clearAnnotoriousEditingAnnotation(),this.onSelectionChange?.(null),this.notifyExtensionSelectionChange(null)))}async selectAnnotationById(e){if(!this.annotorious||!this.store.ready)return;const t=await this.store.resolve(e);if(!t)return;const i=this.toAnnotoriousTarget(t);this.clearAnnotoriousEditingAnnotation();const r=t?.target?.selector;r?.type==="PointSelector"&&this.editingPointOrigin.set(e,{x:r.x,y:r.y}),this.annotorious.setAnnotations([i],!0),this.setActiveEditingAnnotationId(e),this.annotorious?.setSelected(e)}cancelSelection(){this.selectedAnnotation=null,this.onSelectionChange?.(null),this.notifyExtensionSelectionChange(null),this.onAnnotationHydrationChange?.(!1),this.clearAnnotoriousEditingAnnotation()}destroy(){this.osdViewer&&(this.openHandler&&this.osdViewer.removeHandler("open",this.openHandler),this.canvasClickHandler&&this.osdViewer.removeHandler("canvas-click",this.canvasClickHandler)),this.openHandler=null,this.canvasClickHandler=null,this.clearAnnotoriousEditingAnnotation(),this.editingPointOrigin.clear(),this.annotorious?.destroy(),this.annotorious=null,this.ownsStore&&this.store.destroy(),this.osdViewer=null}}const lf=Symbol("triiiceratops:plugin-annotation-editor:t");function wx(n,e){return e?n.replace(/\{(\w+)\}/g,(t,i)=>i in e?String(e[i]):t):n}function Tx(n,e){const t=Fc.en??{};return wx(t[n]??n,e)}function hf(){return Xc(lf)??Tx}function Ex(n){let e=Ge(0);const t=n.subscribe(()=>{_e(e,F(e)+1)});return{t:(r,s)=>(F(e),n.t(r,s)),unsubscribe:t}}const bx=["commenting","tagging","describing","classifying","identifying","linking","bookmarking","highlighting","questioning","replying"];var Sx=rt("<button><!></button>");function wi(n,e){let t=Le(e,"variant",3,"default"),i=Le(e,"size",3,"md"),r=Le(e,"circle",3,!1),s=Le(e,"square",3,!1),o=Le(e,"ghost",3,!1),a=Le(e,"outline",3,!1),l=Le(e,"active",3,!1),h=Le(e,"class",3,""),u=Le(e,"style",3,""),c=Qo(e,["$$slots","$$events","$$legacy","variant","size","circle","square","ghost","outline","active","class","style","children"]);const d={default:"",primary:"--btn-color:var(--tri-color-primary);--btn-color-text:var(--tri-color-primary-text);--btn-fg:var(--tri-color-primary-content);",neutral:"--btn-color:var(--tri-color-neutral);--btn-fg:var(--tri-color-neutral-content);",success:"--btn-color:var(--tri-color-success);--btn-fg:var(--tri-color-success-content);",warning:"--btn-color:var(--tri-color-warning);--btn-fg:var(--tri-color-warning-content);",error:"--btn-color:var(--tri-color-error);--btn-fg:var(--tri-color-error-content);"},f={xs:"--fontsize:0.6875rem;--btn-p:0.5rem;--size:calc(var(--tri-size-field,0.25rem)*6);",sm:"--fontsize:0.75rem;--btn-p:0.75rem;--size:calc(var(--tri-size-field,0.25rem)*8);",md:"--fontsize:0.875rem;--btn-p:1rem;--size:calc(var(--tri-size-field,0.25rem)*10);",lg:"--fontsize:1.125rem;--btn-p:1.25rem;--size:calc(var(--tri-size-field,0.25rem)*12);"};let p=$e(()=>`${f[i()]}${d[t()]}${u()}`);var g=Sx();qo(g,()=>({class:`btn ${h()??""}`,style:F(p),...c,[Bn]:{circle:r(),square:s(),ghost:o(),outline:a(),active:l()}}),void 0,void 0,void 0,"svelte-sgoebi");var m=Ne(g);Kl(m,()=>e.children??tr),Ve(n,g)}let Ax=0;var Rx=rt('<div role="option"> </div>'),Cx=rt('<div><select><!></select> <button type="button" role="combobox" aria-haspopup="listbox"><span> </span></button> <div role="listbox" class="listbox svelte-1hwvamm" popover="manual" tabindex="-1"></div></div>');function Px(n,e){Ur(e,!0);let t=Le(e,"value",15),i=Le(e,"size",3,"md"),r=Le(e,"ghost",3,!1),s=Le(e,"class",3,""),o=Le(e,"style",3,""),a=Qo(e,["$$slots","$$events","$$legacy","value","size","ghost","class","style","children"]);const l={xs:"calc(var(--tri-size-field,0.25rem)*6)",sm:"calc(var(--tri-size-field,0.25rem)*8)",md:"calc(var(--tri-size-field,0.25rem)*10)",lg:"calc(var(--tri-size-field,0.25rem)*12)"};let h=$e(()=>`--size:${l[i()]};${o()}`);const u=`tri-listbox-${Ax++}`;let c=Ge(null),d=Ge(null),f=Ge(null),p=Ge(Wi([])),g=Ge(!1),m=Ge(-1),v=$e(()=>!!e.disabled),_=$e(()=>t()==null?"":String(t())),y=$e(()=>F(p).find(J=>J.value===F(_))??F(p)[0]);function w(){F(c)&&_e(p,Array.from(F(c).querySelectorAll("option")).map(J=>({value:J.value,label:(J.textContent??"").trim(),disabled:J.disabled})),!0)}Xi(()=>{if(!F(c))return;w();const J=new MutationObserver(()=>w());return J.observe(F(c),{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>J.disconnect()});function R(J){const Y=F(p)[J];!F(c)||!Y||Y.disabled||(F(c).value=Y.value,F(c).dispatchEvent(new Event("input",{bubbles:!0})),F(c).dispatchEvent(new Event("change",{bubbles:!0})),X())}function M(){if(!F(d)||!F(f))return;const J=F(d).getBoundingClientRect();F(f).style.minWidth=`${J.width}px`,F(f).style.left=`${J.left}px`;const Y=F(f).offsetHeight,he=window.innerHeight-J.bottom;he<Y&&J.top>he?F(f).style.top=`${Math.max(4,J.top-Y-4)}px`:F(f).style.top=`${J.bottom+4}px`}function C(){F(f)?.children[F(m)]?.scrollIntoView({block:"nearest"})}function O(J){const Y=J.composedPath();F(d)&&Y.includes(F(d))||F(f)&&Y.includes(F(f))||X()}function N(){F(v)||F(g)||!F(f)||(_e(g,!0),F(f).showPopover(),M(),_e(m,F(p).findIndex(J=>J.value===F(_)),!0),F(m)<0&&_e(m,F(p).findIndex(J=>!J.disabled),!0),C(),window.addEventListener("scroll",M,!0),window.addEventListener("resize",M),document.addEventListener("pointerdown",O,!0))}function X(){F(g)&&(_e(g,!1),F(f)?.hidePopover(),window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M),document.removeEventListener("pointerdown",O,!0),F(d)?.focus())}function q(){F(g)?X():N()}function L(J){if(!F(p).length)return;let Y=F(m);for(let he=0;he<F(p).length;he++)if(Y=(Y+J+F(p).length)%F(p).length,!F(p)[Y]?.disabled){_e(m,Y,!0),C();return}}function S(J){const Y=J==="start"?F(p).map((he,le)=>le):F(p).map((he,le)=>F(p).length-1-le);for(const he of Y)if(!F(p)[he]?.disabled){_e(m,he,!0),C();return}}let I="",B;function j(J){I+=J.toLowerCase(),clearTimeout(B),B=setTimeout(()=>I="",600);const Y=F(p).findIndex(he=>!he.disabled&&he.label.toLowerCase().startsWith(I));Y>=0&&(_e(m,Y,!0),C())}function U(J){if(!F(v)){if(!F(g)){["ArrowDown","ArrowUp","Enter"," "].includes(J.key)&&(J.preventDefault(),N());return}switch(J.key){case"ArrowDown":J.preventDefault(),L(1);break;case"ArrowUp":J.preventDefault(),L(-1);break;case"Home":J.preventDefault(),S("start");break;case"End":J.preventDefault(),S("end");break;case"Enter":case" ":J.preventDefault(),F(m)>=0&&R(F(m));break;case"Escape":J.preventDefault(),X();break;case"Tab":X();break;default:J.key.length===1&&!J.metaKey&&!J.ctrlKey&&j(J.key)}}}var W=Cx(),ee=Ne(W);qo(ee,()=>({class:"native-select",tabindex:"-1","aria-hidden":"true",...a}),void 0,void 0,void 0,"svelte-1hwvamm");var z=Ne(ee);Kl(z,()=>e.children??tr),Zo(ee,J=>_e(c,J),()=>F(c));var H=Ze(ee,2);let K;H.__click=q,H.__keydown=U;var $=Ne(H);let se;var fe=Ne($);Zo(H,J=>_e(d,J),()=>F(d));var te=Ze(H,2);Xo(te,23,()=>F(p),(J,Y)=>J.value+"\0"+Y,(J,Y,he)=>{var le=Rx();let ve;le.__click=()=>R(F(he)),le.__pointermove=()=>_e(m,F(he),!0);var Ce=Ne(le);st(()=>{Bt(le,"id",`${u}-opt-${F(he)??""}`),ve=Ln(le,1,"option svelte-1hwvamm",null,ve,{active:F(he)===F(m),selected:F(Y).value===F(_)}),Bt(le,"aria-selected",F(Y).value===F(_)),Bt(le,"aria-disabled",F(Y).disabled),mt(Ce,F(Y).label)}),Ve(J,le)}),Zo(te,J=>_e(f,J),()=>F(f)),st(()=>{Ln(W,1,`select-wrapper ${s()??""}`,"svelte-1hwvamm"),eh(W,o()),K=Ln(H,1,"select svelte-1hwvamm",null,K,{ghost:r(),open:F(g)}),eh(H,F(h)),H.disabled=F(v),Bt(H,"aria-expanded",F(g)),Bt(H,"aria-controls",u),Bt(H,"aria-activedescendant",F(g)&&F(m)>=0?`${u}-opt-${F(m)}`:void 0),Bt(H,"aria-label",a["aria-label"]),se=Ln($,1,"select-label svelte-1hwvamm",null,se,{placeholder:F(y)?.disabled}),mt(fe,F(y)?.label??""),Bt(te,"id",u)}),U0(ee,t),Ve(n,W),Hr()}Xl(["click","keydown","pointermove"]);var Ix=rt("<input/>");function uf(n,e){Ur(e,!0);let t=Le(e,"value",15),i=Le(e,"size",3,"md"),r=Le(e,"ghost",3,!1),s=Le(e,"type",3,"text"),o=Le(e,"class",3,""),a=Le(e,"style",3,""),l=Qo(e,["$$slots","$$events","$$legacy","value","size","ghost","type","class","style"]);const h={xs:"calc(var(--tri-size-field,0.25rem)*6)",sm:"calc(var(--tri-size-field,0.25rem)*8)",md:"calc(var(--tri-size-field,0.25rem)*10)",lg:"calc(var(--tri-size-field,0.25rem)*12)"};let u=$e(()=>`--size:${h[i()]};${a()}`);var c=Ix();qo(c,()=>({type:s(),class:`input ${o()??""}`,style:F(u),...l,[Bn]:{ghost:r()}}),void 0,void 0,void 0,"svelte-4x2zrp",!0),qd(c,t),Ve(n,c),Hr()}var Dx=rt("<span><!></span>");function Mx(n,e){let t=Le(e,"tip",3,""),i=Le(e,"placement",3,"top"),r=Le(e,"open",3,!1),s=Le(e,"class",3,""),o=Le(e,"style",3,""),a=Qo(e,["$$slots","$$events","$$legacy","tip","placement","color","open","class","style","children"]),l=$e(()=>`${e.color?`--tt-bg:var(--color-${e.color});--tt-fg:var(--color-${e.color}-content);`:""}${o()}`);var h=Dx();qo(h,()=>({class:`tooltip ${i()??""} ${s()??""}`,"data-tip":t(),style:F(l),...a,[Bn]:{"tooltip-open":r()}}),void 0,void 0,void 0,"svelte-1cfjd3n");var u=Ne(h);Kl(u,()=>e.children??tr),Ve(n,h)}const hh=(n,e=tr,t=tr)=>{var i=Ox(),r=Ne(i);kd(r,()=>Dl[e()],!0),st(()=>{Bt(i,"viewBox",Il),Bt(i,"width",t()),Bt(i,"height",t())}),Ve(n,i)};var Ox=Bd('<svg class="tri-ae-glyph svelte-u681vn" fill="currentColor" aria-hidden="true" focusable="false"><!></svg>'),Lx=rt('<div class="unknown-body svelte-u681vn"><p class="unknown-body-note svelte-u681vn"> </p> <code class="unknown-body-preview svelte-u681vn"> </code></div>'),Bx=rt('<option class="purpose-option svelte-u681vn"> </option>'),Fx=rt('<textarea class="body-textarea svelte-u681vn" rows="2"></textarea>'),Nx=rt('<div class="body-row svelte-u681vn"><!> <!></div> <!>',1),kx=rt('<div class="card body-card svelte-u681vn"><!></div>'),Ux=rt("<!> ",1),Hx=rt("<!> ",1),zx=rt('<div></div> <!> <div class="save-row svelte-u681vn"><!></div>',1);function Gx(n,e){Ur(e,!0);const t=hf();let i=Le(e,"embedded",3,!1),r=Le(e,"purposes",3,bx),s=Le(e,"allowMultipleBodies",3,!0),o=Ge(Wi([]));function a(){return r()[0]??"commenting"}function l(){return{purpose:a(),value:"",__opaque:!1}}Xi(()=>{e.api.annotation;const M=e.api.bodies.map(c);_e(o,!s()&&M.length===0?[l()]:M,!0)});function h(M){return M&&typeof M=="object"?{...M}:M}function u(M){if(!M||typeof M!="object"||Array.isArray(M))return!1;const C=M,O=C.type,N=C.value;return(O===void 0||O==="TextualBody")&&(N===void 0||typeof N=="string")}function c(M){return u(M)?{...h(M),__opaque:!1}:{__opaque:!0,body:h(M)}}function d(){_e(o,[...F(o),l()],!0)}function f(M){_e(o,F(o).filter((C,O)=>O!==M),!0)}async function p(){const M=F(o).flatMap(C=>{if(C.__opaque)return[C.body];const{__opaque:O,...N}=C;return N.value?.trim()?[N]:[]});await e.api.save(M.length===1?M[0]:M)}var g=zx(),m=_i(g);let v;Xo(m,21,()=>F(o),P0,(M,C,O)=>{var N=kx(),X=Ne(N);{var q=S=>{var I=Lx(),B=Ne(I),j=Ne(B),U=Ze(B,2),W=Ne(U);st((ee,z)=>{mt(j,ee),mt(W,z)},[()=>t("annotation_editor_unknown_body_note"),()=>JSON.stringify(F(C).body,null,2)]),Ve(S,I)},L=S=>{var I=Nx(),B=_i(I),j=Ne(B);Px(j,{class:"body-purpose",size:"xs",get value(){return F(C).purpose},set value(H){F(C).purpose=H},children:(H,K)=>{var $=js(),se=_i($);Xo(se,16,r,fe=>fe,(fe,te)=>{var J=Bx(),Y=Ne(J),he={};st(()=>{mt(Y,te),he!==(he=te)&&(J.value=(J.__value=te)??"")}),Ve(fe,J)}),Ve(H,$)},$$slots:{default:!0}});var U=Ze(j,2);wi(U,{class:"body-remove",size:"xs",ghost:!0,circle:!0,onclick:()=>f(O),children:(H,K)=>{hh(H,()=>"X",()=>14)},$$slots:{default:!0}});var W=Ze(B,2);{var ee=H=>{{let K=$e(()=>t("annotation_editor_tag_placeholder"));uf(H,{class:"body-input",size:"xs",get placeholder(){return F(K)},get disabled(){return e.api.isHydrating},get value(){return F(C).value},set value($){F(C).value=$}})}},z=H=>{var K=js(),$=_i(K);{var se=te=>{{let J=$e(()=>t("annotation_editor_link_placeholder"));uf(te,{class:"body-input",type:"url",size:"xs",get placeholder(){return F(J)},get disabled(){return e.api.isHydrating},get value(){return F(C).value},set value(Y){F(C).value=Y}})}},fe=te=>{var J=Fx();st(Y=>{Bt(J,"placeholder",Y),J.disabled=e.api.isHydrating},[()=>t("annotation_editor_text_placeholder")]),qd(J,()=>F(C).value,Y=>F(C).value=Y),Ve(te,J)};Xt($,te=>{F(C).purpose==="linking"?te(se):te(fe,!1)},!0)}Ve(H,K)};Xt(W,H=>{F(C).purpose==="tagging"?H(ee):H(z,!1)})}Ve(S,I)};Xt(X,S=>{F(C).__opaque?S(q):S(L,!1)})}Ve(M,N)});var _=Ze(m,2);{var y=M=>{wi(M,{class:"add-content",size:"xs",ghost:!0,onclick:d,get disabled(){return e.api.isHydrating},children:(C,O)=>{var N=Ux(),X=_i(N);hh(X,()=>"Plus",()=>14);var q=Ze(X);st(L=>mt(q,` ${L??""}`),[()=>t("annotation_editor_add_content")]),Ve(C,N)},$$slots:{default:!0}})};Xt(_,M=>{s()&&M(y)})}var w=Ze(_,2),R=Ne(w);wi(R,{class:"save-btn",size:"sm",variant:"primary",onclick:p,get disabled(){return e.api.isHydrating},children:(M,C)=>{var O=Hx(),N=_i(O);hh(N,()=>"Check",()=>16);var X=Ze(N);st(q=>mt(X,` ${q??""}`),[()=>t("annotation_editor_save")]),Ve(M,O)},$$slots:{default:!0}}),st(()=>v=Ln(m,1,"bodies svelte-u681vn",null,v,{"bodies-scroll":!i()})),Ve(n,g),Hr()}const Fn=(n,e=tr,t=tr)=>{var i=Vx(),r=Ne(i);kd(r,()=>Dl[e()],!0),st(()=>{Bt(i,"viewBox",Il),Bt(i,"width",t()),Bt(i,"height",t())}),Ve(n,i)};var Vx=Bd('<svg class="tri-ae-glyph svelte-1mu3tdt" fill="currentColor" aria-hidden="true" focusable="false"><!></svg>'),Wx=rt('<div class="header svelte-1mu3tdt"><h2 class="title svelte-1mu3tdt"><!> </h2></div>'),jx=rt('<div class="error-line svelte-1mu3tdt" role="alert"><span class="error-icon svelte-1mu3tdt"><!></span> <span class="error-text svelte-1mu3tdt"> </span> <!></div>'),Xx=rt('<div class="join mode-toggle svelte-1mu3tdt"><!> <!></div>'),Yx=rt('<p class="mode-disabled-reason svelte-1mu3tdt"> </p>'),qx=rt("<!> ",1),Zx=rt("<!> ",1),Kx=rt('<div class="undo-redo svelte-1mu3tdt"><!> <!></div>'),Qx=rt('<div class="tool-section svelte-1mu3tdt"><p class="tool-label svelte-1mu3tdt"> </p> <div class="join svelte-1mu3tdt"></div></div>'),Jx=rt('<div class="custom-body-editor svelte-1mu3tdt"></div>'),$x=rt('<p class="hydrating-note svelte-1mu3tdt"> </p>'),ew=rt('<div class="card editor-card svelte-1mu3tdt"><div class="editor-header svelte-1mu3tdt"><h3 class="editor-title svelte-1mu3tdt"> </h3> <div class="editor-actions svelte-1mu3tdt"><!></div></div> <!> <!></div>'),tw=rt('<dialog class="modal modal-open svelte-1mu3tdt"><div class="modal-box svelte-1mu3tdt"><h3 class="modal-title svelte-1mu3tdt"><span class="modal-warning-icon svelte-1mu3tdt"><!></span> </h3> <p class="modal-message svelte-1mu3tdt"> </p> <div class="modal-action svelte-1mu3tdt"><!> <!></div></div> <form method="dialog" class="modal-backdrop svelte-1mu3tdt"><button class="svelte-1mu3tdt">close</button></form></dialog>'),iw=rt('<div data-panel-id="annotation-editor"><!> <div><!> <div class="mode-section svelte-1mu3tdt"><!> <p class="mode-instruction svelte-1mu3tdt"> </p> <!></div> <!> <!> <!></div></div> <!>',1);function nw(n,e){Ur(e,!0);const t=hf();let i=Le(e,"isEditing",3,!1),r=Le(e,"activeTool",3,"rectangle"),s=Le(e,"selectedAnnotation",3,null),o=Le(e,"showDeleteConfirm",3,!1),a=Le(e,"isHydratingSelection",3,!1),l=Le(e,"canCreateAnnotation",3,!0),h=Le(e,"createDisabledReason",3,null),u=Le(e,"persistenceError",3,null),c=Le(e,"bodyEditor",3,null),d=Le(e,"showModeToggle",3,!0),f=Le(e,"showUndoRedo",3,!0),p=Le(e,"purposes",3,void 0),g=Le(e,"allowMultipleBodies",3,!0),m=Le(e,"canUndo",3,!1),v=Le(e,"canRedo",3,!1),_=Le(e,"availableTools",19,()=>["rectangle","polygon","point"]),y=Le(e,"embedded",3,!1);function w(me){switch(me){case"load":return t("annotation_editor_error_load");case"create":return t("annotation_editor_error_create");case"delete":return t("annotation_editor_error_delete");case"hydrate":return t("annotation_editor_error_hydrate");case"update":default:return t("annotation_editor_error_update")}}const R={rectangle:"Rectangle",polygon:"Polygon",point:"Target"},M={rectangle:"annotation_tool_rectangle",polygon:"annotation_tool_polygon",point:"annotation_tool_point"};let C=Ge(null),O=Ge(null),N=Ge(null);function X(me){const Ae=me?.body;return Array.isArray(Ae)?Ae:Ae!=null?[Ae]:[]}Xi(()=>{if(!s()){_e(C,null),_e(O,null);return}const me=X(s());if(!F(C)||F(O)!==s().id){_e(O,s().id,!0),_e(C,{annotation:s(),bodies:me,context:e.runtimeContext,isHydrating:a(),save:async Ae=>{await e.onSaveBodies(Ae)},cancel:e.onCancelSelection,requestDelete:e.onRequestDelete},!0);return}F(C).annotation=s(),F(C).bodies=me,F(C).context=e.runtimeContext,F(C).isHydrating=a()}),Xi(()=>{const me=F(C),Ae=c(),x=F(N);if(!me||!Ae||!("render"in Ae)||!x)return;me.annotation,me.bodies,me.isHydrating;const A=Ae.render(x,me);return()=>{A?.(),x.replaceChildren()}});var q=iw(),L=_i(q);let S;var I=Ne(L);{var B=me=>{var Ae=Wx(),x=Ne(Ae),A=Ne(x);Fn(A,()=>"PencilSimple",()=>20);var k=Ze(A);st(G=>mt(k,` ${G??""}`),[()=>t("annotation_editor_title")]),Ve(me,Ae)};Xt(I,me=>{y()||me(B)})}var j=Ze(I,2);let U;var W=Ne(j);{var ee=me=>{var Ae=jx(),x=Ne(Ae),A=Ne(x);Fn(A,()=>"Warning",()=>16);var k=Ze(x,2),G=Ne(k),V=Ze(k,2);{let oe=$e(()=>t("annotation_editor_error_dismiss"));wi(V,{class:"error-dismiss",size:"xs",ghost:!0,circle:!0,get onclick(){return e.onDismissError},get"aria-label"(){return F(oe)},children:(Q,xe)=>{Fn(Q,()=>"X",()=>14)},$$slots:{default:!0}})}st(oe=>mt(G,oe),[()=>w(u().op)]),Ve(me,Ae)};Xt(W,me=>{u()&&me(ee)})}var z=Ze(W,2),H=Ne(z);{var K=me=>{var Ae=Xx(),x=Ne(Ae);{let k=$e(()=>i()?"default":"primary");wi(x,{class:"join-item",size:"sm",get variant(){return F(k)},onclick:()=>i()&&e.onToggleEditing(),children:(G,V)=>{var oe=jo();st(Q=>mt(oe,Q),[()=>t("annotation_editor_edit_mode")]),Ve(G,oe)},$$slots:{default:!0}})}var A=Ze(x,2);{let k=$e(()=>i()?"primary":"default"),G=$e(()=>!l());wi(A,{class:"join-item",size:"sm",get variant(){return F(k)},get disabled(){return F(G)},onclick:()=>!i()&&e.onToggleEditing(),children:(V,oe)=>{var Q=jo();st(xe=>mt(Q,xe),[()=>t("annotation_editor_create_mode")]),Ve(V,Q)},$$slots:{default:!0}})}Ve(me,Ae)};Xt(H,me=>{d()&&me(K)})}var $=Ze(H,2),se=Ne($),fe=Ze($,2);{var te=me=>{var Ae=Yx(),x=Ne(Ae);st(()=>mt(x,h())),Ve(me,Ae)};Xt(fe,me=>{!l()&&h()&&me(te)})}var J=Ze(z,2);{var Y=me=>{var Ae=Kx(),x=Ne(Ae);{let k=$e(()=>!m());wi(x,{class:"undo-redo-btn",size:"sm",outline:!0,get disabled(){return F(k)},get onclick(){return e.onUndo},children:(G,V)=>{var oe=qx(),Q=_i(oe);Fn(Q,()=>"ArrowCounterClockwise",()=>16);var xe=Ze(Q);st(Be=>mt(xe,` ${Be??""}`),[()=>t("annotation_editor_undo")]),Ve(G,oe)},$$slots:{default:!0}})}var A=Ze(x,2);{let k=$e(()=>!v());wi(A,{class:"undo-redo-btn",size:"sm",outline:!0,get disabled(){return F(k)},get onclick(){return e.onRedo},children:(G,V)=>{var oe=Zx(),Q=_i(oe);Fn(Q,()=>"ArrowClockwise",()=>16);var xe=Ze(Q);st(Be=>mt(xe,` ${Be??""}`),[()=>t("annotation_editor_redo")]),Ve(G,oe)},$$slots:{default:!0}})}Ve(me,Ae)};Xt(J,me=>{f()&&me(Y)})}var he=Ze(J,2);{var le=me=>{var Ae=Qx(),x=Ne(Ae),A=Ne(x),k=Ze(x,2);Xo(k,20,_,G=>G,(G,V)=>{const oe=$e(()=>R[V]??"Rectangle"),Q=$e(()=>t(M[V]??"annotation_tool_rectangle"));Mx(G,{get tip(){return F(Q)},placement:"bottom",class:"join-item tool-tip",children:(xe,Be)=>{{let tt=$e(()=>r()===V?"primary":"default");wi(xe,{size:"sm",get variant(){return F(tt)},onclick:()=>e.onSetTool(V),get"aria-label"(){return F(Q)},children:(ye,qe)=>{Fn(ye,()=>F(oe),()=>18)},$$slots:{default:!0}})}},$$slots:{default:!0}})}),st(G=>mt(A,G),[()=>t("annotation_editor_tool_label")]),Ve(me,Ae)};Xt(he,me=>{i()&&me(le)})}var ve=Ze(he,2);{var Ce=me=>{var Ae=ew(),x=Ne(Ae),A=Ne(x),k=Ne(A),G=Ze(A,2),V=Ne(G);{let ye=$e(()=>t("annotation_editor_delete_tooltip"));wi(V,{class:"delete-btn",size:"sm",ghost:!0,circle:!0,get onclick(){return e.onRequestDelete},get"aria-label"(){return F(ye)},children:(qe,E)=>{Fn(qe,()=>"Trash",()=>16)},$$slots:{default:!0}})}var oe=Ze(x,2);{var Q=ye=>{const qe=$e(()=>c().component);var E=js(),T=_i(E);O0(T,()=>F(qe),(P,D)=>{D(P,{get api(){return F(C)}})}),Ve(ye,E)},xe=ye=>{var qe=js(),E=_i(qe);{var T=D=>{var Z=Jx();Zo(Z,ne=>_e(N,ne),()=>F(N)),Ve(D,Z)},P=D=>{var Z=js(),ne=_i(Z);{var Re=Qe=>{Gx(Qe,{get api(){return F(C)},get embedded(){return y()},get purposes(){return p()},get allowMultipleBodies(){return g()}})};Xt(ne,Qe=>{F(C)&&Qe(Re)},!0)}Ve(D,Z)};Xt(E,D=>{F(C)&&c()&&"render"in c()?D(T):D(P,!1)},!0)}Ve(ye,qe)};Xt(oe,ye=>{F(C)&&c()&&"component"in c()?ye(Q):ye(xe,!1)})}var Be=Ze(oe,2);{var tt=ye=>{var qe=$x(),E=Ne(qe);st(T=>mt(E,T),[()=>t("annotation_editor_hydrating")]),Ve(ye,qe)};Xt(Be,ye=>{a()&&ye(tt)})}st(ye=>mt(k,ye),[()=>t("annotation_editor_edit_section")]),Ve(me,Ae)};Xt(ve,me=>{s()&&me(Ce)})}var ze=Ze(L,2);{var lt=me=>{var Ae=tw(),x=Ne(Ae),A=Ne(x),k=Ne(A),G=Ne(k);Fn(G,()=>"Warning",()=>24);var V=Ze(k),oe=Ze(A,2),Q=Ne(oe),xe=Ze(oe,2),Be=Ne(xe);wi(Be,{ghost:!0,get onclick(){return e.onCancelDelete},children:(E,T)=>{var P=jo();st(D=>mt(P,D),[()=>t("annotation_editor_cancel")]),Ve(E,P)},$$slots:{default:!0}});var tt=Ze(Be,2);wi(tt,{variant:"error",get onclick(){return e.onConfirmDelete},children:(E,T)=>{var P=jo();st(D=>mt(P,D),[()=>t("annotation_editor_delete")]),Ve(E,P)},$$slots:{default:!0}});var ye=Ze(x,2),qe=Ne(ye);qe.__click=function(...E){e.onCancelDelete?.apply(this,E)},st((E,T)=>{mt(V,` ${E??""}`),mt(Q,T)},[()=>t("annotation_editor_delete_title"),()=>t("annotation_editor_delete_message")]),Ve(me,Ae)};Xt(ze,me=>{o()&&me(lt)})}st(me=>{S=Ln(L,1,"panel svelte-1mu3tdt",null,S,{floating:!y()}),U=Ln(j,1,"content svelte-1mu3tdt",null,U,{scroll:!y()}),mt(se,me)},[()=>i()?t("annotation_editor_instruction_create"):t("annotation_editor_instruction_edit")]),Ve(n,q),Hr()}Xl(["click"]);function rw(n,e){Ur(e,!0);let t=Le(e,"embedded",3,!1);const i=Xc(Kd);let r=Ge(Wi(Mn(()=>e.config.ui?.startInCreateMode??!1)));const s=Mn(()=>af(e.config));let o=Ge(Wi(s.defaultTool)),a=Ge(null),l=Ge(!1),h=Ge(!1),u=Ge(null),c=Ge(0);function d(){return{manifestId:i?.manifestId??null,canvasId:i?.canvasId??null,isEditing:F(r),selectedAnnotation:F(a),user:e.config.user,hostContext:e.config.extension?.getContext?.()??null}}let f=$e(()=>{F(c);const S=d();return e.config.extension?.canCreate?e.config.extension.canCreate(S):e.config.canCreateAnnotation?e.config.canCreateAnnotation():!0}),p=$e(()=>{F(c);const S=d();return e.config.extension?.getCreateDisabledReason?e.config.extension.getCreateDisabledReason(S):e.config.getCreateDisabledReason?e.config.getCreateDisabledReason():null}),g=Ge(null);Xi(()=>{if(F(g)||!i?.osdViewer)return;const S=new cr(e.config,e.store,i);S.onSelectionChange=I=>{_e(a,I,!0)},S.onAnnotationCreated=I=>{_e(a,I,!0)},S.onAnnotationHydrationChange=I=>{_e(l,I,!0)},S.onActiveEditingAnnotationChange=I=>{i?.annotationEditBus&&(i.annotationEditBus.activeEditAnnotationId=I)},S.init(i.osdViewer,i.canvasId),F(r)&&F(f)&&S.setEditing(!0),i.manifestId&&i.canvasId&&S.handleCanvasChange(i.manifestId,i.canvasId),_e(g,S)}),C0(()=>{i?.annotationEditBus&&(i.annotationEditBus.requestEdit=()=>{},i.annotationEditBus.activeEditAnnotationId=null),F(g)?.destroy()}),Fd(()=>{const S=e.config.extension?.subscribe?.(()=>{e0(c)}),I=i?.annotationEditBus?.requestEdit;return i?.annotationEditBus&&(i.annotationEditBus.requestEdit=B=>{B&&F(g)?.selectAnnotationById(B)}),()=>{S?.(),i?.annotationEditBus&&(i.annotationEditBus.requestEdit=I??(()=>{}))}}),Xi(()=>{const S=i?.manifestId,I=i?.canvasId;F(g)?.handleCanvasChange(S??null,I??null)}),Xi(()=>{F(f)||!F(r)||(_e(r,!1),F(g)?.setEditing(!1))});function m(){!F(r)&&!F(f)||(_e(r,!F(r)),F(g)?.setEditing(F(r)))}function v(S){_e(o,S,!0),F(g)?.setTool(S)}let _=$e(()=>F(g)?.persistenceError??null);function y(){F(g)?.dismissPersistenceError()}let w=$e(()=>F(g)?.canUndo??!1),R=$e(()=>F(g)?.canRedo??!1);function M(){F(g)?.undo()}function C(){F(g)?.redo()}async function O(S){F(a)&&F(g)&&!F(l)&&await F(g).updateAnnotationBodies(F(a).id,S)&&(_e(a,null),F(g).cancelSelection())}function N(){_e(a,null),F(g)?.cancelSelection()}function X(){F(a)&&(_e(u,F(a).id,!0),_e(h,!0))}async function q(){let S=!0;F(u)&&F(g)&&(S=await F(g).deleteAnnotation(F(u))),_e(h,!1),_e(u,null),S&&_e(a,null)}function L(){_e(h,!1),_e(u,null)}{let S=$e(()=>e.config.bodyEditor??null),I=$e(()=>e.config.ui?.showModeToggle??!0),B=$e(()=>e.config.ui?.showUndoRedo??!0),j=$e(()=>e.config.ui?.purposes),U=$e(()=>e.config.ui?.allowMultipleBodies??!0),W=$e(d),ee=$e(()=>F(g)?.availableTools??s.tools);nw(n,{get isEditing(){return F(r)},get activeTool(){return F(o)},get selectedAnnotation(){return F(a)},get showDeleteConfirm(){return F(h)},get isHydratingSelection(){return F(l)},get canCreateAnnotation(){return F(f)},get createDisabledReason(){return F(p)},get persistenceError(){return F(_)},get bodyEditor(){return F(S)},get showModeToggle(){return F(I)},get showUndoRedo(){return F(B)},get purposes(){return F(j)},get allowMultipleBodies(){return F(U)},get runtimeContext(){return F(W)},onDismissError:y,get canUndo(){return F(w)},get canRedo(){return F(R)},onUndo:M,onRedo:C,get availableTools(){return F(ee)},onToggleEditing:m,onSetTool:v,onSaveBodies:O,onCancelSelection:N,onRequestDelete:X,onConfirmDelete:q,onCancelDelete:L,get embedded(){return t()}})}Hr()}function sw(n,e){let t=Le(e,"embedded",3,!1);rw(n,{get config(){return e.config},get store(){return e.store},get embedded(){return t()}})}function ow(n){return e=>{n.setDisplayState(e);let t=null;Xi(()=>{const i=e.manifestId,r=e.canvasId;if(!i||!r)return;const s=`${i}::${r}`;s!==t&&(t=s,n.setCanvas(i,r),n.load())}),Xi(()=>()=>n.destroy())}}const aw="canvas.a9s-gl-canvas{height:100%;left:0;position:absolute;top:0;width:100%}canvas.a9s-gl-canvas.hidden{display:none}canvas.a9s-gl-canvas.hover{cursor:pointer!important}svg.svelte-g4ws1v.svelte-g4ws1v{pointer-events:none}svg.drawing.svelte-g4ws1v.svelte-g4ws1v,svg.editing.svelte-g4ws1v .svelte-g4ws1v{pointer-events:all}svg.hover.svelte-g4ws1v.svelte-g4ws1v{cursor:pointer}svg.svelte-g4ws1v .svelte-g4ws1v{pointer-events:all}text.svelte-1rehw2p{fill:#fff;font-family:Arial,Helvetica,sans-serif;font-weight:600}rect.svelte-1rehw2p{stroke-width:1.2;vector-effect:non-scaling-stroke}polygon.svelte-fgq4n0{stroke-width:1.2;vector-effect:non-scaling-stroke}rect.svelte-gze948{stroke-width:1.2;vector-effect:non-scaling-stroke}svg.svelte-1krwc4m{position:absolute;top:0;left:0;width:100%;height:100%;outline:none;pointer-events:none}svg.svelte-jwrce3{overflow:visible;position:absolute;top:0;left:0;width:100%;height:100%;outline:none;pointer-events:none}.a9s-osd-selectionlayer :is(rect,path,polygon,ellipse,line){fill:#3182ed40;stroke:#3182ed;stroke-width:1.5px;vector-effect:non-scaling-stroke}rect.a9s-union-fg.svelte-jwrce3{fill:#3182ed1f;stroke-width:1px}rect.a9s-union-bg.svelte-jwrce3{fill:transparent;stroke:#fff;stroke-width:2px}circle.a9s-handle-buffer.svelte-qtyc7s:focus{outline:none}circle.a9s-handle-buffer.svelte-qtyc7s:focus-visible{stroke:#fffc;stroke-width:3px}.a9s-polygon-midpoint.svelte-12ykj76{cursor:crosshair}.a9s-polygon-midpoint-buffer.svelte-12ykj76{fill:transparent}.a9s-polygon-midpoint-outer.svelte-12ykj76{display:none;fill:transparent;pointer-events:none;stroke:#00000059;stroke-width:1.5px;vector-effect:non-scaling-stroke}.a9s-polygon-midpoint-inner.svelte-12ykj76{fill:#00000040;pointer-events:none;stroke:#fff;stroke-width:1px;vector-effect:non-scaling-stroke}mask.a9s-polygon-editor-mask.svelte-1h2slbm>rect.svelte-1h2slbm{fill:#fff}mask.a9s-polygon-editor-mask.svelte-1h2slbm>circle.svelte-1h2slbm,mask.a9s-polygon-editor-mask.svelte-1h2slbm>polygon.svelte-1h2slbm{fill:#000}mask.a9s-rectangle-editor-mask.svelte-1njczvj>rect.rect-mask-bg.svelte-1njczvj{fill:#fff}mask.a9s-rectangle-editor-mask.svelte-1njczvj>rect.rect-mask-fg.svelte-1njczvj{fill:#000}mask.a9s-multipolygon-editor-mask.svelte-1vxo6dc>rect.svelte-1vxo6dc{fill:#fff}mask.a9s-multipolygon-editor-mask.svelte-1vxo6dc>circle.svelte-1vxo6dc,mask.a9s-multipolygon-editor-mask.svelte-1vxo6dc>path.svelte-1vxo6dc{fill:#000}mask.a9s-rubberband-rectangle-mask.svelte-1a76qe7>rect.rect-mask-bg.svelte-1a76qe7{fill:#fff}mask.a9s-rubberband-rectangle-mask.svelte-1a76qe7>rect.rect-mask-fg.svelte-1a76qe7{fill:#000}mask.a9s-rubberband-polygon-mask.svelte-18wrg3t>rect.svelte-18wrg3t{fill:#fff}mask.a9s-rubberband-polygon-mask.svelte-18wrg3t>polygon.svelte-18wrg3t{fill:#000}circle.a9s-handle.svelte-18wrg3t.svelte-18wrg3t{fill:#fff;pointer-events:none;stroke:#00000059;stroke-width:1px;vector-effect:non-scaling-stroke}path.open.svelte-1w0132l{fill:transparent!important}.a9s-annotationlayer{box-sizing:border-box;height:100%;left:0;outline:none;position:absolute;top:0;touch-action:none;width:100%;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.a9s-annotationlayer.hover{cursor:pointer}.a9s-annotationlayer.hidden{display:none}.a9s-annotationlayer ellipse,.a9s-annotationlayer line,.a9s-annotationlayer path,.a9s-annotationlayer polygon,.a9s-annotationlayer rect{fill:transparent;shape-rendering:geometricPrecision;vector-effect:non-scaling-stroke;-webkit-tap-highlight-color:transparent}.a9s-touch-halo{fill:transparent;pointer-events:none;stroke-width:0;transition:fill .15s}.a9s-touch-halo.touched{fill:#fff6}.a9s-handle-buffer{fill:transparent}.a9s-handle [role=button]{cursor:inherit!important}.a9s-handle-dot{fill:#fff;pointer-events:none;stroke:#00000059;stroke-width:1px;vector-effect:non-scaling-stroke}.a9s-handle-dot.selected{fill:#1a1a1a;stroke:none}.a9s-handle-selected{animation:dash-rotate .35s linear infinite reverse;fill:#ffffff40;stroke:#000000e6;stroke-dasharray:2 2;stroke-width:1px;pointer-events:none;vector-effect:non-scaling-stroke}@keyframes dash-rotate{0%{stroke-dashoffset:0}to{stroke-dashoffset:4}}.a9s-edge-handle{fill:transparent;stroke:transparent;stroke-width:6px}.a9s-shape-handle,.a9s-handle{cursor:move}.a9s-handle.a9s-corner-handle{cursor:crosshair}.a9s-edge-handle-top{cursor:n-resize}.a9s-edge-handle-right{cursor:e-resize}.a9s-edge-handle-bottom{cursor:s-resize}.a9s-edge-handle-left{cursor:w-resize}.a9s-handle.a9s-corner-handle-topleft{cursor:nw-resize}.a9s-handle.a9s-corner-handle-topright{cursor:ne-resize}.a9s-handle.a9s-corner-handle-bottomright{cursor:se-resize}.a9s-handle.a9s-corner-handle-bottomleft{cursor:sw-resize}.a9s-annotationlayer .a9s-outer,div[data-theme=dark] .a9s-annotationlayer .a9s-outer{display:none}.a9s-annotationlayer .a9s-inner,div[data-theme=dark] .a9s-annotationlayer .a9s-inner{fill:#0000001f;stroke:#000;stroke-width:1px}rect.a9s-handle,div[data-theme=dark] rect.a9s-handle{fill:#000;rx:2px}rect.a9s-close-polygon-handle,div[data-theme=dark] rect.a9s-close-polygon-handle{fill:#000;rx:1px}.a9s-annotationlayer .a9s-outer,div[data-theme=light] .a9s-annotationlayer .a9s-outer{display:block;stroke:#00000059;stroke-width:3px}.a9s-annotationlayer .a9s-inner,div[data-theme=light] .a9s-annotationlayer .a9s-inner{fill:#ffffff26;stroke:#fff;stroke-width:1.5px}rect.a9s-handle,div[data-theme=light] rect.a9s-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}rect.a9s-close-polygon-handle,div[data-theme=light] rect.a9s-close-polygon-handle{fill:#fff;rx:1px;stroke:#00000073;stroke-width:1px}",lw=`
6
+ .a9s-annotationlayer, .a9s-osd-drawinglayer {
7
+ width: 100% !important;
8
+ height: 100% !important;
9
+ position: absolute;
10
+ top: 0;
11
+ left: 0;
12
+ pointer-events: none;
13
+ }
14
+ .a9s-annotationlayer svg, .a9s-osd-drawinglayer svg {
15
+ pointer-events: auto;
16
+ width: 100%;
17
+ height: 100%;
18
+ }
19
+ .annotorious-drawing-mode .a9s-annotationlayer svg,
20
+ .annotorious-drawing-mode .a9s-osd-drawinglayer svg {
21
+ pointer-events: none !important;
22
+ cursor: crosshair;
23
+ }
24
+ .a9s-annotationlayer :is(rect, polygon, path, ellipse, line) {
25
+ stroke: #1e90ff;
26
+ stroke-width: 2px;
27
+ fill: transparent;
28
+ vector-effect: non-scaling-stroke;
29
+ }
30
+ .a9s-annotationlayer circle {
31
+ stroke: #1e90ff;
32
+ stroke-width: 2px;
33
+ vector-effect: non-scaling-stroke;
34
+ pointer-events: visiblePainted;
35
+ }
36
+ .point-selected .a9s-osd-selectionlayer rect {
37
+ rx: 999px;
38
+ ry: 999px;
39
+ }
40
+ .point-selected .a9s-handle,
41
+ .point-selected .a9s-edge-handle {
42
+ display: none !important;
43
+ pointer-events: none !important;
44
+ }
45
+ .a9s-osd-selectionlayer circle {
46
+ fill: transparent;
47
+ stroke: #3182ed;
48
+ stroke-width: 1.5px;
49
+ vector-effect: non-scaling-stroke;
50
+ pointer-events: none;
51
+ }
52
+ `,{STYLES:hw,STYLE_ID:uw}=n_(`${aw}
53
+ ${lw}`,"annotorious");class cw{#e;#t;#i=Ge(null);get manifestId(){return F(this.#i)}set manifestId(e){_e(this.#i,e,!0)}#n=Ge(null);get canvasId(){return F(this.#n)}set canvasId(e){_e(this.#n,e,!0)}#r=Ge(null);get osdViewer(){return F(this.#r)}set osdViewer(e){_e(this.#r,e)}constructor(e){this.#e=e,this.manifestId=e.manifestId,this.canvasId=e.canvasId,this.osdViewer=e.osdViewer,this.#t=e.subscribe(()=>{this.manifestId!==e.manifestId&&(this.manifestId=e.manifestId),this.canvasId!==e.canvasId&&(this.canvasId=e.canvasId),this.osdViewer!==e.osdViewer&&(this.osdViewer=e.osdViewer)})}get annotationEditBus(){return this.#e.annotationEditBus}getCanvases(e,t){return this.#e.getCanvases(e,t)}getUserAnnotations(e,t){return this.#e.getUserAnnotations(e,t)}setUserAnnotations(e,t,i){this.#e.setUserAnnotations(e,t,i)}clearUserAnnotations(e,t){this.#e.clearUserAnnotations(e,t)}getStyleRoot(){return this.#e.getStyleRoot()}destroy(){this.#t()}}function dw(n){const e=new cw(n);return{mirror:e,destroy:()=>e.destroy()}}function fw(n,e,t){const i=e.styles.install(hw,uw),r=e.styles.install(W0,"bundled"),{mirror:s,destroy:o}=dw(e.viewerState),{t:a,unsubscribe:l}=Ex(e.locale),h=t.adapter??new Zs,u={...t,adapter:h},c=new Xr(u);c.setDisplayState(s);const d=l0(()=>{ow(c)(s)}),f=S0(sw,{target:n,props:{config:u,store:c,embedded:!0},context:new Map([[Kd,s],[lf,a]])});return()=>{R0(f),d(),l(),o(),r(),i()}}function pw(n={}){const e={mount(t,i){return fw(t,i,n)}};return Jy({name:"@triiiceratops/plugin-annotation-editor",uiId:"annotation-editor",version:"1.0.0-rc.0",coreRange:">=1.0.0-rc.0",pluginApiRange:"^1.0.0",requiredCapabilities:["osd@5"],icon:r_,target:n.target??"panel",dismiss:"explicit",catalog:Fc,view:e})}const gw=pw({adapter:new Zs,tools:["rectangle","polygon","point"],defaultTool:"rectangle"});function mw(){const n=new Map;return{register(e){const t=n.get(e.name);if(!t){n.set(e.name,e);return}t.version!==e.version&&console.warn(`[triiiceratops] Ignoring plugin "${e.name}" version ${e.version}: version ${t.version} is already registered on this page and wins (first registration wins).`)},get(e){return n.get(e)},has(e){return n.has(e)},list(){return[...n.values()]}}}function vw(n){(window.Triiiceratops??={coreVersion:"",pluginApiVersion:"",capabilities:[],plugins:mw()}).plugins.register(n)}vw(gw);function yw(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ta={exports:{}},_w=ta.exports,cf;function xw(){return cf||(cf=1,(function(n){//! openseadragon 5.0.1
54
+ //! Built on 2024-12-09
55
+ //! Git commit: v5.0.1-0-480de92d
56
+ //! http://openseadragon.github.io
57
+ //! License: http://openseadragon.github.io/license/
58
+ function e(t){return new e.Viewer(t)}(function(t){t.version={versionStr:"5.0.1",major:parseInt("5",10),minor:parseInt("0",10),revision:parseInt("1",10)};var i={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object AsyncFunction]":"function","[object Promise]":"promise","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"},r=Object.prototype.toString,s=Object.prototype.hasOwnProperty;t.isFunction=function(o){return t.type(o)==="function"},t.isArray=Array.isArray||function(o){return t.type(o)==="array"},t.isWindow=function(o){return o&&typeof o=="object"&&"setInterval"in o},t.type=function(o){return o==null?String(o):i[r.call(o)]||"object"},t.isPlainObject=function(o){if(!o||e.type(o)!=="object"||o.nodeType||t.isWindow(o)||o.constructor&&!s.call(o,"constructor")&&!s.call(o.constructor.prototype,"isPrototypeOf"))return!1;var a;for(var l in o)a=l;return a===void 0||s.call(o,a)},t.isEmptyObject=function(o){for(var a in o)return!1;return!0},t.freezeObject=function(o){return Object.freeze?t.freezeObject=Object.freeze:t.freezeObject=function(a){return a},t.freezeObject(o)},t.supportsCanvas=(function(){var o=document.createElement("canvas");return!!(t.isFunction(o.getContext)&&o.getContext("2d"))})(),t.isCanvasTainted=function(o){var a=!1;try{o.getContext("2d").getImageData(0,0,1,1)}catch{a=!0}return a},t.supportsAddEventListener=(function(){return!!(document.documentElement.addEventListener&&document.addEventListener)})(),t.supportsRemoveEventListener=(function(){return!!(document.documentElement.removeEventListener&&document.removeEventListener)})(),t.supportsEventListenerOptions=(function(){var o=0;if(t.supportsAddEventListener)try{var a={get capture(){return o++,!1},get once(){return o++,!1},get passive(){return o++,!1}};window.addEventListener("test",null,a),window.removeEventListener("test",null,a)}catch{o=0}return o>=3})(),t.getCurrentPixelDensityRatio=function(){if(t.supportsCanvas){var o=document.createElement("canvas").getContext("2d"),a=window.devicePixelRatio||1,l=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1;return Math.max(a,1)/l}else return 1},t.pixelDensityRatio=t.getCurrentPixelDensityRatio()})(e),(function(t){t.extend=function(){var l,h,u,c,d,f,p=arguments[0]||{},g=arguments.length,m=!1,v=1;for(typeof p=="boolean"&&(m=p,p=arguments[1]||{},v=2),typeof p!="object"&&!e.isFunction(p)&&(p={}),g===v&&(p=this,--v);v<g;v++)if(l=arguments[v],l!==null||l!==void 0)for(h in l){var _=Object.getOwnPropertyDescriptor(l,h);if(_!==void 0){if(_.get||_.set){Object.defineProperty(p,h,_);continue}c=_.value}else{t.console.warn('Could not copy inherited property "'+h+'".');continue}p!==c&&(m&&c&&(e.isPlainObject(c)||(d=e.isArray(c)))?(u=p[h],d?(d=!1,f=u&&e.isArray(u)?u:[]):f=u&&e.isPlainObject(u)?u:{},p[h]=e.extend(m,f,c)):c!==void 0&&(p[h]=c))}return p};var i=function(){if(typeof navigator!="object")return!1;var l=navigator.userAgent;return typeof l!="string"?!1:l.indexOf("iPhone")!==-1||l.indexOf("iPad")!==-1||l.indexOf("iPod")!==-1};t.extend(t,{DEFAULT_SETTINGS:{xmlPath:null,tileSources:null,tileHost:null,initialPage:0,crossOriginPolicy:!1,ajaxWithCredentials:!1,loadTilesWithAjax:!1,ajaxHeaders:{},splitHashDataForPost:!1,panHorizontal:!0,panVertical:!0,constrainDuringPan:!1,wrapHorizontal:!1,wrapVertical:!1,visibilityRatio:.5,minPixelRatio:.5,defaultZoomLevel:0,minZoomLevel:null,maxZoomLevel:null,homeFillsViewer:!1,clickTimeThreshold:300,clickDistThreshold:5,dblClickTimeThreshold:300,dblClickDistThreshold:20,springStiffness:6.5,animationTime:1.2,gestureSettingsMouse:{dragToPan:!0,scrollToZoom:!0,clickToZoom:!0,dblClickToZoom:!1,dblClickDragToZoom:!1,pinchToZoom:!1,zoomToRefPoint:!0,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsTouch:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,dblClickDragToZoom:!0,pinchToZoom:!0,zoomToRefPoint:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsPen:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!0,dblClickToZoom:!1,dblClickDragToZoom:!1,pinchToZoom:!1,zoomToRefPoint:!0,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsUnknown:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,dblClickDragToZoom:!1,pinchToZoom:!0,zoomToRefPoint:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},zoomPerClick:2,zoomPerScroll:1.2,zoomPerDblClickDrag:1.2,zoomPerSecond:1,blendTime:0,alwaysBlend:!1,autoHideControls:!0,immediateRender:!1,minZoomImageRatio:.9,maxZoomPixelRatio:1.1,smoothTileEdgesMinZoom:1.1,iOSDevice:i(),pixelsPerWheelLine:40,pixelsPerArrowPress:40,autoResize:!0,preserveImageSizeOnResize:!1,minScrollDeltaTime:50,rotationIncrement:90,maxTilesPerFrame:1,showSequenceControl:!0,sequenceControlAnchor:null,preserveViewport:!1,preserveOverlays:!1,navPrevNextWrap:!1,showNavigationControl:!0,navigationControlAnchor:null,showZoomControl:!0,showHomeControl:!0,showFullPageControl:!0,showRotationControl:!1,showFlipControl:!1,controlsFadeDelay:2e3,controlsFadeLength:1500,mouseNavEnabled:!0,showNavigator:!1,navigatorElement:null,navigatorId:null,navigatorPosition:null,navigatorSizeRatio:.2,navigatorMaintainSizeRatio:!1,navigatorTop:null,navigatorLeft:null,navigatorHeight:null,navigatorWidth:null,navigatorAutoResize:!0,navigatorAutoFade:!0,navigatorRotate:!0,navigatorBackground:"#000",navigatorOpacity:.8,navigatorBorderColor:"#555",navigatorDisplayRegionColor:"#900",degrees:0,flipped:!1,overlayPreserveContentDirection:!0,opacity:1,compositeOperation:null,drawer:["webgl","canvas","html"],drawerOptions:{webgl:{},canvas:{},html:{},custom:{}},preload:!1,imageSmoothingEnabled:!0,placeholderFillStyle:null,subPixelRoundingForTransparency:null,showReferenceStrip:!1,referenceStripScroll:"horizontal",referenceStripElement:null,referenceStripHeight:null,referenceStripWidth:null,referenceStripPosition:"BOTTOM_LEFT",referenceStripSizeRatio:.2,collectionRows:3,collectionColumns:0,collectionLayout:"horizontal",collectionMode:!1,collectionTileSize:800,collectionTileMargin:80,imageLoaderLimit:0,maxImageCacheCount:200,timeout:3e4,tileRetryMax:0,tileRetryDelay:2500,prefixUrl:"/images/",navImages:{zoomIn:{REST:"zoomin_rest.png",GROUP:"zoomin_grouphover.png",HOVER:"zoomin_hover.png",DOWN:"zoomin_pressed.png"},zoomOut:{REST:"zoomout_rest.png",GROUP:"zoomout_grouphover.png",HOVER:"zoomout_hover.png",DOWN:"zoomout_pressed.png"},home:{REST:"home_rest.png",GROUP:"home_grouphover.png",HOVER:"home_hover.png",DOWN:"home_pressed.png"},fullpage:{REST:"fullpage_rest.png",GROUP:"fullpage_grouphover.png",HOVER:"fullpage_hover.png",DOWN:"fullpage_pressed.png"},rotateleft:{REST:"rotateleft_rest.png",GROUP:"rotateleft_grouphover.png",HOVER:"rotateleft_hover.png",DOWN:"rotateleft_pressed.png"},rotateright:{REST:"rotateright_rest.png",GROUP:"rotateright_grouphover.png",HOVER:"rotateright_hover.png",DOWN:"rotateright_pressed.png"},flip:{REST:"flip_rest.png",GROUP:"flip_grouphover.png",HOVER:"flip_hover.png",DOWN:"flip_pressed.png"},previous:{REST:"previous_rest.png",GROUP:"previous_grouphover.png",HOVER:"previous_hover.png",DOWN:"previous_pressed.png"},next:{REST:"next_rest.png",GROUP:"next_grouphover.png",HOVER:"next_hover.png",DOWN:"next_pressed.png"}},debugMode:!1,debugGridColor:["#437AB2","#1B9E77","#D95F02","#7570B3","#E7298A","#66A61E","#E6AB02","#A6761D","#666666"],silenceMultiImageWarnings:!1},delegate:function(l,h){return function(){var u=arguments;return u===void 0&&(u=[]),h.apply(l,u)}},BROWSERS:{UNKNOWN:0,IE:1,FIREFOX:2,SAFARI:3,CHROME:4,OPERA:5,EDGE:6,CHROMEEDGE:7},SUBPIXEL_ROUNDING_OCCURRENCES:{NEVER:0,ONLY_AT_REST:1,ALWAYS:2},_viewers:new Map,getViewer:function(l){return t._viewers.get(this.getElement(l))},getElement:function(l){return typeof l=="string"&&(l=document.getElementById(l)),l},getElementPosition:function(l){var h=new t.Point,u,c;for(l=t.getElement(l),u=t.getElementStyle(l).position==="fixed",c=a(l,u);c;)h.x+=l.offsetLeft,h.y+=l.offsetTop,u&&(h=h.plus(t.getPageScroll())),l=c,u=t.getElementStyle(l).position==="fixed",c=a(l,u);return h},getElementOffset:function(l){l=t.getElement(l);var h=l&&l.ownerDocument,u,c,d={top:0,left:0};return h?(u=h.documentElement,typeof l.getBoundingClientRect<"u"&&(d=l.getBoundingClientRect()),c=h===h.window?h:h.nodeType===9?h.defaultView||h.parentWindow:!1,new t.Point(d.left+(c.pageXOffset||u.scrollLeft)-(u.clientLeft||0),d.top+(c.pageYOffset||u.scrollTop)-(u.clientTop||0))):new t.Point},getElementSize:function(l){return l=t.getElement(l),new t.Point(l.clientWidth,l.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(l){return l=t.getElement(l),l.currentStyle}:function(l){return l=t.getElement(l),window.getComputedStyle(l,"")},getCssPropertyWithVendorPrefix:function(l){var h={};return t.getCssPropertyWithVendorPrefix=function(u){if(h[u]!==void 0)return h[u];var c=document.createElement("div").style,d=null;if(c[u]!==void 0)d=u;else for(var f=["Webkit","Moz","MS","O","webkit","moz","ms","o"],p=t.capitalizeFirstLetter(u),g=0;g<f.length;g++){var m=f[g]+p;if(c[m]!==void 0){d=m;break}}return h[u]=d,d},t.getCssPropertyWithVendorPrefix(l)},capitalizeFirstLetter:function(l){return l.charAt(0).toUpperCase()+l.slice(1)},positiveModulo:function(l,h){var u=l%h;return u<0&&(u+=h),u},pointInElement:function(l,h){l=t.getElement(l);var u=t.getElementOffset(l),c=t.getElementSize(l);return h.x>=u.x&&h.x<u.x+c.x&&h.y<u.y+c.y&&h.y>=u.y},getMousePosition:function(l){if(typeof l.pageX=="number")t.getMousePosition=function(h){var u=new t.Point;return u.x=h.pageX,u.y=h.pageY,u};else if(typeof l.clientX=="number")t.getMousePosition=function(h){var u=new t.Point;return u.x=h.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,u.y=h.clientY+document.body.scrollTop+document.documentElement.scrollTop,u};else throw new Error("Unknown event mouse position, no known technique.");return t.getMousePosition(l)},getPageScroll:function(){var l=document.documentElement||{},h=document.body||{};if(typeof window.pageXOffset=="number")t.getPageScroll=function(){return new t.Point(window.pageXOffset,window.pageYOffset)};else if(h.scrollLeft||h.scrollTop)t.getPageScroll=function(){return new t.Point(document.body.scrollLeft,document.body.scrollTop)};else if(l.scrollLeft||l.scrollTop)t.getPageScroll=function(){return new t.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)};else return new t.Point(0,0);return t.getPageScroll()},setPageScroll:function(l){if(typeof window.scrollTo<"u")t.setPageScroll=function(c){window.scrollTo(c.x,c.y)};else{var h=t.getPageScroll();if(h.x===l.x&&h.y===l.y)return;document.body.scrollLeft=l.x,document.body.scrollTop=l.y;var u=t.getPageScroll();if(u.x!==h.x&&u.y!==h.y){t.setPageScroll=function(c){document.body.scrollLeft=c.x,document.body.scrollTop=c.y};return}if(document.documentElement.scrollLeft=l.x,document.documentElement.scrollTop=l.y,u=t.getPageScroll(),u.x!==h.x&&u.y!==h.y){t.setPageScroll=function(c){document.documentElement.scrollLeft=c.x,document.documentElement.scrollTop=c.y};return}t.setPageScroll=function(c){}}t.setPageScroll(l)},getWindowSize:function(){var l=document.documentElement||{},h=document.body||{};if(typeof window.innerWidth=="number")t.getWindowSize=function(){return new t.Point(window.innerWidth,window.innerHeight)};else if(l.clientWidth||l.clientHeight)t.getWindowSize=function(){return new t.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else if(h.clientWidth||h.clientHeight)t.getWindowSize=function(){return new t.Point(document.body.clientWidth,document.body.clientHeight)};else throw new Error("Unknown window size, no known technique.");return t.getWindowSize()},makeCenteredNode:function(l){l=t.getElement(l);var h=[t.makeNeutralElement("div"),t.makeNeutralElement("div"),t.makeNeutralElement("div")];return t.extend(h[0].style,{display:"table",height:"100%",width:"100%"}),t.extend(h[1].style,{display:"table-row"}),t.extend(h[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),h[0].appendChild(h[1]),h[1].appendChild(h[2]),h[2].appendChild(l),h[0]},makeNeutralElement:function(l){var h=document.createElement(l),u=h.style;return u.background="transparent none",u.border="none",u.margin="0px",u.padding="0px",u.position="static",h},now:function(){return Date.now?t.now=Date.now:t.now=function(){return new Date().getTime()},t.now()},makeTransparentImage:function(l){var h=t.makeNeutralElement("img");return h.src=l,h},setElementOpacity:function(l,h,u){var c,d;l=t.getElement(l),u&&!t.Browser.alpha&&(h=Math.round(h)),t.Browser.opacity?l.style.opacity=h<1?h:"":h<1?(c=Math.round(100*h),d="alpha(opacity="+c+")",l.style.filter=d):l.style.filter=""},setElementTouchActionNone:function(l){l=t.getElement(l),typeof l.style.touchAction<"u"?l.style.touchAction="none":typeof l.style.msTouchAction<"u"&&(l.style.msTouchAction="none")},setElementPointerEvents:function(l,h){l=t.getElement(l),typeof l.style<"u"&&typeof l.style.pointerEvents<"u"&&(l.style.pointerEvents=h)},setElementPointerEventsNone:function(l){t.setElementPointerEvents(l,"none")},addClass:function(l,h){l=t.getElement(l),l.className?(" "+l.className+" ").indexOf(" "+h+" ")===-1&&(l.className+=" "+h):l.className=h},indexOf:function(l,h,u){return Array.prototype.indexOf?this.indexOf=function(c,d,f){return c.indexOf(d,f)}:this.indexOf=function(c,d,f){var p,g=f||0,m;if(!c)throw new TypeError;if(m=c.length,m===0||g>=m)return-1;for(g<0&&(g=m-Math.abs(g)),p=g;p<m;p++)if(c[p]===d)return p;return-1},this.indexOf(l,h,u)},removeClass:function(l,h){var u,c=[],d;for(l=t.getElement(l),u=l.className.split(/\s+/),d=0;d<u.length;d++)u[d]&&u[d]!==h&&c.push(u[d]);l.className=c.join(" ")},normalizeEventListenerOptions:function(l){var h;return typeof l<"u"?typeof l=="boolean"?h=t.supportsEventListenerOptions?{capture:l}:l:h=t.supportsEventListenerOptions?l:typeof l.capture<"u"?l.capture:!1:h=t.supportsEventListenerOptions?{capture:!1}:!1,h},addEvent:(function(){if(t.supportsAddEventListener)return function(l,h,u,c){c=t.normalizeEventListenerOptions(c),l=t.getElement(l),l.addEventListener(h,u,c)};if(document.documentElement.attachEvent&&document.attachEvent)return function(l,h,u){l=t.getElement(l),l.attachEvent("on"+h,u)};throw new Error("No known event model.")})(),removeEvent:(function(){if(t.supportsRemoveEventListener)return function(l,h,u,c){c=t.normalizeEventListenerOptions(c),l=t.getElement(l),l.removeEventListener(h,u,c)};if(document.documentElement.detachEvent&&document.detachEvent)return function(l,h,u){l=t.getElement(l),l.detachEvent("on"+h,u)};throw new Error("No known event model.")})(),cancelEvent:function(l){l.preventDefault()},eventIsCanceled:function(l){return l.defaultPrevented},stopEvent:function(l){l.stopPropagation()},createCallback:function(l,h){console.error("The createCallback function is deprecated and will be removed in future versions. Please use alternativeFunction instead.");var u=[],c;for(c=2;c<arguments.length;c++)u.push(arguments[c]);return function(){var d=u.concat([]),f;for(f=0;f<arguments.length;f++)d.push(arguments[f]);return h.apply(l,d)}},getUrlParameter:function(l){var h=o[l];return h||null},getUrlProtocol:function(l){var h=l.match(/^([a-z]+:)\/\//i);return h===null?window.location.protocol:h[1].toLowerCase()},createAjaxRequest:function(){if(window.XMLHttpRequest)return t.createAjaxRequest=function(){return new XMLHttpRequest},new XMLHttpRequest;throw new Error("Browser doesn't support XMLHttpRequest.")},makeAjaxRequest:function(l,h,u){var c,d,f,p;t.isPlainObject(l)&&(h=l.success,u=l.error,c=l.withCredentials,d=l.headers,f=l.responseType||null,p=l.postData||null,l=l.url);var g=t.getUrlProtocol(l),m=t.createAjaxRequest();if(!t.isFunction(h))throw new Error("makeAjaxRequest requires a success callback");m.onreadystatechange=function(){m.readyState===4&&(m.onreadystatechange=function(){},m.status>=200&&m.status<300||m.status===0&&g!=="http:"&&g!=="https:"?h(m):t.isFunction(u)?u(m):t.console.error("AJAX request returned %d: %s",m.status,l))};var v=p?"POST":"GET";try{if(m.open(v,l,!0),f&&(m.responseType=f),d)for(var _ in d)Object.prototype.hasOwnProperty.call(d,_)&&d[_]&&m.setRequestHeader(_,d[_]);c&&(m.withCredentials=!0),m.send(p)}catch(y){t.console.error("%s while making AJAX request: %s",y.name,y.message),m.onreadystatechange=function(){},t.isFunction(u)&&u(m,y)}return m},jsonp:function(l){var h,u=l.url,c=document.head||document.getElementsByTagName("head")[0]||document.documentElement,d=l.callbackName||"openseadragon"+t.now(),f=window[d],p="$1"+d+"$2",g=l.param||"callback",m=l.callback;u=u.replace(/(=)\?(&|$)|\?\?/i,p),u+=(/\?/.test(u)?"&":"?")+g+"="+d,window[d]=function(v){if(f)window[d]=f;else try{delete window[d]}catch{}m&&t.isFunction(m)&&m(v)},h=document.createElement("script"),(l.async!==void 0||l.async!==!1)&&(h.async="async"),l.scriptCharset&&(h.charset=l.scriptCharset),h.src=u,h.onload=h.onreadystatechange=function(v,_){(_||!h.readyState||/loaded|complete/.test(h.readyState))&&(h.onload=h.onreadystatechange=null,c&&h.parentNode&&c.removeChild(h),h=void 0)},c.insertBefore(h,c.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(l){if(window.DOMParser)t.parseXml=function(h){var u=null,c;return c=new DOMParser,u=c.parseFromString(h,"text/xml"),u};else throw new Error("Browser doesn't support XML DOM.");return t.parseXml(l)},parseJSON:function(l){return t.parseJSON=window.JSON.parse,t.parseJSON(l)},imageFormatSupported:function(l){return l=l||"",!!s[l.toLowerCase()]},setImageFormatsSupported:function(l){t.extend(s,l)}});var r=function(l){};t.console=window.console||{log:r,debug:r,info:r,warn:r,error:r,assert:r},t.Browser={vendor:t.BROWSERS.UNKNOWN,version:0,alpha:!0};var s={avif:!0,bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1,webp:!0},o={};(function(){var l=navigator.appVersion,h=navigator.userAgent,u;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(t.Browser.vendor=t.BROWSERS.IE,t.Browser.version=parseFloat(h.substring(h.indexOf("MSIE")+5,h.indexOf(";",h.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(h.indexOf("Edge")>=0?(t.Browser.vendor=t.BROWSERS.EDGE,t.Browser.version=parseFloat(h.substring(h.indexOf("Edge")+5))):h.indexOf("Edg")>=0?(t.Browser.vendor=t.BROWSERS.CHROMEEDGE,t.Browser.version=parseFloat(h.substring(h.indexOf("Edg")+4))):h.indexOf("Firefox")>=0?(t.Browser.vendor=t.BROWSERS.FIREFOX,t.Browser.version=parseFloat(h.substring(h.indexOf("Firefox")+8))):h.indexOf("Safari")>=0?(t.Browser.vendor=h.indexOf("Chrome")>=0?t.BROWSERS.CHROME:t.BROWSERS.SAFARI,t.Browser.version=parseFloat(h.substring(h.substring(0,h.indexOf("Safari")).lastIndexOf("/")+1,h.indexOf("Safari")))):(u=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),u.exec(h)!==null&&(t.Browser.vendor=t.BROWSERS.IE,t.Browser.version=parseFloat(RegExp.$1))));break;case"Opera":t.Browser.vendor=t.BROWSERS.OPERA,t.Browser.version=parseFloat(l);break}var c=window.location.search.substring(1),d=c.split("&"),f,p,g;for(g=0;g<d.length;g++)if(f=d[g],p=f.indexOf("="),p>0){var m=f.substring(0,p),v=f.substring(p+1);try{o[m]=decodeURIComponent(v)}catch{t.console.error("Ignoring malformed URL parameter: %s=%s",m,v)}}t.Browser.alpha=!(t.Browser.vendor===t.BROWSERS.CHROME&&t.Browser.version<2),t.Browser.opacity=!0,t.Browser.vendor===t.BROWSERS.IE&&t.console.error("Internet Explorer is not supported by OpenSeadragon")})(),(function(l){var h=l.requestAnimationFrame||l.mozRequestAnimationFrame||l.webkitRequestAnimationFrame||l.msRequestAnimationFrame,u=l.cancelAnimationFrame||l.mozCancelAnimationFrame||l.webkitCancelAnimationFrame||l.msCancelAnimationFrame;if(h&&u)t.requestAnimationFrame=function(){return h.apply(l,arguments)},t.cancelAnimationFrame=function(){return u.apply(l,arguments)};else{var c=[],d=[],f=0,p;t.requestAnimationFrame=function(g){return c.push([++f,g]),p||(p=setInterval(function(){if(c.length){var m=t.now(),v=d;for(d=c,c=v;d.length;)d.shift()[1](m)}else clearInterval(p),p=void 0},1e3/50)),f},t.cancelAnimationFrame=function(g){var m,v;for(m=0,v=c.length;m<v;m+=1)if(c[m][0]===g){c.splice(m,1);return}for(m=0,v=d.length;m<v;m+=1)if(d[m][0]===g){d.splice(m,1);return}}}})(window);function a(l,h){return h&&l!==document.body?document.body:l.offsetParent}})(e),(function(t,i){n.exports?n.exports=i():t.OpenSeadragon=i()})(_w,function(){return e}),(function(t){class i{constructor(s){s||(s=[0,0,0,0,0,0,0,0,0]),this.values=s}static makeIdentity(){return new i([1,0,0,0,1,0,0,0,1])}static makeTranslation(s,o){return new i([1,0,0,0,1,0,s,o,1])}static makeRotation(s){var o=Math.cos(s),a=Math.sin(s);return new i([o,-a,0,a,o,0,0,0,1])}static makeScaling(s,o){return new i([s,0,0,0,o,0,0,0,1])}multiply(s){let o=this.values,a=s.values;var l=o[0],h=o[1],u=o[2],c=o[3],d=o[4],f=o[5],p=o[6],g=o[7],m=o[8],v=a[0],_=a[1],y=a[2],w=a[3],R=a[4],M=a[5],C=a[6],O=a[7],N=a[8];return new i([v*l+_*c+y*p,v*h+_*d+y*g,v*u+_*f+y*m,w*l+R*c+M*p,w*h+R*d+M*g,w*u+R*f+M*m,C*l+O*c+N*p,C*h+O*d+N*g,C*u+O*f+N*m])}}t.Mat3=i})(e),(function(t){var i={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};document.exitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.fullscreenElement},i.requestFullScreen=function(r){return r.requestFullscreen().catch(function(s){t.console.error("Fullscreen request failed: ",s)})},i.exitFullScreen=function(){document.exitFullscreen().catch(function(r){t.console.error("Error while exiting fullscreen: ",r)})},i.fullScreenEventName="fullscreenchange",i.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.msFullscreenElement},i.requestFullScreen=function(r){return r.msRequestFullscreen()},i.exitFullScreen=function(){document.msExitFullscreen()},i.fullScreenEventName="MSFullscreenChange",i.fullScreenErrorEventName="MSFullscreenError"):document.webkitExitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.webkitFullscreenElement},i.requestFullScreen=function(r){return r.webkitRequestFullscreen()},i.exitFullScreen=function(){document.webkitExitFullscreen()},i.fullScreenEventName="webkitfullscreenchange",i.fullScreenErrorEventName="webkitfullscreenerror"):document.webkitCancelFullScreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement},i.requestFullScreen=function(r){return r.webkitRequestFullScreen()},i.exitFullScreen=function(){document.webkitCancelFullScreen()},i.fullScreenEventName="webkitfullscreenchange",i.fullScreenErrorEventName="webkitfullscreenerror"):document.mozCancelFullScreen&&(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.mozFullScreenElement},i.requestFullScreen=function(r){return r.mozRequestFullScreen()},i.exitFullScreen=function(){document.mozCancelFullScreen()},i.fullScreenEventName="mozfullscreenchange",i.fullScreenErrorEventName="mozfullscreenerror"),i.isFullScreen=function(){return i.getFullScreenElement()!==null},i.cancelFullScreen=function(){t.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead."),i.exitFullScreen()},t.extend(t,i)})(e),(function(t){t.EventSource=function(){this.events={},this._rejectedEventList={}},t.EventSource.prototype={addOnceHandler:function(i,r,s,o,a){var l=this;o=o||1;var h=0,u=function(c){return h++,h===o&&l.removeHandler(i,u),r(c)};return this.addHandler(i,u,s,a)},addHandler:function(i,r,s,o){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,i))return t.console.error(`Error adding handler for ${i}. ${this._rejectedEventList[i]}`),!1;var a=this.events[i];if(a||(this.events[i]=a=[]),r&&t.isFunction(r)){var l=a.length,h={handler:r,userData:s||null,priority:o||0};for(a[l]=h;l>0&&a[l-1].priority<a[l].priority;)a[l]=a[l-1],a[l-1]=h,l--}return!0},removeHandler:function(i,r){var s=this.events[i],o=[],a;if(s&&t.isArray(s)){for(a=0;a<s.length;a++)s[a].handler!==r&&o.push(s[a]);this.events[i]=o}},numberOfHandlers:function(i){var r=this.events[i];return r?r.length:0},removeAllHandlers:function(i){if(i)this.events[i]=[];else for(var r in this.events)this.events[r]=[]},getHandler:function(i){var r=this.events[i];return!r||!r.length?null:(r=r.length===1?[r[0]]:Array.apply(null,r),function(s,o){var a,l=r.length;for(a=0;a<l;a++)r[a]&&(o.eventSource=s,o.userData=r[a].userData,r[a].handler(o))})},raiseEvent:function(i,r){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,i))return t.console.error(`Error adding handler for ${i}. ${this._rejectedEventList[i]}`),!1;var s=this.getHandler(i);return s&&s(this,r||{}),!0},rejectEventHandler(i,r=""){this._rejectedEventList[i]=r},allowEventHandler(i){delete this._rejectedEventList[i]}}})(e),(function(t){var i={};t.MouseTracker=function(E){var T=arguments;t.isPlainObject(E)||(E={element:T[0],clickTimeThreshold:T[1],clickDistThreshold:T[2]}),this.hash=Math.random(),this.element=t.getElement(E.element),this.clickTimeThreshold=E.clickTimeThreshold||t.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=E.clickDistThreshold||t.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=E.dblClickTimeThreshold||t.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=E.dblClickDistThreshold||t.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=E.userData||null,this.stopDelay=E.stopDelay||50,this.preProcessEventHandler=E.preProcessEventHandler||null,this.contextMenuHandler=E.contextMenuHandler||null,this.enterHandler=E.enterHandler||null,this.leaveHandler=E.leaveHandler||null,this.exitHandler=E.exitHandler||null,this.overHandler=E.overHandler||null,this.outHandler=E.outHandler||null,this.pressHandler=E.pressHandler||null,this.nonPrimaryPressHandler=E.nonPrimaryPressHandler||null,this.releaseHandler=E.releaseHandler||null,this.nonPrimaryReleaseHandler=E.nonPrimaryReleaseHandler||null,this.moveHandler=E.moveHandler||null,this.scrollHandler=E.scrollHandler||null,this.clickHandler=E.clickHandler||null,this.dblClickHandler=E.dblClickHandler||null,this.dragHandler=E.dragHandler||null,this.dragEndHandler=E.dragEndHandler||null,this.pinchHandler=E.pinchHandler||null,this.stopHandler=E.stopHandler||null,this.keyDownHandler=E.keyDownHandler||null,this.keyUpHandler=E.keyUpHandler||null,this.keyHandler=E.keyHandler||null,this.focusHandler=E.focusHandler||null,this.blurHandler=E.blurHandler||null;var P=this;i[this.hash]={click:function(D){y(P,D)},dblclick:function(D){w(P,D)},keydown:function(D){R(P,D)},keyup:function(D){M(P,D)},keypress:function(D){C(P,D)},focus:function(D){O(P,D)},blur:function(D){N(P,D)},contextmenu:function(D){X(P,D)},wheel:function(D){q(P,D)},mousewheel:function(D){L(P,D)},DOMMouseScroll:function(D){L(P,D)},MozMousePixelScroll:function(D){L(P,D)},losecapture:function(D){I(P,D)},mouseenter:function(D){$(P,D)},mouseleave:function(D){se(P,D)},mouseover:function(D){fe(P,D)},mouseout:function(D){te(P,D)},mousedown:function(D){J(P,D)},mouseup:function(D){Y(P,D)},mousemove:function(D){ve(P,D)},touchstart:function(D){B(P,D)},touchend:function(D){j(P,D)},touchmove:function(D){U(P,D)},touchcancel:function(D){W(P,D)},gesturestart:function(D){ee(P,D)},gesturechange:function(D){z(P,D)},gotpointercapture:function(D){H(P,D)},lostpointercapture:function(D){K(P,D)},pointerenter:function(D){$(P,D)},pointerleave:function(D){se(P,D)},pointerover:function(D){fe(P,D)},pointerout:function(D){te(P,D)},pointerdown:function(D){J(P,D)},pointerup:function(D){Y(P,D)},pointermove:function(D){ve(P,D)},pointercancel:function(D){lt(P,D)},pointerupcaptured:function(D){he(P,D)},pointermovecaptured:function(D){Ce(P,D)},tracking:!1,activePointersLists:[],lastClickPos:null,dblClickTimeOut:null,pinchGPoints:[],lastPinchDist:0,currentPinchDist:0,lastPinchCenter:null,currentPinchCenter:null,sentDragEvent:!1},this.hasGestureHandlers=!!(this.pressHandler||this.nonPrimaryPressHandler||this.releaseHandler||this.nonPrimaryReleaseHandler||this.clickHandler||this.dblClickHandler||this.dragHandler||this.dragEndHandler||this.pinchHandler),this.hasScrollHandler=!!this.scrollHandler,t.MouseTracker.havePointerEvents&&t.setElementPointerEvents(this.element,"auto"),this.exitHandler&&t.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead."),E.startDisabled||this.setTracking(!0)},t.MouseTracker.prototype={destroy:function(){l(this),this.element=null,i[this.hash]=null,delete i[this.hash]},isTracking:function(){return i[this.hash].tracking},setTracking:function(E){return E?a(this):l(this),this},getActivePointersListByType:function(E){var T=i[this.hash],P,D=T?T.activePointersLists.length:0,Z;for(P=0;P<D;P++)if(T.activePointersLists[P].type===E)return T.activePointersLists[P];return Z=new t.MouseTracker.GesturePointList(E),T&&T.activePointersLists.push(Z),Z},getActivePointerCount:function(){var E=i[this.hash],T,P=E.activePointersLists.length,D=0;for(T=0;T<P;T++)D+=E.activePointersLists[T].getLength();return D},preProcessEventHandler:function(){},contextMenuHandler:function(){},enterHandler:function(){},leaveHandler:function(){},exitHandler:function(){},overHandler:function(){},outHandler:function(){},pressHandler:function(){},nonPrimaryPressHandler:function(){},releaseHandler:function(){},nonPrimaryReleaseHandler:function(){},moveHandler:function(){},scrollHandler:function(){},clickHandler:function(){},dblClickHandler:function(){},dragHandler:function(){},dragEndHandler:function(){},pinchHandler:function(){},stopHandler:function(){},keyDownHandler:function(){},keyUpHandler:function(){},keyHandler:function(){},focusHandler:function(){},blurHandler:function(){}};var r=(function(){try{return window.self!==window.top}catch{return!0}})();function s(E){try{return E.addEventListener&&E.removeEventListener}catch{return!1}}t.MouseTracker.gesturePointVelocityTracker=(function(){var E=[],T=0,P=0,D=function(Qe,Me){return Qe.hash.toString()+Me.type+Me.id.toString()},Z=function(){var Qe,Me=E.length,gi,Dt,Ds=t.now(),by,Sy,Ay;for(by=Ds-P,P=Ds,Qe=0;Qe<Me;Qe++)gi=E[Qe],Dt=gi.gPoint,Dt.direction=Math.atan2(Dt.currentPos.y-gi.lastPos.y,Dt.currentPos.x-gi.lastPos.x),Sy=gi.lastPos.distanceTo(Dt.currentPos),gi.lastPos=Dt.currentPos,Ay=1e3*Sy/(by+1),Dt.speed=.75*Ay+.25*Dt.speed},ne=function(Qe,Me){var gi=D(Qe,Me);E.push({guid:gi,gPoint:Me,lastPos:Me.currentPos}),E.length===1&&(P=t.now(),T=window.setInterval(Z,50))},Re=function(Qe,Me){var gi=D(Qe,Me),Dt,Ds=E.length;for(Dt=0;Dt<Ds;Dt++)if(E[Dt].guid===gi){E.splice(Dt,1),Ds--,Ds===0&&window.clearInterval(T);break}};return{addPoint:ne,removePoint:Re}})(),t.MouseTracker.captureElement=document,t.MouseTracker.wheelEventName="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll",t.MouseTracker.subscribeEvents=["click","dblclick","keydown","keyup","keypress","focus","blur","contextmenu",t.MouseTracker.wheelEventName],t.MouseTracker.wheelEventName==="DOMMouseScroll"&&t.MouseTracker.subscribeEvents.push("MozMousePixelScroll"),window.PointerEvent?(t.MouseTracker.havePointerEvents=!0,t.MouseTracker.subscribeEvents.push("pointerenter","pointerleave","pointerover","pointerout","pointerdown","pointerup","pointermove","pointercancel"),t.MouseTracker.havePointerCapture=(function(){var E=document.createElement("div");return t.isFunction(E.setPointerCapture)&&t.isFunction(E.releasePointerCapture)})(),t.MouseTracker.havePointerCapture&&t.MouseTracker.subscribeEvents.push("gotpointercapture","lostpointercapture")):(t.MouseTracker.havePointerEvents=!1,t.MouseTracker.subscribeEvents.push("mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","mousemove"),t.MouseTracker.mousePointerId="legacy-mouse",t.MouseTracker.havePointerCapture=(function(){var E=document.createElement("div");return t.isFunction(E.setCapture)&&t.isFunction(E.releaseCapture)})(),t.MouseTracker.havePointerCapture&&t.MouseTracker.subscribeEvents.push("losecapture"),"ontouchstart"in window&&t.MouseTracker.subscribeEvents.push("touchstart","touchend","touchmove","touchcancel"),"ongesturestart"in window&&t.MouseTracker.subscribeEvents.push("gesturestart","gesturechange")),t.MouseTracker.GesturePointList=function(E){this._gPoints=[],this.type=E,this.buttons=0,this.contacts=0,this.clicks=0,this.captureCount=0},t.MouseTracker.GesturePointList.prototype={getLength:function(){return this._gPoints.length},asArray:function(){return this._gPoints},add:function(E){return this._gPoints.push(E)},removeById:function(E){var T,P=this._gPoints.length;for(T=0;T<P;T++)if(this._gPoints[T].id===E){this._gPoints.splice(T,1);break}return this._gPoints.length},getByIndex:function(E){return E<this._gPoints.length?this._gPoints[E]:null},getById:function(E){var T,P=this._gPoints.length;for(T=0;T<P;T++)if(this._gPoints[T].id===E)return this._gPoints[T];return null},getPrimary:function(E){var T,P=this._gPoints.length;for(T=0;T<P;T++)if(this._gPoints[T].isPrimary)return this._gPoints[T];return null},addContact:function(){++this.contacts,this.contacts>1&&(this.type==="mouse"||this.type==="pen")&&(t.console.warn("GesturePointList.addContact() Implausible contacts value"),this.contacts=1)},removeContact:function(){--this.contacts,this.contacts<0&&(this.contacts=0)}};function o(E){var T=i[E.hash],P,D,Z,ne,Re,Qe=T.activePointersLists.length;for(P=0;P<Qe;P++)if(Z=T.activePointersLists[P],Z.getLength()>0){for(Re=[],ne=Z.asArray(),D=0;D<ne.length;D++)Re.push(ne[D]);for(D=0;D<Re.length;D++)Ae(E,Z,Re[D])}for(P=0;P<Qe;P++)T.activePointersLists.pop();T.sentDragEvent=!1}function a(E){var T=i[E.hash],P,D;if(!T.tracking){for(D=0;D<t.MouseTracker.subscribeEvents.length;D++)P=t.MouseTracker.subscribeEvents[D],t.addEvent(E.element,P,T[P],P===t.MouseTracker.wheelEventName?{passive:!1,capture:!1}:!1);o(E),T.tracking=!0}}function l(E){var T=i[E.hash],P,D;if(T.tracking){for(D=0;D<t.MouseTracker.subscribeEvents.length;D++)P=t.MouseTracker.subscribeEvents[D],t.removeEvent(E.element,P,T[P],!1);o(E),T.tracking=!1}}function h(E,T){var P=i[E.hash];if(T==="pointerevent")return{upName:"pointerup",upHandler:P.pointerupcaptured,moveName:"pointermove",moveHandler:P.pointermovecaptured};if(T==="mouse")return{upName:"pointerup",upHandler:P.pointerupcaptured,moveName:"pointermove",moveHandler:P.pointermovecaptured};if(T==="touch")return{upName:"touchend",upHandler:P.touchendcaptured,moveName:"touchmove",moveHandler:P.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function u(E,T){var P;if(t.MouseTracker.havePointerCapture)if(t.MouseTracker.havePointerEvents)try{E.element.setPointerCapture(T.id)}catch{t.console.warn("setPointerCapture() called on invalid pointer ID");return}else E.element.setCapture(!0);else P=h(E,t.MouseTracker.havePointerEvents?"pointerevent":T.type),r&&s(window.top)&&t.addEvent(window.top,P.upName,P.upHandler,!0),t.addEvent(t.MouseTracker.captureElement,P.upName,P.upHandler,!0),t.addEvent(t.MouseTracker.captureElement,P.moveName,P.moveHandler,!0);k(E,T,!0)}function c(E,T){var P,D,Z;if(t.MouseTracker.havePointerCapture)if(t.MouseTracker.havePointerEvents){if(D=E.getActivePointersListByType(T.type),Z=D.getById(T.id),!Z||!Z.captured)return;try{E.element.releasePointerCapture(T.id)}catch{}}else E.element.releaseCapture();else P=h(E,t.MouseTracker.havePointerEvents?"pointerevent":T.type),r&&s(window.top)&&t.removeEvent(window.top,P.upName,P.upHandler,!0),t.removeEvent(t.MouseTracker.captureElement,P.moveName,P.moveHandler,!0),t.removeEvent(t.MouseTracker.captureElement,P.upName,P.upHandler,!0);k(E,T,!1)}function d(E){return t.MouseTracker.havePointerEvents?E.pointerId:t.MouseTracker.mousePointerId}function f(E){return t.MouseTracker.havePointerEvents&&E.pointerType?E.pointerType:"mouse"}function p(E){return t.MouseTracker.havePointerEvents?E.isPrimary:!0}function g(E){return t.getMousePosition(E)}function m(E,T){return v(g(E),T)}function v(E,T){var P=t.getElementOffset(T);return E.minus(P)}function _(E,T){return new t.Point((E.x+T.x)/2,(E.y+T.y)/2)}function y(E,T){var P={originalEvent:T,eventType:"click",pointerType:"mouse",isEmulated:!1};A(E,P),P.preventDefault&&!P.defaultPrevented&&t.cancelEvent(T),P.stopPropagation&&t.stopEvent(T)}function w(E,T){var P={originalEvent:T,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};A(E,P),P.preventDefault&&!P.defaultPrevented&&t.cancelEvent(T),P.stopPropagation&&t.stopEvent(T)}function R(E,T){var P=null,D={originalEvent:T,eventType:"keydown",pointerType:"",isEmulated:!1};A(E,D),E.keyDownHandler&&!D.preventGesture&&!D.defaultPrevented&&(P={eventSource:E,keyCode:T.keyCode?T.keyCode:T.charCode,ctrl:T.ctrlKey,shift:T.shiftKey,alt:T.altKey,meta:T.metaKey,originalEvent:T,preventDefault:D.preventDefault||D.defaultPrevented,userData:E.userData},E.keyDownHandler(P)),(P&&P.preventDefault||D.preventDefault&&!D.defaultPrevented)&&t.cancelEvent(T),D.stopPropagation&&t.stopEvent(T)}function M(E,T){var P=null,D={originalEvent:T,eventType:"keyup",pointerType:"",isEmulated:!1};A(E,D),E.keyUpHandler&&!D.preventGesture&&!D.defaultPrevented&&(P={eventSource:E,keyCode:T.keyCode?T.keyCode:T.charCode,ctrl:T.ctrlKey,shift:T.shiftKey,alt:T.altKey,meta:T.metaKey,originalEvent:T,preventDefault:D.preventDefault||D.defaultPrevented,userData:E.userData},E.keyUpHandler(P)),(P&&P.preventDefault||D.preventDefault&&!D.defaultPrevented)&&t.cancelEvent(T),D.stopPropagation&&t.stopEvent(T)}function C(E,T){var P=null,D={originalEvent:T,eventType:"keypress",pointerType:"",isEmulated:!1};A(E,D),E.keyHandler&&!D.preventGesture&&!D.defaultPrevented&&(P={eventSource:E,keyCode:T.keyCode?T.keyCode:T.charCode,ctrl:T.ctrlKey,shift:T.shiftKey,alt:T.altKey,meta:T.metaKey,originalEvent:T,preventDefault:D.preventDefault||D.defaultPrevented,userData:E.userData},E.keyHandler(P)),(P&&P.preventDefault||D.preventDefault&&!D.defaultPrevented)&&t.cancelEvent(T),D.stopPropagation&&t.stopEvent(T)}function O(E,T){var P={originalEvent:T,eventType:"focus",pointerType:"",isEmulated:!1};A(E,P),E.focusHandler&&!P.preventGesture&&E.focusHandler({eventSource:E,originalEvent:T,userData:E.userData})}function N(E,T){var P={originalEvent:T,eventType:"blur",pointerType:"",isEmulated:!1};A(E,P),E.blurHandler&&!P.preventGesture&&E.blurHandler({eventSource:E,originalEvent:T,userData:E.userData})}function X(E,T){var P=null,D={originalEvent:T,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};A(E,D),E.contextMenuHandler&&!D.preventGesture&&!D.defaultPrevented&&(P={eventSource:E,position:v(g(T),E.element),originalEvent:D.originalEvent,preventDefault:D.preventDefault||D.defaultPrevented,userData:E.userData},E.contextMenuHandler(P)),(P&&P.preventDefault||D.preventDefault&&!D.defaultPrevented)&&t.cancelEvent(T),D.stopPropagation&&t.stopEvent(T)}function q(E,T){S(E,T,T)}function L(E,T){var P={target:T.target||T.srcElement,type:"wheel",shiftKey:T.shiftKey||!1,clientX:T.clientX,clientY:T.clientY,pageX:T.pageX?T.pageX:T.clientX,pageY:T.pageY?T.pageY:T.clientY,deltaMode:T.type==="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0};t.MouseTracker.wheelEventName==="mousewheel"?P.deltaY=-T.wheelDelta/t.DEFAULT_SETTINGS.pixelsPerWheelLine:P.deltaY=T.detail,S(E,P,T)}function S(E,T,P){var D=0,Z,ne=null;D=T.deltaY?T.deltaY<0?1:-1:0,Z={originalEvent:T,eventType:"wheel",pointerType:"mouse",isEmulated:T!==P},A(E,Z),E.scrollHandler&&!Z.preventGesture&&!Z.defaultPrevented&&(ne={eventSource:E,pointerType:"mouse",position:m(T,E.element),scroll:D,shift:T.shiftKey,isTouchEvent:!1,originalEvent:P,preventDefault:Z.preventDefault||Z.defaultPrevented,userData:E.userData},E.scrollHandler(ne)),Z.stopPropagation&&t.stopEvent(P),(ne&&ne.preventDefault||Z.preventDefault&&!Z.defaultPrevented)&&t.cancelEvent(P)}function I(E,T){var P={id:t.MouseTracker.mousePointerId,type:"mouse"},D={originalEvent:T,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};A(E,D),T.target===E.element&&k(E,P,!1),D.stopPropagation&&t.stopEvent(T)}function B(E,T){var P,D,Z=T.changedTouches.length,ne,Re=E.getActivePointersListByType("touch");P=t.now(),Re.getLength()>T.touches.length-Z&&t.console.warn("Tracked touch contact count doesn't match event.touches.length");var Qe={originalEvent:T,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(A(E,Qe),D=0;D<Z;D++)ne={id:T.changedTouches[D].identifier,type:"touch",isPrimary:Re.getLength()===0,currentPos:g(T.changedTouches[D]),currentTime:P},G(E,Qe,ne),xe(E,Qe,ne,0),k(E,ne,!0);Qe.preventDefault&&!Qe.defaultPrevented&&t.cancelEvent(T),Qe.stopPropagation&&t.stopEvent(T)}function j(E,T){var P,D,Z=T.changedTouches.length,ne;P=t.now();var Re={originalEvent:T,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(A(E,Re),D=0;D<Z;D++)ne={id:T.changedTouches[D].identifier,type:"touch",currentPos:g(T.changedTouches[D]),currentTime:P},Be(E,Re,ne,0),k(E,ne,!1),V(E,Re,ne);Re.preventDefault&&!Re.defaultPrevented&&t.cancelEvent(T),Re.stopPropagation&&t.stopEvent(T)}function U(E,T){var P,D,Z=T.changedTouches.length,ne;P=t.now();var Re={originalEvent:T,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(A(E,Re),D=0;D<Z;D++)ne={id:T.changedTouches[D].identifier,type:"touch",currentPos:g(T.changedTouches[D]),currentTime:P},tt(E,Re,ne);Re.preventDefault&&!Re.defaultPrevented&&t.cancelEvent(T),Re.stopPropagation&&t.stopEvent(T)}function W(E,T){var P=T.changedTouches.length,D,Z,ne={originalEvent:T,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(A(E,ne),D=0;D<P;D++)Z={id:T.changedTouches[D].identifier,type:"touch"},ye(E,ne,Z);ne.stopPropagation&&t.stopEvent(T)}function ee(E,T){return t.eventIsCanceled(T)||T.preventDefault(),!1}function z(E,T){return t.eventIsCanceled(T)||T.preventDefault(),!1}function H(E,T){var P={originalEvent:T,eventType:"gotpointercapture",pointerType:f(T),isEmulated:!1};A(E,P),T.target===E.element&&k(E,{id:T.pointerId,type:f(T)},!0),P.stopPropagation&&t.stopEvent(T)}function K(E,T){var P={originalEvent:T,eventType:"lostpointercapture",pointerType:f(T),isEmulated:!1};A(E,P),T.target===E.element&&k(E,{id:T.pointerId,type:f(T)},!1),P.stopPropagation&&t.stopEvent(T)}function $(E,T){var P={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},D={originalEvent:T,eventType:"pointerenter",pointerType:P.type,isEmulated:!1};A(E,D),G(E,D,P)}function se(E,T){var P={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},D={originalEvent:T,eventType:"pointerleave",pointerType:P.type,isEmulated:!1};A(E,D),V(E,D,P)}function fe(E,T){var P={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},D={originalEvent:T,eventType:"pointerover",pointerType:P.type,isEmulated:!1};A(E,D),oe(E,D,P),D.preventDefault&&!D.defaultPrevented&&t.cancelEvent(T),D.stopPropagation&&t.stopEvent(T)}function te(E,T){var P={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},D={originalEvent:T,eventType:"pointerout",pointerType:P.type,isEmulated:!1};A(E,D),Q(E,D,P),D.preventDefault&&!D.defaultPrevented&&t.cancelEvent(T),D.stopPropagation&&t.stopEvent(T)}function J(E,T){var P={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},D=t.MouseTracker.havePointerEvents&&P.type==="touch",Z={originalEvent:T,eventType:"pointerdown",pointerType:P.type,isEmulated:!1};A(E,Z),xe(E,Z,P,T.button),Z.preventDefault&&!Z.defaultPrevented&&t.cancelEvent(T),Z.stopPropagation&&t.stopEvent(T),Z.shouldCapture&&(D?k(E,P,!0):u(E,P))}function Y(E,T){le(E,T)}function he(E,T){var P=E.getActivePointersListByType(f(T));P.getById(T.pointerId)&&le(E,T),t.stopEvent(T)}function le(E,T){var P;P={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()};var D={originalEvent:T,eventType:"pointerup",pointerType:P.type,isEmulated:!1};A(E,D),Be(E,D,P,T.button),D.preventDefault&&!D.defaultPrevented&&t.cancelEvent(T),D.stopPropagation&&t.stopEvent(T),D.shouldReleaseCapture&&(T.target===E.element?c(E,P):k(E,P,!1))}function ve(E,T){ze(E,T)}function Ce(E,T){var P=E.getActivePointersListByType(f(T));P.getById(T.pointerId)&&ze(E,T),t.stopEvent(T)}function ze(E,T){var P={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},D={originalEvent:T,eventType:"pointermove",pointerType:P.type,isEmulated:!1};A(E,D),tt(E,D,P),D.preventDefault&&!D.defaultPrevented&&t.cancelEvent(T),D.stopPropagation&&t.stopEvent(T)}function lt(E,T){var P={id:T.pointerId,type:f(T)},D={originalEvent:T,eventType:"pointercancel",pointerType:P.type,isEmulated:!1};A(E,D),ye(E,D,P),D.stopPropagation&&t.stopEvent(T)}function me(E,T){return T.speed=0,T.direction=0,T.contactPos=T.currentPos,T.contactTime=T.currentTime,T.lastPos=T.currentPos,T.lastTime=T.currentTime,E.add(T)}function Ae(E,T,P){var D,Z=T.getById(P.id);return Z?(Z.captured&&(t.console.warn("stopTrackingPointer() called on captured pointer"),c(E,Z)),T.removeContact(),D=T.removeById(P.id)):D=T.getLength(),D}function x(E,T){switch(T.eventType){case"pointermove":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!1,T.preventGesture=!E.hasGestureHandlers,T.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!1,T.preventGesture=!1,T.stopPropagation=!1;break;case"pointerdown":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!1,T.preventGesture=!E.hasGestureHandlers,T.stopPropagation=!1;break;case"pointerup":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!1,T.preventGesture=!E.hasGestureHandlers,T.stopPropagation=!1;break;case"wheel":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!1,T.preventGesture=!E.hasScrollHandler,T.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":T.isStoppable=!0,T.isCancelable=!1,T.preventDefault=!1,T.preventGesture=!1,T.stopPropagation=!1;break;case"click":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!!E.clickHandler,T.preventGesture=!1,T.stopPropagation=!1;break;case"dblclick":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!!E.dblClickHandler,T.preventGesture=!1,T.stopPropagation=!1;break;case"focus":case"blur":case"pointerenter":case"pointerleave":default:T.isStoppable=!1,T.isCancelable=!1,T.preventDefault=!1,T.preventGesture=!1,T.stopPropagation=!1;break}}function A(E,T){T.eventSource=E,T.eventPhase=T.originalEvent&&typeof T.originalEvent.eventPhase<"u"?T.originalEvent.eventPhase:0,T.defaultPrevented=t.eventIsCanceled(T.originalEvent),T.shouldCapture=!1,T.shouldReleaseCapture=!1,T.userData=E.userData,x(E,T),E.preProcessEventHandler&&E.preProcessEventHandler(T)}function k(E,T,P){var D=E.getActivePointersListByType(T.type),Z=D.getById(T.id);Z?P&&!Z.captured?(Z.captured=!0,D.captureCount++):!P&&Z.captured&&(Z.captured=!1,D.captureCount--,D.captureCount<0&&(D.captureCount=0,t.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):t.console.warn("updatePointerCaptured() called on untracked pointer")}function G(E,T,P){var D=E.getActivePointersListByType(P.type),Z;Z=D.getById(P.id),Z?(Z.insideElement=!0,Z.lastPos=Z.currentPos,Z.lastTime=Z.currentTime,Z.currentPos=P.currentPos,Z.currentTime=P.currentTime,P=Z):(P.captured=!1,P.insideElementPressed=!1,P.insideElement=!0,me(D,P)),E.enterHandler&&E.enterHandler({eventSource:E,pointerType:P.type,position:v(P.currentPos,E.element),buttons:D.buttons,pointers:E.getActivePointerCount(),insideElementPressed:P.insideElementPressed,buttonDownAny:D.buttons!==0,isTouchEvent:P.type==="touch",originalEvent:T.originalEvent,userData:E.userData})}function V(E,T,P){var D=E.getActivePointersListByType(P.type),Z,ne;Z=D.getById(P.id),Z?(Z.captured?(Z.insideElement=!1,Z.lastPos=Z.currentPos,Z.lastTime=Z.currentTime,Z.currentPos=P.currentPos,Z.currentTime=P.currentTime):Ae(E,D,Z),P=Z):(P.captured=!1,P.insideElementPressed=!1),(E.leaveHandler||E.exitHandler)&&(ne={eventSource:E,pointerType:P.type,position:P.currentPos&&v(P.currentPos,E.element),buttons:D.buttons,pointers:E.getActivePointerCount(),insideElementPressed:P.insideElementPressed,buttonDownAny:D.buttons!==0,isTouchEvent:P.type==="touch",originalEvent:T.originalEvent,userData:E.userData},E.leaveHandler&&E.leaveHandler(ne),E.exitHandler&&E.exitHandler(ne))}function oe(E,T,P){var D,Z;D=E.getActivePointersListByType(P.type),Z=D.getById(P.id),Z?P=Z:(P.captured=!1,P.insideElementPressed=!1),E.overHandler&&E.overHandler({eventSource:E,pointerType:P.type,position:v(P.currentPos,E.element),buttons:D.buttons,pointers:E.getActivePointerCount(),insideElementPressed:P.insideElementPressed,buttonDownAny:D.buttons!==0,isTouchEvent:P.type==="touch",originalEvent:T.originalEvent,userData:E.userData})}function Q(E,T,P){var D,Z;D=E.getActivePointersListByType(P.type),Z=D.getById(P.id),Z?P=Z:(P.captured=!1,P.insideElementPressed=!1),E.outHandler&&E.outHandler({eventSource:E,pointerType:P.type,position:P.currentPos&&v(P.currentPos,E.element),buttons:D.buttons,pointers:E.getActivePointerCount(),insideElementPressed:P.insideElementPressed,buttonDownAny:D.buttons!==0,isTouchEvent:P.type==="touch",originalEvent:T.originalEvent,userData:E.userData})}function xe(E,T,P,D){var Z=i[E.hash],ne=E.getActivePointersListByType(P.type),Re;if(typeof T.originalEvent.buttons<"u"?ne.buttons=T.originalEvent.buttons:D===0?ne.buttons|=1:D===1?ne.buttons|=4:D===2?ne.buttons|=2:D===3?ne.buttons|=8:D===4?ne.buttons|=16:D===5&&(ne.buttons|=32),D!==0){T.shouldCapture=!1,T.shouldReleaseCapture=!1,E.nonPrimaryPressHandler&&!T.preventGesture&&!T.defaultPrevented&&(T.preventDefault=!0,E.nonPrimaryPressHandler({eventSource:E,pointerType:P.type,position:v(P.currentPos,E.element),button:D,buttons:ne.buttons,isTouchEvent:P.type==="touch",originalEvent:T.originalEvent,userData:E.userData}));return}Re=ne.getById(P.id),Re?(Re.insideElementPressed=!0,Re.insideElement=!0,Re.originalTarget=T.originalEvent.target,Re.contactPos=P.currentPos,Re.contactTime=P.currentTime,Re.lastPos=Re.currentPos,Re.lastTime=Re.currentTime,Re.currentPos=P.currentPos,Re.currentTime=P.currentTime,P=Re):(P.captured=!1,P.insideElementPressed=!0,P.insideElement=!0,P.originalTarget=T.originalEvent.target,me(ne,P)),ne.addContact(),!T.preventGesture&&!T.defaultPrevented?(T.shouldCapture=!0,T.shouldReleaseCapture=!1,T.preventDefault=!0,(E.dragHandler||E.dragEndHandler||E.pinchHandler)&&t.MouseTracker.gesturePointVelocityTracker.addPoint(E,P),ne.contacts===1?E.pressHandler&&!T.preventGesture&&E.pressHandler({eventSource:E,pointerType:P.type,position:v(P.contactPos,E.element),buttons:ne.buttons,isTouchEvent:P.type==="touch",originalEvent:T.originalEvent,userData:E.userData}):ne.contacts===2&&E.pinchHandler&&P.type==="touch"&&(Z.pinchGPoints=ne.asArray(),Z.lastPinchDist=Z.currentPinchDist=Z.pinchGPoints[0].currentPos.distanceTo(Z.pinchGPoints[1].currentPos),Z.lastPinchCenter=Z.currentPinchCenter=_(Z.pinchGPoints[0].currentPos,Z.pinchGPoints[1].currentPos))):(T.shouldCapture=!1,T.shouldReleaseCapture=!1)}function Be(E,T,P,D){var Z=i[E.hash],ne=E.getActivePointersListByType(P.type),Re,Qe,Me,gi=!1,Dt;if(typeof T.originalEvent.buttons<"u"?ne.buttons=T.originalEvent.buttons:D===0?ne.buttons^=-2:D===1?ne.buttons^=-5:D===2?ne.buttons^=-3:D===3?ne.buttons^=-9:D===4?ne.buttons^=-17:D===5&&(ne.buttons^=-33),T.shouldCapture=!1,D!==0){T.shouldReleaseCapture=!1,E.nonPrimaryReleaseHandler&&!T.preventGesture&&!T.defaultPrevented&&(T.preventDefault=!0,E.nonPrimaryReleaseHandler({eventSource:E,pointerType:P.type,position:v(P.currentPos,E.element),button:D,buttons:ne.buttons,isTouchEvent:P.type==="touch",originalEvent:T.originalEvent,userData:E.userData}));return}Me=ne.getById(P.id),Me?(ne.removeContact(),Me.captured&&(gi=!0),Me.lastPos=Me.currentPos,Me.lastTime=Me.currentTime,Me.currentPos=P.currentPos,Me.currentTime=P.currentTime,Me.insideElement||Ae(E,ne,Me),Re=Me.currentPos,Qe=Me.currentTime):(P.captured=!1,P.insideElementPressed=!1,P.insideElement=!0,me(ne,P),Me=P),!T.preventGesture&&!T.defaultPrevented&&(gi?(T.shouldReleaseCapture=!0,T.preventDefault=!0,(E.dragHandler||E.dragEndHandler||E.pinchHandler)&&t.MouseTracker.gesturePointVelocityTracker.removePoint(E,Me),ne.contacts===0?(E.releaseHandler&&Re&&E.releaseHandler({eventSource:E,pointerType:Me.type,position:v(Re,E.element),buttons:ne.buttons,insideElementPressed:Me.insideElementPressed,insideElementReleased:Me.insideElement,isTouchEvent:Me.type==="touch",originalEvent:T.originalEvent,userData:E.userData}),E.dragEndHandler&&Z.sentDragEvent&&E.dragEndHandler({eventSource:E,pointerType:Me.type,position:v(Me.currentPos,E.element),speed:Me.speed,direction:Me.direction,shift:T.originalEvent.shiftKey,isTouchEvent:Me.type==="touch",originalEvent:T.originalEvent,userData:E.userData}),Z.sentDragEvent=!1,(E.clickHandler||E.dblClickHandler)&&Me.insideElement&&(Dt=Qe-Me.contactTime<=E.clickTimeThreshold&&Me.contactPos.distanceTo(Re)<=E.clickDistThreshold,E.clickHandler&&E.clickHandler({eventSource:E,pointerType:Me.type,position:v(Me.currentPos,E.element),quick:Dt,shift:T.originalEvent.shiftKey,isTouchEvent:Me.type==="touch",originalEvent:T.originalEvent,originalTarget:Me.originalTarget,userData:E.userData}),E.dblClickHandler&&Dt&&(ne.clicks++,ne.clicks===1?(Z.lastClickPos=Re,Z.dblClickTimeOut=setTimeout(function(){ne.clicks=0},E.dblClickTimeThreshold)):ne.clicks===2&&(clearTimeout(Z.dblClickTimeOut),ne.clicks=0,Z.lastClickPos.distanceTo(Re)<=E.dblClickDistThreshold&&E.dblClickHandler({eventSource:E,pointerType:Me.type,position:v(Me.currentPos,E.element),shift:T.originalEvent.shiftKey,isTouchEvent:Me.type==="touch",originalEvent:T.originalEvent,userData:E.userData}),Z.lastClickPos=null)))):ne.contacts===2&&E.pinchHandler&&Me.type==="touch"&&(Z.pinchGPoints=ne.asArray(),Z.lastPinchDist=Z.currentPinchDist=Z.pinchGPoints[0].currentPos.distanceTo(Z.pinchGPoints[1].currentPos),Z.lastPinchCenter=Z.currentPinchCenter=_(Z.pinchGPoints[0].currentPos,Z.pinchGPoints[1].currentPos))):(T.shouldReleaseCapture=!1,E.releaseHandler&&Re&&(E.releaseHandler({eventSource:E,pointerType:Me.type,position:v(Re,E.element),buttons:ne.buttons,insideElementPressed:Me.insideElementPressed,insideElementReleased:Me.insideElement,isTouchEvent:Me.type==="touch",originalEvent:T.originalEvent,userData:E.userData}),T.preventDefault=!0)))}function tt(E,T,P){var D=i[E.hash],Z=E.getActivePointersListByType(P.type),ne,Re,Qe;if(typeof T.originalEvent.buttons<"u"&&(Z.buttons=T.originalEvent.buttons),ne=Z.getById(P.id),ne)ne.lastPos=ne.currentPos,ne.lastTime=ne.currentTime,ne.currentPos=P.currentPos,ne.currentTime=P.currentTime;else return;T.shouldCapture=!1,T.shouldReleaseCapture=!1,E.stopHandler&&P.type==="mouse"&&(clearTimeout(E.stopTimeOut),E.stopTimeOut=setTimeout(function(){qe(E,T.originalEvent,P.type)},E.stopDelay)),Z.contacts===0?E.moveHandler&&E.moveHandler({eventSource:E,pointerType:P.type,position:v(P.currentPos,E.element),buttons:Z.buttons,isTouchEvent:P.type==="touch",originalEvent:T.originalEvent,userData:E.userData}):Z.contacts===1?(E.moveHandler&&(ne=Z.asArray()[0],E.moveHandler({eventSource:E,pointerType:ne.type,position:v(ne.currentPos,E.element),buttons:Z.buttons,isTouchEvent:ne.type==="touch",originalEvent:T.originalEvent,userData:E.userData})),E.dragHandler&&!T.preventGesture&&!T.defaultPrevented&&(ne=Z.asArray()[0],Qe=ne.currentPos.minus(ne.lastPos),E.dragHandler({eventSource:E,pointerType:ne.type,position:v(ne.currentPos,E.element),buttons:Z.buttons,delta:Qe,speed:ne.speed,direction:ne.direction,shift:T.originalEvent.shiftKey,isTouchEvent:ne.type==="touch",originalEvent:T.originalEvent,userData:E.userData}),T.preventDefault=!0,D.sentDragEvent=!0)):Z.contacts===2&&(E.moveHandler&&(Re=Z.asArray(),E.moveHandler({eventSource:E,pointerType:Re[0].type,position:v(_(Re[0].currentPos,Re[1].currentPos),E.element),buttons:Z.buttons,isTouchEvent:Re[0].type==="touch",originalEvent:T.originalEvent,userData:E.userData})),E.pinchHandler&&P.type==="touch"&&!T.preventGesture&&!T.defaultPrevented&&(Qe=D.pinchGPoints[0].currentPos.distanceTo(D.pinchGPoints[1].currentPos),Qe!==D.currentPinchDist&&(D.lastPinchDist=D.currentPinchDist,D.currentPinchDist=Qe,D.lastPinchCenter=D.currentPinchCenter,D.currentPinchCenter=_(D.pinchGPoints[0].currentPos,D.pinchGPoints[1].currentPos),E.pinchHandler({eventSource:E,pointerType:"touch",gesturePoints:D.pinchGPoints,lastCenter:v(D.lastPinchCenter,E.element),center:v(D.currentPinchCenter,E.element),lastDistance:D.lastPinchDist,distance:D.currentPinchDist,shift:T.originalEvent.shiftKey,originalEvent:T.originalEvent,userData:E.userData}),T.preventDefault=!0)))}function ye(E,T,P){var D=E.getActivePointersListByType(P.type),Z;Z=D.getById(P.id),Z&&Ae(E,D,Z)}function qe(E,T,P){E.stopHandler&&E.stopHandler({eventSource:E,pointerType:P,position:m(T,E.element),buttons:E.getActivePointersListByType(P).buttons,isTouchEvent:P==="touch",originalEvent:T,userData:E.userData})}})(e),(function(t){t.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},t.Control=function(i,r,s){var o=i.parentNode;typeof r=="number"&&(t.console.error("Passing an anchor directly into the OpenSeadragon.Control constructor is deprecated; please use an options object instead. Support for this deprecated variant is scheduled for removal in December 2013"),r={anchor:r}),r.attachToViewer=typeof r.attachToViewer>"u"?!0:r.attachToViewer,this.autoFade=typeof r.autoFade>"u"?!0:r.autoFade,this.element=i,this.anchor=r.anchor,this.container=s,this.anchor===t.ControlAnchor.ABSOLUTE?(this.wrapper=t.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top=typeof r.top=="number"?r.top+"px":r.top,this.wrapper.style.left=typeof r.left=="number"?r.left+"px":r.left,this.wrapper.style.height=typeof r.height=="number"?r.height+"px":r.height,this.wrapper.style.width=typeof r.width=="number"?r.width+"px":r.width,this.wrapper.style.margin="0px",this.wrapper.style.padding="0px",this.element.style.position="relative",this.element.style.top="0px",this.element.style.left="0px",this.element.style.height="100%",this.element.style.width="100%"):(this.wrapper=t.makeNeutralElement("div"),this.wrapper.style.display="inline-block",this.anchor===t.ControlAnchor.NONE&&(this.wrapper.style.width=this.wrapper.style.height="100%")),this.wrapper.appendChild(this.element),r.attachToViewer?this.anchor===t.ControlAnchor.TOP_RIGHT||this.anchor===t.ControlAnchor.BOTTOM_RIGHT?this.container.insertBefore(this.wrapper,this.container.firstChild):this.container.appendChild(this.wrapper):o.appendChild(this.wrapper)},t.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element),this.anchor!==t.ControlAnchor.NONE&&this.container.removeChild(this.wrapper)},isVisible:function(){return this.wrapper.style.display!=="none"},setVisible:function(i){this.wrapper.style.display=i?this.anchor===t.ControlAnchor.ABSOLUTE?"block":"inline-block":"none"},setOpacity:function(i){t.setElementOpacity(this.wrapper,i,!0)}}})(e),(function(t){t.ControlDock=function(r){var s=["topleft","topright","bottomright","bottomleft"],o,a;for(t.extend(!0,this,{id:"controldock-"+t.now()+"-"+Math.floor(Math.random()*1e6),container:t.makeNeutralElement("div"),controls:[]},r),this.container.onsubmit=function(){return!1},this.element&&(this.element=t.getElement(this.element),this.element.appendChild(this.container),t.getElementStyle(this.element).position==="static"&&(this.element.style.position="relative"),this.container.style.width="100%",this.container.style.height="100%"),a=0;a<s.length;a++)o=s[a],this.controls[o]=t.makeNeutralElement("div"),this.controls[o].style.position="absolute",o.match("left")&&(this.controls[o].style.left="0px"),o.match("right")&&(this.controls[o].style.right="0px"),o.match("top")&&(this.controls[o].style.top="0px"),o.match("bottom")&&(this.controls[o].style.bottom="0px");this.container.appendChild(this.controls.topleft),this.container.appendChild(this.controls.topright),this.container.appendChild(this.controls.bottomright),this.container.appendChild(this.controls.bottomleft)},t.ControlDock.prototype={addControl:function(r,s){r=t.getElement(r);var o=null;if(!(i(this,r)>=0)){switch(s.anchor){case t.ControlAnchor.TOP_RIGHT:o=this.controls.topright,r.style.position="relative",r.style.paddingRight="0px",r.style.paddingTop="0px";break;case t.ControlAnchor.BOTTOM_RIGHT:o=this.controls.bottomright,r.style.position="relative",r.style.paddingRight="0px",r.style.paddingBottom="0px";break;case t.ControlAnchor.BOTTOM_LEFT:o=this.controls.bottomleft,r.style.position="relative",r.style.paddingLeft="0px",r.style.paddingBottom="0px";break;case t.ControlAnchor.TOP_LEFT:o=this.controls.topleft,r.style.position="relative",r.style.paddingLeft="0px",r.style.paddingTop="0px";break;case t.ControlAnchor.ABSOLUTE:o=this.container,r.style.margin="0px",r.style.padding="0px";break;default:case t.ControlAnchor.NONE:o=this.container,r.style.margin="0px",r.style.padding="0px";break}this.controls.push(new t.Control(r,s,o)),r.style.display="inline-block"}},removeControl:function(r){r=t.getElement(r);var s=i(this,r);return s>=0&&(this.controls[s].destroy(),this.controls.splice(s,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var r;for(r=this.controls.length-1;r>=0;r--)if(this.controls[r].isVisible())return!0;return!1},setControlsEnabled:function(r){var s;for(s=this.controls.length-1;s>=0;s--)this.controls[s].setVisible(r);return this}};function i(r,s){var o=r.controls,a;for(a=o.length-1;a>=0;a--)if(o[a].element===s)return a;return-1}})(e),(function(t){t.Placement=t.freezeObject({CENTER:0,TOP_LEFT:1,TOP:2,TOP_RIGHT:3,RIGHT:4,BOTTOM_RIGHT:5,BOTTOM:6,BOTTOM_LEFT:7,LEFT:8,properties:{0:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1},1:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},2:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},3:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!0,isVerticallyCentered:!1,isBottom:!1},4:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!0,isBottom:!1},5:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!1,isBottom:!0},6:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},7:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},8:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1}}})})(e),(function(t){var i={},r=1;t.Viewer=function(x){var A=arguments,k=this,G;t.isPlainObject(x)||(x={id:A[0],xmlPath:A.length>1?A[1]:void 0,prefixUrl:A.length>2?A[2]:void 0,controls:A.length>3?A[3]:void 0,overlays:A.length>4?A[4]:void 0}),x.config&&(t.extend(!0,x,x.config),delete x.config);let V=["useCanvas"];if(x.drawerOptions=Object.assign({},V.reduce((Q,xe)=>(Q[xe]=x[xe],delete x[xe],Q),{}),x.drawerOptions),t.extend(!0,this,{id:x.id,hash:x.hash||r++,initialPage:0,element:null,container:null,canvas:null,overlays:[],overlaysContainer:null,previousBody:[],customControls:[],source:null,drawer:null,world:null,viewport:null,navigator:null,collectionViewport:null,collectionDrawer:null,navImages:null,buttonGroup:null,profiler:null},t.DEFAULT_SETTINGS,x),typeof this.hash>"u")throw new Error("A hash must be defined, either by specifying options.id or options.hash.");typeof i[this.hash]<"u"&&t.console.warn("Hash "+this.hash+" has already been used."),i[this.hash]={fsBoundsDelta:new t.Point(1,1),prevContainerSize:null,animating:!1,forceRedraw:!1,needsResize:!1,forceResize:!1,mouseInside:!1,group:null,zooming:!1,zoomFactor:null,lastZoomTime:null,fullPage:!1,onfullscreenchange:null,lastClickTime:null,draggingToZoom:!1},this._sequenceIndex=0,this._firstOpen=!0,this._updateRequestId=null,this._loadQueue=[],this.currentOverlays=[],this._updatePixelDensityRatioBind=null,this._lastScrollTime=t.now(),t.EventSource.call(this),this.addHandler("open-failed",function(Q){var xe=t.getString("Errors.OpenFailed",Q.eventSource,Q.message);k._showMessage(xe)}),t.ControlDock.call(this,x),this.xmlPath&&(this.tileSources=[this.xmlPath]),this.element=this.element||document.getElementById(this.id),this.canvas=t.makeNeutralElement("div"),this.canvas.className="openseadragon-canvas",(function(Q){Q.width="100%",Q.height="100%",Q.overflow="hidden",Q.position="absolute",Q.top="0px",Q.left="0px"})(this.canvas.style),t.setElementTouchActionNone(this.canvas),x.tabIndex!==""&&(this.canvas.tabIndex=x.tabIndex===void 0?0:x.tabIndex),this.container.className="openseadragon-container",(function(Q){Q.width="100%",Q.height="100%",Q.position="relative",Q.overflow="hidden",Q.left="0px",Q.top="0px",Q.textAlign="left"})(this.container.style),t.setElementTouchActionNone(this.container),this.container.insertBefore(this.canvas,this.container.firstChild),this.element.appendChild(this.container),this.bodyWidth=document.body.style.width,this.bodyHeight=document.body.style.height,this.bodyOverflow=document.body.style.overflow,this.docOverflow=document.documentElement.style.overflow,this.innerTracker=new t.MouseTracker({userData:"Viewer.innerTracker",element:this.canvas,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,contextMenuHandler:t.delegate(this,m),keyDownHandler:t.delegate(this,v),keyHandler:t.delegate(this,_),clickHandler:t.delegate(this,y),dblClickHandler:t.delegate(this,w),dragHandler:t.delegate(this,R),dragEndHandler:t.delegate(this,M),enterHandler:t.delegate(this,C),leaveHandler:t.delegate(this,O),pressHandler:t.delegate(this,N),releaseHandler:t.delegate(this,X),nonPrimaryPressHandler:t.delegate(this,q),nonPrimaryReleaseHandler:t.delegate(this,L),scrollHandler:t.delegate(this,j),pinchHandler:t.delegate(this,S),focusHandler:t.delegate(this,I),blurHandler:t.delegate(this,B)}),this.outerTracker=new t.MouseTracker({userData:"Viewer.outerTracker",element:this.container,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,enterHandler:t.delegate(this,U),leaveHandler:t.delegate(this,W)}),this.toolbar&&(this.toolbar=new t.ControlDock({element:this.toolbar})),this.bindStandardControls(),i[this.hash].prevContainerSize=s(this.container),window.ResizeObserver?(this._autoResizePolling=!1,this._resizeObserver=new ResizeObserver(function(){i[k.hash].needsResize=!0}),this._resizeObserver.observe(this.container,{})):this._autoResizePolling=!0,this.world=new t.World({viewer:this}),this.world.addHandler("add-item",function(Q){k.source=k.world.getItemAt(0).source,i[k.hash].forceRedraw=!0,k._updateRequestId||(k._updateRequestId=h(k,ee))}),this.world.addHandler("remove-item",function(Q){k.world.getItemCount()?k.source=k.world.getItemAt(0).source:k.source=null,i[k.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(Q){k.viewport&&k.viewport._setContentBounds(k.world.getHomeBounds(),k.world.getContentFactor())}),this.world.addHandler("item-index-change",function(Q){k.source=k.world.getItemAt(0).source}),this.viewport=new t.Viewport({containerSize:i[this.hash].prevContainerSize,springStiffness:this.springStiffness,animationTime:this.animationTime,minZoomImageRatio:this.minZoomImageRatio,maxZoomPixelRatio:this.maxZoomPixelRatio,visibilityRatio:this.visibilityRatio,wrapHorizontal:this.wrapHorizontal,wrapVertical:this.wrapVertical,defaultZoomLevel:this.defaultZoomLevel,minZoomLevel:this.minZoomLevel,maxZoomLevel:this.maxZoomLevel,viewer:this,degrees:this.degrees,flipped:this.flipped,overlayPreserveContentDirection:this.overlayPreserveContentDirection,navigatorRotate:this.navigatorRotate,homeFillsViewer:this.homeFillsViewer,margins:this.viewportMargins,silenceMultiImageWarnings:this.silenceMultiImageWarnings}),this.viewport._setContentBounds(this.world.getHomeBounds(),this.world.getContentFactor()),this.imageLoader=new t.ImageLoader({jobLimit:this.imageLoaderLimit,timeout:x.timeout,tileRetryMax:this.tileRetryMax,tileRetryDelay:this.tileRetryDelay}),this.tileCache=new t.TileCache({maxImageCacheCount:this.maxImageCacheCount}),Object.prototype.hasOwnProperty.call(this.drawerOptions,"useCanvas")&&(t.console.error('useCanvas is deprecated, use the "drawer" option to indicate preferred drawer(s)'),this.drawerOptions.useCanvas||(this.drawer=t.HTMLDrawer),delete this.drawerOptions.useCanvas);let oe=Array.isArray(this.drawer)?this.drawer:[this.drawer];oe.length===0&&(oe=[t.DEFAULT_SETTINGS.drawer].flat(),t.console.warn("No valid drawers were selected. Using the default value.")),this.drawer=null;for(const Q of oe)if(this.requestDrawer(Q,{mainDrawer:!0,redrawImmediately:!1}))break;if(!this.drawer)throw t.console.error("No drawer could be created!"),"Error with creating the selected drawer(s)";for(this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled),this.overlaysContainer=t.makeNeutralElement("div"),this.canvas.appendChild(this.overlaysContainer),this.drawer.canRotate()||(this.rotateLeft&&(G=this.buttonGroup.buttons.indexOf(this.rotateLeft),this.buttonGroup.buttons.splice(G,1),this.buttonGroup.element.removeChild(this.rotateLeft.element)),this.rotateRight&&(G=this.buttonGroup.buttons.indexOf(this.rotateRight),this.buttonGroup.buttons.splice(G,1),this.buttonGroup.element.removeChild(this.rotateRight.element))),this._addUpdatePixelDensityRatioEvent(),this.showNavigator&&(this.navigator=new t.Navigator({element:this.navigatorElement,id:this.navigatorId,position:this.navigatorPosition,sizeRatio:this.navigatorSizeRatio,maintainSizeRatio:this.navigatorMaintainSizeRatio,top:this.navigatorTop,left:this.navigatorLeft,width:this.navigatorWidth,height:this.navigatorHeight,autoResize:this.navigatorAutoResize,autoFade:this.navigatorAutoFade,prefixUrl:this.prefixUrl,viewer:this,navigatorRotate:this.navigatorRotate,background:this.navigatorBackground,opacity:this.navigatorOpacity,borderColor:this.navigatorBorderColor,displayRegionColor:this.navigatorDisplayRegionColor,crossOriginPolicy:this.crossOriginPolicy,animationTime:this.animationTime,drawer:this.drawer.getType(),loadTilesWithAjax:this.loadTilesWithAjax,ajaxHeaders:this.ajaxHeaders,ajaxWithCredentials:this.ajaxWithCredentials})),this.sequenceMode&&this.bindSequenceControls(),this.tileSources&&this.open(this.tileSources),G=0;G<this.customControls.length;G++)this.addControl(this.customControls[G].id,{anchor:this.customControls[G].anchor});t.requestAnimationFrame(function(){c(k)}),t._viewers.set(this.element,this)},t.extend(t.Viewer.prototype,t.EventSource.prototype,t.ControlDock.prototype,{isOpen:function(){return!!this.world.getItemCount()},openDzi:function(x){return t.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(x)},openTileSource:function(x){return t.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(x)},get buttons(){return t.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(x,A){var k=this;if(this.close(),!x)return this;if(this.sequenceMode&&t.isArray(x))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),typeof A<"u"&&!isNaN(A)&&(this.initialPage=A),this.tileSources=x,this._sequenceIndex=Math.max(0,Math.min(this.tileSources.length-1,this.initialPage)),this.tileSources.length&&(this.open(this.tileSources[this._sequenceIndex]),this.showReferenceStrip&&this.addReferenceStrip()),this._updateSequenceButtons(this._sequenceIndex),this;if(t.isArray(x)||(x=[x]),!x.length)return this;this._opening=!0;for(var G=x.length,V=0,oe=0,Q,xe=function(){if(V+oe===G)if(V){(k._firstOpen||!k.preserveViewport)&&(k.viewport.goHome(!0),k.viewport.update()),k._firstOpen=!1;var ye=x[0];if(ye.tileSource&&(ye=ye.tileSource),k.overlays&&!k.preserveOverlays)for(var qe=0;qe<k.overlays.length;qe++)k.currentOverlays[qe]=a(k,k.overlays[qe]);k._drawOverlays(),k._opening=!1,k.raiseEvent("open",{source:ye})}else k._opening=!1,k.raiseEvent("open-failed",Q)},Be=function(ye){(!t.isPlainObject(ye)||!ye.tileSource)&&(ye={tileSource:ye}),ye.index!==void 0&&(t.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead"),delete ye.index),ye.collectionImmediately===void 0&&(ye.collectionImmediately=!0);var qe=ye.success;ye.success=function(T){if(V++,ye.tileSource.overlays)for(var P=0;P<ye.tileSource.overlays.length;P++)k.addOverlay(ye.tileSource.overlays[P]);qe&&qe(T),xe()};var E=ye.error;ye.error=function(T){oe++,Q||(Q=T),E&&E(T),xe()},k.addTiledImage(ye)},tt=0;tt<x.length;tt++)Be(x[tt]);return this},close:function(){return i[this.hash]?(this._opening=!1,this.navigator&&this.navigator.close(),this.preserveOverlays||(this.clearOverlays(),this.overlaysContainer.innerHTML=""),i[this.hash].animating=!1,this.world.removeAll(),this.imageLoader.clear(),this.raiseEvent("close"),this):this},destroy:function(){if(i[this.hash]){if(this.raiseEvent("before-destroy"),this._removeUpdatePixelDensityRatioEvent(),this.close(),this.clearOverlays(),this.overlaysContainer.innerHTML="",this._resizeObserver&&this._resizeObserver.disconnect(),this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),this._updateRequestId!==null&&(t.cancelAnimationFrame(this._updateRequestId),this._updateRequestId=null),this.drawer&&this.drawer.destroy(),this.navigator&&(this.navigator.destroy(),i[this.navigator.hash]=null,delete i[this.navigator.hash],this.navigator=null),this.buttonGroup)this.buttonGroup.destroy();else if(this.customButtons)for(;this.customButtons.length;)this.customButtons.pop().destroy();if(this.paging&&this.paging.destroy(),this.element)for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);this.container.onsubmit=null,this.clearControls(),this.innerTracker&&this.innerTracker.destroy(),this.outerTracker&&this.outerTracker.destroy(),i[this.hash]=null,delete i[this.hash],this.canvas=null,this.container=null,t._viewers.delete(this.element),this.element=null,this.raiseEvent("destroy"),this.removeAllHandlers()}},requestDrawer(x,A){const k={mainDrawer:!0,redrawImmediately:!0,drawerOptions:null};A=t.extend(!0,k,A);const G=A.mainDrawer,V=A.redrawImmediately,oe=A.drawerOptions,Q=this.drawer;let xe=null;if(x&&x.prototype instanceof t.DrawerBase?(xe=x,x="custom"):typeof x=="string"&&(xe=t.determineDrawer(x)),xe||t.console.warn("Unsupported drawer! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase."),xe&&xe.isSupported()){Q&&G&&Q.destroy();const Be=new xe({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor,options:oe||this.drawerOptions[x]});return G&&(this.drawer=Be,V&&this.forceRedraw()),Be}return!1},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(x){return this.innerTracker.setTracking(x),this.outerTracker.setTracking(x),this.raiseEvent("mouse-enabled",{enabled:x}),this},areControlsEnabled:function(){var x=this.controls.length,A;for(A=0;A<this.controls.length;A++)x=x&&this.controls[A].isVisible();return x},setControlsEnabled:function(x){return x?f(this):c(this),this.raiseEvent("controls-enabled",{enabled:x}),this},setDebugMode:function(x){for(var A=0;A<this.world.getItemCount();A++)this.world.getItemAt(A).debugMode=x;this.debugMode=x,this.forceRedraw()},setAjaxHeaders:function(x,A){if(x===null&&(x={}),!t.isPlainObject(x)){console.error("[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}if(A===void 0&&(A=!0),this.ajaxHeaders=x,A){for(var k=0;k<this.world.getItemCount();k++)this.world.getItemAt(k)._updateAjaxHeaders(!0);if(this.navigator&&this.navigator.setAjaxHeaders(this.ajaxHeaders,!0),this.referenceStrip&&this.referenceStrip.miniViewers)for(var G in this.referenceStrip.miniViewers)this.referenceStrip.miniViewers[G].setAjaxHeaders(this.ajaxHeaders,!0)}},addButton:function(x){this.buttonGroup.addButton(x)},isFullPage:function(){return i[this.hash]&&i[this.hash].fullPage},setFullPage:function(x){var A=document.body,k=A.style,G=document.documentElement.style,V=this,oe,Q;if(x===this.isFullPage())return this;var xe={fullPage:x,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",xe),xe.preventDefaultAction)return this;if(x&&this.element){for(this.elementSize=t.getElementSize(this.element),this.pageScroll=t.getPageScroll(),this.elementMargin=this.element.style.margin,this.element.style.margin="0",this.elementPadding=this.element.style.padding,this.element.style.padding="0",this.bodyMargin=k.margin,this.docMargin=G.margin,k.margin="0",G.margin="0",this.bodyPadding=k.padding,this.docPadding=G.padding,k.padding="0",G.padding="0",this.bodyWidth=k.width,this.docWidth=G.width,k.width="100%",G.width="100%",this.bodyHeight=k.height,this.docHeight=G.height,k.height="100%",G.height="100%",this.bodyDisplay=k.display,k.display="block",this.previousBody=[],i[this.hash].prevElementParent=this.element.parentNode,i[this.hash].prevNextSibling=this.element.nextSibling,i[this.hash].prevElementWidth=this.element.style.width,i[this.hash].prevElementHeight=this.element.style.height,oe=A.childNodes.length,Q=0;Q<oe;Q++)this.previousBody.push(A.childNodes[0]),A.removeChild(A.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,A.appendChild(this.toolbar.element),t.addClass(this.toolbar.element,"fullpage")),t.addClass(this.element,"fullpage"),A.appendChild(this.element),this.element.style.height="100vh",this.element.style.width="100vw",this.toolbar&&this.toolbar.element&&(this.element.style.height=t.getElementSize(this.element).y-t.getElementSize(this.toolbar.element).y+"px"),i[this.hash].fullPage=!0,t.delegate(this,U)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,k.margin=this.bodyMargin,G.margin=this.docMargin,k.padding=this.bodyPadding,G.padding=this.docPadding,k.width=this.bodyWidth,G.width=this.docWidth,k.height=this.bodyHeight,G.height=this.docHeight,k.display=this.bodyDisplay,A.removeChild(this.element),oe=this.previousBody.length,Q=0;Q<oe;Q++)A.appendChild(this.previousBody.shift());t.removeClass(this.element,"fullpage"),i[this.hash].prevElementParent.insertBefore(this.element,i[this.hash].prevNextSibling),this.toolbar&&this.toolbar.element&&(A.removeChild(this.toolbar.element),t.removeClass(this.toolbar.element,"fullpage"),this.toolbar.parentNode.insertBefore(this.toolbar.element,this.toolbar.nextSibling),delete this.toolbar.parentNode,delete this.toolbar.nextSibling),this.element.style.width=i[this.hash].prevElementWidth,this.element.style.height=i[this.hash].prevElementHeight;var Be=0,tt=function(){t.setPageScroll(V.pageScroll);var ye=t.getPageScroll();Be++,Be<10&&(ye.x!==V.pageScroll.x||ye.y!==V.pageScroll.y)&&t.requestAnimationFrame(tt)};t.requestAnimationFrame(tt),i[this.hash].fullPage=!1,t.delegate(this,W)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:x}),this},setFullScreen:function(x){var A=this;if(!t.supportsFullScreen)return this.setFullPage(x);if(t.isFullScreen()===x)return this;var k={fullScreen:x,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",k),k.preventDefaultAction)return this;if(x){if(this.setFullPage(!0),!this.isFullPage())return this;this.fullPageStyleWidth=this.element.style.width,this.fullPageStyleHeight=this.element.style.height,this.element.style.width="100%",this.element.style.height="100%";var G=function(){var V=t.isFullScreen();V||(t.removeEvent(document,t.fullScreenEventName,G),t.removeEvent(document,t.fullScreenErrorEventName,G),A.setFullPage(!1),A.isFullPage()&&(A.element.style.width=A.fullPageStyleWidth,A.element.style.height=A.fullPageStyleHeight)),A.navigator&&A.viewport&&setTimeout(function(){A.navigator.update(A.viewport)}),A.raiseEvent("full-screen",{fullScreen:V})};t.addEvent(document,t.fullScreenEventName,G),t.addEvent(document,t.fullScreenErrorEventName,G),t.requestFullScreen(document.body)}else t.exitFullScreen();return this},isVisible:function(){return this.container.style.visibility!=="hidden"},isFullScreen:function(){return t.isFullScreen()&&this.isFullPage()},setVisible:function(x){return this.container.style.visibility=x?"":"hidden",this.raiseEvent("visible",{visible:x}),this},addTiledImage:function(x){t.console.assert(x,"[Viewer.addTiledImage] options is required"),t.console.assert(x.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),t.console.assert(!x.replace||x.index>-1&&x.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var A=this;x.replace&&(x.replaceItem=A.world.getItemAt(x.index)),this._hideMessage(),x.placeholderFillStyle===void 0&&(x.placeholderFillStyle=this.placeholderFillStyle),x.opacity===void 0&&(x.opacity=this.opacity),x.preload===void 0&&(x.preload=this.preload),x.compositeOperation===void 0&&(x.compositeOperation=this.compositeOperation),x.crossOriginPolicy===void 0&&(x.crossOriginPolicy=x.tileSource.crossOriginPolicy!==void 0?x.tileSource.crossOriginPolicy:this.crossOriginPolicy),x.ajaxWithCredentials===void 0&&(x.ajaxWithCredentials=this.ajaxWithCredentials),x.loadTilesWithAjax===void 0&&(x.loadTilesWithAjax=this.loadTilesWithAjax),t.isPlainObject(x.ajaxHeaders)||(x.ajaxHeaders={});var k={options:x};function G(Q){for(var xe=0;xe<A._loadQueue.length;xe++)if(A._loadQueue[xe]===k){A._loadQueue.splice(xe,1);break}A._loadQueue.length===0&&V(k),A.raiseEvent("add-item-failed",Q),x.error&&x.error(Q)}function V(Q){A.collectionMode&&(A.world.arrange({immediately:Q.options.collectionImmediately,rows:A.collectionRows,columns:A.collectionColumns,layout:A.collectionLayout,tileSize:A.collectionTileSize,tileMargin:A.collectionTileMargin}),A.world.setAutoRefigureSizes(!0))}if(t.isArray(x.tileSource)){setTimeout(function(){G({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:x.tileSource,options:x})});return}this._loadQueue.push(k);function oe(){for(var Q,xe,Be;A._loadQueue.length&&(Q=A._loadQueue[0],!!Q.tileSource);){if(A._loadQueue.splice(0,1),Q.options.replace){var tt=A.world.getIndexOfItem(Q.options.replaceItem);tt!==-1&&(Q.options.index=tt),A.world.removeItem(Q.options.replaceItem)}xe=new t.TiledImage({viewer:A,source:Q.tileSource,viewport:A.viewport,drawer:A.drawer,tileCache:A.tileCache,imageLoader:A.imageLoader,x:Q.options.x,y:Q.options.y,width:Q.options.width,height:Q.options.height,fitBounds:Q.options.fitBounds,fitBoundsPlacement:Q.options.fitBoundsPlacement,clip:Q.options.clip,placeholderFillStyle:Q.options.placeholderFillStyle,opacity:Q.options.opacity,preload:Q.options.preload,degrees:Q.options.degrees,flipped:Q.options.flipped,compositeOperation:Q.options.compositeOperation,springStiffness:A.springStiffness,animationTime:A.animationTime,minZoomImageRatio:A.minZoomImageRatio,wrapHorizontal:A.wrapHorizontal,wrapVertical:A.wrapVertical,maxTilesPerFrame:A.maxTilesPerFrame,immediateRender:A.immediateRender,blendTime:A.blendTime,alwaysBlend:A.alwaysBlend,minPixelRatio:A.minPixelRatio,smoothTileEdgesMinZoom:A.smoothTileEdgesMinZoom,iOSDevice:A.iOSDevice,crossOriginPolicy:Q.options.crossOriginPolicy,ajaxWithCredentials:Q.options.ajaxWithCredentials,loadTilesWithAjax:Q.options.loadTilesWithAjax,ajaxHeaders:Q.options.ajaxHeaders,debugMode:A.debugMode,subPixelRoundingForTransparency:A.subPixelRoundingForTransparency}),A.collectionMode&&A.world.setAutoRefigureSizes(!1),A.navigator&&(Be=t.extend({},Q.options,{replace:!1,originalTiledImage:xe,tileSource:Q.tileSource}),A.navigator.addTiledImage(Be)),A.world.addItem(xe,{index:Q.options.index}),A._loadQueue.length===0&&V(Q),A.world.getItemCount()===1&&!A.preserveViewport&&A.viewport.goHome(!0),Q.options.success&&Q.options.success({item:xe})}}o(this,x.tileSource,x,function(Q){k.tileSource=Q,oe()},function(Q){Q.options=x,G(Q),oe()})},addSimpleImage:function(x){t.console.assert(x,"[Viewer.addSimpleImage] options is required"),t.console.assert(x.url,"[Viewer.addSimpleImage] options.url is required");var A=t.extend({},x,{tileSource:{type:"image",url:x.url}});delete A.url,this.addTiledImage(A)},addLayer:function(x){var A=this;t.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var k=t.extend({},x,{success:function(G){A.raiseEvent("add-layer",{options:x,drawer:G.item})},error:function(G){A.raiseEvent("add-layer-failed",G)}});return this.addTiledImage(k),this},getLayerAtLevel:function(x){return t.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(x)},getLevelOfLayer:function(x){return t.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(x)},getLayersCount:function(){return t.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(x,A){return t.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(x,A)},removeLayer:function(x){return t.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(x)},forceRedraw:function(){return i[this.hash].forceRedraw=!0,this},forceResize:function(){i[this.hash].needsResize=!0,i[this.hash].forceResize=!0},bindSequenceControls:function(){var x=t.delegate(this,p),A=t.delegate(this,g),k=t.delegate(this,this.goToNextPage),G=t.delegate(this,this.goToPreviousPage),V=this.navImages,oe=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(oe=!1),this.previousButton=new t.Button({element:this.previousButton?t.getElement(this.previousButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.PreviousPage"),srcRest:$(this.prefixUrl,V.previous.REST),srcGroup:$(this.prefixUrl,V.previous.GROUP),srcHover:$(this.prefixUrl,V.previous.HOVER),srcDown:$(this.prefixUrl,V.previous.DOWN),onRelease:G,onFocus:x,onBlur:A}),this.nextButton=new t.Button({element:this.nextButton?t.getElement(this.nextButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.NextPage"),srcRest:$(this.prefixUrl,V.next.REST),srcGroup:$(this.prefixUrl,V.next.GROUP),srcHover:$(this.prefixUrl,V.next.HOVER),srcDown:$(this.prefixUrl,V.next.DOWN),onRelease:k,onFocus:x,onBlur:A}),this.navPrevNextWrap||this.previousButton.disable(),(!this.tileSources||!this.tileSources.length)&&this.nextButton.disable(),oe&&(this.paging=new t.ButtonGroup({buttons:[this.previousButton,this.nextButton],clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.pagingControl=this.paging.element,this.toolbar?this.toolbar.addControl(this.pagingControl,{anchor:t.ControlAnchor.BOTTOM_RIGHT}):this.addControl(this.pagingControl,{anchor:this.sequenceControlAnchor||t.ControlAnchor.TOP_LEFT}))),this},bindStandardControls:function(){var x=t.delegate(this,se),A=t.delegate(this,te),k=t.delegate(this,he),G=t.delegate(this,fe),V=t.delegate(this,le),oe=t.delegate(this,Ce),Q=t.delegate(this,ze),xe=t.delegate(this,lt),Be=t.delegate(this,me),tt=t.delegate(this,Ae),ye=t.delegate(this,p),qe=t.delegate(this,g),E=this.navImages,T=[],P=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(P=!1),this.showZoomControl&&(T.push(this.zoomInButton=new t.Button({element:this.zoomInButton?t.getElement(this.zoomInButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.ZoomIn"),srcRest:$(this.prefixUrl,E.zoomIn.REST),srcGroup:$(this.prefixUrl,E.zoomIn.GROUP),srcHover:$(this.prefixUrl,E.zoomIn.HOVER),srcDown:$(this.prefixUrl,E.zoomIn.DOWN),onPress:x,onRelease:A,onClick:k,onEnter:x,onExit:A,onFocus:ye,onBlur:qe})),T.push(this.zoomOutButton=new t.Button({element:this.zoomOutButton?t.getElement(this.zoomOutButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.ZoomOut"),srcRest:$(this.prefixUrl,E.zoomOut.REST),srcGroup:$(this.prefixUrl,E.zoomOut.GROUP),srcHover:$(this.prefixUrl,E.zoomOut.HOVER),srcDown:$(this.prefixUrl,E.zoomOut.DOWN),onPress:G,onRelease:A,onClick:V,onEnter:G,onExit:A,onFocus:ye,onBlur:qe}))),this.showHomeControl&&T.push(this.homeButton=new t.Button({element:this.homeButton?t.getElement(this.homeButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.Home"),srcRest:$(this.prefixUrl,E.home.REST),srcGroup:$(this.prefixUrl,E.home.GROUP),srcHover:$(this.prefixUrl,E.home.HOVER),srcDown:$(this.prefixUrl,E.home.DOWN),onRelease:oe,onFocus:ye,onBlur:qe})),this.showFullPageControl&&T.push(this.fullPageButton=new t.Button({element:this.fullPageButton?t.getElement(this.fullPageButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.FullPage"),srcRest:$(this.prefixUrl,E.fullpage.REST),srcGroup:$(this.prefixUrl,E.fullpage.GROUP),srcHover:$(this.prefixUrl,E.fullpage.HOVER),srcDown:$(this.prefixUrl,E.fullpage.DOWN),onRelease:Q,onFocus:ye,onBlur:qe})),this.showRotationControl&&(T.push(this.rotateLeftButton=new t.Button({element:this.rotateLeftButton?t.getElement(this.rotateLeftButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.RotateLeft"),srcRest:$(this.prefixUrl,E.rotateleft.REST),srcGroup:$(this.prefixUrl,E.rotateleft.GROUP),srcHover:$(this.prefixUrl,E.rotateleft.HOVER),srcDown:$(this.prefixUrl,E.rotateleft.DOWN),onRelease:xe,onFocus:ye,onBlur:qe})),T.push(this.rotateRightButton=new t.Button({element:this.rotateRightButton?t.getElement(this.rotateRightButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.RotateRight"),srcRest:$(this.prefixUrl,E.rotateright.REST),srcGroup:$(this.prefixUrl,E.rotateright.GROUP),srcHover:$(this.prefixUrl,E.rotateright.HOVER),srcDown:$(this.prefixUrl,E.rotateright.DOWN),onRelease:Be,onFocus:ye,onBlur:qe}))),this.showFlipControl&&T.push(this.flipButton=new t.Button({element:this.flipButton?t.getElement(this.flipButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.Flip"),srcRest:$(this.prefixUrl,E.flip.REST),srcGroup:$(this.prefixUrl,E.flip.GROUP),srcHover:$(this.prefixUrl,E.flip.HOVER),srcDown:$(this.prefixUrl,E.flip.DOWN),onRelease:tt,onFocus:ye,onBlur:qe})),P?(this.buttonGroup=new t.ButtonGroup({buttons:T,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",t.delegate(this,ve)),this.toolbar?this.toolbar.addControl(this.navControl,{anchor:this.navigationControlAnchor||t.ControlAnchor.TOP_LEFT}):this.addControl(this.navControl,{anchor:this.navigationControlAnchor||t.ControlAnchor.TOP_LEFT})):this.customButtons=T),this},currentPage:function(){return this._sequenceIndex},goToPage:function(x){return this.tileSources&&x>=0&&x<this.tileSources.length&&(this._sequenceIndex=x,this._updateSequenceButtons(x),this.open(this.tileSources[x]),this.referenceStrip&&this.referenceStrip.setFocus(x),this.raiseEvent("page",{page:x})),this},addOverlay:function(x,A,k,G){var V;if(t.isPlainObject(x)?V=x:V={element:x,location:A,placement:k,onDraw:G},x=t.getElement(V.element),l(this.currentOverlays,x)>=0)return this;var oe=a(this,V);return this.currentOverlays.push(oe),oe.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:x,location:V.location,placement:V.placement}),this},updateOverlay:function(x,A,k){var G;return x=t.getElement(x),G=l(this.currentOverlays,x),G>=0&&(this.currentOverlays[G].update(A,k),i[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:x,location:A,placement:k})),this},removeOverlay:function(x){var A;return x=t.getElement(x),A=l(this.currentOverlays,x),A>=0&&(this.currentOverlays[A].destroy(),this.currentOverlays.splice(A,1),i[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:x})),this},clearOverlays:function(){for(;this.currentOverlays.length>0;)this.currentOverlays.pop().destroy();return i[this.hash].forceRedraw=!0,this.raiseEvent("clear-overlay",{}),this},getOverlayById:function(x){var A;return x=t.getElement(x),A=l(this.currentOverlays,x),A>=0?this.currentOverlays[A]:null},_updateSequenceButtons:function(x){this.nextButton&&(!this.tileSources||this.tileSources.length-1===x?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(x>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(x){this._hideMessage();var A=t.makeNeutralElement("div");A.appendChild(document.createTextNode(x)),this.messageDiv=t.makeCenteredNode(A),t.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var x=this.messageDiv;x&&(x.parentNode.removeChild(x),delete this.messageDiv)},gestureSettingsByDeviceType:function(x){switch(x){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var x,A=this.currentOverlays.length;for(x=0;x<A;x++)this.currentOverlays[x].drawHTML(this.overlaysContainer,this.viewport)},_cancelPendingImages:function(){this._loadQueue=[]},removeReferenceStrip:function(){this.showReferenceStrip=!1,this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null)},addReferenceStrip:function(){if(this.showReferenceStrip=!0,this.sequenceMode){if(this.referenceStrip)return;this.tileSources.length&&this.tileSources.length>1&&(this.referenceStrip=new t.ReferenceStrip({id:this.referenceStripElement,position:this.referenceStripPosition,sizeRatio:this.referenceStripSizeRatio,scroll:this.referenceStripScroll,height:this.referenceStripHeight,width:this.referenceStripWidth,tileSources:this.tileSources,prefixUrl:this.prefixUrl,viewer:this}),this.referenceStrip.setFocus(this._sequenceIndex))}else t.console.warn('Attempting to display a reference strip while "sequenceMode" is off.')},_addUpdatePixelDensityRatioEvent:function(){this._updatePixelDensityRatioBind=this._updatePixelDensityRatio.bind(this),t.addEvent(window,"resize",this._updatePixelDensityRatioBind)},_removeUpdatePixelDensityRatioEvent:function(){t.removeEvent(window,"resize",this._updatePixelDensityRatioBind)},_updatePixelDensityRatio:function(){var x=t.pixelDensityRatio,A=t.getCurrentPixelDensityRatio();x!==A&&(t.pixelDensityRatio=A,this.forceResize())},goToPreviousPage:function(){var x=this._sequenceIndex-1;this.navPrevNextWrap&&x<0&&(x+=this.tileSources.length),this.goToPage(x)},goToNextPage:function(){var x=this._sequenceIndex+1;this.navPrevNextWrap&&x>=this.tileSources.length&&(x=0),this.goToPage(x)},isAnimating:function(){return i[this.hash].animating}});function s(x){return x=t.getElement(x),new t.Point(x.clientWidth===0?1:x.clientWidth,x.clientHeight===0?1:x.clientHeight)}function o(x,A,k,G,V){var oe=x;if(t.type(A)==="string"){if(A.match(/^\s*<.*>\s*$/))A=t.parseXml(A);else if(A.match(/^\s*[{[].*[}\]]\s*$/))try{var Q=t.parseJSON(A);A=Q}catch{}}function xe(Be,tt){Be.ready?G(Be):(Be.addHandler("ready",function(){G(Be)}),Be.addHandler("open-failed",function(ye){V({message:ye.message,source:tt})}))}setTimeout(function(){if(t.type(A)==="string")A=new t.TileSource({url:A,crossOriginPolicy:k.crossOriginPolicy!==void 0?k.crossOriginPolicy:x.crossOriginPolicy,ajaxWithCredentials:x.ajaxWithCredentials,ajaxHeaders:k.ajaxHeaders?k.ajaxHeaders:x.ajaxHeaders,splitHashDataForPost:x.splitHashDataForPost,success:function(qe){G(qe.tileSource)}}),A.addHandler("open-failed",function(qe){V(qe)});else if(t.isPlainObject(A)||A.nodeType)if(A.crossOriginPolicy===void 0&&(k.crossOriginPolicy!==void 0||x.crossOriginPolicy!==void 0)&&(A.crossOriginPolicy=k.crossOriginPolicy!==void 0?k.crossOriginPolicy:x.crossOriginPolicy),A.ajaxWithCredentials===void 0&&(A.ajaxWithCredentials=x.ajaxWithCredentials),t.isFunction(A.getTileUrl)){var Be=new t.TileSource(A);Be.getTileUrl=A.getTileUrl,G(Be)}else{var tt=t.TileSource.determineType(oe,A);if(!tt){V({message:"Unable to load TileSource",source:A});return}var ye=tt.prototype.configure.apply(oe,[A]);xe(new tt(ye),A)}else xe(A,A)})}function a(x,A){if(A instanceof t.Overlay)return A;var k=null;if(A.element)k=t.getElement(A.element);else{var G=A.id?A.id:"openseadragon-overlay-"+Math.floor(Math.random()*1e7);k=t.getElement(A.id),k||(k=document.createElement("a"),k.href="#/overlay/"+G),k.id=G,t.addClass(k,A.className?A.className:"openseadragon-overlay")}var V=A.location,oe=A.width,Q=A.height;if(!V){var xe=A.x,Be=A.y;if(A.px!==void 0){var tt=x.viewport.imageToViewportRectangle(new t.Rect(A.px,A.py,oe||0,Q||0));xe=tt.x,Be=tt.y,oe=oe!==void 0?tt.width:void 0,Q=Q!==void 0?tt.height:void 0}V=new t.Point(xe,Be)}var ye=A.placement;return ye&&t.type(ye)==="string"&&(ye=t.Placement[A.placement.toUpperCase()]),new t.Overlay({element:k,location:V,placement:ye,onDraw:A.onDraw,checkResize:A.checkResize,width:oe,height:Q,rotationMode:A.rotationMode})}function l(x,A){var k;for(k=x.length-1;k>=0;k--)if(x[k].element===A)return k;return-1}function h(x,A){return t.requestAnimationFrame(function(){A(x)})}function u(x){t.requestAnimationFrame(function(){d(x)})}function c(x){x.autoHideControls&&(x.controlsShouldFade=!0,x.controlsFadeBeginTime=t.now()+x.controlsFadeDelay,window.setTimeout(function(){u(x)},x.controlsFadeDelay))}function d(x){var A,k,G,V;if(x.controlsShouldFade){for(A=t.now(),k=A-x.controlsFadeBeginTime,G=1-k/x.controlsFadeLength,G=Math.min(1,G),G=Math.max(0,G),V=x.controls.length-1;V>=0;V--)x.controls[V].autoFade&&x.controls[V].setOpacity(G);G>0&&u(x)}}function f(x){var A;for(x.controlsShouldFade=!1,A=x.controls.length-1;A>=0;A--)x.controls[A].setOpacity(1)}function p(){f(this)}function g(){c(this)}function m(x){var A={tracker:x.eventSource,position:x.position,originalEvent:x.originalEvent,preventDefault:x.preventDefault};this.raiseEvent("canvas-contextmenu",A),x.preventDefault=A.preventDefault}function v(x){var A={originalEvent:x.originalEvent,preventDefaultAction:!1,preventVerticalPan:x.preventVerticalPan||!this.panVertical,preventHorizontalPan:x.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",A),!A.preventDefaultAction&&!x.ctrl&&!x.alt&&!x.meta)switch(x.keyCode){case 38:A.preventVerticalPan||(x.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 40:A.preventVerticalPan||(x.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 37:A.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 39:A.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 187:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),x.preventDefault=!0;break;case 189:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),x.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),x.preventDefault=!0;break;case 87:A.preventVerticalPan||(x.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,-40))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 83:A.preventVerticalPan||(x.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,40))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 65:A.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(-40,0))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 68:A.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(40,0))),this.viewport.applyConstraints()),x.preventDefault=!0;break;case 82:x.shift?this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement):this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement),this.viewport.applyConstraints(),x.preventDefault=!0;break;case 70:this.viewport.toggleFlip(),x.preventDefault=!0;break;case 74:this.goToPreviousPage();break;case 75:this.goToNextPage();break;default:x.preventDefault=!1;break}else x.preventDefault=!1}function _(x){var A={originalEvent:x.originalEvent};this.raiseEvent("canvas-key-press",A)}function y(x){var A,k=document.activeElement===this.canvas;k||this.canvas.focus(),this.viewport.flipped&&(x.position.x=this.viewport.getContainerSize().x-x.position.x);var G={tracker:x.eventSource,position:x.position,quick:x.quick,shift:x.shift,originalEvent:x.originalEvent,originalTarget:x.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",G),!G.preventDefaultAction&&this.viewport&&x.quick&&(A=this.gestureSettingsByDeviceType(x.pointerType),A.clickToZoom===!0&&(this.viewport.zoomBy(x.shift?1/this.zoomPerClick:this.zoomPerClick,A.zoomToRefPoint?this.viewport.pointFromPixel(x.position,!0):null),this.viewport.applyConstraints()),A.dblClickDragToZoom&&(i[this.hash].draggingToZoom===!0?(i[this.hash].lastClickTime=null,i[this.hash].draggingToZoom=!1):i[this.hash].lastClickTime=t.now()))}function w(x){var A,k={tracker:x.eventSource,position:x.position,shift:x.shift,originalEvent:x.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",k),!k.preventDefaultAction&&this.viewport&&(A=this.gestureSettingsByDeviceType(x.pointerType),A.dblClickToZoom&&(this.viewport.zoomBy(x.shift?1/this.zoomPerClick:this.zoomPerClick,A.zoomToRefPoint?this.viewport.pointFromPixel(x.position,!0):null),this.viewport.applyConstraints()))}function R(x){var A,k={tracker:x.eventSource,pointerType:x.pointerType,position:x.position,delta:x.delta,speed:x.speed,direction:x.direction,shift:x.shift,originalEvent:x.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",k),A=this.gestureSettingsByDeviceType(x.pointerType),!k.preventDefaultAction&&this.viewport){if(A.dblClickDragToZoom&&i[this.hash].draggingToZoom){var G=Math.pow(this.zoomPerDblClickDrag,x.delta.y/50);this.viewport.zoomBy(G)}else if(A.dragToPan&&!i[this.hash].draggingToZoom){if(this.panHorizontal||(x.delta.x=0),this.panVertical||(x.delta.y=0),this.viewport.flipped&&(x.delta.x=-x.delta.x),this.constrainDuringPan){var V=this.viewport.deltaPointsFromPixels(x.delta.negate());this.viewport.centerSpringX.target.value+=V.x,this.viewport.centerSpringY.target.value+=V.y;var oe=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=V.x,this.viewport.centerSpringY.target.value-=V.y,oe.xConstrained&&(x.delta.x=0),oe.yConstrained&&(x.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(x.delta.negate()),A.flickEnabled&&!this.constrainDuringPan)}}}function M(x){var A,k={tracker:x.eventSource,pointerType:x.pointerType,position:x.position,speed:x.speed,direction:x.direction,shift:x.shift,originalEvent:x.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",k),A=this.gestureSettingsByDeviceType(x.pointerType),!k.preventDefaultAction&&this.viewport){if(!i[this.hash].draggingToZoom&&A.dragToPan&&A.flickEnabled&&x.speed>=A.flickMinSpeed){var G=0;this.panHorizontal&&(G=A.flickMomentum*x.speed*Math.cos(x.direction));var V=0;this.panVertical&&(V=A.flickMomentum*x.speed*Math.sin(x.direction));var oe=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),Q=this.viewport.pointFromPixel(new t.Point(oe.x-G,oe.y-V));this.viewport.panTo(Q,!1)}this.viewport.applyConstraints()}A.dblClickDragToZoom&&i[this.hash].draggingToZoom===!0&&(i[this.hash].draggingToZoom=!1)}function C(x){this.raiseEvent("canvas-enter",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,buttons:x.buttons,pointers:x.pointers,insideElementPressed:x.insideElementPressed,buttonDownAny:x.buttonDownAny,originalEvent:x.originalEvent})}function O(x){this.raiseEvent("canvas-exit",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,buttons:x.buttons,pointers:x.pointers,insideElementPressed:x.insideElementPressed,buttonDownAny:x.buttonDownAny,originalEvent:x.originalEvent})}function N(x){var A;if(this.raiseEvent("canvas-press",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,insideElementPressed:x.insideElementPressed,insideElementReleased:x.insideElementReleased,originalEvent:x.originalEvent}),A=this.gestureSettingsByDeviceType(x.pointerType),A.dblClickDragToZoom){var k=i[this.hash].lastClickTime,G=t.now();if(k===null)return;G-k<this.dblClickTimeThreshold&&(i[this.hash].draggingToZoom=!0),i[this.hash].lastClickTime=null}}function X(x){this.raiseEvent("canvas-release",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,insideElementPressed:x.insideElementPressed,insideElementReleased:x.insideElementReleased,originalEvent:x.originalEvent})}function q(x){this.raiseEvent("canvas-nonprimary-press",{tracker:x.eventSource,position:x.position,pointerType:x.pointerType,button:x.button,buttons:x.buttons,originalEvent:x.originalEvent})}function L(x){this.raiseEvent("canvas-nonprimary-release",{tracker:x.eventSource,position:x.position,pointerType:x.pointerType,button:x.button,buttons:x.buttons,originalEvent:x.originalEvent})}function S(x){var A,k,G,V,oe={tracker:x.eventSource,pointerType:x.pointerType,gesturePoints:x.gesturePoints,lastCenter:x.lastCenter,center:x.center,lastDistance:x.lastDistance,distance:x.distance,shift:x.shift,originalEvent:x.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",oe),this.viewport&&(A=this.gestureSettingsByDeviceType(x.pointerType),A.pinchToZoom&&(!oe.preventDefaultPanAction||!oe.preventDefaultZoomAction)&&(k=this.viewport.pointFromPixel(x.center,!0),A.zoomToRefPoint&&!oe.preventDefaultPanAction&&(G=this.viewport.pointFromPixel(x.lastCenter,!0),V=G.minus(k),this.panHorizontal||(V.x=0),this.panVertical||(V.y=0),this.viewport.panBy(V,!0)),oe.preventDefaultZoomAction||this.viewport.zoomBy(x.distance/x.lastDistance,k,!0),this.viewport.applyConstraints()),A.pinchRotate&&!oe.preventDefaultRotateAction)){var Q=Math.atan2(x.gesturePoints[0].currentPos.y-x.gesturePoints[1].currentPos.y,x.gesturePoints[0].currentPos.x-x.gesturePoints[1].currentPos.x),xe=Math.atan2(x.gesturePoints[0].lastPos.y-x.gesturePoints[1].lastPos.y,x.gesturePoints[0].lastPos.x-x.gesturePoints[1].lastPos.x);k=this.viewport.pointFromPixel(x.center,!0),this.viewport.rotateTo(this.viewport.getRotation(!0)+(Q-xe)*(180/Math.PI),k,!0)}}function I(x){this.raiseEvent("canvas-focus",{tracker:x.eventSource,originalEvent:x.originalEvent})}function B(x){this.raiseEvent("canvas-blur",{tracker:x.eventSource,originalEvent:x.originalEvent})}function j(x){var A,k,G,V,oe;V=t.now(),oe=V-this._lastScrollTime,oe>this.minScrollDeltaTime?(this._lastScrollTime=V,A={tracker:x.eventSource,position:x.position,scroll:x.scroll,shift:x.shift,originalEvent:x.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",A),!A.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(x.position.x=this.viewport.getContainerSize().x-x.position.x),k=this.gestureSettingsByDeviceType(x.pointerType),k.scrollToZoom&&(G=Math.pow(this.zoomPerScroll,x.scroll),this.viewport.zoomBy(G,k.zoomToRefPoint?this.viewport.pointFromPixel(x.position,!0):null),this.viewport.applyConstraints())),x.preventDefault=A.preventDefault):x.preventDefault=!0}function U(x){i[this.hash].mouseInside=!0,f(this),this.raiseEvent("container-enter",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,buttons:x.buttons,pointers:x.pointers,insideElementPressed:x.insideElementPressed,buttonDownAny:x.buttonDownAny,originalEvent:x.originalEvent})}function W(x){x.pointers<1&&(i[this.hash].mouseInside=!1,i[this.hash].animating||c(this)),this.raiseEvent("container-exit",{tracker:x.eventSource,pointerType:x.pointerType,position:x.position,buttons:x.buttons,pointers:x.pointers,insideElementPressed:x.insideElementPressed,buttonDownAny:x.buttonDownAny,originalEvent:x.originalEvent})}function ee(x){H(x),x.isOpen()?x._updateRequestId=h(x,ee):x._updateRequestId=!1}function z(x,A){var k=x.viewport,G=k.getZoom(),V=k.getCenter();k.resize(A,x.preserveImageSizeOnResize),k.panTo(V,!0);var oe;if(x.preserveImageSizeOnResize)oe=i[x.hash].prevContainerSize.x/A.x;else{var Q=new t.Point(0,0),xe=new t.Point(i[x.hash].prevContainerSize.x,i[x.hash].prevContainerSize.y).distanceTo(Q),Be=new t.Point(A.x,A.y).distanceTo(Q);oe=Be/xe*i[x.hash].prevContainerSize.x/A.x}k.zoomTo(G*oe,null,!0),i[x.hash].prevContainerSize=A,i[x.hash].forceRedraw=!0,i[x.hash].needsResize=!1,i[x.hash].forceResize=!1}function H(x){if(!(x._opening||!i[x.hash])){if(x.autoResize||i[x.hash].forceResize){var A;if(x._autoResizePolling){A=s(x.container);var k=i[x.hash].prevContainerSize;A.equals(k)||(i[x.hash].needsResize=!0)}i[x.hash].needsResize&&z(x,A||s(x.container))}var G=x.viewport.update(),V=x.world.update(G)||G;G&&x.raiseEvent("viewport-change"),x.referenceStrip&&(V=x.referenceStrip.update(x.viewport)||V);var oe=i[x.hash].animating;!oe&&V&&(x.raiseEvent("animation-start"),f(x));var Q=oe&&!V;Q&&(i[x.hash].animating=!1),(V||Q||i[x.hash].forceRedraw||x.world.needsDraw())&&(K(x),x._drawOverlays(),x.navigator&&x.navigator.update(x.viewport),i[x.hash].forceRedraw=!1,V&&x.raiseEvent("animation")),Q&&(x.raiseEvent("animation-finish"),i[x.hash].mouseInside||c(x)),i[x.hash].animating=V}}function K(x){x.imageLoader.clear(),x.world.draw(),x.raiseEvent("update-viewport",{})}function $(x,A){return x?x+A:A}function se(){i[this.hash].lastZoomTime=t.now(),i[this.hash].zoomFactor=this.zoomPerSecond,i[this.hash].zooming=!0,J(this)}function fe(){i[this.hash].lastZoomTime=t.now(),i[this.hash].zoomFactor=1/this.zoomPerSecond,i[this.hash].zooming=!0,J(this)}function te(){i[this.hash].zooming=!1}function J(x){t.requestAnimationFrame(t.delegate(x,Y))}function Y(){var x,A,k;i[this.hash].zooming&&this.viewport&&(x=t.now(),A=x-i[this.hash].lastZoomTime,k=Math.pow(i[this.hash].zoomFactor,A/1e3),this.viewport.zoomBy(k),this.viewport.applyConstraints(),i[this.hash].lastZoomTime=x,J(this))}function he(){this.viewport&&(i[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function le(){this.viewport&&(i[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function ve(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function Ce(){this.viewport&&this.viewport.goHome()}function ze(){this.isFullPage()&&!t.isFullScreen()?this.setFullPage(!1):this.setFullScreen(!this.isFullPage()),this.buttonGroup&&this.buttonGroup.emulateLeave(),this.fullPageButton.element.focus(),this.viewport&&this.viewport.applyConstraints()}function lt(){if(this.viewport){var x=this.viewport.getRotation();this.viewport.flipped?x+=this.rotationIncrement:x-=this.rotationIncrement,this.viewport.setRotation(x)}}function me(){if(this.viewport){var x=this.viewport.getRotation();this.viewport.flipped?x-=this.rotationIncrement:x+=this.rotationIncrement,this.viewport.setRotation(x)}}function Ae(){this.viewport.toggleFlip()}t.determineDrawer=function(x){for(let A in e){const k=e[A],G=k.prototype;if(G&&G instanceof e.DrawerBase&&t.isFunction(G.getType)&&G.getType.call(k)===x)return k}return null}})(e),(function(t){t.Navigator=function(h){var u=h.viewer,c=this,d,f;h.element||h.id?(h.element?(h.id&&t.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."),h.element.id?h.id=h.element.id:h.id="navigator-"+t.now(),this.element=h.element):this.element=document.getElementById(h.id),h.controlOptions={anchor:t.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(h.id="navigator-"+t.now(),this.element=t.makeNeutralElement("div"),h.controlOptions={anchor:t.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:h.autoFade},h.position&&(h.position==="BOTTOM_RIGHT"?h.controlOptions.anchor=t.ControlAnchor.BOTTOM_RIGHT:h.position==="BOTTOM_LEFT"?h.controlOptions.anchor=t.ControlAnchor.BOTTOM_LEFT:h.position==="TOP_RIGHT"?h.controlOptions.anchor=t.ControlAnchor.TOP_RIGHT:h.position==="TOP_LEFT"?h.controlOptions.anchor=t.ControlAnchor.TOP_LEFT:h.position==="ABSOLUTE"&&(h.controlOptions.anchor=t.ControlAnchor.ABSOLUTE,h.controlOptions.top=h.top,h.controlOptions.left=h.left,h.controlOptions.height=h.height,h.controlOptions.width=h.width))),this.element.id=h.id,this.element.className+=" navigator",h=t.extend(!0,{sizeRatio:t.DEFAULT_SETTINGS.navigatorSizeRatio},h,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:h.animationTime,autoResize:!1,minZoomImageRatio:1,background:h.background,opacity:h.opacity,borderColor:h.borderColor,displayRegionColor:h.displayRegionColor}),h.minPixelRatio=this.minPixelRatio=u.minPixelRatio,t.setElementTouchActionNone(this.element),this.borderWidth=2,this.fudge=new t.Point(1,1),this.totalBorderWidths=new t.Point(this.borderWidth*2,this.borderWidth*2).minus(this.fudge),h.controlOptions.anchor!==t.ControlAnchor.NONE&&(function(m,v){m.margin="0px",m.border=v+"px solid "+h.borderColor,m.padding="0px",m.background=h.background,m.opacity=h.opacity,m.overflow="hidden"})(this.element.style,this.borderWidth),this.displayRegion=t.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",(function(m,v){m.position="relative",m.top="0px",m.left="0px",m.fontSize="0px",m.overflow="hidden",m.border=v+"px solid "+h.displayRegionColor,m.margin="0px",m.padding="0px",m.background="transparent",m.float="left",m.cssFloat="left",m.zIndex=999999999,m.cursor="default",m.boxSizing="content-box"})(this.displayRegion.style,this.borderWidth),t.setElementPointerEventsNone(this.displayRegion),t.setElementTouchActionNone(this.displayRegion),this.displayRegionContainer=t.makeNeutralElement("div"),this.displayRegionContainer.id=this.element.id+"-displayregioncontainer",this.displayRegionContainer.className="displayregioncontainer",this.displayRegionContainer.style.width="100%",this.displayRegionContainer.style.height="100%",t.setElementPointerEventsNone(this.displayRegionContainer),t.setElementTouchActionNone(this.displayRegionContainer),u.addControl(this.element,h.controlOptions),this._resizeWithViewer=h.controlOptions.anchor!==t.ControlAnchor.ABSOLUTE&&h.controlOptions.anchor!==t.ControlAnchor.NONE,h.width&&h.height?(this.setWidth(h.width),this.setHeight(h.height)):this._resizeWithViewer&&(d=t.getElementSize(u.element),this.element.style.height=Math.round(d.y*h.sizeRatio)+"px",this.element.style.width=Math.round(d.x*h.sizeRatio)+"px",this.oldViewerSize=d,f=t.getElementSize(this.element),this.elementArea=f.x*f.y),this.oldContainerSize=new t.Point(0,0),t.Viewer.apply(this,[h]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);function p(m,v){a(c.displayRegionContainer,m),a(c.displayRegion,-m),c.viewport.setRotation(m,v)}if(h.navigatorRotate){var g=h.viewer.viewport?h.viewer.viewport.getRotation():h.viewer.degrees||0;p(g,!0),h.viewer.addHandler("rotate",function(m){p(m.degrees,m.immediately)})}this.innerTracker.destroy(),this.innerTracker=new t.MouseTracker({userData:"Navigator.innerTracker",element:this.element,dragHandler:t.delegate(this,r),clickHandler:t.delegate(this,i),releaseHandler:t.delegate(this,s),scrollHandler:t.delegate(this,o),preProcessEventHandler:function(m){m.eventType==="wheel"&&(m.preventDefault=!0)}}),this.outerTracker.userData="Navigator.outerTracker",t.setElementPointerEventsNone(this.canvas),t.setElementPointerEventsNone(this.container),this.addHandler("reset-size",function(){c.viewport&&c.viewport.goHome(!0)}),u.world.addHandler("item-index-change",function(m){window.setTimeout(function(){var v=c.world.getItemAt(m.previousIndex);c.world.setItemIndex(v,m.newIndex)},1)}),u.world.addHandler("remove-item",function(m){var v=m.item,_=c._getMatchingItem(v);_&&c.world.removeItem(_)}),this.update(u.viewport)},t.extend(t.Navigator.prototype,t.EventSource.prototype,t.Viewer.prototype,{updateSize:function(){if(this.viewport){var h=new t.Point(this.container.clientWidth===0?1:this.container.clientWidth,this.container.clientHeight===0?1:this.container.clientHeight);h.equals(this.oldContainerSize)||(this.viewport.resize(h,!0),this.viewport.goHome(!0),this.oldContainerSize=h,this.world.update(),this.world.draw(),this.update(this.viewer.viewport))}},setWidth:function(h){this.width=h,this.element.style.width=typeof h=="number"?h+"px":h,this._resizeWithViewer=!1,this.updateSize()},setHeight:function(h){this.height=h,this.element.style.height=typeof h=="number"?h+"px":h,this._resizeWithViewer=!1,this.updateSize()},setFlip:function(h){return this.viewport.setFlip(h),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(h){l(this.canvas,h),l(this.element,h)},update:function(h){var u,c,d,f,p,g;if(h||(h=this.viewer.viewport),u=t.getElementSize(this.viewer.element),this._resizeWithViewer&&u.x&&u.y&&!u.equals(this.oldViewerSize)&&(this.oldViewerSize=u,this.maintainSizeRatio||!this.elementArea?(c=u.x*this.sizeRatio,d=u.y*this.sizeRatio):(c=Math.sqrt(this.elementArea*(u.x/u.y)),d=this.elementArea/c),this.element.style.width=Math.round(c)+"px",this.element.style.height=Math.round(d)+"px",this.elementArea||(this.elementArea=c*d),this.updateSize()),h&&this.viewport){if(f=h.getBoundsNoRotate(!0),p=this.viewport.pixelFromPointNoRotate(f.getTopLeft(),!1),g=this.viewport.pixelFromPointNoRotate(f.getBottomRight(),!1).minus(this.totalBorderWidths),!this.navigatorRotate){var m=h.getRotation(!0);a(this.displayRegion,-m)}var v=this.displayRegion.style;v.display=this.world.getItemCount()?"block":"none",v.top=p.y.toFixed(2)+"px",v.left=p.x.toFixed(2)+"px";var _=g.x-p.x,y=g.y-p.y;v.width=Math.round(Math.max(_,0))+"px",v.height=Math.round(Math.max(y,0))+"px"}},addTiledImage:function(h){var u=this,c=h.originalTiledImage;delete h.original;var d=t.extend({},h,{success:function(f){var p=f.item;p._originalForNavigator=c,u._matchBounds(p,c,!0),u._matchOpacity(p,c),u._matchCompositeOperation(p,c);function g(){u._matchBounds(p,c)}function m(){u._matchOpacity(p,c)}function v(){u._matchCompositeOperation(p,c)}c.addHandler("bounds-change",g),c.addHandler("clip-change",g),c.addHandler("opacity-change",m),c.addHandler("composite-operation-change",v)}});return t.Viewer.prototype.addTiledImage.apply(this,[d])},destroy:function(){return t.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(h){for(var u=this.world.getItemCount(),c,d=0;d<u;d++)if(c=this.world.getItemAt(d),c._originalForNavigator===h)return c;return null},_matchBounds:function(h,u,c){var d=u.getBoundsNoRotate();h.setPosition(d.getTopLeft(),c),h.setWidth(d.width,c),h.setRotation(u.getRotation(),c),h.setClip(u.getClip()),h.setFlip(u.getFlip())},_matchOpacity:function(h,u){h.setOpacity(u.opacity)},_matchCompositeOperation:function(h,u){h.setCompositeOperation(u.compositeOperation)}});function i(h){var u={tracker:h.eventSource,position:h.position,quick:h.quick,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",u),!u.preventDefaultAction&&h.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(h.position.x=this.viewport.getContainerSize().x-h.position.x);var c=this.viewport.pointFromPixel(h.position);this.panVertical?this.panHorizontal||(c.x=this.viewer.viewport.getCenter(!0).x):c.y=this.viewer.viewport.getCenter(!0).y,this.viewer.viewport.panTo(c),this.viewer.viewport.applyConstraints()}}function r(h){var u={tracker:h.eventSource,position:h.position,delta:h.delta,speed:h.speed,direction:h.direction,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",u),!u.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(h.delta.x=0),this.panVertical||(h.delta.y=0),this.viewer.viewport.flipped&&(h.delta.x=-h.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(h.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function s(h){h.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function o(h){var u={tracker:h.eventSource,position:h.position,scroll:h.scroll,shift:h.shift,originalEvent:h.originalEvent,preventDefault:h.preventDefault};this.viewer.raiseEvent("navigator-scroll",u),h.preventDefault=u.preventDefault}function a(h,u){l(h,"rotate("+u+"deg)")}function l(h,u){h.style.webkitTransform=u,h.style.mozTransform=u,h.style.msTransform=u,h.style.oTransform=u,h.style.transform=u}})(e),(function(t){var i={Errors:{Dzc:"Sorry, we don't support Deep Zoom Collections!",Dzi:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",Xml:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",ImageFormat:"Sorry, we don't support {0}-based Deep Zoom Images.",Security:"It looks like a security restriction stopped us from loading this Deep Zoom Image.",Status:"This space unintentionally left blank ({0} {1}).",OpenFailed:"Unable to open {0}: {1}"},Tooltips:{FullPage:"Toggle full page",Home:"Go home",ZoomIn:"Zoom in",ZoomOut:"Zoom out",NextPage:"Next page",PreviousPage:"Previous page",RotateLeft:"Rotate left",RotateRight:"Rotate right",Flip:"Flip Horizontally"}};t.extend(t,{getString:function(r){var s=r.split("."),o=null,a=arguments,l=i,h;for(h=0;h<s.length-1;h++)l=l[s[h]]||{};return o=l[s[h]],typeof o!="string"&&(t.console.error("Untranslated source string:",r),o=""),o.replace(/\{\d+\}/g,function(u){var c=parseInt(u.match(/\d+/),10)+1;return c<a.length?a[c]:""})},setString:function(r,s){var o=r.split("."),a=i,l;for(l=0;l<o.length-1;l++)a[o[l]]||(a[o[l]]={}),a=a[o[l]];a[o[l]]=s}})})(e),(function(t){t.Point=function(i,r){this.x=typeof i=="number"?i:0,this.y=typeof r=="number"?r:0},t.Point.prototype={clone:function(){return new t.Point(this.x,this.y)},plus:function(i){return new t.Point(this.x+i.x,this.y+i.y)},minus:function(i){return new t.Point(this.x-i.x,this.y-i.y)},times:function(i){return new t.Point(this.x*i,this.y*i)},divide:function(i){return new t.Point(this.x/i,this.y/i)},negate:function(){return new t.Point(-this.x,-this.y)},distanceTo:function(i){return Math.sqrt(Math.pow(this.x-i.x,2)+Math.pow(this.y-i.y,2))},squaredDistanceTo:function(i){return Math.pow(this.x-i.x,2)+Math.pow(this.y-i.y,2)},apply:function(i){return new t.Point(i(this.x),i(this.y))},equals:function(i){return i instanceof t.Point&&this.x===i.x&&this.y===i.y},rotate:function(i,r){r=r||new t.Point(0,0);var s,o;if(i%90===0){var a=t.positiveModulo(i,360);switch(a){case 0:s=1,o=0;break;case 90:s=0,o=1;break;case 180:s=-1,o=0;break;case 270:s=0,o=-1;break}}else{var l=i*Math.PI/180;s=Math.cos(l),o=Math.sin(l)}var h=s*(this.x-r.x)-o*(this.y-r.y)+r.x,u=o*(this.x-r.x)+s*(this.y-r.y)+r.y;return new t.Point(h,u)},toString:function(){return"("+Math.round(this.x*100)/100+","+Math.round(this.y*100)/100+")"}}})(e),(function(t){t.TileSource=function(r,s,o,a,l,h){var u=this,c=arguments,d,f;if(t.isPlainObject(r)?d=r:d={width:c[0],height:c[1],tileSize:c[2],tileOverlap:c[3],minLevel:c[4],maxLevel:c[5]},t.EventSource.call(this),t.extend(!0,this,d),!this.success){for(f=0;f<arguments.length;f++)if(t.isFunction(arguments[f])){this.success=arguments[f];break}}this.success&&this.addHandler("ready",function(p){u.success(p)}),t.type(arguments[0])==="string"&&(this.url=arguments[0]),this.url?(this.aspectRatio=1,this.dimensions=new t.Point(10,10),this._tileWidth=0,this._tileHeight=0,this.tileOverlap=0,this.minLevel=0,this.maxLevel=0,this.ready=!1,this.getImageInfo(this.url)):(this.ready=!0,this.aspectRatio=d.width&&d.height?d.width/d.height:1,this.dimensions=new t.Point(d.width,d.height),this.tileSize?(this._tileWidth=this._tileHeight=this.tileSize,delete this.tileSize):(this.tileWidth?(this._tileWidth=this.tileWidth,delete this.tileWidth):this._tileWidth=0,this.tileHeight?(this._tileHeight=this.tileHeight,delete this.tileHeight):this._tileHeight=0),this.tileOverlap=d.tileOverlap?d.tileOverlap:0,this.minLevel=d.minLevel?d.minLevel:0,this.maxLevel=d.maxLevel!==void 0&&d.maxLevel!==null?d.maxLevel:d.width&&d.height?Math.ceil(Math.log(Math.max(d.width,d.height))/Math.log(2)):0,this.success&&t.isFunction(this.success)&&this.success(this))},t.TileSource.prototype={getTileSize:function(r){return t.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),this._tileWidth},getTileWidth:function(r){return this._tileWidth?this._tileWidth:this.getTileSize(r)},getTileHeight:function(r){return this._tileHeight?this._tileHeight:this.getTileSize(r)},setMaxLevel:function(r){this.maxLevel=r,this._memoizeLevelScale()},getLevelScale:function(r){return this._memoizeLevelScale(),this.getLevelScale(r)},_memoizeLevelScale:function(){var r={},s;for(s=0;s<=this.maxLevel;s++)r[s]=1/Math.pow(2,this.maxLevel-s);this.getLevelScale=function(o){return r[o]}},getNumTiles:function(r){var s=this.getLevelScale(r),o=Math.ceil(s*this.dimensions.x/this.getTileWidth(r)),a=Math.ceil(s*this.dimensions.y/this.getTileHeight(r));return new t.Point(o,a)},getPixelRatio:function(r){var s=this.dimensions.times(this.getLevelScale(r)),o=1/s.x*t.pixelDensityRatio,a=1/s.y*t.pixelDensityRatio;return new t.Point(o,a)},getClosestLevel:function(){var r,s;for(r=this.minLevel+1;r<=this.maxLevel&&(s=this.getNumTiles(r),!(s.x>1||s.y>1));r++);return r-1},getTileAtPoint:function(r,s){var o=s.x>=0&&s.x<=1&&s.y>=0&&s.y<=1/this.aspectRatio;t.console.assert(o,"[TileSource.getTileAtPoint] must be called with a valid point.");var a=this.dimensions.x*this.getLevelScale(r),l=s.x*a,h=s.y*a,u=Math.floor(l/this.getTileWidth(r)),c=Math.floor(h/this.getTileHeight(r));s.x>=1&&(u=this.getNumTiles(r).x-1);var d=1e-15;return s.y>=1/this.aspectRatio-d&&(c=this.getNumTiles(r).y-1),new t.Point(u,c)},getTileBounds:function(r,s,o,a){var l=this.dimensions.times(this.getLevelScale(r)),h=this.getTileWidth(r),u=this.getTileHeight(r),c=s===0?0:h*s-this.tileOverlap,d=o===0?0:u*o-this.tileOverlap,f=h+(s===0?1:2)*this.tileOverlap,p=u+(o===0?1:2)*this.tileOverlap,g=1/l.x;return f=Math.min(f,l.x-c),p=Math.min(p,l.y-d),a?new t.Rect(0,0,f,p):new t.Rect(c*g,d*g,f*g,p*g)},getImageInfo:function(r){var s=this,o,a,l,h,u,c,d;r&&(u=r.split("/"),c=u[u.length-1],d=c.lastIndexOf("."),d>-1&&(u[u.length-1]=c.slice(0,d)));var f=null;if(this.splitHashDataForPost){var p=r.indexOf("#");p!==-1&&(f=r.substring(p+1),r=r.substr(0,p))}a=function(g){typeof g=="string"&&(g=t.parseXml(g));var m=t.TileSource.determineType(s,g,r);if(!m){s.raiseEvent("open-failed",{message:"Unable to load TileSource",source:r});return}h=m.prototype.configure.apply(s,[g,r,f]),h.ajaxWithCredentials===void 0&&(h.ajaxWithCredentials=s.ajaxWithCredentials),l=new m(h),s.ready=!0,s.raiseEvent("ready",{tileSource:l})},r.match(/\.js$/)?(o=r.split("/").pop().replace(".js",""),t.jsonp({url:r,async:!1,callbackName:o,callback:a})):t.makeAjaxRequest({url:r,postData:f,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(g){var m=i(g);a(m)},error:function(g,m){var v;try{v="HTTP "+g.status+" attempting to load TileSource: "+r}catch{var _;typeof m>"u"||!m.toString?_="Unknown error":_=m.toString(),v=_+" attempting to load TileSource: "+r}t.console.error(v),s.raiseEvent("open-failed",{message:v,source:r,postData:f})}})},supports:function(r,s){return!1},configure:function(r,s,o){throw new Error("Method not implemented.")},getTileUrl:function(r,s,o){throw new Error("Method not implemented.")},getTilePostData:function(r,s,o){return null},getTileAjaxHeaders:function(r,s,o){return{}},getTileHashKey:function(r,s,o,a,l,h){function u(c){return l?c+"+"+JSON.stringify(l):c}return u(typeof a!="string"?r+"/"+s+"_"+o:a)},tileExists:function(r,s,o){var a=this.getNumTiles(r);return r>=this.minLevel&&r<=this.maxLevel&&s>=0&&o>=0&&s<a.x&&o<a.y},hasTransparency:function(r,s,o,a){return!!r||s.match(".png")},downloadTileStart:function(r){var s=r.userData,o=new Image;s.image=o,s.request=null;var a=function(l){if(!o){r.finish(null,s.request,"Image load failed: undefined Image instance.");return}o.onload=o.onerror=o.onabort=null,r.finish(l?null:o,s.request,l)};o.onload=function(){a()},o.onabort=o.onerror=function(){a("Image load aborted.")},r.loadWithAjax?s.request=t.makeAjaxRequest({url:r.src,withCredentials:r.ajaxWithCredentials,headers:r.ajaxHeaders,responseType:"arraybuffer",postData:r.postData,success:function(l){var h;try{h=new window.Blob([l.response])}catch(d){var u=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(d.name==="TypeError"&&u){var c=new u;c.append(l.response),h=c.getBlob()}}h.size===0?a("Empty image response."):o.src=(window.URL||window.webkitURL).createObjectURL(h)},error:function(l){a("Image load aborted - XHR error")}}):(r.crossOriginPolicy!==!1&&(o.crossOrigin=r.crossOriginPolicy),o.src=r.src)},downloadTileAbort:function(r){r.userData.request&&r.userData.request.abort();var s=r.userData.image;r.userData.image&&(s.onload=s.onerror=s.onabort=null)},createTileCache:function(r,s,o){r._data=s},destroyTileCache:function(r){r._data=null,r._renderedContext=null},getTileCacheData:function(r){return r._data},getTileCacheDataAsImage:function(r){return r._data},getTileCacheDataAsContext2D:function(r){if(!r._renderedContext){var s=document.createElement("canvas");s.width=r._data.width,s.height=r._data.height,r._renderedContext=s.getContext("2d"),r._renderedContext.drawImage(r._data,0,0),r._data=null}return r._renderedContext}},t.extend(!0,t.TileSource.prototype,t.EventSource.prototype);function i(r){var s=r.responseText,o=r.status,a,l;if(r){if(r.status!==200&&r.status!==0)throw o=r.status,a=o===404?"Not Found":r.statusText,new Error(t.getString("Errors.Status",o,a))}else throw new Error(t.getString("Errors.Security"));if(s.match(/^\s*<.*/))try{l=r.responseXML&&r.responseXML.documentElement?r.responseXML:t.parseXml(s)}catch{l=r.responseText}else if(s.match(/\s*[{[].*/))try{l=t.parseJSON(s)}catch{l=s}else l=s;return l}t.TileSource.determineType=function(r,s,o){var a;for(a in e)if(a.match(/.+TileSource$/)&&t.isFunction(e[a])&&t.isFunction(e[a].prototype.supports)&&e[a].prototype.supports.call(r,s,o))return e[a];return t.console.error("No TileSource was able to open %s %s",o,s),null}})(e),(function(t){t.DziTileSource=function(s,o,a,l,h,u,c,d,f){var p,g,m,v;if(t.isPlainObject(s)?v=s:v={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4],fileFormat:arguments[5],displayRects:arguments[6],minLevel:arguments[7],maxLevel:arguments[8]},this._levelRects={},this.tilesUrl=v.tilesUrl,this.fileFormat=v.fileFormat,this.displayRects=v.displayRects,this.displayRects)for(p=this.displayRects.length-1;p>=0;p--)for(g=this.displayRects[p],m=g.minLevel;m<=g.maxLevel;m++)this._levelRects[m]||(this._levelRects[m]=[]),this._levelRects[m].push(g);t.TileSource.apply(this,[v])},t.extend(t.DziTileSource.prototype,t.TileSource.prototype,{supports:function(s,o){var a;return s.Image?a=s.Image.xmlns:s.documentElement&&(s.documentElement.localName==="Image"||s.documentElement.tagName==="Image")&&(a=s.documentElement.namespaceURI),a=(a||"").toLowerCase(),a.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||a.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(s,o,a){var l;return t.isPlainObject(s)?l=r(this,s):l=i(this,s),o&&!l.tilesUrl&&(l.tilesUrl=o.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/"),o.search(/\.(dzi|xml|js)\?/)!==-1?l.queryParams=o.match(/\?.*/):l.queryParams=""),l},getTileUrl:function(s,o,a){return[this.tilesUrl,s,"/",o,"_",a,".",this.fileFormat,this.queryParams].join("")},tileExists:function(s,o,a){var l=this._levelRects[s],h,u,c,d,f,p,g;if(this.minLevel&&s<this.minLevel||this.maxLevel&&s>this.maxLevel)return!1;if(!l||!l.length)return!0;for(g=l.length-1;g>=0;g--)if(h=l[g],!(s<h.minLevel||s>h.maxLevel)&&(u=this.getLevelScale(s),c=h.x*u,d=h.y*u,f=c+h.width*u,p=d+h.height*u,c=Math.floor(c/this._tileWidth),d=Math.floor(d/this._tileWidth),f=Math.ceil(f/this._tileWidth),p=Math.ceil(p/this._tileWidth),c<=o&&o<f&&d<=a&&a<p))return!0;return!1}});function i(s,o){if(!o||!o.documentElement)throw new Error(t.getString("Errors.Xml"));var a=o.documentElement,l=a.localName||a.tagName,h=o.documentElement.namespaceURI,u=null,c=[],d,f,p,g,m;if(l==="Image")try{if(g=a.getElementsByTagName("Size")[0],g===void 0&&(g=a.getElementsByTagNameNS(h,"Size")[0]),u={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:a.getAttribute("Url"),Format:a.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(a.getAttribute("Overlap"),10),TileSize:parseInt(a.getAttribute("TileSize"),10),Size:{Height:parseInt(g.getAttribute("Height"),10),Width:parseInt(g.getAttribute("Width"),10)}}},!t.imageFormatSupported(u.Image.Format))throw new Error(t.getString("Errors.ImageFormat",u.Image.Format.toUpperCase()));for(d=a.getElementsByTagName("DisplayRect"),d===void 0&&(d=a.getElementsByTagNameNS(h,"DisplayRect")[0]),m=0;m<d.length;m++)f=d[m],p=f.getElementsByTagName("Rect")[0],p===void 0&&(p=f.getElementsByTagNameNS(h,"Rect")[0]),c.push({Rect:{X:parseInt(p.getAttribute("X"),10),Y:parseInt(p.getAttribute("Y"),10),Width:parseInt(p.getAttribute("Width"),10),Height:parseInt(p.getAttribute("Height"),10),MinLevel:parseInt(f.getAttribute("MinLevel"),10),MaxLevel:parseInt(f.getAttribute("MaxLevel"),10)}});return c.length&&(u.Image.DisplayRect=c),r(s,u)}catch(y){throw y instanceof Error?y:new Error(t.getString("Errors.Dzi"))}else{if(l==="Collection")throw new Error(t.getString("Errors.Dzc"));if(l==="Error"){var v=a.getElementsByTagName("Message")[0],_=v.firstChild.nodeValue;throw new Error(_)}}throw new Error(t.getString("Errors.Dzi"))}function r(s,o){var a=o.Image,l=a.Url,h=a.Format,u=a.Size,c=a.DisplayRect||[],d=parseInt(u.Width,10),f=parseInt(u.Height,10),p=parseInt(a.TileSize,10),g=parseInt(a.Overlap,10),m=[],v,_;for(_=0;_<c.length;_++)v=c[_].Rect,m.push(new t.DisplayRect(parseInt(v.X,10),parseInt(v.Y,10),parseInt(v.Width,10),parseInt(v.Height,10),parseInt(v.MinLevel,10),parseInt(v.MaxLevel,10)));return t.extend(!0,{width:d,height:f,tileSize:p,tileOverlap:g,minLevel:null,maxLevel:null,tilesUrl:l,fileFormat:h,displayRects:m},o)}})(e),(function(t){t.IIIFTileSource=function(a){if(t.extend(!0,this,a),this._id=this["@id"]||this.id||this.identifier||null,!(this.height&&this.width&&this._id))throw new Error("IIIF required parameters (width, height, or id) not provided.");if(a.tileSizePerScaleFactor={},this.tileFormat=this.tileFormat||"jpg",this.version=a.version,this.tile_width&&this.tile_height)a.tileWidth=this.tile_width,a.tileHeight=this.tile_height;else if(this.tile_width)a.tileSize=this.tile_width;else if(this.tile_height)a.tileSize=this.tile_height;else if(this.tiles)if(this.tiles.length===1)a.tileWidth=this.tiles[0].width,a.tileHeight=this.tiles[0].height||this.tiles[0].width,this.scale_factors=this.tiles[0].scaleFactors;else{this.scale_factors=[];for(var l=0;l<this.tiles.length;l++)for(var h=0;h<this.tiles[l].scaleFactors.length;h++){var u=this.tiles[l].scaleFactors[h];this.scale_factors.push(u),a.tileSizePerScaleFactor[u]={width:this.tiles[l].width,height:this.tiles[l].height||this.tiles[l].width}}}else if(i(a)){for(var c=Math.min(this.height,this.width),d=[256,512,1024],f=[],p=0;p<d.length;p++)d[p]<=c&&f.push(d[p]);f.length>0?a.tileSize=Math.max.apply(null,f):a.tileSize=c}else this.sizes&&this.sizes.length>0?(this.emulateLegacyImagePyramid=!0,a.levels=r(this),t.extend(!0,a,{width:a.levels[a.levels.length-1].width,height:a.levels[a.levels.length-1].height,tileSize:Math.max(a.height,a.width),tileOverlap:0,minLevel:0,maxLevel:a.levels.length-1}),this.levels=a.levels):t.console.error("Nothing in the info.json to construct image pyramids from");if(!a.maxLevel&&!this.emulateLegacyImagePyramid)if(!this.scale_factors)a.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));else{var g=Math.max.apply(null,this.scale_factors);a.maxLevel=Math.round(Math.log(g)*Math.LOG2E)}if(this.sizes){var m=this.sizes.length;(m===a.maxLevel||m===a.maxLevel+1)&&(this.levelSizes=this.sizes.slice().sort((v,_)=>v.width-_.width),m===a.maxLevel&&this.levelSizes.push({width:this.width,height:this.height}))}t.TileSource.apply(this,[a])},t.extend(t.IIIFTileSource.prototype,t.TileSource.prototype,{supports:function(a,l){return a.protocol&&a.protocol==="http://iiif.io/api/image"||a["@context"]&&(a["@context"]==="http://library.stanford.edu/iiif/image-api/1.1/context.json"||a["@context"]==="http://iiif.io/api/image/1/context.json")||a.profile&&a.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")===0||a.identifier&&a.width&&a.height?!0:!!(a.documentElement&&a.documentElement.tagName==="info"&&a.documentElement.namespaceURI==="http://library.stanford.edu/iiif/image-api/ns/")},configure:function(a,l,h){if(t.isPlainObject(a)){if(!a["@context"])a["@context"]="http://iiif.io/api/image/1.0/context.json",a["@id"]=l.replace("/info.json",""),a.version=1;else{var c=a["@context"];if(Array.isArray(c)){for(var d=0;d<c.length;d++)if(typeof c[d]=="string"&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(c[d])||c[d]==="http://library.stanford.edu/iiif/image-api/1.1/context.json")){c=c[d];break}}switch(c){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":a.version=1;break;case"http://iiif.io/api/image/2/context.json":a.version=2;break;case"http://iiif.io/api/image/3/context.json":a.version=3;break;default:t.console.error("Data has a @context property which contains no known IIIF context URI.")}}if(a.preferredFormats){for(var f=0;f<a.preferredFormats.length;f++)if(e.imageFormatSupported(a.preferredFormats[f])){a.tileFormat=a.preferredFormats[f];break}}return a}else{var u=s(a);return u["@context"]="http://iiif.io/api/image/1.0/context.json",u["@id"]=l.replace("/info.xml",""),u.version=1,u}},getTileWidth:function(a){if(this.emulateLegacyImagePyramid)return t.TileSource.prototype.getTileWidth.call(this,a);var l=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[l]?this.tileSizePerScaleFactor[l].width:this._tileWidth},getTileHeight:function(a){if(this.emulateLegacyImagePyramid)return t.TileSource.prototype.getTileHeight.call(this,a);var l=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[l]?this.tileSizePerScaleFactor[l].height:this._tileHeight},getLevelScale:function(a){if(this.emulateLegacyImagePyramid){var l=NaN;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(l=this.levels[a].width/this.levels[this.maxLevel].width),l}return t.TileSource.prototype.getLevelScale.call(this,a)},getNumTiles:function(a){if(this.emulateLegacyImagePyramid){var l=this.getLevelScale(a);return l?new t.Point(1,1):new t.Point(0,0)}if(this.levelSizes){var h=this.levelSizes[a],u=Math.ceil(h.width/this.getTileWidth(a)),c=Math.ceil(h.height/this.getTileHeight(a));return new t.Point(u,c)}else return t.TileSource.prototype.getNumTiles.call(this,a)},getTileAtPoint:function(a,l){if(this.emulateLegacyImagePyramid)return new t.Point(0,0);if(this.levelSizes){var h=l.x>=0&&l.x<=1&&l.y>=0&&l.y<=1/this.aspectRatio;t.console.assert(h,"[TileSource.getTileAtPoint] must be called with a valid point.");var u=this.levelSizes[a].width,c=l.x*u,d=l.y*u,f=Math.floor(c/this.getTileWidth(a)),p=Math.floor(d/this.getTileHeight(a));l.x>=1&&(f=this.getNumTiles(a).x-1);var g=1e-15;return l.y>=1/this.aspectRatio-g&&(p=this.getNumTiles(a).y-1),new t.Point(f,p)}return t.TileSource.prototype.getTileAtPoint.call(this,a,l)},getTileUrl:function(a,l,h){if(this.emulateLegacyImagePyramid){var u=null;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(u=this.levels[a].url),u}var c="0",d=Math.pow(.5,this.maxLevel-a),f,p,g,m,v,_,y,w,R,M,C,O,N,X,q,L;return this.levelSizes?(f=this.levelSizes[a].width,p=this.levelSizes[a].height):(f=Math.ceil(this.width*d),p=Math.ceil(this.height*d)),g=this.getTileWidth(a),m=this.getTileHeight(a),v=Math.round(g/d),_=Math.round(m/d),this.version===1?q="native."+this.tileFormat:q="default."+this.tileFormat,f<g&&p<m?(this.version===2&&f===this.width?O="full":this.version===3&&f===this.width&&p===this.height?O="max":this.version===3?O=f+","+p:O=f+",",y="full"):(w=l*v,R=h*_,M=Math.min(v,this.width-w),C=Math.min(_,this.height-R),l===0&&h===0&&M===this.width&&C===this.height?y="full":y=[w,R,M,C].join(","),N=Math.min(g,f-l*g),X=Math.min(m,p-h*m),this.version===2&&N===this.width?O="full":this.version===3&&N===this.width&&X===this.height?O="max":this.version===3?O=N+","+X:O=N+","),L=[this._id,y,O,c,q].join("/"),L},__testonly__:{canBeTiled:i,constructLevels:r}});function i(a){var l=["http://library.stanford.edu/iiif/image-api/compliance.html#level0","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0","http://iiif.io/api/image/2/level0.json","level0","https://iiif.io/api/image/3/level0.json"],h=Array.isArray(a.profile)?a.profile[0]:a.profile,u=l.indexOf(h)!==-1,c=!1;return a.version===2&&a.profile.length>1&&a.profile[1].supports&&(c=a.profile[1].supports.indexOf("sizeByW")!==-1),a.version===3&&a.extraFeatures&&(c=a.extraFeatures.indexOf("sizeByWh")!==-1),!u||c}function r(a){for(var l=[],h=0;h<a.sizes.length;h++)l.push({url:a._id+"/full/"+a.sizes[h].width+","+(a.version===3?a.sizes[h].height:"")+"/0/default."+a.tileFormat,width:a.sizes[h].width,height:a.sizes[h].height});return l.sort(function(u,c){return u.width-c.width})}function s(a){if(!a||!a.documentElement)throw new Error(t.getString("Errors.Xml"));var l=a.documentElement,h=l.tagName,u=null;if(h==="info")try{return u={},o(l,u),u}catch(c){throw c instanceof Error?c:new Error(t.getString("Errors.IIIF"))}throw new Error(t.getString("Errors.IIIF"))}function o(a,l,h){var u,c;if(a.nodeType===3&&h)c=a.nodeValue.trim(),c.match(/^\d*$/)&&(c=Number(c)),l[h]?(t.isArray(l[h])||(l[h]=[l[h]]),l[h].push(c)):l[h]=c;else if(a.nodeType===1)for(u=0;u<a.childNodes.length;u++)o(a.childNodes[u],l,a.nodeName)}})(e),(function(t){t.OsmTileSource=function(i,r,s,o,a){var l;t.isPlainObject(i)?l=i:l={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]},(!l.width||!l.height)&&(l.width=65572864,l.height=65572864),l.tileSize||(l.tileSize=256,l.tileOverlap=0),l.tilesUrl||(l.tilesUrl="http://tile.openstreetmap.org/"),l.minLevel=8,t.TileSource.apply(this,[l])},t.extend(t.OsmTileSource.prototype,t.TileSource.prototype,{supports:function(i,r){return i.type&&i.type==="openstreetmaps"},configure:function(i,r,s){return i},getTileUrl:function(i,r,s){return this.tilesUrl+(i-8)+"/"+r+"/"+s+".png"}})})(e),(function(t){t.TmsTileSource=function(i,r,s,o,a){var l;t.isPlainObject(i)?l=i:l={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var h=Math.ceil(l.width/256)*256,u=Math.ceil(l.height/256)*256,c;h>u?c=h/256:c=u/256,l.maxLevel=Math.ceil(Math.log(c)/Math.log(2))-1,l.tileSize=256,l.width=h,l.height=u,t.TileSource.apply(this,[l])},t.extend(t.TmsTileSource.prototype,t.TileSource.prototype,{supports:function(i,r){return i.type&&i.type==="tiledmapservice"},configure:function(i,r,s){return i},getTileUrl:function(i,r,s){var o=this.getNumTiles(i).y-1;return this.tilesUrl+i+"/"+r+"/"+(o-s)+".png"}})})(e),(function(t){t.ZoomifyTileSource=function(i){typeof i.tileSize>"u"&&(i.tileSize=256),typeof i.fileFormat>"u"&&(i.fileFormat="jpg",this.fileFormat=i.fileFormat);var r={x:i.width,y:i.height};for(i.imageSizes=[{x:i.width,y:i.height}],i.gridSize=[this._getGridSize(i.width,i.height,i.tileSize)];parseInt(r.x,10)>i.tileSize||parseInt(r.y,10)>i.tileSize;)r.x=Math.floor(r.x/2),r.y=Math.floor(r.y/2),i.imageSizes.push({x:r.x,y:r.y}),i.gridSize.push(this._getGridSize(r.x,r.y,i.tileSize));i.imageSizes.reverse(),i.gridSize.reverse(),i.minLevel=0,i.maxLevel=i.gridSize.length-1,e.TileSource.apply(this,[i])},t.extend(t.ZoomifyTileSource.prototype,t.TileSource.prototype,{_getGridSize:function(i,r,s){return{x:Math.ceil(i/s),y:Math.ceil(r/s)}},_calculateAbsoluteTileNumber:function(i,r,s){for(var o=0,a={},l=0;l<i;l++)a=this.gridSize[l],o+=a.x*a.y;return a=this.gridSize[i],o+=a.x*s+r,o},supports:function(i,r){return i.type&&i.type==="zoomifytileservice"},configure:function(i,r,s){return i},getTileUrl:function(i,r,s){var o=0,a=this._calculateAbsoluteTileNumber(i,r,s);return o=Math.floor(a/256),this.tilesUrl+"TileGroup"+o+"/"+i+"-"+r+"-"+s+"."+this.fileFormat}})})(e),(function(t){t.LegacyTileSource=function(o){var a,l,h;t.isArray(o)&&(a={type:"legacy-image-pyramid",levels:o}),a.levels=i(a.levels),a.levels.length>0?(l=a.levels[a.levels.length-1].width,h=a.levels[a.levels.length-1].height):(l=0,h=0,t.console.error("No supported image formats found")),t.extend(!0,a,{width:l,height:h,tileSize:Math.max(h,l),tileOverlap:0,minLevel:0,maxLevel:a.levels.length>0?a.levels.length-1:0}),t.TileSource.apply(this,[a]),this.levels=a.levels},t.extend(t.LegacyTileSource.prototype,t.TileSource.prototype,{supports:function(o,a){return o.type&&o.type==="legacy-image-pyramid"||o.documentElement&&o.documentElement.getAttribute("type")==="legacy-image-pyramid"},configure:function(o,a,l){var h;return t.isPlainObject(o)?h=s(this,o):h=r(this,o),h},getLevelScale:function(o){var a=NaN;return this.levels.length>0&&o>=this.minLevel&&o<=this.maxLevel&&(a=this.levels[o].width/this.levels[this.maxLevel].width),a},getNumTiles:function(o){var a=this.getLevelScale(o);return a?new t.Point(1,1):new t.Point(0,0)},getTileUrl:function(o,a,l){var h=null;return this.levels.length>0&&o>=this.minLevel&&o<=this.maxLevel&&(h=this.levels[o].url),h}});function i(o){var a=[],l,h;for(h=0;h<o.length;h++)l=o[h],l.height&&l.width&&l.url?a.push({url:l.url,width:Number(l.width),height:Number(l.height)}):t.console.error("Unsupported image format: %s",l.url?l.url:"<no URL>");return a.sort(function(u,c){return u.height-c.height})}function r(o,a){if(!a||!a.documentElement)throw new Error(t.getString("Errors.Xml"));var l=a.documentElement,h=l.tagName,u=null,c=[],d,f;if(h==="image")try{for(u={type:l.getAttribute("type"),levels:[]},c=l.getElementsByTagName("level"),f=0;f<c.length;f++)d=c[f],u.levels.push({url:d.getAttribute("url"),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10)});return s(o,u)}catch(p){throw p instanceof Error?p:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if(h==="collection")throw new Error("Legacy Image Pyramid Collections not yet supported.");if(h==="error")throw new Error("Error: "+a)}throw new Error("Unknown element "+h)}function s(o,a){return a.levels}})(e),(function(t){t.ImageTileSource=function(i){i=t.extend({buildPyramid:!0,crossOriginPolicy:!1,ajaxWithCredentials:!1},i),t.TileSource.apply(this,[i])},t.extend(t.ImageTileSource.prototype,t.TileSource.prototype,{supports:function(i,r){return i.type&&i.type==="image"},configure:function(i,r,s){return i},getImageInfo:function(i){var r=this._image=new Image,s=this;this.crossOriginPolicy&&(r.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(r.useCredentials=this.ajaxWithCredentials),t.addEvent(r,"load",function(){s.width=r.naturalWidth,s.height=r.naturalHeight,s.aspectRatio=s.width/s.height,s.dimensions=new t.Point(s.width,s.height),s._tileWidth=s.width,s._tileHeight=s.height,s.tileOverlap=0,s.minLevel=0,s.levels=s._buildLevels(),s.maxLevel=s.levels.length-1,s.ready=!0,s.raiseEvent("ready",{tileSource:s})}),t.addEvent(r,"error",function(){s.raiseEvent("open-failed",{message:"Error loading image at "+i,source:i})}),r.src=i},getLevelScale:function(i){var r=NaN;return i>=this.minLevel&&i<=this.maxLevel&&(r=this.levels[i].width/this.levels[this.maxLevel].width),r},getNumTiles:function(i){var r=this.getLevelScale(i);return r?new t.Point(1,1):new t.Point(0,0)},getTileUrl:function(i,r,s){var o=null;return i>=this.minLevel&&i<=this.maxLevel&&(o=this.levels[i].url),o},getContext2D:function(i,r,s){var o=null;return i>=this.minLevel&&i<=this.maxLevel&&(o=this.levels[i].context2D),o},destroy:function(i){this._freeupCanvasMemory(i)},_buildLevels:function(){var i=[{url:this._image.src,width:this._image.naturalWidth,height:this._image.naturalHeight}];if(!this.buildPyramid||!t.supportsCanvas)return delete this._image,i;var r=this._image.naturalWidth,s=this._image.naturalHeight,o=document.createElement("canvas"),a=o.getContext("2d");if(o.width=r,o.height=s,a.drawImage(this._image,0,0,r,s),i[0].context2D=a,delete this._image,t.isCanvasTainted(o))return i;for(;r>=2&&s>=2;){r=Math.floor(r/2),s=Math.floor(s/2);var l=document.createElement("canvas"),h=l.getContext("2d");l.width=r,l.height=s,h.drawImage(o,0,0,r,s),i.splice(0,0,{context2D:h,width:r,height:s}),o=l,a=h}return i},_freeupCanvasMemory:function(i){for(var r=0;r<this.levels.length;r++)this.levels[r].context2D&&(this.levels[r].context2D.canvas.height=0,this.levels[r].context2D.canvas.width=0,i&&i.raiseEvent("image-unloaded",{context2D:this.levels[r].context2D}))}})})(e),(function(t){t.TileSourceCollection=function(i,r,s,o){t.console.error("TileSourceCollection is deprecated; use World instead")}})(e),(function(t){t.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},t.Button=function(h){var u=this;t.EventSource.call(this),t.extend(!0,this,{tooltip:null,srcRest:null,srcGroup:null,srcHover:null,srcDown:null,clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:t.DEFAULT_SETTINGS.clickDistThreshold,fadeDelay:0,fadeLength:2e3,onPress:null,onRelease:null,onClick:null,onEnter:null,onExit:null,onFocus:null,onBlur:null,userData:null},h),this.element=h.element||t.makeNeutralElement("div"),h.element||(this.imgRest=t.makeTransparentImage(this.srcRest),this.imgGroup=t.makeTransparentImage(this.srcGroup),this.imgHover=t.makeTransparentImage(this.srcHover),this.imgDown=t.makeTransparentImage(this.srcDown),this.imgRest.alt=this.imgGroup.alt=this.imgHover.alt=this.imgDown.alt=this.tooltip,t.setElementPointerEventsNone(this.imgRest),t.setElementPointerEventsNone(this.imgGroup),t.setElementPointerEventsNone(this.imgHover),t.setElementPointerEventsNone(this.imgDown),this.element.style.position="relative",t.setElementTouchActionNone(this.element),this.imgGroup.style.position=this.imgHover.style.position=this.imgDown.style.position="absolute",this.imgGroup.style.top=this.imgHover.style.top=this.imgDown.style.top="0px",this.imgGroup.style.left=this.imgHover.style.left=this.imgDown.style.left="0px",this.imgHover.style.visibility=this.imgDown.style.visibility="hidden",this.element.appendChild(this.imgRest),this.element.appendChild(this.imgGroup),this.element.appendChild(this.imgHover),this.element.appendChild(this.imgDown)),this.addHandler("press",this.onPress),this.addHandler("release",this.onRelease),this.addHandler("click",this.onClick),this.addHandler("enter",this.onEnter),this.addHandler("exit",this.onExit),this.addHandler("focus",this.onFocus),this.addHandler("blur",this.onBlur),this.currentState=t.ButtonState.GROUP,this.fadeBeginTime=null,this.shouldFade=!1,this.element.style.display="inline-block",this.element.style.position="relative",this.element.title=this.tooltip,this.tracker=new t.MouseTracker({userData:"Button.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(c){c.insideElementPressed?(a(u,t.ButtonState.DOWN),u.raiseEvent("enter",{originalEvent:c.originalEvent})):c.buttonDownAny||a(u,t.ButtonState.HOVER)},focusHandler:function(c){u.tracker.enterHandler(c),u.raiseEvent("focus",{originalEvent:c.originalEvent})},leaveHandler:function(c){l(u,t.ButtonState.GROUP),c.insideElementPressed&&u.raiseEvent("exit",{originalEvent:c.originalEvent})},blurHandler:function(c){u.tracker.leaveHandler(c),u.raiseEvent("blur",{originalEvent:c.originalEvent})},pressHandler:function(c){a(u,t.ButtonState.DOWN),u.raiseEvent("press",{originalEvent:c.originalEvent})},releaseHandler:function(c){c.insideElementPressed&&c.insideElementReleased?(l(u,t.ButtonState.HOVER),u.raiseEvent("release",{originalEvent:c.originalEvent})):c.insideElementPressed?l(u,t.ButtonState.GROUP):a(u,t.ButtonState.HOVER)},clickHandler:function(c){c.quick&&u.raiseEvent("click",{originalEvent:c.originalEvent})},keyHandler:function(c){c.keyCode===13?(u.raiseEvent("click",{originalEvent:c.originalEvent}),u.raiseEvent("release",{originalEvent:c.originalEvent}),c.preventDefault=!0):c.preventDefault=!1}}),l(this,t.ButtonState.REST)},t.extend(t.Button.prototype,t.EventSource.prototype,{notifyGroupEnter:function(){a(this,t.ButtonState.GROUP)},notifyGroupExit:function(){l(this,t.ButtonState.REST)},disable:function(){this.notifyGroupExit(),this.element.disabled=!0,this.tracker.setTracking(!1),t.setElementOpacity(this.element,.2,!0)},enable:function(){this.element.disabled=!1,this.tracker.setTracking(!0),t.setElementOpacity(this.element,1,!0),this.notifyGroupEnter()},destroy:function(){this.imgRest&&(this.element.removeChild(this.imgRest),this.imgRest=null),this.imgGroup&&(this.element.removeChild(this.imgGroup),this.imgGroup=null),this.imgHover&&(this.element.removeChild(this.imgHover),this.imgHover=null),this.imgDown&&(this.element.removeChild(this.imgDown),this.imgDown=null),this.removeAllHandlers(),this.tracker.destroy(),this.element=null}});function i(h){t.requestAnimationFrame(function(){r(h)})}function r(h){var u,c,d;h.shouldFade&&(u=t.now(),c=u-h.fadeBeginTime,d=1-c/h.fadeLength,d=Math.min(1,d),d=Math.max(0,d),h.imgGroup&&t.setElementOpacity(h.imgGroup,d,!0),d>0&&i(h))}function s(h){h.shouldFade=!0,h.fadeBeginTime=t.now()+h.fadeDelay,window.setTimeout(function(){i(h)},h.fadeDelay)}function o(h){h.shouldFade=!1,h.imgGroup&&t.setElementOpacity(h.imgGroup,1,!0)}function a(h,u){h.element.disabled||(u>=t.ButtonState.GROUP&&h.currentState===t.ButtonState.REST&&(o(h),h.currentState=t.ButtonState.GROUP),u>=t.ButtonState.HOVER&&h.currentState===t.ButtonState.GROUP&&(h.imgHover&&(h.imgHover.style.visibility=""),h.currentState=t.ButtonState.HOVER),u>=t.ButtonState.DOWN&&h.currentState===t.ButtonState.HOVER&&(h.imgDown&&(h.imgDown.style.visibility=""),h.currentState=t.ButtonState.DOWN))}function l(h,u){h.element.disabled||(u<=t.ButtonState.HOVER&&h.currentState===t.ButtonState.DOWN&&(h.imgDown&&(h.imgDown.style.visibility="hidden"),h.currentState=t.ButtonState.HOVER),u<=t.ButtonState.GROUP&&h.currentState===t.ButtonState.HOVER&&(h.imgHover&&(h.imgHover.style.visibility="hidden"),h.currentState=t.ButtonState.GROUP),u<=t.ButtonState.REST&&h.currentState===t.ButtonState.GROUP&&(s(h),h.currentState=t.ButtonState.REST))}})(e),(function(t){t.ButtonGroup=function(i){t.extend(!0,this,{buttons:[],clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:t.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},i);var r=this.buttons.concat([]),s=this,o;if(this.element=i.element||t.makeNeutralElement("div"),!i.group)for(this.element.style.display="inline-block",o=0;o<r.length;o++)this.element.appendChild(r[o].element);t.setElementTouchActionNone(this.element),this.tracker=new t.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(a){var l;for(l=0;l<s.buttons.length;l++)s.buttons[l].notifyGroupEnter()},leaveHandler:function(a){var l;if(!a.insideElementPressed)for(l=0;l<s.buttons.length;l++)s.buttons[l].notifyGroupExit()}})},t.ButtonGroup.prototype={addButton:function(i){this.buttons.push(i),this.element.appendChild(i.element)},emulateEnter:function(){this.tracker.enterHandler({eventSource:this.tracker})},emulateLeave:function(){this.tracker.leaveHandler({eventSource:this.tracker})},destroy:function(){for(;this.buttons.length;){var i=this.buttons.pop();this.element.removeChild(i.element),i.destroy()}this.tracker.destroy(),this.element=null}}})(e),(function(t){t.Rect=function(i,r,s,o,a){this.x=typeof i=="number"?i:0,this.y=typeof r=="number"?r:0,this.width=typeof s=="number"?s:0,this.height=typeof o=="number"?o:0,this.degrees=typeof a=="number"?a:0,this.degrees=t.positiveModulo(this.degrees,360);var l,h;this.degrees>=270?(l=this.getTopRight(),this.x=l.x,this.y=l.y,h=this.height,this.height=this.width,this.width=h,this.degrees-=270):this.degrees>=180?(l=this.getBottomRight(),this.x=l.x,this.y=l.y,this.degrees-=180):this.degrees>=90&&(l=this.getBottomLeft(),this.x=l.x,this.y=l.y,h=this.height,this.height=this.width,this.width=h,this.degrees-=90)},t.Rect.fromSummits=function(i,r,s){var o=i.distanceTo(r),a=i.distanceTo(s),l=r.minus(i),h=Math.atan(l.y/l.x);return l.x<0?h+=Math.PI:l.y<0&&(h+=2*Math.PI),new t.Rect(i.x,i.y,o,a,h/Math.PI*180)},t.Rect.prototype={clone:function(){return new t.Rect(this.x,this.y,this.width,this.height,this.degrees)},getAspectRatio:function(){return this.width/this.height},getTopLeft:function(){return new t.Point(this.x,this.y)},getBottomRight:function(){return new t.Point(this.x+this.width,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getTopRight:function(){return new t.Point(this.x+this.width,this.y).rotate(this.degrees,this.getTopLeft())},getBottomLeft:function(){return new t.Point(this.x,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getCenter:function(){return new t.Point(this.x+this.width/2,this.y+this.height/2).rotate(this.degrees,this.getTopLeft())},getSize:function(){return new t.Point(this.width,this.height)},equals:function(i){return i instanceof t.Rect&&this.x===i.x&&this.y===i.y&&this.width===i.width&&this.height===i.height&&this.degrees===i.degrees},times:function(i){return new t.Rect(this.x*i,this.y*i,this.width*i,this.height*i,this.degrees)},translate:function(i){return new t.Rect(this.x+i.x,this.y+i.y,this.width,this.height,this.degrees)},union:function(i){var r=this.getBoundingBox(),s=i.getBoundingBox(),o=Math.min(r.x,s.x),a=Math.min(r.y,s.y),l=Math.max(r.x+r.width,s.x+s.width),h=Math.max(r.y+r.height,s.y+s.height);return new t.Rect(o,a,l-o,h-a)},intersection:function(i){var r=1e-10,s=[],o=this.getTopLeft();i.containsPoint(o,r)&&s.push(o);var a=this.getTopRight();i.containsPoint(a,r)&&s.push(a);var l=this.getBottomLeft();i.containsPoint(l,r)&&s.push(l);var h=this.getBottomRight();i.containsPoint(h,r)&&s.push(h);var u=i.getTopLeft();this.containsPoint(u,r)&&s.push(u);var c=i.getTopRight();this.containsPoint(c,r)&&s.push(c);var d=i.getBottomLeft();this.containsPoint(d,r)&&s.push(d);var f=i.getBottomRight();this.containsPoint(f,r)&&s.push(f);for(var p=this._getSegments(),g=i._getSegments(),m=0;m<p.length;m++)for(var v=p[m],_=0;_<g.length;_++){var y=g[_],w=R(v[0],v[1],y[0],y[1]);w&&s.push(w)}function R(L,S,I,B){var j=S.minus(L),U=B.minus(I),W=-U.x*j.y+j.x*U.y;if(W===0)return null;var ee=(j.x*(L.y-I.y)-j.y*(L.x-I.x))/W,z=(U.x*(L.y-I.y)-U.y*(L.x-I.x))/W;return-r<=ee&&ee<=1-r&&-r<=z&&z<=1-r?new t.Point(L.x+z*j.x,L.y+z*j.y):null}if(s.length===0)return null;for(var M=s[0].x,C=s[0].x,O=s[0].y,N=s[0].y,X=1;X<s.length;X++){var q=s[X];q.x<M&&(M=q.x),q.x>C&&(C=q.x),q.y<O&&(O=q.y),q.y>N&&(N=q.y)}return new t.Rect(M,O,C-M,N-O)},_getSegments:function(){var i=this.getTopLeft(),r=this.getTopRight(),s=this.getBottomLeft(),o=this.getBottomRight();return[[i,r],[r,o],[o,s],[s,i]]},rotate:function(i,r){if(i=t.positiveModulo(i,360),i===0)return this.clone();r=r||this.getCenter();var s=this.getTopLeft().rotate(i,r),o=this.getTopRight().rotate(i,r),a=o.minus(s);a=a.apply(function(h){var u=1e-15;return Math.abs(h)<u?0:h});var l=Math.atan(a.y/a.x);return a.x<0?l+=Math.PI:a.y<0&&(l+=2*Math.PI),new t.Rect(s.x,s.y,this.width,this.height,l/Math.PI*180)},getBoundingBox:function(){if(this.degrees===0)return this.clone();var i=this.getTopLeft(),r=this.getTopRight(),s=this.getBottomLeft(),o=this.getBottomRight(),a=Math.min(i.x,r.x,s.x,o.x),l=Math.max(i.x,r.x,s.x,o.x),h=Math.min(i.y,r.y,s.y,o.y),u=Math.max(i.y,r.y,s.y,o.y);return new t.Rect(a,h,l-a,u-h)},getIntegerBoundingBox:function(){var i=this.getBoundingBox(),r=Math.floor(i.x),s=Math.floor(i.y),o=Math.ceil(i.width+i.x-r),a=Math.ceil(i.height+i.y-s);return new t.Rect(r,s,o,a)},containsPoint:function(i,r){r=r||0;var s=this.getTopLeft(),o=this.getTopRight(),a=this.getBottomLeft(),l=o.minus(s),h=a.minus(s);return(i.x-s.x)*l.x+(i.y-s.y)*l.y>=-r&&(i.x-o.x)*l.x+(i.y-o.y)*l.y<=r&&(i.x-s.x)*h.x+(i.y-s.y)*h.y>=-r&&(i.x-a.x)*h.x+(i.y-a.y)*h.y<=r},toString:function(){return"["+Math.round(this.x*100)/100+", "+Math.round(this.y*100)/100+", "+Math.round(this.width*100)/100+"x"+Math.round(this.height*100)/100+", "+Math.round(this.degrees*100)/100+"deg]"}}})(e),(function(t){var i={};t.ReferenceStrip=function(d){var f=this,p=d.viewer,g=t.getElementSize(p.element),m,v,_;for(d.id||(d.id="referencestrip-"+t.now(),this.element=t.makeNeutralElement("div"),this.element.id=d.id,this.element.className="referencestrip"),d=t.extend(!0,{sizeRatio:t.DEFAULT_SETTINGS.referenceStripSizeRatio,position:t.DEFAULT_SETTINGS.referenceStripPosition,scroll:t.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold},d,{element:this.element}),t.extend(this,d),i[this.id]={animating:!1},this.minPixelRatio=this.viewer.minPixelRatio,this.element.tabIndex=0,v=this.element.style,v.marginTop="0px",v.marginRight="0px",v.marginBottom="0px",v.marginLeft="0px",v.left="0px",v.bottom="0px",v.border="0px",v.background="#000",v.position="relative",t.setElementTouchActionNone(this.element),t.setElementOpacity(this.element,.8),this.viewer=p,this.tracker=new t.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:t.delegate(this,r),dragHandler:t.delegate(this,s),scrollHandler:t.delegate(this,o),enterHandler:t.delegate(this,l),leaveHandler:t.delegate(this,h),keyDownHandler:t.delegate(this,u),keyHandler:t.delegate(this,c),preProcessEventHandler:function(y){y.eventType==="wheel"&&(y.preventDefault=!0)}}),d.width&&d.height?(this.element.style.width=d.width+"px",this.element.style.height=d.height+"px",p.addControl(this.element,{anchor:t.ControlAnchor.BOTTOM_LEFT})):d.scroll==="horizontal"?(this.element.style.width=g.x*d.sizeRatio*p.tileSources.length+12*p.tileSources.length+"px",this.element.style.height=g.y*d.sizeRatio+"px",p.addControl(this.element,{anchor:t.ControlAnchor.BOTTOM_LEFT})):(this.element.style.height=g.y*d.sizeRatio*p.tileSources.length+12*p.tileSources.length+"px",this.element.style.width=g.x*d.sizeRatio+"px",p.addControl(this.element,{anchor:t.ControlAnchor.TOP_LEFT})),this.panelWidth=g.x*this.sizeRatio+8,this.panelHeight=g.y*this.sizeRatio+8,this.panels=[],this.miniViewers={},_=0;_<p.tileSources.length;_++)m=t.makeNeutralElement("div"),m.id=this.element.id+"-"+_,m.style.width=f.panelWidth+"px",m.style.height=f.panelHeight+"px",m.style.display="inline",m.style.float="left",m.style.cssFloat="left",m.style.padding="2px",t.setElementTouchActionNone(m),t.setElementPointerEventsNone(m),this.element.appendChild(m),m.activePanel=!1,this.panels.push(m);a(this,this.scroll==="vertical"?g.y:g.x,0),this.setFocus(0)},t.ReferenceStrip.prototype={setFocus:function(d){var f=this.element.querySelector("#"+this.element.id+"-"+d),p=t.getElementSize(this.viewer.canvas),g=Number(this.element.style.width.replace("px","")),m=Number(this.element.style.height.replace("px","")),v=-Number(this.element.style.marginLeft.replace("px","")),_=-Number(this.element.style.marginTop.replace("px","")),y;this.currentSelected!==f&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=f,this.currentSelected.style.background="#999",this.scroll==="horizontal"?(y=Number(d)*(this.panelWidth+3),y>v+p.x-this.panelWidth?(y=Math.min(y,g-p.x),this.element.style.marginLeft=-y+"px",a(this,p.x,-y)):y<v&&(y=Math.max(0,y-p.x/2),this.element.style.marginLeft=-y+"px",a(this,p.x,-y))):(y=Number(d)*(this.panelHeight+3),y>_+p.y-this.panelHeight?(y=Math.min(y,m-p.y),this.element.style.marginTop=-y+"px",a(this,p.y,-y)):y<_&&(y=Math.max(0,y-p.y/2),this.element.style.marginTop=-y+"px",a(this,p.y,-y))),this.currentPage=d,l.call(this,{eventSource:this.tracker}))},update:function(){return!!i[this.id].animating},destroy:function(){if(this.miniViewers)for(var d in this.miniViewers)this.miniViewers[d].destroy();this.tracker.destroy(),this.element&&this.viewer.removeControl(this.element)}};function r(d){if(d.quick){var f;this.scroll==="horizontal"?f=Math.floor(d.position.x/(this.panelWidth+4)):f=Math.floor(d.position.y/this.panelHeight),this.viewer.goToPage(f)}this.element.focus()}function s(d){if(this.dragging=!0,this.element){var f=Number(this.element.style.marginLeft.replace("px","")),p=Number(this.element.style.marginTop.replace("px","")),g=Number(this.element.style.width.replace("px","")),m=Number(this.element.style.height.replace("px","")),v=t.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?-d.delta.x>0?f>-(g-v.x)&&(this.element.style.marginLeft=f+d.delta.x*2+"px",a(this,v.x,f+d.delta.x*2)):-d.delta.x<0&&f<0&&(this.element.style.marginLeft=f+d.delta.x*2+"px",a(this,v.x,f+d.delta.x*2)):-d.delta.y>0?p>-(m-v.y)&&(this.element.style.marginTop=p+d.delta.y*2+"px",a(this,v.y,p+d.delta.y*2)):-d.delta.y<0&&p<0&&(this.element.style.marginTop=p+d.delta.y*2+"px",a(this,v.y,p+d.delta.y*2))}}function o(d){if(this.element){var f=Number(this.element.style.marginLeft.replace("px","")),p=Number(this.element.style.marginTop.replace("px","")),g=Number(this.element.style.width.replace("px","")),m=Number(this.element.style.height.replace("px","")),v=t.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?d.scroll>0?f>-(g-v.x)&&(this.element.style.marginLeft=f-d.scroll*60+"px",a(this,v.x,f-d.scroll*60)):d.scroll<0&&f<0&&(this.element.style.marginLeft=f-d.scroll*60+"px",a(this,v.x,f-d.scroll*60)):d.scroll<0?p>v.y-m&&(this.element.style.marginTop=p+d.scroll*60+"px",a(this,v.y,p+d.scroll*60)):d.scroll>0&&p<0&&(this.element.style.marginTop=p+d.scroll*60+"px",a(this,v.y,p+d.scroll*60)),d.preventDefault=!0}}function a(d,f,p){var g,m,v,_,y,w;for(d.scroll==="horizontal"?g=d.panelWidth:g=d.panelHeight,m=Math.ceil(f/g)+5,v=Math.ceil((Math.abs(p)+f)/g)+1,m=v-m,m=m<0?0:m,y=m;y<v&&y<d.panels.length;y++)if(w=d.panels[y],!w.activePanel){var R,M=d.viewer.tileSources[y];M.referenceStripThumbnailUrl?R={type:"image",url:M.referenceStripThumbnailUrl}:R=M,_=new t.Viewer({id:w.id,tileSources:[R],element:w,navigatorSizeRatio:d.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,loadTilesWithAjax:d.viewer.loadTilesWithAjax,ajaxHeaders:d.viewer.ajaxHeaders,drawer:"canvas"}),t.setElementPointerEventsNone(_.canvas),t.setElementPointerEventsNone(_.container),_.innerTracker.setTracking(!1),_.outerTracker.setTracking(!1),d.miniViewers[w.id]=_,w.activePanel=!0}}function l(d){var f=d.eventSource.element;this.scroll==="horizontal"?f.style.marginBottom="0px":f.style.marginLeft="0px"}function h(d){var f=d.eventSource.element;this.scroll==="horizontal"?f.style.marginBottom="-"+t.getElementSize(f).y/2+"px":f.style.marginLeft="-"+t.getElementSize(f).x/2+"px"}function u(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 38:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 40:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 37:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 39:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}function c(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 61:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 45:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 48:case 119:case 87:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 115:case 83:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 97:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 100:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}})(e),(function(t){t.DisplayRect=function(i,r,s,o,a,l){t.Rect.apply(this,[i,r,s,o]),this.minLevel=a,this.maxLevel=l},t.extend(t.DisplayRect.prototype,t.Rect.prototype)})(e),(function(t){t.Spring=function(r){var s=arguments;typeof r!="object"&&(r={initial:s.length&&typeof s[0]=="number"?s[0]:void 0,springStiffness:s.length>1?s[1].springStiffness:5,animationTime:s.length>1?s[1].animationTime:1.5}),t.console.assert(typeof r.springStiffness=="number"&&r.springStiffness!==0,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number"),t.console.assert(typeof r.animationTime=="number"&&r.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0"),r.exponential&&(this._exponential=!0,delete r.exponential),t.extend(!0,this,r),this.current={value:typeof this.initial=="number"?this.initial:this._exponential?0:1,time:t.now()},t.console.assert(!this._exponential||this.current.value!==0,"[OpenSeadragon.Spring] value must be non-zero for exponential springs"),this.start={value:this.current.value,time:this.current.time},this.target={value:this.current.value,time:this.current.time},this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},t.Spring.prototype={resetTo:function(r){t.console.assert(!this._exponential||r!==0,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs"),this.start.value=this.target.value=this.current.value=r,this.start.time=this.target.time=this.current.time=t.now(),this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},springTo:function(r){t.console.assert(!this._exponential||r!==0,"[OpenSeadragon.Spring.springTo] target must be non-zero for exponential springs"),this.start.value=this.current.value,this.start.time=this.current.time,this.target.value=r,this.target.time=this.start.time+1e3*this.animationTime,this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value))},shiftBy:function(r){this.start.value+=r,this.target.value+=r,this._exponential&&(t.console.assert(this.target.value!==0&&this.start.value!==0,"[OpenSeadragon.Spring.shiftBy] spring value must be non-zero for exponential springs"),this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value))},setExponential:function(r){this._exponential=r,this._exponential&&(t.console.assert(this.current.value!==0&&this.target.value!==0&&this.start.value!==0,"[OpenSeadragon.Spring.setExponential] spring value must be non-zero for exponential springs"),this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},update:function(){this.current.time=t.now();let r,s;if(this._exponential?(r=this.start._logValue,s=this.target._logValue):(r=this.start.value,s=this.target.value),this.current.time>=this.target.time)this.current.value=this.target.value;else{let o=r+(s-r)*i(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time));this._exponential?this.current.value=Math.exp(o):this.current.value=o}return this.current.value!==this.target.value},isAtTargetValue:function(){return this.current.value===this.target.value}};function i(r,s){return(1-Math.exp(r*-s))/(1-Math.exp(-r))}})(e),(function(t){t.ImageJob=function(r){t.extend(!0,this,{timeout:t.DEFAULT_SETTINGS.timeout,jobId:null,tries:0},r),this.data=null,this.userData={},this.errorMsg=null},t.ImageJob.prototype={start:function(){this.tries++;var r=this,s=this.abort;this.jobId=window.setTimeout(function(){r.finish(null,null,"Image load exceeded timeout ("+r.timeout+" ms)")},this.timeout),this.abort=function(){r.source.downloadTileAbort(r),typeof s=="function"&&s()},this.source.downloadTileStart(this)},finish:function(r,s,o){this.data=r,this.request=s,this.errorMsg=o,this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},t.ImageLoader=function(r){t.extend(!0,this,{jobLimit:t.DEFAULT_SETTINGS.imageLoaderLimit,timeout:t.DEFAULT_SETTINGS.timeout,jobQueue:[],failedTiles:[],jobsInProgress:0},r)},t.ImageLoader.prototype={addJob:function(r){if(!r.source){t.console.error("ImageLoader.prototype.addJob() requires [options.source]. TileSource since new API defines how images are fetched. Creating a dummy TileSource.");var s=t.TileSource.prototype;r.source={downloadTileStart:s.downloadTileStart,downloadTileAbort:s.downloadTileAbort}}var o=this,a=function(u){i(o,u,r.callback)},l={src:r.src,tile:r.tile||{},source:r.source,loadWithAjax:r.loadWithAjax,ajaxHeaders:r.loadWithAjax?r.ajaxHeaders:null,crossOriginPolicy:r.crossOriginPolicy,ajaxWithCredentials:r.ajaxWithCredentials,postData:r.postData,callback:a,abort:r.abort,timeout:this.timeout},h=new t.ImageJob(l);!this.jobLimit||this.jobsInProgress<this.jobLimit?(h.start(),this.jobsInProgress++):this.jobQueue.push(h)},clear:function(){for(var r=0;r<this.jobQueue.length;r++){var s=this.jobQueue[r];typeof s.abort=="function"&&s.abort()}this.jobQueue=[]}};function i(r,s,o){s.errorMsg!==""&&(s.data===null||s.data===void 0)&&s.tries<1+r.tileRetryMax&&r.failedTiles.push(s);var a;r.jobsInProgress--,(!r.jobLimit||r.jobsInProgress<r.jobLimit)&&r.jobQueue.length>0&&(a=r.jobQueue.shift(),a.start(),r.jobsInProgress++),r.tileRetryMax>0&&r.jobQueue.length===0&&(!r.jobLimit||r.jobsInProgress<r.jobLimit)&&r.failedTiles.length>0&&(a=r.failedTiles.shift(),setTimeout(function(){a.start()},r.tileRetryDelay),r.jobsInProgress++),o(s.data,s.errorMsg,s.request)}})(e),(function(t){t.Tile=function(i,r,s,o,a,l,h,u,c,d,f,p){this.level=i,this.x=r,this.y=s,this.bounds=o,this.positionedBounds=new e.Rect(o.x,o.y,o.width,o.height),this.sourceBounds=d,this.exists=a,this._url=l,this.postData=f,this.context2D=h,this.loadWithAjax=u,this.ajaxHeaders=c,p===void 0&&(t.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."),p=t.TileSource.prototype.getTileHashKey(i,r,s,l,c,f)),this.cacheKey=p,this.loaded=!1,this.loading=!1,this.element=null,this.imgElement=null,this.style=null,this.position=null,this.size=null,this.flipped=!1,this.blendStart=null,this.opacity=null,this.squaredDistance=null,this.visibility=null,this.hasTransparency=!1,this.beingDrawn=!1,this.lastTouchTime=0,this.isRightMost=!1,this.isBottomMost=!1},t.Tile.prototype={toString:function(){return this.level+"/"+this.x+"_"+this.y},_hasTransparencyChannel:function(){return console.warn("Tile.prototype._hasTransparencyChannel() has been deprecated and will be removed in the future. Use TileSource.prototype.hasTransparency() instead."),!!this.context2D||this.getUrl().match(".png")},get image(){return t.console.error("[Tile.image] property has been deprecated. Use [Tile.prototype.getImage] instead."),this.getImage()},get url(){return t.console.error("[Tile.url] property has been deprecated. Use [Tile.prototype.getUrl] instead."),this.getUrl()},getImage:function(){return this.cacheImageRecord.getImage()},getUrl:function(){return typeof this._url=="function"?this._url():this._url},getCanvasContext:function(){return this.context2D||this.cacheImageRecord&&this.cacheImageRecord.getRenderedContext()},getScaleForEdgeSmoothing:function(){var i;if(this.cacheImageRecord)i=this.cacheImageRecord.getRenderedContext();else if(this.context2D)i=this.context2D;else return t.console.warn("[Tile.drawCanvas] attempting to get tile scale %s when tile's not cached",this.toString()),1;return i.canvas.width/(this.size.x*t.pixelDensityRatio)},getTranslationForEdgeSmoothing:function(i,r,s){var o=Math.max(1,Math.ceil((s.x-r.x)/2)),a=Math.max(1,Math.ceil((s.y-r.y)/2));return new t.Point(o,a).minus(this.position.times(t.pixelDensityRatio).times(i||1).apply(function(l){return l%1}))},unload:function(){this.imgElement&&this.imgElement.parentNode&&this.imgElement.parentNode.removeChild(this.imgElement),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.imgElement=null,this.loaded=!1,this.loading=!1}}})(e),(function(t){t.OverlayPlacement=t.Placement,t.OverlayRotationMode=t.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),t.Overlay=function(i,r,s){var o;t.isPlainObject(i)?o=i:o={element:i,location:r,placement:s},this.elementWrapper=document.createElement("div"),this.element=o.element,this.elementWrapper.appendChild(this.element),this.element.id?this.elementWrapper.id="overlay-wrapper-"+this.element.id:this.elementWrapper.id="overlay-wrapper",this.style=this.elementWrapper.style,this._init(o)},t.Overlay.prototype={_init:function(i){this.location=i.location,this.placement=i.placement===void 0?t.Placement.TOP_LEFT:i.placement,this.onDraw=i.onDraw,this.checkResize=i.checkResize===void 0?!0:i.checkResize,this.width=i.width===void 0?null:i.width,this.height=i.height===void 0?null:i.height,this.rotationMode=i.rotationMode||t.OverlayRotationMode.EXACT,this.location instanceof t.Rect&&(this.width=this.location.width,this.height=this.location.height,this.location=this.location.getTopLeft(),this.placement=t.Placement.TOP_LEFT),this.scales=this.width!==null&&this.height!==null,this.bounds=new t.Rect(this.location.x,this.location.y,this.width,this.height),this.position=this.location},adjust:function(i,r){var s=t.Placement.properties[this.placement];s&&(s.isHorizontallyCentered?i.x-=r.x/2:s.isRight&&(i.x-=r.x),s.isVerticallyCentered?i.y-=r.y/2:s.isBottom&&(i.y-=r.y))},destroy:function(){var i=this.elementWrapper,r=this.style;i.parentNode&&(i.parentNode.removeChild(i),i.prevElementParent&&(r.display="none",document.body.appendChild(i))),this.onDraw=null,r.top="",r.left="",r.position="",this.width!==null&&(r.width=""),this.height!==null&&(r.height="");var s=t.getCssPropertyWithVendorPrefix("transformOrigin"),o=t.getCssPropertyWithVendorPrefix("transform");s&&o&&(r[s]="",r[o]="")},drawHTML:function(i,r){var s=this.elementWrapper;s.parentNode!==i&&(s.prevElementParent=s.parentNode,s.prevNextSibling=s.nextSibling,i.appendChild(s),this.style.position="absolute",this.size=t.getElementSize(this.elementWrapper));var o=this._getOverlayPositionAndSize(r),a=o.position,l=this.size=o.size,h="";r.overlayPreserveContentDirection&&(h=r.flipped?" scaleX(-1)":" scaleX(1)");var u=r.flipped?-o.rotate:o.rotate,c=r.flipped?" scaleX(-1)":"";if(this.onDraw)this.onDraw(a,l,this.element);else{var d=this.style,f=this.element.style;f.display="block",d.left=a.x+"px",d.top=a.y+"px",this.width!==null&&(f.width=l.x+"px"),this.height!==null&&(f.height=l.y+"px");var p=t.getCssPropertyWithVendorPrefix("transformOrigin"),g=t.getCssPropertyWithVendorPrefix("transform");p&&g&&(u&&!r.flipped?(f[g]="",d[p]=this._getTransformOrigin(),d[g]="rotate("+u+"deg)"):!u&&r.flipped?(f[g]=h,d[p]=this._getTransformOrigin(),d[g]=c):u&&r.flipped?(f[g]=h,d[p]=this._getTransformOrigin(),d[g]="rotate("+u+"deg)"+c):(f[g]="",d[p]="",d[g]="")),d.display="flex"}},_getOverlayPositionAndSize:function(i){var r=i.pixelFromPoint(this.location,!0),s=this._getSizeInPixels(i);this.adjust(r,s);var o=0;if(i.getRotation(!0)&&this.rotationMode!==t.OverlayRotationMode.NO_ROTATION)if(this.rotationMode===t.OverlayRotationMode.BOUNDING_BOX&&this.width!==null&&this.height!==null){var a=new t.Rect(r.x,r.y,s.x,s.y),l=this._getBoundingBox(a,i.getRotation(!0));r=l.getTopLeft(),s=l.getSize()}else o=i.getRotation(!0);return i.flipped&&(r.x=i.getContainerSize().x-r.x),{position:r,size:s,rotate:o}},_getSizeInPixels:function(i){var r=this.size.x,s=this.size.y;if(this.width!==null||this.height!==null){var o=i.deltaPixelsFromPointsNoRotate(new t.Point(this.width||0,this.height||0),!0);this.width!==null&&(r=o.x),this.height!==null&&(s=o.y)}if(this.checkResize&&(this.width===null||this.height===null)){var a=this.size=t.getElementSize(this.elementWrapper);this.width===null&&(r=a.x),this.height===null&&(s=a.y)}return new t.Point(r,s)},_getBoundingBox:function(i,r){var s=this._getPlacementPoint(i);return i.rotate(r,s).getBoundingBox()},_getPlacementPoint:function(i){var r=new t.Point(i.x,i.y),s=t.Placement.properties[this.placement];return s&&(s.isHorizontallyCentered?r.x+=i.width/2:s.isRight&&(r.x+=i.width),s.isVerticallyCentered?r.y+=i.height/2:s.isBottom&&(r.y+=i.height)),r},_getTransformOrigin:function(){var i="",r=t.Placement.properties[this.placement];return r&&(r.isLeft?i="left":r.isRight&&(i="right"),r.isTop?i+=" top":r.isBottom&&(i+=" bottom")),i},update:function(i,r){var s=t.isPlainObject(i)?i:{location:i,placement:r};this._init({location:s.location||this.location,placement:s.placement!==void 0?s.placement:this.placement,onDraw:s.onDraw||this.onDraw,checkResize:s.checkResize||this.checkResize,width:s.width!==void 0?s.width:this.width,height:s.height!==void 0?s.height:this.height,rotationMode:s.rotationMode||this.rotationMode})},getBounds:function(i){t.console.assert(i,"A viewport must now be passed to Overlay.getBounds.");var r=this.width,s=this.height;if(r===null||s===null){var o=i.deltaPointsFromPixelsNoRotate(this.size,!0);r===null&&(r=o.x),s===null&&(s=o.y)}var a=this.location.clone();return this.adjust(a,new t.Point(r,s)),this._adjustBoundsForRotation(i,new t.Rect(a.x,a.y,r,s))},_adjustBoundsForRotation:function(i,r){if(!i||i.getRotation(!0)===0||this.rotationMode===t.OverlayRotationMode.EXACT)return r;if(this.rotationMode===t.OverlayRotationMode.BOUNDING_BOX){if(this.width===null||this.height===null)return r;var s=this._getOverlayPositionAndSize(i);return i.viewerElementToViewportRectangle(new t.Rect(s.position.x,s.position.y,s.size.x,s.size.y))}return r.rotate(-i.getRotation(!0),this._getPlacementPoint(r))}}})(e),(function(t){const i=t;i.DrawerBase=class{constructor(s){t.console.assert(s.viewer,"[Drawer] options.viewer is required"),t.console.assert(s.viewport,"[Drawer] options.viewport is required"),t.console.assert(s.element,"[Drawer] options.element is required"),this.viewer=s.viewer,this.viewport=s.viewport,this.debugGridColor=typeof s.debugGridColor=="string"?[s.debugGridColor]:s.debugGridColor||t.DEFAULT_SETTINGS.debugGridColor,this.options=s.options||{},this.container=t.getElement(s.element),this._renderingTarget=this._createDrawingElement(),this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.position="absolute",this.canvas.style.left="0",t.setElementOpacity(this.canvas,this.viewer.opacity,!0),t.setElementPointerEventsNone(this.canvas),t.setElementTouchActionNone(this.canvas),this.container.style.textAlign="left",this.container.appendChild(this.canvas),this._checkForAPIOverrides()}get canvas(){return this._renderingTarget}get element(){return t.console.error("Drawer.element is deprecated. Use Drawer.container instead."),this.container}getType(){t.console.error("Drawer.getType must be implemented by child class")}static isSupported(){t.console.error("Drawer.isSupported must be implemented by child class")}_createDrawingElement(){return t.console.error("Drawer._createDrawingElement must be implemented by child class"),null}draw(s){t.console.error("Drawer.draw must be implemented by child class")}canRotate(){t.console.error("Drawer.canRotate must be implemented by child class")}destroy(){t.console.error("Drawer.destroy must be implemented by child class")}minimumOverlapRequired(s){return!1}setImageSmoothingEnabled(s){t.console.error("Drawer.setImageSmoothingEnabled must be implemented by child class")}drawDebuggingRect(s){t.console.warn("[drawer].drawDebuggingRect is not implemented by this drawer")}clear(){t.console.warn("[drawer].clear() is deprecated. The drawer is responsible for clearing itself as needed before drawing tiles.")}_checkForAPIOverrides(){if(this._createDrawingElement===t.DrawerBase.prototype._createDrawingElement)throw new Error("[drawer]._createDrawingElement must be implemented by child class");if(this.draw===t.DrawerBase.prototype.draw)throw new Error("[drawer].draw must be implemented by child class");if(this.canRotate===t.DrawerBase.prototype.canRotate)throw new Error("[drawer].canRotate must be implemented by child class");if(this.destroy===t.DrawerBase.prototype.destroy)throw new Error("[drawer].destroy must be implemented by child class");if(this.setImageSmoothingEnabled===t.DrawerBase.prototype.setImageSmoothingEnabled)throw new Error("[drawer].setImageSmoothingEnabled must be implemented by child class")}viewportToDrawerRectangle(s){var o=this.viewport.pixelFromPointNoRotate(s.getTopLeft(),!0),a=this.viewport.deltaPixelsFromPointsNoRotate(s.getSize(),!0);return new t.Rect(o.x*t.pixelDensityRatio,o.y*t.pixelDensityRatio,a.x*t.pixelDensityRatio,a.y*t.pixelDensityRatio)}viewportCoordToDrawerCoord(s){var o=this.viewport.pixelFromPointNoRotate(s,!0);return new t.Point(o.x*t.pixelDensityRatio,o.y*t.pixelDensityRatio)}_calculateCanvasSize(){var s=t.pixelDensityRatio,o=this.viewport.getContainerSize();return new i.Point(Math.round(o.x*s),Math.round(o.y*s))}_raiseTiledImageDrawnEvent(s,o){this.viewer&&this.viewer.raiseEvent("tiled-image-drawn",{tiledImage:s,tiles:o})}_raiseDrawerErrorEvent(s,o){this.viewer&&this.viewer.raiseEvent("drawer-error",{tiledImage:s,drawer:this,error:o})}}})(e),(function(t){const i=t;class r extends i.DrawerBase{constructor(o){super(o),this.viewer.rejectEventHandler("tile-drawing","The HTMLDrawer does not raise the tile-drawing event"),this.viewer.allowEventHandler("tile-drawn")}static isSupported(){return!0}getType(){return"html"}minimumOverlapRequired(o){return!0}_createDrawingElement(){return t.makeNeutralElement("div")}draw(o){var a=this;this._prepareNewFrame(),o.forEach(function(l){l.opacity!==0&&a._drawTiles(l)})}canRotate(){return!1}destroy(){this.container.removeChild(this.canvas)}setImageSmoothingEnabled(){}_prepareNewFrame(){this.canvas.innerHTML=""}_drawTiles(o){var a=o.getTilesToDraw().map(u=>u.tile);if(!(o.opacity===0||a.length===0&&!o.placeholderFillStyle))for(var l=a.length-1;l>=0;l--){var h=a[l];this._drawTile(h),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:o,tile:h})}}_drawTile(o){t.console.assert(o,"[Drawer._drawTile] tile is required");let a=this.canvas;if(!o.cacheImageRecord){t.console.warn("[Drawer._drawTileToHTML] attempting to draw tile %s when it's not cached",o.toString());return}if(!o.loaded){t.console.warn("Attempting to draw tile %s when it's not yet loaded.",o.toString());return}if(!o.element){var l=o.getImage();if(!l)return;o.element=t.makeNeutralElement("div"),o.imgElement=l.cloneNode(),o.imgElement.style.msInterpolationMode="nearest-neighbor",o.imgElement.style.width="100%",o.imgElement.style.height="100%",o.style=o.element.style,o.style.position="absolute"}o.element.parentNode!==a&&a.appendChild(o.element),o.imgElement.parentNode!==o.element&&o.element.appendChild(o.imgElement),o.style.top=o.position.y+"px",o.style.left=o.position.x+"px",o.style.height=o.size.y+"px",o.style.width=o.size.x+"px",o.flipped&&(o.style.transform="scaleX(-1)"),t.setElementOpacity(o.element,o.opacity)}}t.HTMLDrawer=r})(e),(function(t){const i=t;class r extends i.DrawerBase{constructor(u){super(u),this.context=this.canvas.getContext("2d"),this.sketchCanvas=null,this.sketchContext=null,this._imageSmoothingEnabled=!0,this.viewer.allowEventHandler("tile-drawn"),this.viewer.allowEventHandler("tile-drawing")}static isSupported(){return t.supportsCanvas}getType(){return"canvas"}_createDrawingElement(){let u=t.makeNeutralElement("canvas"),c=this._calculateCanvasSize();return u.width=c.x,u.height=c.y,u}draw(u){this._prepareNewFrame(),this.viewer.viewport.getFlip()!==this._viewportFlipped&&this._flip();for(const c of u)c.opacity!==0&&this._drawTiles(c)}canRotate(){return!0}destroy(){this.canvas.width=1,this.canvas.height=1,this.sketchCanvas=null,this.sketchContext=null,this.container.removeChild(this.canvas)}minimumOverlapRequired(u){return!0}setImageSmoothingEnabled(u){this._imageSmoothingEnabled=!!u,this._updateImageSmoothingEnabled(this.context),this.viewer.forceRedraw()}drawDebuggingRect(u){var c=this.context;c.save(),c.lineWidth=2*t.pixelDensityRatio,c.strokeStyle=this.debugGridColor[0],c.fillStyle=this.debugGridColor[0],c.strokeRect(u.x*t.pixelDensityRatio,u.y*t.pixelDensityRatio,u.width*t.pixelDensityRatio,u.height*t.pixelDensityRatio),c.restore()}get _viewportFlipped(){return this.context.getTransform().a<0}_raiseTileDrawingEvent(u,c,d,f){this.viewer.raiseEvent("tile-drawing",{tiledImage:u,context:c,tile:d,rendered:f})}_prepareNewFrame(){var u=this._calculateCanvasSize();if((this.canvas.width!==u.x||this.canvas.height!==u.y)&&(this.canvas.width=u.x,this.canvas.height=u.y,this._updateImageSmoothingEnabled(this.context),this.sketchCanvas!==null)){var c=this._calculateSketchCanvasSize();this.sketchCanvas.width=c.x,this.sketchCanvas.height=c.y,this._updateImageSmoothingEnabled(this.sketchContext)}this._clear()}_clear(u,c){var d=this._getContext(u);if(c)d.clearRect(c.x,c.y,c.width,c.height);else{var f=d.canvas;d.clearRect(0,0,f.width,f.height)}}_drawTiles(u){var c=u.getTilesToDraw().map(L=>L.tile);if(!(u.opacity===0||c.length===0&&!u.placeholderFillStyle)){var d=c[0],f;d&&(f=u.opacity<1||u.compositeOperation&&u.compositeOperation!=="source-over"||!u._isBottomItem()&&u.source.hasTransparency(d.context2D,d.getUrl(),d.ajaxHeaders,d.postData));var p,g,m=this.viewport.getZoom(!0),v=u.viewportToImageZoom(m);c.length>1&&v>u.smoothTileEdgesMinZoom&&!u.iOSDevice&&u.getRotation(!0)%360===0&&(f=!0,p=d.getScaleForEdgeSmoothing(),g=d.getTranslationForEdgeSmoothing(p,this._getCanvasSize(!1),this._getCanvasSize(!0)));var _;f&&(p||(_=this.viewport.viewportToViewerElementRectangle(u.getClippedBounds(!0)).getIntegerBoundingBox(),_=_.times(t.pixelDensityRatio)),this._clear(!0,_)),p||this._setRotations(u,f);var y=!1;if(u._clip){this._saveContext(f);var w=u.imageToViewportRectangle(u._clip,!0);w=w.rotate(-u.getRotation(!0),u._getRotationPoint(!0));var R=this.viewportToDrawerRectangle(w);p&&(R=R.times(p)),g&&(R=R.translate(g)),this._setClip(R,f),y=!0}if(u._croppingPolygons){var M=this;y||this._saveContext(f);try{var C=u._croppingPolygons.map(function(L){return L.map(function(S){var I=u.imageToViewportCoordinates(S.x,S.y,!0).rotate(-u.getRotation(!0),u._getRotationPoint(!0)),B=M.viewportCoordToDrawerCoord(I);return p&&(B=B.times(p)),g&&(B=B.plus(g)),B})});this._clipWithPolygons(C,f)}catch(L){t.console.error(L)}y=!0}if(u._hasOpaqueTile=!1,u.placeholderFillStyle&&u._hasOpaqueTile===!1){let L=this.viewportToDrawerRectangle(u.getBoundsNoRotate(!0));p&&(L=L.times(p)),g&&(L=L.translate(g));let S=null;typeof u.placeholderFillStyle=="function"?S=u.placeholderFillStyle(u,this.context):S=u.placeholderFillStyle,this._drawRectangle(L,S,f)}var O=l(u.subPixelRoundingForTransparency),N=!1;if(O===t.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS)N=!0;else if(O===t.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST){var X=this.viewer&&this.viewer.isAnimating();N=!X}for(var q=0;q<c.length;q++)d=c[q],this._drawTile(d,u,f,p,g,N,u.source),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:u,tile:d});y&&this._restoreContext(f),p||(u.getRotation(!0)%360!==0&&this._restoreRotationChanges(f),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(f)),f&&(p&&this._setRotations(u),this.blendSketch({opacity:u.opacity,scale:p,translate:g,compositeOperation:u.compositeOperation,bounds:_}),p&&(u.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1))),this._drawDebugInfo(u,c),this._raiseTiledImageDrawnEvent(u,c)}}_drawDebugInfo(u,c){if(u.debugMode)for(var d=c.length-1;d>=0;d--){var f=c[d];try{this._drawDebugInfoOnTile(f,c.length,d,u)}catch(p){t.console.error(p)}}}_clipWithPolygons(u,c){var d=this._getContext(c);d.beginPath();for(const f of u)for(const[p,g]of f.entries())d[p===0?"moveTo":"lineTo"](g.x,g.y);d.clip()}_drawTile(u,c,d,f,p,g,m){t.console.assert(u,"[Drawer._drawTile] tile is required"),t.console.assert(c,"[Drawer._drawTile] drawingHandler is required");var v=this._getContext(d);f=f||1,this._drawTileToCanvas(u,v,c,f,p,g,m)}_drawTileToCanvas(u,c,d,f,p,g,m){var v=u.position.times(t.pixelDensityRatio),_=u.size.times(t.pixelDensityRatio),y;if(!u.context2D&&!u.cacheImageRecord){t.console.warn("[Drawer._drawTileToCanvas] attempting to draw tile %s when it's not cached",u.toString());return}if(y=u.getCanvasContext(),!u.loaded||!y){t.console.warn("Attempting to draw tile %s when it's not yet loaded.",u.toString());return}c.save(),typeof f=="number"&&f!==1&&(v=v.times(f),_=_.times(f)),p instanceof t.Point&&(v=v.plus(p)),c.globalAlpha===1&&u.hasTransparency&&(g&&(v.x=Math.round(v.x),v.y=Math.round(v.y),_.x=Math.round(_.x),_.y=Math.round(_.y)),c.clearRect(v.x,v.y,_.x,_.y)),this._raiseTileDrawingEvent(d,c,u,y);var w,R;u.sourceBounds?(w=Math.min(u.sourceBounds.width,y.canvas.width),R=Math.min(u.sourceBounds.height,y.canvas.height)):(w=y.canvas.width,R=y.canvas.height),c.translate(v.x+_.x/2,0),u.flipped&&c.scale(-1,1),c.drawImage(y.canvas,0,0,w,R,-_.x/2,v.y,_.x,_.y),c.restore()}_getContext(u){var c=this.context;if(u){if(this.sketchCanvas===null){this.sketchCanvas=document.createElement("canvas");var d=this._calculateSketchCanvasSize();if(this.sketchCanvas.width=d.x,this.sketchCanvas.height=d.y,this.sketchContext=this.sketchCanvas.getContext("2d"),this.viewport.getRotation()===0){var f=this;this.viewer.addHandler("rotate",function p(){if(f.viewport.getRotation()!==0){f.viewer.removeHandler("rotate",p);var g=f._calculateSketchCanvasSize();f.sketchCanvas.width=g.x,f.sketchCanvas.height=g.y}})}this._updateImageSmoothingEnabled(this.sketchContext)}c=this.sketchContext}return c}_saveContext(u){this._getContext(u).save()}_restoreContext(u){this._getContext(u).restore()}_setClip(u,c){var d=this._getContext(c);d.beginPath(),d.rect(u.x,u.y,u.width,u.height),d.clip()}_drawRectangle(u,c,d){var f=this._getContext(d);f.save(),f.fillStyle=c,f.fillRect(u.x,u.y,u.width,u.height),f.restore()}blendSketch(u,c,d,f){var p=u;t.isPlainObject(p)||(p={opacity:u,scale:c,translate:d,compositeOperation:f}),u=p.opacity,f=p.compositeOperation;var g=p.bounds;if(this.context.save(),this.context.globalAlpha=u,f&&(this.context.globalCompositeOperation=f),g)g.x<0&&(g.width+=g.x,g.x=0),g.x+g.width>this.canvas.width&&(g.width=this.canvas.width-g.x),g.y<0&&(g.height+=g.y,g.y=0),g.y+g.height>this.canvas.height&&(g.height=this.canvas.height-g.y),this.context.drawImage(this.sketchCanvas,g.x,g.y,g.width,g.height,g.x,g.y,g.width,g.height);else{c=p.scale||1,d=p.translate;var m=d instanceof t.Point?d:new t.Point(0,0),v=0,_=0;if(d){var y=this.sketchCanvas.width-this.canvas.width,w=this.sketchCanvas.height-this.canvas.height;v=Math.round(y/2),_=Math.round(w/2)}this.context.drawImage(this.sketchCanvas,m.x-v*c,m.y-_*c,(this.canvas.width+2*v)*c,(this.canvas.height+2*_)*c,-v,-_,this.canvas.width+2*v,this.canvas.height+2*_)}this.context.restore()}_drawDebugInfoOnTile(u,c,d,f){var p=this.viewer.world.getIndexOfItem(f)%this.debugGridColor.length,g=this.context;g.save(),g.lineWidth=2*t.pixelDensityRatio,g.font="small-caps bold "+13*t.pixelDensityRatio+"px arial",g.strokeStyle=this.debugGridColor[p],g.fillStyle=this.debugGridColor[p],this._setRotations(f),this._viewportFlipped&&this._flip({point:u.position.plus(u.size.divide(2))}),g.strokeRect(u.position.x*t.pixelDensityRatio,u.position.y*t.pixelDensityRatio,u.size.x*t.pixelDensityRatio,u.size.y*t.pixelDensityRatio);var m=(u.position.x+u.size.x/2)*t.pixelDensityRatio,v=(u.position.y+u.size.y/2)*t.pixelDensityRatio;g.translate(m,v);const _=this.viewport.getRotation(!0);g.rotate(Math.PI/180*-_),g.translate(-m,-v),u.x===0&&u.y===0&&(g.fillText("Zoom: "+this.viewport.getZoom(),u.position.x*t.pixelDensityRatio,(u.position.y-30)*t.pixelDensityRatio),g.fillText("Pan: "+this.viewport.getBounds().toString(),u.position.x*t.pixelDensityRatio,(u.position.y-20)*t.pixelDensityRatio)),g.fillText("Level: "+u.level,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+20)*t.pixelDensityRatio),g.fillText("Column: "+u.x,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+30)*t.pixelDensityRatio),g.fillText("Row: "+u.y,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+40)*t.pixelDensityRatio),g.fillText("Order: "+d+" of "+c,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+50)*t.pixelDensityRatio),g.fillText("Size: "+u.size.toString(),(u.position.x+10)*t.pixelDensityRatio,(u.position.y+60)*t.pixelDensityRatio),g.fillText("Position: "+u.position.toString(),(u.position.x+10)*t.pixelDensityRatio,(u.position.y+70)*t.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),f.getRotation(!0)%360!==0&&this._restoreRotationChanges(),g.restore()}_updateImageSmoothingEnabled(u){u.msImageSmoothingEnabled=this._imageSmoothingEnabled,u.imageSmoothingEnabled=this._imageSmoothingEnabled}_getCanvasSize(u){var c=this._getContext(u).canvas;return new t.Point(c.width,c.height)}_getCanvasCenter(){return new t.Point(this.canvas.width/2,this.canvas.height/2)}_setRotations(u,c=!1){var d=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:c,saveContext:d}),d=!1),u.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:u.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(u._getRotationPoint(!0),!0),useSketch:c,saveContext:d})}_offsetForRotation(u){var c=u.point?u.point.times(t.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(u.useSketch);d.save(),d.translate(c.x,c.y),d.rotate(Math.PI/180*u.degrees),d.translate(-c.x,-c.y)}_flip(u){u=u||{};var c=u.point?u.point.times(t.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(u.useSketch);d.translate(c.x,0),d.scale(-1,1),d.translate(-c.x,0)}_restoreRotationChanges(u){var c=this._getContext(u);c.restore()}_calculateCanvasSize(){var u=t.pixelDensityRatio,c=this.viewport.getContainerSize();return{x:Math.round(c.x*u),y:Math.round(c.y*u)}}_calculateSketchCanvasSize(){var u=this._calculateCanvasSize();if(this.viewport.getRotation()===0)return u;var c=Math.ceil(Math.sqrt(u.x*u.x+u.y*u.y));return{x:c,y:c}}}t.CanvasDrawer=r;var s=t.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function o(h){return h!==t.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&h!==t.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&h!==t.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function a(h){return o(h)?s:h}function l(h){if(typeof h=="number")return a(h);if(!h||!t.Browser)return s;var u=h[t.Browser.vendor];return o(u)&&(u=h["*"]),a(u)}})(e),(function(t){const i=t;i.WebGLDrawer=class extends i.DrawerBase{constructor(s){super(s),this._destroyed=!1,this._TextureMap=new Map,this._TileMap=new Map,this._gl=null,this._firstPass=null,this._secondPass=null,this._glFrameBuffer=null,this._renderToTexture=null,this._glFramebufferToCanvasTransform=null,this._outputCanvas=null,this._outputContext=null,this._clippingCanvas=null,this._clippingContext=null,this._renderingCanvas=null,this._backupCanvasDrawer=null,this._imageSmoothingEnabled=!0,this._boundToTileReady=o=>this._tileReadyHandler(o),this._boundToImageUnloaded=o=>this._imageUnloadedHandler(o),this.viewer.addHandler("tile-ready",this._boundToTileReady),this.viewer.addHandler("image-unloaded",this._boundToImageUnloaded),this.viewer.rejectEventHandler("tile-drawn","The WebGLDrawer does not raise the tile-drawn event"),this.viewer.rejectEventHandler("tile-drawing","The WebGLDrawer does not raise the tile-drawing event"),this._setupCanvases(),this._setupRenderer(),this.context=this._outputContext}destroy(){if(this._destroyed)return;let s=this._gl;var o=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS);for(let l=0;l<o;++l)s.activeTexture(s.TEXTURE0+l),s.bindTexture(s.TEXTURE_2D,null),s.bindTexture(s.TEXTURE_CUBE_MAP,null);s.bindBuffer(s.ARRAY_BUFFER,null),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,null),s.bindRenderbuffer(s.RENDERBUFFER,null),s.bindFramebuffer(s.FRAMEBUFFER,null),this._unloadTextures(),s.deleteBuffer(this._secondPass.bufferOutputPosition),s.deleteFramebuffer(this._glFrameBuffer),this._renderingCanvas.width=this._renderingCanvas.height=1,this._clippingCanvas.width=this._clippingCanvas.height=1,this._outputCanvas.width=this._outputCanvas.height=1,this._renderingCanvas=null,this._clippingCanvas=this._clippingContext=null,this._outputCanvas=this._outputContext=null;let a=s.getExtension("WEBGL_lose_context");a&&a.loseContext(),this.viewer.removeHandler("tile-ready",this._boundToTileReady),this.viewer.removeHandler("image-unloaded",this._boundToImageUnloaded),this.viewer.removeHandler("resize",this._resizeHandler),this._gl=null,this._backupCanvasDrawer&&(this._backupCanvasDrawer.destroy(),this._backupCanvasDrawer=null),this.container.removeChild(this.canvas),this.viewer.drawer===this&&(this.viewer.drawer=null),this._destroyed=!0}canRotate(){return!0}static isSupported(){let s=document.createElement("canvas"),o=t.isFunction(s.getContext)&&s.getContext("webgl"),a=o&&o.getExtension("WEBGL_lose_context");return a&&a.loseContext(),!!o}getType(){return"webgl"}minimumOverlapRequired(s){return s.isTainted()}_createDrawingElement(){let s=t.makeNeutralElement("canvas"),o=this._calculateCanvasSize();return s.width=o.x,s.height=o.y,s}_getBackupCanvasDrawer(){return this._backupCanvasDrawer||(this._backupCanvasDrawer=this.viewer.requestDrawer("canvas",{mainDrawer:!1}),this._backupCanvasDrawer.canvas.style.setProperty("visibility","hidden")),this._backupCanvasDrawer}draw(s){let o=this._gl;const a=this.viewport.getBoundsNoRotateWithMargins(!0);let l={bounds:a,center:new i.Point(a.x+a.width/2,a.y+a.height/2),rotation:this.viewport.getRotation(!0)*Math.PI/180},h=this.viewport.flipped?-1:1,u=t.Mat3.makeTranslation(-l.center.x,-l.center.y),c=t.Mat3.makeScaling(2/l.bounds.width*h,-2/l.bounds.height),d=t.Mat3.makeRotation(-l.rotation),f=c.multiply(d).multiply(u);o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT),this._outputContext.clearRect(0,0,this._outputCanvas.width,this._outputCanvas.height);let p=!1;s.forEach((g,m)=>{if(g.isTainted()){p&&(this._outputContext.drawImage(this._renderingCanvas,0,0),o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT),p=!1);const v=this._getBackupCanvasDrawer();v.draw([g]),this._outputContext.drawImage(v.canvas,0,0)}else{let v=g.getTilesToDraw();if(g.placeholderFillStyle&&g._hasOpaqueTile===!1&&this._drawPlaceholder(g),v.length===0||g.getOpacity()===0)return;let _=v[0],y=g.compositeOperation||this.viewer.compositeOperation||g._clip||g._croppingPolygons||g.debugMode,w=y||g.opacity<1||_.hasTransparency;y&&(p&&this._outputContext.drawImage(this._renderingCanvas,0,0),o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT)),o.useProgram(this._firstPass.shaderProgram),w?(o.bindFramebuffer(o.FRAMEBUFFER,this._glFrameBuffer),o.clear(o.COLOR_BUFFER_BIT)):o.bindFramebuffer(o.FRAMEBUFFER,null);let R=f,M=g.getRotation(!0);if(M%360!==0){let L=t.Mat3.makeRotation(-M*Math.PI/180),S=g.getBoundsNoRotate(!0).getCenter(),I=t.Mat3.makeTranslation(S.x,S.y),B=t.Mat3.makeTranslation(-S.x,-S.y),j=I.multiply(L).multiply(B);R=f.multiply(j)}let C=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);if(C<=0)throw new Error(`WegGL error: bad value for gl parameter MAX_TEXTURE_IMAGE_UNITS (${C}). This could happen
59
+ if too many contexts have been created and not released, or there is another problem with the graphics card.`);let O=new Float32Array(C*12),N=new Array(C),X=new Array(C),q=new Array(C);for(let L=0;L<v.length;L++){let S=v[L].tile,I=L%C,B=I+1,j=S.getCanvasContext(),U=j?this._TextureMap.get(j.canvas):null;if(U||(this._tileReadyHandler({tile:S,tiledImage:g}),U=j?this._TextureMap.get(j.canvas):null),U&&this._getTileData(S,g,U,R,I,O,N,X,q),B===C||L===v.length-1){for(let W=0;W<=B;W++)o.activeTexture(o.TEXTURE0+W),o.bindTexture(o.TEXTURE_2D,N[W]);o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),o.bufferData(o.ARRAY_BUFFER,O,o.DYNAMIC_DRAW),X.forEach((W,ee)=>{o.uniformMatrix3fv(this._firstPass.uTransformMatrices[ee],!1,W)}),o.uniform1fv(this._firstPass.uOpacities,new Float32Array(q)),o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),o.vertexAttribPointer(this._firstPass.aOutputPosition,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),o.vertexAttribPointer(this._firstPass.aTexturePosition,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferIndex),o.vertexAttribPointer(this._firstPass.aIndex,1,o.FLOAT,!1,0,0),o.drawArrays(o.TRIANGLES,0,6*B)}}w&&(o.useProgram(this._secondPass.shaderProgram),o.bindFramebuffer(o.FRAMEBUFFER,null),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,this._renderToTexture),this._gl.uniform1f(this._secondPass.uOpacityMultiplier,g.opacity),o.bindBuffer(o.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),o.vertexAttribPointer(this._secondPass.aTexturePosition,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),o.vertexAttribPointer(this._secondPass.aOutputPosition,2,o.FLOAT,!1,0,0),o.drawArrays(o.TRIANGLES,0,6)),p=!0,y&&(this._applyContext2dPipeline(g,v,m),p=!1,o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT)),m===0&&this._raiseTiledImageDrawnEvent(g,v.map(L=>L.tile))}}),p&&this._outputContext.drawImage(this._renderingCanvas,0,0)}setImageSmoothingEnabled(s){this._imageSmoothingEnabled!==s&&(this._imageSmoothingEnabled=s,this._unloadTextures(),this.viewer.world.draw())}drawDebuggingRect(s){let o=this._outputContext;o.save(),o.lineWidth=2*t.pixelDensityRatio,o.strokeStyle=this.debugGridColor[0],o.fillStyle=this.debugGridColor[0],o.strokeRect(s.x*t.pixelDensityRatio,s.y*t.pixelDensityRatio,s.width*t.pixelDensityRatio,s.height*t.pixelDensityRatio),o.restore()}_getTextureDataFromTile(s){return s.getCanvasContext().canvas}_applyContext2dPipeline(s,o,a){if(this._outputContext.save(),this._outputContext.globalCompositeOperation=a===0?null:s.compositeOperation||this.viewer.compositeOperation,s._croppingPolygons||s._clip?(this._renderToClippingCanvas(s),this._outputContext.drawImage(this._clippingCanvas,0,0)):this._outputContext.drawImage(this._renderingCanvas,0,0),this._outputContext.restore(),s.debugMode){const l=this.viewer.viewport.getFlip();l&&this._flip(),this._drawDebugInfo(o,s,l),l&&this._flip()}}_getTileData(s,o,a,l,h,u,c,d,f){let p=a.texture,g=a.position;u.set(g,h*12);let m=this._calculateOverlapFraction(s,o),v=s.positionedBounds.width*m.x,_=s.positionedBounds.height*m.y,y=s.positionedBounds.x+(s.x===0?0:v),w=s.positionedBounds.y+(s.y===0?0:_),R=s.positionedBounds.x+s.positionedBounds.width-(s.isRightMost?0:v),M=s.positionedBounds.y+s.positionedBounds.height-(s.isBottomMost?0:_),C=R-y,O=M-w,N=new t.Mat3([C,0,0,0,O,0,y,w,1]);if(s.flipped){let q=t.Mat3.makeTranslation(.5,0),L=t.Mat3.makeTranslation(-.5,0),S=q.multiply(t.Mat3.makeScaling(-1,1)).multiply(L);N=N.multiply(S)}let X=l.multiply(N);f[h]=s.opacity,c[h]=p,d[h]=X.values}_textureFilter(){return this._imageSmoothingEnabled?this._gl.LINEAR:this._gl.NEAREST}_setupRenderer(){let s=this._gl;s||t.console.error("_setupCanvases must be called before _setupRenderer"),this._unitQuad=this._makeQuadVertexBuffer(0,1,0,1),this._makeFirstPassShaderProgram(),this._makeSecondPassShaderProgram(),this._renderToTexture=s.createTexture(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this._renderToTexture),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,this._renderingCanvas.width,this._renderingCanvas.height,0,s.RGBA,s.UNSIGNED_BYTE,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this._textureFilter()),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),this._glFrameBuffer=s.createFramebuffer(),s.bindFramebuffer(s.FRAMEBUFFER,this._glFrameBuffer),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._renderToTexture,0),s.enable(s.BLEND),s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA)}_makeFirstPassShaderProgram(){let s=this._glNumTextures=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),o=()=>[...Array(s).keys()].map(p=>`uniform mat3 u_matrix_${p};`).join(`
60
+ `),a=()=>[...Array(s).keys()].map(p=>`${p>0?"else ":""}if(int(a_index) == ${p}) { transform_matrix = u_matrix_${p}; }`).join(`
61
+ `);const l=`
62
+ attribute vec2 a_output_position;
63
+ attribute vec2 a_texture_position;
64
+ attribute float a_index;
65
+
66
+ ${o()} // create a uniform mat3 for each potential tile to draw
67
+
68
+ varying vec2 v_texture_position;
69
+ varying float v_image_index;
70
+
71
+ void main() {
72
+
73
+ mat3 transform_matrix; // value will be set by the if/elses in makeConditional()
74
+
75
+ ${a()}
76
+
77
+ gl_Position = vec4(transform_matrix * vec3(a_output_position, 1), 1);
78
+
79
+ v_texture_position = a_texture_position;
80
+ v_image_index = a_index;
81
+ }
82
+ `,h=`
83
+ precision mediump float;
84
+
85
+ // our textures
86
+ uniform sampler2D u_images[${s}];
87
+ // our opacities
88
+ uniform float u_opacities[${s}];
89
+
90
+ // the varyings passed in from the vertex shader.
91
+ varying vec2 v_texture_position;
92
+ varying float v_image_index;
93
+
94
+ void main() {
95
+ // can't index directly with a variable, need to use a loop iterator hack
96
+ for(int i = 0; i < ${s}; ++i){
97
+ if(i == int(v_image_index)){
98
+ gl_FragColor = texture2D(u_images[i], v_texture_position) * u_opacities[i];
99
+ }
100
+ }
101
+ }
102
+ `;let u=this._gl,c=this.constructor.initShaderProgram(u,l,h);u.useProgram(c),this._firstPass={shaderProgram:c,aOutputPosition:u.getAttribLocation(c,"a_output_position"),aTexturePosition:u.getAttribLocation(c,"a_texture_position"),aIndex:u.getAttribLocation(c,"a_index"),uTransformMatrices:[...Array(this._glNumTextures).keys()].map(p=>u.getUniformLocation(c,`u_matrix_${p}`)),uImages:u.getUniformLocation(c,"u_images"),uOpacities:u.getUniformLocation(c,"u_opacities"),bufferOutputPosition:u.createBuffer(),bufferTexturePosition:u.createBuffer(),bufferIndex:u.createBuffer()},u.uniform1iv(this._firstPass.uImages,[...Array(s).keys()]);let d=new Float32Array(s*12);for(let p=0;p<s;++p)d.set(Float32Array.from(this._unitQuad),p*12);u.bindBuffer(u.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),u.bufferData(u.ARRAY_BUFFER,d,u.STATIC_DRAW),u.enableVertexAttribArray(this._firstPass.aOutputPosition),u.bindBuffer(u.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),u.enableVertexAttribArray(this._firstPass.aTexturePosition),u.bindBuffer(u.ARRAY_BUFFER,this._firstPass.bufferIndex);let f=[...Array(this._glNumTextures).keys()].map(p=>Array(6).fill(p)).flat();u.bufferData(u.ARRAY_BUFFER,new Float32Array(f),u.STATIC_DRAW),u.enableVertexAttribArray(this._firstPass.aIndex)}_makeSecondPassShaderProgram(){const s=`
103
+ attribute vec2 a_output_position;
104
+ attribute vec2 a_texture_position;
105
+
106
+ uniform mat3 u_matrix;
107
+
108
+ varying vec2 v_texture_position;
109
+
110
+ void main() {
111
+ gl_Position = vec4(u_matrix * vec3(a_output_position, 1), 1);
112
+
113
+ v_texture_position = a_texture_position;
114
+ }
115
+ `,o=`
116
+ precision mediump float;
117
+
118
+ // our texture
119
+ uniform sampler2D u_image;
120
+
121
+ // the texCoords passed in from the vertex shader.
122
+ varying vec2 v_texture_position;
123
+
124
+ // the opacity multiplier for the image
125
+ uniform float u_opacity_multiplier;
126
+
127
+ void main() {
128
+ gl_FragColor = texture2D(u_image, v_texture_position);
129
+ gl_FragColor *= u_opacity_multiplier;
130
+ }
131
+ `;let a=this._gl,l=this.constructor.initShaderProgram(a,s,o);a.useProgram(l),this._secondPass={shaderProgram:l,aOutputPosition:a.getAttribLocation(l,"a_output_position"),aTexturePosition:a.getAttribLocation(l,"a_texture_position"),uMatrix:a.getUniformLocation(l,"u_matrix"),uImage:a.getUniformLocation(l,"u_image"),uOpacityMultiplier:a.getUniformLocation(l,"u_opacity_multiplier"),bufferOutputPosition:a.createBuffer(),bufferTexturePosition:a.createBuffer()},a.bindBuffer(a.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),a.bufferData(a.ARRAY_BUFFER,this._unitQuad,a.STATIC_DRAW),a.enableVertexAttribArray(this._secondPass.aOutputPosition),a.bindBuffer(a.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),a.bufferData(a.ARRAY_BUFFER,this._unitQuad,a.DYNAMIC_DRAW),a.enableVertexAttribArray(this._secondPass.aTexturePosition);let h=t.Mat3.makeScaling(2,2).multiply(t.Mat3.makeTranslation(-.5,-.5));a.uniformMatrix3fv(this._secondPass.uMatrix,!1,h.values)}_resizeRenderer(){let s=this._gl,o=this._renderingCanvas.width,a=this._renderingCanvas.height;s.viewport(0,0,o,a),s.deleteTexture(this._renderToTexture),this._renderToTexture=s.createTexture(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this._renderToTexture),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,o,a,0,s.RGBA,s.UNSIGNED_BYTE,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this._textureFilter()),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.bindFramebuffer(s.FRAMEBUFFER,this._glFrameBuffer),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._renderToTexture,0)}_setupCanvases(){let s=this;this._outputCanvas=this.canvas,this._outputContext=this._outputCanvas.getContext("2d"),this._renderingCanvas=document.createElement("canvas"),this._clippingCanvas=document.createElement("canvas"),this._clippingContext=this._clippingCanvas.getContext("2d"),this._renderingCanvas.width=this._clippingCanvas.width=this._outputCanvas.width,this._renderingCanvas.height=this._clippingCanvas.height=this._outputCanvas.height,this._gl=this._renderingCanvas.getContext("webgl"),this._resizeHandler=function(){s._outputCanvas!==s.viewer.drawer.canvas&&(s._outputCanvas.style.width=s.viewer.drawer.canvas.clientWidth+"px",s._outputCanvas.style.height=s.viewer.drawer.canvas.clientHeight+"px");let o=s._calculateCanvasSize();(s._outputCanvas.width!==o.x||s._outputCanvas.height!==o.y)&&(s._outputCanvas.width=o.x,s._outputCanvas.height=o.y),s._renderingCanvas.style.width=s._outputCanvas.clientWidth+"px",s._renderingCanvas.style.height=s._outputCanvas.clientHeight+"px",s._renderingCanvas.width=s._clippingCanvas.width=s._outputCanvas.width,s._renderingCanvas.height=s._clippingCanvas.height=s._outputCanvas.height,s._resizeRenderer()},this.viewer.addHandler("resize",this._resizeHandler)}_makeQuadVertexBuffer(s,o,a,l){return new Float32Array([s,l,o,l,s,a,s,a,o,l,o,a])}_tileReadyHandler(s){let o=s.tile,a=s.tiledImage;if(a.isTainted())return;let l=o.getCanvasContext(),h=l&&l.canvas;if(!h||t.isCanvasTainted(h)){a.isTainted()||(a.setTainted(!0),t.console.warn("WebGL cannot be used to draw this TiledImage because it has tainted data. Does crossOriginPolicy need to be set?"),this._raiseDrawerErrorEvent(a,"Tainted data cannot be used by the WebGLDrawer. Falling back to CanvasDrawer for this TiledImage."));return}if(!this._TextureMap.get(h)){let c=this._gl,d=c.createTexture(),f,p=a.source.tileOverlap,g,m;if(o.sourceBounds?(g=Math.min(o.sourceBounds.width,h.width)/h.width,m=Math.min(o.sourceBounds.height,h.height)/h.height):(g=1,m=1),p>0){let _=this._calculateOverlapFraction(o,a),y=(o.x===0?0:_.x)*g,w=(o.y===0?0:_.y)*m,R=(o.isRightMost?1:1-_.x)*g,M=(o.isBottomMost?1:1-_.y)*m;f=this._makeQuadVertexBuffer(y,R,w,M)}else g===1&&m===1?f=this._unitQuad:f=this._makeQuadVertexBuffer(0,g,0,m);let v={texture:d,position:f};this._TextureMap.set(h,v),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,d),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,this._textureFilter()),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,this._textureFilter()),this._uploadImageData(l)}}_calculateOverlapFraction(s,o){let a=o.source.tileOverlap,l=s.sourceBounds.width,h=s.sourceBounds.height,u=(s.x===0?0:a)+(s.isRightMost?0:a),c=(s.y===0?0:a)+(s.isBottomMost?0:a),d=a/(l+u),f=a/(h+c);return{x:d,y:f}}_unloadTextures(){Array.from(this._TextureMap.keys()).forEach(o=>{this._cleanupImageData(o)})}_uploadImageData(s){let o=this._gl,a=s.canvas;try{if(!a)throw s;o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,a)}catch(l){t.console.error("Error uploading image data to WebGL",l)}}_imageUnloadedHandler(s){let o=s.context2D.canvas;this._cleanupImageData(o)}_cleanupImageData(s){let o=this._TextureMap.get(s);this._TextureMap.delete(s),o&&this._gl.deleteTexture(o.texture)}_setClip(){}_renderToClippingCanvas(s){if(this._clippingContext.clearRect(0,0,this._clippingCanvas.width,this._clippingCanvas.height),this._clippingContext.save(),this.viewer.viewport.getFlip()){const o=new t.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(o.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-o.x,0)}if(s._clip){let a=[{x:s._clip.x,y:s._clip.y},{x:s._clip.x+s._clip.width,y:s._clip.y},{x:s._clip.x+s._clip.width,y:s._clip.y+s._clip.height},{x:s._clip.x,y:s._clip.y+s._clip.height}].map(l=>{let h=s.imageToViewportCoordinates(l.x,l.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(h)});this._clippingContext.beginPath(),a.forEach((l,h)=>{this._clippingContext[h===0?"moveTo":"lineTo"](l.x,l.y)}),this._clippingContext.clip(),this._setClip()}if(s._croppingPolygons){let o=s._croppingPolygons.map(a=>a.map(l=>{let h=s.imageToViewportCoordinates(l.x,l.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(h)}));this._clippingContext.beginPath(),o.forEach(a=>{a.forEach((l,h)=>{this._clippingContext[h===0?"moveTo":"lineTo"](l.x,l.y)})}),this._clippingContext.clip()}if(this.viewer.viewport.getFlip()){const o=new t.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(o.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-o.x,0)}this._clippingContext.drawImage(this._renderingCanvas,0,0),this._clippingContext.restore()}_setRotations(s){var o=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),saveContext:o}),o=!1),s.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:s.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(s._getRotationPoint(!0),!0),saveContext:o})}_offsetForRotation(s){var o=s.point?s.point.times(t.pixelDensityRatio):this._getCanvasCenter(),a=this._outputContext;a.save(),a.translate(o.x,o.y),a.rotate(Math.PI/180*s.degrees),a.translate(-o.x,-o.y)}_flip(s){s=s||{};var o=s.point?s.point.times(t.pixelDensityRatio):this._getCanvasCenter(),a=this._outputContext;a.translate(o.x,0),a.scale(-1,1),a.translate(-o.x,0)}_drawDebugInfo(s,o,a){for(var l=s.length-1;l>=0;l--){var h=s[l].tile;try{this._drawDebugInfoOnTile(h,s.length,l,o,a)}catch(u){t.console.error(u)}}}_drawDebugInfoOnTile(s,o,a,l,h){var u=this.viewer.world.getIndexOfItem(l)%this.debugGridColor.length,c=this.context;c.save(),c.lineWidth=2*t.pixelDensityRatio,c.font="small-caps bold "+13*t.pixelDensityRatio+"px arial",c.strokeStyle=this.debugGridColor[u],c.fillStyle=this.debugGridColor[u],this._setRotations(l),h&&this._flip({point:s.position.plus(s.size.divide(2))}),c.strokeRect(s.position.x*t.pixelDensityRatio,s.position.y*t.pixelDensityRatio,s.size.x*t.pixelDensityRatio,s.size.y*t.pixelDensityRatio);var d=(s.position.x+s.size.x/2)*t.pixelDensityRatio,f=(s.position.y+s.size.y/2)*t.pixelDensityRatio;c.translate(d,f);const p=this.viewport.getRotation(!0);c.rotate(Math.PI/180*-p),c.translate(-d,-f),s.x===0&&s.y===0&&(c.fillText("Zoom: "+this.viewport.getZoom(),s.position.x*t.pixelDensityRatio,(s.position.y-30)*t.pixelDensityRatio),c.fillText("Pan: "+this.viewport.getBounds().toString(),s.position.x*t.pixelDensityRatio,(s.position.y-20)*t.pixelDensityRatio)),c.fillText("Level: "+s.level,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+20)*t.pixelDensityRatio),c.fillText("Column: "+s.x,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+30)*t.pixelDensityRatio),c.fillText("Row: "+s.y,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+40)*t.pixelDensityRatio),c.fillText("Order: "+a+" of "+o,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+50)*t.pixelDensityRatio),c.fillText("Size: "+s.size.toString(),(s.position.x+10)*t.pixelDensityRatio,(s.position.y+60)*t.pixelDensityRatio),c.fillText("Position: "+s.position.toString(),(s.position.x+10)*t.pixelDensityRatio,(s.position.y+70)*t.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),l.getRotation(!0)%360!==0&&this._restoreRotationChanges(),c.restore()}_drawPlaceholder(s){const o=s.getBounds(!0),a=this.viewportToDrawerRectangle(s.getBounds(!0)),l=this._outputContext;let h;typeof s.placeholderFillStyle=="function"?h=s.placeholderFillStyle(s,l):h=s.placeholderFillStyle,this._offsetForRotation({degrees:this.viewer.viewport.getRotation(!0)}),l.fillStyle=h,l.translate(a.x,a.y),l.rotate(Math.PI/180*o.degrees),l.translate(-a.x,-a.y),l.fillRect(a.x,a.y,a.width,a.height),this._restoreRotationChanges()}_getCanvasCenter(){return new t.Point(this.canvas.width/2,this.canvas.height/2)}_restoreRotationChanges(){var s=this._outputContext;s.restore()}static initShaderProgram(s,o,a){function l(d,f,p){const g=d.createShader(f);return d.shaderSource(g,p),d.compileShader(g),d.getShaderParameter(g,d.COMPILE_STATUS)?g:(t.console.error(`An error occurred compiling the shaders: ${d.getShaderInfoLog(g)}`),d.deleteShader(g),null)}const h=l(s,s.VERTEX_SHADER,o),u=l(s,s.FRAGMENT_SHADER,a),c=s.createProgram();return s.attachShader(c,h),s.attachShader(c,u),s.linkProgram(c),s.getProgramParameter(c,s.LINK_STATUS)?c:(t.console.error(`Unable to initialize the shader program: ${s.getProgramInfoLog(c)}`),null)}}})(e),(function(t){t.Viewport=function(i){var r=arguments;r.length&&r[0]instanceof t.Point&&(i={containerSize:r[0],contentSize:r[1],config:r[2]}),i.config&&(t.extend(!0,i,i.config),delete i.config),this._margins=t.extend({left:0,top:0,right:0,bottom:0},i.margins||{}),delete i.margins,i.initialDegrees=i.degrees,delete i.degrees,t.extend(!0,this,{containerSize:null,contentSize:null,zoomPoint:null,rotationPivot:null,viewer:null,springStiffness:t.DEFAULT_SETTINGS.springStiffness,animationTime:t.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:t.DEFAULT_SETTINGS.minZoomImageRatio,maxZoomPixelRatio:t.DEFAULT_SETTINGS.maxZoomPixelRatio,visibilityRatio:t.DEFAULT_SETTINGS.visibilityRatio,wrapHorizontal:t.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:t.DEFAULT_SETTINGS.wrapVertical,defaultZoomLevel:t.DEFAULT_SETTINGS.defaultZoomLevel,minZoomLevel:t.DEFAULT_SETTINGS.minZoomLevel,maxZoomLevel:t.DEFAULT_SETTINGS.maxZoomLevel,initialDegrees:t.DEFAULT_SETTINGS.degrees,flipped:t.DEFAULT_SETTINGS.flipped,homeFillsViewer:t.DEFAULT_SETTINGS.homeFillsViewer,silenceMultiImageWarnings:t.DEFAULT_SETTINGS.silenceMultiImageWarnings},i),this._updateContainerInnerSize(),this.centerSpringX=new t.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.centerSpringY=new t.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.zoomSpring=new t.Spring({exponential:!0,initial:1,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.degreesSpring=new t.Spring({initial:i.initialDegrees,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value,this._setContentBounds(new t.Rect(0,0,1,1),1),this.goHome(!0),this.update()},t.Viewport.prototype={get degrees(){return t.console.warn("Accessing [Viewport.degrees] is deprecated. Use viewport.getRotation instead."),this.getRotation()},set degrees(i){t.console.warn("Setting [Viewport.degrees] is deprecated. Use viewport.rotateTo, viewport.rotateBy, or viewport.setRotation instead."),this.rotateTo(i)},resetContentSize:function(i){return t.console.assert(i,"[Viewport.resetContentSize] contentSize is required"),t.console.assert(i instanceof t.Point,"[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point"),t.console.assert(i.x>0,"[Viewport.resetContentSize] contentSize.x must be greater than 0"),t.console.assert(i.y>0,"[Viewport.resetContentSize] contentSize.y must be greater than 0"),this._setContentBounds(new t.Rect(0,0,1,i.y/i.x),i.x),this},setHomeBounds:function(i,r){t.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually."),this._setContentBounds(i,r)},_setContentBounds:function(i,r){t.console.assert(i,"[Viewport._setContentBounds] bounds is required"),t.console.assert(i instanceof t.Rect,"[Viewport._setContentBounds] bounds must be an OpenSeadragon.Rect"),t.console.assert(i.width>0,"[Viewport._setContentBounds] bounds.width must be greater than 0"),t.console.assert(i.height>0,"[Viewport._setContentBounds] bounds.height must be greater than 0"),this._contentBoundsNoRotate=i.clone(),this._contentSizeNoRotate=this._contentBoundsNoRotate.getSize().times(r),this._contentBounds=i.rotate(this.getRotation()).getBoundingBox(),this._contentSize=this._contentBounds.getSize().times(r),this._contentAspectRatio=this._contentSize.x/this._contentSize.y,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:r,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var i=this._contentAspectRatio/this.getAspectRatio(),r;return this.homeFillsViewer?r=i>=1?i:1:r=i>=1?1:i,r/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var i=this._contentBounds.getCenter(),r=1/this.getHomeZoom(),s=r/this.getAspectRatio();return new t.Rect(i.x-r/2,i.y-s/2,r,s)},goHome:function(i){return this.viewer&&this.viewer.raiseEvent("home",{immediately:i}),this.fitBounds(this.getHomeBounds(),i)},getMinZoom:function(){var i=this.getHomeZoom(),r=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*i;return r},getMaxZoom:function(){var i=this.maxZoomLevel;return i||(i=this._contentSize.x*this.maxZoomPixelRatio/this._containerInnerSize.x,i/=this._contentBounds.width),Math.max(i,this.getHomeZoom())},getAspectRatio:function(){return this._containerInnerSize.x/this._containerInnerSize.y},getContainerSize:function(){return new t.Point(this.containerSize.x,this.containerSize.y)},getMargins:function(){return t.extend({},this._margins)},setMargins:function(i){t.console.assert(t.type(i)==="object","[Viewport.setMargins] margins must be an object"),this._margins=t.extend({left:0,top:0,right:0,bottom:0},i),this._updateContainerInnerSize(),this.viewer&&this.viewer.forceRedraw()},getBounds:function(i){return this.getBoundsNoRotate(i).rotate(-this.getRotation(i))},getBoundsNoRotate:function(i){var r=this.getCenter(i),s=1/this.getZoom(i),o=s/this.getAspectRatio();return new t.Rect(r.x-s/2,r.y-o/2,s,o)},getBoundsWithMargins:function(i){return this.getBoundsNoRotateWithMargins(i).rotate(-this.getRotation(i),this.getCenter(i))},getBoundsNoRotateWithMargins:function(i){var r=this.getBoundsNoRotate(i),s=this._containerInnerSize.x*this.getZoom(i);return r.x-=this._margins.left/s,r.y-=this._margins.top/s,r.width+=(this._margins.left+this._margins.right)/s,r.height+=(this._margins.top+this._margins.bottom)/s,r},getCenter:function(i){var r=new t.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),s=new t.Point(this.centerSpringX.target.value,this.centerSpringY.target.value),o,a,l,h,u,c,d,f;return i?r:this.zoomPoint?(o=this.pixelFromPoint(this.zoomPoint,!0),a=this.getZoom(),l=1/a,h=l/this.getAspectRatio(),u=new t.Rect(r.x-l/2,r.y-h/2,l,h),c=this._pixelFromPoint(this.zoomPoint,u),d=c.minus(o).rotate(-this.getRotation(!0)),f=d.divide(this._containerInnerSize.x*a),s.plus(f)):s},getZoom:function(i){return i?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyZoomConstraints:function(i){return Math.max(Math.min(i,this.getMaxZoom()),this.getMinZoom())},_applyBoundaryConstraints:function(i){var r=this.viewportToViewerElementRectangle(i).getBoundingBox(),s=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),o=!1,a=!1;if(!this.wrapHorizontal){var l=r.x+r.width,h=s.x+s.width,u,c,d;r.width>s.width?u=this.visibilityRatio*s.width:u=this.visibilityRatio*r.width,c=s.x-l+u,d=h-r.x-u,u>s.width?(r.x+=(c+d)/2,o=!0):d<0?(r.x+=d,o=!0):c>0&&(r.x+=c,o=!0)}if(!this.wrapVertical){var f=r.y+r.height,p=s.y+s.height,g,m,v;r.height>s.height?g=this.visibilityRatio*s.height:g=this.visibilityRatio*r.height,m=s.y-f+g,v=p-r.y-g,g>s.height?(r.y+=(m+v)/2,a=!0):v<0?(r.y+=v,a=!0):m>0&&(r.y+=m,a=!0)}var _=o||a,y=_?this.viewerElementToViewportRectangle(r):i.clone();return y.xConstrained=o,y.yConstrained=a,y.constraintApplied=_,y},_raiseConstraintsEvent:function(i){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:i})},applyConstraints:function(i){var r=this.getZoom(),s=this._applyZoomConstraints(r);r!==s&&this.zoomTo(s,this.zoomPoint,i);var o=this.getConstrainedBounds(!1);return o.constraintApplied&&(this.fitBounds(o,i),this._raiseConstraintsEvent(i)),this},ensureVisible:function(i){return this.applyConstraints(i)},_fitBounds:function(i,r){r=r||{};var s=r.immediately||!1,o=r.constraints||!1,a=this.getAspectRatio(),l=i.getCenter(),h=new t.Rect(i.x,i.y,i.width,i.height,i.degrees+this.getRotation()).getBoundingBox();h.getAspectRatio()>=a?h.height=h.width/a:h.width=h.height*a,h.x=l.x-h.width/2,h.y=l.y-h.height/2;var u=1/h.width;if(s)return this.panTo(l,!0),this.zoomTo(u,null,!0),o&&this.applyConstraints(!0),this;var c=this.getCenter(!0),d=this.getZoom(!0);this.panTo(c,!0),this.zoomTo(d,null,!0);var f=this.getBounds(),p=this.getZoom();if(p===0||Math.abs(u/p-1)<1e-8)return this.zoomTo(u,null,!0),this.panTo(l,s),o&&this.applyConstraints(!1),this;if(o){this.panTo(l,!1),u=this._applyZoomConstraints(u),this.zoomTo(u,null,!1);var g=this.getConstrainedBounds();this.panTo(c,!0),this.zoomTo(d,null,!0),this.fitBounds(g)}else{var m=h.rotate(-this.getRotation()),v=m.getTopLeft().times(u).minus(f.getTopLeft().times(p)).divide(u-p);this.zoomTo(u,v,s)}return this},fitBounds:function(i,r){return this._fitBounds(i,{immediately:r,constraints:!1})},fitBoundsWithConstraints:function(i,r){return this._fitBounds(i,{immediately:r,constraints:!0})},fitVertically:function(i){var r=new t.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(r,i)},fitHorizontally:function(i){var r=new t.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(r,i)},getConstrainedBounds:function(i){var r,s;return r=this.getBounds(i),s=this._applyBoundaryConstraints(r),s},panBy:function(i,r){var s=new t.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(s.plus(i),r)},panTo:function(i,r){return r?(this.centerSpringX.resetTo(i.x),this.centerSpringY.resetTo(i.y)):(this.centerSpringX.springTo(i.x),this.centerSpringY.springTo(i.y)),this.viewer&&this.viewer.raiseEvent("pan",{center:i,immediately:r}),this},zoomBy:function(i,r,s){return this.zoomTo(this.zoomSpring.target.value*i,r,s)},zoomTo:function(i,r,s){var o=this;return this.zoomPoint=r instanceof t.Point&&!isNaN(r.x)&&!isNaN(r.y)?r:null,s?this._adjustCenterSpringsForZoomPoint(function(){o.zoomSpring.resetTo(i)}):this.zoomSpring.springTo(i),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:i,refPoint:r,immediately:s}),this},setRotation:function(i,r){return this.rotateTo(i,null,r)},getRotation:function(i){return i?this.degreesSpring.current.value:this.degreesSpring.target.value},setRotationWithPivot:function(i,r,s){return this.rotateTo(i,r,s)},rotateTo:function(i,r,s){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===i&&this.degreesSpring.isAtTargetValue())return this;if(this.rotationPivot=r instanceof t.Point&&!isNaN(r.x)&&!isNaN(r.y)?r:null,s)if(this.rotationPivot){var o=i-this._oldDegrees;if(!o)return this.rotationPivot=null,this;this._rotateAboutPivot(i)}else this.degreesSpring.resetTo(i);else{var a=t.positiveModulo(this.degreesSpring.current.value,360),l=t.positiveModulo(i,360),h=l-a;h>180?l-=360:h<-180&&(l+=360);var u=a-l;this.degreesSpring.resetTo(i+u),this.degreesSpring.springTo(i)}return this._setContentBounds(this.viewer.world.getHomeBounds(),this.viewer.world.getContentFactor()),this.viewer.forceRedraw(),this.viewer.raiseEvent("rotate",{degrees:i,immediately:!!s,pivot:this.rotationPivot||this.getCenter()}),this},rotateBy:function(i,r,s){return this.rotateTo(this.degreesSpring.target.value+i,r,s)},resize:function(i,r){var s=this.getBoundsNoRotate(),o=s,a;this.containerSize.x=i.x,this.containerSize.y=i.y,this._updateContainerInnerSize(),r&&(a=i.x/this.containerSize.x,o.width=s.width*a,o.height=o.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:i,maintain:r});var l=this.fitBounds(o,!0);return this.viewer&&this.viewer.raiseEvent("after-resize",{newContainerSize:i,maintain:r}),l},_updateContainerInnerSize:function(){this._containerInnerSize=new t.Point(Math.max(1,this.containerSize.x-(this._margins.left+this._margins.right)),Math.max(1,this.containerSize.y-(this._margins.top+this._margins.bottom)))},update:function(){var i=this;this._adjustCenterSpringsForZoomPoint(function(){i.zoomSpring.update()}),this.degreesSpring.isAtTargetValue()&&(this.rotationPivot=null),this.centerSpringX.update(),this.centerSpringY.update(),this.rotationPivot?this._rotateAboutPivot(!0):this.degreesSpring.update();var r=this.centerSpringX.current.value!==this._oldCenterX||this.centerSpringY.current.value!==this._oldCenterY||this.zoomSpring.current.value!==this._oldZoom||this.degreesSpring.current.value!==this._oldDegrees;this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value;var s=r||!this.zoomSpring.isAtTargetValue()||!this.centerSpringX.isAtTargetValue()||!this.centerSpringY.isAtTargetValue()||!this.degreesSpring.isAtTargetValue();return s},_rotateAboutPivot:function(i){var r=i===!0,s=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(s.x),this.centerSpringY.shiftBy(s.y),r?this.degreesSpring.update():this.degreesSpring.resetTo(i);var o=this.degreesSpring.current.value-this._oldDegrees,a=s.rotate(o*-1).times(-1);this.centerSpringX.shiftBy(a.x),this.centerSpringY.shiftBy(a.y)},_adjustCenterSpringsForZoomPoint:function(i){if(this.zoomPoint){var r=this.pixelFromPoint(this.zoomPoint,!0);i();var s=this.pixelFromPoint(this.zoomPoint,!0),o=s.minus(r),a=this.deltaPointsFromPixels(o,!0);this.centerSpringX.shiftBy(a.x),this.centerSpringY.shiftBy(a.y),this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else i()},deltaPixelsFromPointsNoRotate:function(i,r){return i.times(this._containerInnerSize.x*this.getZoom(r))},deltaPixelsFromPoints:function(i,r){return this.deltaPixelsFromPointsNoRotate(i.rotate(this.getRotation(r)),r)},deltaPointsFromPixelsNoRotate:function(i,r){return i.divide(this._containerInnerSize.x*this.getZoom(r))},deltaPointsFromPixels:function(i,r){return this.deltaPointsFromPixelsNoRotate(i,r).rotate(-this.getRotation(r))},pixelFromPointNoRotate:function(i,r){return this._pixelFromPointNoRotate(i,this.getBoundsNoRotate(r))},pixelFromPoint:function(i,r){return this._pixelFromPoint(i,this.getBoundsNoRotate(r))},_pixelFromPointNoRotate:function(i,r){return i.minus(r.getTopLeft()).times(this._containerInnerSize.x/r.width).plus(new t.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(i,r){return this._pixelFromPointNoRotate(i.rotate(this.getRotation(!0),this.getCenter(!0)),r)},pointFromPixelNoRotate:function(i,r){var s=this.getBoundsNoRotate(r);return i.minus(new t.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/s.width).plus(s.getTopLeft())},pointFromPixel:function(i,r){return this.pointFromPixelNoRotate(i,r).rotate(-this.getRotation(r),this.getCenter(r))},_viewportToImageDelta:function(i,r){var s=this._contentBoundsNoRotate.width;return new t.Point(i*this._contentSizeNoRotate.x/s,r*this._contentSizeNoRotate.x/s)},viewportToImageCoordinates:function(i,r){if(i instanceof t.Point)return this.viewportToImageCoordinates(i.x,i.y);if(this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(s===1){var o=this.viewer.world.getItemAt(0);return o.viewportToImageCoordinates(i,r,!0)}}return this._viewportToImageDelta(i-this._contentBoundsNoRotate.x,r-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(i,r){var s=this._contentBoundsNoRotate.width;return new t.Point(i/this._contentSizeNoRotate.x*s,r/this._contentSizeNoRotate.x*s)},imageToViewportCoordinates:function(i,r){if(i instanceof t.Point)return this.imageToViewportCoordinates(i.x,i.y);if(this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(s===1){var o=this.viewer.world.getItemAt(0);return o.imageToViewportCoordinates(i,r,!0)}}var a=this._imageToViewportDelta(i,r);return a.x+=this._contentBoundsNoRotate.x,a.y+=this._contentBoundsNoRotate.y,a},imageToViewportRectangle:function(i,r,s,o){var a=i;if(a instanceof t.Rect||(a=new t.Rect(i,r,s,o)),this.viewer){var l=this.viewer.world.getItemCount();if(l>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(l===1){var h=this.viewer.world.getItemAt(0);return h.imageToViewportRectangle(i,r,s,o,!0)}}var u=this.imageToViewportCoordinates(a.x,a.y),c=this._imageToViewportDelta(a.width,a.height);return new t.Rect(u.x,u.y,c.x,c.y,a.degrees)},viewportToImageRectangle:function(i,r,s,o){var a=i;if(a instanceof t.Rect||(a=new t.Rect(i,r,s,o)),this.viewer){var l=this.viewer.world.getItemCount();if(l>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(l===1){var h=this.viewer.world.getItemAt(0);return h.viewportToImageRectangle(i,r,s,o,!0)}}var u=this.viewportToImageCoordinates(a.x,a.y),c=this._viewportToImageDelta(a.width,a.height);return new t.Rect(u.x,u.y,c.x,c.y,a.degrees)},viewerElementToImageCoordinates:function(i){var r=this.pointFromPixel(i,!0);return this.viewportToImageCoordinates(r)},imageToViewerElementCoordinates:function(i){var r=this.imageToViewportCoordinates(i);return this.pixelFromPoint(r,!0)},windowToImageCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");var r=i.minus(t.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(r)},imageToWindowCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");var r=this.imageToViewerElementCoordinates(i);return r.plus(t.getElementPosition(this.viewer.element))},viewerElementToViewportCoordinates:function(i){return this.pointFromPixel(i,!0)},viewportToViewerElementCoordinates:function(i){return this.pixelFromPoint(i,!0)},viewerElementToViewportRectangle:function(i){return t.Rect.fromSummits(this.pointFromPixel(i.getTopLeft(),!0),this.pointFromPixel(i.getTopRight(),!0),this.pointFromPixel(i.getBottomLeft(),!0))},viewportToViewerElementRectangle:function(i){return t.Rect.fromSummits(this.pixelFromPoint(i.getTopLeft(),!0),this.pixelFromPoint(i.getTopRight(),!0),this.pixelFromPoint(i.getBottomLeft(),!0))},windowToViewportCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.windowToViewportCoordinates] the viewport must have a viewer.");var r=i.minus(t.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(r)},viewportToWindowCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");var r=this.viewportToViewerElementCoordinates(i);return r.plus(t.getElementPosition(this.viewer.element))},viewportToImageZoom:function(i){if(this.viewer){var r=this.viewer.world.getItemCount();if(r>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(r===1){var s=this.viewer.world.getItemAt(0);return s.viewportToImageZoom(i)}}var o=this._contentSizeNoRotate.x,a=this._containerInnerSize.x,l=this._contentBoundsNoRotate.width,h=a/o*l;return i*h},imageToViewportZoom:function(i){if(this.viewer){var r=this.viewer.world.getItemCount();if(r>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportZoom] is not accurate with multi-image. Instead, use [TiledImage.imageToViewportZoom] for the specific image of interest");else if(r===1){var s=this.viewer.world.getItemAt(0);return s.imageToViewportZoom(i)}}var o=this._contentSizeNoRotate.x,a=this._containerInnerSize.x,l=this._contentBoundsNoRotate.width,h=o/a/l;return i*h},toggleFlip:function(){return this.setFlip(!this.getFlip()),this},getFlip:function(){return this.flipped},setFlip:function(i){return this.flipped===i?this:(this.flipped=i,this.viewer.navigator&&this.viewer.navigator.setFlip(this.getFlip()),this.viewer.forceRedraw(),this.viewer.raiseEvent("flip",{flipped:i}),this)},getMaxZoomPixelRatio:function(){return this.maxZoomPixelRatio},setMaxZoomPixelRatio:function(i,r=!0,s=!1){t.console.assert(!isNaN(i),"[Viewport.setMaxZoomPixelRatio] ratio must be a number"),!isNaN(i)&&(this.maxZoomPixelRatio=i,r&&this.getZoom()>this.getMaxZoom()&&this.applyConstraints(s))}}})(e),(function(t){t.TiledImage=function(i){this._initialized=!1,t.console.assert(i.tileCache,"[TiledImage] options.tileCache is required"),t.console.assert(i.drawer,"[TiledImage] options.drawer is required"),t.console.assert(i.viewer,"[TiledImage] options.viewer is required"),t.console.assert(i.imageLoader,"[TiledImage] options.imageLoader is required"),t.console.assert(i.source,"[TiledImage] options.source is required"),t.console.assert(!i.clip||i.clip instanceof t.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present"),t.EventSource.call(this),this._tileCache=i.tileCache,delete i.tileCache,this._drawer=i.drawer,delete i.drawer,this._imageLoader=i.imageLoader,delete i.imageLoader,i.clip instanceof t.Rect&&(this._clip=i.clip.clone()),delete i.clip;var r=i.x||0;delete i.x;var s=i.y||0;delete i.y,this.normHeight=i.source.dimensions.y/i.source.dimensions.x,this.contentAspectX=i.source.dimensions.x/i.source.dimensions.y;var o=1;i.width?(o=i.width,delete i.width,i.height&&(t.console.error("specifying both width and height to a tiledImage is not supported"),delete i.height)):i.height&&(o=i.height/this.normHeight,delete i.height);var a=i.fitBounds;delete i.fitBounds;var l=i.fitBoundsPlacement||e.Placement.CENTER;delete i.fitBoundsPlacement;var h=i.degrees||0;delete i.degrees;var u=i.ajaxHeaders;delete i.ajaxHeaders,t.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},loadingCoverage:{},lastDrawn:[],lastResetTime:0,_needsDraw:!0,_needsUpdate:!0,_hasOpaqueTile:!1,_tilesLoading:0,_tilesToDraw:[],_lastDrawn:[],_isBlending:!1,_wasBlending:!1,_isTainted:!1,springStiffness:t.DEFAULT_SETTINGS.springStiffness,animationTime:t.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:t.DEFAULT_SETTINGS.minZoomImageRatio,wrapHorizontal:t.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:t.DEFAULT_SETTINGS.wrapVertical,immediateRender:t.DEFAULT_SETTINGS.immediateRender,blendTime:t.DEFAULT_SETTINGS.blendTime,alwaysBlend:t.DEFAULT_SETTINGS.alwaysBlend,minPixelRatio:t.DEFAULT_SETTINGS.minPixelRatio,smoothTileEdgesMinZoom:t.DEFAULT_SETTINGS.smoothTileEdgesMinZoom,iOSDevice:t.DEFAULT_SETTINGS.iOSDevice,debugMode:t.DEFAULT_SETTINGS.debugMode,crossOriginPolicy:t.DEFAULT_SETTINGS.crossOriginPolicy,ajaxWithCredentials:t.DEFAULT_SETTINGS.ajaxWithCredentials,placeholderFillStyle:t.DEFAULT_SETTINGS.placeholderFillStyle,opacity:t.DEFAULT_SETTINGS.opacity,preload:t.DEFAULT_SETTINGS.preload,compositeOperation:t.DEFAULT_SETTINGS.compositeOperation,subPixelRoundingForTransparency:t.DEFAULT_SETTINGS.subPixelRoundingForTransparency,maxTilesPerFrame:t.DEFAULT_SETTINGS.maxTilesPerFrame},i),this._preload=this.preload,delete this.preload,this._fullyLoaded=!1,this._xSpring=new t.Spring({initial:r,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._ySpring=new t.Spring({initial:s,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._scaleSpring=new t.Spring({initial:o,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new t.Spring({initial:h,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),a&&this.fitBounds(a,l,!0),this._ownAjaxHeaders={},this.setAjaxHeaders(u,!1),this._initialized=!0},t.extend(t.TiledImage.prototype,t.EventSource.prototype,{needsDraw:function(){return this._needsDraw},redraw:function(){this._needsDraw=!0},getFullyLoaded:function(){return this._fullyLoaded},_setFullyLoaded:function(i){i!==this._fullyLoaded&&(this._fullyLoaded=i,this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded}))},reset:function(){this._tileCache.clearTilesFor(this),this.lastResetTime=t.now(),this._needsDraw=!0},update:function(i){let r=this._xSpring.update(),s=this._ySpring.update(),o=this._scaleSpring.update(),a=this._degreesSpring.update(),l=r||s||o||a||this._needsUpdate;if(l||i||!this._fullyLoaded){let h=this._updateLevelsForViewport();this._setFullyLoaded(h)}return this._needsUpdate=!1,l?(this._updateForScale(),this._raiseBoundsChange(),this._needsDraw=!0,!0):!1},setDrawn:function(){return this._needsDraw=this._isBlending||this._wasBlending,this._needsDraw},setTainted(i){this._isTainted=i},isTainted(){return this._isTainted},destroy:function(){this.reset(),this.source.destroy&&this.source.destroy(this.viewer)},getBounds:function(i){return this.getBoundsNoRotate(i).rotate(this.getRotation(i),this._getRotationPoint(i))},getBoundsNoRotate:function(i){return i?new t.Rect(this._xSpring.current.value,this._ySpring.current.value,this._worldWidthCurrent,this._worldHeightCurrent):new t.Rect(this._xSpring.target.value,this._ySpring.target.value,this._worldWidthTarget,this._worldHeightTarget)},getWorldBounds:function(){return t.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead"),this.getBounds()},getClippedBounds:function(i){var r=this.getBoundsNoRotate(i);if(this._clip){var s=i?this._worldWidthCurrent:this._worldWidthTarget,o=s/this.source.dimensions.x,a=this._clip.times(o);r=new t.Rect(r.x+a.x,r.y+a.y,a.width,a.height)}return r.rotate(this.getRotation(i),this._getRotationPoint(i))},getTileBounds:function(i,r,s){var o=this.source.getNumTiles(i),a=(o.x+r%o.x)%o.x,l=(o.y+s%o.y)%o.y,h=this.source.getTileBounds(i,a,l);return this.getFlip()&&(h.x=Math.max(0,1-h.x-h.width)),h.x+=(r-a)/o.x,h.y+=this._worldHeightCurrent/this._worldWidthCurrent*((s-l)/o.y),h},getContentSize:function(){return new t.Point(this.source.dimensions.x,this.source.dimensions.y)},getSizeInWindowCoordinates:function(){var i=this.imageToWindowCoordinates(new t.Point(0,0)),r=this.imageToWindowCoordinates(this.getContentSize());return new t.Point(r.x-i.x,r.y-i.y)},_viewportToImageDelta:function(i,r,s){var o=s?this._scaleSpring.current.value:this._scaleSpring.target.value;return new t.Point(i*(this.source.dimensions.x/o),r*(this.source.dimensions.y*this.contentAspectX/o))},viewportToImageCoordinates:function(i,r,s){var o;return i instanceof t.Point?(s=r,o=i):o=new t.Point(i,r),o=o.rotate(-this.getRotation(s),this._getRotationPoint(s)),s?this._viewportToImageDelta(o.x-this._xSpring.current.value,o.y-this._ySpring.current.value):this._viewportToImageDelta(o.x-this._xSpring.target.value,o.y-this._ySpring.target.value)},_imageToViewportDelta:function(i,r,s){var o=s?this._scaleSpring.current.value:this._scaleSpring.target.value;return new t.Point(i/this.source.dimensions.x*o,r/this.source.dimensions.y/this.contentAspectX*o)},imageToViewportCoordinates:function(i,r,s){i instanceof t.Point&&(s=r,r=i.y,i=i.x);var o=this._imageToViewportDelta(i,r,s);return s?(o.x+=this._xSpring.current.value,o.y+=this._ySpring.current.value):(o.x+=this._xSpring.target.value,o.y+=this._ySpring.target.value),o.rotate(this.getRotation(s),this._getRotationPoint(s))},imageToViewportRectangle:function(i,r,s,o,a){var l=i;l instanceof t.Rect?a=r:l=new t.Rect(i,r,s,o);var h=this.imageToViewportCoordinates(l.getTopLeft(),a),u=this._imageToViewportDelta(l.width,l.height,a);return new t.Rect(h.x,h.y,u.x,u.y,l.degrees+this.getRotation(a))},viewportToImageRectangle:function(i,r,s,o,a){var l=i;i instanceof t.Rect?a=r:l=new t.Rect(i,r,s,o);var h=this.viewportToImageCoordinates(l.getTopLeft(),a),u=this._viewportToImageDelta(l.width,l.height,a);return new t.Rect(h.x,h.y,u.x,u.y,l.degrees-this.getRotation(a))},viewerElementToImageCoordinates:function(i){var r=this.viewport.pointFromPixel(i,!0);return this.viewportToImageCoordinates(r)},imageToViewerElementCoordinates:function(i){var r=this.imageToViewportCoordinates(i);return this.viewport.pixelFromPoint(r,!0)},windowToImageCoordinates:function(i){var r=i.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(r)},imageToWindowCoordinates:function(i){var r=this.imageToViewerElementCoordinates(i);return r.plus(e.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(i){var r=this._scaleSpring.current.value;return i=i.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new t.Rect((i.x-this._xSpring.current.value)/r,(i.y-this._ySpring.current.value)/r,i.width/r,i.height/r,i.degrees)},viewportToImageZoom:function(i){var r=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return r*i},imageToViewportZoom:function(i){var r=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return i/r},setPosition:function(i,r){var s=this._xSpring.target.value===i.x&&this._ySpring.target.value===i.y;if(r){if(s&&this._xSpring.current.value===i.x&&this._ySpring.current.value===i.y)return;this._xSpring.resetTo(i.x),this._ySpring.resetTo(i.y),this._needsDraw=!0,this._needsUpdate=!0}else{if(s)return;this._xSpring.springTo(i.x),this._ySpring.springTo(i.y),this._needsDraw=!0,this._needsUpdate=!0}s||this._raiseBoundsChange()},setWidth:function(i,r){this._setScale(i,r)},setHeight:function(i,r){this._setScale(i/this.normHeight,r)},setCroppingPolygons:function(i){var r=function(o){return o instanceof t.Point||typeof o.x=="number"&&typeof o.y=="number"},s=function(o){return o.map(function(a){try{if(r(a))return{x:a.x,y:a.y};throw new Error}catch{throw new Error("A Provided cropping polygon point is not supported")}})};try{if(!t.isArray(i))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=i.map(function(o){return s(o)}),this._needsDraw=!0}catch(o){t.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),t.console.error(o),this.resetCroppingPolygons()}},resetCroppingPolygons:function(){this._croppingPolygons=null,this._needsDraw=!0},fitBounds:function(i,r,s){r=r||t.Placement.CENTER;var o=t.Placement.properties[r],a=this.contentAspectX,l=0,h=0,u=1,c=1;if(this._clip&&(a=this._clip.getAspectRatio(),u=this._clip.width/this.source.dimensions.x,c=this._clip.height/this.source.dimensions.y,i.getAspectRatio()>a?(l=this._clip.x/this._clip.height*i.height,h=this._clip.y/this._clip.height*i.height):(l=this._clip.x/this._clip.width*i.width,h=this._clip.y/this._clip.width*i.width)),i.getAspectRatio()>a){var d=i.height/c,f=0;o.isHorizontallyCentered?f=(i.width-i.height*a)/2:o.isRight&&(f=i.width-i.height*a),this.setPosition(new t.Point(i.x-l+f,i.y-h),s),this.setHeight(d,s)}else{var p=i.width/u,g=0;o.isVerticallyCentered?g=(i.height-i.width/a)/2:o.isBottom&&(g=i.height-i.width/a),this.setPosition(new t.Point(i.x-l,i.y-h+g),s),this.setWidth(p,s)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(i){t.console.assert(!i||i instanceof t.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null"),i instanceof t.Rect?this._clip=i.clone():this._clip=null,this._needsUpdate=!0,this._needsDraw=!0,this.raiseEvent("clip-change")},getFlip:function(){return this.flipped},setFlip:function(i){this.flipped=i},get flipped(){return this._flipped},set flipped(i){let r=this._flipped!==!!i;this._flipped=!!i,r&&(this.update(!0),this._needsDraw=!0,this._raiseBoundsChange())},get wrapHorizontal(){return this._wrapHorizontal},set wrapHorizontal(i){let r=this._wrapHorizontal!==!!i;this._wrapHorizontal=!!i,this._initialized&&r&&(this.update(!0),this._needsDraw=!0)},get wrapVertical(){return this._wrapVertical},set wrapVertical(i){let r=this._wrapVertical!==!!i;this._wrapVertical=!!i,this._initialized&&r&&(this.update(!0),this._needsDraw=!0)},get debugMode(){return this._debugMode},set debugMode(i){this._debugMode=!!i,this._needsDraw=!0},getOpacity:function(){return this.opacity},setOpacity:function(i){this.opacity=i},get opacity(){return this._opacity},set opacity(i){i!==this.opacity&&(this._opacity=i,this._needsDraw=!0,this.raiseEvent("opacity-change",{opacity:this.opacity}))},getPreload:function(){return this._preload},setPreload:function(i){this._preload=!!i,this._needsDraw=!0},getRotation:function(i){return i?this._degreesSpring.current.value:this._degreesSpring.target.value},setRotation:function(i,r){this._degreesSpring.target.value===i&&this._degreesSpring.isAtTargetValue()||(r?this._degreesSpring.resetTo(i):this._degreesSpring.springTo(i),this._needsDraw=!0,this._needsUpdate=!0,this._raiseBoundsChange())},getDrawArea:function(){if(this._opacity===0&&!this._preload)return!1;var i=this._viewportToTiledImageRectangle(this.viewport.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var r=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));i=i.intersection(r)}return i},getTilesToDraw:function(){let i=this._tilesToDraw.flat();return this._updateTilesInViewport(i),i=this._tilesToDraw.flat(),i.forEach(r=>{r.tile.beingDrawn=!0}),this._lastDrawn=i,i},_getRotationPoint:function(i){return this.getBoundsNoRotate(i).getCenter()},get compositeOperation(){return this._compositeOperation},set compositeOperation(i){i!==this._compositeOperation&&(this._compositeOperation=i,this._needsDraw=!0,this.raiseEvent("composite-operation-change",{compositeOperation:this._compositeOperation}))},getCompositeOperation:function(){return this._compositeOperation},setCompositeOperation:function(i){this.compositeOperation=i},setAjaxHeaders:function(i,r){if(i===null&&(i={}),!t.isPlainObject(i)){console.error("[TiledImage.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}this._ownAjaxHeaders=i,this._updateAjaxHeaders(r)},_updateAjaxHeaders:function(i){if(i===void 0&&(i=!0),t.isPlainObject(this.viewer.ajaxHeaders)?this.ajaxHeaders=t.extend({},this.viewer.ajaxHeaders,this._ownAjaxHeaders):this.ajaxHeaders=this._ownAjaxHeaders,i){var r,s,o,a;for(var l in this.tilesMatrix){r=this.source.getNumTiles(l);for(var h in this.tilesMatrix[l]){s=(r.x+h%r.x)%r.x;for(var u in this.tilesMatrix[l][h])if(o=(r.y+u%r.y)%r.y,a=this.tilesMatrix[l][h][u],a.loadWithAjax=this.loadTilesWithAjax,a.loadWithAjax){var c=this.source.getTileAjaxHeaders(l,s,o);a.ajaxHeaders=t.extend({},this.ajaxHeaders,c)}else a.ajaxHeaders=null}}for(var d=0;d<this._imageLoader.jobQueue.length;d++){var f=this._imageLoader.jobQueue[d];f.loadWithAjax=f.tile.loadWithAjax,f.ajaxHeaders=f.tile.loadWithAjax?f.tile.ajaxHeaders:null}}},_setScale:function(i,r){var s=this._scaleSpring.target.value===i;if(r){if(s&&this._scaleSpring.current.value===i)return;this._scaleSpring.resetTo(i),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}else{if(s)return;this._scaleSpring.springTo(i),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}s||this._raiseBoundsChange()},_updateForScale:function(){this._worldWidthTarget=this._scaleSpring.target.value,this._worldHeightTarget=this.normHeight*this._scaleSpring.target.value,this._worldWidthCurrent=this._scaleSpring.current.value,this._worldHeightCurrent=this.normHeight*this._scaleSpring.current.value},_raiseBoundsChange:function(){this.raiseEvent("bounds-change")},_isBottomItem:function(){return this.viewer.world.getItemAt(0)===this},_getLevelsInterval:function(){var i=Math.max(this.source.minLevel,Math.floor(Math.log(this.minZoomImageRatio)/Math.log(2))),r=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value,s=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(r/this.minPixelRatio)/Math.log(2))));return s=Math.max(s,this.source.minLevel||0),i=Math.min(i,s),{lowestLevel:i,highestLevel:s}},_updateLevelsForViewport:function(){var i=this._getLevelsInterval(),r=i.lowestLevel,s=i.highestLevel,o=[],a=this.getDrawArea(),l=t.now();if(this._lastDrawn.forEach(R=>{R.tile.beingDrawn=!1}),this._tilesToDraw=[],this._tilesLoading=0,this.loadingCoverage={},!a)return this._needsDraw=!1,this._fullyLoaded;var h=new Array(s-r+1);for(let R=0,M=s;M>=r;M--,R++)h[R]=M;for(let R=s+1;R<=this.source.maxLevel;R++){var u=this.tilesMatrix[R]&&this.tilesMatrix[R][0]&&this.tilesMatrix[R][0][0];if(u&&u.isBottomMost&&u.isRightMost&&u.loaded){h.push(R);break}}let c=!1;for(let R=0;R<h.length;R++){let M=h[R];var d=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(M),!0).x*this._scaleSpring.current.value;if(R===h.length-1||d>=this.minPixelRatio)c=!0;else if(!c)continue;var f=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(M),!1).x*this._scaleSpring.current.value,p=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value,g=this.immediateRender?1:p,m=Math.min(1,(d-.5)/.5),v=g/Math.abs(g-f),_=this._updateLevel(M,m,v,a,l,o);o=_.bestTiles;var y=_.updatedTiles.filter(C=>C.loaded),w=(function(C,O,N){return function(X){return{tile:X,level:C,levelOpacity:O,currentTime:N}}})(M,m,l);if(this._tilesToDraw[M]=y.map(w),this._providesCoverage(this.coverage,M))break}return o&&o.length>0?(o.forEach(function(R){R&&!R.context2D&&this._loadTile(R,l)},this),this._needsDraw=!0,!1):this._tilesLoading===0},_updateTilesInViewport:function(i){let r=t.now(),s=this;this._tilesLoading=0,this._wasBlending=this._isBlending,this._isBlending=!1,this.loadingCoverage={};let o=i.length?i[0].level:0;if(!this.getDrawArea())return;function l(u){let c=u.tile;if(c&&c.loaded){let d=s._blendTile(c,c.x,c.y,u.level,u.levelOpacity,r,o);s._isBlending=s._isBlending||d,s._needsDraw=s._needsDraw||d||s._wasBlending}}let h=0;for(let u=0;u<i.length;u++){let c=i[u];l(c),this._providesCoverage(this.coverage,c.level)&&(h=Math.max(h,c.level))}if(h>0)for(let u in this._tilesToDraw)u<h&&delete this._tilesToDraw[u]},_blendTile:function(i,r,s,o,a,l,h){let u=1e3*this.blendTime,c,d;return i.blendStart||(i.blendStart=l),c=l-i.blendStart,d=u?Math.min(1,c/u):1,o===h&&(d=1,c=u),this.alwaysBlend&&(d*=a),i.opacity=d,d===1&&(this._setCoverage(this.coverage,o,r,s,!0),this._hasOpaqueTile=!0),c<u},_updateLevel:function(i,r,s,o,a,l){var h=o.getBoundingBox().getTopLeft(),u=o.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:!0,level:i,opacity:r,visibility:s,drawArea:o,topleft:h,bottomright:u,currenttime:a,best:l}),this._resetCoverage(this.coverage,i),this._resetCoverage(this.loadingCoverage,i);var c=this._getCornerTiles(i,h,u),d=c.topLeft,f=c.bottomRight,p=this.source.getNumTiles(i),g=this.viewport.pixelFromPoint(this.viewport.getCenter());this.getFlip()&&(f.x+=1,this.wrapHorizontal||(f.x=Math.min(f.x,p.x-1)));for(var m=Math.max(0,(f.x-d.x)*(f.y-d.y)),v=new Array(m),_=0,y=d.x;y<=f.x;y++)for(var w=d.y;w<=f.y;w++){var R;if(this.getFlip()){var M=(p.x+y%p.x)%p.x;R=y+p.x-M-M-1}else R=y;if(o.intersection(this.getTileBounds(i,R,w))!==null){var C=this._updateTile(R,w,i,s,g,p,a,l);l=C.bestTiles,v[_]=C.tile,_+=1}}return{bestTiles:l,updatedTiles:v}},_positionTile:function(i,r,s,o,a){var l=i.bounds.getTopLeft();l.x*=this._scaleSpring.current.value,l.y*=this._scaleSpring.current.value,l.x+=this._xSpring.current.value,l.y+=this._ySpring.current.value;var h=i.bounds.getSize();h.x*=this._scaleSpring.current.value,h.y*=this._scaleSpring.current.value,i.positionedBounds.x=l.x,i.positionedBounds.y=l.y,i.positionedBounds.width=h.x,i.positionedBounds.height=h.y;var u=s.pixelFromPointNoRotate(l,!0),c=s.pixelFromPointNoRotate(l,!1),d=s.deltaPixelsFromPointsNoRotate(h,!0),f=s.deltaPixelsFromPointsNoRotate(h,!1),p=c.plus(f.divide(2)),g=o.squaredDistanceTo(p);this.viewer.drawer.minimumOverlapRequired(this)&&(r||(d=d.plus(new t.Point(1,1))),i.isRightMost&&this.wrapHorizontal&&(d.x+=.75),i.isBottomMost&&this.wrapVertical&&(d.y+=.75)),i.position=u,i.size=d,i.squaredDistance=g,i.visibility=a},_updateTile:function(i,r,s,o,a,l,h,u){var c=this._getTile(i,r,s,h,l);this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:c}),this._setCoverage(this.coverage,s,i,r,!1);var d=c.loaded||c.loading||this._isCovered(this.loadingCoverage,s,i,r);if(this._setCoverage(this.loadingCoverage,s,i,r,d),!c.exists)return{bestTiles:u,tile:c};if(c.loaded&&c.opacity===1&&this._setCoverage(this.coverage,s,i,r,!0),this._positionTile(c,this.source.tileOverlap,this.viewport,a,o),!c.loaded)if(c.context2D)this._setTileLoaded(c);else{var f=this._tileCache.getImageRecord(c.cacheKey);f&&this._setTileLoaded(c,f.getData())}return c.loading?this._tilesLoading++:d||(u=this._compareTiles(u,c,this.maxTilesPerFrame)),{bestTiles:u,tile:c}},_getCornerTiles:function(i,r,s){var o,a;this.wrapHorizontal?(o=t.positiveModulo(r.x,1),a=t.positiveModulo(s.x,1)):(o=Math.max(0,r.x),a=Math.min(1,s.x));var l,h,u=1/this.source.aspectRatio;this.wrapVertical?(l=t.positiveModulo(r.y,u),h=t.positiveModulo(s.y,u)):(l=Math.max(0,r.y),h=Math.min(u,s.y));var c=this.source.getTileAtPoint(i,new t.Point(o,l)),d=this.source.getTileAtPoint(i,new t.Point(a,h)),f=this.source.getNumTiles(i);return this.wrapHorizontal&&(c.x+=f.x*Math.floor(r.x),d.x+=f.x*Math.floor(s.x)),this.wrapVertical&&(c.y+=f.y*Math.floor(r.y/u),d.y+=f.y*Math.floor(s.y/u)),{topLeft:c,bottomRight:d}},_getTile:function(i,r,s,o,a){var l,h,u,c,d,f,p,g,m,v,_=this.tilesMatrix,y=this.source;return _[s]||(_[s]={}),_[s][i]||(_[s][i]={}),(!_[s][i][r]||!_[s][i][r].flipped!=!this.flipped)&&(l=(a.x+i%a.x)%a.x,h=(a.y+r%a.y)%a.y,u=this.getTileBounds(s,i,r),c=y.getTileBounds(s,l,h,!0),d=y.tileExists(s,l,h),f=y.getTileUrl(s,l,h),p=y.getTilePostData(s,l,h),this.loadTilesWithAjax?(g=y.getTileAjaxHeaders(s,l,h),t.isPlainObject(this.ajaxHeaders)&&(g=t.extend({},this.ajaxHeaders,g))):g=null,m=y.getContext2D?y.getContext2D(s,l,h):void 0,v=new t.Tile(s,i,r,u,d,f,m,this.loadTilesWithAjax,g,c,p,y.getTileHashKey(s,l,h,f,g,p)),this.getFlip()?l===0&&(v.isRightMost=!0):l===a.x-1&&(v.isRightMost=!0),h===a.y-1&&(v.isBottomMost=!0),v.flipped=this.flipped,_[s][i][r]=v),v=_[s][i][r],v.lastTouchTime=o,v},_loadTile:function(i,r){var s=this;i.loading=!0,this._imageLoader.addJob({src:i.getUrl(),tile:i,source:this.source,postData:i.postData,loadWithAjax:i.loadWithAjax,ajaxHeaders:i.ajaxHeaders,crossOriginPolicy:this.crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,callback:function(o,a,l){s._onTileLoad(i,r,o,a,l)},abort:function(){i.loading=!1}})},_onTileLoad:function(i,r,s,o,a){if(s)i.exists=!0;else{t.console.error("Tile %s failed to load: %s - error: %s",i,i.getUrl(),o),this.viewer.raiseEvent("tile-load-failed",{tile:i,tiledImage:this,time:r,message:o,tileRequest:a}),i.loading=!1,i.exists=!1;return}if(r<this.lastResetTime){t.console.warn("Ignoring tile %s loaded before reset: %s",i,i.getUrl()),i.loading=!1;return}var l=this,h=function(){var u=l.source,c=u.getClosestLevel();l._setTileLoaded(i,s,c,a)};h()},_setTileLoaded:function(i,r,s,o){var a=0,l=!1,h=this;function u(){return l&&t.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. Its return value should be called asynchronously."),a++,c}function c(){a--,a===0&&(i.loading=!1,i.loaded=!0,i.hasTransparency=h.source.hasTransparency(i.context2D,i.getUrl(),i.ajaxHeaders,i.postData),i.context2D||h._tileCache.cacheTile({data:r,tile:i,cutoff:s,tiledImage:h}),h.viewer.raiseEvent("tile-ready",{tile:i,tiledImage:h,tileRequest:o}),h._needsDraw=!0)}var d=u();this.viewer.raiseEvent("tile-loaded",{tile:i,tiledImage:this,tileRequest:o,get image(){return t.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),r},data:r,getCompletionCallback:u}),l=!0,d()},_compareTiles:function(i,r,s){return i?(i.push(r),this._sortTiles(i),i.length>s&&i.pop(),i):[r]},_sortTiles:function(i){i.sort(function(r,s){return r===null?1:s===null?-1:r.visibility===s.visibility?r.squaredDistance-s.squaredDistance:s.visibility-r.visibility})},_providesCoverage:function(i,r,s,o){var a,l,h,u;if(!i[r])return!1;if(s===void 0||o===void 0){a=i[r];for(h in a)if(Object.prototype.hasOwnProperty.call(a,h)){l=a[h];for(u in l)if(Object.prototype.hasOwnProperty.call(l,u)&&!l[u])return!1}return!0}return i[r][s]===void 0||i[r][s][o]===void 0||i[r][s][o]===!0},_isCovered:function(i,r,s,o){return s===void 0||o===void 0?this._providesCoverage(i,r+1):this._providesCoverage(i,r+1,2*s,2*o)&&this._providesCoverage(i,r+1,2*s,2*o+1)&&this._providesCoverage(i,r+1,2*s+1,2*o)&&this._providesCoverage(i,r+1,2*s+1,2*o+1)},_setCoverage:function(i,r,s,o,a){if(!i[r]){t.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",r);return}i[r][s]||(i[r][s]={}),i[r][s][o]=a},_resetCoverage:function(i,r){i[r]={}}})})(e),(function(t){var i=function(s){t.console.assert(s,"[TileCache.cacheTile] options is required"),t.console.assert(s.tile,"[TileCache.cacheTile] options.tile is required"),t.console.assert(s.tiledImage,"[TileCache.cacheTile] options.tiledImage is required"),this.tile=s.tile,this.tiledImage=s.tiledImage},r=function(s){t.console.assert(s,"[ImageRecord] options is required"),t.console.assert(s.data,"[ImageRecord] options.data is required"),this._tiles=[],s.create.apply(null,[this,s.data,s.ownerTile]),this._destroyImplementation=s.destroy.bind(null,this),this.getImage=s.getImage.bind(null,this),this.getData=s.getData.bind(null,this),this.getRenderedContext=s.getRenderedContext.bind(null,this)};r.prototype={destroy:function(){this._destroyImplementation(),this._tiles=null},addTile:function(s){t.console.assert(s,"[ImageRecord.addTile] tile is required"),this._tiles.push(s)},removeTile:function(s){for(var o=0;o<this._tiles.length;o++)if(this._tiles[o]===s){this._tiles.splice(o,1);return}t.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",s)},getTileCount:function(){return this._tiles.length}},t.TileCache=function(s){s=s||{},this._maxImageCacheCount=s.maxImageCacheCount||t.DEFAULT_SETTINGS.maxImageCacheCount,this._tilesLoaded=[],this._imagesLoaded=[],this._imagesLoadedCount=0},t.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(s){t.console.assert(s,"[TileCache.cacheTile] options is required"),t.console.assert(s.tile,"[TileCache.cacheTile] options.tile is required"),t.console.assert(s.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required"),t.console.assert(s.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var o=s.cutoff||0,a=this._tilesLoaded.length,l=this._imagesLoaded[s.tile.cacheKey];if(l||(s.data||(t.console.error("[TileCache.cacheTile] options.image was renamed to options.data. '.image' attribute has been deprecated and will be removed in the future."),s.data=s.image),t.console.assert(s.data,"[TileCache.cacheTile] options.data is required to create an ImageRecord"),l=this._imagesLoaded[s.tile.cacheKey]=new r({data:s.data,ownerTile:s.tile,create:s.tiledImage.source.createTileCache,destroy:s.tiledImage.source.destroyTileCache,getImage:s.tiledImage.source.getTileCacheDataAsImage,getData:s.tiledImage.source.getTileCacheData,getRenderedContext:s.tiledImage.source.getTileCacheDataAsContext2D}),this._imagesLoadedCount++),l.addTile(s.tile),s.tile.cacheImageRecord=l,this._imagesLoadedCount>this._maxImageCacheCount){for(var h=null,u=-1,c=null,d,f,p,g,m,v,_=this._tilesLoaded.length-1;_>=0;_--)if(v=this._tilesLoaded[_],d=v.tile,!(d.level<=o||d.beingDrawn)){if(!h){h=d,u=_,c=v;continue}g=d.lastTouchTime,f=h.lastTouchTime,m=d.level,p=h.level,(g<f||g===f&&m>p)&&(h=d,u=_,c=v)}h&&u>=0&&(this._unloadTile(c),a=u)}this._tilesLoaded[a]=new i({tile:s.tile,tiledImage:s.tiledImage})},clearTilesFor:function(s){t.console.assert(s,"[TileCache.clearTilesFor] tiledImage is required");for(var o,a=0;a<this._tilesLoaded.length;++a)o=this._tilesLoaded[a],o.tiledImage===s&&(this._unloadTile(o),this._tilesLoaded.splice(a,1),a--)},getImageRecord:function(s){return t.console.assert(s,"[TileCache.getImageRecord] cacheKey is required"),this._imagesLoaded[s]},_unloadTile:function(s){t.console.assert(s,"[TileCache._unloadTile] tileRecord is required");var o=s.tile,a=s.tiledImage;let l=o.getCanvasContext&&o.getCanvasContext();o.unload(),o.cacheImageRecord=null;var h=this._imagesLoaded[o.cacheKey];h&&(h.removeTile(o),h.getTileCount()||(h.destroy(),delete this._imagesLoaded[o.cacheKey],this._imagesLoadedCount--,l&&(l.canvas.width=0,l.canvas.height=0,a.viewer.raiseEvent("image-unloaded",{context2D:l,tile:o}))),a.viewer.raiseEvent("tile-unloaded",{tile:o,tiledImage:a}))}}})(e),(function(t){t.World=function(i){var r=this;t.console.assert(i.viewer,"[World] options.viewer is required"),t.EventSource.call(this),this.viewer=i.viewer,this._items=[],this._needsDraw=!1,this._autoRefigureSizes=!0,this._needsSizesFigured=!1,this._delegatedFigureSizes=function(s){r._autoRefigureSizes?r._figureSizes():r._needsSizesFigured=!0},this._figureSizes()},t.extend(t.World.prototype,t.EventSource.prototype,{addItem:function(i,r){if(t.console.assert(i,"[World.addItem] item is required"),t.console.assert(i instanceof t.TiledImage,"[World.addItem] only TiledImages supported at this time"),r=r||{},r.index!==void 0){var s=Math.max(0,Math.min(this._items.length,r.index));this._items.splice(s,0,i)}else this._items.push(i);this._autoRefigureSizes?this._figureSizes():this._needsSizesFigured=!0,this._needsDraw=!0,i.addHandler("bounds-change",this._delegatedFigureSizes),i.addHandler("clip-change",this._delegatedFigureSizes),this.raiseEvent("add-item",{item:i})},getItemAt:function(i){return t.console.assert(i!==void 0,"[World.getItemAt] index is required"),this._items[i]},getIndexOfItem:function(i){return t.console.assert(i,"[World.getIndexOfItem] item is required"),t.indexOf(this._items,i)},getItemCount:function(){return this._items.length},setItemIndex:function(i,r){t.console.assert(i,"[World.setItemIndex] item is required"),t.console.assert(r!==void 0,"[World.setItemIndex] index is required");var s=this.getIndexOfItem(i);if(r>=this._items.length)throw new Error("Index bigger than number of layers.");r===s||s===-1||(this._items.splice(s,1),this._items.splice(r,0,i),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:i,previousIndex:s,newIndex:r}))},removeItem:function(i){t.console.assert(i,"[World.removeItem] item is required");var r=t.indexOf(this._items,i);r!==-1&&(i.removeHandler("bounds-change",this._delegatedFigureSizes),i.removeHandler("clip-change",this._delegatedFigureSizes),i.destroy(),this._items.splice(r,1),this._figureSizes(),this._needsDraw=!0,this._raiseRemoveItem(i))},removeAll:function(){this.viewer._cancelPendingImages();var i,r;for(r=0;r<this._items.length;r++)i=this._items[r],i.removeHandler("bounds-change",this._delegatedFigureSizes),i.removeHandler("clip-change",this._delegatedFigureSizes),i.destroy();var s=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,r=0;r<s.length;r++)i=s[r],this._raiseRemoveItem(i)},resetItems:function(){for(var i=0;i<this._items.length;i++)this._items[i].reset()},update:function(i){for(var r=!1,s=0;s<this._items.length;s++)r=this._items[s].update(i)||r;return r},draw:function(){this.viewer.drawer.draw(this._items),this._needsDraw=!1,this._items.forEach(i=>{this._needsDraw=i.setDrawn()||this._needsDraw})},needsDraw:function(){for(var i=0;i<this._items.length;i++)if(this._items[i].needsDraw())return!0;return this._needsDraw},getHomeBounds:function(){return this._homeBounds.clone()},getContentFactor:function(){return this._contentFactor},setAutoRefigureSizes:function(i){this._autoRefigureSizes=i,i&this._needsSizesFigured&&(this._figureSizes(),this._needsSizesFigured=!1)},arrange:function(i){i=i||{};var r=i.immediately||!1,s=i.layout||t.DEFAULT_SETTINGS.collectionLayout,o=i.rows||t.DEFAULT_SETTINGS.collectionRows,a=i.columns||t.DEFAULT_SETTINGS.collectionColumns,l=i.tileSize||t.DEFAULT_SETTINGS.collectionTileSize,h=i.tileMargin||t.DEFAULT_SETTINGS.collectionTileMargin,u=l+h,c;!i.rows&&a?c=a:c=Math.ceil(this._items.length/o);var d=0,f=0,p,g,m,v,_;this.setAutoRefigureSizes(!1);for(var y=0;y<this._items.length;y++)y&&y%c===0&&(s==="horizontal"?(f+=u,d=0):(d+=u,f=0)),p=this._items[y],g=p.getBounds(),g.width>g.height?m=l:m=l*(g.width/g.height),v=m*(g.height/g.width),_=new t.Point(d+(l-m)/2,f+(l-v)/2),p.setPosition(_,r),p.setWidth(m,r),s==="horizontal"?d+=u:f+=u;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var i=this._homeBounds?this._homeBounds.clone():null,r=this._contentSize?this._contentSize.clone():null,s=this._contentFactor||0;if(!this._items.length)this._homeBounds=new t.Rect(0,0,1,1),this._contentSize=new t.Point(1,1),this._contentFactor=1;else{var o=this._items[0],a=o.getBounds();this._contentFactor=o.getContentSize().x/a.width;for(var l=o.getClippedBounds().getBoundingBox(),h=l.x,u=l.y,c=l.x+l.width,d=l.y+l.height,f=1;f<this._items.length;f++)o=this._items[f],a=o.getBounds(),this._contentFactor=Math.max(this._contentFactor,o.getContentSize().x/a.width),l=o.getClippedBounds().getBoundingBox(),h=Math.min(h,l.x),u=Math.min(u,l.y),c=Math.max(c,l.x+l.width),d=Math.max(d,l.y+l.height);this._homeBounds=new t.Rect(h,u,c-h,d-u),this._contentSize=new t.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}(this._contentFactor!==s||!this._homeBounds.equals(i)||!this._contentSize.equals(r))&&this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(i){this.raiseEvent("remove-item",{item:i})}})})(e)})(ta)),ta.exports}var df=xw();const dr=yw(df),ww=Dy({__proto__:null,default:dr},[df]);var Tw=Object.defineProperty,Ew=(n,e,t)=>e in n?Tw(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ff=(n,e,t)=>Ew(n,typeof e!="symbol"?e+"":e,t),pf=Object.prototype.hasOwnProperty;function fr(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&fr(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(pf.call(n,t)&&++i&&!pf.call(e,t)||!(t in e)||!fr(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}var uh=(n=>(n.EDIT="EDIT",n.SELECT="SELECT",n.NONE="NONE",n))(uh||{});const Ft=[];for(let n=0;n<256;++n)Ft.push((n+256).toString(16).slice(1));function bw(n,e=0){return(Ft[n[e+0]]+Ft[n[e+1]]+Ft[n[e+2]]+Ft[n[e+3]]+"-"+Ft[n[e+4]]+Ft[n[e+5]]+"-"+Ft[n[e+6]]+Ft[n[e+7]]+"-"+Ft[n[e+8]]+Ft[n[e+9]]+"-"+Ft[n[e+10]]+Ft[n[e+11]]+Ft[n[e+12]]+Ft[n[e+13]]+Ft[n[e+14]]+Ft[n[e+15]]).toLowerCase()}let ch;const Sw=new Uint8Array(16);function Aw(){if(!ch){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ch=crypto.getRandomValues.bind(crypto)}return ch(Sw)}const Rw=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),gf={randomUUID:Rw};function Cw(n,e,t){var i;n=n||{};const r=n.random??((i=n.rng)==null?void 0:i.call(n))??Aw();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,bw(r)}function Pw(n,e,t){return gf.randomUUID&&!n?gf.randomUUID():Cw(n)}const dh=n=>{const e=t=>{const i={...t};return t.created&&typeof t.created=="string"&&(i.created=new Date(t.created)),t.updated&&typeof t.updated=="string"&&(i.updated=new Date(t.updated)),i};return{...n,bodies:(n.bodies||[]).map(e),target:e(n.target)}},Iw=(n,e,t,i)=>({id:Pw(),annotation:typeof n=="string"?n:n.id,created:t||new Date,creator:i,...e}),Dw=(n,e)=>{const t=new Set(n.bodies.map(i=>i.id));return e.bodies.filter(i=>!t.has(i.id))},Mw=(n,e)=>{const t=new Set(e.bodies.map(i=>i.id));return n.bodies.filter(i=>!t.has(i.id))},Ow=(n,e)=>e.bodies.map(t=>{const i=n.bodies.find(r=>r.id===t.id);return{newBody:t,oldBody:i&&!fr(i,t)?i:void 0}}).filter(({oldBody:t})=>t).map(({oldBody:t,newBody:i})=>({oldBody:t,newBody:i})),Lw=(n,e)=>!fr(n.target,e.target),Bw=(n,e)=>{const t=Dw(n,e),i=Mw(n,e),r=Ow(n,e);return{oldValue:n,newValue:e,bodiesCreated:t.length>0?t:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:r.length>0?r:void 0,targetUpdated:Lw(n,e)?{oldTarget:n.target,newTarget:e.target}:void 0}};var Nn=(n=>(n.LOCAL="LOCAL",n.REMOTE="REMOTE",n.SILENT="SILENT",n))(Nn||{});const Fw=(n,e)=>{const t=new Set((n.created||[]).map(c=>c.id)),i=new Set((n.updated||[]).map(({newValue:c})=>c.id)),r=new Set((e.created||[]).map(c=>c.id)),s=new Set((e.deleted||[]).map(c=>c.id)),o=new Set((e.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((e.updated||[]).filter(({oldValue:c})=>t.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(n.created||[]).filter(c=>!s.has(c.id)).map(c=>o.has(c.id)?e.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...e.created||[]],h=[...(n.deleted||[]).filter(c=>!r.has(c.id)),...(e.deleted||[]).filter(c=>!t.has(c.id))],u=[...(n.updated||[]).filter(({newValue:c})=>!s.has(c.id)).map(c=>{const{oldValue:d,newValue:f}=c;if(o.has(f.id)){const p=e.updated.find(g=>g.oldValue.id===f.id).newValue;return Bw(d,p)}else return c}),...(e.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}};let Nw=()=>({emit(n,...e){for(let t=this.events[n]||[],i=0,r=t.length;i<r;i++)t[i](...e)},events:{},on(n,e){var t;return((t=this.events)[n]||(t[n]=[])).push(e),()=>{var i;this.events[n]=(i=this.events[n])==null?void 0:i.filter(r=>e!==r)}}});const kw=250,Uw=(n,e)=>{const t=Nw(),i=e?.changes||[];let r=e?e.pointer:-1,s=!1,o=0;const a=p=>{if(!s){const{changes:g}=p,m=performance.now();if(m-o>kw)i.splice(r+1),i.push(g),r=i.length-1;else{const v=i.length-1;i[v]=Fw(i[v],g)}o=m}s=!1};n.observe(a,{origin:Nn.LOCAL});const l=p=>p&&p.length>0&&n.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&n.bulkAddAnnotations(p,!1),u=p=>p&&p.length>0&&n.bulkUpdateAnnotations(p.map(({oldValue:g})=>g)),c=p=>p&&p.length>0&&n.bulkUpdateAnnotations(p.map(({newValue:g})=>g)),d=p=>p&&p.length>0&&n.bulkAddAnnotations(p,!1),f=p=>p&&p.length>0&&n.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>r,canUndo:()=>r>-1,destroy:()=>n.unobserve(a),getHistory:()=>({changes:[...i],pointer:r}),on:(p,g)=>t.on(p,g),redo:()=>{if(i.length-1>r){s=!0;const{created:p,updated:g,deleted:m}=i[r+1];h(p),c(g),f(m),t.emit("redo",i[r+1]),r+=1}},undo:()=>{if(r>-1){s=!0;const{created:p,updated:g,deleted:m}=i[r];l(p),u(g),d(m),t.emit("undo",i[r]),r-=1}}}},Hw=(n,e,t,i)=>{const{hover:r,selection:s,store:o,viewport:a}=n,l=new Map;let h=[],u,c;const d=(v,_)=>{l.has(v)?l.get(v).push(_):l.set(v,[_])},f=(v,_)=>{const y=l.get(v);if(y){const w=y.indexOf(_);w!==-1&&y.splice(w,1)}},p=(v,_,y)=>{l.has(v)&&setTimeout(()=>{l.get(v).forEach(w=>{if(t){const R=Array.isArray(_)?_.map(C=>t.serialize(C)):t.serialize(_),M=y?y instanceof PointerEvent?y:t.serialize(y):void 0;w(R,M)}else w(_,y)})},1)},g=()=>{const{selected:v}=s,_=(v||[]).map(({id:y})=>o.getAnnotation(y));_.forEach(y=>{const w=h.find(R=>R.id===y.id);(!w||!fr(w,y))&&p("updateAnnotation",y,w)}),h=h.map(y=>_.find(({id:w})=>w===y.id)||y)};s.subscribe(({selected:v})=>{if(!(h.length===0&&v.length===0)){if(h.length===0&&v.length>0)h=v.map(({id:_})=>o.getAnnotation(_));else if(h.length>0&&v.length===0)h.forEach(_=>{const y=o.getAnnotation(_.id);y&&!fr(y,_)&&p("updateAnnotation",y,_)}),h=[];else{const _=new Set(h.map(w=>w.id)),y=new Set(v.map(({id:w})=>w));h.filter(w=>!y.has(w.id)).forEach(w=>{const R=o.getAnnotation(w.id);R&&!fr(R,w)&&p("updateAnnotation",R,w)}),h=[...h.filter(w=>y.has(w.id)),...v.filter(({id:w})=>!_.has(w)).map(({id:w})=>o.getAnnotation(w))]}p("selectionChanged",h)}}),r.subscribe(v=>{!u&&v?p("mouseEnterAnnotation",o.getAnnotation(v)):u&&!v?p("mouseLeaveAnnotation",o.getAnnotation(u)):u&&v&&(p("mouseLeaveAnnotation",o.getAnnotation(u)),p("mouseEnterAnnotation",o.getAnnotation(v))),u=v}),a?.subscribe(v=>p("viewportIntersect",v.map(_=>o.getAnnotation(_)))),o.observe(v=>{i&&(c&&clearTimeout(c),c=setTimeout(g,1e3));const{created:_,deleted:y}=v.changes;(_||[]).forEach(w=>p("createAnnotation",w)),(y||[]).forEach(w=>p("deleteAnnotation",w)),(v.changes.updated||[]).filter(w=>[...w.bodiesCreated||[],...w.bodiesDeleted||[],...w.bodiesUpdated||[]].length>0).forEach(({oldValue:w,newValue:R})=>{const M=h.find(C=>C.id===w.id)||w;h=h.map(C=>C.id===w.id?R:C),p("updateAnnotation",R,M)})},{origin:Nn.LOCAL}),o.observe(v=>{if(h){const _=new Set(h.map(w=>w.id)),y=(v.changes.updated||[]).filter(({newValue:w})=>_.has(w.id)).map(({newValue:w})=>w);y.length>0&&(h=h.map(w=>y.find(R=>R.id===w.id)||w))}},{origin:Nn.REMOTE});const m=v=>_=>{const{updated:y}=_;v?(y||[]).forEach(w=>p("updateAnnotation",w.oldValue,w.newValue)):(y||[]).forEach(w=>p("updateAnnotation",w.newValue,w.oldValue))};return e.on("undo",m(!0)),e.on("redo",m(!1)),{on:d,off:f,emit:p}},zw=n=>e=>e.reduce((t,i)=>{const{parsed:r,error:s}=n.parse(i);return s?{parsed:t.parsed,failed:[...t.failed,i]}:r?{parsed:[...t.parsed,r],failed:t.failed}:{...t}},{parsed:[],failed:[]}),Gw=(n,e,t)=>{const{store:i,selection:r}=n,s=v=>{if(t){const{parsed:_,error:y}=t.parse(v);_?i.addAnnotation(_,Nn.REMOTE):console.error(y)}else i.addAnnotation(dh(v),Nn.REMOTE)},o=()=>r.clear(),a=()=>i.clear(),l=v=>{const _=i.getAnnotation(v);return t&&_?t.serialize(_):_},h=()=>t?i.all().map(t.serialize):i.all(),u=()=>{var v;const _=(((v=r.selected)==null?void 0:v.map(y=>y.id))||[]).map(y=>i.getAnnotation(y)).filter(Boolean);return t?_.map(t.serialize):_},c=(v,_=!0)=>fetch(v).then(y=>y.json()).then(y=>(f(y,_),y)),d=v=>{if(typeof v=="string"){const _=i.getAnnotation(v);if(i.deleteAnnotation(v),_)return t?t.serialize(_):_}else{const _=t?t.parse(v).parsed:v;if(_)return i.deleteAnnotation(_),v}},f=(v,_=!0)=>{if(t){const y=t.parseAll||zw(t),{parsed:w,failed:R}=y(v);R.length>0&&console.warn(`Discarded ${R.length} invalid annotations`,R),i.bulkAddAnnotations(w,_,Nn.REMOTE)}else i.bulkAddAnnotations(v.map(dh),_,Nn.REMOTE)},p=(v,_)=>{v?r.setSelected(v,_):r.clear()},g=v=>{r.setUserSelectAction(v)},m=v=>{if(t){const _=t.parse(v).parsed,y=t.serialize(i.getAnnotation(_.id));return i.updateAnnotation(_),y}else{const _=i.getAnnotation(v.id);return i.updateAnnotation(dh(v)),_}};return{addAnnotation:s,cancelSelected:o,canRedo:e.canRedo,canUndo:e.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:e.getHistory,getSelected:u,loadAnnotations:c,redo:e.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:g,undo:e.undo,updateAnnotation:m}},Vw="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ww=n=>crypto.getRandomValues(new Uint8Array(n)),jw=(n,e,t)=>{let i=(2<<Math.log2(n.length-1))-1,r=-~(1.6*i*e/n.length);return(s=e)=>{let o="";for(;;){let a=t(r),l=r|0;for(;l--;)if(o+=n[a[l]&i]||"",o.length>=s)return o}}},Xw=(n,e=21)=>jw(n,e|0,Ww),Yw=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n|=0));for(;n--;)e+=Vw[t[n]&63];return e};const qw=()=>({isGuest:!0,id:Xw("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Zw=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],Kw=()=>{const n=[...Zw];return{assignRandomColor:()=>{const e=Math.floor(Math.random()*n.length),t=n[e];return n.splice(e,1),t},releaseColor:e=>n.push(e)}};Yw();var Qw=Object.defineProperty,Jw=(n,e,t)=>e in n?Qw(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,mf=(n,e,t)=>Jw(n,typeof e!="symbol"?e+"":e,t);function et(){}function fh(n,e){for(const t in e)n[t]=e[t];return n}function vf(n){return n()}function yf(){return Object.create(null)}function di(n){n.forEach(vf)}function ut(n){return typeof n=="function"}function vt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function $w(n){return Object.keys(n).length===0}function _f(n,...e){if(n==null){for(const i of e)i(void 0);return et}const t=n.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function ph(n,e,t){n.$$.on_destroy.push(_f(e,t))}function eT(n,e,t,i){if(n){const r=xf(n,e,t,i);return n[0](r)}}function xf(n,e,t,i){return n[1]&&i?fh(t.ctx.slice(),n[1](i(e))):t.ctx}function tT(n,e,t,i){if(n[2]&&i){const r=n[2](i(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const s=[],o=Math.max(e.dirty.length,r.length);for(let a=0;a<o;a+=1)s[a]=e.dirty[a]|r[a];return s}return e.dirty|r}return e.dirty}function iT(n,e,t,i,r,s){if(r){const o=xf(e,t,i,s);n.p(o,r)}}function nT(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let i=0;i<t;i++)e[i]=-1;return e}return-1}function wf(n){const e={};for(const t in n)t[0]!=="$"&&(e[t]=n[t]);return e}function Kr(n){return n??""}function ke(n,e){n.appendChild(e)}function ge(n,e,t){n.insertBefore(e,t||null)}function pe(n){n.parentNode&&n.parentNode.removeChild(n)}function pr(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function ae(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function Tf(n){return document.createTextNode(n)}function Jt(){return Tf(" ")}function fi(){return Tf("")}function Xe(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function b(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function rT(n){return Array.from(n.childNodes)}function Zi(n,e,t){n.classList.toggle(e,!!t)}function sT(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}let Ks;function Qs(n){Ks=n}function Ef(){if(!Ks)throw new Error("Function called outside component initialization");return Ks}function gr(n){Ef().$$.on_mount.push(n)}function kn(){const n=Ef();return(e,t,{cancelable:i=!1}={})=>{const r=n.$$.callbacks[e];if(r){const s=sT(e,t,{cancelable:i});return r.slice().forEach(o=>{o.call(n,s)}),!s.defaultPrevented}return!0}}function At(n,e){const t=n.$$.callbacks[e.type];t&&t.slice().forEach(i=>i.call(this,e))}const Qr=[],ia=[];let Jr=[];const bf=[],Sf=Promise.resolve();let gh=!1;function Af(){gh||(gh=!0,Sf.then(Cf))}function Rf(){return Af(),Sf}function mh(n){Jr.push(n)}const vh=new Set;let $r=0;function Cf(){if($r!==0)return;const n=Ks;do{try{for(;$r<Qr.length;){const e=Qr[$r];$r++,Qs(e),oT(e.$$)}}catch(e){throw Qr.length=0,$r=0,e}for(Qs(null),Qr.length=0,$r=0;ia.length;)ia.pop()();for(let e=0;e<Jr.length;e+=1){const t=Jr[e];vh.has(t)||(vh.add(t),t())}Jr.length=0}while(Qr.length);for(;bf.length;)bf.pop()();gh=!1,vh.clear(),Qs(n)}function oT(n){if(n.fragment!==null){n.update(),di(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(mh)}}function aT(n){const e=[],t=[];Jr.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),Jr=e}const na=new Set;let mr;function $t(){mr={r:0,c:[],p:mr}}function ei(){mr.r||di(mr.c),mr=mr.p}function we(n,e){n&&n.i&&(na.delete(n),n.i(e))}function Pe(n,e,t,i){if(n&&n.o){if(na.has(n))return;na.add(n),mr.c.push(()=>{na.delete(n),i&&(t&&n.d(1),i())}),n.o(e)}else i&&i()}function ai(n){return n?.length!==void 0?n:Array.from(n)}function Et(n){n&&n.c()}function xt(n,e,t){const{fragment:i,after_update:r}=n.$$;i&&i.m(e,t),mh(()=>{const s=n.$$.on_mount.map(vf).filter(ut);n.$$.on_destroy?n.$$.on_destroy.push(...s):di(s),n.$$.on_mount=[]}),r.forEach(mh)}function wt(n,e){const t=n.$$;t.fragment!==null&&(aT(t.after_update),di(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function lT(n,e){n.$$.dirty[0]===-1&&(Qr.push(n),Af(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Nt(n,e,t,i,r,s,o=null,a=[-1]){const l=Ks;Qs(n);const h=n.$$={fragment:null,ctx:[],props:s,update:et,not_equal:r,bound:yf(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:yf(),dirty:a,skip_bound:!1,root:e.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=t?t(n,e.props||{},(c,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&r(h.ctx[c],h.ctx[c]=p)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](p),u&&lT(n,c)),d}):[],h.update(),u=!0,di(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const c=rT(e.target);h.fragment&&h.fragment.l(c),c.forEach(pe)}else h.fragment&&h.fragment.c();e.intro&&we(n.$$.fragment),xt(n,e.target,e.anchor),Cf()}Qs(l)}class kt{constructor(){mf(this,"$$"),mf(this,"$$set")}$destroy(){wt(this,1),this.$destroy=et}$on(e,t){if(!ut(t))return et;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}$set(e){this.$$set&&!$w(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const hT="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(hT);var Ie=(n=>(n.ELLIPSE="ELLIPSE",n.MULTIPOLYGON="MULTIPOLYGON",n.POLYGON="POLYGON",n.POLYLINE="POLYLINE",n.RECTANGLE="RECTANGLE",n.LINE="LINE",n))(Ie||{}),uT={exports:{}};(function(n){(function(){function e(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function t(a,l,h){var u=l.x,c=l.y,d=h.x-u,f=h.y-c;if(d!==0||f!==0){var p=((a.x-u)*d+(a.y-c)*f)/(d*d+f*f);p>1?(u=h.x,c=h.y):p>0&&(u+=d*p,c+=f*p)}return d=a.x-u,f=a.y-c,d*d+f*f}function i(a,l){for(var h=a[0],u=[h],c,d=1,f=a.length;d<f;d++)c=a[d],e(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function r(a,l,h,u,c){for(var d=u,f,p=l+1;p<h;p++){var g=t(a[p],a[l],a[h]);g>d&&(f=p,d=g)}d>u&&(f-l>1&&r(a,l,f,u,c),c.push(a[f]),h-f>1&&r(a,f,h,u,c))}function s(a,l){var h=a.length-1,u=[a[0]];return r(a,0,h,l,u),u.push(a[h]),u}function o(a,l,h){if(a.length<=2)return a;var u=l!==void 0?l*l:1;return a=h?a:i(a,u),a=s(a,u),a}n.exports=o,n.exports.default=o})()})(uT);const yh={},es=(n,e)=>yh[n]=e,_h=n=>yh[n.type].area(n),cT=(n,e,t,i)=>yh[n.type].intersects(n,e,t,i),ti=n=>{let e=1/0,t=1/0,i=-1/0,r=-1/0;return n.forEach(([s,o])=>{e=Math.min(e,s),t=Math.min(t,o),i=Math.max(i,s),r=Math.max(r,o)}),{minX:e,minY:t,maxX:i,maxY:r}},ra=n=>{let e=0,t=n.length-1;for(let i=0;i<n.length;i++)e+=(n[t][0]+n[i][0])*(n[t][1]-n[i][1]),t=i;return Math.abs(.5*e)},sa=(n,e,t)=>{let i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){const o=n[r][0],a=n[r][1],l=n[s][0],h=n[s][1];a>t!=h>t&&e<(l-o)*(t-a)/(h-a)+o&&(i=!i)}return i},dT=(n,e=!0)=>{let t="M ";return n.forEach(([i,r],s)=>{s===0?t+=`${i},${r}`:t+=` L ${i},${r}`}),e&&(t+=" Z"),t},oa=(n,e)=>{const t=Math.abs(e[0]-n[0]),i=Math.abs(e[1]-n[1]);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))},fT={area:n=>Math.PI*n.geometry.rx*n.geometry.ry,intersects:(n,e,t)=>{const{cx:i,cy:r,rx:s,ry:o}=n.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=e-i,c=t-r,d=l*u+h*c,f=h*u-l*c;return d*d/(s*s)+f*f/(o*o)<=1}};es(Ie.ELLIPSE,fT);const pT={area:n=>0,intersects:(n,e,t,i=2)=>{const[[r,s],[o,a]]=n.geometry.points,l=Math.abs((a-s)*e-(o-r)*t+o*s-a*r),h=oa([r,s],[o,a]);return l/h<=i}};es(Ie.LINE,pT);const gT={area:n=>{const{polygons:e}=n.geometry;return e.reduce((t,i)=>{const[r,...s]=i.rings,o=ra(r.points),a=s.reduce((l,h)=>l+ra(h.points),0);return t+o-a},0)},intersects:(n,e,t)=>{const{polygons:i}=n.geometry;for(const r of i){const[s,...o]=r.rings;if(sa(s.points,e,t)){let a=!1;for(const l of o)if(sa(l.points,e,t)){a=!0;break}if(!a)return!0}}return!1}},xh=n=>{const e=n.reduce((t,i)=>[...t,...i.rings[0].points],[]);return ti(e)},Oi=n=>n.rings.map(e=>dT(e.points)).join(" "),mT=n=>n.polygons.reduce((e,t)=>[...e,...t.rings.reduce((i,r)=>[...i,...r.points],[])],[]);es(Ie.MULTIPOLYGON,gT);const vT={area:n=>{const e=n.geometry.points;return ra(e)},intersects:(n,e,t)=>{const i=n.geometry.points;return sa(i,e,t)}};es(Ie.POLYGON,vT);const yT={area:n=>{const e=n.geometry;if(!e.closed||e.points.length<3)return 0;const t=wh(e.points,e.closed);return ra(t)},intersects:(n,e,t,i=2)=>{const r=n.geometry;if(r.closed){const s=wh(r.points,r.closed);return sa(s,e,t)}else return _T(r,[e,t],i)}},wh=(n,e=!1)=>{const t=[];for(let i=0;i<n.length;i++){const r=n[i],s=n[(i+1)%n.length];if(t.push(r.point),(i<n.length-1||e)&&(r.type==="CURVE"||s.type=="CURVE")){const o=Pf(r.point,r.type==="CURVE"&&r.outHandle||r.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);t.push(...o.slice(1))}}return t},Pf=(n,e,t,i,r=10)=>{const s=[];for(let o=0;o<=r;o++){const a=o/r,l=Math.pow(1-a,3)*n[0]+3*Math.pow(1-a,2)*a*e[0]+3*(1-a)*Math.pow(a,2)*t[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*n[1]+3*Math.pow(1-a,2)*a*e[1]+3*(1-a)*Math.pow(a,2)*t[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},_T=(n,e,t)=>{for(let i=0;i<n.points.length-1;i++){const r=n.points[i],s=n.points[i+1];if(r.type==="CURVE"||s.type==="CURVE"){const o=Pf(r.point,r.type==="CURVE"&&r.outHandle||r.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let a=0;a<o.length-1;a++)if(If(e,o[a],o[a+1])<=t)return!0}else if(If(e,r.point,s.point)<=t)return!0}return!1},If=(n,e,t)=>{const[i,r]=n,[s,o]=e,[a,l]=t,h=a-s,u=l-o,c=Math.sqrt(h*h+u*u);if(c===0)return Math.sqrt((i-s)*(i-s)+(r-o)*(r-o));const d=((i-s)*h+(r-o)*u)/(c*c);return d<=0?Math.sqrt((i-s)*(i-s)+(r-o)*(r-o)):d>=1?Math.sqrt((i-a)*(i-a)+(r-l)*(r-l)):Math.abs((l-o)*i-(a-s)*r+a*o-l*s)/c},Th=n=>{if(!n.points||n.points.length===0)return"";const e=[],t=n.points[0];e.push(`M ${t.point[0]} ${t.point[1]}`);for(let i=1;i<n.points.length;i++){const r=n.points[i],s=n.points[i-1];if(r.type==="CURVE"||s.type==="CURVE"){const o=s.type==="CURVE"&&s.outHandle||s.point,a=r.type==="CURVE"&&r.inHandle||r.point,l=r.point;e.push(`C ${o[0]} ${o[1]} ${a[0]} ${a[1]} ${l[0]} ${l[1]}`)}else e.push(`L ${r.point[0]} ${r.point[1]}`)}if(n.closed){const i=n.points[n.points.length-1],r=n.points[0];if(i.type==="CURVE"||r.type==="CURVE"){const s=i.outHandle||i.point,o=r.inHandle||r.point,a=r.point;e.push(`C ${s[0]} ${s[1]} ${o[0]} ${o[1]} ${a[0]} ${a[1]}`)}e.push("Z")}return e.join(" ")};es(Ie.POLYLINE,yT);const xT={area:n=>n.geometry.w*n.geometry.h,intersects:(n,e,t)=>e>=n.geometry.x&&e<=n.geometry.x+n.geometry.w&&t>=n.geometry.y&&t<=n.geometry.y+n.geometry.h};es(Ie.RECTANGLE,xT);const Ti=n=>aa(n.target),aa=n=>{var e,t;return n?.annotation!==void 0&&((t=(e=n?.selector)==null?void 0:e.geometry)==null?void 0:t.bounds)!==void 0},wT=n=>n?.type==="FragmentSelector"?!0:typeof n=="string"?n.indexOf("#")<0?!1:/^#xywh(?:=(?:pixel:|percent:)?)\s*\d+(\.\d*)?,\s*\d+(\.\d*)?,\s*\d+(\.\d*)?,\s*\d+(\.\d*)?$/i.test(n):!1,TT=(n,e=!1)=>{const t=typeof n=="string"?n:n.value,i=/(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,r=[...t.matchAll(i)][0];if(!r)throw new Error("Not a MediaFragment: "+t);const[s,o,a,l,h,u,c]=r;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+t);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,f,p,g]=[l,h,u,c].map(parseFloat);return{type:Ie.RECTANGLE,geometry:{x:d,y:f,w:p,h:g,bounds:{minX:d,minY:e?f-g:f,maxX:d+p,maxY:e?f:f+g}}}},ET=n=>{const{x:e,y:t,w:i,h:r}=n;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${e},${t},${i},${r}`}},Df="http://www.w3.org/2000/svg",Mf=n=>{const e=i=>{Array.from(i.attributes).forEach(r=>{r.name.startsWith("on")&&i.removeAttribute(r.name)})},t=n.getElementsByTagName("script");return Array.from(t).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(n.querySelectorAll("*")).forEach(e),n},bT=n=>{const e=new XMLSerializer().serializeToString(n.documentElement).replace("<svg>",`<svg xmlns="${Df}">`);return new DOMParser().parseFromString(e,"image/svg+xml").documentElement},la=n=>{const e=new DOMParser().parseFromString(n,"image/svg+xml"),t=e.lookupPrefix(Df),i=e.lookupNamespaceURI(null);return t||i?Mf(e).firstChild:Mf(bT(e)).firstChild},ST=n=>{const e=Of(n),t=[];let i=[],r=[0,0];for(const s of e)switch(s.type.toUpperCase()){case"M":i.length>0&&(t.push({points:i}),i=[]),r=[s.args[0],s.args[1]],i.push([...r]);break;case"L":r=[s.args[0],s.args[1]],i.push([...r]);break;case"H":r=[s.args[0],r[1]],i.push([...r]);break;case"V":r=[r[0],s.args[0]],i.push([...r]);break;case"C":r=[s.args[4],s.args[5]],i.push([...r]);break;case"Z":break;default:console.warn(`Unsupported SVG path command: ${s.type}`);break}if(i.length>2&&t.push({points:i}),t.length>0){const s=ti(t[0].points);return{rings:t,bounds:s}}},AT=n=>{const{point:e,inHandle:t,outHandle:i}=n;if(!t||!i)return!1;const r=t[0]-e[0],s=t[1]-e[1],o=i[0]-e[0],a=i[1]-e[1],l=r*a-s*o;return Math.abs(l)<.01},RT=n=>{const e=Of(n);let t=[],i=[0,0],r=!1;for(let o=0;o<e.length;o++){const a=e[o];switch(a.type.toUpperCase()){case"M":i=[a.args[0],a.args[1]],t.push({type:"CORNER",point:[...i]});break;case"L":i=[a.args[0],a.args[1]],t.push({type:"CORNER",point:[...i]});break;case"C":const l=[a.args[0],a.args[1]],h=[a.args[2],a.args[3]],u=[a.args[4],a.args[5]];if(t.length>0){const d=t[t.length-1];(l[0]!==d.point[0]||l[1]!==d.point[1])&&(d.type="CURVE",d.outHandle=l)}const c={type:h[0]!==u[0]||h[1]!==u[1]?"CURVE":"CORNER",point:u};c.type==="CURVE"&&(c.inHandle=h),t.push(c),i=u;break;case"Z":r=!0;break;default:console.warn(`Unsupported SVG path command: ${a.type}`);break}}t=t.map(o=>AT(o)?{...o,locked:!0}:o);const s=ti(wh(t,r));return{points:t,closed:r,bounds:s}},Of=n=>{const e=[],t=n.replace(/,/g," ").trim(),i=/([MmLlHhVvCcZz])\s*([^MmLlHhVvCcZz]*)/g;let r;for(;(r=i.exec(t))!==null;){const[,s,o]=r,a=o.trim()===""?[]:o.trim().split(/\s+/).map(Number).filter(l=>!isNaN(l));e.push({type:s,args:a})}return e},CT=n=>{const[e,t,i]=n.match(/(<polygon points=["|'])([^("|')]*)/)||[],r=i.split(" ").map(s=>s.split(",").map(parseFloat));return{type:Ie.POLYGON,geometry:{points:r,bounds:ti(r)}}},PT=n=>{const e=la(n),t=parseFloat(e.getAttribute("cx")),i=parseFloat(e.getAttribute("cy")),r=parseFloat(e.getAttribute("rx")),s=parseFloat(e.getAttribute("ry")),o={minX:t-r,minY:i-s,maxX:t+r,maxY:i+s};return{type:Ie.ELLIPSE,geometry:{cx:t,cy:i,rx:r,ry:s,bounds:o}}},IT=n=>{const e=la(n),t=parseFloat(e.getAttribute("x1")),i=parseFloat(e.getAttribute("x2")),r=parseFloat(e.getAttribute("y1")),s=parseFloat(e.getAttribute("y2")),o={minX:Math.min(t,i),minY:Math.min(r,s),maxX:Math.max(t,i),maxY:Math.max(r,s)};return{type:Ie.LINE,geometry:{points:[[t,r],[i,s]],bounds:o}}},DT=n=>{const e=la(n),t=e.nodeName==="path"?e:Array.from(e.querySelectorAll("path"))[0],i=t?.getAttribute("d");if(!i)throw new Error("Could not parse SVG path");const r=RT(i);if(!r)throw new Error("Could not parse SVG path");return{type:Ie.POLYLINE,geometry:r}},MT=n=>{const e=la(n),t=(e.nodeName==="path"?[e]:Array.from(e.querySelectorAll("path"))).map(s=>s.getAttribute("d")||"").map(s=>ST(s)).filter(Boolean),i=t.reduce((s,o)=>[...s,...o.rings[0].points],[]),r=ti(i);return t.length===1&&t[0].rings.length===1?{type:Ie.POLYGON,geometry:{points:i,bounds:r}}:{type:Ie.MULTIPOLYGON,geometry:{polygons:t,bounds:r}}},OT=n=>{const e=typeof n=="string"?n:n.value;if(e.includes("<polygon points="))return CT(e);if(e.includes("<path ")&&(e.includes(" C ")||!e.includes("Z")))return DT(e);if(e.includes("<path "))return MT(e);if(e.includes("<ellipse "))return PT(e);if(e.includes("<line "))return IT(e);throw"Unsupported SVG shape: "+e},LT=n=>`<g>${n.polygons.map(e=>`<path fill-rule="evenodd" d="${Oi(e)}" />`).join("")}</g>`,BT=n=>{let e;switch(n.type){case Ie.POLYGON:{const t=n.geometry,{points:i}=t;e=`<svg><polygon points="${i.map(r=>r.join(",")).join(" ")}" /></svg>`;break}case Ie.ELLIPSE:{const t=n.geometry;e=`<svg><ellipse cx="${t.cx}" cy="${t.cy}" rx="${t.rx}" ry="${t.ry}" /></svg>`;break}case Ie.MULTIPOLYGON:{const t=n.geometry;e=`<svg>${LT(t)}</svg>`;break}case Ie.LINE:{const t=n.geometry,[[i,r],[s,o]]=t.points;e=`<svg><line x1="${i}" y1="${r}" x2="${s}" y2="${o}" /></svg>`;break}case Ie.POLYLINE:e=`<svg><path d="${Th(n.geometry)}" /></svg>`}if(e)return{type:"SvgSelector",value:e};throw`Unsupported shape type: ${n.type}`},Ut=[];for(let n=0;n<256;++n)Ut.push((n+256).toString(16).slice(1));function FT(n,e=0){return(Ut[n[e+0]]+Ut[n[e+1]]+Ut[n[e+2]]+Ut[n[e+3]]+"-"+Ut[n[e+4]]+Ut[n[e+5]]+"-"+Ut[n[e+6]]+Ut[n[e+7]]+"-"+Ut[n[e+8]]+Ut[n[e+9]]+"-"+Ut[n[e+10]]+Ut[n[e+11]]+Ut[n[e+12]]+Ut[n[e+13]]+Ut[n[e+14]]+Ut[n[e+15]]).toLowerCase()}let Eh;const NT=new Uint8Array(16);function kT(){if(!Eh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Eh=crypto.getRandomValues.bind(crypto)}return Eh(NT)}const UT=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Lf={randomUUID:UT};function HT(n,e,t){var i;n=n||{};const r=n.random??((i=n.rng)==null?void 0:i.call(n))??kT();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,FT(r)}function Bf(n,e,t){return Lf.randomUUID&&!n?Lf.randomUUID():HT(n)}var Ff=Object.prototype.hasOwnProperty;function Un(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&Un(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(Ff.call(n,t)&&++i&&!Ff.call(e,t)||!(t in e)||!Un(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}let zT=Symbol("clean"),Li=[],Hn=0;const ha=4;let bh=n=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(i){return t.lc=e.push(i),()=>{for(let s=Hn+ha;s<Li.length;)Li[s]===i?Li.splice(s,ha):s+=ha;let r=e.indexOf(i);~r&&(e.splice(r,1),--t.lc||t.off())}},notify(i,r){let s=!Li.length;for(let o of e)Li.push(o,t.value,i,r);if(s){for(Hn=0;Hn<Li.length;Hn+=ha)Li[Hn](Li[Hn+1],Li[Hn+2],Li[Hn+3]);Li.length=0}},off(){},set(i){let r=t.value;r!==i&&(t.value=i,t.notify(r))},subscribe(i){let r=t.listen(i);return i(t.value),r},value:n};return process.env.NODE_ENV!=="production"&&(t[zT]=()=>{e=[],t.lc=0,t.off()}),t};const GT=n=>{const e=bh(null);return n.observe(({changes:t})=>{const i=e.get();if(i){(t.deleted||[]).some(s=>s.id===i)&&e.set(null);const r=(t.updated||[]).find(({oldValue:s})=>s.id===i);r&&e.set(r.newValue.id)}}),{get current(){return e.get()},subscribe:e.subscribe.bind(e),set:e.set.bind(e)}};var Nf=(n=>(n.EDIT="EDIT",n.SELECT="SELECT",n.NONE="NONE",n))(Nf||{});const Sh={selected:[]},VT=(n,e,t)=>{const i=bh(Sh);let r=e;const s=()=>{Un(i.get(),Sh)||i.set(Sh)},o=()=>{var f;return((f=i.get().selected)==null?void 0:f.length)===0},a=f=>{if(o())return!1;const p=typeof f=="string"?f:f.id;return i.get().selected.some(g=>g.id===p)},l=(f,p)=>{let g;if(Array.isArray(f)){if(g=f.map(v=>n.getAnnotation(v)).filter(Boolean),g.length<f.length){console.warn("Invalid selection: "+f.filter(v=>!g.some(_=>_.id===v)));return}}else{const v=n.getAnnotation(f);if(!v){console.warn("Invalid selection: "+f);return}g=[v]}const m=g.reduce((v,_)=>{const y=d(_);return y==="EDIT"?[...v,{id:_.id,editable:!0}]:y==="SELECT"?[...v,{id:_.id}]:v},[]);i.set({selected:m,event:p})},h=(f,p)=>{const g=Array.isArray(f)?f:[f],m=g.map(v=>n.getAnnotation(v)).filter(v=>!!v);i.set({selected:m.map(v=>{const _=p===void 0?d(v)==="EDIT":p;return{id:v.id,editable:_}})}),m.length!==g.length&&console.warn("Invalid selection",f)},u=f=>{if(o())return!1;const{selected:p}=i.get();p.some(({id:g})=>f.includes(g))&&i.set({selected:p.filter(({id:g})=>!f.includes(g))})},c=f=>{r=f,h(i.get().selected.map(({id:p})=>p))},d=f=>WT(f,r,t);return n.observe(({changes:f})=>u((f.deleted||[]).map(p=>p.id))),{get event(){const f=i.get();return f?f.event:null},get selected(){const f=i.get();return f?[...f.selected]:null},get userSelectAction(){return r},clear:s,evalSelectAction:d,isEmpty:o,isSelected:a,setSelected:h,setUserSelectAction:c,subscribe:i.subscribe.bind(i),userSelect:l}},WT=(n,e,t)=>{const i=t?t.serialize(n):n;return typeof e=="function"?e(i):e||"EDIT"},Ht=[];for(let n=0;n<256;++n)Ht.push((n+256).toString(16).slice(1));function jT(n,e=0){return(Ht[n[e+0]]+Ht[n[e+1]]+Ht[n[e+2]]+Ht[n[e+3]]+"-"+Ht[n[e+4]]+Ht[n[e+5]]+"-"+Ht[n[e+6]]+Ht[n[e+7]]+"-"+Ht[n[e+8]]+Ht[n[e+9]]+"-"+Ht[n[e+10]]+Ht[n[e+11]]+Ht[n[e+12]]+Ht[n[e+13]]+Ht[n[e+14]]+Ht[n[e+15]]).toLowerCase()}let Ah;const XT=new Uint8Array(16);function YT(){if(!Ah){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ah=crypto.getRandomValues.bind(crypto)}return Ah(XT)}const qT=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),kf={randomUUID:qT};function ZT(n,e,t){var i;n=n||{};const r=n.random??((i=n.rng)==null?void 0:i.call(n))??YT();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,jT(r)}function KT(n,e,t){return kf.randomUUID&&!n?kf.randomUUID():ZT(n)}const Rh=n=>{const e=t=>{const i={...t};return t.created&&typeof t.created=="string"&&(i.created=new Date(t.created)),t.updated&&typeof t.updated=="string"&&(i.updated=new Date(t.updated)),i};return{...n,bodies:(n.bodies||[]).map(e),target:e(n.target)}},QT=(n,e)=>{const t=new Set(n.bodies.map(i=>i.id));return e.bodies.filter(i=>!t.has(i.id))},JT=(n,e)=>{const t=new Set(e.bodies.map(i=>i.id));return n.bodies.filter(i=>!t.has(i.id))},$T=(n,e)=>e.bodies.map(t=>{const i=n.bodies.find(r=>r.id===t.id);return{newBody:t,oldBody:i&&!Un(i,t)?i:void 0}}).filter(({oldBody:t})=>t).map(({oldBody:t,newBody:i})=>({oldBody:t,newBody:i})),eE=(n,e)=>!Un(n.target,e.target),Uf=(n,e)=>{const t=QT(n,e),i=JT(n,e),r=$T(n,e);return{oldValue:n,newValue:e,bodiesCreated:t.length>0?t:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:r.length>0?r:void 0,targetUpdated:eE(n,e)?{oldTarget:n.target,newTarget:e.target}:void 0}};var ot=(n=>(n.LOCAL="LOCAL",n.REMOTE="REMOTE",n.SILENT="SILENT",n))(ot||{});const tE=(n,e)=>{var t,i;const{changes:r,origin:s}=e;if(!(n.options.origin?n.options.origin===s:s!=="SILENT"))return!1;if(n.options.ignore){const{ignore:o}=n.options,a=l=>l&&l.length>0;if(!(a(r.created)||a(r.deleted))){const l=(t=r.updated)==null?void 0:t.some(u=>a(u.bodiesCreated)||a(u.bodiesDeleted)||a(u.bodiesUpdated)),h=(i=r.updated)==null?void 0:i.some(u=>u.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(n.options.annotations){const o=new Set([...(r.created||[]).map(a=>a.id),...(r.deleted||[]).map(a=>a.id),...(r.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(n.options.annotations)?n.options.annotations:[n.options.annotations]).find(a=>o.has(a))}else return!0},iE=(n,e)=>{const t=new Set((n.created||[]).map(c=>c.id)),i=new Set((n.updated||[]).map(({newValue:c})=>c.id)),r=new Set((e.created||[]).map(c=>c.id)),s=new Set((e.deleted||[]).map(c=>c.id)),o=new Set((e.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((e.updated||[]).filter(({oldValue:c})=>t.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(n.created||[]).filter(c=>!s.has(c.id)).map(c=>o.has(c.id)?e.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...e.created||[]],h=[...(n.deleted||[]).filter(c=>!r.has(c.id)),...(e.deleted||[]).filter(c=>!t.has(c.id))],u=[...(n.updated||[]).filter(({newValue:c})=>!s.has(c.id)).map(c=>{const{oldValue:d,newValue:f}=c;if(o.has(f.id)){const p=e.updated.find(g=>g.oldValue.id===f.id).newValue;return Uf(d,p)}else return c}),...(e.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}},ua=n=>{const e=n.id===void 0?KT():n.id;return{...n,id:e,bodies:n.bodies===void 0?[]:n.bodies.map(t=>({...t,annotation:e})),target:{...n.target,annotation:e}}},nE=n=>n.id!==void 0,rE=()=>{const n=new Map,e=new Map,t=[],i=(L,S={})=>{t.push({onChange:L,options:S})},r=L=>{const S=t.findIndex(I=>I.onChange==L);S>-1&&t.splice(S,1)},s=(L,S)=>{const I={origin:L,changes:{created:S.created||[],updated:S.updated||[],deleted:S.deleted||[]},state:[...n.values()]};t.forEach(B=>{tE(B,I)&&B.onChange(I)})},o=(L,S=ot.LOCAL)=>{if(L.id&&n.get(L.id))throw Error(`Cannot add annotation ${L.id} - exists already`);{const I=ua(L);n.set(I.id,I),I.bodies.forEach(B=>e.set(B.id,I.id)),s(S,{created:[I]})}},a=(L,S)=>{const I=ua(typeof L=="string"?S:L),B=typeof L=="string"?L:L.id,j=B&&n.get(B);if(j){const U=Uf(j,I);return B===I.id?n.set(B,I):(n.delete(B),n.set(I.id,I)),j.bodies.forEach(W=>e.delete(W.id)),I.bodies.forEach(W=>e.set(W.id,I.id)),U}else console.warn(`Cannot update annotation ${B} - does not exist`)},l=(L,S=ot.LOCAL,I=ot.LOCAL)=>{const B=nE(S)?I:S,j=a(L,S);j&&s(B,{updated:[j]})},h=(L,S=ot.LOCAL)=>{n.get(L.id)?l(L,S):o(L,S)},u=(L,S=ot.LOCAL)=>{const I=L.reduce((B,j)=>{const U=a(j);return U?[...B,U]:B},[]);I.length>0&&s(S,{updated:I})},c=(L,S=ot.LOCAL)=>{const I=L.map(ua),{toAdd:B,toUpdate:j}=I.reduce((W,ee)=>n.get(ee.id)?{...W,toUpdate:[...W.toUpdate,ee]}:{...W,toAdd:[...W.toAdd,ee]},{toAdd:[],toUpdate:[]}),U=j.map(W=>a(W,S)).filter(Boolean);B.forEach(W=>{n.set(W.id,W),W.bodies.forEach(ee=>e.set(ee.id,W.id))}),s(S,{created:B,updated:U})},d=(L,S=ot.LOCAL)=>{const I=n.get(L.annotation);if(I){const B={...I,bodies:[...I.bodies,L]};n.set(I.id,B),e.set(L.id,B.id),s(S,{updated:[{oldValue:I,newValue:B,bodiesCreated:[L]}]})}else console.warn(`Attempt to add body to missing annotation: ${L.annotation}`)},f=()=>[...n.values()],p=(L=ot.LOCAL)=>{const S=[...n.values()];n.clear(),e.clear(),s(L,{deleted:S})},g=(L,S=!0,I=ot.LOCAL)=>{const B=L.map(ua);if(S){const j=[...n.values()];n.clear(),e.clear(),B.forEach(U=>{n.set(U.id,U),U.bodies.forEach(W=>e.set(W.id,U.id))}),s(I,{created:B,deleted:j})}else{const j=L.reduce((U,W)=>{const ee=W.id&&n.get(W.id);return ee?[...U,ee]:U},[]);if(j.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${j.map(U=>U.id).join(", ")}`);B.forEach(U=>{n.set(U.id,U),U.bodies.forEach(W=>e.set(W.id,U.id))}),s(I,{created:B})}},m=L=>{const S=typeof L=="string"?L:L.id,I=n.get(S);if(I)return n.delete(S),I.bodies.forEach(B=>e.delete(B.id)),I;console.warn(`Attempt to delete missing annotation: ${S}`)},v=(L,S=ot.LOCAL)=>{const I=m(L);I&&s(S,{deleted:[I]})},_=(L,S=ot.LOCAL)=>{const I=L.reduce((B,j)=>{const U=m(j);return U?[...B,U]:B},[]);I.length>0&&s(S,{deleted:I})},y=L=>{const S=n.get(L.annotation);if(S){const I=S.bodies.find(B=>B.id===L.id);if(I){e.delete(I.id);const B={...S,bodies:S.bodies.filter(j=>j.id!==L.id)};return n.set(S.id,B),{oldValue:S,newValue:B,bodiesDeleted:[I]}}else console.warn(`Attempt to delete missing body ${L.id} from annotation ${L.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${L.annotation}`)},w=(L,S=ot.LOCAL)=>{const I=y(L);I&&s(S,{updated:[I]})},R=(L,S=ot.LOCAL)=>{const I=L.map(B=>y(B)).filter(Boolean);I.length>0&&s(S,{updated:I})},M=L=>{const S=n.get(L);return S?{...S}:void 0},C=L=>{const S=e.get(L);if(S){const I=M(S).bodies.find(B=>B.id===L);if(I)return I;console.error(`Store integrity error: body ${L} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${L}`)},O=(L,S)=>{if(L.annotation!==S.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const I=n.get(L.annotation);if(I){const B=I.bodies.find(U=>U.id===L.id),j={...I,bodies:I.bodies.map(U=>U.id===B.id?S:U)};return n.set(I.id,j),B.id!==S.id&&(e.delete(B.id),e.set(S.id,j.id)),{oldValue:I,newValue:j,bodiesUpdated:[{oldBody:B,newBody:S}]}}else console.warn(`Attempt to add body to missing annotation ${L.annotation}`)},N=(L,S,I=ot.LOCAL)=>{const B=O(L,S);B&&s(I,{updated:[B]})},X=(L,S=ot.LOCAL)=>{const I=L.map(B=>O({id:B.id,annotation:B.annotation},B)).filter(Boolean);s(S,{updated:I})},q=L=>{const S=n.get(L.annotation);if(S){const I={...S,target:{...S.target,...L}};return n.set(S.id,I),{oldValue:S,newValue:I,targetUpdated:{oldTarget:S.target,newTarget:L}}}else console.warn(`Attempt to update target on missing annotation: ${L.annotation}`)};return{addAnnotation:o,addBody:d,all:f,bulkAddAnnotations:g,bulkDeleteAnnotations:_,bulkDeleteBodies:R,bulkUpdateAnnotations:u,bulkUpdateBodies:X,bulkUpdateTargets:(L,S=ot.LOCAL)=>{const I=L.map(B=>q(B)).filter(Boolean);I.length>0&&s(S,{updated:I})},bulkUpsertAnnotations:c,clear:p,deleteAnnotation:v,deleteBody:w,getAnnotation:M,getBody:C,observe:i,unobserve:r,updateAnnotation:l,updateBody:N,updateTarget:(L,S=ot.LOCAL)=>{const I=q(L);I&&s(S,{updated:[I]})},upsertAnnotation:h}};let sE=()=>({emit(n,...e){for(let t=this.events[n]||[],i=0,r=t.length;i<r;i++)t[i](...e)},events:{},on(n,e){var t;return((t=this.events)[n]||(t[n]=[])).push(e),()=>{var i;this.events[n]=(i=this.events[n])==null?void 0:i.filter(r=>e!==r)}}});const oE=250,aE=(n,e)=>{const t=sE(),i=e?.changes||[];let r=e?e.pointer:-1,s=!1,o=0;const a=p=>{if(!s){const{changes:g}=p,m=performance.now();if(m-o>oE)i.splice(r+1),i.push(g),r=i.length-1;else{const v=i.length-1;i[v]=iE(i[v],g)}o=m}s=!1};n.observe(a,{origin:ot.LOCAL});const l=p=>p&&p.length>0&&n.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&n.bulkAddAnnotations(p,!1),u=p=>p&&p.length>0&&n.bulkUpdateAnnotations(p.map(({oldValue:g})=>g)),c=p=>p&&p.length>0&&n.bulkUpdateAnnotations(p.map(({newValue:g})=>g)),d=p=>p&&p.length>0&&n.bulkAddAnnotations(p,!1),f=p=>p&&p.length>0&&n.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>r,canUndo:()=>r>-1,destroy:()=>n.unobserve(a),getHistory:()=>({changes:[...i],pointer:r}),on:(p,g)=>t.on(p,g),redo:()=>{if(i.length-1>r){s=!0;const{created:p,updated:g,deleted:m}=i[r+1];h(p),c(g),f(m),t.emit("redo",i[r+1]),r+=1}},undo:()=>{if(r>-1){s=!0;const{created:p,updated:g,deleted:m}=i[r];l(p),u(g),d(m),t.emit("undo",i[r]),r-=1}}}},lE=()=>{const n=bh([]);return{subscribe:n.subscribe.bind(n),set:n.set.bind(n)}},hE=(n,e,t,i)=>{const{hover:r,selection:s,store:o,viewport:a}=n,l=new Map;let h=[],u,c;const d=(v,_)=>{l.has(v)?l.get(v).push(_):l.set(v,[_])},f=(v,_)=>{const y=l.get(v);if(y){const w=y.indexOf(_);w!==-1&&y.splice(w,1)}},p=(v,_,y)=>{l.has(v)&&setTimeout(()=>{l.get(v).forEach(w=>{if(t){const R=Array.isArray(_)?_.map(C=>t.serialize(C)):t.serialize(_),M=y?y instanceof PointerEvent?y:t.serialize(y):void 0;w(R,M)}else w(_,y)})},1)},g=()=>{const{selected:v}=s,_=(v||[]).map(({id:y})=>o.getAnnotation(y));_.forEach(y=>{const w=h.find(R=>R.id===y.id);(!w||!Un(w,y))&&p("updateAnnotation",y,w)}),h=h.map(y=>_.find(({id:w})=>w===y.id)||y)};s.subscribe(({selected:v})=>{if(!(h.length===0&&v.length===0)){if(h.length===0&&v.length>0)h=v.map(({id:_})=>o.getAnnotation(_));else if(h.length>0&&v.length===0)h.forEach(_=>{const y=o.getAnnotation(_.id);y&&!Un(y,_)&&p("updateAnnotation",y,_)}),h=[];else{const _=new Set(h.map(w=>w.id)),y=new Set(v.map(({id:w})=>w));h.filter(w=>!y.has(w.id)).forEach(w=>{const R=o.getAnnotation(w.id);R&&!Un(R,w)&&p("updateAnnotation",R,w)}),h=[...h.filter(w=>y.has(w.id)),...v.filter(({id:w})=>!_.has(w)).map(({id:w})=>o.getAnnotation(w))]}p("selectionChanged",h)}}),r.subscribe(v=>{!u&&v?p("mouseEnterAnnotation",o.getAnnotation(v)):u&&!v?p("mouseLeaveAnnotation",o.getAnnotation(u)):u&&v&&(p("mouseLeaveAnnotation",o.getAnnotation(u)),p("mouseEnterAnnotation",o.getAnnotation(v))),u=v}),a?.subscribe(v=>p("viewportIntersect",v.map(_=>o.getAnnotation(_)))),o.observe(v=>{i&&(c&&clearTimeout(c),c=setTimeout(g,1e3));const{created:_,deleted:y}=v.changes;(_||[]).forEach(w=>p("createAnnotation",w)),(y||[]).forEach(w=>p("deleteAnnotation",w)),(v.changes.updated||[]).filter(w=>[...w.bodiesCreated||[],...w.bodiesDeleted||[],...w.bodiesUpdated||[]].length>0).forEach(({oldValue:w,newValue:R})=>{const M=h.find(C=>C.id===w.id)||w;h=h.map(C=>C.id===w.id?R:C),p("updateAnnotation",R,M)})},{origin:ot.LOCAL}),o.observe(v=>{if(h){const _=new Set(h.map(w=>w.id)),y=(v.changes.updated||[]).filter(({newValue:w})=>_.has(w.id)).map(({newValue:w})=>w);y.length>0&&(h=h.map(w=>y.find(R=>R.id===w.id)||w))}},{origin:ot.REMOTE});const m=v=>_=>{const{updated:y}=_;v?(y||[]).forEach(w=>p("updateAnnotation",w.oldValue,w.newValue)):(y||[]).forEach(w=>p("updateAnnotation",w.newValue,w.oldValue))};return e.on("undo",m(!0)),e.on("redo",m(!1)),{on:d,off:f,emit:p}},uE=n=>e=>e.reduce((t,i)=>{const{parsed:r,error:s}=n.parse(i);return s?{parsed:t.parsed,failed:[...t.failed,i]}:r?{parsed:[...t.parsed,r],failed:t.failed}:{...t}},{parsed:[],failed:[]}),cE=(n,e,t)=>{const{store:i,selection:r}=n,s=v=>{if(t){const{parsed:_,error:y}=t.parse(v);_?i.addAnnotation(_,ot.REMOTE):console.error(y)}else i.addAnnotation(Rh(v),ot.REMOTE)},o=()=>r.clear(),a=()=>i.clear(),l=v=>{const _=i.getAnnotation(v);return t&&_?t.serialize(_):_},h=()=>t?i.all().map(t.serialize):i.all(),u=()=>{var v;const _=(((v=r.selected)==null?void 0:v.map(y=>y.id))||[]).map(y=>i.getAnnotation(y)).filter(Boolean);return t?_.map(t.serialize):_},c=(v,_=!0)=>fetch(v).then(y=>y.json()).then(y=>(f(y,_),y)),d=v=>{if(typeof v=="string"){const _=i.getAnnotation(v);if(i.deleteAnnotation(v),_)return t?t.serialize(_):_}else{const _=t?t.parse(v).parsed:v;if(_)return i.deleteAnnotation(_),v}},f=(v,_=!0)=>{if(t){const y=t.parseAll||uE(t),{parsed:w,failed:R}=y(v);R.length>0&&console.warn(`Discarded ${R.length} invalid annotations`,R),i.bulkAddAnnotations(w,_,ot.REMOTE)}else i.bulkAddAnnotations(v.map(Rh),_,ot.REMOTE)},p=(v,_)=>{v?r.setSelected(v,_):r.clear()},g=v=>{r.setUserSelectAction(v)},m=v=>{if(t){const _=t.parse(v).parsed,y=t.serialize(i.getAnnotation(_.id));return i.updateAnnotation(_),y}else{const _=i.getAnnotation(v.id);return i.updateAnnotation(Rh(v)),_}};return{addAnnotation:s,cancelSelected:o,canRedo:e.canRedo,canUndo:e.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:e.getHistory,getSelected:u,loadAnnotations:c,redo:e.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:g,undo:e.undo,updateAnnotation:m}},dE=(n,e,t)=>typeof e=="function"?e(n,t):e,fE=(n,e)=>typeof n!="function"&&typeof e!="function"?{...n||{},...e||{}}:(t,i)=>{const r=typeof n=="function"?n(t,i):n,s=typeof e=="function"?e(t,i):e;return{...r||{},...s||{}}},pE="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let gE=n=>crypto.getRandomValues(new Uint8Array(n)),mE=(n,e,t)=>{let i=(2<<Math.log2(n.length-1))-1,r=-~(1.6*i*e/n.length);return(s=e)=>{let o="";for(;;){let a=t(r),l=r|0;for(;l--;)if(o+=n[a[l]&i]||"",o.length>=s)return o}}},vE=(n,e=21)=>mE(n,e|0,gE),yE=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n|=0));for(;n--;)e+=pE[t[n]&63];return e};const _E=()=>({isGuest:!0,id:vE("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),xE=n=>{const e=JSON.stringify(n);let t=0;for(let i=0,r=e.length;i<r;i++){let s=e.charCodeAt(i);t=(t<<5)-t+s,t|=0}return`${t}`},Hf=n=>n?typeof n=="object"?{...n}:n:void 0,wE=(n,e)=>(Array.isArray(n)?n:[n]).map(t=>{const{id:i,type:r,purpose:s,value:o,created:a,modified:l,creator:h,...u}=t;return{id:i||`temp-${xE(t)}`,annotation:e,type:r,purpose:s,value:o,creator:Hf(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),TE=n=>n.map(e=>{var t;const{annotation:i,created:r,updated:s,...o}=e,a={...o,created:r?.toISOString(),modified:s?.toISOString()};return(t=a.id)!=null&&t.startsWith("temp-")&&delete a.id,a});yE();const EE=(n,e={strict:!0,invertY:!1})=>({parse:t=>bE(t,e),serialize:t=>SE(t,n,e)}),bE=(n,e={strict:!0,invertY:!1})=>{const t=n.id||Bf(),{creator:i,created:r,modified:s,body:o,...a}=n,l=wE(o||[],t),h=Array.isArray(n.target)?n.target[0]:n.target,u=typeof h=="string"?h:Array.isArray(h.selector)?h.selector[0]:h.selector,c=wT(u)?TT(u,e.invertY):u?.type==="SvgSelector"?OT(u):void 0,d=Array.isArray(a.target)?a.target[0]:a.targret;return c||!e.strict?{parsed:{...a,id:t,bodies:l,target:{created:r?new Date(r):void 0,creator:Hf(i),updated:s?new Date(s):void 0,...typeof d=="string"?{}:d,annotation:t,selector:c||u}}}:{error:Error(`Invalid selector: ${JSON.stringify(u)}`)}},SE=(n,e,t={strict:!0,invertY:!1})=>{const{selector:i,creator:r,created:s,updated:o,updatedBy:a,...l}=n.target;let h;try{h=i.type==Ie.RECTANGLE?ET(i.geometry):BT(i)}catch(c){if(t.strict)throw c;h=i}const u={...n,"@context":"http://www.w3.org/ns/anno.jsonld",id:n.id,type:"Annotation",body:TE(n.bodies),created:s?.toISOString(),creator:r,modified:o?.toISOString(),target:{...l,source:e,type:"SpecificResource",selector:h}};return delete u.bodies,typeof u.target!="string"&&"annotation"in u.target&&delete u.target.annotation,u},ts=[];function AE(n,e=et){let t;const i=new Set;function r(a){if(vt(n,a)&&(n=a,t)){const l=!ts.length;for(const h of i)h[1](),ts.push(h,n);if(l){for(let h=0;h<ts.length;h+=2)ts[h][0](ts[h+1]);ts.length=0}}}function s(a){r(a(n))}function o(a,l=et){const h=[a,l];return i.add(h),i.size===1&&(t=e(r,s)||et),a(n),()=>{i.delete(h),i.size===0&&t&&(t(),t=null)}}return{set:r,update:s,subscribe:o}}const RE=(n,e)=>{const{naturalWidth:t,naturalHeight:i}=n;if(!t&&!i){const{width:r,height:s}=n;e.setAttribute("viewBox",`0 0 ${r} ${s}`),n.addEventListener("load",o=>{const a=o.target;e.setAttribute("viewBox",`0 0 ${a.naturalWidth} ${a.naturalHeight}`)})}else e.setAttribute("viewBox",`0 0 ${t} ${i}`)},CE=(n,e)=>{RE(n,e);const{subscribe:t,set:i}=AE(1);let r;return window.ResizeObserver&&(r=new ResizeObserver(()=>{const s=e.getBoundingClientRect(),{width:o,height:a}=e.viewBox.baseVal,l=Math.max(s.width/o,s.height/a);i(l)}),r.observe(e.parentElement)),{destroy:()=>{r&&r.disconnect()},subscribe:t}},vr=(n,e,t)=>{const i=typeof e=="function"?e(n,t):e;if(i){const{fill:r,fillOpacity:s,stroke:o,strokeWidth:a,strokeOpacity:l}=i;let h="";return r&&(h+=`fill:${r};`),s||s===0?h+=`fill-opacity:${s};`:r&&(h+="fill-opacity:0.25;"),o&&(h+=`stroke:${o};`,h+=`stroke-width:${a||"1"};`,h+=`stroke-opacity:${l||"1"};`),h}},ca=(n,e=0)=>{const{minX:t,minY:i,maxX:r,maxY:s}=n;return{x:t-e,y:i-e,w:r-t+2*e,h:s-i+2*e}},Ei=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,PE=n=>({}),zf=n=>({grab:n[0]});function IE(n){let e,t,i,r;const s=n[8].default,o=eT(s,n,n[7],zf);return{c(){e=ae("g"),o&&o.c(),b(e,"class","a9s-annotation selected")},m(a,l){ge(a,e,l),o&&o.m(e,null),t=!0,i||(r=[Xe(e,"pointerup",n[2]),Xe(e,"pointermove",n[1])],i=!0)},p(a,[l]){o&&o.p&&(!t||l&128)&&iT(o,s,a,a[7],t?tT(s,a[7],l,PE):nT(a[7]),zf)},i(a){t||(we(o,a),t=!0)},o(a){Pe(o,a),t=!1},d(a){a&&pe(e),o&&o.d(a),i=!1,di(r)}}}function DE(n,e,t){let{$$slots:i={},$$scope:r}=e;const s=kn();let{shape:o}=e,{editor:a}=e,{transform:l}=e,{svgEl:h}=e,u,c,d;const f=m=>v=>{if(u=m,h){const{left:_,top:y}=h.getBoundingClientRect(),w=v.clientX-_,R=v.clientY-y;c=l.elementToImage(w,R)}else{const{offsetX:_,offsetY:y}=v;c=l.elementToImage(_,y)}d=o,v.target.setPointerCapture(v.pointerId),s("grab",v)},p=m=>{if(u){const[v,_]=l.elementToImage(m.offsetX,m.offsetY),y=[v-c[0],_-c[1]];t(3,o=a(d,u,y)),s("change",o)}},g=m=>{m.target.releasePointerCapture(m.pointerId),u=void 0,d=o,s("release",m)};return n.$$set=m=>{"shape"in m&&t(3,o=m.shape),"editor"in m&&t(4,a=m.editor),"transform"in m&&t(5,l=m.transform),"svgEl"in m&&t(6,h=m.svgEl),"$$scope"in m&&t(7,r=m.$$scope)},[f,p,g,o,a,l,h,r,i]}class Ch extends kt{constructor(e){super(),Nt(this,e,DE,IE,vt,{shape:3,editor:4,transform:5,svgEl:6})}}function ME(n){let e,t,i,r,s,o,a,l,h=n[3]&&Gf(n);return{c(){e=ae("g"),t=ae("circle"),h&&h.c(),r=ae("circle"),b(t,"class","a9s-handle-buffer svelte-qtyc7s"),b(t,"cx",n[0]),b(t,"cy",n[1]),b(t,"r",i=n[5]+6/n[2]),b(t,"role","button"),b(t,"tabindex","0"),b(r,"class",s=Kr(`a9s-handle-dot${n[3]?" selected":""}`)+" svelte-qtyc7s"),b(r,"cx",n[0]),b(r,"cy",n[1]),b(r,"r",n[5]),b(e,"class",o=`a9s-handle ${n[8].class||""}`.trim())},m(u,c){ge(u,e,c),ke(e,t),h&&h.m(e,null),ke(e,r),a||(l=[Xe(t,"dblclick",n[12]),Xe(t,"pointerenter",n[13]),Xe(t,"pointerleave",n[14]),Xe(t,"pointerdown",n[15]),Xe(t,"pointerdown",n[6]),Xe(t,"pointerup",n[16]),Xe(t,"pointerup",n[7])],a=!0)},p(u,c){c&1&&b(t,"cx",u[0]),c&2&&b(t,"cy",u[1]),c&36&&i!==(i=u[5]+6/u[2])&&b(t,"r",i),u[3]?h?h.p(u,c):(h=Gf(u),h.c(),h.m(e,r)):h&&(h.d(1),h=null),c&8&&s!==(s=Kr(`a9s-handle-dot${u[3]?" selected":""}`)+" svelte-qtyc7s")&&b(r,"class",s),c&1&&b(r,"cx",u[0]),c&2&&b(r,"cy",u[1]),c&32&&b(r,"r",u[5]),c&256&&o!==(o=`a9s-handle ${u[8].class||""}`.trim())&&b(e,"class",o)},d(u){u&&pe(e),h&&h.d(),a=!1,di(l)}}}function OE(n){let e,t,i,r,s,o,a,l,h;return{c(){e=ae("g"),t=ae("circle"),r=ae("circle"),o=ae("circle"),b(t,"cx",n[0]),b(t,"cy",n[1]),b(t,"r",i=n[5]*10),b(t,"class","a9s-touch-halo"),Zi(t,"touched",n[4]),b(r,"cx",n[0]),b(r,"cy",n[1]),b(r,"r",s=n[5]+10/n[2]),b(r,"class","a9s-handle-buffer svelte-qtyc7s"),b(r,"role","button"),b(r,"tabindex","0"),b(o,"class","a9s-handle-dot"),b(o,"cx",n[0]),b(o,"cy",n[1]),b(o,"r",a=n[5]+2/n[2]),b(e,"class","a9s-touch-handle")},m(u,c){ge(u,e,c),ke(e,t),ke(e,r),ke(e,o),l||(h=[Xe(r,"dblclick",n[9]),Xe(r,"pointerdown",n[10]),Xe(r,"pointerdown",n[6]),Xe(r,"pointerup",n[11]),Xe(r,"pointerup",n[7])],l=!0)},p(u,c){c&1&&b(t,"cx",u[0]),c&2&&b(t,"cy",u[1]),c&32&&i!==(i=u[5]*10)&&b(t,"r",i),c&16&&Zi(t,"touched",u[4]),c&1&&b(r,"cx",u[0]),c&2&&b(r,"cy",u[1]),c&36&&s!==(s=u[5]+10/u[2])&&b(r,"r",s),c&1&&b(o,"cx",u[0]),c&2&&b(o,"cy",u[1]),c&36&&a!==(a=u[5]+2/u[2])&&b(o,"r",a)},d(u){u&&pe(e),l=!1,di(h)}}}function Gf(n){let e,t;return{c(){e=ae("circle"),b(e,"class","a9s-handle-selected"),b(e,"cx",n[0]),b(e,"cy",n[1]),b(e,"r",t=n[5]+8/n[2])},m(i,r){ge(i,e,r)},p(i,r){r&1&&b(e,"cx",i[0]),r&2&&b(e,"cy",i[1]),r&36&&t!==(t=i[5]+8/i[2])&&b(e,"r",t)},d(i){i&&pe(e)}}}function LE(n){let e;function t(r,s){return Ei?OE:ME}let i=t()(n);return{c(){i.c(),e=fi()},m(r,s){i.m(r,s),ge(r,e,s)},p(r,[s]){i.p(r,s)},i:et,o:et,d(r){r&&pe(e),i.d(r)}}}function BE(n,e,t){let i,{x:r}=e,{y:s}=e,{scale:o}=e,{selected:a=void 0}=e,l=!1;const h=y=>{y.pointerType==="touch"&&t(4,l=!0)},u=()=>t(4,l=!1);function c(y){At.call(this,n,y)}function d(y){At.call(this,n,y)}function f(y){At.call(this,n,y)}function p(y){At.call(this,n,y)}function g(y){At.call(this,n,y)}function m(y){At.call(this,n,y)}function v(y){At.call(this,n,y)}function _(y){At.call(this,n,y)}return n.$$set=y=>{t(8,e=fh(fh({},e),wf(y))),"x"in y&&t(0,r=y.x),"y"in y&&t(1,s=y.y),"scale"in y&&t(2,o=y.scale),"selected"in y&&t(3,a=y.selected)},n.$$.update=()=>{n.$$.dirty&4&&t(5,i=4/o)},e=wf(e),[r,s,o,a,l,i,h,u,e,c,d,f,p,g,m,v,_]}class is extends kt{constructor(e){super(),Nt(this,e,BE,LE,vt,{x:0,y:1,scale:2,selected:3})}}function FE(n){let e,t,i,r,s,o,a;return{c(){e=ae("g"),t=ae("circle"),r=ae("circle"),s=ae("circle"),b(t,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),b(t,"cx",n[0]),b(t,"cy",n[1]),b(t,"r",i=1.75*n[2]),b(r,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),b(r,"cx",n[0]),b(r,"cy",n[1]),b(r,"r",n[2]),b(s,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),b(s,"cx",n[0]),b(s,"cy",n[1]),b(s,"r",n[2]),b(e,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){ge(l,e,h),ke(e,t),ke(e,r),ke(e,s),o||(a=[Xe(t,"pointerdown",n[5]),Xe(t,"pointerdown",n[3])],o=!0)},p(l,h){h&1&&b(t,"cx",l[0]),h&2&&b(t,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&b(t,"r",i),h&1&&b(r,"cx",l[0]),h&2&&b(r,"cy",l[1]),h&4&&b(r,"r",l[2]),h&1&&b(s,"cx",l[0]),h&2&&b(s,"cy",l[1]),h&4&&b(s,"r",l[2])},d(l){l&&pe(e),o=!1,di(a)}}}function NE(n){let e;return{c(){e=ae("circle"),b(e,"cx",n[0]),b(e,"cy",n[1]),b(e,"r",n[2])},m(t,i){ge(t,e,i)},p(t,i){i&1&&b(e,"cx",t[0]),i&2&&b(e,"cy",t[1]),i&4&&b(e,"r",t[2])},d(t){t&&pe(e)}}}function kE(n){let e;function t(r,s){return Ei?NE:FE}let i=t()(n);return{c(){i.c(),e=fi()},m(r,s){i.m(r,s),ge(r,e,s)},p(r,[s]){i.p(r,s)},i:et,o:et,d(r){r&&pe(e),i.d(r)}}}function UE(n,e,t){let i,{x:r}=e,{y:s}=e,{scale:o}=e;const a=h=>{h.pointerType};function l(h){At.call(this,n,h)}return n.$$set=h=>{"x"in h&&t(0,r=h.x),"y"in h&&t(1,s=h.y),"scale"in h&&t(4,o=h.scale)},n.$$.update=()=>{n.$$.dirty&16&&t(2,i=4/o)},[r,s,i,a,o,l]}class Vf extends kt{constructor(e){super(),Nt(this,e,UE,kE,vt,{x:0,y:1,scale:4})}}function Ph(n){const e=n.slice(),t=e[10][e[6]];return e[28]=t.point,e}function Wf(n,e,t){const i=n.slice();return i[28]=e[t],i[30]=t,i}function Ih(n){const e=n.slice(),t=e[10][e[6]];return e[28]=t.point,e}function Dh(n){const e=n.slice(),t=e[10][e[6]];return e[28]=t.point,e}function jf(n){let e,t,i,r;return{c(){e=ae("circle"),b(e,"cx",t=n[28][0]),b(e,"cy",i=n[28][1]),b(e,"r",r=Js/n[3]),b(e,"class","svelte-1h2slbm")},m(s,o){ge(s,e,o)},p(s,o){o[0]&1088&&t!==(t=s[28][0])&&b(e,"cx",t),o[0]&1088&&i!==(i=s[28][1])&&b(e,"cy",i),o[0]&8&&r!==(r=Js/s[3])&&b(e,"r",r)},d(s){s&&pe(e)}}}function Xf(n){let e,t,i,r,s,o,a,l,h,u;return{c(){e=ae("mask"),t=ae("rect"),a=ae("circle"),b(t,"x",i=n[9].x),b(t,"y",r=n[9].y),b(t,"width",s=n[9].w),b(t,"height",o=n[9].h),b(t,"class","svelte-1h2slbm"),b(a,"cx",l=n[28][0]),b(a,"cy",h=n[28][1]),b(a,"r",u=Js/n[3]),b(a,"class","svelte-1h2slbm"),b(e,"id",`${n[19]}-inner`),b(e,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){ge(c,e,d),ke(e,t),ke(e,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&b(t,"x",i),d[0]&512&&r!==(r=c[9].y)&&b(t,"y",r),d[0]&512&&s!==(s=c[9].w)&&b(t,"width",s),d[0]&512&&o!==(o=c[9].h)&&b(t,"height",o),d[0]&1088&&l!==(l=c[28][0])&&b(a,"cx",l),d[0]&1088&&h!==(h=c[28][1])&&b(a,"cy",h),d[0]&8&&u!==(u=Js/c[3])&&b(a,"r",u)},d(c){c&&pe(e)}}}function Yf(n){let e,t;return e=new is({props:{class:"a9s-corner-handle",x:n[28][0],y:n[28][1],scale:n[3],selected:n[8].includes(n[30])}}),e.$on("pointerenter",n[11]),e.$on("pointerleave",n[12]),e.$on("pointerdown",n[15]),e.$on("pointerdown",function(){ut(n[27](`HANDLE-${n[30]}`))&&n[27](`HANDLE-${n[30]}`).apply(this,arguments)}),e.$on("pointerup",n[16](n[30])),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&32&&(s.x=n[28][0]),r[0]&32&&(s.y=n[28][1]),r[0]&8&&(s.scale=n[3]),r[0]&256&&(s.selected=n[8].includes(n[30])),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function qf(n){let e,t;return e=new Vf({props:{x:n[28][0],y:n[28][1],scale:n[3]}}),e.$on("pointerdown",function(){ut(n[18](n[6]))&&n[18](n[6]).apply(this,arguments)}),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&1088&&(s.x=n[28][0]),r[0]&1088&&(s.y=n[28][1]),r[0]&8&&(s.scale=n[3]),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function HE(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g,m,v,_,y,w,R,M=n[6]!==void 0&&!n[7]&&jf(Dh(n)),C=n[6]!==void 0&&!n[7]&&Xf(Ih(n)),O=ai(n[5].points),N=[];for(let L=0;L<O.length;L+=1)N[L]=Yf(Wf(n,O,L));const X=L=>Pe(N[L],1,1,()=>{N[L]=null});let q=n[6]!==void 0&&!n[7]&&qf(Ph(n));return{c(){e=ae("defs"),t=ae("mask"),i=ae("rect"),l=ae("polygon"),M&&M.c(),C&&C.c(),u=Jt(),c=ae("polygon"),f=Jt(),p=ae("polygon"),m=Jt();for(let L=0;L<N.length;L+=1)N[L].c();v=Jt(),q&&q.c(),_=fi(),b(i,"x",r=n[9].x),b(i,"y",s=n[9].y),b(i,"width",o=n[9].w),b(i,"height",a=n[9].h),b(i,"class","svelte-1h2slbm"),b(l,"points",h=n[5].points.map(Zf).join(" ")),b(l,"class","svelte-1h2slbm"),b(t,"id",`${n[19]}-outer`),b(t,"class","a9s-polygon-editor-mask svelte-1h2slbm"),b(c,"class","a9s-outer"),b(c,"mask",`url(#${n[19]}-outer)`),b(c,"points",d=n[5].points.map(Kf).join(" ")),b(p,"class","a9s-inner a9s-shape-handle"),b(p,"mask",`url(#${n[19]}-inner)`),b(p,"style",n[1]),b(p,"points",g=n[5].points.map(Qf).join(" "))},m(L,S){ge(L,e,S),ke(e,t),ke(t,i),ke(t,l),M&&M.m(t,null),C&&C.m(e,null),ge(L,u,S),ge(L,c,S),ge(L,f,S),ge(L,p,S),ge(L,m,S);for(let I=0;I<N.length;I+=1)N[I]&&N[I].m(L,S);ge(L,v,S),q&&q.m(L,S),ge(L,_,S),y=!0,w||(R=[Xe(c,"pointerup",n[14]),Xe(c,"pointerdown",function(){ut(n[27]("SHAPE"))&&n[27]("SHAPE").apply(this,arguments)}),Xe(p,"pointermove",n[13]),Xe(p,"pointerup",n[14]),Xe(p,"pointerdown",function(){ut(n[27]("SHAPE"))&&n[27]("SHAPE").apply(this,arguments)})],w=!0)},p(L,S){if(n=L,(!y||S[0]&512&&r!==(r=n[9].x))&&b(i,"x",r),(!y||S[0]&512&&s!==(s=n[9].y))&&b(i,"y",s),(!y||S[0]&512&&o!==(o=n[9].w))&&b(i,"width",o),(!y||S[0]&512&&a!==(a=n[9].h))&&b(i,"height",a),(!y||S[0]&32&&h!==(h=n[5].points.map(Zf).join(" ")))&&b(l,"points",h),n[6]!==void 0&&!n[7]?M?M.p(Dh(n),S):(M=jf(Dh(n)),M.c(),M.m(t,null)):M&&(M.d(1),M=null),n[6]!==void 0&&!n[7]?C?C.p(Ih(n),S):(C=Xf(Ih(n)),C.c(),C.m(e,null)):C&&(C.d(1),C=null),(!y||S[0]&32&&d!==(d=n[5].points.map(Kf).join(" ")))&&b(c,"points",d),(!y||S[0]&2)&&b(p,"style",n[1]),(!y||S[0]&32&&g!==(g=n[5].points.map(Qf).join(" ")))&&b(p,"points",g),S[0]&134322472){O=ai(n[5].points);let I;for(I=0;I<O.length;I+=1){const B=Wf(n,O,I);N[I]?(N[I].p(B,S),we(N[I],1)):(N[I]=Yf(B),N[I].c(),we(N[I],1),N[I].m(v.parentNode,v))}for($t(),I=O.length;I<N.length;I+=1)X(I);ei()}n[6]!==void 0&&!n[7]?q?(q.p(Ph(n),S),S[0]&192&&we(q,1)):(q=qf(Ph(n)),q.c(),we(q,1),q.m(_.parentNode,_)):q&&($t(),Pe(q,1,1,()=>{q=null}),ei())},i(L){if(!y){for(let S=0;S<O.length;S+=1)we(N[S]);we(q),y=!0}},o(L){N=N.filter(Boolean);for(let S=0;S<N.length;S+=1)Pe(N[S]);Pe(q),y=!1},d(L){L&&(pe(e),pe(u),pe(c),pe(f),pe(p),pe(m),pe(v),pe(_)),M&&M.d(),C&&C.d(),pr(N,L),q&&q.d(L),w=!1,di(R)}}}function zE(n){let e,t;return e=new Ch({props:{shape:n[0],transform:n[2],editor:n[17],svgEl:n[4],$$slots:{default:[HE,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:n}}}),e.$on("change",n[20]),e.$on("grab",n[21]),e.$on("release",n[22]),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){const s={};r[0]&1&&(s.shape=i[0]),r[0]&4&&(s.transform=i[2]),r[0]&16&&(s.svgEl=i[4]),r[0]&134219754|r[1]&1&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}const GE=250,VE=1e3,WE=12,Js=4.5,Zf=n=>n.join(","),Kf=n=>n.join(","),Qf=n=>n.join(",");function jE(n,e,t){let i,r,s;const o=kn();let{shape:a}=e,{computedStyle:l}=e,{transform:h}=e,{viewportScale:u=1}=e,{svgEl:c}=e,d,f=!1,p,g=[];const m=()=>t(7,f=!0),v=()=>t(7,f=!1),_=I=>{if(g.length>0||!r.some(H=>H.visible)){t(6,d=void 0);return}const[B,j]=h.elementToImage(I.offsetX,I.offsetY),U=H=>Math.pow(H[0]-B,2)+Math.pow(H[1]-j,2),W=i.points.reduce((H,K)=>U(K)<U(H)?K:H),ee=r.filter(H=>H.visible).reduce((H,K)=>U(K.point)<U(H.point)?K:H),z=Math.pow(VE/u,2);U(W)<z||U(ee.point)<z?t(6,d=r.indexOf(ee)):t(6,d=void 0)},y=()=>{document.activeElement!==c&&c.focus()},w=()=>{t(8,g=[]),y()},R=I=>{t(7,f=!0),I.preventDefault(),I.stopPropagation(),p=performance.now()},M=I=>B=>{if(!p||Ei||performance.now()-p>GE)return;const j=g.includes(I);B.metaKey||B.ctrlKey||B.shiftKey?j?t(8,g=g.filter(U=>U!==I)):t(8,g=[...g,I]):j&&g.length>1?t(8,g=[I]):j?t(8,g=[]):t(8,g=[I]),y()},C=(I,B,j)=>{y();let U;const W=I.geometry;g.length>1?U=W.points.map(([z,H],K)=>g.includes(K)?[z+j[0],H+j[1]]:[z,H]):B==="SHAPE"?U=W.points.map(([z,H])=>[z+j[0],H+j[1]]):U=W.points.map(([z,H],K)=>B===`HANDLE-${K}`?[z+j[0],H+j[1]]:[z,H]);const ee=ti(U);return{...I,geometry:{points:U,bounds:ee}}},O=I=>async B=>{B.stopPropagation();const j=[...i.points.slice(0,I+1),r[I].point,...i.points.slice(I+1)],U=ti(j);o("change",{...a,geometry:{points:j,bounds:U}}),await Rf();const W=[...document.querySelectorAll(".a9s-handle")][I+1];if(W!=null&&W.firstChild){const ee=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:B.clientX,clientY:B.clientY,pointerId:B.pointerId,pointerType:B.pointerType,isPrimary:B.isPrimary,buttons:B.buttons});W.firstChild.dispatchEvent(ee)}},N=()=>{if(i.points.length-g.length<3)return;const I=i.points.filter((j,U)=>!g.includes(U)),B=ti(I);o("change",{...a,geometry:{points:I,bounds:B}}),t(8,g=[])};gr(()=>{if(Ei)return;const I=B=>{(B.key==="Delete"||B.key==="Backspace")&&(B.preventDefault(),N())};return c.addEventListener("pointermove",_),c.addEventListener("keydown",I),()=>{c.removeEventListener("pointermove",_),c.removeEventListener("keydown",I)}});const X=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function q(I){At.call(this,n,I)}function L(I){At.call(this,n,I)}function S(I){At.call(this,n,I)}return n.$$set=I=>{"shape"in I&&t(0,a=I.shape),"computedStyle"in I&&t(1,l=I.computedStyle),"transform"in I&&t(2,h=I.transform),"viewportScale"in I&&t(3,u=I.viewportScale),"svgEl"in I&&t(4,c=I.svgEl)},n.$$.update=()=>{n.$$.dirty[0]&1&&t(5,i=a.geometry),n.$$.dirty[0]&40&&t(10,r=Ei?[]:i.points.map((I,B)=>{const j=B===i.points.length-1?i.points[0]:i.points[B+1],U=(I[0]+j[0])/2,W=(I[1]+j[1])/2,ee=Math.sqrt(Math.pow(j[0]-U,2)+Math.pow(j[1]-W,2))>WE/u;return{point:[U,W],visible:ee}})),n.$$.dirty[0]&40&&t(9,s=ca(i.bounds,Js/u))},[a,l,h,u,c,i,d,f,g,s,r,m,v,_,w,R,M,C,O,X,q,L,S]}class XE extends kt{constructor(e){super(),Nt(this,e,jE,zE,vt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function YE(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g,m,v,_,y,w,R,M,C,O,N,X,q,L,S,I,B,j,U,W,ee,z,H,K,$,se,fe,te,J,Y,he,le,ve,Ce,ze,lt,me,Ae,x,A,k;return le=new is({props:{class:"a9s-corner-handle-topleft",x:n[5].x,y:n[5].y,scale:n[3]}}),le.$on("pointerdown",function(){ut(n[12]("TOP_LEFT"))&&n[12]("TOP_LEFT").apply(this,arguments)}),Ce=new is({props:{class:"a9s-corner-handle-topright",x:n[5].x+n[5].w,y:n[5].y,scale:n[3]}}),Ce.$on("pointerdown",function(){ut(n[12]("TOP_RIGHT"))&&n[12]("TOP_RIGHT").apply(this,arguments)}),lt=new is({props:{class:"a9s-corner-handle-bottomright",x:n[5].x+n[5].w,y:n[5].y+n[5].h,scale:n[3]}}),lt.$on("pointerdown",function(){ut(n[12]("BOTTOM_RIGHT"))&&n[12]("BOTTOM_RIGHT").apply(this,arguments)}),Ae=new is({props:{class:"a9s-corner-handle-bottomleft",x:n[5].x,y:n[5].y+n[5].h,scale:n[3]}}),Ae.$on("pointerdown",function(){ut(n[12]("BOTTOM_LEFT"))&&n[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){e=ae("defs"),t=ae("mask"),i=ae("rect"),l=ae("rect"),f=Jt(),p=ae("rect"),y=Jt(),w=ae("rect"),N=Jt(),X=ae("rect"),I=Jt(),B=ae("rect"),ee=Jt(),z=ae("rect"),se=Jt(),fe=ae("rect"),he=Jt(),Et(le.$$.fragment),ve=Jt(),Et(Ce.$$.fragment),ze=Jt(),Et(lt.$$.fragment),me=Jt(),Et(Ae.$$.fragment),b(i,"class","rect-mask-bg svelte-1njczvj"),b(i,"x",r=n[6].x),b(i,"y",s=n[6].y),b(i,"width",o=n[6].w),b(i,"height",a=n[6].h),b(l,"class","rect-mask-fg svelte-1njczvj"),b(l,"x",h=n[5].x),b(l,"y",u=n[5].y),b(l,"width",c=n[5].w),b(l,"height",d=n[5].h),b(t,"id",n[8]),b(t,"class","a9s-rectangle-editor-mask svelte-1njczvj"),b(p,"class","a9s-outer"),b(p,"mask",`url(#${n[8]})`),b(p,"x",g=n[5].x),b(p,"y",m=n[5].y),b(p,"width",v=n[5].w),b(p,"height",_=n[5].h),b(w,"class","a9s-inner a9s-shape-handle"),b(w,"style",n[1]),b(w,"x",R=n[5].x),b(w,"y",M=n[5].y),b(w,"width",C=n[5].w),b(w,"height",O=n[5].h),b(X,"class","a9s-edge-handle a9s-edge-handle-top"),b(X,"x",q=n[5].x),b(X,"y",L=n[5].y),b(X,"height",1),b(X,"width",S=n[5].w),b(B,"class","a9s-edge-handle a9s-edge-handle-right"),b(B,"x",j=n[5].x+n[5].w),b(B,"y",U=n[5].y),b(B,"height",W=n[5].h),b(B,"width",1),b(z,"class","a9s-edge-handle a9s-edge-handle-bottom"),b(z,"x",H=n[5].x),b(z,"y",K=n[5].y+n[5].h),b(z,"height",1),b(z,"width",$=n[5].w),b(fe,"class","a9s-edge-handle a9s-edge-handle-left"),b(fe,"x",te=n[5].x),b(fe,"y",J=n[5].y),b(fe,"height",Y=n[5].h),b(fe,"width",1)},m(G,V){ge(G,e,V),ke(e,t),ke(t,i),ke(t,l),ge(G,f,V),ge(G,p,V),ge(G,y,V),ge(G,w,V),ge(G,N,V),ge(G,X,V),ge(G,I,V),ge(G,B,V),ge(G,ee,V),ge(G,z,V),ge(G,se,V),ge(G,fe,V),ge(G,he,V),xt(le,G,V),ge(G,ve,V),xt(Ce,G,V),ge(G,ze,V),xt(lt,G,V),ge(G,me,V),xt(Ae,G,V),x=!0,A||(k=[Xe(p,"pointerdown",function(){ut(n[12]("SHAPE"))&&n[12]("SHAPE").apply(this,arguments)}),Xe(w,"pointerdown",function(){ut(n[12]("SHAPE"))&&n[12]("SHAPE").apply(this,arguments)}),Xe(X,"pointerdown",function(){ut(n[12]("TOP"))&&n[12]("TOP").apply(this,arguments)}),Xe(B,"pointerdown",function(){ut(n[12]("RIGHT"))&&n[12]("RIGHT").apply(this,arguments)}),Xe(z,"pointerdown",function(){ut(n[12]("BOTTOM"))&&n[12]("BOTTOM").apply(this,arguments)}),Xe(fe,"pointerdown",function(){ut(n[12]("LEFT"))&&n[12]("LEFT").apply(this,arguments)})],A=!0)},p(G,V){n=G,(!x||V&64&&r!==(r=n[6].x))&&b(i,"x",r),(!x||V&64&&s!==(s=n[6].y))&&b(i,"y",s),(!x||V&64&&o!==(o=n[6].w))&&b(i,"width",o),(!x||V&64&&a!==(a=n[6].h))&&b(i,"height",a),(!x||V&32&&h!==(h=n[5].x))&&b(l,"x",h),(!x||V&32&&u!==(u=n[5].y))&&b(l,"y",u),(!x||V&32&&c!==(c=n[5].w))&&b(l,"width",c),(!x||V&32&&d!==(d=n[5].h))&&b(l,"height",d),(!x||V&32&&g!==(g=n[5].x))&&b(p,"x",g),(!x||V&32&&m!==(m=n[5].y))&&b(p,"y",m),(!x||V&32&&v!==(v=n[5].w))&&b(p,"width",v),(!x||V&32&&_!==(_=n[5].h))&&b(p,"height",_),(!x||V&2)&&b(w,"style",n[1]),(!x||V&32&&R!==(R=n[5].x))&&b(w,"x",R),(!x||V&32&&M!==(M=n[5].y))&&b(w,"y",M),(!x||V&32&&C!==(C=n[5].w))&&b(w,"width",C),(!x||V&32&&O!==(O=n[5].h))&&b(w,"height",O),(!x||V&32&&q!==(q=n[5].x))&&b(X,"x",q),(!x||V&32&&L!==(L=n[5].y))&&b(X,"y",L),(!x||V&32&&S!==(S=n[5].w))&&b(X,"width",S),(!x||V&32&&j!==(j=n[5].x+n[5].w))&&b(B,"x",j),(!x||V&32&&U!==(U=n[5].y))&&b(B,"y",U),(!x||V&32&&W!==(W=n[5].h))&&b(B,"height",W),(!x||V&32&&H!==(H=n[5].x))&&b(z,"x",H),(!x||V&32&&K!==(K=n[5].y+n[5].h))&&b(z,"y",K),(!x||V&32&&$!==($=n[5].w))&&b(z,"width",$),(!x||V&32&&te!==(te=n[5].x))&&b(fe,"x",te),(!x||V&32&&J!==(J=n[5].y))&&b(fe,"y",J),(!x||V&32&&Y!==(Y=n[5].h))&&b(fe,"height",Y);const oe={};V&32&&(oe.x=n[5].x),V&32&&(oe.y=n[5].y),V&8&&(oe.scale=n[3]),le.$set(oe);const Q={};V&32&&(Q.x=n[5].x+n[5].w),V&32&&(Q.y=n[5].y),V&8&&(Q.scale=n[3]),Ce.$set(Q);const xe={};V&32&&(xe.x=n[5].x+n[5].w),V&32&&(xe.y=n[5].y+n[5].h),V&8&&(xe.scale=n[3]),lt.$set(xe);const Be={};V&32&&(Be.x=n[5].x),V&32&&(Be.y=n[5].y+n[5].h),V&8&&(Be.scale=n[3]),Ae.$set(Be)},i(G){x||(we(le.$$.fragment,G),we(Ce.$$.fragment,G),we(lt.$$.fragment,G),we(Ae.$$.fragment,G),x=!0)},o(G){Pe(le.$$.fragment,G),Pe(Ce.$$.fragment,G),Pe(lt.$$.fragment,G),Pe(Ae.$$.fragment,G),x=!1},d(G){G&&(pe(e),pe(f),pe(p),pe(y),pe(w),pe(N),pe(X),pe(I),pe(B),pe(ee),pe(z),pe(se),pe(fe),pe(he),pe(ve),pe(ze),pe(me)),wt(le,G),wt(Ce,G),wt(lt,G),wt(Ae,G),A=!1,di(k)}}}function qE(n){let e,t;return e=new Ch({props:{shape:n[0],transform:n[2],editor:n[7],svgEl:n[4],$$slots:{default:[YE,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:n}}}),e.$on("grab",n[9]),e.$on("change",n[10]),e.$on("release",n[11]),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,[r]){const s={};r&1&&(s.shape=i[0]),r&4&&(s.transform=i[2]),r&16&&(s.svgEl=i[4]),r&12394&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function ZE(n,e,t){let i,r,{shape:s}=e,{computedStyle:o}=e,{transform:a}=e,{viewportScale:l=1}=e,{svgEl:h}=e;const u=(g,m,v)=>{const _=g.geometry.bounds;let[y,w]=[_.minX,_.minY],[R,M]=[_.maxX,_.maxY];const[C,O]=v;if(m==="SHAPE")y+=C,R+=C,w+=O,M+=O;else{switch(m){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{w+=O;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{M+=O;break}}switch(m){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{y+=C;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{R+=C;break}}}const N=Math.min(y,R),X=Math.min(w,M),q=Math.abs(R-y),L=Math.abs(M-w);return{...g,geometry:{x:N,y:X,w:q,h:L,bounds:{minX:N,minY:X,maxX:N+q,maxY:X+L}}}},c=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(g){At.call(this,n,g)}function f(g){At.call(this,n,g)}function p(g){At.call(this,n,g)}return n.$$set=g=>{"shape"in g&&t(0,s=g.shape),"computedStyle"in g&&t(1,o=g.computedStyle),"transform"in g&&t(2,a=g.transform),"viewportScale"in g&&t(3,l=g.viewportScale),"svgEl"in g&&t(4,h=g.svgEl)},n.$$.update=()=>{n.$$.dirty&1&&t(5,i=s.geometry),n.$$.dirty&40&&t(6,r=ca(i.bounds,2/l))},[s,o,a,l,h,i,r,u,c,d,f,p]}class KE extends kt{constructor(e){super(),Nt(this,e,ZE,qE,vt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var Jf=Object.prototype.hasOwnProperty;function Mh(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&Mh(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(Jf.call(n,t)&&++i&&!Jf.call(e,t)||!(t in e)||!Mh(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}const QE=12,JE=(n,e)=>n.polygons.reduce((t,i,r)=>{const s=i.rings.reduce((o,a,l)=>{const h=a.points.map((u,c)=>{const d=c===a.points.length-1?a.points[0]:a.points[c+1],f=(u[0]+d[0])/2,p=(u[1]+d[1])/2,g=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>QE/e;return{point:[f,p],visible:g,elementIdx:r,ringIdx:l,pointIdx:c}});return[...o,...h]},[]);return[...t,...s]},[]);function Oh(n){const e=n.slice(),t=e[10][e[6]];return e[29]=t.point,e}function $f(n,e,t){const i=n.slice();return i[30]=e[t],i[32]=t,i}function ep(n,e,t){const i=n.slice();return i[33]=e[t],i[35]=t,i}function tp(n,e,t){const i=n.slice();return i[29]=e[t],i[37]=t,i}function Lh(n){const e=n.slice(),t=e[10][e[6]];return e[29]=t.point,e}function Bh(n){const e=n.slice(),t=e[10][e[6]];return e[29]=t.point,e}function ip(n){let e,t,i,r;return{c(){e=ae("circle"),b(e,"cx",t=n[29][0]),b(e,"cy",i=n[29][1]),b(e,"r",r=$s/n[3]),b(e,"class","svelte-1vxo6dc")},m(s,o){ge(s,e,o)},p(s,o){o[0]&1088&&t!==(t=s[29][0])&&b(e,"cx",t),o[0]&1088&&i!==(i=s[29][1])&&b(e,"cy",i),o[0]&8&&r!==(r=$s/s[3])&&b(e,"r",r)},d(s){s&&pe(e)}}}function np(n){let e,t,i,r,s,o,a,l,h,u;return{c(){e=ae("mask"),t=ae("rect"),a=ae("circle"),b(t,"x",i=n[9].x),b(t,"y",r=n[9].y),b(t,"width",s=n[9].w),b(t,"height",o=n[9].h),b(t,"class","svelte-1vxo6dc"),b(a,"cx",l=n[29][0]),b(a,"cy",h=n[29][1]),b(a,"r",u=$s/n[3]),b(a,"class","svelte-1vxo6dc"),b(e,"id",`${n[18]}-${n[32]}-inner`),b(e,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(c,d){ge(c,e,d),ke(e,t),ke(e,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&b(t,"x",i),d[0]&512&&r!==(r=c[9].y)&&b(t,"y",r),d[0]&512&&s!==(s=c[9].w)&&b(t,"width",s),d[0]&512&&o!==(o=c[9].h)&&b(t,"height",o),d[0]&1088&&l!==(l=c[29][0])&&b(a,"cx",l),d[0]&1088&&h!==(h=c[29][1])&&b(a,"cy",h),d[0]&8&&u!==(u=$s/c[3])&&b(a,"r",u)},d(c){c&&pe(e)}}}function rp(n){let e,t;function i(...r){return n[19](n[32],n[35],n[37],...r)}return e=new is({props:{class:"a9s-corner-handle",x:n[29][0],y:n[29][1],scale:n[3],selected:n[8].some(i)}}),e.$on("pointerenter",n[11]),e.$on("pointerleave",n[12]),e.$on("pointerdown",n[14]),e.$on("pointerdown",function(){ut(n[28](`HANDLE-${n[32]}-${n[35]}-${n[37]}`))&&n[28](`HANDLE-${n[32]}-${n[35]}-${n[37]}`).apply(this,arguments)}),e.$on("pointerup",n[15](n[32],n[35],n[37])),{c(){Et(e.$$.fragment)},m(r,s){xt(e,r,s),t=!0},p(r,s){n=r;const o={};s[0]&32&&(o.x=n[29][0]),s[0]&32&&(o.y=n[29][1]),s[0]&8&&(o.scale=n[3]),s[0]&256&&(o.selected=n[8].some(i)),e.$set(o)},i(r){t||(we(e.$$.fragment,r),t=!0)},o(r){Pe(e.$$.fragment,r),t=!1},d(r){wt(e,r)}}}function sp(n){let e,t,i=ai(n[33].points),r=[];for(let o=0;o<i.length;o+=1)r[o]=rp(tp(n,i,o));const s=o=>Pe(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=fi()},m(o,a){for(let l=0;l<r.length;l+=1)r[l]&&r[l].m(o,a);ge(o,e,a),t=!0},p(o,a){if(a[0]&268491048){i=ai(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=tp(o,i,l);r[l]?(r[l].p(h,a),we(r[l],1)):(r[l]=rp(h),r[l].c(),we(r[l],1),r[l].m(e.parentNode,e))}for($t(),l=i.length;l<r.length;l+=1)s(l);ei()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)we(r[a]);t=!0}},o(o){r=r.filter(Boolean);for(let a=0;a<r.length;a+=1)Pe(r[a]);t=!1},d(o){o&&pe(e),pr(r,o)}}}function op(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g,m,v,_=n[6]!==void 0&&!n[7]&&ip(Bh(n)),y=n[6]!==void 0&&!n[7]&&np(Lh(n)),w=ai(n[30].rings),R=[];for(let C=0;C<w.length;C+=1)R[C]=sp(ep(n,w,C));const M=C=>Pe(R[C],1,1,()=>{R[C]=null});return{c(){e=ae("g"),t=ae("defs"),i=ae("mask"),r=ae("rect"),h=ae("path"),_&&_.c(),y&&y.c(),c=ae("path"),f=ae("path");for(let C=0;C<R.length;C+=1)R[C].c();b(r,"x",s=n[9].x),b(r,"y",o=n[9].y),b(r,"width",a=n[9].w),b(r,"height",l=n[9].h),b(r,"class","svelte-1vxo6dc"),b(h,"d",u=Oi(n[30])),b(h,"class","svelte-1vxo6dc"),b(i,"id",`${n[18]}-${n[32]}-outer`),b(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),b(c,"class","a9s-outer"),b(c,"mask",`url(#${n[18]}-${n[32]}-outer)`),b(c,"fill-rule","evenodd"),b(c,"d",d=Oi(n[30])),b(f,"class","a9s-inner"),b(f,"mask",`url(#${n[18]}-${n[32]}-inner)`),b(f,"style",n[1]),b(f,"fill-rule","evenodd"),b(f,"d",p=Oi(n[30]))},m(C,O){ge(C,e,O),ke(e,t),ke(t,i),ke(i,r),ke(i,h),_&&_.m(i,null),y&&y.m(t,null),ke(e,c),ke(e,f);for(let N=0;N<R.length;N+=1)R[N]&&R[N].m(e,null);g=!0,m||(v=[Xe(c,"pointerup",n[13]),Xe(c,"pointerdown",function(){ut(n[28]("SHAPE"))&&n[28]("SHAPE").apply(this,arguments)}),Xe(f,"pointerup",n[13]),Xe(f,"pointerdown",function(){ut(n[28]("SHAPE"))&&n[28]("SHAPE").apply(this,arguments)})],m=!0)},p(C,O){if(n=C,(!g||O[0]&512&&s!==(s=n[9].x))&&b(r,"x",s),(!g||O[0]&512&&o!==(o=n[9].y))&&b(r,"y",o),(!g||O[0]&512&&a!==(a=n[9].w))&&b(r,"width",a),(!g||O[0]&512&&l!==(l=n[9].h))&&b(r,"height",l),(!g||O[0]&32&&u!==(u=Oi(n[30])))&&b(h,"d",u),n[6]!==void 0&&!n[7]?_?_.p(Bh(n),O):(_=ip(Bh(n)),_.c(),_.m(i,null)):_&&(_.d(1),_=null),n[6]!==void 0&&!n[7]?y?y.p(Lh(n),O):(y=np(Lh(n)),y.c(),y.m(t,null)):y&&(y.d(1),y=null),(!g||O[0]&32&&d!==(d=Oi(n[30])))&&b(c,"d",d),(!g||O[0]&2)&&b(f,"style",n[1]),(!g||O[0]&32&&p!==(p=Oi(n[30])))&&b(f,"d",p),O[0]&268491048){w=ai(n[30].rings);let N;for(N=0;N<w.length;N+=1){const X=ep(n,w,N);R[N]?(R[N].p(X,O),we(R[N],1)):(R[N]=sp(X),R[N].c(),we(R[N],1),R[N].m(e,null))}for($t(),N=w.length;N<R.length;N+=1)M(N);ei()}},i(C){if(!g){for(let O=0;O<w.length;O+=1)we(R[O]);g=!0}},o(C){R=R.filter(Boolean);for(let O=0;O<R.length;O+=1)Pe(R[O]);g=!1},d(C){C&&pe(e),_&&_.d(),y&&y.d(),pr(R,C),m=!1,di(v)}}}function ap(n){let e,t;return e=new Vf({props:{x:n[29][0],y:n[29][1],scale:n[3]}}),e.$on("pointerdown",function(){ut(n[17](n[6]))&&n[17](n[6]).apply(this,arguments)}),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&1088&&(s.x=n[29][0]),r[0]&1088&&(s.y=n[29][1]),r[0]&8&&(s.scale=n[3]),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function $E(n){let e,t,i,r=ai(n[5].polygons),s=[];for(let l=0;l<r.length;l+=1)s[l]=op($f(n,r,l));const o=l=>Pe(s[l],1,1,()=>{s[l]=null});let a=n[6]!==void 0&&!n[7]&&ap(Oh(n));return{c(){for(let l=0;l<s.length;l+=1)s[l].c();e=Jt(),a&&a.c(),t=fi()},m(l,h){for(let u=0;u<s.length;u+=1)s[u]&&s[u].m(l,h);ge(l,e,h),a&&a.m(l,h),ge(l,t,h),i=!0},p(l,h){if(h[0]&268763114){r=ai(l[5].polygons);let u;for(u=0;u<r.length;u+=1){const c=$f(l,r,u);s[u]?(s[u].p(c,h),we(s[u],1)):(s[u]=op(c),s[u].c(),we(s[u],1),s[u].m(e.parentNode,e))}for($t(),u=r.length;u<s.length;u+=1)o(u);ei()}l[6]!==void 0&&!l[7]?a?(a.p(Oh(l),h),h[0]&192&&we(a,1)):(a=ap(Oh(l)),a.c(),we(a,1),a.m(t.parentNode,t)):a&&($t(),Pe(a,1,1,()=>{a=null}),ei())},i(l){if(!i){for(let h=0;h<r.length;h+=1)we(s[h]);we(a),i=!0}},o(l){s=s.filter(Boolean);for(let h=0;h<s.length;h+=1)Pe(s[h]);Pe(a),i=!1},d(l){l&&(pe(e),pe(t)),pr(s,l),a&&a.d(l)}}}function eb(n){let e,t;return e=new Ch({props:{shape:n[0],transform:n[2],editor:n[16],svgEl:n[4],$$slots:{default:[$E,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:n}}}),e.$on("change",n[20]),e.$on("grab",n[21]),e.$on("release",n[22]),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){const s={};r[0]&1&&(s.shape=i[0]),r[0]&4&&(s.transform=i[2]),r[0]&16&&(s.svgEl=i[4]),r[0]&268437482|r[1]&128&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}const tb=250,ib=1e3,$s=4.5;function nb(n,e,t){let i,r,s;const o=kn();let{shape:a}=e,{computedStyle:l}=e,{transform:h}=e,{viewportScale:u=1}=e,{svgEl:c}=e,d,f=!1,p,g=[];const m=()=>t(7,f=!0),v=()=>t(7,f=!1),_=B=>{if(g.length>0||!r.some(K=>K.visible)){t(6,d=void 0);return}const[j,U]=h.elementToImage(B.offsetX,B.offsetY),W=K=>Math.pow(K[0]-j,2)+Math.pow(K[1]-U,2),ee=mT(i).reduce((K,$)=>W($)<W(K)?$:K),z=r.filter(K=>K.visible).reduce((K,$)=>W($.point)<W(K.point)?$:K),H=Math.pow(ib/u,2);W(ee)<H||W(z.point)<H?t(6,d=r.indexOf(z)):t(6,d=void 0)},y=()=>{document.activeElement!==c&&c.focus()},w=()=>{t(8,g=[]),y()},R=B=>{t(7,f=!0),B.preventDefault(),B.stopPropagation(),p=performance.now()},M=(B,j,U)=>W=>{if(!p||Ei||performance.now()-p>tb)return;const ee=H=>H.polygon===B&&H.ring===j&&H.point===U,z=g.some(ee);W.metaKey||W.ctrlKey||W.shiftKey?z?t(8,g=g.filter(H=>!ee(H))):t(8,g=[...g,{polygon:B,ring:j,point:U}]):z&&g.length>1?t(8,g=[{polygon:B,ring:j,point:U}]):z?t(8,g=[]):t(8,g=[{polygon:B,ring:j,point:U}]),y()},C=(B,j,U)=>{y();const W=B.geometry.polygons;let ee;if(j==="SHAPE")ee=W.map(z=>{const H=z.rings.map(($,se)=>({points:$.points.map((fe,te)=>[fe[0]+U[0],fe[1]+U[1]])})),K=ti(H[0].points);return{rings:H,bounds:K}});else{const[z,H,K,$]=j.split("-").map(se=>parseInt(se));ee=W.map((se,fe)=>{if(fe===H){const te=se.rings.map((Y,he)=>he===K?{points:Y.points.map((le,ve)=>ve===$?[le[0]+U[0],le[1]+U[1]]:le)}:Y),J=ti(te[0].points);return{rings:te,bounds:J}}else return se})}return{...B,geometry:{polygons:ee,bounds:xh(ee)}}},O=B=>async j=>{j.stopPropagation();const U=r[B],W=i.polygons.map((z,H)=>{if(H===U.elementIdx){const K=z.rings.map((se,fe)=>fe===U.ringIdx?{points:[...se.points.slice(0,U.pointIdx+1),U.point,...se.points.slice(U.pointIdx+1)]}:se),$=ti(K[0].points);return{rings:K,bounds:$}}else return z});o("change",{...a,geometry:{polygons:W,bounds:xh(W)}}),await Rf();const ee=[...document.querySelectorAll(".a9s-handle")][B+1];if(ee!=null&&ee.firstChild){const z=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:j.clientX,clientY:j.clientY,pointerId:j.pointerId,pointerType:j.pointerType,isPrimary:j.isPrimary,buttons:j.buttons});ee.firstChild.dispatchEvent(z)}},N=()=>{const B=i.polygons.map((j,U)=>{if(g.some(W=>W.polygon===U)){const W=j.rings.map((z,H)=>{const K=g.filter($=>$.polygon===U&&$.ring===H);return K.length&&z.points.length-K.length>=3?{points:z.points.filter(($,se)=>!K.some(fe=>fe.point===se))}:z}),ee=ti(W[0].points);return{rings:W,bounds:ee}}else return j});!Mh(i.polygons,B)&&(o("change",{...a,geometry:{polygons:B,bounds:xh(B)}}),t(8,g=[]))};gr(()=>{if(Ei)return;const B=j=>{(j.key==="Delete"||j.key==="Backspace")&&(j.preventDefault(),N())};return c.addEventListener("pointermove",_),c.addEventListener("keydown",B),()=>{c.removeEventListener("pointermove",_),c.removeEventListener("keydown",B)}});const X=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,q=(B,j,U,{polygon:W,ring:ee,point:z})=>W===B&&ee===j&&z===U;function L(B){At.call(this,n,B)}function S(B){At.call(this,n,B)}function I(B){At.call(this,n,B)}return n.$$set=B=>{"shape"in B&&t(0,a=B.shape),"computedStyle"in B&&t(1,l=B.computedStyle),"transform"in B&&t(2,h=B.transform),"viewportScale"in B&&t(3,u=B.viewportScale),"svgEl"in B&&t(4,c=B.svgEl)},n.$$.update=()=>{n.$$.dirty[0]&1&&t(5,i=a.geometry),n.$$.dirty[0]&40&&t(10,r=Ei?[]:JE(i,u)),n.$$.dirty[0]&40&&t(9,s=ca(i.bounds,$s/u))},[a,l,h,u,c,i,d,f,g,s,r,m,v,w,R,M,C,O,X,q,L,S,I]}class rb extends kt{constructor(e){super(),Nt(this,e,nb,eb,vt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}const lp=new Map([[Ie.RECTANGLE,KE],[Ie.POLYGON,XE],[Ie.MULTIPOLYGON,rb]]),Fh=n=>lp.get(n.type),hp=(n,e)=>lp.set(n,e);function sb(n,e,t){let i;const r=kn();let{annotation:s}=e,{editor:o}=e,{style:a}=e,{target:l}=e,{transform:h}=e,{viewportScale:u}=e,c;return gr(()=>(t(6,c=new o({target:l,props:{shape:s.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),r("change",d.detail)}),c.$on("grab",d=>r("grab",d.detail)),c.$on("release",d=>r("release",d.detail)),()=>{c.$destroy()})),n.$$set=d=>{"annotation"in d&&t(0,s=d.annotation),"editor"in d&&t(1,o=d.editor),"style"in d&&t(2,a=d.style),"target"in d&&t(3,l=d.target),"transform"in d&&t(4,h=d.transform),"viewportScale"in d&&t(5,u=d.viewportScale)},n.$$.update=()=>{n.$$.dirty&5&&t(7,i=vr(s,a,{selected:!0,hovered:!0})),n.$$.dirty&65&&s&&c?.$set({shape:s.target.selector}),n.$$.dirty&80&&c&&c.$set({transform:h}),n.$$.dirty&96&&c&&c.$set({viewportScale:u}),n.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[s,o,a,l,h,u,c,i]}class ob extends kt{constructor(e){super(),Nt(this,e,sb,null,vt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function ab(n,e,t){const i=kn();let{drawingMode:r}=e,{target:s}=e,{tool:o}=e,{transform:a}=e,{viewportScale:l}=e,h;return gr(()=>{const u=s.closest("svg"),c=[],d=(f,p,g)=>{u?.addEventListener(f,p,g),c.push(()=>u?.removeEventListener(f,p,g))};return t(5,h=new o({target:s,props:{addEventListener:d,drawingMode:r,transform:a,viewportScale:l}})),h.$on("create",f=>i("create",f.detail)),()=>{c.forEach(f=>f()),h.$destroy()}}),n.$$set=u=>{"drawingMode"in u&&t(0,r=u.drawingMode),"target"in u&&t(1,s=u.target),"tool"in u&&t(2,o=u.tool),"transform"in u&&t(3,a=u.transform),"viewportScale"in u&&t(4,l=u.viewportScale)},n.$$.update=()=>{n.$$.dirty&40&&h&&h.$set({transform:a}),n.$$.dirty&48&&h&&h.$set({viewportScale:l})},[r,s,o,a,l,h]}class lb extends kt{constructor(e){super(),Nt(this,e,ab,null,vt,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function up(n){let e,t,i,r,s,o,a,l,h,u;return{c(){e=ae("defs"),t=ae("mask"),i=ae("rect"),l=ae("rect"),h=ae("rect"),u=ae("rect"),b(i,"class","rect-mask-bg svelte-1a76qe7"),b(i,"x",r=n[1]-n[5]),b(i,"y",s=n[2]-n[5]),b(i,"width",o=n[3]+2*n[5]),b(i,"height",a=n[4]+2*n[5]),b(l,"class","rect-mask-fg svelte-1a76qe7"),b(l,"x",n[1]),b(l,"y",n[2]),b(l,"width",n[3]),b(l,"height",n[4]),b(t,"id",n[6]),b(t,"class","a9s-rubberband-rectangle-mask svelte-1a76qe7"),b(h,"class","a9s-outer"),b(h,"mask",`url(#${n[6]})`),b(h,"x",n[1]),b(h,"y",n[2]),b(h,"width",n[3]),b(h,"height",n[4]),b(u,"class","a9s-inner"),b(u,"x",n[1]),b(u,"y",n[2]),b(u,"width",n[3]),b(u,"height",n[4])},m(c,d){ge(c,e,d),ke(e,t),ke(t,i),ke(t,l),ge(c,h,d),ge(c,u,d)},p(c,d){d&34&&r!==(r=c[1]-c[5])&&b(i,"x",r),d&36&&s!==(s=c[2]-c[5])&&b(i,"y",s),d&40&&o!==(o=c[3]+2*c[5])&&b(i,"width",o),d&48&&a!==(a=c[4]+2*c[5])&&b(i,"height",a),d&2&&b(l,"x",c[1]),d&4&&b(l,"y",c[2]),d&8&&b(l,"width",c[3]),d&16&&b(l,"height",c[4]),d&2&&b(h,"x",c[1]),d&4&&b(h,"y",c[2]),d&8&&b(h,"width",c[3]),d&16&&b(h,"height",c[4]),d&2&&b(u,"x",c[1]),d&4&&b(u,"y",c[2]),d&8&&b(u,"width",c[3]),d&16&&b(u,"height",c[4])},d(c){c&&(pe(e),pe(h),pe(u))}}}function hb(n){let e,t=n[0]&&up(n);return{c(){e=ae("g"),t&&t.c(),b(e,"class","a9s-annotation a9s-rubberband")},m(i,r){ge(i,e,r),t&&t.m(e,null)},p(i,[r]){i[0]?t?t.p(i,r):(t=up(i),t.c(),t.m(e,null)):t&&(t.d(1),t=null)},i:et,o:et,d(i){i&&pe(e),t&&t.d()}}}function ub(n,e,t){let i;const r=kn();let{addEventListener:s}=e,{drawingMode:o}=e,{transform:a}=e,{viewportScale:l=1}=e,h,u,c,d,f,p,g;const m=R=>{const M=R;h=performance.now(),o==="drag"&&(t(0,u=a.elementToImage(M.offsetX,M.offsetY)),c=u,t(1,d=u[0]),t(2,f=u[1]),t(3,p=1),t(4,g=1))},v=R=>{const M=R;u&&(c=a.elementToImage(M.offsetX,M.offsetY),t(1,d=Math.min(c[0],u[0])),t(2,f=Math.min(c[1],u[1])),t(3,p=Math.abs(c[0]-u[0])),t(4,g=Math.abs(c[1]-u[1])))},_=R=>{const M=R,C=performance.now()-h;if(o==="click"){if(C>300)return;u?y():(t(0,u=a.elementToImage(M.offsetX,M.offsetY)),c=u,t(1,d=u[0]),t(2,f=u[1]),t(3,p=1),t(4,g=1))}else u&&(C>300||p*g>100?(M.stopPropagation(),y()):(t(0,u=void 0),c=void 0))},y=()=>{if(p*g>15){const R={type:Ie.RECTANGLE,geometry:{bounds:{minX:d,minY:f,maxX:d+p,maxY:f+g},x:d,y:f,w:p,h:g}};r("create",R)}t(0,u=void 0),c=void 0};gr(()=>{s("pointerdown",m),s("pointermove",v),s("pointerup",_,!0)});const w=`rect-mask-${Math.random().toString(36).substring(2,12)}`;return n.$$set=R=>{"addEventListener"in R&&t(7,s=R.addEventListener),"drawingMode"in R&&t(8,o=R.drawingMode),"transform"in R&&t(9,a=R.transform),"viewportScale"in R&&t(10,l=R.viewportScale)},n.$$.update=()=>{n.$$.dirty&1024&&t(5,i=2/l)},[u,d,f,p,g,i,w,s,o,a,l]}class cb extends kt{constructor(e){super(),Nt(this,e,ub,hb,vt,{addEventListener:7,drawingMode:8,transform:9,viewportScale:10})}}function Nh(n){const e=n.slice(),t=e[2].map(i=>i.join(",")).join(" ");return e[19]=t,e}function cp(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g=n[1]&&dp(n);return{c(){e=ae("defs"),t=ae("mask"),i=ae("rect"),l=ae("polygon"),u=ae("polygon"),d=ae("polygon"),g&&g.c(),p=fi(),b(i,"x",r=n[3].x),b(i,"y",s=n[3].y),b(i,"width",o=n[3].w),b(i,"height",a=n[3].h),b(i,"class","svelte-18wrg3t"),b(l,"points",h=n[19]),b(l,"class","svelte-18wrg3t"),b(t,"id",n[5]),b(t,"class","a9s-rubberband-polygon-mask svelte-18wrg3t"),b(u,"class","a9s-outer"),b(u,"mask",`url(#${n[5]})`),b(u,"points",c=n[19]),b(d,"class","a9s-inner"),b(d,"points",f=n[19])},m(m,v){ge(m,e,v),ke(e,t),ke(t,i),ke(t,l),ge(m,u,v),ge(m,d,v),g&&g.m(m,v),ge(m,p,v)},p(m,v){v&8&&r!==(r=m[3].x)&&b(i,"x",r),v&8&&s!==(s=m[3].y)&&b(i,"y",s),v&8&&o!==(o=m[3].w)&&b(i,"width",o),v&8&&a!==(a=m[3].h)&&b(i,"height",a),v&4&&h!==(h=m[19])&&b(l,"points",h),v&4&&c!==(c=m[19])&&b(u,"points",c),v&4&&f!==(f=m[19])&&b(d,"points",f),m[1]?g?g.p(m,v):(g=dp(m),g.c(),g.m(p.parentNode,p)):g&&(g.d(1),g=null)},d(m){m&&(pe(e),pe(u),pe(d),pe(p)),g&&g.d(m)}}}function dp(n){let e,t,i;return{c(){e=ae("circle"),b(e,"class","a9s-handle svelte-18wrg3t"),b(e,"cx",t=n[0][0][0]),b(e,"cy",i=n[0][0][1]),b(e,"r",n[4])},m(r,s){ge(r,e,s)},p(r,s){s&1&&t!==(t=r[0][0][0])&&b(e,"cx",t),s&1&&i!==(i=r[0][0][1])&&b(e,"cy",i),s&16&&b(e,"r",r[4])},d(r){r&&pe(e)}}}function db(n){let e,t=n[3]&&cp(Nh(n));return{c(){e=ae("g"),t&&t.c(),b(e,"class","a9s-annotation a9s-rubberband")},m(i,r){ge(i,e,r),t&&t.m(e,null)},p(i,[r]){i[3]?t?t.p(Nh(i),r):(t=cp(Nh(i)),t.c(),t.m(e,null)):t&&(t.d(1),t=null)},i:et,o:et,d(i){i&&pe(e),t&&t.d()}}}const fb=20,pb=1500;function gb(n,e,t){let i,r,s;const o=kn();let{addEventListener:a}=e,{drawingMode:l}=e,{transform:h}=e,{viewportScale:u=1}=e,c,d=[],f,p,g=!1;const m=M=>{const C=M,{timeStamp:O,offsetX:N,offsetY:X}=C;if(c={timeStamp:O,offsetX:N,offsetY:X},l==="drag"&&d.length===0){const q=h.elementToImage(C.offsetX,C.offsetY);d.push(q),t(10,f=q)}},v=M=>{const C=M;if(p&&clearTimeout(p),d.length>0){if(t(10,f=h.elementToImage(C.offsetX,C.offsetY)),d.length>2){const O=oa(f,d[0])*u;t(1,g=O<fb)}C.pointerType==="touch"&&(p=setTimeout(()=>{y()},pb))}},_=M=>{const C=M;if(p&&clearTimeout(p),l==="click"){const O=C.timeStamp-c.timeStamp,N=oa([c.offsetX,c.offsetY],[C.offsetX,C.offsetY]);if(O>300||N>15)return;if(g)w();else if(d.length===0){const X=h.elementToImage(C.offsetX,C.offsetY);d.push(X),t(10,f=X)}else f&&d.push(f)}else{if(!f)return;if(d.length===1&&oa(d[0],f)<=4){t(0,d=[]),t(10,f=void 0);return}C.stopImmediatePropagation(),g?w():d.push(f)}},y=()=>{if(!f)return;const M=d.slice(0,-1);if(M.length<3)return;const C={type:Ie.POLYGON,geometry:{bounds:ti(d),points:M}};_h(C)>4&&(t(0,d=[]),t(10,f=void 0),o("create",C))},w=()=>{const M={type:Ie.POLYGON,geometry:{bounds:ti(d),points:[...d]}};t(0,d=[]),t(10,f=void 0),o("create",M)};gr(()=>{a("pointerdown",m,!0),a("pointermove",v),a("pointerup",_,!0),a("dblclick",y,!0)});const R=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;return n.$$set=M=>{"addEventListener"in M&&t(6,a=M.addEventListener),"drawingMode"in M&&t(7,l=M.drawingMode),"transform"in M&&t(8,h=M.transform),"viewportScale"in M&&t(9,u=M.viewportScale)},n.$$.update=()=>{n.$$.dirty&512&&t(4,i=4/u),n.$$.dirty&1027&&t(2,r=f?g?d:[...d,f]:[]),n.$$.dirty&516&&t(3,s=r.length>0?ca(ti(r),2/u):void 0)},[d,g,r,s,i,R,a,l,h,u,f]}class mb extends kt{constructor(e){super(),Nt(this,e,gb,db,vt,{addEventListener:6,drawingMode:7,transform:8,viewportScale:9})}}const kh=new Map([["rectangle",{tool:cb}],["polygon",{tool:mb}]]),da=()=>[...kh.keys()],fa=n=>kh.get(n),fp=(n,e,t={})=>kh.set(n,{tool:e,opts:t});function vb(n){let e,t,i,r,s;return{c(){e=ae("g"),t=ae("ellipse"),r=ae("ellipse"),b(t,"class","a9s-outer"),b(t,"style",i=n[1]?"display:none;":void 0),b(t,"cx",n[2]),b(t,"cy",n[3]),b(t,"rx",n[4]),b(t,"ry",n[5]),b(r,"class","a9s-inner"),b(r,"style",n[1]),b(r,"cx",n[2]),b(r,"cy",n[3]),b(r,"rx",n[4]),b(r,"ry",n[5]),b(e,"class","a9s-annotation"),b(e,"data-id",s=n[0].id)},m(o,a){ge(o,e,a),ke(e,t),ke(e,r)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(t,"style",i),a&2&&b(r,"style",o[1]),a&1&&s!==(s=o[0].id)&&b(e,"data-id",s)},i:et,o:et,d(o){o&&pe(e)}}}function yb(n,e,t){let i,{annotation:r}=e,{geom:s}=e,{style:o}=e;const{cx:a,cy:l,rx:h,ry:u}=s;return n.$$set=c=>{"annotation"in c&&t(0,r=c.annotation),"geom"in c&&t(6,s=c.geom),"style"in c&&t(7,o=c.style)},n.$$.update=()=>{n.$$.dirty&129&&t(1,i=vr(r,o))},[r,i,a,l,h,u,s,o]}class _b extends kt{constructor(e){super(),Nt(this,e,yb,vb,vt,{annotation:0,geom:6,style:7})}}function xb(n){let e,t,i,r,s;return{c(){e=ae("g"),t=ae("line"),r=ae("line"),b(t,"class","a9s-outer"),b(t,"style",i=n[1]?"display:none;":void 0),b(t,"x1",n[2]),b(t,"y1",n[3]),b(t,"x2",n[4]),b(t,"y2",n[5]),b(r,"class","a9s-inner"),b(r,"style",n[1]),b(r,"x1",n[2]),b(r,"y1",n[3]),b(r,"x2",n[4]),b(r,"y2",n[5]),b(e,"class","a9s-annotation"),b(e,"data-id",s=n[0].id)},m(o,a){ge(o,e,a),ke(e,t),ke(e,r)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(t,"style",i),a&2&&b(r,"style",o[1]),a&1&&s!==(s=o[0].id)&&b(e,"data-id",s)},i:et,o:et,d(o){o&&pe(e)}}}function wb(n,e,t){let i,{annotation:r}=e,{geom:s}=e,{style:o}=e;const{points:a}=s,[[l,h],[u,c]]=a;return n.$$set=d=>{"annotation"in d&&t(0,r=d.annotation),"geom"in d&&t(6,s=d.geom),"style"in d&&t(7,o=d.style)},n.$$.update=()=>{n.$$.dirty&129&&t(1,i=vr(r,o))},[r,i,l,h,u,c,s,o]}class Tb extends kt{constructor(e){super(),Nt(this,e,wb,xb,vt,{annotation:0,geom:6,style:7})}}function pp(n,e,t){const i=n.slice();return i[5]=e[t],i}function gp(n){let e,t,i;return{c(){e=ae("path"),i=ae("path"),b(e,"class","a9s-outer"),b(e,"style",t=n[1]?"display:none;":void 0),b(e,"fill-rule","evenodd"),b(e,"d",Oi(n[5])),b(i,"class","a9s-inner"),b(i,"style",n[1]),b(i,"fill-rule","evenodd"),b(i,"d",Oi(n[5]))},m(r,s){ge(r,e,s),ge(r,i,s)},p(r,s){s&2&&t!==(t=r[1]?"display:none;":void 0)&&b(e,"style",t),s&2&&b(i,"style",r[1])},d(r){r&&(pe(e),pe(i))}}}function Eb(n){let e,t,i=ai(n[2]),r=[];for(let s=0;s<i.length;s+=1)r[s]=gp(pp(n,i,s));return{c(){e=ae("g");for(let s=0;s<r.length;s+=1)r[s].c();b(e,"class","a9s-annotation"),b(e,"data-id",t=n[0].id)},m(s,o){ge(s,e,o);for(let a=0;a<r.length;a+=1)r[a]&&r[a].m(e,null)},p(s,[o]){if(o&6){i=ai(s[2]);let a;for(a=0;a<i.length;a+=1){const l=pp(s,i,a);r[a]?r[a].p(l,o):(r[a]=gp(l),r[a].c(),r[a].m(e,null))}for(;a<r.length;a+=1)r[a].d(1);r.length=i.length}o&1&&t!==(t=s[0].id)&&b(e,"data-id",t)},i:et,o:et,d(s){s&&pe(e),pr(r,s)}}}function bb(n,e,t){let i,{annotation:r}=e,{geom:s}=e,{style:o}=e;const{polygons:a}=s;return n.$$set=l=>{"annotation"in l&&t(0,r=l.annotation),"geom"in l&&t(3,s=l.geom),"style"in l&&t(4,o=l.style)},n.$$.update=()=>{n.$$.dirty&17&&t(1,i=vr(r,o))},[r,i,a,s,o]}class Sb extends kt{constructor(e){super(),Nt(this,e,bb,Eb,vt,{annotation:0,geom:3,style:4})}}function Ab(n){let e,t,i,r,s;return{c(){e=ae("g"),t=ae("polygon"),r=ae("polygon"),b(t,"class","a9s-outer"),b(t,"style",i=n[1]?"display:none;":void 0),b(t,"points",n[2].map(Rb).join(" ")),b(r,"class","a9s-inner"),b(r,"style",n[1]),b(r,"points",n[2].map(Cb).join(" ")),b(e,"class","a9s-annotation"),b(e,"data-id",s=n[0].id)},m(o,a){ge(o,e,a),ke(e,t),ke(e,r)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(t,"style",i),a&2&&b(r,"style",o[1]),a&1&&s!==(s=o[0].id)&&b(e,"data-id",s)},i:et,o:et,d(o){o&&pe(e)}}}const Rb=n=>n.join(","),Cb=n=>n.join(",");function Pb(n,e,t){let i,{annotation:r}=e,{geom:s}=e,{style:o}=e;const{points:a}=s;return n.$$set=l=>{"annotation"in l&&t(0,r=l.annotation),"geom"in l&&t(3,s=l.geom),"style"in l&&t(4,o=l.style)},n.$$.update=()=>{n.$$.dirty&17&&t(1,i=vr(r,o))},[r,i,a,s,o]}class Ib extends kt{constructor(e){super(),Nt(this,e,Pb,Ab,vt,{annotation:0,geom:3,style:4})}}function Db(n){let e,t,i,r,s,o,a;return{c(){e=ae("g"),t=ae("path"),s=ae("path"),b(t,"class",i=Kr(`a9s-outer ${n[1]}`)+" svelte-1w0132l"),b(t,"style",r=n[3]?"display:none;":void 0),b(t,"d",n[2]),b(s,"class",o=Kr(`a9s-inner ${n[1]}`)+" svelte-1w0132l"),b(s,"style",n[3]),b(s,"d",n[2]),b(e,"class","a9s-annotation"),b(e,"data-id",a=n[0].id)},m(l,h){ge(l,e,h),ke(e,t),ke(e,s)},p(l,[h]){h&2&&i!==(i=Kr(`a9s-outer ${l[1]}`)+" svelte-1w0132l")&&b(t,"class",i),h&8&&r!==(r=l[3]?"display:none;":void 0)&&b(t,"style",r),h&4&&b(t,"d",l[2]),h&2&&o!==(o=Kr(`a9s-inner ${l[1]}`)+" svelte-1w0132l")&&b(s,"class",o),h&8&&b(s,"style",l[3]),h&4&&b(s,"d",l[2]),h&1&&a!==(a=l[0].id)&&b(e,"data-id",a)},i:et,o:et,d(l){l&&pe(e)}}}function Mb(n,e,t){let i,r,s,{annotation:o}=e,{geom:a}=e,{style:l}=e;return n.$$set=h=>{"annotation"in h&&t(0,o=h.annotation),"geom"in h&&t(4,a=h.geom),"style"in h&&t(5,l=h.style)},n.$$.update=()=>{n.$$.dirty&33&&t(3,i=vr(o,l)),n.$$.dirty&16&&t(2,r=Th(a)),n.$$.dirty&16&&t(1,s=a.closed?"closed":"open")},[o,s,r,i,a,l]}class Ob extends kt{constructor(e){super(),Nt(this,e,Mb,Db,vt,{annotation:0,geom:4,style:5})}}function Lb(n){let e,t,i,r,s;return{c(){e=ae("g"),t=ae("rect"),r=ae("rect"),b(t,"class","a9s-outer"),b(t,"style",i=n[5]?"display:none;":void 0),b(t,"x",n[4]),b(t,"y",n[3]),b(t,"width",n[2]),b(t,"height",n[1]),b(r,"class","a9s-inner"),b(r,"style",n[5]),b(r,"x",n[4]),b(r,"y",n[3]),b(r,"width",n[2]),b(r,"height",n[1]),b(e,"class","a9s-annotation"),b(e,"data-id",s=n[0].id)},m(o,a){ge(o,e,a),ke(e,t),ke(e,r)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&b(t,"style",i),a&16&&b(t,"x",o[4]),a&8&&b(t,"y",o[3]),a&4&&b(t,"width",o[2]),a&2&&b(t,"height",o[1]),a&32&&b(r,"style",o[5]),a&16&&b(r,"x",o[4]),a&8&&b(r,"y",o[3]),a&4&&b(r,"width",o[2]),a&2&&b(r,"height",o[1]),a&1&&s!==(s=o[0].id)&&b(e,"data-id",s)},i:et,o:et,d(o){o&&pe(e)}}}function Bb(n,e,t){let i,r,s,o,a,{annotation:l}=e,{geom:h}=e,{style:u}=e;return n.$$set=c=>{"annotation"in c&&t(0,l=c.annotation),"geom"in c&&t(6,h=c.geom),"style"in c&&t(7,u=c.style)},n.$$.update=()=>{n.$$.dirty&129&&t(5,i=vr(l,u)),n.$$.dirty&64&&t(4,{x:r,y:s,w:o,h:a}=h,r,(t(3,s),t(6,h)),(t(2,o),t(6,h)),(t(1,a),t(6,h)))},[l,a,o,s,r,i,h,u]}class Fb extends kt{constructor(e){super(),Nt(this,e,Bb,Lb,vt,{annotation:0,geom:6,style:7})}}const Nb=n=>({elementToImage:(e,t)=>{const i=n.getBoundingClientRect(),r=n.createSVGPoint();r.x=e+i.x,r.y=t+i.y;const{x:s,y:o}=r.matrixTransform(n.getScreenCTM().inverse());return[s,o]}}),kb=250,Ub=(n,e)=>{const t=kn();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:r=>{if(performance.now()-i<kb){const{x:s,y:o}=mp(r,n),a=Ei?10:2,l=e.getAt(s,o,void 0,a);l?t("click",{originalEvent:r,annotation:l}):t("click",{originalEvent:r})}}}},mp=(n,e)=>{const t=e.createSVGPoint(),i=e.getBoundingClientRect(),r=n.clientX-i.x,s=n.clientY-i.y,{left:o,top:a}=e.getBoundingClientRect();return t.x=r+o,t.y=s+a,t.matrixTransform(e.getScreenCTM().inverse())};function vp(n,e,t){const i=n.slice();return i[39]=e[t],i}function yp(n,e,t){const i=n.slice();return i[42]=e[t],i}function Uh(n){const e=n.slice(),t=e[42].target.selector;return e[45]=t,e}function _p(n){let e=n[42],t,i,r=xp(n);return{c(){r.c(),t=fi()},m(s,o){r.m(s,o),ge(s,t,o),i=!0},p(s,o){o[0]&131072&&vt(e,e=s[42])?($t(),Pe(r,1,1,et),ei(),r=xp(s),r.c(),we(r,1),r.m(t.parentNode,t)):r.p(s,o)},i(s){i||(we(r),i=!0)},o(s){Pe(r),i=!1},d(s){s&&pe(t),r.d(s)}}}function Hb(n){let e,t;return e=new Tb({props:{annotation:n[42],geom:n[45].geometry,style:n[1]}}),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){const s={};r[0]&131072&&(s.annotation=i[42]),r[0]&131072&&(s.geom=i[45].geometry),r[0]&2&&(s.style=i[1]),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function zb(n){let e,t;return e=new Ob({props:{annotation:n[42],geom:n[45].geometry,style:n[1]}}),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){const s={};r[0]&131072&&(s.annotation=i[42]),r[0]&131072&&(s.geom=i[45].geometry),r[0]&2&&(s.style=i[1]),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function Gb(n){let e,t;return e=new Sb({props:{annotation:n[42],geom:n[45].geometry,style:n[1]}}),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){const s={};r[0]&131072&&(s.annotation=i[42]),r[0]&131072&&(s.geom=i[45].geometry),r[0]&2&&(s.style=i[1]),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function Vb(n){let e,t;return e=new Ib({props:{annotation:n[42],geom:n[45].geometry,style:n[1]}}),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){const s={};r[0]&131072&&(s.annotation=i[42]),r[0]&131072&&(s.geom=i[45].geometry),r[0]&2&&(s.style=i[1]),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function Wb(n){let e,t;return e=new Fb({props:{annotation:n[42],geom:n[45].geometry,style:n[1]}}),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){const s={};r[0]&131072&&(s.annotation=i[42]),r[0]&131072&&(s.geom=i[45].geometry),r[0]&2&&(s.style=i[1]),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function jb(n){var e;let t,i;return t=new _b({props:{annotation:n[42],geom:(e=n[45])==null?void 0:e.geometry,style:n[1]}}),{c(){Et(t.$$.fragment)},m(r,s){xt(t,r,s),i=!0},p(r,s){var o;const a={};s[0]&131072&&(a.annotation=r[42]),s[0]&131072&&(a.geom=(o=r[45])==null?void 0:o.geometry),s[0]&2&&(a.style=r[1]),t.$set(a)},i(r){i||(we(t.$$.fragment,r),i=!0)},o(r){Pe(t.$$.fragment,r),i=!1},d(r){wt(t,r)}}}function xp(n){let e,t,i,r;const s=[jb,Wb,Vb,Gb,zb,Hb],o=[];function a(l,h){var u,c,d,f,p,g;return((u=l[45])==null?void 0:u.type)===Ie.ELLIPSE?0:((c=l[45])==null?void 0:c.type)===Ie.RECTANGLE?1:((d=l[45])==null?void 0:d.type)===Ie.POLYGON?2:((f=l[45])==null?void 0:f.type)===Ie.MULTIPOLYGON?3:((p=l[45])==null?void 0:p.type)===Ie.POLYLINE?4:((g=l[45])==null?void 0:g.type)===Ie.LINE?5:-1}return~(e=a(n))&&(t=o[e]=s[e](n)),{c(){t&&t.c(),i=fi()},m(l,h){~e&&o[e].m(l,h),ge(l,i,h),r=!0},p(l,h){let u=e;e=a(l),e===u?~e&&o[e].p(l,h):(t&&($t(),Pe(o[u],1,1,()=>{o[u]=null}),ei()),~e?(t=o[e],t?t.p(l,h):(t=o[e]=s[e](l),t.c()),we(t,1),t.m(i.parentNode,i)):t=null)},i(l){r||(we(t),r=!0)},o(l){Pe(t),r=!1},d(l){l&&pe(i),~e&&o[e].d(l)}}}function wp(n){let e=Ti(n[42])&&!n[10](n[42]),t,i,r=e&&_p(Uh(n));return{c(){r&&r.c(),t=fi()},m(s,o){r&&r.m(s,o),ge(s,t,o),i=!0},p(s,o){o[0]&132096&&(e=Ti(s[42])&&!s[10](s[42])),e?r?(r.p(Uh(s),o),o[0]&132096&&we(r,1)):(r=_p(Uh(s)),r.c(),we(r,1),r.m(t.parentNode,t)):r&&($t(),Pe(r,1,1,()=>{r=null}),ei())},i(s){i||(we(r),i=!0)},o(s){Pe(r),i=!1},d(s){s&&pe(t),r&&r.d(s)}}}function Tp(n){let e,t,i,r;const s=[Yb,Xb],o=[];function a(l,h){return l[6]?0:l[15]&&l[0]?1:-1}return~(e=a(n))&&(t=o[e]=s[e](n)),{c(){t&&t.c(),i=fi()},m(l,h){~e&&o[e].m(l,h),ge(l,i,h),r=!0},p(l,h){let u=e;e=a(l),e===u?~e&&o[e].p(l,h):(t&&($t(),Pe(o[u],1,1,()=>{o[u]=null}),ei()),~e?(t=o[e],t?t.p(l,h):(t=o[e]=s[e](l),t.c()),we(t,1),t.m(i.parentNode,i)):t=null)},i(l){r||(we(t),r=!0)},o(l){Pe(t),r=!1},d(l){l&&pe(i),~e&&o[e].d(l)}}}function Xb(n){let e=`${n[2]}-${n[7]}`,t,i,r=Ep(n);return{c(){r.c(),t=fi()},m(s,o){r.m(s,o),ge(s,t,o),i=!0},p(s,o){o[0]&132&&vt(e,e=`${s[2]}-${s[7]}`)?($t(),Pe(r,1,1,et),ei(),r=Ep(s),r.c(),we(r,1),r.m(t.parentNode,t)):r.p(s,o)},i(s){i||(we(r),i=!0)},o(s){Pe(r),i=!1},d(s){s&&pe(t),r.d(s)}}}function Yb(n){let e,t,i=ai(n[6]),r=[];for(let o=0;o<i.length;o+=1)r[o]=Sp(vp(n,i,o));const s=o=>Pe(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=fi()},m(o,a){for(let l=0;l<r.length;l+=1)r[l]&&r[l].m(o,a);ge(o,e,a),t=!0},p(o,a){if(a[0]&8659266){i=ai(o[6]);let l;for(l=0;l<i.length;l+=1){const h=vp(o,i,l);r[l]?(r[l].p(h,a),we(r[l],1)):(r[l]=Sp(h),r[l].c(),we(r[l],1),r[l].m(e.parentNode,e))}for($t(),l=i.length;l<r.length;l+=1)s(l);ei()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)we(r[a]);t=!0}},o(o){r=r.filter(Boolean);for(let a=0;a<r.length;a+=1)Pe(r[a]);t=!1},d(o){o&&pe(e),pr(r,o)}}}function Ep(n){let e,t;return e=new lb({props:{target:n[8],tool:n[15],drawingMode:n[14],transform:n[13],viewportScale:n[18]}}),e.$on("create",n[22]),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){const s={};r[0]&256&&(s.target=i[8]),r[0]&32768&&(s.tool=i[15]),r[0]&16384&&(s.drawingMode=i[14]),r[0]&8192&&(s.transform=i[13]),r[0]&262144&&(s.viewportScale=i[18]),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function bp(n){let e,t;return e=new ob({props:{target:n[8],editor:n[39].editor,annotation:n[39].annotation,style:n[1],transform:n[13],viewportScale:n[18]}}),e.$on("change",function(){ut(n[23](n[39].annotation))&&n[23](n[39].annotation).apply(this,arguments)}),{c(){Et(e.$$.fragment)},m(i,r){xt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&256&&(s.target=n[8]),r[0]&64&&(s.editor=n[39].editor),r[0]&64&&(s.annotation=n[39].annotation),r[0]&2&&(s.style=n[1]),r[0]&8192&&(s.transform=n[13]),r[0]&262144&&(s.viewportScale=n[18]),e.$set(s)},i(i){t||(we(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){wt(e,i)}}}function Sp(n){let e=n[39].annotation.id,t,i,r=bp(n);return{c(){r.c(),t=fi()},m(s,o){r.m(s,o),ge(s,t,o),i=!0},p(s,o){o[0]&64&&vt(e,e=s[39].annotation.id)?($t(),Pe(r,1,1,et),ei(),r=bp(s),r.c(),we(r,1),r.m(t.parentNode,t)):r.p(s,o)},i(s){i||(we(r),i=!0)},o(s){Pe(r),i=!1},d(s){s&&pe(t),r.d(s)}}}function qb(n){let e,t,i,r,s,o,a=ai(n[17].filter(n[34])),l=[];for(let c=0;c<a.length;c+=1)l[c]=wp(yp(n,a,c));const h=c=>Pe(l[c],1,1,()=>{l[c]=null});let u=n[8]&&Tp(n);return{c(){e=ae("svg"),t=ae("g");for(let c=0;c<l.length;c+=1)l[c].c();i=ae("g"),u&&u.c(),b(i,"class","drawing"),b(e,"role","application"),b(e,"tabindex",0),b(e,"class","a9s-annotationlayer"),Zi(e,"drawing",n[15]),Zi(e,"editing",n[5]),Zi(e,"hidden",!n[3]),Zi(e,"hover",n[16])},m(c,d){ge(c,e,d),ke(e,t);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(t,null);ke(e,i),u&&u.m(i,null),n[35](i),n[36](e),r=!0,s||(o=[Xe(e,"pointerup",function(){ut(n[11])&&n[11].apply(this,arguments)}),Xe(e,"pointerdown",function(){ut(n[12])&&n[12].apply(this,arguments)}),Xe(e,"pointermove",n[24])],s=!0)},p(c,d){if(n=c,d[0]&132098){a=ai(n[17].filter(n[34]));let f;for(f=0;f<a.length;f+=1){const p=yp(n,a,f);l[f]?(l[f].p(p,d),we(l[f],1)):(l[f]=wp(p),l[f].c(),we(l[f],1),l[f].m(t,null))}for($t(),f=a.length;f<l.length;f+=1)h(f);ei()}n[8]?u?(u.p(n,d),d[0]&256&&we(u,1)):(u=Tp(n),u.c(),we(u,1),u.m(i,null)):u&&($t(),Pe(u,1,1,()=>{u=null}),ei()),(!r||d[0]&32768)&&Zi(e,"drawing",n[15]),(!r||d[0]&32)&&Zi(e,"editing",n[5]),(!r||d[0]&8)&&Zi(e,"hidden",!n[3]),(!r||d[0]&65536)&&Zi(e,"hover",n[16])},i(c){if(!r){for(let d=0;d<a.length;d+=1)we(l[d]);we(u),r=!0}},o(c){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)Pe(l[d]);Pe(u),r=!1},d(c){c&&pe(e),pr(l,c),u&&u.d(),n[35](null),n[36](null),s=!1,di(o)}}}function Zb(n,e,t){let i,r,s,o,a,l,h,u,c,d,f,p,g=et,m=()=>(g(),g=_f(B,Y=>t(18,p=Y)),B);n.$$.on_destroy.push(()=>g());let{drawingEnabled:v}=e,{image:_}=e,{preferredDrawingMode:y}=e,{state:w}=e,{style:R=void 0}=e,{toolName:M=da()[0]}=e,{user:C}=e,{visible:O=!0}=e,N=0;const X=()=>t(7,N+=1),q=()=>M,L=()=>v;let S,I,B;gr(()=>m(t(9,B=CE(_,I))));const{hover:j,selection:U,store:W}=w;ph(n,j,Y=>t(16,c=Y)),ph(n,U,Y=>t(33,d=Y)),ph(n,W,Y=>t(17,f=Y));let ee,z;const H=Y=>{ee&&W.unobserve(ee);const he=Y.filter(({editable:le})=>le).map(({id:le})=>le);he.length>0?(t(5,z=he.map(le=>W.getAnnotation(le)).filter(le=>le&&Ti(le))),ee=le=>{const{updated:ve}=le.changes;t(5,z=ve?.map(Ce=>Ce.newValue))},W.observe(ee,{annotations:he})):t(5,z=void 0)},K=Y=>{const he=Bf(),le={id:he,bodies:[],target:{annotation:he,selector:Y.detail,creator:C,created:new Date}};W.addAnnotation(le),U.setSelected(le.id)},$=Y=>he=>{var le;const{target:ve}=Y,Ce=600*1e3,ze=((le=ve.creator)==null?void 0:le.id)!==C.id||!ve.created||new Date().getTime()-ve.created.getTime()>Ce;W.updateTarget({...ve,selector:he.detail,created:ze?ve.created:new Date,updated:ze?new Date:void 0,updatedBy:ze?C:void 0})},se=Y=>{const{x:he,y:le}=mp(Y,I),ve=W.getAt(he,le,void 0,2);ve?c!==ve.id&&j.set(ve.id):j.set(void 0)},fe=Y=>Ti(Y);function te(Y){ia[Y?"unshift":"push"](()=>{S=Y,t(8,S)})}function J(Y){ia[Y?"unshift":"push"](()=>{I=Y,t(4,I)})}return n.$$set=Y=>{"drawingEnabled"in Y&&t(0,v=Y.drawingEnabled),"image"in Y&&t(25,_=Y.image),"preferredDrawingMode"in Y&&t(26,y=Y.preferredDrawingMode),"state"in Y&&t(27,w=Y.state),"style"in Y&&t(1,R=Y.style),"toolName"in Y&&t(2,M=Y.toolName),"user"in Y&&t(28,C=Y.user),"visible"in Y&&t(3,O=Y.visible)},n.$$.update=()=>{n.$$.dirty[0]&4&&t(15,{tool:i,opts:r}=fa(M)||{tool:void 0,opts:void 0},i,(t(32,r),t(2,M))),n.$$.dirty[0]&67108864|n.$$.dirty[1]&2&&t(14,s=r?.drawingMode||y),n.$$.dirty[0]&16&&t(13,o=Nb(I)),n.$$.dirty[0]&16&&t(12,{onPointerDown:a,onPointerUp:l}=Ub(I,W),a,(t(11,l),t(4,I))),n.$$.dirty[1]&4&&H(d.selected),n.$$.dirty[0]&32&&t(6,h=z?z.map(Y=>({annotation:Y,editor:Fh(Y.target.selector)})).filter(Y=>Y.editor):void 0),n.$$.dirty[0]&64&&t(10,u=Y=>h&&h.some(he=>he.annotation.id===Y.id))},[v,R,M,O,I,z,h,N,S,B,u,l,a,o,s,i,c,f,p,j,U,W,K,$,se,_,y,w,C,X,q,L,r,d,fe,te,J]}class Kb extends kt{constructor(e){super(),Nt(this,e,Zb,qb,vt,{drawingEnabled:0,image:25,preferredDrawingMode:26,state:27,style:1,toolName:2,user:28,visible:3,cancelDrawing:29,getDrawingTool:30,isDrawingEnabled:31},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[29]}get getDrawingTool(){return this.$$.ctx[30]}get isDrawingEnabled(){return this.$$.ctx[31]}}function Ap(n,e,t=0,i=n.length-1,r=Qb){for(;i>t;){if(i-t>600){const l=i-t+1,h=e-t+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1),f=Math.max(t,Math.floor(e-h*c/l+d)),p=Math.min(i,Math.floor(e+(l-h)*c/l+d));Ap(n,e,f,p,r)}const s=n[e];let o=t,a=i;for(eo(n,t,e),r(n[i],s)>0&&eo(n,t,i);o<a;){for(eo(n,o,a),o++,a--;r(n[o],s)<0;)o++;for(;r(n[a],s)>0;)a--}r(n[t],s)===0?eo(n,t,a):(a++,eo(n,a,i)),a<=e&&(t=a+1),e<=a&&(i=a-1)}}function eo(n,e,t){const i=n[e];n[e]=n[t],n[t]=i}function Qb(n,e){return n<e?-1:n>e?1:0}class Jb{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!ga(e,t))return i;const r=this.toBBox,s=[];for(;t;){for(let o=0;o<t.children.length;o++){const a=t.children[o],l=t.leaf?r(a):a;ga(e,l)&&(t.leaf?i.push(a):zh(e,l)?this._all(a,i):s.push(a))}t=s.pop()}return i}collides(e){let t=this.data;if(!ga(e,t))return!1;const i=[];for(;t;){for(let r=0;r<t.children.length;r++){const s=t.children[r],o=t.leaf?this.toBBox(s):s;if(ga(e,o)){if(t.leaf||zh(e,o))return!0;i.push(s)}}t=i.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let i=0;i<e.length;i++)this.insert(e[i]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const i=this.data;this.data=t,t=i}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=rs([]),this}remove(e,t){if(!e)return this;let i=this.data;const r=this.toBBox(e),s=[],o=[];let a,l,h;for(;i||s.length;){if(i||(i=s.pop(),l=s[s.length-1],a=o.pop(),h=!0),i.leaf){const u=$b(e,i.children,t);if(u!==-1)return i.children.splice(u,1),s.push(i),this._condense(s),this}!h&&!i.leaf&&zh(i,r)?(s.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,r){const s=i-t+1;let o=this._maxEntries,a;if(s<=o)return a=rs(e.slice(t,i+1)),ns(a,this.toBBox),a;r||(r=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,r-1))),a=rs([]),a.leaf=!1,a.height=r;const l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));Rp(e,t,i,h,this.compareMinX);for(let u=t;u<=i;u+=h){const c=Math.min(u+h-1,i);Rp(e,u,c,l,this.compareMinY);for(let d=u;d<=c;d+=l){const f=Math.min(d+l-1,c);a.children.push(this._build(e,d,f,r-1))}}return ns(a,this.toBBox),a}_chooseSubtree(e,t,i,r){for(;r.push(t),!(t.leaf||r.length-1===i);){let s=1/0,o=1/0,a;for(let l=0;l<t.children.length;l++){const h=t.children[l],u=Hh(h),c=i1(e,h)-u;c<o?(o=c,s=u<s?u:s,a=h):c===o&&u<s&&(s=u,a=h)}t=a||t.children[0]}return t}_insert(e,t,i){const r=i?e:this.toBBox(e),s=[],o=this._chooseSubtree(r,this.data,t,s);for(o.children.push(e),io(o,r);t>=0&&s[t].children.length>this._maxEntries;)this._split(s,t),t--;this._adjustParentBBoxes(r,s,t)}_split(e,t){const i=e[t],r=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,r);const o=this._chooseSplitIndex(i,s,r),a=rs(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,ns(i,this.toBBox),ns(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=rs([e,t]),this.data.height=e.height+1,this.data.leaf=!1,ns(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let r,s=1/0,o=1/0;for(let a=t;a<=i-t;a++){const l=to(e,0,a,this.toBBox),h=to(e,a,i,this.toBBox),u=n1(l,h),c=Hh(l)+Hh(h);u<s?(s=u,r=a,o=c<o?c:o):u===s&&c<o&&(o=c,r=a)}return r||i-t}_chooseSplitAxis(e,t,i){const r=e.leaf?this.compareMinX:e1,s=e.leaf?this.compareMinY:t1,o=this._allDistMargin(e,t,i,r),a=this._allDistMargin(e,t,i,s);o<a&&e.children.sort(r)}_allDistMargin(e,t,i,r){e.children.sort(r);const s=this.toBBox,o=to(e,0,t,s),a=to(e,i-t,i,s);let l=pa(o)+pa(a);for(let h=t;h<i-t;h++){const u=e.children[h];io(o,e.leaf?s(u):u),l+=pa(o)}for(let h=i-t-1;h>=t;h--){const u=e.children[h];io(a,e.leaf?s(u):u),l+=pa(a)}return l}_adjustParentBBoxes(e,t,i){for(let r=i;r>=0;r--)io(t[r],e)}_condense(e){for(let t=e.length-1,i;t>=0;t--)e[t].children.length===0?t>0?(i=e[t-1].children,i.splice(i.indexOf(e[t]),1)):this.clear():ns(e[t],this.toBBox)}}function $b(n,e,t){if(!t)return e.indexOf(n);for(let i=0;i<e.length;i++)if(t(n,e[i]))return i;return-1}function ns(n,e){to(n,0,n.children.length,e,n)}function to(n,e,t,i,r){r||(r=rs(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=e;s<t;s++){const o=n.children[s];io(r,n.leaf?i(o):o)}return r}function io(n,e){return n.minX=Math.min(n.minX,e.minX),n.minY=Math.min(n.minY,e.minY),n.maxX=Math.max(n.maxX,e.maxX),n.maxY=Math.max(n.maxY,e.maxY),n}function e1(n,e){return n.minX-e.minX}function t1(n,e){return n.minY-e.minY}function Hh(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function pa(n){return n.maxX-n.minX+(n.maxY-n.minY)}function i1(n,e){return(Math.max(e.maxX,n.maxX)-Math.min(e.minX,n.minX))*(Math.max(e.maxY,n.maxY)-Math.min(e.minY,n.minY))}function n1(n,e){const t=Math.max(n.minX,e.minX),i=Math.max(n.minY,e.minY),r=Math.min(n.maxX,e.maxX),s=Math.min(n.maxY,e.maxY);return Math.max(0,r-t)*Math.max(0,s-i)}function zh(n,e){return n.minX<=e.minX&&n.minY<=e.minY&&e.maxX<=n.maxX&&e.maxY<=n.maxY}function ga(n,e){return e.minX<=n.maxX&&e.minY<=n.maxY&&e.maxX>=n.minX&&e.maxY>=n.minY}function rs(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Rp(n,e,t,i,r){const s=[e,t];for(;s.length;){if(t=s.pop(),e=s.pop(),t-e<=i)continue;const o=e+Math.ceil((t-e)/i/2)*i;Ap(n,o,e,t,r),s.push(e,o,o,t)}}const r1=()=>{const n=new Jb,e=new Map,t=()=>[...e.values()],i=()=>{n.clear(),e.clear()},r=o=>{if(!aa(o))return;const{minX:a,minY:l,maxX:h,maxY:u}=o.selector.geometry.bounds,c={minX:a,minY:l,maxX:h,maxY:u,target:o};n.insert(c),e.set(o.annotation,c)},s=o=>{if(!aa(o))return;const a=e.get(o.annotation);a&&n.remove(a),e.delete(o.annotation)};return{all:t,clear:i,getAt:(o,a,l=0)=>{const h=n.search({minX:o-l,minY:a-l,maxX:o+l,maxY:a+l}).map(u=>u.target).filter(u=>u.selector.type===Ie.RECTANGLE||cT(u.selector,o,a,l));return h.length>0?(h.sort((u,c)=>_h(u.selector)-_h(c.selector)),h):[]},getIntersecting:(o,a,l,h)=>n.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(u=>u.target),insert:r,remove:s,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,u)=>{if(aa(u)){const{minX:c,minY:d,maxX:f,maxY:p}=u.selector.geometry.bounds;return[...h,{minX:c,minY:d,maxX:f,maxY:p,target:u}]}else return h},[]);l.forEach(h=>e.set(h.target.annotation,h)),n.load(l)},size:()=>n.all().length,update:(o,a)=>{s(o),r(a)}}},s1=n=>({...n,subscribe:e=>{const t=i=>e(i.state);return n.observe(t),e(n.all()),()=>n.unobserve(t)}}),Cp=n=>{const e=rE(),t=r1(),i=VT(e,n.userSelectAction,n.adapter),r=GT(e),s=lE();return e.observe(({changes:o})=>{t.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>t.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>t.update(a.target,l.target))}),{store:{...e,getAt:(o,a,l,h)=>{const u=t.getAt(o,a,h);if(l)return u.map(c=>e.getAnnotation(c.annotation)).filter(Boolean).filter(l)[0];{const c=u[0];return c?e.getAnnotation(c.annotation):void 0}},getIntersecting:(o,a,l,h)=>t.getIntersecting(o,a,l,h).map(u=>e.getAnnotation(u.annotation)).filter(Boolean)},selection:i,hover:r,viewport:s}},o1=n=>{const e=Cp(n);return{...e,store:s1(e.store)}},a1=n=>{let e,t;if(n.nodeName==="CANVAS")e=n,t=e.getContext("2d",{willReadFrequently:!0});else{const r=n;e=document.createElement("canvas"),e.width=r.width,e.height=r.height,t=e.getContext("2d",{willReadFrequently:!0}),t.drawImage(r,0,0,r.width,r.height)}let i=0;for(let r=1;r<10;r++)for(let s=1;s<10;s++){const o=Math.round(s*e.width/10),a=Math.round(r*e.height/10),l=t.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},Pp=n=>{const e=a1(n),t=e>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${e.toFixed(1)}. Setting ${t} theme.`),t},Ip=(n,e,t)=>e.setAttribute("data-theme",t==="auto"?Pp(n):t),Dp=(n,e)=>({...n,drawingEnabled:n.drawingEnabled===void 0?e.drawingEnabled:n.drawingEnabled,drawingMode:n.drawingMode||e.drawingMode,userSelectAction:n.userSelectAction||e.userSelectAction,theme:n.theme||e.theme}),Mp=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,Op=(n,e)=>{const t=e||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?n.undo():a.key==="y"&&a.ctrlKey&&n.redo()},r=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?n.redo():n.undo())},s=()=>{Mp?t.removeEventListener("keydown",r):t.removeEventListener("keydown",i)};return Mp?t.addEventListener("keydown",r):t.addEventListener("keydown",i),{destroy:s}},l1=(n,e={})=>{if(!n)throw"Missing argument: image";const t=typeof n=="string"?document.getElementById(n):n,i=Dp(e,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:Nf.EDIT,theme:"light"}),r=o1(i),{selection:s,store:o}=r,a=aE(o,i.initialHistory),l=hE(r,a,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",t.style.display="block",t.parentNode.insertBefore(h,t),h.appendChild(t);const u=Op(a);let c=_E();Ip(t,h,i.theme);const d=new Kb({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:t,preferredDrawingMode:i.drawingMode,state:r,style:i.style,user:c}});d.$on("click",S=>{const{originalEvent:I,annotation:B}=S.detail;B?s.userSelect(B.id,I):s.isEmpty()||s.clear()});const f=cE(r,a,i.adapter),p=()=>d.cancelDrawing(),g=()=>{d.$destroy(),h.parentNode.insertBefore(t,h),h.parentNode.removeChild(h),u.destroy(),a.destroy()},m=()=>d.getDrawingTool(),v=()=>c,_=()=>d.isDrawingEnabled(),y=(S,I,B)=>fp(S,I,B),w=(S,I)=>hp(S,I),R=S=>{if(!fa(S))throw`No drawing tool named ${S}`;d.$set({toolName:S})},M=S=>d.$set({drawingEnabled:S}),C=S=>d.$set({preferredDrawingMode:S}),O=S=>{console.warn("Filter not implemented yet")},N=S=>d.$set({style:S}),X=S=>Ip(t,h,S),q=S=>{c=S,d.$set({user:S})},L=S=>d.$set({visible:S});return{...f,cancelDrawing:p,destroy:g,getDrawingTool:m,getUser:v,isDrawingEnabled:_,listDrawingTools:da,on:l.on,off:l.off,registerDrawingTool:y,registerShapeEditor:w,setDrawingEnabled:M,setDrawingMode:C,setDrawingTool:R,setFilter:O,setStyle:N,setTheme:X,setUser:q,setVisible:L,element:h,state:r}};function yt(){}function h1(n,e){for(const t in e)n[t]=e[t];return n}function Lp(n){return n()}function Bp(){return Object.create(null)}function no(n){n.forEach(Lp)}function Gh(n){return typeof n=="function"}function Rt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function u1(n){return Object.keys(n).length===0}function c1(n,...e){if(n==null){for(const i of e)i(void 0);return yt}const t=n.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function ro(n,e,t){n.$$.on_destroy.push(c1(e,t))}function d1(n,e,t,i){if(n){const r=Fp(n,e,t,i);return n[0](r)}}function Fp(n,e,t,i){return n[1]&&i?h1(t.ctx.slice(),n[1](i(e))):t.ctx}function f1(n,e,t,i){if(n[2]&&i){const r=n[2](i(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const s=[],o=Math.max(e.dirty.length,r.length);for(let a=0;a<o;a+=1)s[a]=e.dirty[a]|r[a];return s}return e.dirty|r}return e.dirty}function p1(n,e,t,i,r,s){if(r){const o=Fp(e,t,i,s);n.p(o,r)}}function g1(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let i=0;i<t;i++)e[i]=-1;return e}return-1}const Vh=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ki(n,e){n.appendChild(e)}function ct(n,e,t){n.insertBefore(e,t||null)}function ht(n){n.parentNode&&n.parentNode.removeChild(n)}function ma(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function dt(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function Np(n){return document.createTextNode(n)}function _n(){return Np("")}function m1(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function ie(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function v1(n){return Array.from(n.childNodes)}function y1(n,e){e=""+e,n.data!==e&&(n.data=e)}function ss(n,e,t){n.classList.toggle(e,!!t)}function _1(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}let so;function oo(n){so=n}function Wh(){if(!so)throw new Error("Function called outside component initialization");return so}function ao(n){Wh().$$.on_mount.push(n)}function x1(n){Wh().$$.on_destroy.push(n)}function jh(){const n=Wh();return(e,t,{cancelable:i=!1}={})=>{const r=n.$$.callbacks[e];if(r){const s=_1(e,t,{cancelable:i});return r.slice().forEach(o=>{o.call(n,s)}),!s.defaultPrevented}return!0}}const os=[],va=[];let as=[];const kp=[],w1=Promise.resolve();let Xh=!1;function T1(){Xh||(Xh=!0,w1.then(Up))}function Yh(n){as.push(n)}const qh=new Set;let ls=0;function Up(){if(ls!==0)return;const n=so;do{try{for(;ls<os.length;){const e=os[ls];ls++,oo(e),E1(e.$$)}}catch(e){throw os.length=0,ls=0,e}for(oo(null),os.length=0,ls=0;va.length;)va.pop()();for(let e=0;e<as.length;e+=1){const t=as[e];qh.has(t)||(qh.add(t),t())}as.length=0}while(os.length);for(;kp.length;)kp.pop()();Xh=!1,qh.clear(),oo(n)}function E1(n){if(n.fragment!==null){n.update(),no(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Yh)}}function b1(n){const e=[],t=[];as.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),as=e}const ya=new Set;let yr;function bi(){yr={r:0,c:[],p:yr}}function Si(){yr.r||no(yr.c),yr=yr.p}function Oe(n,e){n&&n.i&&(ya.delete(n),n.i(e))}function He(n,e,t,i){if(n&&n.o){if(ya.has(n))return;ya.add(n),yr.c.push(()=>{ya.delete(n),i&&(t&&n.d(1),i())}),n.o(e)}else i&&i()}function zn(n){return n?.length!==void 0?n:Array.from(n)}function ii(n){n&&n.c()}function Yt(n,e,t){const{fragment:i,after_update:r}=n.$$;i&&i.m(e,t),Yh(()=>{const s=n.$$.on_mount.map(Lp).filter(Gh);n.$$.on_destroy?n.$$.on_destroy.push(...s):no(s),n.$$.on_mount=[]}),r.forEach(Yh)}function qt(n,e){const t=n.$$;t.fragment!==null&&(b1(t.after_update),no(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function S1(n,e){n.$$.dirty[0]===-1&&(os.push(n),T1(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Zt(n,e,t,i,r,s,o=null,a=[-1]){const l=so;oo(n);const h=n.$$={fragment:null,ctx:[],props:s,update:yt,not_equal:r,bound:Bp(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:Bp(),dirty:a,skip_bound:!1,root:e.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=t?t(n,e.props||{},(c,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&r(h.ctx[c],h.ctx[c]=p)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](p),u&&S1(n,c)),d}):[],h.update(),u=!0,no(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const c=v1(e.target);h.fragment&&h.fragment.l(c),c.forEach(ht)}else h.fragment&&h.fragment.c();e.intro&&Oe(n.$$.fragment),Yt(n,e.target,e.anchor),Up()}oo(l)}class Kt{constructor(){ff(this,"$$"),ff(this,"$$set")}$destroy(){qt(this,1),this.$destroy=yt}$on(e,t){if(!Gh(t))return yt;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}$set(e){this.$$set&&!u1(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const A1="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(A1);var Qi=(n=>(n.ELLIPSE="ELLIPSE",n.MULTIPOLYGON="MULTIPOLYGON",n.POLYGON="POLYGON",n.POLYLINE="POLYLINE",n.RECTANGLE="RECTANGLE",n.LINE="LINE",n))(Qi||{}),Zh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Kh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function R1(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}var Hp={exports:{}};(function(n){(function(){function e(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function t(a,l,h){var u=l.x,c=l.y,d=h.x-u,f=h.y-c;if(d!==0||f!==0){var p=((a.x-u)*d+(a.y-c)*f)/(d*d+f*f);p>1?(u=h.x,c=h.y):p>0&&(u+=d*p,c+=f*p)}return d=a.x-u,f=a.y-c,d*d+f*f}function i(a,l){for(var h=a[0],u=[h],c,d=1,f=a.length;d<f;d++)c=a[d],e(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function r(a,l,h,u,c){for(var d=u,f,p=l+1;p<h;p++){var g=t(a[p],a[l],a[h]);g>d&&(f=p,d=g)}d>u&&(f-l>1&&r(a,l,f,u,c),c.push(a[f]),h-f>1&&r(a,f,h,u,c))}function s(a,l){var h=a.length-1,u=[a[0]];return r(a,0,h,l,u),u.push(a[h]),u}function o(a,l,h){if(a.length<=2)return a;var u=l!==void 0?l*l:1;return a=h?a:i(a,u),a=s(a,u),a}n.exports=o,n.exports.default=o})()})(Hp);var C1=Hp.exports;const P1=Kh(C1),hs=(n,e)=>e,Qh=n=>{let e=1/0,t=1/0,i=-1/0,r=-1/0;return n.forEach(([s,o])=>{e=Math.min(e,s),t=Math.min(t,o),i=Math.max(i,s),r=Math.max(r,o)}),{minX:e,minY:t,maxX:i,maxY:r}},_a=n=>{let e=0,t=n.length-1;for(let i=0;i<n.length;i++)e+=(n[t][0]+n[i][0])*(n[t][1]-n[i][1]),t=i;return Math.abs(.5*e)},xa=(n,e,t)=>{let i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){const o=n[r][0],a=n[r][1],l=n[s][0],h=n[s][1];a>t!=h>t&&e<(l-o)*(t-a)/(h-a)+o&&(i=!i)}return i},zp=(n,e=1)=>{const t=n.map(([i,r])=>({x:i,y:r}));return P1(t,e,!0).map(i=>[i.x,i.y])},I1=(n,e)=>{const t=Math.abs(e[0]-n[0]),i=Math.abs(e[1]-n[1]);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))},D1={area:n=>Math.PI*n.geometry.rx*n.geometry.ry,intersects:(n,e,t)=>{const{cx:i,cy:r,rx:s,ry:o}=n.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=e-i,c=t-r,d=l*u+h*c,f=h*u-l*c;return d*d/(s*s)+f*f/(o*o)<=1}};hs(Qi.ELLIPSE,D1);const M1={area:n=>0,intersects:(n,e,t,i=2)=>{const[[r,s],[o,a]]=n.geometry.points,l=Math.abs((a-s)*e-(o-r)*t+o*s-a*r),h=I1([r,s],[o,a]);return l/h<=i}};hs(Qi.LINE,M1);const O1={area:n=>{const{polygons:e}=n.geometry;return e.reduce((t,i)=>{const[r,...s]=i.rings,o=_a(r.points),a=s.reduce((l,h)=>l+_a(h.points),0);return t+o-a},0)},intersects:(n,e,t)=>{const{polygons:i}=n.geometry;for(const r of i){const[s,...o]=r.rings;if(xa(s.points,e,t)){let a=!1;for(const l of o)if(xa(l.points,e,t)){a=!0;break}if(!a)return!0}}return!1}},L1=n=>{const e=n.reduce((t,i)=>[...t,...i.rings[0].points],[]);return Qh(e)},B1=(n,e=1)=>{const t=n.geometry.polygons.map(r=>{const s=r.rings.map(a=>{const l=zp(a.points,e);return{...a,points:l}}),o=Qh(s[0].points);return{...r,rings:s,bounds:o}}),i=L1(t);return{...n,geometry:{...n.geometry,polygons:t,bounds:i}}};hs(Qi.MULTIPOLYGON,O1);const F1={area:n=>{const e=n.geometry.points;return _a(e)},intersects:(n,e,t)=>{const i=n.geometry.points;return xa(i,e,t)}},N1=(n,e=1)=>{const t=zp(n.geometry.points,e),i=Qh(t);return{...n,geometry:{...n.geometry,bounds:i,points:t}}};hs(Qi.POLYGON,F1);const k1={area:n=>{const e=n.geometry;if(!e.closed||e.points.length<3)return 0;const t=Gp(e.points,e.closed);return _a(t)},intersects:(n,e,t,i=2)=>{const r=n.geometry;if(r.closed){const s=Gp(r.points,r.closed);return xa(s,e,t)}else return U1(r,[e,t],i)}},Gp=(n,e=!1)=>{const t=[];for(let i=0;i<n.length;i++){const r=n[i],s=n[(i+1)%n.length];if(t.push(r.point),(i<n.length-1||e)&&(r.type==="CURVE"||s.type=="CURVE")){const o=Vp(r.point,r.type==="CURVE"&&r.outHandle||r.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);t.push(...o.slice(1))}}return t},Vp=(n,e,t,i,r=10)=>{const s=[];for(let o=0;o<=r;o++){const a=o/r,l=Math.pow(1-a,3)*n[0]+3*Math.pow(1-a,2)*a*e[0]+3*(1-a)*Math.pow(a,2)*t[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*n[1]+3*Math.pow(1-a,2)*a*e[1]+3*(1-a)*Math.pow(a,2)*t[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},U1=(n,e,t)=>{for(let i=0;i<n.points.length-1;i++){const r=n.points[i],s=n.points[i+1];if(r.type==="CURVE"||s.type==="CURVE"){const o=Vp(r.point,r.type==="CURVE"&&r.outHandle||r.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let a=0;a<o.length-1;a++)if(Wp(e,o[a],o[a+1])<=t)return!0}else if(Wp(e,r.point,s.point)<=t)return!0}return!1},Wp=(n,e,t)=>{const[i,r]=n,[s,o]=e,[a,l]=t,h=a-s,u=l-o,c=Math.sqrt(h*h+u*u);if(c===0)return Math.sqrt((i-s)*(i-s)+(r-o)*(r-o));const d=((i-s)*h+(r-o)*u)/(c*c);return d<=0?Math.sqrt((i-s)*(i-s)+(r-o)*(r-o)):d>=1?Math.sqrt((i-a)*(i-a)+(r-l)*(r-l)):Math.abs((l-o)*i-(a-s)*r+a*o-l*s)/c};hs(Qi.POLYLINE,k1);const H1={area:n=>n.geometry.w*n.geometry.h,intersects:(n,e,t)=>e>=n.geometry.x&&e<=n.geometry.x+n.geometry.w&&t>=n.geometry.y&&t<=n.geometry.y+n.geometry.h};hs(Qi.RECTANGLE,H1);const zt=[];for(let n=0;n<256;++n)zt.push((n+256).toString(16).slice(1));function z1(n,e=0){return(zt[n[e+0]]+zt[n[e+1]]+zt[n[e+2]]+zt[n[e+3]]+"-"+zt[n[e+4]]+zt[n[e+5]]+"-"+zt[n[e+6]]+zt[n[e+7]]+"-"+zt[n[e+8]]+zt[n[e+9]]+"-"+zt[n[e+10]]+zt[n[e+11]]+zt[n[e+12]]+zt[n[e+13]]+zt[n[e+14]]+zt[n[e+15]]).toLowerCase()}let Jh;const G1=new Uint8Array(16);function V1(){if(!Jh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Jh=crypto.getRandomValues.bind(crypto)}return Jh(G1)}const W1=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),jp={randomUUID:W1};function j1(n,e,t){var i;n=n||{};const r=n.random??((i=n.rng)==null?void 0:i.call(n))??V1();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,z1(r)}function X1(n,e,t){return jp.randomUUID&&!n?jp.randomUUID():j1(n)}const Y1=(n,e,t)=>{const i=typeof e=="function"?e(n,t):e;if(i){const{fill:r,fillOpacity:s,stroke:o,strokeWidth:a,strokeOpacity:l}=i;let h="";return r&&(h+=`fill:${r};`),s||s===0?h+=`fill-opacity:${s};`:r&&(h+="fill-opacity:0.25;"),o&&(h+=`stroke:${o};`,h+=`stroke-width:${a||"1"};`,h+=`stroke-opacity:${l||"1"};`),h}};Qi.RECTANGLE,Qi.POLYGON,Qi.MULTIPOLYGON;function q1(n,e,t){let i;const r=jh();let{annotation:s}=e,{editor:o}=e,{style:a}=e,{target:l}=e,{transform:h}=e,{viewportScale:u}=e,c;return ao(()=>(t(6,c=new o({target:l,props:{shape:s.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),r("change",d.detail)}),c.$on("grab",d=>r("grab",d.detail)),c.$on("release",d=>r("release",d.detail)),()=>{c.$destroy()})),n.$$set=d=>{"annotation"in d&&t(0,s=d.annotation),"editor"in d&&t(1,o=d.editor),"style"in d&&t(2,a=d.style),"target"in d&&t(3,l=d.target),"transform"in d&&t(4,h=d.transform),"viewportScale"in d&&t(5,u=d.viewportScale)},n.$$.update=()=>{n.$$.dirty&5&&t(7,i=Y1(s,a,{selected:!0,hovered:!0})),n.$$.dirty&65&&s&&c?.$set({shape:s.target.selector}),n.$$.dirty&80&&c&&c.$set({transform:h}),n.$$.dirty&96&&c&&c.$set({viewportScale:u}),n.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[s,o,a,l,h,u,c,i]}class Z1 extends Kt{constructor(e){super(),Zt(this,e,q1,null,Rt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"||navigator.userAgent.indexOf("Mac OS X");var _r=(n=>(n[n.WEBGL_LEGACY=0]="WEBGL_LEGACY",n[n.WEBGL=1]="WEBGL",n[n.WEBGL2=2]="WEBGL2",n))(_r||{}),Xp=(n=>(n[n.UNKNOWN=0]="UNKNOWN",n[n.WEBGL=1]="WEBGL",n[n.CANVAS=2]="CANVAS",n))(Xp||{}),$h=(n=>(n[n.COLOR=16384]="COLOR",n[n.DEPTH=256]="DEPTH",n[n.STENCIL=1024]="STENCIL",n))($h||{}),De=(n=>(n[n.NORMAL=0]="NORMAL",n[n.ADD=1]="ADD",n[n.MULTIPLY=2]="MULTIPLY",n[n.SCREEN=3]="SCREEN",n[n.OVERLAY=4]="OVERLAY",n[n.DARKEN=5]="DARKEN",n[n.LIGHTEN=6]="LIGHTEN",n[n.COLOR_DODGE=7]="COLOR_DODGE",n[n.COLOR_BURN=8]="COLOR_BURN",n[n.HARD_LIGHT=9]="HARD_LIGHT",n[n.SOFT_LIGHT=10]="SOFT_LIGHT",n[n.DIFFERENCE=11]="DIFFERENCE",n[n.EXCLUSION=12]="EXCLUSION",n[n.HUE=13]="HUE",n[n.SATURATION=14]="SATURATION",n[n.COLOR=15]="COLOR",n[n.LUMINOSITY=16]="LUMINOSITY",n[n.NORMAL_NPM=17]="NORMAL_NPM",n[n.ADD_NPM=18]="ADD_NPM",n[n.SCREEN_NPM=19]="SCREEN_NPM",n[n.NONE=20]="NONE",n[n.SRC_OVER=0]="SRC_OVER",n[n.SRC_IN=21]="SRC_IN",n[n.SRC_OUT=22]="SRC_OUT",n[n.SRC_ATOP=23]="SRC_ATOP",n[n.DST_OVER=24]="DST_OVER",n[n.DST_IN=25]="DST_IN",n[n.DST_OUT=26]="DST_OUT",n[n.DST_ATOP=27]="DST_ATOP",n[n.ERASE=26]="ERASE",n[n.SUBTRACT=28]="SUBTRACT",n[n.XOR=29]="XOR",n))(De||{}),Ji=(n=>(n[n.POINTS=0]="POINTS",n[n.LINES=1]="LINES",n[n.LINE_LOOP=2]="LINE_LOOP",n[n.LINE_STRIP=3]="LINE_STRIP",n[n.TRIANGLES=4]="TRIANGLES",n[n.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",n[n.TRIANGLE_FAN=6]="TRIANGLE_FAN",n))(Ji||{}),re=(n=>(n[n.RGBA=6408]="RGBA",n[n.RGB=6407]="RGB",n[n.RG=33319]="RG",n[n.RED=6403]="RED",n[n.RGBA_INTEGER=36249]="RGBA_INTEGER",n[n.RGB_INTEGER=36248]="RGB_INTEGER",n[n.RG_INTEGER=33320]="RG_INTEGER",n[n.RED_INTEGER=36244]="RED_INTEGER",n[n.ALPHA=6406]="ALPHA",n[n.LUMINANCE=6409]="LUMINANCE",n[n.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",n[n.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",n[n.DEPTH_STENCIL=34041]="DEPTH_STENCIL",n))(re||{}),us=(n=>(n[n.TEXTURE_2D=3553]="TEXTURE_2D",n[n.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",n[n.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",n[n.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",n[n.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",n[n.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",n[n.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",n))(us||{}),Se=(n=>(n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",n[n.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",n[n.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",n[n.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",n[n.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",n[n.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",n[n.BYTE=5120]="BYTE",n[n.SHORT=5122]="SHORT",n[n.INT=5124]="INT",n[n.FLOAT=5126]="FLOAT",n[n.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",n[n.HALF_FLOAT=36193]="HALF_FLOAT",n))(Se||{}),ce=(n=>(n[n.FLOAT=0]="FLOAT",n[n.INT=1]="INT",n[n.UINT=2]="UINT",n))(ce||{}),xn=(n=>(n[n.NEAREST=0]="NEAREST",n[n.LINEAR=1]="LINEAR",n))(xn||{}),Gn=(n=>(n[n.CLAMP=33071]="CLAMP",n[n.REPEAT=10497]="REPEAT",n[n.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",n))(Gn||{}),$i=(n=>(n[n.OFF=0]="OFF",n[n.POW2=1]="POW2",n[n.ON=2]="ON",n[n.ON_MANUAL=3]="ON_MANUAL",n))($i||{}),li=(n=>(n[n.NPM=0]="NPM",n[n.UNPACK=1]="UNPACK",n[n.PMA=2]="PMA",n[n.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",n[n.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",n[n.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",n))(li||{}),en=(n=>(n[n.NO=0]="NO",n[n.YES=1]="YES",n[n.AUTO=2]="AUTO",n[n.BLEND=0]="BLEND",n[n.CLEAR=1]="CLEAR",n[n.BLIT=2]="BLIT",n))(en||{}),eu=(n=>(n[n.AUTO=0]="AUTO",n[n.MANUAL=1]="MANUAL",n))(eu||{}),Ai=(n=>(n.LOW="lowp",n.MEDIUM="mediump",n.HIGH="highp",n))(Ai||{}),bt=(n=>(n[n.NONE=0]="NONE",n[n.SCISSOR=1]="SCISSOR",n[n.STENCIL=2]="STENCIL",n[n.SPRITE=3]="SPRITE",n[n.COLOR=4]="COLOR",n))(bt||{}),Tt=(n=>(n[n.NONE=0]="NONE",n[n.LOW=2]="LOW",n[n.MEDIUM=4]="MEDIUM",n[n.HIGH=8]="HIGH",n))(Tt||{}),tn=(n=>(n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",n))(tn||{});const K1={createCanvas:(n,e)=>{const t=document.createElement("canvas");return t.width=n,t.height=e,t},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(n,e)=>fetch(n,e),parseXML:n=>new DOMParser().parseFromString(n,"text/xml")},de={ADAPTER:K1,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var tu=/iPhone/i,Yp=/iPod/i,qp=/iPad/i,Zp=/\biOS-universal(?:.+)Mac\b/i,iu=/\bAndroid(?:.+)Mobile\b/i,Kp=/Android/i,cs=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,wa=/Silk/i,wn=/Windows Phone/i,Qp=/\bWindows(?:.+)ARM\b/i,Jp=/BlackBerry/i,$p=/BB10/i,eg=/Opera Mini/i,tg=/\b(CriOS|Chrome)(?:.+)Mobile/i,ig=/Mobile(?:.+)Firefox\b/i,ng=function(n){return typeof n<"u"&&n.platform==="MacIntel"&&typeof n.maxTouchPoints=="number"&&n.maxTouchPoints>1&&typeof MSStream>"u"};function Q1(n){return function(e){return e.test(n)}}function rg(n){var e={userAgent:"",platform:"",maxTouchPoints:0};!n&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof n=="string"?e.userAgent=n:n&&n.userAgent&&(e={userAgent:n.userAgent,platform:n.platform,maxTouchPoints:n.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var r=Q1(t),s={apple:{phone:r(tu)&&!r(wn),ipod:r(Yp),tablet:!r(tu)&&(r(qp)||ng(e))&&!r(wn),universal:r(Zp),device:(r(tu)||r(Yp)||r(qp)||r(Zp)||ng(e))&&!r(wn)},amazon:{phone:r(cs),tablet:!r(cs)&&r(wa),device:r(cs)||r(wa)},android:{phone:!r(wn)&&r(cs)||!r(wn)&&r(iu),tablet:!r(wn)&&!r(cs)&&!r(iu)&&(r(wa)||r(Kp)),device:!r(wn)&&(r(cs)||r(wa)||r(iu)||r(Kp))||r(/\bokhttp\b/i)},windows:{phone:r(wn),tablet:r(Qp),device:r(wn)||r(Qp)},other:{blackberry:r(Jp),blackberry10:r($p),opera:r(eg),firefox:r(ig),chrome:r(tg),device:r(Jp)||r($p)||r(eg)||r(ig)||r(tg)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const J1=rg.default??rg,Tn=J1(globalThis.navigator);de.RETINA_PREFIX=/@([0-9\.]+)x/,de.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var sg={exports:{}};(function(n){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function r(l,h,u){this.fn=l,this.context=h,this.once=u||!1}function s(l,h,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new r(u,c||l,d),p=t?t+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],h,u;if(this._eventsCount===0)return l;for(u in h=this._events)e.call(h,u)&&l.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=t?t+l:l,u=this._events[h];if(!u)return[];if(u.fn)return[u.fn];for(var c=0,d=u.length,f=new Array(d);c<d;c++)f[c]=u[c].fn;return f},a.prototype.listenerCount=function(l){var h=t?t+l:l,u=this._events[h];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,h,u,c,d,f){var p=t?t+l:l;if(!this._events[p])return!1;var g=this._events[p],m=arguments.length,v,_;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),m){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,h),!0;case 3:return g.fn.call(g.context,h,u),!0;case 4:return g.fn.call(g.context,h,u,c),!0;case 5:return g.fn.call(g.context,h,u,c,d),!0;case 6:return g.fn.call(g.context,h,u,c,d,f),!0}for(_=1,v=new Array(m-1);_<m;_++)v[_-1]=arguments[_];g.fn.apply(g.context,v)}else{var y=g.length,w;for(_=0;_<y;_++)switch(g[_].once&&this.removeListener(l,g[_].fn,void 0,!0),m){case 1:g[_].fn.call(g[_].context);break;case 2:g[_].fn.call(g[_].context,h);break;case 3:g[_].fn.call(g[_].context,h,u);break;case 4:g[_].fn.call(g[_].context,h,u,c);break;default:if(!v)for(w=1,v=new Array(m-1);w<m;w++)v[w-1]=arguments[w];g[_].fn.apply(g[_].context,v)}}return!0},a.prototype.on=function(l,h,u){return s(this,l,h,u,!1)},a.prototype.once=function(l,h,u){return s(this,l,h,u,!0)},a.prototype.removeListener=function(l,h,u,c){var d=t?t+l:l;if(!this._events[d])return this;if(!h)return o(this,d),this;var f=this._events[d];if(f.fn)f.fn===h&&(!c||f.once)&&(!u||f.context===u)&&o(this,d);else{for(var p=0,g=[],m=f.length;p<m;p++)(f[p].fn!==h||c&&!f[p].once||u&&f[p].context!==u)&&g.push(f[p]);g.length?this._events[d]=g.length===1?g[0]:g:o(this,d)}return this},a.prototype.removeAllListeners=function(l){var h;return l?(h=t?t+l:l,this._events[h]&&o(this,h)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a})(sg);var $1=sg.exports;const lo=Kh($1);var nu={exports:{}};nu.exports=Ta,nu.exports.default=Ta;function Ta(n,e,t){t=t||2;var i=e&&e.length,r=i?e[0]*t:n.length,s=og(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;var a,l,h,u,c,d,f;if(i&&(s=rS(n,e,s,t)),n.length>80*t){a=h=n[0],l=u=n[1];for(var p=t;p<r;p+=t)c=n[p],d=n[p+1],c<a&&(a=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);f=Math.max(h-a,u-l),f=f!==0?32767/f:0}return ho(s,o,t,a,l,f,0),o}function og(n,e,t,i,r){var s,o;if(r===ou(n,e,t,i)>0)for(s=e;s<t;s+=i)o=hg(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=hg(s,n[s],n[s+1],o);return o&&Ea(o,o.next)&&(co(o),o=o.next),o}function xr(n,e){if(!n)return n;e||(e=n);var t=n,i;do if(i=!1,!t.steiner&&(Ea(t,t.next)||ft(t.prev,t,t.next)===0)){if(co(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function ho(n,e,t,i,r,s,o){if(n){!o&&s&&hS(n,i,r,s);for(var a=n,l,h;n.prev!==n.next;){if(l=n.prev,h=n.next,s?tS(n,i,r,s):eS(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(h.i/t|0),co(n),n=h.next,a=h.next;continue}if(n=h,n===a){o?o===1?(n=iS(xr(n),e,t),ho(n,e,t,i,r,s,2)):o===2&&nS(n,e,t,i,r,s):ho(xr(n),e,t,i,r,s,1);break}}}}function eS(n){var e=n.prev,t=n,i=n.next;if(ft(e,t,i)>=0)return!1;for(var r=e.x,s=t.x,o=i.x,a=e.y,l=t.y,h=i.y,u=r<s?r<o?r:o:s<o?s:o,c=a<l?a<h?a:h:l<h?l:h,d=r>s?r>o?r:o:s>o?s:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==e;){if(p.x>=u&&p.x<=d&&p.y>=c&&p.y<=f&&ds(r,a,s,l,o,h,p.x,p.y)&&ft(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function tS(n,e,t,i){var r=n.prev,s=n,o=n.next;if(ft(r,s,o)>=0)return!1;for(var a=r.x,l=s.x,h=o.x,u=r.y,c=s.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=u<c?u<d?u:d:c<d?c:d,g=a>l?a>h?a:h:l>h?l:h,m=u>c?u>d?u:d:c>d?c:d,v=ru(f,p,e,t,i),_=ru(g,m,e,t,i),y=n.prevZ,w=n.nextZ;y&&y.z>=v&&w&&w.z<=_;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==r&&y!==o&&ds(a,u,l,c,h,d,y.x,y.y)&&ft(y.prev,y,y.next)>=0||(y=y.prevZ,w.x>=f&&w.x<=g&&w.y>=p&&w.y<=m&&w!==r&&w!==o&&ds(a,u,l,c,h,d,w.x,w.y)&&ft(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;y&&y.z>=v;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==r&&y!==o&&ds(a,u,l,c,h,d,y.x,y.y)&&ft(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;w&&w.z<=_;){if(w.x>=f&&w.x<=g&&w.y>=p&&w.y<=m&&w!==r&&w!==o&&ds(a,u,l,c,h,d,w.x,w.y)&&ft(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function iS(n,e,t){var i=n;do{var r=i.prev,s=i.next.next;!Ea(r,s)&&ag(r,i,i.next,s)&&uo(r,s)&&uo(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),co(i),co(i.next),i=n=s),i=i.next}while(i!==n);return xr(i)}function nS(n,e,t,i,r,s){var o=n;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&dS(o,a)){var l=lg(o,a);o=xr(o,o.next),l=xr(l,l.next),ho(o,e,t,i,r,s,0),ho(l,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function rS(n,e,t,i){var r=[],s,o,a,l,h;for(s=0,o=e.length;s<o;s++)a=e[s]*i,l=s<o-1?e[s+1]*i:n.length,h=og(n,a,l,i,!1),h===h.next&&(h.steiner=!0),r.push(cS(h));for(r.sort(sS),s=0;s<r.length;s++)t=oS(r[s],t);return t}function sS(n,e){return n.x-e.x}function oS(n,e){var t=aS(n,e);if(!t)return e;var i=lg(t,n);return xr(i,i.next),xr(t,t.next)}function aS(n,e){var t=e,i=n.x,r=n.y,s=-1/0,o;do{if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){var a=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(a<=i&&a>s&&(s=a,o=t.x<t.next.x?t:t.next,a===i))return o}t=t.next}while(t!==e);if(!o)return null;var l=o,h=o.x,u=o.y,c=1/0,d;t=o;do i>=t.x&&t.x>=h&&i!==t.x&&ds(r<u?i:s,r,h,u,r<u?s:i,r,t.x,t.y)&&(d=Math.abs(r-t.y)/(i-t.x),uo(t,n)&&(d<c||d===c&&(t.x>o.x||t.x===o.x&&lS(o,t)))&&(o=t,c=d)),t=t.next;while(t!==l);return o}function lS(n,e){return ft(n.prev,n,e.prev)<0&&ft(e.next,n,n.next)<0}function hS(n,e,t,i){var r=n;do r.z===0&&(r.z=ru(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,uS(r)}function uS(n){var e,t,i,r,s,o,a,l,h=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<h&&(a++,i=i.nextZ,!!i);e++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,h*=2}while(o>1);return n}function ru(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function cS(n){var e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function ds(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function dS(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!fS(n,e)&&(uo(n,e)&&uo(e,n)&&pS(n,e)&&(ft(n.prev,n,e.prev)||ft(n,e.prev,e))||Ea(n,e)&&ft(n.prev,n,n.next)>0&&ft(e.prev,e,e.next)>0)}function ft(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Ea(n,e){return n.x===e.x&&n.y===e.y}function ag(n,e,t,i){var r=Sa(ft(n,e,t)),s=Sa(ft(n,e,i)),o=Sa(ft(t,i,n)),a=Sa(ft(t,i,e));return!!(r!==s&&o!==a||r===0&&ba(n,t,e)||s===0&&ba(n,i,e)||o===0&&ba(t,n,i)||a===0&&ba(t,e,i))}function ba(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Sa(n){return n>0?1:n<0?-1:0}function fS(n,e){var t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&ag(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function uo(n,e){return ft(n.prev,n,n.next)<0?ft(n,e,n.next)>=0&&ft(n,n.prev,e)>=0:ft(n,e,n.prev)<0||ft(n,n.next,e)<0}function pS(n,e){var t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function lg(n,e){var t=new su(n.i,n.x,n.y),i=new su(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function hg(n,e,t,i){var r=new su(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function co(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function su(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Ta.deviation=function(n,e,t,i){var r=e&&e.length,s=r?e[0]*t:n.length,o=Math.abs(ou(n,0,s,t));if(r)for(var a=0,l=e.length;a<l;a++){var h=e[a]*t,u=a<l-1?e[a+1]*t:n.length;o-=Math.abs(ou(n,h,u,t))}var c=0;for(a=0;a<i.length;a+=3){var d=i[a]*t,f=i[a+1]*t,p=i[a+2]*t;c+=Math.abs((n[d]-n[p])*(n[f+1]-n[d+1])-(n[d]-n[f])*(n[p+1]-n[d+1]))}return o===0&&c===0?0:Math.abs((c-o)/o)};function ou(n,e,t,i){for(var r=0,s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}Ta.flatten=function(n){for(var e=n[0][0].length,t={vertices:[],holes:[],dimensions:e},i=0,r=0;r<n.length;r++){for(var s=0;s<n[r].length;s++)for(var o=0;o<e;o++)t.vertices.push(n[r][s][o]);r>0&&(i+=n[r-1].length,t.holes.push(i))}return t};var gS=nu.exports;const mS=Kh(gS);var Aa={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Aa.exports,(function(n,e){(function(t){var i=e&&!e.nodeType&&e,r=n&&!n.nodeType&&n,s=typeof Zh=="object"&&Zh;(s.global===s||s.window===s||s.self===s)&&(t=s);var o,a=2147483647,l=36,h=1,u=26,c=38,d=700,f=72,p=128,g="-",m=/^xn--/,v=/[^\x20-\x7E]/,_=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=l-h,R=Math.floor,M=String.fromCharCode,C;function O(z){throw new RangeError(y[z])}function N(z,H){for(var K=z.length,$=[];K--;)$[K]=H(z[K]);return $}function X(z,H){var K=z.split("@"),$="";K.length>1&&($=K[0]+"@",z=K[1]),z=z.replace(_,".");var se=z.split("."),fe=N(se,H).join(".");return $+fe}function q(z){for(var H=[],K=0,$=z.length,se,fe;K<$;)se=z.charCodeAt(K++),se>=55296&&se<=56319&&K<$?(fe=z.charCodeAt(K++),(fe&64512)==56320?H.push(((se&1023)<<10)+(fe&1023)+65536):(H.push(se),K--)):H.push(se);return H}function L(z){return N(z,function(H){var K="";return H>65535&&(H-=65536,K+=M(H>>>10&1023|55296),H=56320|H&1023),K+=M(H),K}).join("")}function S(z){return z-48<10?z-22:z-65<26?z-65:z-97<26?z-97:l}function I(z,H){return z+22+75*(z<26)-((H!=0)<<5)}function B(z,H,K){var $=0;for(z=K?R(z/d):z>>1,z+=R(z/H);z>w*u>>1;$+=l)z=R(z/w);return R($+(w+1)*z/(z+c))}function j(z){var H=[],K=z.length,$,se=0,fe=p,te=f,J,Y,he,le,ve,Ce,ze,lt,me;for(J=z.lastIndexOf(g),J<0&&(J=0),Y=0;Y<J;++Y)z.charCodeAt(Y)>=128&&O("not-basic"),H.push(z.charCodeAt(Y));for(he=J>0?J+1:0;he<K;){for(le=se,ve=1,Ce=l;he>=K&&O("invalid-input"),ze=S(z.charCodeAt(he++)),(ze>=l||ze>R((a-se)/ve))&&O("overflow"),se+=ze*ve,lt=Ce<=te?h:Ce>=te+u?u:Ce-te,!(ze<lt);Ce+=l)me=l-lt,ve>R(a/me)&&O("overflow"),ve*=me;$=H.length+1,te=B(se-le,$,le==0),R(se/$)>a-fe&&O("overflow"),fe+=R(se/$),se%=$,H.splice(se++,0,fe)}return L(H)}function U(z){var H,K,$,se,fe,te,J,Y,he,le,ve,Ce=[],ze,lt,me,Ae;for(z=q(z),ze=z.length,H=p,K=0,fe=f,te=0;te<ze;++te)ve=z[te],ve<128&&Ce.push(M(ve));for($=se=Ce.length,se&&Ce.push(g);$<ze;){for(J=a,te=0;te<ze;++te)ve=z[te],ve>=H&&ve<J&&(J=ve);for(lt=$+1,J-H>R((a-K)/lt)&&O("overflow"),K+=(J-H)*lt,H=J,te=0;te<ze;++te)if(ve=z[te],ve<H&&++K>a&&O("overflow"),ve==H){for(Y=K,he=l;le=he<=fe?h:he>=fe+u?u:he-fe,!(Y<le);he+=l)Ae=Y-le,me=l-le,Ce.push(M(I(le+Ae%me,0))),Y=R(Ae/me);Ce.push(M(I(Y,0))),fe=B(K,lt,$==se),K=0,++$}++K,++H}return Ce.join("")}function W(z){return X(z,function(H){return m.test(H)?j(H.slice(4).toLowerCase()):H})}function ee(z){return X(z,function(H){return v.test(H)?"xn--"+U(H):H})}if(o={version:"1.4.1",ucs2:{decode:q,encode:L},decode:j,encode:U,toASCII:ee,toUnicode:W},i&&r)if(n.exports==i)r.exports=o;else for(C in o)o.hasOwnProperty(C)&&(i[C]=o[C]);else t.punycode=o})(Zh)})(Aa,Aa.exports),Aa.exports;var ug=TypeError;const vS={},yS=Object.freeze(Object.defineProperty({__proto__:null,default:vS},Symbol.toStringTag,{value:"Module"})),_S=R1(yS);var cg=typeof Map=="function"&&Map.prototype,au=Object.getOwnPropertyDescriptor&&cg?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null;cg&&au&&typeof au.get=="function"&&au.get;var dg=typeof Set=="function"&&Set.prototype,lu=Object.getOwnPropertyDescriptor&&dg?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null;dg&&lu&&typeof lu.get=="function"&&lu.get;var fg=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,xS=typeof Symbol=="function"&&typeof Symbol.iterator=="object",wS=_S,pg=wS.custom;TS(pg);function TS(n){if(xS)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!fg)return!1;try{return fg.call(n),!0}catch{}return!1}var gg=Object,ES=Error,bS=EvalError,SS=RangeError,AS=ReferenceError,RS=SyntaxError,CS=URIError,PS=Math.abs,IS=Math.floor,DS=Math.max,MS=Math.min,OS=Math.pow,LS=Math.round,BS=Number.isNaN||function(n){return n!==n},FS=BS,NS=function(n){return FS(n)||n===0?n:n<0?-1:1},kS=Object.getOwnPropertyDescriptor,Ra=kS;if(Ra)try{Ra([],"length")}catch{Ra=null}var mg=Ra,Ca=Object.defineProperty||!1;if(Ca)try{Ca({},"a",{value:1})}catch{Ca=!1}var US=Ca,vg,yg;function HS(){return yg||(yg=1,vg=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var n={},e=Symbol("test"),t=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(t)!=="[object Symbol]")return!1;var i=42;n[e]=i;for(var r in n)return!1;if(typeof Object.keys=="function"&&Object.keys(n).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(n).length!==0)return!1;var s=Object.getOwnPropertySymbols(n);if(s.length!==1||s[0]!==e||!Object.prototype.propertyIsEnumerable.call(n,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(n,e);if(o.value!==i||o.enumerable!==!0)return!1}return!0}),vg}var hu,_g;function zS(){if(_g)return hu;_g=1;var n=typeof Symbol<"u"&&Symbol,e=HS();return hu=function(){return typeof n!="function"||typeof Symbol!="function"||typeof n("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},hu}var xg,wg;function Tg(){return wg||(wg=1,xg=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),xg}var uu,Eg;function bg(){if(Eg)return uu;Eg=1;var n=gg;return uu=n.getPrototypeOf||null,uu}var GS="Function.prototype.bind called on incompatible ",VS=Object.prototype.toString,WS=Math.max,jS="[object Function]",Sg=function(n,e){for(var t=[],i=0;i<n.length;i+=1)t[i]=n[i];for(var r=0;r<e.length;r+=1)t[r+n.length]=e[r];return t},XS=function(n,e){for(var t=[],i=e,r=0;i<n.length;i+=1,r+=1)t[r]=n[i];return t},YS=function(n,e){for(var t="",i=0;i<n.length;i+=1)t+=n[i],i+1<n.length&&(t+=e);return t},qS=function(n){var e=this;if(typeof e!="function"||VS.apply(e)!==jS)throw new TypeError(GS+e);for(var t=XS(arguments,1),i,r=function(){if(this instanceof i){var h=e.apply(this,Sg(t,arguments));return Object(h)===h?h:this}return e.apply(n,Sg(t,arguments))},s=WS(0,e.length-t.length),o=[],a=0;a<s;a++)o[a]="$"+a;if(i=Function("binder","return function ("+YS(o,",")+"){ return binder.apply(this,arguments); }")(r),e.prototype){var l=function(){};l.prototype=e.prototype,i.prototype=new l,l.prototype=null}return i},ZS=qS,Pa=Function.prototype.bind||ZS,Ag,Rg;function cu(){return Rg||(Rg=1,Ag=Function.prototype.call),Ag}var Cg,Pg;function Ig(){return Pg||(Pg=1,Cg=Function.prototype.apply),Cg}var KS=typeof Reflect<"u"&&Reflect&&Reflect.apply,QS=Pa,JS=Ig(),$S=cu(),eA=KS,tA=eA||QS.call($S,JS),iA=Pa,nA=ug,rA=cu(),sA=tA,Dg=function(n){if(n.length<1||typeof n[0]!="function")throw new nA("a function is required");return sA(iA,rA,n)},du,Mg;function oA(){if(Mg)return du;Mg=1;var n=Dg,e=mg,t;try{t=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var i=!!t&&e&&e(Object.prototype,"__proto__"),r=Object,s=r.getPrototypeOf;return du=i&&typeof i.get=="function"?n([i.get]):typeof s=="function"?(function(o){return s(o==null?o:r(o))}):!1,du}var fu,Og;function aA(){if(Og)return fu;Og=1;var n=Tg(),e=bg(),t=oA();return fu=n?function(i){return n(i)}:e?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return e(i)}:t?function(i){return t(i)}:null,fu}var pu,Lg;function lA(){if(Lg)return pu;Lg=1;var n=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=Pa;return pu=t.call(n,e),pu}var je,hA=gg,uA=ES,cA=bS,dA=SS,fA=AS,fs=RS,ps=ug,pA=CS,gA=PS,mA=IS,vA=DS,yA=MS,_A=OS,xA=LS,wA=NS,Bg=Function,gu=function(n){try{return Bg('"use strict"; return ('+n+").constructor;")()}catch{}},fo=mg,TA=US,mu=function(){throw new ps},EA=fo?(function(){try{return arguments.callee,mu}catch{try{return fo(arguments,"callee").get}catch{return mu}}})():mu,gs=zS()(),Ct=aA(),bA=bg(),SA=Tg(),Fg=Ig(),po=cu(),ms={},AA=typeof Uint8Array>"u"||!Ct?je:Ct(Uint8Array),wr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?je:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?je:ArrayBuffer,"%ArrayIteratorPrototype%":gs&&Ct?Ct([][Symbol.iterator]()):je,"%AsyncFromSyncIteratorPrototype%":je,"%AsyncFunction%":ms,"%AsyncGenerator%":ms,"%AsyncGeneratorFunction%":ms,"%AsyncIteratorPrototype%":ms,"%Atomics%":typeof Atomics>"u"?je:Atomics,"%BigInt%":typeof BigInt>"u"?je:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?je:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?je:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?je:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":uA,"%eval%":eval,"%EvalError%":cA,"%Float16Array%":typeof Float16Array>"u"?je:Float16Array,"%Float32Array%":typeof Float32Array>"u"?je:Float32Array,"%Float64Array%":typeof Float64Array>"u"?je:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?je:FinalizationRegistry,"%Function%":Bg,"%GeneratorFunction%":ms,"%Int8Array%":typeof Int8Array>"u"?je:Int8Array,"%Int16Array%":typeof Int16Array>"u"?je:Int16Array,"%Int32Array%":typeof Int32Array>"u"?je:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":gs&&Ct?Ct(Ct([][Symbol.iterator]())):je,"%JSON%":typeof JSON=="object"?JSON:je,"%Map%":typeof Map>"u"?je:Map,"%MapIteratorPrototype%":typeof Map>"u"||!gs||!Ct?je:Ct(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":hA,"%Object.getOwnPropertyDescriptor%":fo,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?je:Promise,"%Proxy%":typeof Proxy>"u"?je:Proxy,"%RangeError%":dA,"%ReferenceError%":fA,"%Reflect%":typeof Reflect>"u"?je:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?je:Set,"%SetIteratorPrototype%":typeof Set>"u"||!gs||!Ct?je:Ct(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?je:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":gs&&Ct?Ct(""[Symbol.iterator]()):je,"%Symbol%":gs?Symbol:je,"%SyntaxError%":fs,"%ThrowTypeError%":EA,"%TypedArray%":AA,"%TypeError%":ps,"%Uint8Array%":typeof Uint8Array>"u"?je:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?je:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?je:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?je:Uint32Array,"%URIError%":pA,"%WeakMap%":typeof WeakMap>"u"?je:WeakMap,"%WeakRef%":typeof WeakRef>"u"?je:WeakRef,"%WeakSet%":typeof WeakSet>"u"?je:WeakSet,"%Function.prototype.call%":po,"%Function.prototype.apply%":Fg,"%Object.defineProperty%":TA,"%Object.getPrototypeOf%":bA,"%Math.abs%":gA,"%Math.floor%":mA,"%Math.max%":vA,"%Math.min%":yA,"%Math.pow%":_A,"%Math.round%":xA,"%Math.sign%":wA,"%Reflect.getPrototypeOf%":SA};if(Ct)try{null.error}catch(n){var RA=Ct(Ct(n));wr["%Error.prototype%"]=RA}var CA=function n(e){var t;if(e==="%AsyncFunction%")t=gu("async function () {}");else if(e==="%GeneratorFunction%")t=gu("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=gu("async function* () {}");else if(e==="%AsyncGenerator%"){var i=n("%AsyncGeneratorFunction%");i&&(t=i.prototype)}else if(e==="%AsyncIteratorPrototype%"){var r=n("%AsyncGenerator%");r&&Ct&&(t=Ct(r.prototype))}return wr[e]=t,t},Ng={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},go=Pa,Ia=lA(),PA=go.call(po,Array.prototype.concat),IA=go.call(Fg,Array.prototype.splice),kg=go.call(po,String.prototype.replace),Da=go.call(po,String.prototype.slice),DA=go.call(po,RegExp.prototype.exec),MA=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,OA=/\\(\\)?/g,LA=function(n){var e=Da(n,0,1),t=Da(n,-1);if(e==="%"&&t!=="%")throw new fs("invalid intrinsic syntax, expected closing `%`");if(t==="%"&&e!=="%")throw new fs("invalid intrinsic syntax, expected opening `%`");var i=[];return kg(n,MA,function(r,s,o,a){i[i.length]=o?kg(a,OA,"$1"):s||r}),i},BA=function(n,e){var t=n,i;if(Ia(Ng,t)&&(i=Ng[t],t="%"+i[0]+"%"),Ia(wr,t)){var r=wr[t];if(r===ms&&(r=CA(t)),typeof r>"u"&&!e)throw new ps("intrinsic "+n+" exists, but is not available. Please file an issue!");return{alias:i,name:t,value:r}}throw new fs("intrinsic "+n+" does not exist!")},vu=function(n,e){if(typeof n!="string"||n.length===0)throw new ps("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new ps('"allowMissing" argument must be a boolean');if(DA(/^%?[^%]*%?$/,n)===null)throw new fs("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var t=LA(n),i=t.length>0?t[0]:"",r=BA("%"+i+"%",e),s=r.name,o=r.value,a=!1,l=r.alias;l&&(i=l[0],IA(t,PA([0,1],l)));for(var h=1,u=!0;h<t.length;h+=1){var c=t[h],d=Da(c,0,1),f=Da(c,-1);if((d==='"'||d==="'"||d==="`"||f==='"'||f==="'"||f==="`")&&d!==f)throw new fs("property names with quotes must have matching quotes");if((c==="constructor"||!u)&&(a=!0),i+="."+c,s="%"+i+"%",Ia(wr,s))o=wr[s];else if(o!=null){if(!(c in o)){if(!e)throw new ps("base intrinsic for "+n+" exists, but the property is not available.");return}if(fo&&h+1>=t.length){var p=fo(o,c);u=!!p,u&&"get"in p&&!("originalValue"in p.get)?o=p.get:o=o[c]}else u=Ia(o,c),o=o[c];u&&!a&&(wr[s]=o)}}return o},Ug=vu,Hg=Dg,FA=Hg([Ug("%String.prototype.indexOf%")]),zg=function(n,e){var t=Ug(n,!!e);return typeof t=="function"&&FA(n,".prototype.")>-1?Hg([t]):t},NA=vu,mo=zg;NA("%Map%",!0),mo("Map.prototype.get",!0),mo("Map.prototype.set",!0),mo("Map.prototype.has",!0),mo("Map.prototype.delete",!0),mo("Map.prototype.size",!0);var kA=vu,Ma=zg;kA("%WeakMap%",!0),Ma("WeakMap.prototype.get",!0),Ma("WeakMap.prototype.set",!0),Ma("WeakMap.prototype.has",!0),Ma("WeakMap.prototype.delete",!0),(function(){for(var n=[],e=0;e<256;++e)n.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return n})();const Gg={};function We(n,e,t=3){if(Gg[e])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${e}
132
+ Deprecated since v${n}`):(i=i.split(`
133
+ `).splice(t).join(`
134
+ `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e}
135
+ Deprecated since v${n}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e}
136
+ Deprecated since v${n}`),console.warn(i))),Gg[e]=!0}function Bi(n){if(typeof n!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(n)}`)}function vo(n){return n.split("?")[0].split("#")[0]}function UA(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function HA(n,e,t){return n.replace(new RegExp(UA(e),"g"),t)}function zA(n,e){let t="",i=0,r=-1,s=0,o=-1;for(let a=0;a<=n.length;++a){if(a<n.length)o=n.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(r===a-1||s===1))if(r!==a-1&&s===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){const l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",i=0):(t=t.slice(0,l),i=t.length-1-t.lastIndexOf("/")),r=a,s=0;continue}}else if(t.length===2||t.length===1){t="",i=0,r=a,s=0;continue}}}else t.length>0?t+=`/${n.slice(r+1,a)}`:t=n.slice(r+1,a),i=a-r-1;r=a,s=0}else o===46&&s!==-1?++s:s=-1}return t}const Pt={toPosix(n){return HA(n,"\\","/")},isUrl(n){return/^https?:/.test(this.toPosix(n))},isDataUrl(n){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(n)},isBlobUrl(n){return n.startsWith("blob:")},hasProtocol(n){return/^[^/:]+:/.test(this.toPosix(n))},getProtocol(n){Bi(n),n=this.toPosix(n);const e=/^file:\/\/\//.exec(n);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(n);return t?t[0]:""},toAbsolute(n,e,t){if(Bi(n),this.isDataUrl(n)||this.isBlobUrl(n))return n;const i=vo(this.toPosix(e??de.ADAPTER.getBaseUrl())),r=vo(this.toPosix(t??this.rootname(i)));return n=this.toPosix(n),n.startsWith("/")?Pt.join(r,n.slice(1)):this.isAbsolute(n)?n:this.join(i,n)},normalize(n){if(Bi(n),n.length===0)return".";if(this.isDataUrl(n)||this.isBlobUrl(n))return n;n=this.toPosix(n);let e="";const t=n.startsWith("/");this.hasProtocol(n)&&(e=this.rootname(n),n=n.slice(e.length));const i=n.endsWith("/");return n=zA(n),n.length>0&&i&&(n+="/"),t?`/${n}`:e+n},isAbsolute(n){return Bi(n),n=this.toPosix(n),this.hasProtocol(n)?!0:n.startsWith("/")},join(...n){if(n.length===0)return".";let e;for(let t=0;t<n.length;++t){const i=n[t];if(Bi(i),i.length>0)if(e===void 0)e=i;else{const r=n[t-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(n){if(Bi(n),n.length===0)return".";n=this.toPosix(n);let e=n.charCodeAt(0);const t=e===47;let i=-1,r=!0;const s=this.getProtocol(n),o=n;n=n.slice(s.length);for(let a=n.length-1;a>=1;--a)if(e=n.charCodeAt(a),e===47){if(!r){i=a;break}}else r=!1;return i===-1?t?"/":this.isUrl(o)?s+n:s:t&&i===1?"//":s+n.slice(0,i)},rootname(n){Bi(n),n=this.toPosix(n);let e="";if(n.startsWith("/")?e="/":e=this.getProtocol(n),this.isUrl(n)){const t=n.indexOf("/",e.length);t!==-1?e=n.slice(0,t):e=n,e.endsWith("/")||(e+="/")}return e},basename(n,e){Bi(n),e&&Bi(e),n=vo(this.toPosix(n));let t=0,i=-1,r=!0,s;if(e!==void 0&&e.length>0&&e.length<=n.length){if(e.length===n.length&&e===n)return"";let o=e.length-1,a=-1;for(s=n.length-1;s>=0;--s){const l=n.charCodeAt(s);if(l===47){if(!r){t=s+1;break}}else a===-1&&(r=!1,a=s+1),o>=0&&(l===e.charCodeAt(o)?--o===-1&&(i=s):(o=-1,i=a))}return t===i?i=a:i===-1&&(i=n.length),n.slice(t,i)}for(s=n.length-1;s>=0;--s)if(n.charCodeAt(s)===47){if(!r){t=s+1;break}}else i===-1&&(r=!1,i=s+1);return i===-1?"":n.slice(t,i)},extname(n){Bi(n),n=vo(this.toPosix(n));let e=-1,t=0,i=-1,r=!0,s=0;for(let o=n.length-1;o>=0;--o){const a=n.charCodeAt(o);if(a===47){if(!r){t=o+1;break}continue}i===-1&&(r=!1,i=o+1),a===46?e===-1?e=o:s!==1&&(s=1):e!==-1&&(s=-1)}return e===-1||i===-1||s===0||s===1&&e===i-1&&e===t+1?"":n.slice(e,i)},parse(n){Bi(n);const e={root:"",dir:"",base:"",ext:"",name:""};if(n.length===0)return e;n=vo(this.toPosix(n));let t=n.charCodeAt(0);const i=this.isAbsolute(n);let r;e.root=this.rootname(n),i||this.hasProtocol(n)?r=1:r=0;let s=-1,o=0,a=-1,l=!0,h=n.length-1,u=0;for(;h>=r;--h){if(t=n.charCodeAt(h),t===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),t===46?s===-1?s=h:u!==1&&(u=1):s!==-1&&(u=-1)}return s===-1||a===-1||u===0||u===1&&s===a-1&&s===o+1?a!==-1&&(o===0&&i?e.base=e.name=n.slice(1,a):e.base=e.name=n.slice(o,a)):(o===0&&i?(e.name=n.slice(1,s),e.base=n.slice(1,a)):(e.name=n.slice(o,s),e.base=n.slice(o,a)),e.ext=n.slice(s,a)),e.dir=this.dirname(n),e},sep:"/",delimiter:":",joinExtensions:[".html"]};let yu;async function GA(){return yu??(yu=(async()=>{var n;const e=document.createElement("canvas").getContext("webgl");if(!e)return li.UNPACK;const t=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!t)return li.UNPACK;const i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,s),e.deleteFramebuffer(r),e.deleteTexture(i),(n=e.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?li.PMA:li.UNPACK})()),yu}let _u;function VA(){return typeof _u>"u"&&(_u=(function(){var n;const e={stencil:!0,failIfMajorPerformanceCaveat:de.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!de.ADAPTER.getWebGLRenderingContext())return!1;const t=de.ADAPTER.createCanvas();let i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e);const r=!!((n=i?.getContextAttributes())!=null&&n.stencil);if(i){const s=i.getExtension("WEBGL_lose_context");s&&s.loseContext()}return i=null,r}catch{return!1}})()),_u}var WA={grad:.9,turn:360,rad:360/(2*Math.PI)},En=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},It=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*n)/t+0},Ri=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),n>t?t:n>e?n:e},Vg=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},Wg=function(n){return{r:Ri(n.r,0,255),g:Ri(n.g,0,255),b:Ri(n.b,0,255),a:Ri(n.a)}},xu=function(n){return{r:It(n.r),g:It(n.g),b:It(n.b),a:It(n.a,3)}},jA=/^#([0-9a-f]{3,8})$/i,Oa=function(n){var e=n.toString(16);return e.length<2?"0"+e:e},jg=function(n){var e=n.r,t=n.g,i=n.b,r=n.a,s=Math.max(e,t,i),o=s-Math.min(e,t,i),a=o?s===e?(t-i)/o:s===t?2+(i-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:s?o/s*100:0,v:s/255*100,a:r}},Xg=function(n){var e=n.h,t=n.s,i=n.v,r=n.a;e=e/360*6,t/=100,i/=100;var s=Math.floor(e),o=i*(1-t),a=i*(1-(e-s)*t),l=i*(1-(1-e+s)*t),h=s%6;return{r:255*[i,a,o,o,l,i][h],g:255*[l,i,i,a,o,o][h],b:255*[o,o,l,i,i,a][h],a:r}},Yg=function(n){return{h:Vg(n.h),s:Ri(n.s,0,100),l:Ri(n.l,0,100),a:Ri(n.a)}},qg=function(n){return{h:It(n.h),s:It(n.s),l:It(n.l),a:It(n.a,3)}},Zg=function(n){return Xg((t=(e=n).s,{h:e.h,s:(t*=((i=e.l)<50?i:100-i)/100)>0?2*t/(i+t)*100:0,v:i+t,a:e.a}));var e,t,i},yo=function(n){return{h:(e=jg(n)).h,s:(r=(200-(t=e.s))*(i=e.v)/100)>0&&r<200?t*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,t,i,r},XA=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,YA=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qA=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ZA=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wu={string:[[function(n){var e=jA.exec(n);return e?(n=e[1]).length<=4?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?It(parseInt(n[3]+n[3],16)/255,2):1}:n.length===6||n.length===8?{r:parseInt(n.substr(0,2),16),g:parseInt(n.substr(2,2),16),b:parseInt(n.substr(4,2),16),a:n.length===8?It(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var e=qA.exec(n)||ZA.exec(n);return e?e[2]!==e[4]||e[4]!==e[6]?null:Wg({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(n){var e=XA.exec(n)||YA.exec(n);if(!e)return null;var t,i,r=Yg({h:(t=e[1],i=e[2],i===void 0&&(i="deg"),Number(t)*(WA[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Zg(r)},"hsl"]],object:[[function(n){var e=n.r,t=n.g,i=n.b,r=n.a,s=r===void 0?1:r;return En(e)&&En(t)&&En(i)?Wg({r:Number(e),g:Number(t),b:Number(i),a:Number(s)}):null},"rgb"],[function(n){var e=n.h,t=n.s,i=n.l,r=n.a,s=r===void 0?1:r;if(!En(e)||!En(t)||!En(i))return null;var o=Yg({h:Number(e),s:Number(t),l:Number(i),a:Number(s)});return Zg(o)},"hsl"],[function(n){var e=n.h,t=n.s,i=n.v,r=n.a,s=r===void 0?1:r;if(!En(e)||!En(t)||!En(i))return null;var o=(function(a){return{h:Vg(a.h),s:Ri(a.s,0,100),v:Ri(a.v,0,100),a:Ri(a.a)}})({h:Number(e),s:Number(t),v:Number(i),a:Number(s)});return Xg(o)},"hsv"]]},Kg=function(n,e){for(var t=0;t<e.length;t++){var i=e[t][0](n);if(i)return[i,e[t][1]]}return[null,void 0]},KA=function(n){return typeof n=="string"?Kg(n.trim(),wu.string):typeof n=="object"&&n!==null?Kg(n,wu.object):[null,void 0]},Tu=function(n,e){var t=yo(n);return{h:t.h,s:Ri(t.s+100*e,0,100),l:t.l,a:t.a}},Eu=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},Qg=function(n,e){var t=yo(n);return{h:t.h,s:t.s,l:Ri(t.l+100*e,0,100),a:t.a}},bu=(function(){function n(e){this.parsed=KA(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return n.prototype.isValid=function(){return this.parsed!==null},n.prototype.brightness=function(){return It(Eu(this.rgba),2)},n.prototype.isDark=function(){return Eu(this.rgba)<.5},n.prototype.isLight=function(){return Eu(this.rgba)>=.5},n.prototype.toHex=function(){return e=xu(this.rgba),t=e.r,i=e.g,r=e.b,o=(s=e.a)<1?Oa(It(255*s)):"","#"+Oa(t)+Oa(i)+Oa(r)+o;var e,t,i,r,s,o},n.prototype.toRgb=function(){return xu(this.rgba)},n.prototype.toRgbString=function(){return e=xu(this.rgba),t=e.r,i=e.g,r=e.b,(s=e.a)<1?"rgba("+t+", "+i+", "+r+", "+s+")":"rgb("+t+", "+i+", "+r+")";var e,t,i,r,s},n.prototype.toHsl=function(){return qg(yo(this.rgba))},n.prototype.toHslString=function(){return e=qg(yo(this.rgba)),t=e.h,i=e.s,r=e.l,(s=e.a)<1?"hsla("+t+", "+i+"%, "+r+"%, "+s+")":"hsl("+t+", "+i+"%, "+r+"%)";var e,t,i,r,s},n.prototype.toHsv=function(){return e=jg(this.rgba),{h:It(e.h),s:It(e.s),v:It(e.v),a:It(e.a,3)};var e},n.prototype.invert=function(){return nn({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},n.prototype.saturate=function(e){return e===void 0&&(e=.1),nn(Tu(this.rgba,e))},n.prototype.desaturate=function(e){return e===void 0&&(e=.1),nn(Tu(this.rgba,-e))},n.prototype.grayscale=function(){return nn(Tu(this.rgba,-1))},n.prototype.lighten=function(e){return e===void 0&&(e=.1),nn(Qg(this.rgba,e))},n.prototype.darken=function(e){return e===void 0&&(e=.1),nn(Qg(this.rgba,-e))},n.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},n.prototype.alpha=function(e){return typeof e=="number"?nn({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):It(this.rgba.a,3);var t},n.prototype.hue=function(e){var t=yo(this.rgba);return typeof e=="number"?nn({h:e,s:t.s,l:t.l,a:t.a}):It(t.h)},n.prototype.isEqual=function(e){return this.toHex()===nn(e).toHex()},n})(),nn=function(n){return n instanceof bu?n:new bu(n)},Jg=[],QA=function(n){n.forEach(function(e){Jg.indexOf(e)<0&&(e(bu,wu),Jg.push(e))})};function JA(n,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in t)i[t[r]]=r;var s={};n.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=i[this.toHex()];if(h)return h;if(o!=null&&o.closest){var u=this.toRgb(),c=1/0,d="black";if(!s.length)for(var f in t)s[f]=new n(t[f]).toRgb();for(var p in t){var g=(a=u,l=s[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));g<c&&(c=g,d=p)}return d}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new n(l).toRgb():null},"name"])}QA([JA]);const vs=class El{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(e){if(e instanceof El)this._value=this.cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,e))&&(this.normalize(e),this._value=this.cloneSource(e))}}get value(){return this._value}cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}isSourceEqual(e,t){const i=typeof e;if(i!==typeof t)return!1;if(i==="number"||i==="string"||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length!==t.length?!1:e.every((r,s)=>r===t[s]);if(e!==null&&t!==null){const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(o=>e[o]===t[o])}return e===t}toRgba(){const[e,t,i,r]=this._components;return{r:e,g:t,b:i,a:r}}toRgb(){const[e,t,i]=this._components;return{r:e,g:t,b:i}}toRgbaString(){const[e,t,i]=this.toUint8RgbArray();return`rgba(${e},${t},${i},${this.alpha})`}toUint8RgbArray(e){const[t,i,r]=this._components;return e=e??[],e[0]=Math.round(t*255),e[1]=Math.round(i*255),e[2]=Math.round(r*255),e}toRgbArray(e){e=e??[];const[t,i,r]=this._components;return e[0]=t,e[1]=i,e[2]=r,e}toNumber(){return this._int}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,i,r,s]=El.temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=i,this._components[2]*=r,this._components[3]*=s,this.refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this.refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,s=this._int&255;return t&&(i=i*e+.5|0,r=r*e+.5|0,s=s*e+.5|0),(e*255<<24)+(i<<16)+(r<<8)+s}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(e){return this._components[3]=this._clamp(e),this}round(e){const[t,i,r]=this._components;return this._components[0]=Math.round(t*e)/e,this._components[1]=Math.round(i*e)/e,this._components[2]=Math.round(r*e)/e,this.refreshInt(),this._value=null,this}toArray(e){e=e??[];const[t,i,r,s]=this._components;return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e}normalize(e){let t,i,r,s;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;t=(o>>16&255)/255,i=(o>>8&255)/255,r=(o&255)/255,s=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,i,r,s=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,i,r,s=255]=e,t/=255,i/=255,r/=255,s/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=El.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=nn(e);o.isValid()&&({r:t,g:i,b:r,a:s}=o.rgba,t/=255,i/=255,r/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=i,this._components[2]=r,this._components[3]=s,this.refreshInt();else throw new Error(`Unable to convert color ${e}`)}refreshInt(){this._clamp(this._components);const[e,t,i]=this._components;this._int=(e*255<<16)+(t*255<<8)+(i*255|0)}_clamp(e,t=0,i=1){return typeof e=="number"?Math.min(Math.max(e,t),i):(e.forEach((r,s)=>{e[s]=Math.min(Math.max(r,t),i)}),e)}};vs.shared=new vs,vs.temp=new vs,vs.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let nt=vs;function $A(n){return We("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),nt.shared.setValue(n).toHex()}function eR(n){return We("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),nt.shared.setValue(n).toNumber()}function tR(){const n=[],e=[];for(let i=0;i<32;i++)n[i]=i,e[i]=i;n[De.NORMAL_NPM]=De.NORMAL,n[De.ADD_NPM]=De.ADD,n[De.SCREEN_NPM]=De.SCREEN,e[De.NORMAL]=De.NORMAL_NPM,e[De.ADD]=De.ADD_NPM,e[De.SCREEN]=De.SCREEN_NPM;const t=[];return t.push(e),t.push(n),t}const $g=tR();function em(n,e){return $g[e?1:0][n]}function iR(n,e=null){const t=n*6;if(e=e||new Uint16Array(t),e.length!==t)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);for(let i=0,r=0;i<t;i+=6,r+=4)e[i+0]=r+0,e[i+1]=r+1,e[i+2]=r+2,e[i+3]=r+0,e[i+4]=r+2,e[i+5]=r+3;return e}function tm(n){if(n.BYTES_PER_ELEMENT===4)return n instanceof Float32Array?"Float32Array":n instanceof Uint32Array?"Uint32Array":"Int32Array";if(n.BYTES_PER_ELEMENT===2){if(n instanceof Uint16Array)return"Uint16Array"}else if(n.BYTES_PER_ELEMENT===1&&n instanceof Uint8Array)return"Uint8Array";return null}function La(n){return n+=n===0?1:0,--n,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n+1}function im(n){return!(n&n-1)&&!!n}function nm(n){let e=(n>65535?1:0)<<4;n>>>=e;let t=(n>255?1:0)<<3;return n>>>=t,e|=t,t=(n>15?1:0)<<2,n>>>=t,e|=t,t=(n>3?1:0)<<1,n>>>=t,e|=t,e|n>>1}function ys(n,e,t){const i=n.length;let r;if(e>=i||t===0)return;t=e+t>i?i-e:t;const s=i-t;for(r=e;r<s;++r)n[r]=n[r+t];n.length=s}function Vn(n){return n===0?0:n<0?-1:1}let nR=0;function Tr(){return++nR}const Su=class{constructor(n,e,t,i){this.left=n,this.top=e,this.right=t,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};Su.EMPTY=new Su(0,0,0,0);let rm=Su;const sm={},rn=Object.create(null),Wn=Object.create(null);class rR{constructor(e,t,i){this._canvas=de.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||de.RESOLUTION,this.resize(e,t)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(e,t){this._checkDestroyed(),this._canvas.width=Math.round(e*this.resolution),this._canvas.height=Math.round(t*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(e){this._checkDestroyed(),this._canvas.width=Math.round(e)}get height(){return this._checkDestroyed(),this._canvas.height}set height(e){this._checkDestroyed(),this._canvas.height=Math.round(e)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function om(n,e,t){for(let i=0,r=4*t*e;i<e;++i,r+=4)if(n[r+3]!==0)return!1;return!0}function am(n,e,t,i,r){const s=4*e;for(let o=i,a=i*s+4*t;o<=r;++o,a+=s)if(n[a+3]!==0)return!1;return!0}function sR(n){const{width:e,height:t}=n,i=n.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const r=i.getImageData(0,0,e,t).data;let s=0,o=0,a=e-1,l=t-1;for(;o<t&&om(r,e,o);)++o;if(o===t)return rm.EMPTY;for(;om(r,e,l);)--l;for(;am(r,e,s,o,l);)++s;for(;am(r,e,a,o,l);)--a;return++a,++l,new rm(s,o,a,l)}function oR(n){const e=sR(n),{width:t,height:i}=e;let r=null;if(!e.isEmpty()){const s=n.getContext("2d");if(s===null)throw new TypeError("Failed to get canvas 2D context");r=s.getImageData(e.left,e.top,t,i)}return{width:t,height:i,data:r}}function aR(n,e=globalThis.location){if(n.startsWith("data:"))return"";e=e||globalThis.location;const t=new URL(n,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}function bn(n,e=1){var t;const i=(t=de.RETINA_PREFIX)==null?void 0:t.exec(n);return i?parseFloat(i[1]):e}var ue=(n=>(n.Renderer="renderer",n.Application="application",n.RendererSystem="renderer-webgl-system",n.RendererPlugin="renderer-webgl-plugin",n.CanvasRendererSystem="renderer-canvas-system",n.CanvasRendererPlugin="renderer-canvas-plugin",n.Asset="asset",n.LoadParser="load-parser",n.ResolveParser="resolve-parser",n.CacheParser="cache-parser",n.DetectionParser="detection-parser",n))(ue||{});const Au=n=>{if(typeof n=="function"||typeof n=="object"&&n.extension){if(!n.extension)throw new Error("Extension class must have an extension object");n={...typeof n.extension!="object"?{type:n.extension}:n.extension,ref:n}}if(typeof n=="object")n={...n};else throw new Error("Invalid extension type");return typeof n.type=="string"&&(n.type=[n.type]),n},lm=(n,e)=>Au(n).priority??e,Te={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...n){return n.map(Au).forEach(e=>{e.type.forEach(t=>{var i,r;return(r=(i=this._removeHandlers)[t])==null?void 0:r.call(i,e)})}),this},add(...n){return n.map(Au).forEach(e=>{e.type.forEach(t=>{var i,r;const s=this._addHandlers,o=this._queue;s[t]?(i=s[t])==null||i.call(s,e):(o[t]=o[t]||[],(r=o[t])==null||r.push(e))})}),this},handle(n,e,t){var i;const r=this._addHandlers,s=this._removeHandlers;if(r[n]||s[n])throw new Error(`Extension type ${n} already has a handler`);r[n]=e,s[n]=t;const o=this._queue;return o[n]&&((i=o[n])==null||i.forEach(a=>e(a)),delete o[n]),this},handleByMap(n,e){return this.handle(n,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByList(n,e,t=-1){return this.handle(n,i=>{e.includes(i.ref)||(e.push(i.ref),e.sort((r,s)=>lm(s,t)-lm(r,t)))},i=>{const r=e.indexOf(i.ref);r!==-1&&e.splice(r,1)})}};class Ru{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}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 uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}const lR=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
137
+ `);function hR(n){let e="";for(let t=0;t<n;++t)t>0&&(e+=`
138
+ else `),t<n-1&&(e+=`if(test == ${t}.0){}`);return e}function uR(n,e){if(n===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const t=e.createShader(e.FRAGMENT_SHADER);for(;;){const i=lR.replace(/%forloop%/gi,hR(n));if(e.shaderSource(t,i),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS))n=n/2|0;else break}return n}const Cu=0,Pu=1,Iu=2,Du=3,Mu=4,Ou=5;class sn{constructor(){this.data=0,this.blendMode=De.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Cu)}set blend(e){!!(this.data&1<<Cu)!==e&&(this.data^=1<<Cu)}get offsets(){return!!(this.data&1<<Pu)}set offsets(e){!!(this.data&1<<Pu)!==e&&(this.data^=1<<Pu)}get culling(){return!!(this.data&1<<Iu)}set culling(e){!!(this.data&1<<Iu)!==e&&(this.data^=1<<Iu)}get depthTest(){return!!(this.data&1<<Du)}set depthTest(e){!!(this.data&1<<Du)!==e&&(this.data^=1<<Du)}get depthMask(){return!!(this.data&1<<Ou)}set depthMask(e){!!(this.data&1<<Ou)!==e&&(this.data^=1<<Ou)}get clockwiseFrontFace(){return!!(this.data&1<<Mu)}set clockwiseFrontFace(e){!!(this.data&1<<Mu)!==e&&(this.data^=1<<Mu)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!==De.NONE,this._blendMode=e}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}static for2d(){const e=new sn;return e.depthTest=!1,e.blend=!0,e}}sn.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Lu=[];function hm(n,e){if(!n)return null;let t="";if(typeof n=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(n);i&&(t=i[1].toLowerCase())}for(let i=Lu.length-1;i>=0;--i){const r=Lu[i];if(r.test&&r.test(n,t))return new r(n,e)}throw new Error("Unrecognized source type to auto-detect Resource")}class Fi{constructor(e){this.items=[],this._name=e,this._aliasCount=0}emit(e,t,i,r,s,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][h](e,t,i,r,s,o,a,l);return u===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(e){return e[this._name]&&(this.ensureNonAliasedItems(),this.remove(e),this.items.push(e)),this}remove(e){const t=this.items.indexOf(e);return t!==-1&&(this.ensureNonAliasedItems(),this.items.splice(t,1)),this}contains(e){return this.items.includes(e)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(Fi.prototype,{dispatch:{value:Fi.prototype.emit},run:{value:Fi.prototype.emit}});class _o{constructor(e=0,t=0){this._width=e,this._height=t,this.destroyed=!1,this.internal=!1,this.onResize=new Fi("setRealSize"),this.onUpdate=new Fi("update"),this.onError=new Fi("onError")}bind(e){this.onResize.add(e),this.onUpdate.add(e),this.onError.add(e),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(e){this.onResize.remove(e),this.onUpdate.remove(e),this.onError.remove(e)}resize(e,t){(e!==this._width||t!==this._height)&&(this._width=e,this._height=t,this.onResize.emit(e,t))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(e,t,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(e,t){return!1}}class Ba extends _o{constructor(e,t){const{width:i,height:r}=t||{};if(!i||!r)throw new Error("BufferResource width or height invalid");super(i,r),this.data=e,this.unpackAlignment=t.unpackAlignment??4}upload(e,t,i){const r=e.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,this.unpackAlignment),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===li.UNPACK);const s=t.realWidth,o=t.realHeight;return i.width===s&&i.height===o?r.texSubImage2D(t.target,0,0,0,s,o,t.format,i.type,this.data):(i.width=s,i.height=o,r.texImage2D(t.target,0,i.internalFormat,s,o,0,t.format,i.type,this.data)),!0}dispose(){this.data=null}static test(e){return e===null||e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}const cR={scaleMode:xn.NEAREST,alphaMode:li.NPM},Bu=class Ms extends lo{constructor(e=null,t=null){super(),t=Object.assign({},Ms.defaultOptions,t);const{alphaMode:i,mipmap:r,anisotropicLevel:s,scaleMode:o,width:a,height:l,wrapMode:h,format:u,type:c,target:d,resolution:f,resourceOptions:p}=t;e&&!(e instanceof _o)&&(e=hm(e,p),e.internal=!0),this.resolution=f||de.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=r,this.anisotropicLevel=s,this._wrapMode=h,this._scaleMode=o,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=Tr(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(e)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(e){this._mipmap!==e&&(this._mipmap=e,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(e){this._scaleMode!==e&&(this._scaleMode=e,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(e){this._wrapMode!==e&&(this._wrapMode=e,this.dirtyStyleId++)}setStyle(e,t){let i;return e!==void 0&&e!==this.scaleMode&&(this.scaleMode=e,i=!0),t!==void 0&&t!==this.mipmap&&(this.mipmap=t,i=!0),i&&this.dirtyStyleId++,this}setSize(e,t,i){return i=i||this.resolution,this.setRealSize(e*i,t*i,i)}setRealSize(e,t,i){return this.resolution=i||this.resolution,this.width=Math.round(e)/this.resolution,this.height=Math.round(t)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=im(this.realWidth)&&im(this.realHeight)}setResolution(e){const t=this.resolution;return t===e?this:(this.resolution=e,this.valid&&(this.width=Math.round(this.width*t)/e,this.height=Math.round(this.height*t)/e,this.emit("update",this)),this._refreshPOT(),this)}setResource(e){if(this.resource===e)return this;if(this.resource)throw new Error("Resource can be set only once");return e.bind(this),this.resource=e,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(e){this.emit("error",this,e)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete Wn[this.cacheId],delete rn[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Ms.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(e,t,i=de.STRICT_TEXTURE_CACHE){const r=typeof e=="string";let s=null;if(r)s=e;else{if(!e._pixiId){const a=t?.pixiIdPrefix||"pixiid";e._pixiId=`${a}_${Tr()}`}s=e._pixiId}let o=Wn[s];if(r&&i&&!o)throw new Error(`The cacheId "${s}" does not exist in BaseTextureCache.`);return o||(o=new Ms(e,t),o.cacheId=s,Ms.addToCache(o,s)),o}static fromBuffer(e,t,i,r){e=e||new Float32Array(t*i*4);const s=new Ba(e,{width:t,height:i,...r?.resourceOptions});let o,a;return e instanceof Float32Array?(o=re.RGBA,a=Se.FLOAT):e instanceof Int32Array?(o=re.RGBA_INTEGER,a=Se.INT):e instanceof Uint32Array?(o=re.RGBA_INTEGER,a=Se.UNSIGNED_INT):e instanceof Int16Array?(o=re.RGBA_INTEGER,a=Se.SHORT):e instanceof Uint16Array?(o=re.RGBA_INTEGER,a=Se.UNSIGNED_SHORT):e instanceof Int8Array?(o=re.RGBA,a=Se.BYTE):(o=re.RGBA,a=Se.UNSIGNED_BYTE),s.internal=!0,new Ms(s,Object.assign({},cR,{type:a,format:o},r))}static addToCache(e,t){t&&(e.textureCacheIds.includes(t)||e.textureCacheIds.push(t),Wn[t]&&Wn[t]!==e&&console.warn(`BaseTexture added to the cache with an id [${t}] that already had an entry`),Wn[t]=e)}static removeFromCache(e){if(typeof e=="string"){const t=Wn[e];if(t){const i=t.textureCacheIds.indexOf(e);return i>-1&&t.textureCacheIds.splice(i,1),delete Wn[e],t}}else if(e!=null&&e.textureCacheIds){for(let t=0;t<e.textureCacheIds.length;++t)delete Wn[e.textureCacheIds[t]];return e.textureCacheIds.length=0,e}return null}};Bu.defaultOptions={mipmap:$i.POW2,anisotropicLevel:0,scaleMode:xn.LINEAR,wrapMode:Gn.CLAMP,alphaMode:li.UNPACK,target:us.TEXTURE_2D,format:re.RGBA,type:Se.UNSIGNED_BYTE},Bu._globalBatch=0;let Fe=Bu;class Fu{constructor(){this.texArray=null,this.blend=0,this.type=Ji.TRIANGLES,this.start=0,this.size=0,this.data=null}}let dR=0;class _t{constructor(e,t=!0,i=!1){this.data=e||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=t,this.id=dR++,this.disposeRunner=new Fi("disposeBuffer")}update(e){e instanceof Array&&(e=new Float32Array(e)),this.data=e||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(e){this.type=e?tn.ELEMENT_ARRAY_BUFFER:tn.ARRAY_BUFFER}get index(){return this.type===tn.ELEMENT_ARRAY_BUFFER}static from(e){return e instanceof Array&&(e=new Float32Array(e)),new _t(e)}}class Fa{constructor(e,t=0,i=!1,r=Se.FLOAT,s,o,a,l=1){this.buffer=e,this.size=t,this.normalized=i,this.type=r,this.stride=s,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(e,t,i,r,s){return new Fa(e,t,i,r,s)}}const fR={Float32Array,Uint32Array,Int32Array,Uint8Array};function pR(n,e){let t=0,i=0;const r={};for(let l=0;l<n.length;l++)i+=e[l],t+=n[l].length;const s=new ArrayBuffer(t*4);let o=null,a=0;for(let l=0;l<n.length;l++){const h=e[l],u=n[l],c=tm(u);r[c]||(r[c]=new fR[c](s)),o=r[c];for(let d=0;d<u.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=u[d]}a+=h}return new Float32Array(s)}const um={5126:4,5123:2,5121:1};let gR=0;const mR={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class jn{constructor(e=[],t={}){this.buffers=e,this.indexBuffer=null,this.attributes=t,this.glVertexArrayObjects={},this.id=gR++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Fi("disposeGeometry"),this.refCount=0}addAttribute(e,t,i=0,r=!1,s,o,a,l=!1){if(!t)throw new Error("You must pass a buffer when creating an attribute");t instanceof _t||(t instanceof Array&&(t=new Float32Array(t)),t=new _t(t));const h=e.split("|");if(h.length>1){for(let c=0;c<h.length;c++)this.addAttribute(h[c],t,i,r,s);return this}let u=this.buffers.indexOf(t);return u===-1&&(this.buffers.push(t),u=this.buffers.length-1),this.attributes[e]=new Fa(u,i,r,s,o,a,l),this.instanced=this.instanced||l,this}getAttribute(e){return this.attributes[e]}getBuffer(e){return this.buffers[this.getAttribute(e).buffer]}addIndex(e){return e instanceof _t||(e instanceof Array&&(e=new Uint16Array(e)),e=new _t(e)),e.type=tn.ELEMENT_ARRAY_BUFFER,this.indexBuffer=e,this.buffers.includes(e)||this.buffers.push(e),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const e=[],t=[],i=new _t;let r;for(r in this.attributes){const s=this.attributes[r],o=this.buffers[s.buffer];e.push(o.data),t.push(s.size*um[s.type]/4),s.buffer=0}for(i.data=pR(e,t),r=0;r<this.buffers.length;r++)this.buffers[r]!==this.indexBuffer&&this.buffers[r].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const e in this.attributes){const t=this.attributes[e];return this.buffers[t.buffer].data.length/(t.stride/4||t.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const e=new jn;for(let t=0;t<this.buffers.length;t++)e.buffers[t]=new _t(this.buffers[t].data.slice(0));for(const t in this.attributes){const i=this.attributes[t];e.attributes[t]=new Fa(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(e.indexBuffer=e.buffers[this.buffers.indexOf(this.indexBuffer)],e.indexBuffer.type=tn.ELEMENT_ARRAY_BUFFER),e}static merge(e){const t=new jn,i=[],r=[],s=[];let o;for(let a=0;a<e.length;a++){o=e[a];for(let l=0;l<o.buffers.length;l++)r[l]=r[l]||0,r[l]+=o.buffers[l].data.length,s[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new mR[tm(o.buffers[a].data)](r[a]),t.buffers[a]=new _t(i[a]);for(let a=0;a<e.length;a++){o=e[a];for(let l=0;l<o.buffers.length;l++)i[l].set(o.buffers[l].data,s[l]),s[l]+=o.buffers[l].data.length}if(t.attributes=o.attributes,o.indexBuffer){t.indexBuffer=t.buffers[o.buffers.indexOf(o.indexBuffer)],t.indexBuffer.type=tn.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,u=0;for(let c=0;c<o.buffers.length;c++)if(o.buffers[c]!==o.indexBuffer){u=c;break}for(const c in o.attributes){const d=o.attributes[c];(d.buffer|0)===u&&(l+=d.size*um[d.type]/4)}for(let c=0;c<e.length;c++){const d=e[c].indexBuffer.data;for(let f=0;f<d.length;f++)t.indexBuffer.data[f+h]+=a;a+=e[c].buffers[u].data.length/l,h+=d.length}}return t}}class cm extends jn{constructor(e=!1){super(),this._buffer=new _t(null,e,!1),this._indexBuffer=new _t(null,e,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,Se.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,Se.FLOAT).addAttribute("aColor",this._buffer,4,!0,Se.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,Se.FLOAT).addIndex(this._indexBuffer)}}const Na=Math.PI*2,vR=180/Math.PI,yR=Math.PI/180;var Gt=(n=>(n[n.POLY=0]="POLY",n[n.RECT=1]="RECT",n[n.CIRC=2]="CIRC",n[n.ELIP=3]="ELIP",n[n.RREC=4]="RREC",n))(Gt||{});class Ye{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new Ye(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}}Ye.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const ka=[new Ye,new Ye,new Ye,new Ye];class Ue{constructor(e=0,t=0,i=0,r=0){this.x=Number(e),this.y=Number(t),this.width=Number(i),this.height=Number(r),this.type=Gt.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new Ue(0,0,0,0)}clone(){return new Ue(this.x,this.y,this.width,this.height)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}intersects(e,t){if(!t){const O=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=O)return!1;const N=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>N}const i=this.left,r=this.right,s=this.top,o=this.bottom;if(r<=i||o<=s)return!1;const a=ka[0].set(e.left,e.top),l=ka[1].set(e.left,e.bottom),h=ka[2].set(e.right,e.top),u=ka[3].set(e.right,e.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(t.a*t.d-t.b*t.c);if(c===0||(t.apply(a,a),t.apply(l,l),t.apply(h,h),t.apply(u,u),Math.max(a.x,l.x,h.x,u.x)<=i||Math.min(a.x,l.x,h.x,u.x)>=r||Math.max(a.y,l.y,h.y,u.y)<=s||Math.min(a.y,l.y,h.y,u.y)>=o))return!1;const d=c*(l.y-a.y),f=c*(a.x-l.x),p=d*i+f*s,g=d*r+f*s,m=d*i+f*o,v=d*r+f*o;if(Math.max(p,g,m,v)<=d*a.x+f*a.y||Math.min(p,g,m,v)>=d*u.x+f*u.y)return!1;const _=c*(a.y-h.y),y=c*(h.x-a.x),w=_*i+y*s,R=_*r+y*s,M=_*i+y*o,C=_*r+y*o;return!(Math.max(w,R,M,C)<=_*a.x+y*a.y||Math.min(w,R,M,C)>=_*u.x+y*u.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),i=Math.min(this.x+this.width,e.x+e.width),r=Math.max(this.y,e.y),s=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(i-t,0),this.y=r,this.height=Math.max(s-r,0),this}ceil(e=1,t=.001){const i=Math.ceil((this.x+this.width-t)*e)/e,r=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=i-this.x,this.height=r-this.y,this}enlarge(e){const t=Math.min(this.x,e.x),i=Math.max(this.x+this.width,e.x+e.width),r=Math.min(this.y,e.y),s=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=i-t,this.y=r,this.height=s-r,this}}Ue.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ua{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.radius=i,this.type=Gt.CIRC}clone(){return new Ua(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-e,s=this.y-t;return r*=r,s*=s,r+s<=i}getBounds(){return new Ue(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Ua.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Ha{constructor(e=0,t=0,i=0,r=0){this.x=e,this.y=t,this.width=i,this.height=r,this.type=Gt.ELIP}clone(){return new Ha(this.x,this.y,this.width,this.height)}contains(e,t){if(this.width<=0||this.height<=0)return!1;let i=(e-this.x)/this.width,r=(t-this.y)/this.height;return i*=i,r*=r,i+r<=1}getBounds(){return new Ue(this.x-this.width,this.y-this.height,this.width,this.height)}}Ha.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Er{constructor(...e){let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const i=[];for(let r=0,s=t.length;r<s;r++)i.push(t[r].x,t[r].y);t=i}this.points=t,this.type=Gt.POLY,this.closeStroke=!0}clone(){const e=this.points.slice(),t=new Er(e);return t.closeStroke=this.closeStroke,t}contains(e,t){let i=!1;const r=this.points.length/2;for(let s=0,o=r-1;s<r;o=s++){const a=this.points[s*2],l=this.points[s*2+1],h=this.points[o*2],u=this.points[o*2+1];l>t!=u>t&&e<(h-a)*((t-l)/(u-l))+a&&(i=!i)}return i}}Er.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((n,e)=>`${n}, ${e}`,"")}]`};class za{constructor(e=0,t=0,i=0,r=0,s=20){this.x=e,this.y=t,this.width=i,this.height=r,this.radius=s,this.type=Gt.RREC}clone(){return new za(this.x,this.y,this.width,this.height,this.radius)}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+i&&t<=this.y+this.height-i||e>=this.x+i&&e<=this.x+this.width-i)return!0;let r=e-(this.x+i),s=t-(this.y+i);const o=i*i;if(r*r+s*s<=o||(r=e-(this.x+this.width-i),r*r+s*s<=o)||(s=t-(this.y+this.height-i),r*r+s*s<=o)||(r=e-(this.x+i),r*r+s*s<=o))return!0}return!1}}za.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class at{constructor(e=1,t=0,i=0,r=1,s=0,o=0){this.array=null,this.a=e,this.b=t,this.c=i,this.d=r,this.tx=s,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,i,r,s,o){return this.a=e,this.b=t,this.c=i,this.d=r,this.tx=s,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const i=t||this.array;return e?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(e,t){t=t||new Ye;const i=e.x,r=e.y;return t.x=this.a*i+this.c*r+this.tx,t.y=this.b*i+this.d*r+this.ty,t}applyInverse(e,t){t=t||new Ye;const i=1/(this.a*this.d+this.c*-this.b),r=e.x,s=e.y;return t.x=this.d*i*r+-this.c*i*s+(this.ty*this.c-this.tx*this.d)*i,t.y=this.a*i*s+-this.b*i*r+(-this.ty*this.a+this.tx*this.b)*i,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),r=this.a,s=this.c,o=this.tx;return this.a=r*t-this.b*i,this.b=r*i+this.b*t,this.c=s*t-this.d*i,this.d=s*i+this.d*t,this.tx=o*t-this.ty*i,this.ty=o*i+this.ty*t,this}append(e){const t=this.a,i=this.b,r=this.c,s=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*i+e.b*s,this.c=e.c*t+e.d*r,this.d=e.c*i+e.d*s,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*i+e.ty*s+this.ty,this}setTransform(e,t,i,r,s,o,a,l,h){return this.a=Math.cos(a+h)*s,this.b=Math.sin(a+h)*s,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=e-(i*this.a+r*this.c),this.ty=t-(i*this.b+r*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const i=this.a,r=this.c;this.a=i*e.a+this.b*e.c,this.b=i*e.b+this.b*e.d,this.c=r*e.a+this.d*e.c,this.d=r*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,i=this.b,r=this.c,s=this.d,o=e.pivot,a=-Math.atan2(-r,s),l=Math.atan2(i,t),h=Math.abs(a+l);return h<1e-5||Math.abs(Na-h)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=a,e.skew.y=l),e.scale.x=Math.sqrt(t*t+i*i),e.scale.y=Math.sqrt(r*r+s*s),e.position.x=this.tx+(o.x*t+o.y*r),e.position.y=this.ty+(o.x*i+o.y*s),e}invert(){const e=this.a,t=this.b,i=this.c,r=this.d,s=this.tx,o=e*r-t*i;return this.a=r/o,this.b=-t/o,this.c=-i/o,this.d=e/o,this.tx=(i*this.ty-r*s)/o,this.ty=-(e*this.ty-t*s)/o,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new at;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}static get IDENTITY(){return new at}static get TEMP_MATRIX(){return new at}}at.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const br=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Sr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ar=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Rr=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Nu=[],dm=[],Ga=Math.sign;function _R(){for(let n=0;n<16;n++){const e=[];Nu.push(e);for(let t=0;t<16;t++){const i=Ga(br[n]*br[t]+Ar[n]*Sr[t]),r=Ga(Sr[n]*br[t]+Rr[n]*Sr[t]),s=Ga(br[n]*Ar[t]+Ar[n]*Rr[t]),o=Ga(Sr[n]*Ar[t]+Rr[n]*Rr[t]);for(let a=0;a<16;a++)if(br[a]===i&&Sr[a]===r&&Ar[a]===s&&Rr[a]===o){e.push(a);break}}}for(let n=0;n<16;n++){const e=new at;e.set(br[n],Sr[n],Ar[n],Rr[n],0,0),dm.push(e)}}_R();const pt={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:n=>br[n],uY:n=>Sr[n],vX:n=>Ar[n],vY:n=>Rr[n],inv:n=>n&8?n&15:-n&7,add:(n,e)=>Nu[n][e],sub:(n,e)=>Nu[n][pt.inv(e)],rotate180:n=>n^4,isVertical:n=>(n&3)===2,byDirection:(n,e)=>Math.abs(n)*2<=Math.abs(e)?e>=0?pt.S:pt.N:Math.abs(e)*2<=Math.abs(n)?n>0?pt.E:pt.W:e>0?n>0?pt.SE:pt.SW:n>0?pt.NE:pt.NW,matrixAppendRotationInv:(n,e,t=0,i=0)=>{const r=dm[pt.inv(e)];r.tx=t,r.ty=i,n.append(r)}};class Sn{constructor(e,t,i=0,r=0){this._x=i,this._y=r,this.cb=e,this.scope=t}clone(e=this.cb,t=this.scope){return new Sn(e,t,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this.cb.call(this.scope)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this.cb.call(this.scope)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this.cb.call(this.scope))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this.cb.call(this.scope))}}Sn.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const ku=class{constructor(){this.worldTransform=new at,this.localTransform=new at,this.position=new Sn(this.onChange,this,0,0),this.scale=new Sn(this.onChange,this,1,1),this.pivot=new Sn(this.onChange,this,0,0),this.skew=new Sn(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const n=this.localTransform;this._localID!==this._currentLocalID&&(n.a=this._cx*this.scale.x,n.b=this._sx*this.scale.x,n.c=this._cy*this.scale.y,n.d=this._sy*this.scale.y,n.tx=this.position.x-(this.pivot.x*n.a+this.pivot.y*n.c),n.ty=this.position.y-(this.pivot.x*n.b+this.pivot.y*n.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(n){const e=this.localTransform;if(this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==n._worldID){const t=n.worldTransform,i=this.worldTransform;i.a=e.a*t.a+e.b*t.c,i.b=e.a*t.b+e.b*t.d,i.c=e.c*t.a+e.d*t.c,i.d=e.c*t.b+e.d*t.d,i.tx=e.tx*t.a+e.ty*t.c+t.tx,i.ty=e.tx*t.b+e.ty*t.d+t.ty,this._parentID=n._worldID,this._worldID++}}setFromMatrix(n){n.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(n){this._rotation!==n&&(this._rotation=n,this.updateSkew())}};ku.IDENTITY=new ku;let Uu=ku;Uu.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var xR=`varying vec2 vTextureCoord;
139
+
140
+ uniform sampler2D uSampler;
141
+
142
+ void main(void){
143
+ gl_FragColor *= texture2D(uSampler, vTextureCoord);
144
+ }`,wR=`attribute vec2 aVertexPosition;
145
+ attribute vec2 aTextureCoord;
146
+
147
+ uniform mat3 projectionMatrix;
148
+
149
+ varying vec2 vTextureCoord;
150
+
151
+ void main(void){
152
+ gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
153
+ vTextureCoord = aTextureCoord;
154
+ }
155
+ `;function fm(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function Hu(n){const e=new Array(n);for(let t=0;t<e.length;t++)e[t]=!1;return e}function pm(n,e){switch(n){case"float":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return Hu(2*e);case"bvec3":return Hu(3*e);case"bvec4":return Hu(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const _s=[{test:n=>n.type==="float"&&n.size===1&&!n.isArray,code:n=>`
156
+ if(uv["${n}"] !== ud["${n}"].value)
157
+ {
158
+ ud["${n}"].value = uv["${n}"]
159
+ gl.uniform1f(ud["${n}"].location, uv["${n}"])
160
+ }
161
+ `},{test:(n,e)=>(n.type==="sampler2D"||n.type==="samplerCube"||n.type==="sampler2DArray")&&n.size===1&&!n.isArray&&(e==null||e.castToBaseTexture!==void 0),code:n=>`t = syncData.textureCount++;
162
+
163
+ renderer.texture.bind(uv["${n}"], t);
164
+
165
+ if(ud["${n}"].value !== t)
166
+ {
167
+ ud["${n}"].value = t;
168
+ gl.uniform1i(ud["${n}"].location, t);
169
+ ; // eslint-disable-line max-len
170
+ }`},{test:(n,e)=>n.type==="mat3"&&n.size===1&&!n.isArray&&e.a!==void 0,code:n=>`
171
+ gl.uniformMatrix3fv(ud["${n}"].location, false, uv["${n}"].toArray(true));
172
+ `,codeUbo:n=>`
173
+ var ${n}_matrix = uv.${n}.toArray(true);
174
+
175
+ data[offset] = ${n}_matrix[0];
176
+ data[offset+1] = ${n}_matrix[1];
177
+ data[offset+2] = ${n}_matrix[2];
178
+
179
+ data[offset + 4] = ${n}_matrix[3];
180
+ data[offset + 5] = ${n}_matrix[4];
181
+ data[offset + 6] = ${n}_matrix[5];
182
+
183
+ data[offset + 8] = ${n}_matrix[6];
184
+ data[offset + 9] = ${n}_matrix[7];
185
+ data[offset + 10] = ${n}_matrix[8];
186
+ `},{test:(n,e)=>n.type==="vec2"&&n.size===1&&!n.isArray&&e.x!==void 0,code:n=>`
187
+ cv = ud["${n}"].value;
188
+ v = uv["${n}"];
189
+
190
+ if(cv[0] !== v.x || cv[1] !== v.y)
191
+ {
192
+ cv[0] = v.x;
193
+ cv[1] = v.y;
194
+ gl.uniform2f(ud["${n}"].location, v.x, v.y);
195
+ }`,codeUbo:n=>`
196
+ v = uv.${n};
197
+
198
+ data[offset] = v.x;
199
+ data[offset+1] = v.y;
200
+ `},{test:n=>n.type==="vec2"&&n.size===1&&!n.isArray,code:n=>`
201
+ cv = ud["${n}"].value;
202
+ v = uv["${n}"];
203
+
204
+ if(cv[0] !== v[0] || cv[1] !== v[1])
205
+ {
206
+ cv[0] = v[0];
207
+ cv[1] = v[1];
208
+ gl.uniform2f(ud["${n}"].location, v[0], v[1]);
209
+ }
210
+ `},{test:(n,e)=>n.type==="vec4"&&n.size===1&&!n.isArray&&e.width!==void 0,code:n=>`
211
+ cv = ud["${n}"].value;
212
+ v = uv["${n}"];
213
+
214
+ if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)
215
+ {
216
+ cv[0] = v.x;
217
+ cv[1] = v.y;
218
+ cv[2] = v.width;
219
+ cv[3] = v.height;
220
+ gl.uniform4f(ud["${n}"].location, v.x, v.y, v.width, v.height)
221
+ }`,codeUbo:n=>`
222
+ v = uv.${n};
223
+
224
+ data[offset] = v.x;
225
+ data[offset+1] = v.y;
226
+ data[offset+2] = v.width;
227
+ data[offset+3] = v.height;
228
+ `},{test:(n,e)=>n.type==="vec4"&&n.size===1&&!n.isArray&&e.red!==void 0,code:n=>`
229
+ cv = ud["${n}"].value;
230
+ v = uv["${n}"];
231
+
232
+ if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)
233
+ {
234
+ cv[0] = v.red;
235
+ cv[1] = v.green;
236
+ cv[2] = v.blue;
237
+ cv[3] = v.alpha;
238
+ gl.uniform4f(ud["${n}"].location, v.red, v.green, v.blue, v.alpha)
239
+ }`,codeUbo:n=>`
240
+ v = uv.${n};
241
+
242
+ data[offset] = v.red;
243
+ data[offset+1] = v.green;
244
+ data[offset+2] = v.blue;
245
+ data[offset+3] = v.alpha;
246
+ `},{test:(n,e)=>n.type==="vec3"&&n.size===1&&!n.isArray&&e.red!==void 0,code:n=>`
247
+ cv = ud["${n}"].value;
248
+ v = uv["${n}"];
249
+
250
+ if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)
251
+ {
252
+ cv[0] = v.red;
253
+ cv[1] = v.green;
254
+ cv[2] = v.blue;
255
+
256
+ gl.uniform3f(ud["${n}"].location, v.red, v.green, v.blue)
257
+ }`,codeUbo:n=>`
258
+ v = uv.${n};
259
+
260
+ data[offset] = v.red;
261
+ data[offset+1] = v.green;
262
+ data[offset+2] = v.blue;
263
+ `},{test:n=>n.type==="vec4"&&n.size===1&&!n.isArray,code:n=>`
264
+ cv = ud["${n}"].value;
265
+ v = uv["${n}"];
266
+
267
+ if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
268
+ {
269
+ cv[0] = v[0];
270
+ cv[1] = v[1];
271
+ cv[2] = v[2];
272
+ cv[3] = v[3];
273
+
274
+ gl.uniform4f(ud["${n}"].location, v[0], v[1], v[2], v[3])
275
+ }`}],TR={float:`
276
+ if (cv !== v)
277
+ {
278
+ cu.value = v;
279
+ gl.uniform1f(location, v);
280
+ }`,vec2:`
281
+ if (cv[0] !== v[0] || cv[1] !== v[1])
282
+ {
283
+ cv[0] = v[0];
284
+ cv[1] = v[1];
285
+
286
+ gl.uniform2f(location, v[0], v[1])
287
+ }`,vec3:`
288
+ if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
289
+ {
290
+ cv[0] = v[0];
291
+ cv[1] = v[1];
292
+ cv[2] = v[2];
293
+
294
+ gl.uniform3f(location, v[0], v[1], v[2])
295
+ }`,vec4:`
296
+ if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
297
+ {
298
+ cv[0] = v[0];
299
+ cv[1] = v[1];
300
+ cv[2] = v[2];
301
+ cv[3] = v[3];
302
+
303
+ gl.uniform4f(location, v[0], v[1], v[2], v[3]);
304
+ }`,int:`
305
+ if (cv !== v)
306
+ {
307
+ cu.value = v;
308
+
309
+ gl.uniform1i(location, v);
310
+ }`,ivec2:`
311
+ if (cv[0] !== v[0] || cv[1] !== v[1])
312
+ {
313
+ cv[0] = v[0];
314
+ cv[1] = v[1];
315
+
316
+ gl.uniform2i(location, v[0], v[1]);
317
+ }`,ivec3:`
318
+ if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
319
+ {
320
+ cv[0] = v[0];
321
+ cv[1] = v[1];
322
+ cv[2] = v[2];
323
+
324
+ gl.uniform3i(location, v[0], v[1], v[2]);
325
+ }`,ivec4:`
326
+ if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
327
+ {
328
+ cv[0] = v[0];
329
+ cv[1] = v[1];
330
+ cv[2] = v[2];
331
+ cv[3] = v[3];
332
+
333
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
334
+ }`,uint:`
335
+ if (cv !== v)
336
+ {
337
+ cu.value = v;
338
+
339
+ gl.uniform1ui(location, v);
340
+ }`,uvec2:`
341
+ if (cv[0] !== v[0] || cv[1] !== v[1])
342
+ {
343
+ cv[0] = v[0];
344
+ cv[1] = v[1];
345
+
346
+ gl.uniform2ui(location, v[0], v[1]);
347
+ }`,uvec3:`
348
+ if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
349
+ {
350
+ cv[0] = v[0];
351
+ cv[1] = v[1];
352
+ cv[2] = v[2];
353
+
354
+ gl.uniform3ui(location, v[0], v[1], v[2]);
355
+ }`,uvec4:`
356
+ if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
357
+ {
358
+ cv[0] = v[0];
359
+ cv[1] = v[1];
360
+ cv[2] = v[2];
361
+ cv[3] = v[3];
362
+
363
+ gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
364
+ }`,bool:`
365
+ if (cv !== v)
366
+ {
367
+ cu.value = v;
368
+ gl.uniform1i(location, v);
369
+ }`,bvec2:`
370
+ if (cv[0] != v[0] || cv[1] != v[1])
371
+ {
372
+ cv[0] = v[0];
373
+ cv[1] = v[1];
374
+
375
+ gl.uniform2i(location, v[0], v[1]);
376
+ }`,bvec3:`
377
+ if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
378
+ {
379
+ cv[0] = v[0];
380
+ cv[1] = v[1];
381
+ cv[2] = v[2];
382
+
383
+ gl.uniform3i(location, v[0], v[1], v[2]);
384
+ }`,bvec4:`
385
+ if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
386
+ {
387
+ cv[0] = v[0];
388
+ cv[1] = v[1];
389
+ cv[2] = v[2];
390
+ cv[3] = v[3];
391
+
392
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
393
+ }`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:`
394
+ if (cv !== v)
395
+ {
396
+ cu.value = v;
397
+
398
+ gl.uniform1i(location, v);
399
+ }`,samplerCube:`
400
+ if (cv !== v)
401
+ {
402
+ cu.value = v;
403
+
404
+ gl.uniform1i(location, v);
405
+ }`,sampler2DArray:`
406
+ if (cv !== v)
407
+ {
408
+ cu.value = v;
409
+
410
+ gl.uniform1i(location, v);
411
+ }`},ER={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function bR(n,e){var t;const i=[`
412
+ var v = null;
413
+ var cv = null;
414
+ var cu = null;
415
+ var t = 0;
416
+ var gl = renderer.gl;
417
+ `];for(const r in n.uniforms){const s=e[r];if(!s){((t=n.uniforms[r])==null?void 0:t.group)===!0&&(n.uniforms[r].ubo?i.push(`
418
+ renderer.shader.syncUniformBufferGroup(uv.${r}, '${r}');
419
+ `):i.push(`
420
+ renderer.shader.syncUniformGroup(uv.${r}, syncData);
421
+ `));continue}const o=n.uniforms[r];let a=!1;for(let l=0;l<_s.length;l++)if(_s[l].test(s,o)){i.push(_s[l].code(r,o)),a=!0;break}if(!a){const l=(s.size===1&&!s.isArray?TR:ER)[s.type].replace("location",`ud["${r}"].location`);i.push(`
422
+ cu = ud["${r}"];
423
+ cv = cu.value;
424
+ v = uv["${r}"];
425
+ ${l};`)}}return new Function("ud","uv","renderer","syncData",i.join(`
426
+ `))}const gm={};let xo=gm;function SR(){if(xo===gm||xo!=null&&xo.isContextLost()){const n=de.ADAPTER.createCanvas();let e;de.PREFER_ENV>=_r.WEBGL2&&(e=n.getContext("webgl2",{})),e||(e=n.getContext("webgl",{})||n.getContext("experimental-webgl",{}),e?e.getExtension("WEBGL_draw_buffers"):e=null),xo=e}return xo}let Va;function AR(){if(!Va){Va=Ai.MEDIUM;const n=SR();if(n&&n.getShaderPrecisionFormat){const e=n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT);e&&(Va=e.precision?Ai.HIGH:Ai.MEDIUM)}}return Va}function mm(n,e){const t=n.getShaderSource(e).split(`
427
+ `).map((h,u)=>`${u}: ${h}`),i=n.getShaderInfoLog(e),r=i.split(`
428
+ `),s={},o=r.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!s[h]?(s[h]=!0,!0):!1),a=[""];o.forEach(h=>{t[h-1]=`%c${t[h-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=t.join(`
429
+ `);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function RR(n,e,t,i){n.getProgramParameter(e,n.LINK_STATUS)||(n.getShaderParameter(t,n.COMPILE_STATUS)||mm(n,t),n.getShaderParameter(i,n.COMPILE_STATUS)||mm(n,i),console.error("PixiJS Error: Could not initialize shader."),n.getProgramInfoLog(e)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",n.getProgramInfoLog(e)))}const CR={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function vm(n){return CR[n]}let Wa=null;const ym={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function _m(n,e){if(!Wa){const t=Object.keys(ym);Wa={};for(let i=0;i<t.length;++i){const r=t[i];Wa[n[r]]=ym[r]}}return Wa[e]}function xm(n,e,t){if(n.substring(0,9)!=="precision"){let i=e;return e===Ai.HIGH&&t!==Ai.HIGH&&(i=Ai.MEDIUM),`precision ${i} float;
430
+ ${n}`}else if(t!==Ai.HIGH&&n.substring(0,15)==="precision highp")return n.replace("precision highp","precision mediump");return n}let wo;function PR(){if(typeof wo=="boolean")return wo;try{wo=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{wo=!1}return wo}let IR=0;const ja={},zu=class Os{constructor(e,t,i="pixi-shader",r={}){this.extra={},this.id=IR++,this.vertexSrc=e||Os.defaultVertexSrc,this.fragmentSrc=t||Os.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=r,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),ja[i]?(ja[i]++,i+=`-${ja[i]}`):ja[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
431
+ ${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
432
+ ${this.fragmentSrc}`,this.vertexSrc=xm(this.vertexSrc,Os.defaultVertexPrecision,Ai.HIGH),this.fragmentSrc=xm(this.fragmentSrc,Os.defaultFragmentPrecision,AR())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return wR}static get defaultFragmentSrc(){return xR}static from(e,t,i){const r=e+t;let s=sm[r];return s||(sm[r]=s=new Os(e,t,i)),s}};zu.defaultVertexPrecision=Ai.HIGH,zu.defaultFragmentPrecision=Tn.apple.device?Ai.HIGH:Ai.MEDIUM;let An=zu,DR=0;class Ni{constructor(e,t,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=DR++,this.static=!!t,this.ubo=!!i,e instanceof _t?(this.buffer=e,this.buffer.type=tn.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=e,this.ubo&&(this.buffer=new _t(new Float32Array(1)),this.buffer.type=tn.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(e,t,i){if(!this.ubo)this.uniforms[e]=new Ni(t,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(e,t,i){return new Ni(e,t,i)}static uboFrom(e,t){return new Ni(e,t??!0,!0)}}class on{constructor(e,t){this.uniformBindCount=0,this.program=e,t?t instanceof Ni?this.uniformGroup=t:this.uniformGroup=new Ni(t):this.uniformGroup=new Ni({}),this.disposeRunner=new Fi("disposeShader")}checkUniformExists(e,t){if(t.uniforms[e])return!0;for(const i in t.uniforms){const r=t.uniforms[i];if(r.group===!0&&this.checkUniformExists(e,r))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(e,t,i){const r=An.from(e,t);return new on(r,i)}}class MR{constructor(e,t){if(this.vertexSrc=e,this.fragTemplate=t,this.programCache={},this.defaultGroupCache={},!t.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!t.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(e){if(!this.programCache[e]){const i=new Int32Array(e);for(let s=0;s<e;s++)i[s]=s;this.defaultGroupCache[e]=Ni.from({uSamplers:i},!0);let r=this.fragTemplate;r=r.replace(/%count%/gi,`${e}`),r=r.replace(/%forloop%/gi,this.generateSampleSrc(e)),this.programCache[e]=new An(this.vertexSrc,r)}const t={tint:new Float32Array([1,1,1,1]),translationMatrix:new at,default:this.defaultGroupCache[e]};return new on(this.programCache[e],t)}generateSampleSrc(e){let t="";t+=`
433
+ `,t+=`
434
+ `;for(let i=0;i<e;i++)i>0&&(t+=`
435
+ else `),i<e-1&&(t+=`if(vTextureId < ${i}.5)`),t+=`
436
+ {`,t+=`
437
+ color = texture2D(uSamplers[${i}], vTextureCoord);`,t+=`
438
+ }`;return t+=`
439
+ `,t+=`
440
+ `,t}}class Gu{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let e=0;e<this.count;e++)this.elements[e]=null;this.count=0}}function OR(){return!Tn.apple.device}function LR(n){let e=!0;const t=de.ADAPTER.getNavigator();if(Tn.tablet||Tn.phone){if(Tn.apple.device){const i=t.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(e=!1)}if(Tn.android.device){const i=t.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(e=!1)}}return e?n:4}class Xa{constructor(e){this.renderer=e}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(e){}}var BR=`varying vec2 vTextureCoord;
441
+ varying vec4 vColor;
442
+ varying float vTextureId;
443
+ uniform sampler2D uSamplers[%count%];
444
+
445
+ void main(void){
446
+ vec4 color;
447
+ %forloop%
448
+ gl_FragColor = color * vColor;
449
+ }
450
+ `,FR=`precision highp float;
451
+ attribute vec2 aVertexPosition;
452
+ attribute vec2 aTextureCoord;
453
+ attribute vec4 aColor;
454
+ attribute float aTextureId;
455
+
456
+ uniform mat3 projectionMatrix;
457
+ uniform mat3 translationMatrix;
458
+ uniform vec4 tint;
459
+
460
+ varying vec2 vTextureCoord;
461
+ varying vec4 vColor;
462
+ varying float vTextureId;
463
+
464
+ void main(void){
465
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
466
+
467
+ vTextureCoord = aTextureCoord;
468
+ vTextureId = aTextureId;
469
+ vColor = aColor * tint;
470
+ }
471
+ `;const To=class Vi extends Xa{constructor(e){super(e),this.setShaderGenerator(),this.geometryClass=cm,this.vertexSize=6,this.state=sn.for2d(),this.size=Vi.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),e.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??LR(32),this._defaultMaxTextures}static set defaultMaxTextures(e){this._defaultMaxTextures=e}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??OR(),this._canUploadSameBuffer}static set canUploadSameBuffer(e){this._canUploadSameBuffer=e}get MAX_TEXTURES(){return We("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return FR}static get defaultFragmentTemplate(){return BR}setShaderGenerator({vertex:e=Vi.defaultVertexSrc,fragment:t=Vi.defaultFragmentTemplate}={}){this.shaderGenerator=new MR(e,t)}contextChange(){const e=this.renderer.gl;de.PREFER_ENV===_r.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),Vi.defaultMaxTextures),this.maxTextures=uR(this.maxTextures,e)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:e,_textureArrayPool:t}=Vi,i=this.size/4,r=Math.floor(i/this.maxTextures)+1;for(;e.length<i;)e.push(new Fu);for(;t.length<r;)t.push(new Gu);for(let s=0;s<this.maxTextures;s++)this._tempBoundTextures[s]=null}onPrerender(){this._flushId=0}render(e){e._texture.valid&&(this._vertexCount+e.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=e.vertexData.length/2,this._indexCount+=e.indices.length,this._bufferedTextures[this._bufferSize]=e._texture.baseTexture,this._bufferedElements[this._bufferSize++]=e)}buildTexturesAndDrawCalls(){const{_bufferedTextures:e,maxTextures:t}=this,i=Vi._textureArrayPool,r=this.renderer.batch,s=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++Fe._globalBatch,l=0,h=i[0],u=0;r.copyBoundTextures(s,t);for(let c=0;c<this._bufferSize;++c){const d=e[c];e[c]=null,d._batchEnabled!==a&&(h.count>=t&&(r.boundArray(h,s,a,t),this.buildDrawCalls(h,u,c),u=c,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(r.boundArray(h,s,a,t),this.buildDrawCalls(h,u,this._bufferSize),++l,++a);for(let c=0;c<s.length;c++)s[c]=null;Fe._globalBatch=a}buildDrawCalls(e,t,i){const{_bufferedElements:r,_attributeBuffer:s,_indexBuffer:o,vertexSize:a}=this,l=Vi._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=e;for(let f=t;f<i;++f){const p=r[f],g=p._texture.baseTexture,m=$g[g.alphaMode?1:0][p.blendMode];r[f]=null,t<f&&d.blend!==m&&(d.size=c-d.start,t=f,d=l[++h],d.texArray=e,d.start=c),this.packInterleavedGeometry(p,s,o,u,c),u+=p.vertexData.length/2*a,c+=p.indices.length,d.blend=m}t<i&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(e){const t=this.renderer.texture;for(let i=0;i<e.count;i++)t.bind(e.elements[i],e.ids[i]),e.elements[i]=null;e.count=0}updateGeometry(){const{_packedGeometries:e,_attributeBuffer:t,_indexBuffer:i}=this;Vi.canUploadSameBuffer?(e[this._flushId]._buffer.update(t.rawBinaryData),e[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,e[this._flushId]=new this.geometryClass),e[this._flushId]._buffer.update(t.rawBinaryData),e[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(e[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const e=this._dcIndex,{gl:t,state:i}=this.renderer,r=Vi._drawCallPool;let s=null;for(let o=0;o<e;o++){const{texArray:a,type:l,size:h,start:u,blend:c}=r[o];s!==a&&(s=a,this.bindAndClearTexArray(a)),this.state.blendMode=c,i.set(this.state),t.drawElements(l,h,t.UNSIGNED_SHORT,u*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),Vi.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]&&this._packedGeometries[e].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(e){const t=La(Math.ceil(e/8)),i=nm(t),r=t*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._aBuffers[r];return s||(this._aBuffers[r]=s=new Ru(r*this.vertexSize*4)),s}getIndexBuffer(e){const t=La(Math.ceil(e/12)),i=nm(t),r=t*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._iBuffers[i];return s||(this._iBuffers[i]=s=new Uint16Array(r)),s}packInterleavedGeometry(e,t,i,r,s){const{uint32View:o,float32View:a}=t,l=r/this.vertexSize,h=e.uvs,u=e.indices,c=e.vertexData,d=e._texture.baseTexture._batchLocation,f=Math.min(e.worldAlpha,1),p=nt.shared.setValue(e._tintRGB).toPremultiplied(f,e._texture.baseTexture.alphaMode>0);for(let g=0;g<c.length;g+=2)a[r++]=c[g],a[r++]=c[g+1],a[r++]=h[g],a[r++]=h[g+1],o[r++]=p,a[r++]=d;for(let g=0;g<u.length;g++)i[s++]=l+u[g]}};To.defaultBatchSize=4096,To.extension={name:"batch",type:ue.RendererPlugin},To._drawCallPool=[],To._textureArrayPool=[];let Cr=To;Te.add(Cr);var NR=`varying vec2 vTextureCoord;
472
+
473
+ uniform sampler2D uSampler;
474
+
475
+ void main(void){
476
+ gl_FragColor = texture2D(uSampler, vTextureCoord);
477
+ }
478
+ `,kR=`attribute vec2 aVertexPosition;
479
+
480
+ uniform mat3 projectionMatrix;
481
+
482
+ varying vec2 vTextureCoord;
483
+
484
+ uniform vec4 inputSize;
485
+ uniform vec4 outputFrame;
486
+
487
+ vec4 filterVertexPosition( void )
488
+ {
489
+ vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
490
+
491
+ return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
492
+ }
493
+
494
+ vec2 filterTextureCoord( void )
495
+ {
496
+ return aVertexPosition * (outputFrame.zw * inputSize.zw);
497
+ }
498
+
499
+ void main(void)
500
+ {
501
+ gl_Position = filterVertexPosition();
502
+ vTextureCoord = filterTextureCoord();
503
+ }
504
+ `;const Vu=class Po extends on{constructor(e,t,i){const r=An.from(e||Po.defaultVertexSrc,t||Po.defaultFragmentSrc);super(r,i),this.padding=0,this.resolution=Po.defaultResolution,this.multisample=Po.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new sn}apply(e,t,i,r,s){e.applyFilter(this,t,i,r)}get blendMode(){return this.state.blendMode}set blendMode(e){this.state.blendMode=e}get resolution(){return this._resolution}set resolution(e){this._resolution=e}static get defaultVertexSrc(){return kR}static get defaultFragmentSrc(){return NR}};Vu.defaultResolution=1,Vu.defaultMultisample=Tt.NONE;let ni=Vu;class Ya{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new nt(0),this.alpha=1}init(e){this.clearBeforeRender=e.clearBeforeRender;const{backgroundColor:t,background:i,backgroundAlpha:r}=e,s=i??t;s!==void 0&&(this.color=s),this.alpha=r}get color(){return this._backgroundColor.value}set color(e){this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get backgroundColor(){return this._backgroundColor}destroy(){}}Ya.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Ya.extension={type:[ue.RendererSystem,ue.CanvasRendererSystem],name:"background"},Te.add(Ya);class wm{constructor(e){this.renderer=e,this.emptyRenderer=new Xa(e),this.currentRenderer=this.emptyRenderer}setObjectRenderer(e){this.currentRenderer!==e&&(this.currentRenderer.stop(),this.currentRenderer=e,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(e,t){const{boundTextures:i}=this.renderer.texture;for(let r=t-1;r>=0;--r)e[r]=i[r]||null,e[r]&&(e[r]._batchLocation=r)}boundArray(e,t,i,r){const{elements:s,ids:o,count:a}=e;let l=0;for(let h=0;h<a;h++){const u=s[h],c=u._batchLocation;if(c>=0&&c<r&&t[c]===u){o[h]=c;continue}for(;l<r;){const d=t[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,u._batchLocation=l,t[l]=u;break}}}destroy(){this.renderer=null}}wm.extension={type:ue.RendererSystem,name:"batch"},Te.add(wm);let Tm=0;class qa{constructor(e){this.renderer=e,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this.renderer.gl=e,this.renderer.CONTEXT_UID=Tm++}init(e){if(e.context)this.initFromContext(e.context);else{const t=this.renderer.background.alpha<1,i=e.premultipliedAlpha;this.preserveDrawingBuffer=e.preserveDrawingBuffer,this.useContextAlpha=e.useContextAlpha,this.powerPreference=e.powerPreference,this.initFromOptions({alpha:t,premultipliedAlpha:i,antialias:e.antialias,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference})}}initFromContext(e){this.gl=e,this.validateContext(e),this.renderer.gl=e,this.renderer.CONTEXT_UID=Tm++,this.renderer.runners.contextChange.emit(e);const t=this.renderer.view;t.addEventListener!==void 0&&(t.addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(e){const t=this.createContext(this.renderer.view,e);this.initFromContext(t)}createContext(e,t){let i;if(de.PREFER_ENV>=_r.WEBGL2&&(i=e.getContext("webgl2",t)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:e}=this,t={loseContext:e.getExtension("WEBGL_lose_context"),anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,t,{drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,t,{colorBufferFloat:e.getExtension("EXT_color_buffer_float")})}handleContextLost(e){e.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this.renderer.view;this.renderer=null,e.removeEventListener!==void 0&&(e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(e){const t=e.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&e instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),t&&!t.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=i||!!e.getExtension("OES_element_index_uint");this.supports.uint32Indices=r,r||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}qa.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},qa.extension={type:ue.RendererSystem,name:"context"},Te.add(qa);class Wu{constructor(e,t){if(this.width=Math.round(e),this.height=Math.round(t),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Fi("disposeFramebuffer"),this.multisample=Tt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(e=0,t){return this.colorTextures[e]=t||new Fe(null,{scaleMode:xn.NEAREST,resolution:1,mipmap:$i.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(e){return this.depthTexture=e||new Fe(null,{scaleMode:xn.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:$i.OFF,format:re.DEPTH_COMPONENT,type:Se.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(e,t){if(e=Math.round(e),t=Math.round(t),!e||!t)throw new Error("Framebuffer width and height must not be zero");if(!(e===this.width&&t===this.height)){this.width=e,this.height=t,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const r=this.colorTextures[i],s=r.resolution;r.setSize(e/s,t/s)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(e/i,t/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Em extends Fe{constructor(e={}){if(typeof e=="number"){const t=arguments[0],i=arguments[1],r=arguments[2],s=arguments[3];e={width:t,height:i,scaleMode:r,resolution:s}}e.width=e.width??100,e.height=e.height??100,e.multisample??(e.multisample=Tt.NONE),super(null,e),this.mipmap=$i.OFF,this.valid=!0,this._clear=new nt([0,0,0,0]),this.framebuffer=new Wu(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=e.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(e){this._clear.setValue(e)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(e){this.framebuffer.multisample=e}resize(e,t){this.framebuffer.resize(e*this.resolution,t*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Rn extends _o{constructor(e){const t=e,i=t.naturalWidth||t.videoWidth||t.displayWidth||t.width,r=t.naturalHeight||t.videoHeight||t.displayHeight||t.height;super(i,r),this.source=e,this.noSubImage=!1}static crossOrigin(e,t,i){i===void 0&&!t.startsWith("data:")?e.crossOrigin=aR(t):i!==!1&&(e.crossOrigin=typeof i=="string"?i:"anonymous")}upload(e,t,i,r){const s=e.gl,o=t.realWidth,a=t.realHeight;if(r=r||this.source,typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement){if(!r.complete||r.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement&&r.readyState<=1)return!1;return s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===li.UNPACK),!this.noSubImage&&t.target===s.TEXTURE_2D&&i.width===o&&i.height===a?s.texSubImage2D(s.TEXTURE_2D,0,0,0,t.format,i.type,r):(i.width=o,i.height=a,s.texImage2D(t.target,0,i.internalFormat,t.format,i.type,r)),!0}update(){if(this.destroyed)return;const e=this.source,t=e.naturalWidth||e.videoWidth||e.width,i=e.naturalHeight||e.videoHeight||e.height;this.resize(t,i),super.update()}dispose(){this.source=null}}class bm extends Rn{constructor(e,t){if(t=t||{},typeof e=="string"){const i=new Image;Rn.crossOrigin(i,e,t.crossorigin),i.src=e,e=i}super(e),!e.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=e.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(t.createBitmap??de.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof t.alphaMode=="number"?t.alphaMode:null,this.bitmap=null,this._load=null,t.autoLoad!==!1&&this.load()}load(e){return this._load?this._load:(e!==void 0&&(this.createBitmap=e),this._load=new Promise((t,i)=>{const r=this.source;this.url=r.src;const s=()=>{this.destroyed||(r.onload=null,r.onerror=null,this.update(),this._load=null,this.createBitmap?t(this.process()):t(this))};r.complete&&r.src?s():(r.onload=s,r.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const e=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const t=globalThis.createImageBitmap,i=!e.crossOrigin||e.crossOrigin==="anonymous";return this._process=fetch(e.src,{mode:i?"cors":"no-cors"}).then(r=>r.blob()).then(r=>t(r,0,0,e.width,e.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===li.UNPACK?"premultiply":"none"})).then(r=>this.destroyed?Promise.reject():(this.bitmap=r,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(e,t,i){if(typeof this.alphaMode=="number"&&(t.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(e,t,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(e,t,i,this.bitmap),!this.preserveBitmap){let r=!0;const s=t._glTextures;for(const o in s){const a=s[o];if(a!==i&&a.dirtyId!==t.dirtyId){r=!1;break}}r&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(e){return typeof HTMLImageElement<"u"&&(typeof e=="string"||e instanceof HTMLImageElement)}}class ju{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(e,t,i){const r=t.width,s=t.height;if(i){const o=e.width/2/r,a=e.height/2/s,l=e.x/r+o,h=e.y/s+a;i=pt.add(i,pt.NW),this.x0=l+o*pt.uX(i),this.y0=h+a*pt.uY(i),i=pt.add(i,2),this.x1=l+o*pt.uX(i),this.y1=h+a*pt.uY(i),i=pt.add(i,2),this.x2=l+o*pt.uX(i),this.y2=h+a*pt.uY(i),i=pt.add(i,2),this.x3=l+o*pt.uX(i),this.y3=h+a*pt.uY(i)}else this.x0=e.x/r,this.y0=e.y/s,this.x1=(e.x+e.width)/r,this.y1=e.y/s,this.x2=(e.x+e.width)/r,this.y2=(e.y+e.height)/s,this.x3=e.x/r,this.y3=(e.y+e.height)/s;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}ju.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const Sm=new ju;function Za(n){n.destroy=function(){},n.on=function(){},n.once=function(){},n.emit=function(){}}class Ee extends lo{constructor(e,t,i,r,s,o,a){if(super(),this.noFrame=!1,t||(this.noFrame=!0,t=new Ue(0,0,1,1)),e instanceof Ee&&(e=e.baseTexture),this.baseTexture=e,this._frame=t,this.trim=r,this.valid=!1,this.destroyed=!1,this._uvs=Sm,this.uvMatrix=null,this.orig=i||t,this._rotate=Number(s||0),s===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new Ye(o.x,o.y):new Ye(0,0),this.defaultBorders=a,this._updateID=0,this.textureCacheIds=[],e.valid?this.noFrame?e.valid&&this.onBaseTextureUpdated(e):this.frame=t:e.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&e.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(e){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=e.width,this._frame.height=e.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(e){if(this.baseTexture){if(e){const{resource:t}=this.baseTexture;t!=null&&t.url&&rn[t.url]&&Ee.removeFromCache(t.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,Ee.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var e;const t=this._frame.clone(),i=this._frame===this.orig?t:this.orig.clone(),r=new Ee(this.baseTexture,!this.noFrame&&t,i,(e=this.trim)==null?void 0:e.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(r._frame=t),r}updateUvs(){this._uvs===Sm&&(this._uvs=new ju),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(e,t={},i=de.STRICT_TEXTURE_CACHE){const r=typeof e=="string";let s=null;if(r)s=e;else if(e instanceof Fe){if(!e.cacheId){const a=t?.pixiIdPrefix||"pixiid";e.cacheId=`${a}-${Tr()}`,Fe.addToCache(e,e.cacheId)}s=e.cacheId}else{if(!e._pixiId){const a=t?.pixiIdPrefix||"pixiid";e._pixiId=`${a}_${Tr()}`}s=e._pixiId}let o=rn[s];if(r&&i&&!o)throw new Error(`The cacheId "${s}" does not exist in TextureCache.`);return!o&&!(e instanceof Fe)?(t.resolution||(t.resolution=bn(e)),o=new Ee(new Fe(e,t)),o.baseTexture.cacheId=s,Fe.addToCache(o.baseTexture,s),Ee.addToCache(o,s)):!o&&e instanceof Fe&&(o=new Ee(e),Ee.addToCache(o,s)),o}static fromURL(e,t){const i=Object.assign({autoLoad:!1},t?.resourceOptions),r=Ee.from(e,Object.assign({resourceOptions:i},t),!1),s=r.baseTexture.resource;return r.baseTexture.valid?Promise.resolve(r):s.load().then(()=>Promise.resolve(r))}static fromBuffer(e,t,i,r){return new Ee(Fe.fromBuffer(e,t,i,r))}static fromLoader(e,t,i,r){const s=new Fe(e,Object.assign({scaleMode:Fe.defaultOptions.scaleMode,resolution:bn(t)},r)),{resource:o}=s;o instanceof bm&&(o.url=t);const a=new Ee(s);return i||(i=t),Fe.addToCache(a.baseTexture,i),Ee.addToCache(a,i),i!==t&&(Fe.addToCache(a.baseTexture,t),Ee.addToCache(a,t)),a.baseTexture.valid?Promise.resolve(a):new Promise(l=>{a.baseTexture.once("loaded",()=>l(a))})}static addToCache(e,t){t&&(e.textureCacheIds.includes(t)||e.textureCacheIds.push(t),rn[t]&&rn[t]!==e&&console.warn(`Texture added to the cache with an id [${t}] that already had an entry`),rn[t]=e)}static removeFromCache(e){if(typeof e=="string"){const t=rn[e];if(t){const i=t.textureCacheIds.indexOf(e);return i>-1&&t.textureCacheIds.splice(i,1),delete rn[e],t}}else if(e!=null&&e.textureCacheIds){for(let t=0;t<e.textureCacheIds.length;++t)rn[e.textureCacheIds[t]]===e&&delete rn[e.textureCacheIds[t]];return e.textureCacheIds.length=0,e}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(e){this._frame=e,this.noFrame=!1;const{x:t,y:i,width:r,height:s}=e,o=t+r>this.baseTexture.width,a=i+s>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${t} + ${r} = ${t+r} > ${this.baseTexture.width}`,u=`Y: ${i} + ${s} = ${i+s} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${u}`)}this.valid=r&&s&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=e),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(e){this._rotate=e,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return Ee._EMPTY||(Ee._EMPTY=new Ee(new Fe),Za(Ee._EMPTY),Za(Ee._EMPTY.baseTexture)),Ee._EMPTY}static get WHITE(){if(!Ee._WHITE){const e=de.ADAPTER.createCanvas(16,16),t=e.getContext("2d");e.width=16,e.height=16,t.fillStyle="white",t.fillRect(0,0,16,16),Ee._WHITE=new Ee(Fe.from(e)),Za(Ee._WHITE),Za(Ee._WHITE.baseTexture)}return Ee._WHITE}}class Pr extends Ee{constructor(e,t){super(e,t),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(e){this.framebuffer.multisample=e}resize(e,t,i=!0){const r=this.baseTexture.resolution,s=Math.round(e*r)/r,o=Math.round(t*r)/r;this.valid=s>0&&o>0,this._frame.width=this.orig.width=s,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(s,o),this.updateUvs()}setResolution(e){const{baseTexture:t}=this;t.resolution!==e&&(t.setResolution(e),this.resize(t.width,t.height,!1))}static create(e){return new Pr(new Em(e))}}class Am{constructor(e){this.texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(e,t,i=Tt.NONE){const r=new Em(Object.assign({width:e,height:t,resolution:1,multisample:i},this.textureOptions));return new Pr(r)}getOptimalTexture(e,t,i=1,r=Tt.NONE){let s;e=Math.max(Math.ceil(e*i-1e-6),1),t=Math.max(Math.ceil(t*i-1e-6),1),!this.enableFullScreen||e!==this._pixelsWidth||t!==this._pixelsHeight?(e=La(e),t=La(t),s=((e&65535)<<16|t&65535)>>>0,r>1&&(s+=r*4294967296)):s=r>1?-r:-1,this.texturePool[s]||(this.texturePool[s]=[]);let o=this.texturePool[s].pop();return o||(o=this.createTexture(e,t,r)),o.filterPoolKey=s,o.setResolution(i),o}getFilterTexture(e,t,i){const r=this.getOptimalTexture(e.width,e.height,t||e.resolution,i||Tt.NONE);return r.filterFrame=e.filterFrame,r}returnTexture(e){const t=e.filterPoolKey;e.filterFrame=null,this.texturePool[t].push(e)}returnFilterTexture(e){this.returnTexture(e)}clear(e){if(e=e!==!1,e)for(const t in this.texturePool){const i=this.texturePool[t];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0)}this.texturePool={}}setScreenSize(e){if(!(e.width===this._pixelsWidth&&e.height===this._pixelsHeight)){this.enableFullScreen=e.width>0&&e.height>0;for(const t in this.texturePool){if(!(Number(t)<0))continue;const i=this.texturePool[t];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0);this.texturePool[t]=[]}this._pixelsWidth=e.width,this._pixelsHeight=e.height}}}Am.SCREEN_KEY=-1;class UR extends jn{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Rm extends jn{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new _t(this.vertices),this.uvBuffer=new _t(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(e,t){let i=0,r=0;return this.uvs[0]=i,this.uvs[1]=r,this.uvs[2]=i+t.width/e.width,this.uvs[3]=r,this.uvs[4]=i+t.width/e.width,this.uvs[5]=r+t.height/e.height,this.uvs[6]=i,this.uvs[7]=r+t.height/e.height,i=t.x,r=t.y,this.vertices[0]=i,this.vertices[1]=r,this.vertices[2]=i+t.width,this.vertices[3]=r,this.vertices[4]=i+t.width,this.vertices[5]=r+t.height,this.vertices[6]=i,this.vertices[7]=r+t.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class HR{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Tt.NONE,this.sourceFrame=new Ue,this.destinationFrame=new Ue,this.bindingSourceFrame=new Ue,this.bindingDestinationFrame=new Ue,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Ka=[new Ye,new Ye,new Ye,new Ye],Xu=new at;class Cm{constructor(e){this.renderer=e,this.defaultFilterStack=[{}],this.texturePool=new Am,this.statePool=[],this.quad=new UR,this.quadUv=new Rm,this.tempRect=new Ue,this.activeState={},this.globalUniforms=new Ni({outputFrame:new Ue,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(e,t){const i=this.renderer,r=this.defaultFilterStack,s=this.statePool.pop()||new HR,o=i.renderTexture;let a,l;if(o.current){const m=o.current;a=m.resolution,l=m.multisample}else a=i.resolution,l=i.multisample;let h=t[0].resolution||a,u=t[0].multisample??l,c=t[0].padding,d=t[0].autoFit,f=t[0].legacy??!0;for(let m=1;m<t.length;m++){const v=t[m];h=Math.min(h,v.resolution||a),u=Math.min(u,v.multisample??l),c=this.useMaxPadding?Math.max(c,v.padding):c+v.padding,d=d&&v.autoFit,f=f||(v.legacy??!0)}r.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),r.push(s),s.resolution=h,s.multisample=u,s.legacy=f,s.target=e,s.sourceFrame.copyFrom(e.filterArea||e.getBounds(!0)),s.sourceFrame.pad(c);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Xu.copyFrom(i.projection.transform).invert(),p),d?(s.sourceFrame.fit(p),(s.sourceFrame.width<=0||s.sourceFrame.height<=0)&&(s.sourceFrame.width=0,s.sourceFrame.height=0)):s.sourceFrame.intersects(p)||(s.sourceFrame.width=0,s.sourceFrame.height=0),this.roundFrame(s.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),s.renderTexture=this.getOptimalFilterTexture(s.sourceFrame.width,s.sourceFrame.height,h,u),s.filters=t,s.destinationFrame.width=s.renderTexture.width,s.destinationFrame.height=s.renderTexture.height;const g=this.tempRect;g.x=0,g.y=0,g.width=s.sourceFrame.width,g.height=s.sourceFrame.height,s.renderTexture.filterFrame=s.sourceFrame,s.bindingSourceFrame.copyFrom(o.sourceFrame),s.bindingDestinationFrame.copyFrom(o.destinationFrame),s.transform=i.projection.transform,i.projection.transform=null,o.bind(s.renderTexture,s.sourceFrame,g),i.framebuffer.clear(0,0,0,0)}pop(){const e=this.defaultFilterStack,t=e.pop(),i=t.filters;this.activeState=t;const r=this.globalUniforms.uniforms;r.outputFrame=t.sourceFrame,r.resolution=t.resolution;const s=r.inputSize,o=r.inputPixel,a=r.inputClamp;if(s[0]=t.destinationFrame.width,s[1]=t.destinationFrame.height,s[2]=1/s[0],s[3]=1/s[1],o[0]=Math.round(s[0]*t.resolution),o[1]=Math.round(s[1]*t.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=t.sourceFrame.width*s[2]-.5*o[2],a[3]=t.sourceFrame.height*s[3]-.5*o[3],t.legacy){const h=r.filterArea;h[0]=t.destinationFrame.width,h[1]=t.destinationFrame.height,h[2]=t.sourceFrame.x,h[3]=t.sourceFrame.y,r.filterClamp=r.inputClamp}this.globalUniforms.update();const l=e[e.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,t.renderTexture,l.renderTexture,en.BLEND,t),this.returnFilterTexture(t.renderTexture);else{let h=t.renderTexture,u=this.getOptimalFilterTexture(h.width,h.height,t.resolution);u.filterFrame=h.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&t.multisample>1&&(u=this.getOptimalFilterTexture(h.width,h.height,t.resolution),u.filterFrame=h.filterFrame),i[c].apply(this,h,u,en.CLEAR,t);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,en.BLEND,t),c>1&&t.multisample>1&&this.returnFilterTexture(t.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(u)}t.clear(),this.statePool.push(t)}bindAndClear(e,t=en.CLEAR){const{renderTexture:i,state:r}=this.renderer;if(e===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,e?.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=e.filterFrame.width,o.height=e.filterFrame.height,i.bind(e,e.filterFrame,o)}else e!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(e):this.renderer.renderTexture.bind(e,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const s=r.stateId&1||this.forceClear;(t===en.CLEAR||t===en.BLIT&&s)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(e,t,i,r){const s=this.renderer;s.state.set(e.state),this.bindAndClear(i,r),e.uniforms.uSampler=t,e.uniforms.filterGlobals=this.globalUniforms,s.shader.bind(e),e.legacy=!!e.program.attributeData.aTextureCoord,e.legacy?(this.quadUv.map(t._frame,t.filterFrame),s.geometry.bind(this.quadUv),s.geometry.draw(Ji.TRIANGLES)):(s.geometry.bind(this.quad),s.geometry.draw(Ji.TRIANGLE_STRIP))}calculateSpriteMatrix(e,t){const{sourceFrame:i,destinationFrame:r}=this.activeState,{orig:s}=t._texture,o=e.set(r.width,0,0,r.height,i.x,i.y),a=t.worldTransform.copyTo(at.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/s.width,1/s.height),o.translate(t.anchor.x,t.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(e,t,i=1,r=Tt.NONE){return this.texturePool.getOptimalTexture(e,t,i,r)}getFilterTexture(e,t,i){if(typeof e=="number"){const s=e;e=t,t=s}e=e||this.activeState.renderTexture;const r=this.texturePool.getOptimalTexture(e.width,e.height,t||e.resolution,i||Tt.NONE);return r.filterFrame=e.filterFrame,r}returnFilterTexture(e){this.texturePool.returnTexture(e)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(e,t){const i=Ka[0],r=Ka[1],s=Ka[2],o=Ka[3];i.set(t.left,t.top),r.set(t.left,t.bottom),s.set(t.right,t.top),o.set(t.right,t.bottom),e.apply(i,i),e.apply(r,r),e.apply(s,s),e.apply(o,o);const a=Math.min(i.x,r.x,s.x,o.x),l=Math.min(i.y,r.y,s.y,o.y),h=Math.max(i.x,r.x,s.x,o.x),u=Math.max(i.y,r.y,s.y,o.y);t.x=a,t.y=l,t.width=h-a,t.height=u-l}roundFrame(e,t,i,r,s){if(!(e.width<=0||e.height<=0||i.width<=0||i.height<=0)){if(s){const{a:o,b:a,c:l,d:h}=s;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}s=s?Xu.copyFrom(s):Xu.identity(),s.translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.transformAABB(s,e),e.ceil(t),this.transformAABB(s.invert(),e)}}}Cm.extension={type:ue.RendererSystem,name:"filter"},Te.add(Cm);class zR{constructor(e){this.framebuffer=e,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Tt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const GR=new Ue;class Pm{constructor(e){this.renderer=e,this.managedFramebuffers=[],this.unknownFramebuffer=new Wu(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const e=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Ue,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let t=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;de.PREFER_ENV===_r.WEBGL_LEGACY&&(t=null,i=null),t?e.drawBuffers=r=>t.drawBuffersWEBGL(r):(this.hasMRT=!1,e.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=e.getInternalformatParameter(e.RENDERBUFFER,e.RGBA8,e.SAMPLES)}bind(e,t,i=0){const{gl:r}=this;if(e){const s=e.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(e);this.current!==e&&(this.current=e,r.bindFramebuffer(r.FRAMEBUFFER,s.framebuffer)),s.mipLevel!==i&&(e.dirtyId++,e.dirtyFormat++,s.mipLevel=i),s.dirtyId!==e.dirtyId&&(s.dirtyId=e.dirtyId,s.dirtyFormat!==e.dirtyFormat?(s.dirtyFormat=e.dirtyFormat,s.dirtySize=e.dirtySize,this.updateFramebuffer(e,i)):s.dirtySize!==e.dirtySize&&(s.dirtySize=e.dirtySize,this.resizeFramebuffer(e)));for(let o=0;o<e.colorTextures.length;o++){const a=e.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(e.depthTexture&&this.renderer.texture.unbind(e.depthTexture),t){const o=t.width>>i,a=t.height>>i,l=o/t.width;this.setViewport(t.x*l,t.y*l,o,a)}else{const o=e.width>>i,a=e.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),t?this.setViewport(t.x,t.y,t.width,t.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(e,t,i,r){const s=this.viewport;e=Math.round(e),t=Math.round(t),i=Math.round(i),r=Math.round(r),(s.width!==i||s.height!==r||s.x!==e||s.y!==t)&&(s.x=e,s.y=t,s.width=i,s.height=r,this.gl.viewport(e,t,i,r))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(e,t,i,r,s=$h.COLOR|$h.DEPTH){const{gl:o}=this;o.clearColor(e,t,i,r),o.clear(s)}initFramebuffer(e){const{gl:t}=this,i=new zR(t.createFramebuffer());return i.multisample=this.detectSamples(e.multisample),e.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(e),e.disposeRunner.add(this),i}resizeFramebuffer(e){const{gl:t}=this,i=e.glFramebuffers[this.CONTEXT_UID];if(i.stencil){t.bindRenderbuffer(t.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=t.DEPTH_STENCIL:e.depth&&e.stencil?o=t.DEPTH24_STENCIL8:e.depth?o=t.DEPTH_COMPONENT24:o=t.STENCIL_INDEX8,i.msaaBuffer?t.renderbufferStorageMultisample(t.RENDERBUFFER,i.multisample,o,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,o,e.width,e.height)}const r=e.colorTextures;let s=r.length;t.drawBuffers||(s=Math.min(s,1));for(let o=0;o<s;o++){const a=r[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(t.bindRenderbuffer(t.RENDERBUFFER,i.msaaBuffer),t.renderbufferStorageMultisample(t.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,e.width,e.height))}e.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(e.depthTexture,0)}updateFramebuffer(e,t){const{gl:i}=this,r=e.glFramebuffers[this.CONTEXT_UID],s=e.colorTextures;let o=s.length;i.drawBuffers||(o=Math.min(o,1)),r.multisample>1&&this.canMultisampleFramebuffer(e)?r.msaaBuffer=r.msaaBuffer||i.createRenderbuffer():r.msaaBuffer&&(i.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=s[l],u=h.parentTextureArray||h;this.renderer.texture.bind(u,0),l===0&&r.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,r.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,u._glTextures[this.CONTEXT_UID].internalFormat,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,u._glTextures[this.CONTEXT_UID].texture,t),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),e.depthTexture&&this.writeDepthTexture){const l=e.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,t)}if((e.stencil||e.depth)&&!(e.depthTexture&&this.writeDepthTexture)){r.stencil=r.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):e.depth&&e.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):e.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,r.stencil),r.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,h,e.width,e.height):i.renderbufferStorage(i.RENDERBUFFER,h,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,r.stencil)}else r.stencil&&(i.deleteRenderbuffer(r.stencil),r.stencil=null)}canMultisampleFramebuffer(e){return this.renderer.context.webGLVersion!==1&&e.colorTextures.length<=1&&!e.depthTexture}detectSamples(e){const{msaaSamples:t}=this;let i=Tt.NONE;if(e<=1||t===null)return i;for(let r=0;r<t.length;r++)if(t[r]<=e){i=t[r];break}return i===1&&(i=Tt.NONE),i}blit(e,t,i){const{current:r,renderer:s,gl:o,CONTEXT_UID:a}=this;if(s.context.webGLVersion!==2||!r)return;const l=r.glFramebuffers[a];if(!l)return;if(!e){if(!l.msaaBuffer)return;const u=r.colorTextures[0];if(!u)return;l.blitFramebuffer||(l.blitFramebuffer=new Wu(r.width,r.height),l.blitFramebuffer.addColorTexture(0,u)),e=l.blitFramebuffer,e.colorTextures[0]!==u&&(e.colorTextures[0]=u,e.dirtyId++,e.dirtyFormat++),(e.width!==r.width||e.height!==r.height)&&(e.width=r.width,e.height=r.height,e.dirtyId++,e.dirtySize++)}t||(t=GR,t.width=r.width,t.height=r.height),i||(i=t);const h=t.width===i.width&&t.height===i.height;this.bind(e),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(t.left,t.top,t.right,t.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,e.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(e,t){const i=e.glFramebuffers[this.CONTEXT_UID],r=this.gl;if(!i)return;delete e.glFramebuffers[this.CONTEXT_UID];const s=this.managedFramebuffers.indexOf(e);s>=0&&this.managedFramebuffers.splice(s,1),e.disposeRunner.remove(this),t||(r.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&r.deleteRenderbuffer(i.msaaBuffer),i.stencil&&r.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,t)}disposeAll(e){const t=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<t.length;i++)this.disposeFramebuffer(t[i],e)}forceStencil(){const e=this.current;if(!e)return;const t=e.glFramebuffers[this.CONTEXT_UID];if(!t||t.stencil&&e.stencil)return;e.stencil=!0;const i=e.width,r=e.height,s=this.gl,o=t.stencil=s.createRenderbuffer();s.bindRenderbuffer(s.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH_STENCIL):e.depth?(a=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH24_STENCIL8):(a=s.STENCIL_ATTACHMENT,l=s.STENCIL_INDEX8),t.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,t.multisample,l,i,r):s.renderbufferStorage(s.RENDERBUFFER,l,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,a,s.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new Ue}destroy(){this.renderer=null}}Pm.extension={type:ue.RendererSystem,name:"framebuffer"},Te.add(Pm);const Yu={5126:4,5123:2,5121:1};class Im{constructor(e){this.renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const e=this.gl=this.renderer.gl,t=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,t.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;de.PREFER_ENV===_r.WEBGL_LEGACY&&(i=null),i?(e.createVertexArray=()=>i.createVertexArrayOES(),e.bindVertexArray=r=>i.bindVertexArrayOES(r),e.deleteVertexArray=r=>i.deleteVertexArrayOES(r)):(this.hasVao=!1,e.createVertexArray=()=>null,e.bindVertexArray=()=>null,e.deleteVertexArray=()=>null)}if(t.webGLVersion!==2){const i=e.getExtension("ANGLE_instanced_arrays");i?(e.vertexAttribDivisor=(r,s)=>i.vertexAttribDivisorANGLE(r,s),e.drawElementsInstanced=(r,s,o,a,l)=>i.drawElementsInstancedANGLE(r,s,o,a,l),e.drawArraysInstanced=(r,s,o,a)=>i.drawArraysInstancedANGLE(r,s,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=t.webGLVersion===2||!!t.extensions.uint32ElementIndex}bind(e,t){t=t||this.renderer.shader.shader;const{gl:i}=this;let r=e.glVertexArrayObjects[this.CONTEXT_UID],s=!1;r||(this.managedGeometries[e.id]=e,e.disposeRunner.add(this),e.glVertexArrayObjects[this.CONTEXT_UID]=r={},s=!0);const o=r[t.program.id]||this.initGeometryVao(e,t,s);this._activeGeometry=e,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(e,t.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this.renderer.buffer;for(let i=0;i<e.buffers.length;i++){const r=e.buffers[i];t.update(r)}}checkCompatibility(e,t){const i=e.attributes,r=t.attributeData;for(const s in r)if(!i[s])throw new Error(`shader and geometry incompatible, geometry missing the "${s}" attribute`)}getSignature(e,t){const i=e.attributes,r=t.attributeData,s=["g",e.id];for(const o in i)r[o]&&s.push(o,r[o].location);return s.join("-")}initGeometryVao(e,t,i=!0){const r=this.gl,s=this.CONTEXT_UID,o=this.renderer.buffer,a=t.program;a.glPrograms[s]||this.renderer.shader.generateProgram(t),this.checkCompatibility(e,a);const l=this.getSignature(e,a),h=e.glVertexArrayObjects[this.CONTEXT_UID];let u=h[l];if(u)return h[a.id]=u,u;const c=e.buffers,d=e.attributes,f={},p={};for(const g in c)f[g]=0,p[g]=0;for(const g in d)!d[g].size&&a.attributeData[g]?d[g].size=a.attributeData[g].size:d[g].size||console.warn(`PIXI Geometry attribute '${g}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[g].buffer]+=d[g].size*Yu[d[g].type];for(const g in d){const m=d[g],v=m.size;m.stride===void 0&&(f[m.buffer]===v*Yu[m.type]?m.stride=0:m.stride=f[m.buffer]),m.start===void 0&&(m.start=p[m.buffer],p[m.buffer]+=v*Yu[m.type])}u=r.createVertexArray(),r.bindVertexArray(u);for(let g=0;g<c.length;g++){const m=c[g];o.bind(m),i&&m._glBuffers[s].refCount++}return this.activateVao(e,a),h[a.id]=u,h[l]=u,r.bindVertexArray(null),o.unbind(tn.ARRAY_BUFFER),u}disposeGeometry(e,t){var i;if(!this.managedGeometries[e.id])return;delete this.managedGeometries[e.id];const r=e.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,o=e.buffers,a=(i=this.renderer)==null?void 0:i.buffer;if(e.disposeRunner.remove(this),!!r){if(a)for(let l=0;l<o.length;l++){const h=o[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!t&&a.dispose(o[l],t))}if(!t){for(const l in r)if(l[0]==="g"){const h=r[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete e.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(e){const t=Object.keys(this.managedGeometries);for(let i=0;i<t.length;i++)this.disposeGeometry(this.managedGeometries[t[i]],e)}activateVao(e,t){const i=this.gl,r=this.CONTEXT_UID,s=this.renderer.buffer,o=e.buffers,a=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let l=null;for(const h in a){const u=a[h],c=o[u.buffer],d=c._glBuffers[r];if(t.attributeData[h]){l!==d&&(s.bind(c),l=d);const f=t.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(f,u.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,t,i,r){const{gl:s}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?s.UNSIGNED_SHORT:s.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?s.drawElementsInstanced(e,t||o.indexBuffer.data.length,l,(i||0)*a,r||1):s.drawElements(e,t||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?s.drawArraysInstanced(e,i,t||o.getSize(),r||1):s.drawArrays(e,i,t||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}Im.extension={type:ue.RendererSystem,name:"geometry"},Te.add(Im);const Dm=new at;class Mm{constructor(e,t){this._texture=e,this.mapCoord=new at,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof t>"u"?.5:t,this.isSimple=!1}get texture(){return this._texture}set texture(e){this._texture=e,this._textureID=-1}multiplyUvs(e,t){t===void 0&&(t=e);const i=this.mapCoord;for(let r=0;r<e.length;r+=2){const s=e[r],o=e[r+1];t[r]=s*i.a+o*i.c+i.tx,t[r+1]=s*i.b+o*i.d+i.ty}return t}update(e){const t=this._texture;if(!t||!t.valid||!e&&this._textureID===t._updateID)return!1;this._textureID=t._updateID,this._updateID++;const i=t._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const r=t.orig,s=t.trim;s&&(Dm.set(r.width/s.width,0,0,r.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(Dm));const o=t.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(t._frame.x+l+h)/o.width,a[1]=(t._frame.y+l+h)/o.height,a[2]=(t._frame.x+t._frame.width-l+h)/o.width,a[3]=(t._frame.y+t._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=t._frame.width===o.width&&t._frame.height===o.height&&t.rotate===0,!0}}var VR=`varying vec2 vMaskCoord;
505
+ varying vec2 vTextureCoord;
506
+
507
+ uniform sampler2D uSampler;
508
+ uniform sampler2D mask;
509
+ uniform float alpha;
510
+ uniform float npmAlpha;
511
+ uniform vec4 maskClamp;
512
+
513
+ void main(void)
514
+ {
515
+ float clip = step(3.5,
516
+ step(maskClamp.x, vMaskCoord.x) +
517
+ step(maskClamp.y, vMaskCoord.y) +
518
+ step(vMaskCoord.x, maskClamp.z) +
519
+ step(vMaskCoord.y, maskClamp.w));
520
+
521
+ vec4 original = texture2D(uSampler, vTextureCoord);
522
+ vec4 masky = texture2D(mask, vMaskCoord);
523
+ float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
524
+
525
+ original *= (alphaMul * masky.r * alpha * clip);
526
+
527
+ gl_FragColor = original;
528
+ }
529
+ `,WR=`attribute vec2 aVertexPosition;
530
+ attribute vec2 aTextureCoord;
531
+
532
+ uniform mat3 projectionMatrix;
533
+ uniform mat3 otherMatrix;
534
+
535
+ varying vec2 vMaskCoord;
536
+ varying vec2 vTextureCoord;
537
+
538
+ void main(void)
539
+ {
540
+ gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
541
+
542
+ vTextureCoord = aTextureCoord;
543
+ vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
544
+ }
545
+ `;class jR extends ni{constructor(e,t,i){let r=null;typeof e!="string"&&t===void 0&&i===void 0&&(r=e,e=void 0,t=void 0,i=void 0),super(e||WR,t||VR,i),this.maskSprite=r,this.maskMatrix=new at}get maskSprite(){return this._maskSprite}set maskSprite(e){this._maskSprite=e,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(e,t,i,r){const s=this._maskSprite,o=s._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new Mm(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=e.calculateSpriteMatrix(this.maskMatrix,s).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=s.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,e.applyFilter(this,t,i,r))}}class XR{constructor(e=null){this.type=bt.NONE,this.autoDetect=!0,this.maskObject=e||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=ni.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(e){e?this._filters?this._filters[0]=e:this._filters=[e]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=bt.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(e){e?(this._stencilCounter=e._stencilCounter,this._scissorCounter=e._scissorCounter,this._scissorRect=e._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Om{constructor(e){this.renderer=e,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(e){this.maskStack=e,this.renderer.scissor.setMaskStack(e),this.renderer.stencil.setMaskStack(e)}push(e,t){let i=t;if(!i.isMaskData){const s=this.maskDataPool.pop()||new XR;s.pooled=!0,s.maskObject=t,i=s}const r=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(r),i._colorMask=r?r._colorMask:15,i.autoDetect&&this.detect(i),i._target=e,i.type!==bt.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case bt.SCISSOR:this.renderer.scissor.push(i);break;case bt.STENCIL:this.renderer.stencil.push(i);break;case bt.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case bt.COLOR:this.pushColorMask(i);break}i.type===bt.SPRITE&&this.maskStack.push(i)}pop(e){const t=this.maskStack.pop();if(!(!t||t._target!==e)){if(t.enabled)switch(t.type){case bt.SCISSOR:this.renderer.scissor.pop(t);break;case bt.STENCIL:this.renderer.stencil.pop(t.maskObject);break;case bt.SPRITE:this.popSpriteMask(t);break;case bt.COLOR:this.popColorMask(t);break}if(t.reset(),t.pooled&&this.maskDataPool.push(t),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===bt.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(e){const t=e.maskObject;t?t.isSprite?e.type=bt.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(e)?e.type=bt.SCISSOR:e.type=bt.STENCIL:e.type=bt.COLOR}pushSpriteMask(e){const{maskObject:t}=e,i=e._target;let r=e._filters;r||(r=this.alphaMaskPool[this.alphaMaskIndex],r||(r=this.alphaMaskPool[this.alphaMaskIndex]=[new jR])),r[0].resolution=e.resolution,r[0].multisample=e.multisample,r[0].maskSprite=t;const s=i.filterArea;i.filterArea=t.getBounds(!0),this.renderer.filter.push(i,r),i.filterArea=s,e._filters||this.alphaMaskIndex++}popSpriteMask(e){this.renderer.filter.pop(),e._filters?e._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(e){const t=e._colorMask,i=e._colorMask=t&e.colorMask;i!==t&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(e){const t=e._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==t&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Om.extension={type:ue.RendererSystem,name:"mask"},Te.add(Om);class Lm{constructor(e){this.renderer=e,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(e){const{gl:t}=this.renderer,i=this.getStackLength();this.maskStack=e;const r=this.getStackLength();r!==i&&(r===0?t.disable(this.glConst):(t.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const Bm=new at,Fm=[],Nm=class bl extends Lm{constructor(e){super(e),this.glConst=de.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const e=this.maskStack[this.maskStack.length-1];return e?e._scissorCounter:0}calcScissorRect(e){if(e._scissorRectLocal)return;const t=e._scissorRect,{maskObject:i}=e,{renderer:r}=this,s=r.renderTexture,o=i.getBounds(!0,Fm.pop()??new Ue);this.roundFrameToPixels(o,s.current?s.current.resolution:r.resolution,s.sourceFrame,s.destinationFrame,r.projection.transform),t&&o.fit(t),e._scissorRectLocal=o}static isMatrixRotated(e){if(!e)return!1;const{a:t,b:i,c:r,d:s}=e;return(Math.abs(i)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(t)>1e-4||Math.abs(s)>1e-4)}testScissor(e){const{maskObject:t}=e;if(!t.isFastRect||!t.isFastRect()||bl.isMatrixRotated(t.worldTransform)||bl.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(e);const i=e._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(e,t,i,r,s){bl.isMatrixRotated(s)||(s=s?Bm.copyFrom(s):Bm.identity(),s.translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.renderer.filter.transformAABB(s,e),e.fit(r),e.x=Math.round(e.x*t),e.y=Math.round(e.y*t),e.width=Math.round(e.width*t),e.height=Math.round(e.height*t))}push(e){e._scissorRectLocal||this.calcScissorRect(e);const{gl:t}=this.renderer;e._scissorRect||t.enable(t.SCISSOR_TEST),e._scissorCounter++,e._scissorRect=e._scissorRectLocal,this._useCurrent()}pop(e){const{gl:t}=this.renderer;e&&Fm.push(e._scissorRectLocal),this.getStackLength()>0?this._useCurrent():t.disable(t.SCISSOR_TEST)}_useCurrent(){const e=this.maskStack[this.maskStack.length-1]._scissorRect;let t;this.renderer.renderTexture.current?t=e.y:t=this.renderer.height-e.height-e.y,this.renderer.gl.scissor(e.x,t,e.width,e.height)}};Nm.extension={type:ue.RendererSystem,name:"scissor"};let YR=Nm;Te.add(YR);class km extends Lm{constructor(e){super(e),this.glConst=de.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const e=this.maskStack[this.maskStack.length-1];return e?e._stencilCounter:0}push(e){const t=e.maskObject,{gl:i}=this.renderer,r=e._stencilCounter;r===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),e._stencilCounter++;const s=e._colorMask;s!==0&&(e._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,r,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(e._colorMask=s,i.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}pop(e){const t=this.renderer.gl;if(this.getStackLength()===0)t.disable(t.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,r=i?i._colorMask:15;r!==0&&(i._colorMask=0,t.colorMask(!1,!1,!1,!1)),t.stencilOp(t.KEEP,t.KEEP,t.DECR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,r!==0&&(i._colorMask=r,t.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)),this._useCurrent()}}_useCurrent(){const e=this.renderer.gl;e.stencilFunc(e.EQUAL,this.getStackLength(),4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)}}km.extension={type:ue.RendererSystem,name:"stencil"},Te.add(km);class Um{constructor(e){this.renderer=e,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return We("7.0.0","renderer.plugins.extract has moved to renderer.extract"),e.extract}},prepare:{enumerable:!1,get(){return We("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),e.prepare}},interaction:{enumerable:!1,get(){return We("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),e.events}}})}init(){const e=this.rendererPlugins;for(const t in e)this.plugins[t]=new e[t](this.renderer)}destroy(){for(const e in this.plugins)this.plugins[e].destroy(),this.plugins[e]=null}}Um.extension={type:[ue.RendererSystem,ue.CanvasRendererSystem],name:"_plugin"},Te.add(Um);class Hm{constructor(e){this.renderer=e,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new at,this.transform=null}update(e,t,i,r){this.destinationFrame=e||this.destinationFrame||this.defaultFrame,this.sourceFrame=t||this.sourceFrame||e,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,r),this.transform&&this.projectionMatrix.append(this.transform);const s=this.renderer;s.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,s.globalUniforms.update(),s.shader.shader&&s.shader.syncUniformGroup(s.shader.shader.uniforms.globals)}calculateProjection(e,t,i,r){const s=this.projectionMatrix,o=r?-1:1;s.identity(),s.a=1/t.width*2,s.d=o*(1/t.height*2),s.tx=-1-t.x*s.a,s.ty=-o-t.y*s.d}setTransform(e){}destroy(){this.renderer=null}}Hm.extension={type:ue.RendererSystem,name:"projection"},Te.add(Hm);const qR=new Uu,zm=new Ue;class Gm{constructor(e){this.renderer=e,this._tempMatrix=new at}generateTexture(e,t){const{region:i,...r}=t||{},s=i?.copyTo(zm)||e.getLocalBounds(zm,!0),o=r.resolution||this.renderer.resolution;s.width=Math.max(s.width,1/o),s.height=Math.max(s.height,1/o),r.width=s.width,r.height=s.height,r.resolution=o,r.multisample??(r.multisample=this.renderer.multisample);const a=Pr.create(r);this._tempMatrix.tx=-s.x,this._tempMatrix.ty=-s.y;const l=e.transform;return e.transform=qR,this.renderer.render(e,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!e.parent,blit:!0}),e.transform=l,a}destroy(){}}Gm.extension={type:[ue.RendererSystem,ue.CanvasRendererSystem],name:"textureGenerator"},Te.add(Gm);const Ir=new Ue,Eo=new Ue;class Vm{constructor(e){this.renderer=e,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Ue,this.destinationFrame=new Ue,this.viewportFrame=new Ue}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(e=null,t,i){const r=this.renderer;this.current=e;let s,o,a;e?(s=e.baseTexture,a=s.resolution,t||(Ir.width=e.frame.width,Ir.height=e.frame.height,t=Ir),i||(Eo.x=e.frame.x,Eo.y=e.frame.y,Eo.width=t.width,Eo.height=t.height,i=Eo),o=s.framebuffer):(a=r.resolution,t||(Ir.width=r._view.screen.width,Ir.height=r._view.screen.height,t=Ir),i||(i=Ir,i.width=t.width,i.height=t.height));const l=this.viewportFrame;l.x=i.x*a,l.y=i.y*a,l.width=i.width*a,l.height=i.height*a,e||(l.y=r.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,t,a,!o),e?this.renderer.mask.setMaskStack(s.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(t),this.destinationFrame.copyFrom(i)}clear(e,t){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,r=nt.shared.setValue(e||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&r.premultiply(r.alpha);const s=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=s.width!==o.width||s.height!==o.height;if(a){let{x:l,y:h,width:u,height:c}=this.viewportFrame;l=Math.round(l),h=Math.round(h),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,u,c)}this.renderer.framebuffer.clear(r.red,r.green,r.blue,r.alpha,t),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}Vm.extension={type:ue.RendererSystem,name:"renderTexture"},Te.add(Vm);class ZR{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function KR(n,e){const t={},i=e.getProgramParameter(n,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=e.getActiveAttrib(n,r);if(s.name.startsWith("gl_"))continue;const o=_m(e,s.type),a={type:o,name:s.name,size:vm(o),location:e.getAttribLocation(n,s.name)};t[s.name]=a}return t}function QR(n,e){const t={},i=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let r=0;r<i;r++){const s=e.getActiveUniform(n,r),o=s.name.replace(/\[.*?\]$/,""),a=!!s.name.match(/\[.*?\]$/),l=_m(e,s.type);t[o]={name:o,index:r,type:l,size:s.size,isArray:a,value:pm(l,s.size)}}return t}function JR(n,e){var t;const i=fm(n,n.VERTEX_SHADER,e.vertexSrc),r=fm(n,n.FRAGMENT_SHADER,e.fragmentSrc),s=n.createProgram();n.attachShader(s,i),n.attachShader(s,r);const o=(t=e.extra)==null?void 0:t.transformFeedbackVaryings;if(o&&(typeof n.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):n.transformFeedbackVaryings(s,o.names,o.bufferMode==="separate"?n.SEPARATE_ATTRIBS:n.INTERLEAVED_ATTRIBS)),n.linkProgram(s),n.getProgramParameter(s,n.LINK_STATUS)||RR(n,s,i,r),e.attributeData=KR(s,n),e.uniformData=QR(s,n),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertexSrc)){const l=Object.keys(e.attributeData);l.sort((h,u)=>h>u?1:-1);for(let h=0;h<l.length;h++)e.attributeData[l[h]].location=h,n.bindAttribLocation(s,h,l[h]);n.linkProgram(s)}n.deleteShader(i),n.deleteShader(r);const a={};for(const l in e.uniformData){const h=e.uniformData[l];a[l]={location:n.getUniformLocation(s,l),value:pm(h.type,h.size)}}return new ZR(s,a)}function $R(n,e,t,i,r){t.buffer.update(r)}const eC={float:`
546
+ data[offset] = v;
547
+ `,vec2:`
548
+ data[offset] = v[0];
549
+ data[offset+1] = v[1];
550
+ `,vec3:`
551
+ data[offset] = v[0];
552
+ data[offset+1] = v[1];
553
+ data[offset+2] = v[2];
554
+
555
+ `,vec4:`
556
+ data[offset] = v[0];
557
+ data[offset+1] = v[1];
558
+ data[offset+2] = v[2];
559
+ data[offset+3] = v[3];
560
+ `,mat2:`
561
+ data[offset] = v[0];
562
+ data[offset+1] = v[1];
563
+
564
+ data[offset+4] = v[2];
565
+ data[offset+5] = v[3];
566
+ `,mat3:`
567
+ data[offset] = v[0];
568
+ data[offset+1] = v[1];
569
+ data[offset+2] = v[2];
570
+
571
+ data[offset + 4] = v[3];
572
+ data[offset + 5] = v[4];
573
+ data[offset + 6] = v[5];
574
+
575
+ data[offset + 8] = v[6];
576
+ data[offset + 9] = v[7];
577
+ data[offset + 10] = v[8];
578
+ `,mat4:`
579
+ for(var i = 0; i < 16; i++)
580
+ {
581
+ data[offset + i] = v[i];
582
+ }
583
+ `},Wm={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:32,mat3:48,mat4:64};function tC(n){const e=n.map(s=>({data:s,offset:0,dataLen:0,dirty:0}));let t=0,i=0,r=0;for(let s=0;s<e.length;s++){const o=e[s];if(t=Wm[o.data.type],o.data.size>1&&(t=Math.max(t,16)*o.data.size),o.dataLen=t,i%t!==0&&i<16){const a=i%t%16;i+=a,r+=a}i+t>16?(r=Math.ceil(r/16)*16,o.offset=r,r+=t,i=t):(o.offset=r,i+=t,r+=t)}return r=Math.ceil(r/16)*16,{uboElements:e,size:r}}function iC(n,e){const t=[];for(const i in n)e[i]&&t.push(e[i]);return t.sort((i,r)=>i.index-r.index),t}function nC(n,e){if(!n.autoManage)return{size:0,syncFunc:$R};const t=iC(n.uniforms,e),{uboElements:i,size:r}=tC(t),s=[`
584
+ var v = null;
585
+ var v2 = null;
586
+ var cv = null;
587
+ var t = 0;
588
+ var gl = renderer.gl
589
+ var index = 0;
590
+ var data = buffer.data;
591
+ `];for(let o=0;o<i.length;o++){const a=i[o],l=n.uniforms[a.data.name],h=a.data.name;let u=!1;for(let c=0;c<_s.length;c++){const d=_s[c];if(d.codeUbo&&d.test(a.data,l)){s.push(`offset = ${a.offset/4};`,_s[c].codeUbo(a.data.name,l)),u=!0;break}}if(!u)if(a.data.size>1){const c=vm(a.data.type),d=Math.max(Wm[a.data.type]/16,1),f=c/d,p=(4-f%4)%4;s.push(`
592
+ cv = ud.${h}.value;
593
+ v = uv.${h};
594
+ offset = ${a.offset/4};
595
+
596
+ t = 0;
597
+
598
+ for(var i=0; i < ${a.data.size*d}; i++)
599
+ {
600
+ for(var j = 0; j < ${f}; j++)
601
+ {
602
+ data[offset++] = v[t++];
603
+ }
604
+ offset += ${p};
605
+ }
606
+
607
+ `)}else{const c=eC[a.data.type];s.push(`
608
+ cv = ud.${h}.value;
609
+ v = uv.${h};
610
+ offset = ${a.offset/4};
611
+ ${c};
612
+ `)}}return s.push(`
613
+ renderer.buffer.update(buffer);
614
+ `),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",s.join(`
615
+ `))}}let rC=0;const Qa={textureCount:0,uboCount:0};class jm{constructor(e){this.destroyed=!1,this.renderer=e,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=rC++}systemCheck(){if(!PR())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(e){this.gl=e,this.reset()}bind(e,t){e.disposeRunner.add(this),e.uniforms.globals=this.renderer.globalUniforms;const i=e.program,r=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(e);return this.shader=e,this.program!==i&&(this.program=i,this.gl.useProgram(r.program)),t||(Qa.textureCount=0,Qa.uboCount=0,this.syncUniformGroup(e.uniformGroup,Qa)),r}setUniforms(e){const t=this.shader.program,i=t.glPrograms[this.renderer.CONTEXT_UID];t.syncUniforms(i.uniformData,e,this.renderer)}syncUniformGroup(e,t){const i=this.getGlProgram();(!e.static||e.dirtyId!==i.uniformDirtyGroups[e.id])&&(i.uniformDirtyGroups[e.id]=e.dirtyId,this.syncUniforms(e,i,t))}syncUniforms(e,t,i){(e.syncUniforms[this.shader.program.id]||this.createSyncGroups(e))(t.uniformData,e.uniforms,this.renderer,i)}createSyncGroups(e){const t=this.getSignature(e,this.shader.program.uniformData,"u");return this.cache[t]||(this.cache[t]=bR(e,this.shader.program.uniformData)),e.syncUniforms[this.shader.program.id]=this.cache[t],e.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(e,t){const i=this.getGlProgram();if(!e.static||e.dirtyId!==0||!i.uniformGroups[e.id]){e.dirtyId=0;const r=i.uniformGroups[e.id]||this.createSyncBufferGroup(e,i,t);e.buffer.update(),r(i.uniformData,e.uniforms,this.renderer,Qa,e.buffer)}this.renderer.buffer.bindBufferBase(e.buffer,i.uniformBufferBindings[t])}createSyncBufferGroup(e,t,i){const{gl:r}=this.renderer;this.renderer.buffer.bind(e.buffer);const s=this.gl.getUniformBlockIndex(t.program,i);t.uniformBufferBindings[i]=this.shader.uniformBindCount,r.uniformBlockBinding(t.program,s,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(e,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=nC(e,this.shader.program.uniformData)),e.autoManage){const l=new Float32Array(a.size/4);e.buffer.update(l)}return t.uniformGroups[e.id]=a.syncFunc,t.uniformGroups[e.id]}getSignature(e,t,i){const r=e.uniforms,s=[`${i}-`];for(const o in r)s.push(o),t[o]&&s.push(t[o].type);return s.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(e){const t=this.gl,i=e.program,r=JR(t,i);return i.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(e){this.shader===e&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}jm.extension={type:ue.RendererSystem,name:"shader"},Te.add(jm);class Ja{constructor(e){this.renderer=e}run(e){const{renderer:t}=this;t.runners.init.emit(t.options),e.hello&&console.log(`PixiJS 7.4.3 - ${t.rendererLogId} - https://pixijs.com`),t.resize(t.screen.width,t.screen.height)}destroy(){}}Ja.defaultOptions={hello:!1},Ja.extension={type:[ue.RendererSystem,ue.CanvasRendererSystem],name:"startup"},Te.add(Ja);function sC(n,e=[]){return e[De.NORMAL]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.ADD]=[n.ONE,n.ONE],e[De.MULTIPLY]=[n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.SCREEN]=[n.ONE,n.ONE_MINUS_SRC_COLOR,n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.OVERLAY]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.DARKEN]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.LIGHTEN]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.COLOR_DODGE]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.COLOR_BURN]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.HARD_LIGHT]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.SOFT_LIGHT]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.DIFFERENCE]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.EXCLUSION]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.HUE]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.SATURATION]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.COLOR]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.LUMINOSITY]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.NONE]=[0,0],e[De.NORMAL_NPM]=[n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.ADD_NPM]=[n.SRC_ALPHA,n.ONE,n.ONE,n.ONE],e[De.SCREEN_NPM]=[n.SRC_ALPHA,n.ONE_MINUS_SRC_COLOR,n.ONE,n.ONE_MINUS_SRC_ALPHA],e[De.SRC_IN]=[n.DST_ALPHA,n.ZERO],e[De.SRC_OUT]=[n.ONE_MINUS_DST_ALPHA,n.ZERO],e[De.SRC_ATOP]=[n.DST_ALPHA,n.ONE_MINUS_SRC_ALPHA],e[De.DST_OVER]=[n.ONE_MINUS_DST_ALPHA,n.ONE],e[De.DST_IN]=[n.ZERO,n.SRC_ALPHA],e[De.DST_OUT]=[n.ZERO,n.ONE_MINUS_SRC_ALPHA],e[De.DST_ATOP]=[n.ONE_MINUS_DST_ALPHA,n.SRC_ALPHA],e[De.XOR]=[n.ONE_MINUS_DST_ALPHA,n.ONE_MINUS_SRC_ALPHA],e[De.SUBTRACT]=[n.ONE,n.ONE,n.ONE,n.ONE,n.FUNC_REVERSE_SUBTRACT,n.FUNC_ADD],e}const oC=0,aC=1,lC=2,hC=3,uC=4,cC=5,Xm=class Cc{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=De.NONE,this._blendEq=!1,this.map=[],this.map[oC]=this.setBlend,this.map[aC]=this.setOffset,this.map[lC]=this.setCullFace,this.map[hC]=this.setDepthTest,this.map[uC]=this.setFrontFace,this.map[cC]=this.setDepthMask,this.checks=[],this.defaultState=new sn,this.defaultState.blend=!0}contextChange(e){this.gl=e,this.blendModes=sC(e),this.set(this.defaultState),this.reset()}set(e){if(e=e||this.defaultState,this.stateId!==e.data){let t=this.stateId^e.data,i=0;for(;t;)t&1&&this.map[i].call(this,!!(e.data&1<<i)),t=t>>1,i++;this.stateId=e.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,e)}forceState(e){e=e||this.defaultState;for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(e.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,e);this.stateId=e.data}setBlend(e){this.updateCheck(Cc.checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this.updateCheck(Cc.checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}setCullFace(e){this.gl[e?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(e){this.gl.frontFace(this.gl[e?"CW":"CCW"])}setBlendMode(e){if(e===this.blendMode)return;this.blendMode=e;const t=this.blendModes[e],i=this.gl;t.length===2?i.blendFunc(t[0],t[1]):i.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,i.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(e,t){this.gl.polygonOffset(e,t)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(e,t){const i=this.checks.indexOf(e);t&&i===-1?this.checks.push(e):!t&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(e,t){e.setBlendMode(t.blendMode)}static checkPolygonOffset(e,t){e.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null}};Xm.extension={type:ue.RendererSystem,name:"state"};let dC=Xm;Te.add(dC);class fC extends lo{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(e){this.addRunners(...e.runners);const t=(e.priority??[]).filter(r=>e.systems[r]),i=[...t,...Object.keys(e.systems).filter(r=>!t.includes(r))];for(const r of i)this.addSystem(e.systems[r],r)}addRunners(...e){e.forEach(t=>{this.runners[t]=new Fi(t)})}addSystem(e,t){const i=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=i,this._systemsHash[t]=i;for(const r in this.runners)this.runners[r].add(i);return this}emitWithCustomOptions(e,t){const i=Object.keys(this._systemsHash);e.items.forEach(r=>{const s=i.find(o=>this._systemsHash[o]===r);r[e.name](t[s])})}destroy(){Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash={}}}const bo=class Sl{constructor(e){this.renderer=e,this.count=0,this.checkCount=0,this.maxIdle=Sl.defaultMaxIdle,this.checkCountMax=Sl.defaultCheckCountMax,this.mode=Sl.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==eu.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const e=this.renderer.texture,t=e.managedTextures;let i=!1;for(let r=0;r<t.length;r++){const s=t[r];s.resource&&this.count-s.touched>this.maxIdle&&(e.destroyTexture(s,!0),t[r]=null,i=!0)}if(i){let r=0;for(let s=0;s<t.length;s++)t[s]!==null&&(t[r++]=t[s]);t.length=r}}unload(e){const t=this.renderer.texture,i=e._texture;i&&!i.framebuffer&&t.destroyTexture(i);for(let r=e.children.length-1;r>=0;r--)this.unload(e.children[r])}destroy(){this.renderer=null}};bo.defaultMode=eu.AUTO,bo.defaultMaxIdle=3600,bo.defaultCheckCountMax=600,bo.extension={type:ue.RendererSystem,name:"textureGC"};let Dr=bo;Te.add(Dr);class qu{constructor(e){this.texture=e,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=Se.UNSIGNED_BYTE,this.internalFormat=re.RGBA,this.samplerType=0}}function pC(n){let e;return"WebGL2RenderingContext"in globalThis&&n instanceof globalThis.WebGL2RenderingContext?e={[n.RGB]:ce.FLOAT,[n.RGBA]:ce.FLOAT,[n.ALPHA]:ce.FLOAT,[n.LUMINANCE]:ce.FLOAT,[n.LUMINANCE_ALPHA]:ce.FLOAT,[n.R8]:ce.FLOAT,[n.R8_SNORM]:ce.FLOAT,[n.RG8]:ce.FLOAT,[n.RG8_SNORM]:ce.FLOAT,[n.RGB8]:ce.FLOAT,[n.RGB8_SNORM]:ce.FLOAT,[n.RGB565]:ce.FLOAT,[n.RGBA4]:ce.FLOAT,[n.RGB5_A1]:ce.FLOAT,[n.RGBA8]:ce.FLOAT,[n.RGBA8_SNORM]:ce.FLOAT,[n.RGB10_A2]:ce.FLOAT,[n.RGB10_A2UI]:ce.FLOAT,[n.SRGB8]:ce.FLOAT,[n.SRGB8_ALPHA8]:ce.FLOAT,[n.R16F]:ce.FLOAT,[n.RG16F]:ce.FLOAT,[n.RGB16F]:ce.FLOAT,[n.RGBA16F]:ce.FLOAT,[n.R32F]:ce.FLOAT,[n.RG32F]:ce.FLOAT,[n.RGB32F]:ce.FLOAT,[n.RGBA32F]:ce.FLOAT,[n.R11F_G11F_B10F]:ce.FLOAT,[n.RGB9_E5]:ce.FLOAT,[n.R8I]:ce.INT,[n.R8UI]:ce.UINT,[n.R16I]:ce.INT,[n.R16UI]:ce.UINT,[n.R32I]:ce.INT,[n.R32UI]:ce.UINT,[n.RG8I]:ce.INT,[n.RG8UI]:ce.UINT,[n.RG16I]:ce.INT,[n.RG16UI]:ce.UINT,[n.RG32I]:ce.INT,[n.RG32UI]:ce.UINT,[n.RGB8I]:ce.INT,[n.RGB8UI]:ce.UINT,[n.RGB16I]:ce.INT,[n.RGB16UI]:ce.UINT,[n.RGB32I]:ce.INT,[n.RGB32UI]:ce.UINT,[n.RGBA8I]:ce.INT,[n.RGBA8UI]:ce.UINT,[n.RGBA16I]:ce.INT,[n.RGBA16UI]:ce.UINT,[n.RGBA32I]:ce.INT,[n.RGBA32UI]:ce.UINT,[n.DEPTH_COMPONENT16]:ce.FLOAT,[n.DEPTH_COMPONENT24]:ce.FLOAT,[n.DEPTH_COMPONENT32F]:ce.FLOAT,[n.DEPTH_STENCIL]:ce.FLOAT,[n.DEPTH24_STENCIL8]:ce.FLOAT,[n.DEPTH32F_STENCIL8]:ce.FLOAT}:e={[n.RGB]:ce.FLOAT,[n.RGBA]:ce.FLOAT,[n.ALPHA]:ce.FLOAT,[n.LUMINANCE]:ce.FLOAT,[n.LUMINANCE_ALPHA]:ce.FLOAT,[n.DEPTH_STENCIL]:ce.FLOAT},e}function gC(n){let e;return"WebGL2RenderingContext"in globalThis&&n instanceof globalThis.WebGL2RenderingContext?e={[Se.UNSIGNED_BYTE]:{[re.RGBA]:n.RGBA8,[re.RGB]:n.RGB8,[re.RG]:n.RG8,[re.RED]:n.R8,[re.RGBA_INTEGER]:n.RGBA8UI,[re.RGB_INTEGER]:n.RGB8UI,[re.RG_INTEGER]:n.RG8UI,[re.RED_INTEGER]:n.R8UI,[re.ALPHA]:n.ALPHA,[re.LUMINANCE]:n.LUMINANCE,[re.LUMINANCE_ALPHA]:n.LUMINANCE_ALPHA},[Se.BYTE]:{[re.RGBA]:n.RGBA8_SNORM,[re.RGB]:n.RGB8_SNORM,[re.RG]:n.RG8_SNORM,[re.RED]:n.R8_SNORM,[re.RGBA_INTEGER]:n.RGBA8I,[re.RGB_INTEGER]:n.RGB8I,[re.RG_INTEGER]:n.RG8I,[re.RED_INTEGER]:n.R8I},[Se.UNSIGNED_SHORT]:{[re.RGBA_INTEGER]:n.RGBA16UI,[re.RGB_INTEGER]:n.RGB16UI,[re.RG_INTEGER]:n.RG16UI,[re.RED_INTEGER]:n.R16UI,[re.DEPTH_COMPONENT]:n.DEPTH_COMPONENT16},[Se.SHORT]:{[re.RGBA_INTEGER]:n.RGBA16I,[re.RGB_INTEGER]:n.RGB16I,[re.RG_INTEGER]:n.RG16I,[re.RED_INTEGER]:n.R16I},[Se.UNSIGNED_INT]:{[re.RGBA_INTEGER]:n.RGBA32UI,[re.RGB_INTEGER]:n.RGB32UI,[re.RG_INTEGER]:n.RG32UI,[re.RED_INTEGER]:n.R32UI,[re.DEPTH_COMPONENT]:n.DEPTH_COMPONENT24},[Se.INT]:{[re.RGBA_INTEGER]:n.RGBA32I,[re.RGB_INTEGER]:n.RGB32I,[re.RG_INTEGER]:n.RG32I,[re.RED_INTEGER]:n.R32I},[Se.FLOAT]:{[re.RGBA]:n.RGBA32F,[re.RGB]:n.RGB32F,[re.RG]:n.RG32F,[re.RED]:n.R32F,[re.DEPTH_COMPONENT]:n.DEPTH_COMPONENT32F},[Se.HALF_FLOAT]:{[re.RGBA]:n.RGBA16F,[re.RGB]:n.RGB16F,[re.RG]:n.RG16F,[re.RED]:n.R16F},[Se.UNSIGNED_SHORT_5_6_5]:{[re.RGB]:n.RGB565},[Se.UNSIGNED_SHORT_4_4_4_4]:{[re.RGBA]:n.RGBA4},[Se.UNSIGNED_SHORT_5_5_5_1]:{[re.RGBA]:n.RGB5_A1},[Se.UNSIGNED_INT_2_10_10_10_REV]:{[re.RGBA]:n.RGB10_A2,[re.RGBA_INTEGER]:n.RGB10_A2UI},[Se.UNSIGNED_INT_10F_11F_11F_REV]:{[re.RGB]:n.R11F_G11F_B10F},[Se.UNSIGNED_INT_5_9_9_9_REV]:{[re.RGB]:n.RGB9_E5},[Se.UNSIGNED_INT_24_8]:{[re.DEPTH_STENCIL]:n.DEPTH24_STENCIL8},[Se.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[re.DEPTH_STENCIL]:n.DEPTH32F_STENCIL8}}:e={[Se.UNSIGNED_BYTE]:{[re.RGBA]:n.RGBA,[re.RGB]:n.RGB,[re.ALPHA]:n.ALPHA,[re.LUMINANCE]:n.LUMINANCE,[re.LUMINANCE_ALPHA]:n.LUMINANCE_ALPHA},[Se.UNSIGNED_SHORT_5_6_5]:{[re.RGB]:n.RGB},[Se.UNSIGNED_SHORT_4_4_4_4]:{[re.RGBA]:n.RGBA},[Se.UNSIGNED_SHORT_5_5_5_1]:{[re.RGBA]:n.RGBA}},e}class Ym{constructor(e){this.renderer=e,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Fe,this.hasIntegerTextures=!1}contextChange(){const e=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=gC(e),this.samplerTypes=pC(e);const t=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=t;for(let r=0;r<t;r++)this.boundTextures[r]=null;this.emptyTextures={};const i=new qu(e.createTexture());e.bindTexture(e.TEXTURE_2D,i.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[e.TEXTURE_2D]=i,this.emptyTextures[e.TEXTURE_CUBE_MAP]=new qu(e.createTexture()),e.bindTexture(e.TEXTURE_CUBE_MAP,this.emptyTextures[e.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(e,t=0){const{gl:i}=this;if(e=e?.castToBaseTexture(),e?.valid&&!e.parentTextureArray){e.touched=this.renderer.textureGC.count;const r=e._glTextures[this.CONTEXT_UID]||this.initTexture(e);this.boundTextures[t]!==e&&(this.currentLocation!==t&&(this.currentLocation=t,i.activeTexture(i.TEXTURE0+t)),i.bindTexture(e.target,r.texture)),r.dirtyId!==e.dirtyId?(this.currentLocation!==t&&(this.currentLocation=t,i.activeTexture(i.TEXTURE0+t)),this.updateTexture(e)):r.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(e),this.boundTextures[t]=e}else this.currentLocation!==t&&(this.currentLocation=t,i.activeTexture(i.TEXTURE0+t)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[t]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let e=0;e<this.boundTextures.length;e++)this.boundTextures[e]=this.unknownTexture}unbind(e){const{gl:t,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let r=0;r<i.length;r++)i[r]===this.unknownTexture&&this.bind(null,r)}for(let r=0;r<i.length;r++)i[r]===e&&(this.currentLocation!==r&&(t.activeTexture(t.TEXTURE0+r),this.currentLocation=r),t.bindTexture(e.target,this.emptyTextures[e.target].texture),i[r]=null)}ensureSamplerType(e){const{boundTextures:t,hasIntegerTextures:i,CONTEXT_UID:r}=this;if(i)for(let s=e-1;s>=0;--s){const o=t[s];o&&o._glTextures[r].samplerType!==ce.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(e){const t=new qu(this.gl.createTexture());return t.dirtyId=-1,e._glTextures[this.CONTEXT_UID]=t,this.managedTextures.push(e),e.on("dispose",this.destroyTexture,this),t}initTextureType(e,t){var i;t.internalFormat=((i=this.internalFormats[e.type])==null?void 0:i[e.format])??e.format,t.samplerType=this.samplerTypes[t.internalFormat]??ce.FLOAT,this.webGLVersion===2&&e.type===Se.HALF_FLOAT?t.type=this.gl.HALF_FLOAT:t.type=e.type}updateTexture(e){var t;const i=e._glTextures[this.CONTEXT_UID];if(!i)return;const r=this.renderer;if(this.initTextureType(e,i),(t=e.resource)==null?void 0:t.upload(r,e,i))i.samplerType!==ce.FLOAT&&(this.hasIntegerTextures=!0);else{const s=e.realWidth,o=e.realHeight,a=r.gl;(i.width!==s||i.height!==o||i.dirtyId<0)&&(i.width=s,i.height=o,a.texImage2D(e.target,0,i.internalFormat,s,o,0,e.format,i.type,null))}e.dirtyStyleId!==i.dirtyStyleId&&this.updateTextureStyle(e),i.dirtyId=e.dirtyId}destroyTexture(e,t){const{gl:i}=this;if(e=e.castToBaseTexture(),e._glTextures[this.CONTEXT_UID]&&(this.unbind(e),i.deleteTexture(e._glTextures[this.CONTEXT_UID].texture),e.off("dispose",this.destroyTexture,this),delete e._glTextures[this.CONTEXT_UID],!t)){const r=this.managedTextures.indexOf(e);r!==-1&&ys(this.managedTextures,r,1)}}updateTextureStyle(e){var t;const i=e._glTextures[this.CONTEXT_UID];i&&((e.mipmap===$i.POW2||this.webGLVersion!==2)&&!e.isPowerOfTwo?i.mipmap=!1:i.mipmap=e.mipmap>=1,this.webGLVersion!==2&&!e.isPowerOfTwo?i.wrapMode=Gn.CLAMP:i.wrapMode=e.wrapMode,(t=e.resource)!=null&&t.style(this.renderer,e,i)||this.setStyle(e,i),i.dirtyStyleId=e.dirtyStyleId)}setStyle(e,t){const i=this.gl;if(t.mipmap&&e.mipmap!==$i.ON_MANUAL&&i.generateMipmap(e.target),i.texParameteri(e.target,i.TEXTURE_WRAP_S,t.wrapMode),i.texParameteri(e.target,i.TEXTURE_WRAP_T,t.wrapMode),t.mipmap){i.texParameteri(e.target,i.TEXTURE_MIN_FILTER,e.scaleMode===xn.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&e.anisotropicLevel>0&&e.scaleMode===xn.LINEAR){const s=Math.min(e.anisotropicLevel,i.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(e.target,r.TEXTURE_MAX_ANISOTROPY_EXT,s)}}else i.texParameteri(e.target,i.TEXTURE_MIN_FILTER,e.scaleMode===xn.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(e.target,i.TEXTURE_MAG_FILTER,e.scaleMode===xn.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Ym.extension={type:ue.RendererSystem,name:"texture"},Te.add(Ym);class qm{constructor(e){this.renderer=e}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(e){const{gl:t,CONTEXT_UID:i}=this,r=e._glTransformFeedbacks[i]||this.createGLTransformFeedback(e);t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(e,t){const{gl:i,renderer:r}=this;t&&r.shader.bind(t),i.beginTransformFeedback(e)}endTransformFeedback(){const{gl:e}=this;e.endTransformFeedback()}createGLTransformFeedback(e){const{gl:t,renderer:i,CONTEXT_UID:r}=this,s=t.createTransformFeedback();e._glTransformFeedbacks[r]=s,t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,s);for(let o=0;o<e.buffers.length;o++){const a=e.buffers[o];a&&(i.buffer.update(a),a._glBuffers[r].refCount++,t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[r].buffer||null))}return t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),e.disposeRunner.add(this),s}disposeTransformFeedback(e,t){const i=e._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;e.disposeRunner.remove(this);const s=this.renderer.buffer;if(s)for(let o=0;o<e.buffers.length;o++){const a=e.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!t&&s.dispose(a,t))}i&&(t||r.deleteTransformFeedback(i),delete e._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}qm.extension={type:ue.RendererSystem,name:"transformFeedback"},Te.add(qm);class $a{constructor(e){this.renderer=e}init(e){this.screen=new Ue(0,0,e.width,e.height),this.element=e.view||de.ADAPTER.createCanvas(),this.resolution=e.resolution||de.RESOLUTION,this.autoDensity=!!e.autoDensity}resizeView(e,t){this.element.width=Math.round(e*this.resolution),this.element.height=Math.round(t*this.resolution);const i=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=i,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",i,r),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(e){var t;e&&((t=this.element.parentNode)==null||t.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}$a.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},$a.extension={type:[ue.RendererSystem,ue.CanvasRendererSystem],name:"_view"},Te.add($a),de.PREFER_ENV=_r.WEBGL2,de.STRICT_TEXTURE_CACHE=!1,de.RENDER_OPTIONS={...qa.defaultOptions,...Ya.defaultOptions,...$a.defaultOptions,...Ja.defaultOptions},Object.defineProperties(de,{WRAP_MODE:{get(){return Fe.defaultOptions.wrapMode},set(n){We("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),Fe.defaultOptions.wrapMode=n}},SCALE_MODE:{get(){return Fe.defaultOptions.scaleMode},set(n){We("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),Fe.defaultOptions.scaleMode=n}},MIPMAP_TEXTURES:{get(){return Fe.defaultOptions.mipmap},set(n){We("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),Fe.defaultOptions.mipmap=n}},ANISOTROPIC_LEVEL:{get(){return Fe.defaultOptions.anisotropicLevel},set(n){We("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),Fe.defaultOptions.anisotropicLevel=n}},FILTER_RESOLUTION:{get(){return We("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),ni.defaultResolution},set(n){ni.defaultResolution=n}},FILTER_MULTISAMPLE:{get(){return We("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),ni.defaultMultisample},set(n){ni.defaultMultisample=n}},SPRITE_MAX_TEXTURES:{get(){return Cr.defaultMaxTextures},set(n){We("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Cr.defaultMaxTextures=n}},SPRITE_BATCH_SIZE:{get(){return Cr.defaultBatchSize},set(n){We("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Cr.defaultBatchSize=n}},CAN_UPLOAD_SAME_BUFFER:{get(){return Cr.canUploadSameBuffer},set(n){We("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Cr.canUploadSameBuffer=n}},GC_MODE:{get(){return Dr.defaultMode},set(n){We("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Dr.defaultMode=n}},GC_MAX_IDLE:{get(){return Dr.defaultMaxIdle},set(n){We("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Dr.defaultMaxIdle=n}},GC_MAX_CHECK_COUNT:{get(){return Dr.defaultCheckCountMax},set(n){We("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Dr.defaultCheckCountMax=n}},PRECISION_VERTEX:{get(){return An.defaultVertexPrecision},set(n){We("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),An.defaultVertexPrecision=n}},PRECISION_FRAGMENT:{get(){return An.defaultFragmentPrecision},set(n){We("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),An.defaultFragmentPrecision=n}}});var Mr=(n=>(n[n.INTERACTION=50]="INTERACTION",n[n.HIGH=25]="HIGH",n[n.NORMAL=0]="NORMAL",n[n.LOW=-25]="LOW",n[n.UTILITY=-50]="UTILITY",n))(Mr||{});class Zu{constructor(e,t=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=e,this.context=t,this.priority=i,this.once=r}match(e,t=null){return this.fn===e&&this.context===t}emit(e){this.fn&&(this.context?this.fn.call(this.context,e):this.fn(e));const t=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const t=this.next;return this.next=e?null:t,this.previous=null,t}}const Zm=class mi{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 Zu(null,null,1/0),this.deltaMS=1/mi.targetFPMS,this.elapsedMS=1/mi.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,t,i=Mr.NORMAL){return this._addListener(new Zu(e,t,i))}addOnce(e,t,i=Mr.NORMAL){return this._addListener(new Zu(e,t,i,!0))}_addListener(e){let t=this._head.next,i=this._head;if(!t)e.connect(i);else{for(;t;){if(e.priority>t.priority){e.connect(i);break}i=t,t=t.next}e.previous||e.connect(i)}return this._startIfPossible(),this}remove(e,t){let i=this._head.next;for(;i;)i.match(e,t)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const s=e-this._lastFrame|0;if(s<this._minElapsedMS)return;this._lastFrame=e-s%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*mi.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const t=Math.min(this.maxFPS,e),i=Math.min(Math.max(0,t)/1e3,mi.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){if(e===0)this._minElapsedMS=0;else{const t=Math.max(this.minFPS,e);this._minElapsedMS=1/(t/1e3)}}static get shared(){if(!mi._shared){const e=mi._shared=new mi;e.autoStart=!0,e._protected=!0}return mi._shared}static get system(){if(!mi._system){const e=mi._system=new mi;e.autoStart=!0,e._protected=!0}return mi._system}};Zm.targetFPMS=.06;let pi=Zm;Object.defineProperties(de,{TARGET_FPMS:{get(){return pi.targetFPMS},set(n){We("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),pi.targetFPMS=n}}});class Km{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,Mr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?pi.shared:new pi,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}Km.extension=ue.Application,Te.add(Km);const Qm=[];Te.handleByList(ue.Renderer,Qm);function Jm(n){for(const e of Qm)if(e.test(n))return new e(n);throw new Error("Unable to auto-detect a suitable renderer.")}var mC=`attribute vec2 aVertexPosition;
616
+ attribute vec2 aTextureCoord;
617
+
618
+ uniform mat3 projectionMatrix;
619
+
620
+ varying vec2 vTextureCoord;
621
+
622
+ void main(void)
623
+ {
624
+ gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
625
+ vTextureCoord = aTextureCoord;
626
+ }`,vC=`attribute vec2 aVertexPosition;
627
+
628
+ uniform mat3 projectionMatrix;
629
+
630
+ varying vec2 vTextureCoord;
631
+
632
+ uniform vec4 inputSize;
633
+ uniform vec4 outputFrame;
634
+
635
+ vec4 filterVertexPosition( void )
636
+ {
637
+ vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
638
+
639
+ return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
640
+ }
641
+
642
+ vec2 filterTextureCoord( void )
643
+ {
644
+ return aVertexPosition * (outputFrame.zw * inputSize.zw);
645
+ }
646
+
647
+ void main(void)
648
+ {
649
+ gl_Position = filterVertexPosition();
650
+ vTextureCoord = filterTextureCoord();
651
+ }
652
+ `;const yC=mC,$m=vC;class ev{constructor(e){this.renderer=e}contextChange(e){let t;if(this.renderer.context.webGLVersion===1){const i=e.getParameter(e.FRAMEBUFFER_BINDING);e.bindFramebuffer(e.FRAMEBUFFER,null),t=e.getParameter(e.SAMPLES),e.bindFramebuffer(e.FRAMEBUFFER,i)}else{const i=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING);e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),t=e.getParameter(e.SAMPLES),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,i)}t>=Tt.HIGH?this.multisample=Tt.HIGH:t>=Tt.MEDIUM?this.multisample=Tt.MEDIUM:t>=Tt.LOW?this.multisample=Tt.LOW:this.multisample=Tt.NONE}destroy(){}}ev.extension={type:ue.RendererSystem,name:"_multisample"},Te.add(ev);class _C{constructor(e){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class tv{constructor(e){this.renderer=e,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(e){const{gl:t,CONTEXT_UID:i}=this,r=e._glBuffers[i]||this.createGLBuffer(e);t.bindBuffer(e.type,r.buffer)}unbind(e){const{gl:t}=this;t.bindBuffer(e,null)}bindBufferBase(e,t){const{gl:i,CONTEXT_UID:r}=this;if(this.boundBufferBases[t]!==e){const s=e._glBuffers[r]||this.createGLBuffer(e);this.boundBufferBases[t]=e,i.bindBufferBase(i.UNIFORM_BUFFER,t,s.buffer)}}bindBufferRange(e,t,i){const{gl:r,CONTEXT_UID:s}=this;i=i||0;const o=e._glBuffers[s]||this.createGLBuffer(e);r.bindBufferRange(r.UNIFORM_BUFFER,t||0,o.buffer,i*256,256)}update(e){const{gl:t,CONTEXT_UID:i}=this,r=e._glBuffers[i]||this.createGLBuffer(e);if(e._updateID!==r.updateID)if(r.updateID=e._updateID,t.bindBuffer(e.type,r.buffer),r.byteLength>=e.data.byteLength)t.bufferSubData(e.type,0,e.data);else{const s=e.static?t.STATIC_DRAW:t.DYNAMIC_DRAW;r.byteLength=e.data.byteLength,t.bufferData(e.type,e.data,s)}}dispose(e,t){if(!this.managedBuffers[e.id])return;delete this.managedBuffers[e.id];const i=e._glBuffers[this.CONTEXT_UID],r=this.gl;e.disposeRunner.remove(this),i&&(t||r.deleteBuffer(i.buffer),delete e._glBuffers[this.CONTEXT_UID])}disposeAll(e){const t=Object.keys(this.managedBuffers);for(let i=0;i<t.length;i++)this.dispose(this.managedBuffers[t[i]],e)}createGLBuffer(e){const{CONTEXT_UID:t,gl:i}=this;return e._glBuffers[t]=new _C(i.createBuffer()),this.managedBuffers[e.id]=e,e.disposeRunner.add(this),e._glBuffers[t]}}tv.extension={type:ue.RendererSystem,name:"buffer"},Te.add(tv);class iv{constructor(e){this.renderer=e}render(e,t){const i=this.renderer;let r,s,o,a;if(t&&(r=t.renderTexture,s=t.clear,o=t.transform,a=t.skipUpdateTransform),this.renderingToScreen=!r,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(r||(this.lastObjectRendered=e),!a){const l=e.enableTempParent();e.updateTransform(),e.disableTempParent(l)}i.renderTexture.bind(r),i.batch.currentRenderer.start(),(s??i.background.clearBeforeRender)&&i.renderTexture.clear(),e.render(i),i.batch.currentRenderer.flush(),r&&(t.blit&&i.framebuffer.blit(),r.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}iv.extension={type:ue.RendererSystem,name:"objectRenderer"},Te.add(iv);const el=class Pc extends fC{constructor(e){super(),this.type=Xp.WEBGL,e=Object.assign({},de.RENDER_OPTIONS,e),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Ni({projectionMatrix:new at},!0);const t={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Pc.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(t),"useContextAlpha"in e&&(We("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),e.premultipliedAlpha=e.useContextAlpha&&e.useContextAlpha!=="notMultiplied",e.backgroundAlpha=e.useContextAlpha===!1?1:e.backgroundAlpha),this._plugin.rendererPlugins=Pc.__plugins,this.options=e,this.startup.run(this.options)}static test(e){return e!=null&&e.forceCanvas?!1:VA()}render(e,t){this.objectRenderer.render(e,t)}resize(e,t){this._view.resizeView(e,t)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(e=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:e}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(e){this._view.resolution=e,this.runners.resolutionChange.emit(e)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return We("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return We("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return We("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return We("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(e){We("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=e}get backgroundAlpha(){return We("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(e){We("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=e}get powerPreference(){return We("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(e,t){return this.textureGenerator.generateTexture(e,t)}};el.extension={type:ue.Renderer,priority:1},el.__plugins={},el.__systems={};let Ku=el;Te.handleByMap(ue.RendererPlugin,Ku.__plugins),Te.handleByMap(ue.RendererSystem,Ku.__systems),Te.add(Ku);class nv extends _o{constructor(e,t){const{width:i,height:r}=t||{};super(i,r),this.items=[],this.itemDirtyIds=[];for(let s=0;s<e;s++){const o=new Fe;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=e,this._load=null,this.baseTexture=null}initFromArray(e,t){for(let i=0;i<this.length;i++)e[i]&&(e[i].castToBaseTexture?this.addBaseTextureAt(e[i].castToBaseTexture(),i):e[i]instanceof _o?this.addResourceAt(e[i],i):this.addResourceAt(hm(e[i],t),i))}dispose(){for(let e=0,t=this.length;e<t;e++)this.items[e].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(e,t){if(!this.items[t])throw new Error(`Index ${t} is out of bounds`);return e.valid&&!this.valid&&this.resize(e.width,e.height),this.items[t].setResource(e),this}bind(e){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(e);for(let t=0;t<this.length;t++)this.items[t].parentTextureArray=e,this.items[t].on("update",e.update,e)}unbind(e){super.unbind(e);for(let t=0;t<this.length;t++)this.items[t].parentTextureArray=null,this.items[t].off("update",e.update,e)}load(){if(this._load)return this._load;const e=this.items.map(t=>t.resource).filter(t=>t).map(t=>t.load());return this._load=Promise.all(e).then(()=>{const{realWidth:t,realHeight:i}=this.items[0];return this.resize(t,i),this.update(),Promise.resolve(this)}),this._load}}class xC extends nv{constructor(e,t){const{width:i,height:r}=t||{};let s,o;Array.isArray(e)?(s=e,o=e.length):o=e,super(o,{width:i,height:r}),s&&this.initFromArray(s,t)}addBaseTextureAt(e,t){if(e.resource)this.addResourceAt(e.resource,t);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(e){super.bind(e),e.target=us.TEXTURE_2D_ARRAY}upload(e,t,i){const{length:r,itemDirtyIds:s,items:o}=this,{gl:a}=e;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,r,0,t.format,i.type,null);for(let l=0;l<r;l++){const h=o[l];s[l]<h.dirtyId&&(s[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,t.format,i.type,h.resource.source))}return!0}}class wC extends Rn{constructor(e){super(e)}static test(e){const{OffscreenCanvas:t}=globalThis;return t&&e instanceof t?!0:globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement}}const rv=class Io extends nv{constructor(e,t){const{width:i,height:r,autoLoad:s,linkBaseTexture:o}=t||{};if(e&&e.length!==Io.SIDES)throw new Error(`Invalid length. Got ${e.length}, expected 6`);super(6,{width:i,height:r});for(let a=0;a<Io.SIDES;a++)this.items[a].target=us.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,e&&this.initFromArray(e,t),s!==!1&&this.load()}bind(e){super.bind(e),e.target=us.TEXTURE_CUBE_MAP}addBaseTextureAt(e,t,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[t])throw new Error(`Index ${t} is out of bounds`);if(!this.linkBaseTexture||e.parentTextureArray||Object.keys(e._glTextures).length>0)if(e.resource)this.addResourceAt(e.resource,t);else throw new Error("CubeResource does not support copying of renderTexture.");else e.target=us.TEXTURE_CUBE_MAP_POSITIVE_X+t,e.parentTextureArray=this.baseTexture,this.items[t]=e;return e.valid&&!this.valid&&this.resize(e.realWidth,e.realHeight),this.items[t]=e,this}upload(e,t,i){const r=this.itemDirtyIds;for(let s=0;s<Io.SIDES;s++){const o=this.items[s];(r[s]<o.dirtyId||i.dirtyId<t.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(e,o,i),r[s]=o.dirtyId):r[s]<-1&&(e.gl.texImage2D(o.target,0,i.internalFormat,t.realWidth,t.realHeight,0,t.format,i.type,null),r[s]=-1))}return!0}static test(e){return Array.isArray(e)&&e.length===Io.SIDES}};rv.SIDES=6;let TC=rv;class xs extends Rn{constructor(e,t){t=t||{};let i,r,s;typeof e=="string"?(i=xs.EMPTY,r=e,s=!0):(i=e,r=null,s=!1),super(i),this.url=r,this.crossOrigin=t.crossOrigin??!0,this.alphaMode=typeof t.alphaMode=="number"?t.alphaMode:null,this.ownsImageBitmap=t.ownsImageBitmap??s,this._load=null,t.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(e,t)=>{if(this.url===null){e(this);return}try{const i=await de.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const r=await i.blob();if(this.destroyed)return;const s=await createImageBitmap(r,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===li.UNPACK?"premultiply":"none"});if(this.destroyed){s.close();return}this.source=s,this.update(),e(this)}catch(i){if(this.destroyed)return;t(i),this.onError.emit(i)}}),this._load)}upload(e,t,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(t.alphaMode=this.alphaMode),super.upload(e,t,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(e){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof e=="string"||e instanceof ImageBitmap)}static get EMPTY(){return xs._EMPTY=xs._EMPTY??de.ADAPTER.createCanvas(0,0),xs._EMPTY}}const Qu=class Al extends Rn{constructor(e,t){t=t||{},super(de.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=e,this.scale=t.scale||1,this._overrideWidth=t.width,this._overrideHeight=t.height,this._resolve=null,this._crossorigin=t.crossorigin,this._load=null,t.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(e=>{if(this._resolve=()=>{this.update(),e(this)},Al.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const e=new Image;Rn.crossOrigin(e,this.svg,this._crossorigin),e.src=this.svg,e.onerror=t=>{this._resolve&&(e.onerror=null,this.onError.emit(t))},e.onload=()=>{if(!this._resolve)return;const t=e.width,i=e.height;if(!t||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let r=t*this.scale,s=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(r=this._overrideWidth||this._overrideHeight/i*t,s=this._overrideHeight||this._overrideWidth/t*i),r=Math.round(r),s=Math.round(s);const o=this.source;o.width=r,o.height=s,o._pixiId=`canvas_${Tr()}`,o.getContext("2d").drawImage(e,0,0,t,i,0,0,r,s),this._resolve(),this._resolve=null}}static getSize(e){const t=Al.SVG_SIZE.exec(e),i={};return t&&(i[t[1]]=Math.round(parseFloat(t[3])),i[t[5]]=Math.round(parseFloat(t[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(e,t){return t==="svg"||typeof e=="string"&&e.startsWith("data:image/svg+xml")||typeof e=="string"&&Al.SVG_XML.test(e)}};Qu.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Qu.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Ju=Qu;class EC extends Rn{constructor(e){super(e)}static test(e){return!!globalThis.VideoFrame&&e instanceof globalThis.VideoFrame}}const $u=class Ic extends Rn{constructor(e,t){if(t=t||{},!(e instanceof HTMLVideoElement)){const i=document.createElement("video");t.autoLoad!==!1&&i.setAttribute("preload","auto"),t.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),t.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),t.loop===!0&&i.setAttribute("loop",""),t.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof e=="string"&&(e=[e]);const r=e[0].src||e[0];Rn.crossOrigin(i,r,t.crossorigin);for(let s=0;s<e.length;++s){const o=document.createElement("source");let{src:a,mime:l}=e[s];if(a=a||e[s],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),u=h.slice(h.lastIndexOf(".")+1);l=l||Ic.MIME_TYPES[u]||`video/${u}`}o.src=a,l&&(o.type=l),i.appendChild(o)}e=i}super(e),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,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._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()}update(e=0){if(!this.destroyed){if(this._updateFPS){const t=pi.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const e=this.source;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._load=new Promise((t,i)=>{this.valid?t(this):(this._resolve=t,this._reject=i,e.load())}),this._load}_onError(e){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.source;return!e.paused&&!e.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!t&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&e.play()}dispose(){this._configureAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(pi.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(pi.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(pi.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e,t){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement||Ic.TYPES.includes(t)}};$u.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],$u.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let sv=$u;Lu.push(xs,bm,wC,sv,EC,Ju,Ba,TC,xC);class tl{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(e){return this.minX>this.maxX||this.minY>this.maxY?Ue.EMPTY:(e=e||new Ue(0,0,1,1),e.x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY,e)}addPoint(e){this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y)}addPointMatrix(e,t){const{a:i,b:r,c:s,d:o,tx:a,ty:l}=e,h=i*t.x+s*t.y+a,u=r*t.x+o*t.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(e){let t=this.minX,i=this.minY,r=this.maxX,s=this.maxY,o=e[0],a=e[1];t=o<t?o:t,i=a<i?a:i,r=o>r?o:r,s=a>s?a:s,o=e[2],a=e[3],t=o<t?o:t,i=a<i?a:i,r=o>r?o:r,s=a>s?a:s,o=e[4],a=e[5],t=o<t?o:t,i=a<i?a:i,r=o>r?o:r,s=a>s?a:s,o=e[6],a=e[7],t=o<t?o:t,i=a<i?a:i,r=o>r?o:r,s=a>s?a:s,this.minX=t,this.minY=i,this.maxX=r,this.maxY=s}addFrame(e,t,i,r,s){this.addFrameMatrix(e.worldTransform,t,i,r,s)}addFrameMatrix(e,t,i,r,s){const o=e.a,a=e.b,l=e.c,h=e.d,u=e.tx,c=e.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,m=o*t+l*i+u,v=a*t+h*i+c;d=m<d?m:d,f=v<f?v:f,p=m>p?m:p,g=v>g?v:g,m=o*r+l*i+u,v=a*r+h*i+c,d=m<d?m:d,f=v<f?v:f,p=m>p?m:p,g=v>g?v:g,m=o*t+l*s+u,v=a*t+h*s+c,d=m<d?m:d,f=v<f?v:f,p=m>p?m:p,g=v>g?v:g,m=o*r+l*s+u,v=a*r+h*s+c,d=m<d?m:d,f=v<f?v:f,p=m>p?m:p,g=v>g?v:g,this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addVertexData(e,t,i){let r=this.minX,s=this.minY,o=this.maxX,a=this.maxY;for(let l=t;l<i;l+=2){const h=e[l],u=e[l+1];r=h<r?h:r,s=u<s?u:s,o=h>o?h:o,a=u>a?u:a}this.minX=r,this.minY=s,this.maxX=o,this.maxY=a}addVertices(e,t,i,r){this.addVerticesMatrix(e.worldTransform,t,i,r)}addVerticesMatrix(e,t,i,r,s=0,o=s){const a=e.a,l=e.b,h=e.c,u=e.d,c=e.tx,d=e.ty;let f=this.minX,p=this.minY,g=this.maxX,m=this.maxY;for(let v=i;v<r;v+=2){const _=t[v],y=t[v+1],w=a*_+h*y+c,R=u*y+l*_+d;f=Math.min(f,w-s),g=Math.max(g,w+s),p=Math.min(p,R-o),m=Math.max(m,R+o)}this.minX=f,this.minY=p,this.maxX=g,this.maxY=m}addBounds(e){const t=this.minX,i=this.minY,r=this.maxX,s=this.maxY;this.minX=e.minX<t?e.minX:t,this.minY=e.minY<i?e.minY:i,this.maxX=e.maxX>r?e.maxX:r,this.maxY=e.maxY>s?e.maxY:s}addBoundsMask(e,t){const i=e.minX>t.minX?e.minX:t.minX,r=e.minY>t.minY?e.minY:t.minY,s=e.maxX<t.maxX?e.maxX:t.maxX,o=e.maxY<t.maxY?e.maxY:t.maxY;if(i<=s&&r<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=r<l?r:l,this.maxX=s>h?s:h,this.maxY=o>u?o:u}}addBoundsMatrix(e,t){this.addFrameMatrix(t,e.minX,e.minY,e.maxX,e.maxY)}addBoundsArea(e,t){const i=e.minX>t.x?e.minX:t.x,r=e.minY>t.y?e.minY:t.y,s=e.maxX<t.x+t.width?e.maxX:t.x+t.width,o=e.maxY<t.y+t.height?e.maxY:t.y+t.height;if(i<=s&&r<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=r<l?r:l,this.maxX=s>h?s:h,this.maxY=o>u?o:u}}pad(e=0,t=e){this.isEmpty()||(this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t)}addFramePad(e,t,i,r,s,o){e-=s,t-=o,i+=s,r+=o,this.minX=this.minX<e?this.minX:e,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<t?this.minY:t,this.maxY=this.maxY>r?this.maxY:r}}class gt extends lo{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Uu,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new tl,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(e){const t=Object.keys(e);for(let i=0;i<t.length;++i){const r=t[i];Object.defineProperty(gt.prototype,r,Object.getOwnPropertyDescriptor(e,r))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(e,t){return e||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),t||(this._boundsRect||(this._boundsRect=new Ue),t=this._boundsRect),this._bounds.getRectangle(t)}getLocalBounds(e){e||(this._localBoundsRect||(this._localBoundsRect=new Ue),e=this._localBoundsRect),this._localBounds||(this._localBounds=new tl);const t=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=i?.worldAlpha??1,this.transform=this._tempDisplayObjectParent.transform;const r=this._bounds,s=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,e);return this.parent=i,this.transform=t,this._bounds=r,this._bounds.updateID+=this._boundsID-s,o}toGlobal(e,t,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(e,t)}toLocal(e,t,i,r){return t&&(e=t.toGlobal(e,i,r)),r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(e,i)}setParent(e){if(!e||!e.addChild)throw new Error("setParent: Argument must be a Container");return e.addChild(this),e}removeFromParent(){var e;(e=this.parent)==null||e.removeChild(this)}setTransform(e=0,t=0,i=1,r=1,s=0,o=0,a=0,l=0,h=0){return this.position.x=e,this.position.y=t,this.scale.x=i||1,this.scale.y=r||1,this.rotation=s,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(e){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new bC),this.tempDisplayObjectParent}enableTempParent(){const e=this.parent;return this.parent=this._tempDisplayObjectParent,e}disableTempParent(e){this.parent=e}get x(){return this.position.x}set x(e){this.transform.position.x=e}get y(){return this.position.y}set y(e){this.transform.position.y=e}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(e){this.transform.position.copyFrom(e)}get scale(){return this.transform.scale}set scale(e){this.transform.scale.copyFrom(e)}get pivot(){return this.transform.pivot}set pivot(e){this.transform.pivot.copyFrom(e)}get skew(){return this.transform.skew}set skew(e){this.transform.skew.copyFrom(e)}get rotation(){return this.transform.rotation}set rotation(e){this.transform.rotation=e}get angle(){return this.transform.rotation*vR}set angle(e){this.transform.rotation=e*yR}get zIndex(){return this._zIndex}set zIndex(e){this._zIndex!==e&&(this._zIndex=e,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let e=this;do{if(!e.visible)return!1;e=e.parent}while(e);return!0}get mask(){return this._mask}set mask(e){if(this._mask!==e){if(this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(t._maskRefCount--,t._maskRefCount===0&&(t.renderable=!0,t.isMask=!1))}if(this._mask=e,this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(t._maskRefCount===0&&(t.renderable=!1,t.isMask=!0),t._maskRefCount++)}}}}class bC extends gt{constructor(){super(...arguments),this.sortDirty=null}}gt.prototype.displayObjectUpdateTransform=gt.prototype.updateTransform;const SC=new at;function AC(n,e){return n.zIndex===e.zIndex?n._lastSortedIndex-e._lastSortedIndex:n.zIndex-e.zIndex}const ov=class Dc extends gt{constructor(){super(),this.children=[],this.sortableChildren=Dc.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(e){}addChild(...e){if(e.length>1)for(let t=0;t<e.length;t++)this.addChild(e[t]);else{const t=e[0];t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.push(t),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",t,this,this.children.length-1),t.emit("added",this)}return e[0]}addChildAt(e,t){if(t<0||t>this.children.length)throw new Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${this.children.length}`);return e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.splice(t,0,e),this._boundsID++,this.onChildrenChange(t),e.emit("added",this),this.emit("childAdded",e,this,t),e}swapChildren(e,t){if(e===t)return;const i=this.getChildIndex(e),r=this.getChildIndex(t);this.children[i]=t,this.children[r]=e,this.onChildrenChange(i<r?i:r)}getChildIndex(e){const t=this.children.indexOf(e);if(t===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return t}setChildIndex(e,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(e);ys(this.children,i,1),this.children.splice(t,0,e),this.onChildrenChange(t)}getChildAt(e){if(e<0||e>=this.children.length)throw new Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]}removeChild(...e){if(e.length>1)for(let t=0;t<e.length;t++)this.removeChild(e[t]);else{const t=e[0],i=this.children.indexOf(t);if(i===-1)return null;t.parent=null,t.transform._parentID=-1,ys(this.children,i,1),this._boundsID++,this.onChildrenChange(i),t.emit("removed",this),this.emit("childRemoved",t,this,i)}return e[0]}removeChildAt(e){const t=this.getChildAt(e);return t.parent=null,t.transform._parentID=-1,ys(this.children,e,1),this._boundsID++,this.onChildrenChange(e),t.emit("removed",this),this.emit("childRemoved",t,this,e),t}removeChildren(e=0,t=this.children.length){const i=e,r=t,s=r-i;let o;if(s>0&&s<=r){o=this.children.splice(i,s);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(e);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(s===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let e=!1;for(let t=0,i=this.children.length;t<i;++t){const r=this.children[t];r._lastSortedIndex=t,!e&&r.zIndex!==0&&(e=!0)}e&&this.children.length>1&&this.children.sort(AC),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let e=0,t=this.children.length;e<t;++e){const i=this.children[e];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let e=0;e<this.children.length;e++){const t=this.children[e];if(!(!t.visible||!t.renderable))if(t.calculateBounds(),t._mask){const i=t._mask.isMaskData?t._mask.maskObject:t._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(t._bounds,i._bounds)):this._bounds.addBounds(t._bounds)}else t.filterArea?this._bounds.addBoundsArea(t._bounds,t.filterArea):this._bounds.addBounds(t._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(e,t=!1){const i=super.getLocalBounds(e);if(!t)for(let r=0,s=this.children.length;r<s;++r){const o=this.children[r];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(e){const t=e.renderTexture.sourceFrame;if(!(t.width>0&&t.height>0))return;let i,r;this.cullArea?(i=this.cullArea,r=this.worldTransform):this._render!==Dc.prototype._render&&(i=this.getBounds(!0));const s=e.projection.transform;if(s&&(r?(r=SC.copyFrom(r),r.prepend(s)):r=s),i&&t.intersects(i,r))this._render(e);else if(this.cullArea)return;for(let o=0,a=this.children.length;o<a;++o){const l=this.children[o],h=l.cullable;l.cullable=h||!this.cullArea,l.render(e),l.cullable=h}}render(e){var t;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(t=this.filters)!=null&&t.length)this.renderAdvanced(e);else if(this.cullable)this._renderWithCulling(e);else{this._render(e);for(let i=0,r=this.children.length;i<r;++i)this.children[i].render(e)}}renderAdvanced(e){var t,i,r;const s=this.filters,o=this._mask;if(s){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<s.length;l++)s[l].enabled&&this._enabledFilters.push(s[l])}const a=s&&((t=this._enabledFilters)==null?void 0:t.length)||o&&(!o.isMaskData||o.enabled&&(o.autoDetect||o.type!==bt.NONE));if(a&&e.batch.flush(),s&&(i=this._enabledFilters)!=null&&i.length&&e.filter.push(this,this._enabledFilters),o&&e.mask.push(this,this._mask),this.cullable)this._renderWithCulling(e);else{this._render(e);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(e)}a&&e.batch.flush(),o&&e.mask.pop(this),s&&(r=this._enabledFilters)!=null&&r.length&&e.filter.pop()}_render(e){}destroy(e){super.destroy(),this.sortDirty=!1;const t=typeof e=="boolean"?e:e?.children,i=this.removeChildren(0,this.children.length);if(t)for(let r=0;r<i.length;++r)i[r].destroy(e)}get width(){return this.scale.x*this.getLocalBounds().width}set width(e){const t=this.getLocalBounds().width;t!==0?this.scale.x=e/t:this.scale.x=1,this._width=e}get height(){return this.scale.y*this.getLocalBounds().height}set height(e){const t=this.getLocalBounds().height;t!==0?this.scale.y=e/t:this.scale.y=1,this._height=e}};ov.defaultSortableChildren=!1;let ki=ov;ki.prototype.containerUpdateTransform=ki.prototype.updateTransform,Object.defineProperties(de,{SORTABLE_CHILDREN:{get(){return ki.defaultSortableChildren},set(n){We("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),ki.defaultSortableChildren=n}}});const So=new Ye,RC=new Uint16Array([0,1,2,0,2,3]);class ws extends ki{constructor(e){super(),this._anchor=new Sn(this._onAnchorUpdate,this,e?e.defaultAnchor.x:0,e?e.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new nt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=De.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=e||Ee.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=RC,this.pluginName="batch",this.isSprite=!0,this._roundPixels=de.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Vn(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Vn(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const e=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===e._updateID)return;this._textureID!==e._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=e._updateID;const t=this.transform.worldTransform,i=t.a,r=t.b,s=t.c,o=t.d,a=t.tx,l=t.ty,h=this.vertexData,u=e.trim,c=e.orig,d=this._anchor;let f=0,p=0,g=0,m=0;if(u?(p=u.x-d._x*c.width,f=p+u.width,m=u.y-d._y*c.height,g=m+u.height):(p=-d._x*c.width,f=p+c.width,m=-d._y*c.height,g=m+c.height),h[0]=i*p+s*m+a,h[1]=o*m+r*p+l,h[2]=i*f+s*m+a,h[3]=o*m+r*f+l,h[4]=i*f+s*g+a,h[5]=o*g+r*f+l,h[6]=i*p+s*g+a,h[7]=o*g+r*p+l,this._roundPixels){const v=de.RESOLUTION;for(let _=0;_<h.length;++_)h[_]=Math.round(h[_]*v)/v}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const e=this._texture,t=this.vertexTrimmedData,i=e.orig,r=this._anchor,s=this.transform.worldTransform,o=s.a,a=s.b,l=s.c,h=s.d,u=s.tx,c=s.ty,d=-r._x*i.width,f=d+i.width,p=-r._y*i.height,g=p+i.height;if(t[0]=o*d+l*p+u,t[1]=h*p+a*d+c,t[2]=o*f+l*p+u,t[3]=h*p+a*f+c,t[4]=o*f+l*g+u,t[5]=h*g+a*f+c,t[6]=o*d+l*g+u,t[7]=h*g+a*d+c,this._roundPixels){const m=de.RESOLUTION;for(let v=0;v<t.length;++v)t[v]=Math.round(t[v]*m)/m}}_render(e){this.calculateVertices(),e.batch.setObjectRenderer(e.plugins[this.pluginName]),e.plugins[this.pluginName].render(this)}_calculateBounds(){const e=this._texture.trim,t=this._texture.orig;!e||e.width===t.width&&e.height===t.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(e){return this.children.length===0?(this._localBounds||(this._localBounds=new tl),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),e||(this._localBoundsRect||(this._localBoundsRect=new Ue),e=this._localBoundsRect),this._localBounds.getRectangle(e)):super.getLocalBounds.call(this,e)}containsPoint(e){this.worldTransform.applyInverse(e,So);const t=this._texture.orig.width,i=this._texture.orig.height,r=-t*this.anchor.x;let s=0;return So.x>=r&&So.x<r+t&&(s=-i*this.anchor.y,So.y>=s&&So.y<s+i)}destroy(e){if(super.destroy(e),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof e=="boolean"?e:e?.texture){const t=typeof e=="boolean"?e:e?.baseTexture;this._texture.destroy(!!t)}this._texture=null}static from(e,t){const i=e instanceof Ee?e:Ee.from(e,t);return new ws(i)}set roundPixels(e){this._roundPixels!==e&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=e}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){const t=Vn(this.scale.x)||1;this.scale.x=t*e/this._texture.orig.width,this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){const t=Vn(this.scale.y)||1;this.scale.y=t*e/this._texture.orig.height,this._height=e}get anchor(){return this._anchor}set anchor(e){this._anchor.copyFrom(e)}get tint(){return this._tintColor.value}set tint(e){this._tintColor.setValue(e),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=e||Ee.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,e&&(e.baseTexture.valid?this._onTextureUpdate():e.once("update",this._onTextureUpdate,this)))}}const av=new at;gt.prototype._cacheAsBitmap=!1,gt.prototype._cacheData=null,gt.prototype._cacheAsBitmapResolution=null,gt.prototype._cacheAsBitmapMultisample=null;class CC{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(gt.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(n){n!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=n,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(n){n!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=n,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(n){if(this._cacheAsBitmap===n)return;this._cacheAsBitmap=n;let e;n?(this._cacheData||(this._cacheData=new CC),e=this._cacheData,e.originalRender=this.render,e.originalRenderCanvas=this.renderCanvas,e.originalUpdateTransform=this.updateTransform,e.originalCalculateBounds=this.calculateBounds,e.originalGetLocalBounds=this.getLocalBounds,e.originalDestroy=this.destroy,e.originalContainsPoint=this.containsPoint,e.originalMask=this._mask,e.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(e=this._cacheData,e.sprite&&this._destroyCachedDisplayObject(),this.render=e.originalRender,this.renderCanvas=e.originalRenderCanvas,this.calculateBounds=e.originalCalculateBounds,this.getLocalBounds=e.originalGetLocalBounds,this.destroy=e.originalDestroy,this.updateTransform=e.originalUpdateTransform,this.containsPoint=e.originalContainsPoint,this._mask=e.originalMask,this.filterArea=e.originalFilterArea)}}}),gt.prototype._renderCached=function(n){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(n),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(n))},gt.prototype._initCachedDisplayObject=function(n){var e,t;if((e=this._cacheData)!=null&&e.sprite)return;const i=this.alpha;this.alpha=1,n.batch.flush();const r=this.getLocalBounds(new Ue,!0);if((t=this.filters)!=null&&t.length){const p=this.filters[0].padding;r.pad(p)}const s=this.cacheAsBitmapResolution||n.resolution;r.ceil(s),r.width=Math.max(r.width,1/s),r.height=Math.max(r.height,1/s);const o=n.renderTexture.current,a=n.renderTexture.sourceFrame.clone(),l=n.renderTexture.destinationFrame.clone(),h=n.projection.transform,u=Pr.create({width:r.width,height:r.height,resolution:s,multisample:this.cacheAsBitmapMultisample??n.multisample}),c=`cacheAsBitmap_${Tr()}`;this._cacheData.textureCacheId=c,Fe.addToCache(u.baseTexture,c),Ee.addToCache(u,c);const d=this.transform.localTransform.copyTo(av).invert().translate(-r.x,-r.y);this.render=this._cacheData.originalRender,n.render(this,{renderTexture:u,clear:!0,transform:d,skipUpdateTransform:!1}),n.framebuffer.blit(),n.projection.transform=h,n.renderTexture.bind(o,a,l),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=i;const f=new ws(u);f.transform.worldTransform=this.transform.worldTransform,f.anchor.x=-(r.x/r.width),f.anchor.y=-(r.y/r.height),f.alpha=i,f._bounds=this._bounds,this._cacheData.sprite=f,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=f.containsPoint.bind(f)},gt.prototype._renderCachedCanvas=function(n){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(n),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(n))},gt.prototype._initCachedDisplayObjectCanvas=function(n){var e;if((e=this._cacheData)!=null&&e.sprite)return;const t=this.getLocalBounds(new Ue,!0),i=this.alpha;this.alpha=1;const r=n.canvasContext.activeContext,s=n._projTransform,o=this.cacheAsBitmapResolution||n.resolution;t.ceil(o),t.width=Math.max(t.width,1/o),t.height=Math.max(t.height,1/o);const a=Pr.create({width:t.width,height:t.height,resolution:o}),l=`cacheAsBitmap_${Tr()}`;this._cacheData.textureCacheId=l,Fe.addToCache(a.baseTexture,l),Ee.addToCache(a,l);const h=av;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=t.x,h.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,n.render(this,{renderTexture:a,clear:!0,transform:h,skipUpdateTransform:!1}),n.canvasContext.activeContext=r,n._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=i;const u=new ws(a);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(t.x/t.width),u.anchor.y=-(t.y/t.height),u.alpha=i,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=n._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=u.containsPoint.bind(u)},gt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},gt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},gt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,Fe.removeFromCache(this._cacheData.textureCacheId),Ee.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},gt.prototype._cacheAsBitmapDestroy=function(n){this.cacheAsBitmap=!1,this.destroy(n)},gt.prototype.name=null,ki.prototype.getChildByName=function(n,e){for(let t=0,i=this.children.length;t<i;t++)if(this.children[t].name===n)return this.children[t];if(e)for(let t=0,i=this.children.length;t<i;t++){const r=this.children[t];if(!r.getChildByName)continue;const s=r.getChildByName(n,!0);if(s)return s}return null},gt.prototype.getGlobalPosition=function(n=new Ye,e=!1){return this.parent?this.parent.toGlobal(this.position,n,e):(n.x=this.position.x,n.y=this.position.y),n};var PC=`varying vec2 vTextureCoord;
653
+
654
+ uniform sampler2D uSampler;
655
+ uniform float uAlpha;
656
+
657
+ void main(void)
658
+ {
659
+ gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
660
+ }
661
+ `;class IC extends ni{constructor(e=1){super(yC,PC,{uAlpha:1}),this.alpha=e}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}}const DC={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},MC=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
662
+ `);function OC(n){const e=DC[n],t=e.length;let i=MC,r="";const s="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<n;a++){let l=s.replace("%index%",a.toString());o=a,a>=t&&(o=n-a-1),l=l.replace("%value%",e[o].toString()),r+=l,r+=`
663
+ `}return i=i.replace("%blur%",r),i=i.replace("%size%",n.toString()),i}const LC=`
664
+ attribute vec2 aVertexPosition;
665
+
666
+ uniform mat3 projectionMatrix;
667
+
668
+ uniform float strength;
669
+
670
+ varying vec2 vBlurTexCoords[%size%];
671
+
672
+ uniform vec4 inputSize;
673
+ uniform vec4 outputFrame;
674
+
675
+ vec4 filterVertexPosition( void )
676
+ {
677
+ vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
678
+
679
+ return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
680
+ }
681
+
682
+ vec2 filterTextureCoord( void )
683
+ {
684
+ return aVertexPosition * (outputFrame.zw * inputSize.zw);
685
+ }
686
+
687
+ void main(void)
688
+ {
689
+ gl_Position = filterVertexPosition();
690
+
691
+ vec2 textureCoord = filterTextureCoord();
692
+ %blur%
693
+ }`;function BC(n,e){const t=Math.ceil(n/2);let i=LC,r="",s;e?s="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":s="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<n;o++){let a=s.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(t-1)}.0`),r+=a,r+=`
694
+ `}return i=i.replace("%blur%",r),i=i.replace("%size%",n.toString()),i}class ec extends ni{constructor(e,t=8,i=4,r=ni.defaultResolution,s=5){const o=BC(s,e),a=OC(s);super(o,a),this.horizontal=e,this.resolution=r,this._quality=0,this.quality=i,this.blur=t}apply(e,t,i,r){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/t.width):this.uniforms.strength=1/i.height*(i.height/t.height):this.horizontal?this.uniforms.strength=1/e.renderer.width*(e.renderer.width/t.width):this.uniforms.strength=1/e.renderer.height*(e.renderer.height/t.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)e.applyFilter(this,t,i,r);else{const s=e.getFilterTexture(),o=e.renderer;let a=t,l=s;this.state.blend=!1,e.applyFilter(this,a,l,en.CLEAR);for(let h=1;h<this.passes-1;h++){e.bindAndClear(a,en.BLIT),this.uniforms.uSampler=l;const u=l;l=a,a=u,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,e.applyFilter(this,l,i,r),e.returnFilterTexture(s)}}get blur(){return this.strength}set blur(e){this.padding=1+Math.abs(e)*2,this.strength=e}get quality(){return this._quality}set quality(e){this._quality=e,this.passes=e}}class FC extends ni{constructor(e=8,t=4,i=ni.defaultResolution,r=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new ec(!0,e,t,i,r),this.blurYFilter=new ec(!1,e,t,i,r),this.resolution=i,this.quality=t,this.blur=e,this.repeatEdgePixels=!1}apply(e,t,i,r){const s=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(s&&o){const a=e.getFilterTexture();this.blurXFilter.apply(e,t,a,en.CLEAR),this.blurYFilter.apply(e,a,i,r),e.returnFilterTexture(a)}else o?this.blurYFilter.apply(e,t,i,r):this.blurXFilter.apply(e,t,i,r)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(e){this.blurXFilter.blur=this.blurYFilter.blur=e,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(e){this.blurXFilter.quality=this.blurYFilter.quality=e}get blurX(){return this.blurXFilter.blur}set blurX(e){this.blurXFilter.blur=e,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(e){this.blurYFilter.blur=e,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(e){this.blurYFilter.blendMode=e}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(e){this._repeatEdgePixels=e,this.updatePadding()}}var NC=`varying vec2 vTextureCoord;
695
+ uniform sampler2D uSampler;
696
+ uniform float m[20];
697
+ uniform float uAlpha;
698
+
699
+ void main(void)
700
+ {
701
+ vec4 c = texture2D(uSampler, vTextureCoord);
702
+
703
+ if (uAlpha == 0.0) {
704
+ gl_FragColor = c;
705
+ return;
706
+ }
707
+
708
+ // Un-premultiply alpha before applying the color matrix. See issue #3539.
709
+ if (c.a > 0.0) {
710
+ c.rgb /= c.a;
711
+ }
712
+
713
+ vec4 result;
714
+
715
+ result.r = (m[0] * c.r);
716
+ result.r += (m[1] * c.g);
717
+ result.r += (m[2] * c.b);
718
+ result.r += (m[3] * c.a);
719
+ result.r += m[4];
720
+
721
+ result.g = (m[5] * c.r);
722
+ result.g += (m[6] * c.g);
723
+ result.g += (m[7] * c.b);
724
+ result.g += (m[8] * c.a);
725
+ result.g += m[9];
726
+
727
+ result.b = (m[10] * c.r);
728
+ result.b += (m[11] * c.g);
729
+ result.b += (m[12] * c.b);
730
+ result.b += (m[13] * c.a);
731
+ result.b += m[14];
732
+
733
+ result.a = (m[15] * c.r);
734
+ result.a += (m[16] * c.g);
735
+ result.a += (m[17] * c.b);
736
+ result.a += (m[18] * c.a);
737
+ result.a += m[19];
738
+
739
+ vec3 rgb = mix(c.rgb, result.rgb, uAlpha);
740
+
741
+ // Premultiply alpha again.
742
+ rgb *= result.a;
743
+
744
+ gl_FragColor = vec4(rgb, result.a);
745
+ }
746
+ `;class tc extends ni{constructor(){const e={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super($m,NC,e),this.alpha=1}_loadMatrix(e,t=!1){let i=e;t&&(this._multiply(i,this.uniforms.m,e),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(e,t,i){return e[0]=t[0]*i[0]+t[1]*i[5]+t[2]*i[10]+t[3]*i[15],e[1]=t[0]*i[1]+t[1]*i[6]+t[2]*i[11]+t[3]*i[16],e[2]=t[0]*i[2]+t[1]*i[7]+t[2]*i[12]+t[3]*i[17],e[3]=t[0]*i[3]+t[1]*i[8]+t[2]*i[13]+t[3]*i[18],e[4]=t[0]*i[4]+t[1]*i[9]+t[2]*i[14]+t[3]*i[19]+t[4],e[5]=t[5]*i[0]+t[6]*i[5]+t[7]*i[10]+t[8]*i[15],e[6]=t[5]*i[1]+t[6]*i[6]+t[7]*i[11]+t[8]*i[16],e[7]=t[5]*i[2]+t[6]*i[7]+t[7]*i[12]+t[8]*i[17],e[8]=t[5]*i[3]+t[6]*i[8]+t[7]*i[13]+t[8]*i[18],e[9]=t[5]*i[4]+t[6]*i[9]+t[7]*i[14]+t[8]*i[19]+t[9],e[10]=t[10]*i[0]+t[11]*i[5]+t[12]*i[10]+t[13]*i[15],e[11]=t[10]*i[1]+t[11]*i[6]+t[12]*i[11]+t[13]*i[16],e[12]=t[10]*i[2]+t[11]*i[7]+t[12]*i[12]+t[13]*i[17],e[13]=t[10]*i[3]+t[11]*i[8]+t[12]*i[13]+t[13]*i[18],e[14]=t[10]*i[4]+t[11]*i[9]+t[12]*i[14]+t[13]*i[19]+t[14],e[15]=t[15]*i[0]+t[16]*i[5]+t[17]*i[10]+t[18]*i[15],e[16]=t[15]*i[1]+t[16]*i[6]+t[17]*i[11]+t[18]*i[16],e[17]=t[15]*i[2]+t[16]*i[7]+t[17]*i[12]+t[18]*i[17],e[18]=t[15]*i[3]+t[16]*i[8]+t[17]*i[13]+t[18]*i[18],e[19]=t[15]*i[4]+t[16]*i[9]+t[17]*i[14]+t[18]*i[19]+t[19],e}_colorMatrix(e){const t=new Float32Array(e);return t[4]/=255,t[9]/=255,t[14]/=255,t[19]/=255,t}brightness(e,t){const i=[e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0];this._loadMatrix(i,t)}tint(e,t){const[i,r,s]=nt.shared.setValue(e).toArray(),o=[i,0,0,0,0,0,r,0,0,0,0,0,s,0,0,0,0,0,1,0];this._loadMatrix(o,t)}greyscale(e,t){const i=[e,e,e,0,0,e,e,e,0,0,e,e,e,0,0,0,0,0,1,0];this._loadMatrix(i,t)}blackAndWhite(e){const t=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(t,e)}hue(e,t){e=(e||0)/180*Math.PI;const i=Math.cos(e),r=Math.sin(e),s=Math.sqrt,o=1/3,a=s(o),l=i+(1-i)*o,h=o*(1-i)-a*r,u=o*(1-i)+a*r,c=o*(1-i)+a*r,d=i+o*(1-i),f=o*(1-i)-a*r,p=o*(1-i)-a*r,g=o*(1-i)+a*r,m=i+o*(1-i),v=[l,h,u,0,0,c,d,f,0,0,p,g,m,0,0,0,0,0,1,0];this._loadMatrix(v,t)}contrast(e,t){const i=(e||0)+1,r=-.5*(i-1),s=[i,0,0,0,r,0,i,0,0,r,0,0,i,0,r,0,0,0,1,0];this._loadMatrix(s,t)}saturate(e=0,t){const i=e*2/3+1,r=(i-1)*-.5,s=[i,r,r,0,0,r,i,r,0,0,r,r,i,0,0,0,0,0,1,0];this._loadMatrix(s,t)}desaturate(){this.saturate(-1)}negative(e){const t=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(t,e)}sepia(e){const t=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(t,e)}technicolor(e){const t=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(t,e)}polaroid(e){const t=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(t,e)}toBGR(e){const t=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(t,e)}kodachrome(e){const t=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(t,e)}browni(e){const t=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(t,e)}vintage(e){const t=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(t,e)}colorTone(e,t,i,r,s){e=e||.2,t=t||.15,i=i||16770432,r=r||3375104;const o=nt.shared,[a,l,h]=o.setValue(i).toArray(),[u,c,d]=o.setValue(r).toArray(),f=[.3,.59,.11,0,0,a,l,h,e,0,u,c,d,t,0,a-u,l-c,h-d,0,0];this._loadMatrix(f,s)}night(e,t){e=e||.1;const i=[e*-2,-e,0,0,0,-e,0,e,0,0,0,e,e*2,0,0,0,0,0,1,0];this._loadMatrix(i,t)}predator(e,t){const i=[11.224130630493164*e,-4.794486999511719*e,-2.8746118545532227*e,0*e,.40342438220977783*e,-3.6330697536468506*e,9.193157196044922*e,-2.951810836791992*e,0*e,-1.316135048866272*e,-3.2184197902679443*e,-4.2375030517578125*e,7.476448059082031*e,0*e,.8044459223747253*e,0,0,0,1,0];this._loadMatrix(i,t)}lsd(e){const t=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(t,e)}reset(){const e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(e,!1)}get matrix(){return this.uniforms.m}set matrix(e){this.uniforms.m=e}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}}tc.prototype.grayscale=tc.prototype.greyscale;var kC=`varying vec2 vFilterCoord;
747
+ varying vec2 vTextureCoord;
748
+
749
+ uniform vec2 scale;
750
+ uniform mat2 rotation;
751
+ uniform sampler2D uSampler;
752
+ uniform sampler2D mapSampler;
753
+
754
+ uniform highp vec4 inputSize;
755
+ uniform vec4 inputClamp;
756
+
757
+ void main(void)
758
+ {
759
+ vec4 map = texture2D(mapSampler, vFilterCoord);
760
+
761
+ map -= 0.5;
762
+ map.xy = scale * inputSize.zw * (rotation * map.xy);
763
+
764
+ gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
765
+ }
766
+ `,UC=`attribute vec2 aVertexPosition;
767
+
768
+ uniform mat3 projectionMatrix;
769
+ uniform mat3 filterMatrix;
770
+
771
+ varying vec2 vTextureCoord;
772
+ varying vec2 vFilterCoord;
773
+
774
+ uniform vec4 inputSize;
775
+ uniform vec4 outputFrame;
776
+
777
+ vec4 filterVertexPosition( void )
778
+ {
779
+ vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
780
+
781
+ return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
782
+ }
783
+
784
+ vec2 filterTextureCoord( void )
785
+ {
786
+ return aVertexPosition * (outputFrame.zw * inputSize.zw);
787
+ }
788
+
789
+ void main(void)
790
+ {
791
+ gl_Position = filterVertexPosition();
792
+ vTextureCoord = filterTextureCoord();
793
+ vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
794
+ }
795
+ `;class HC extends ni{constructor(e,t){const i=new at;e.renderable=!1,super(UC,kC,{mapSampler:e._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=e,this.maskMatrix=i,t==null&&(t=20),this.scale=new Ye(t,t)}apply(e,t,i,r){this.uniforms.filterMatrix=e.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const s=this.maskSprite.worldTransform,o=Math.sqrt(s.a*s.a+s.b*s.b),a=Math.sqrt(s.c*s.c+s.d*s.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=s.a/o,this.uniforms.rotation[1]=s.b/o,this.uniforms.rotation[2]=s.c/a,this.uniforms.rotation[3]=s.d/a),e.applyFilter(this,t,i,r)}get map(){return this.uniforms.mapSampler}set map(e){this.uniforms.mapSampler=e}}var zC=`varying vec2 v_rgbNW;
796
+ varying vec2 v_rgbNE;
797
+ varying vec2 v_rgbSW;
798
+ varying vec2 v_rgbSE;
799
+ varying vec2 v_rgbM;
800
+
801
+ varying vec2 vFragCoord;
802
+ uniform sampler2D uSampler;
803
+ uniform highp vec4 inputSize;
804
+
805
+
806
+ /**
807
+ Basic FXAA implementation based on the code on geeks3d.com with the
808
+ modification that the texture2DLod stuff was removed since it's
809
+ unsupported by WebGL.
810
+
811
+ --
812
+
813
+ From:
814
+ https://github.com/mitsuhiko/webgl-meincraft
815
+
816
+ Copyright (c) 2011 by Armin Ronacher.
817
+
818
+ Some rights reserved.
819
+
820
+ Redistribution and use in source and binary forms, with or without
821
+ modification, are permitted provided that the following conditions are
822
+ met:
823
+
824
+ * Redistributions of source code must retain the above copyright
825
+ notice, this list of conditions and the following disclaimer.
826
+
827
+ * Redistributions in binary form must reproduce the above
828
+ copyright notice, this list of conditions and the following
829
+ disclaimer in the documentation and/or other materials provided
830
+ with the distribution.
831
+
832
+ * The names of the contributors may not be used to endorse or
833
+ promote products derived from this software without specific
834
+ prior written permission.
835
+
836
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
837
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
838
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
839
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
840
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
841
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
842
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
843
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
844
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
845
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
846
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
847
+ */
848
+
849
+ #ifndef FXAA_REDUCE_MIN
850
+ #define FXAA_REDUCE_MIN (1.0/ 128.0)
851
+ #endif
852
+ #ifndef FXAA_REDUCE_MUL
853
+ #define FXAA_REDUCE_MUL (1.0 / 8.0)
854
+ #endif
855
+ #ifndef FXAA_SPAN_MAX
856
+ #define FXAA_SPAN_MAX 8.0
857
+ #endif
858
+
859
+ //optimized version for mobile, where dependent
860
+ //texture reads can be a bottleneck
861
+ vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP,
862
+ vec2 v_rgbNW, vec2 v_rgbNE,
863
+ vec2 v_rgbSW, vec2 v_rgbSE,
864
+ vec2 v_rgbM) {
865
+ vec4 color;
866
+ vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;
867
+ vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;
868
+ vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;
869
+ vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;
870
+ vec4 texColor = texture2D(tex, v_rgbM);
871
+ vec3 rgbM = texColor.xyz;
872
+ vec3 luma = vec3(0.299, 0.587, 0.114);
873
+ float lumaNW = dot(rgbNW, luma);
874
+ float lumaNE = dot(rgbNE, luma);
875
+ float lumaSW = dot(rgbSW, luma);
876
+ float lumaSE = dot(rgbSE, luma);
877
+ float lumaM = dot(rgbM, luma);
878
+ float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
879
+ float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
880
+
881
+ mediump vec2 dir;
882
+ dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
883
+ dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
884
+
885
+ float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
886
+ (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
887
+
888
+ float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
889
+ dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
890
+ max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
891
+ dir * rcpDirMin)) * inverseVP;
892
+
893
+ vec3 rgbA = 0.5 * (
894
+ texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
895
+ texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
896
+ vec3 rgbB = rgbA * 0.5 + 0.25 * (
897
+ texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +
898
+ texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);
899
+
900
+ float lumaB = dot(rgbB, luma);
901
+ if ((lumaB < lumaMin) || (lumaB > lumaMax))
902
+ color = vec4(rgbA, texColor.a);
903
+ else
904
+ color = vec4(rgbB, texColor.a);
905
+ return color;
906
+ }
907
+
908
+ void main() {
909
+
910
+ vec4 color;
911
+
912
+ color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
913
+
914
+ gl_FragColor = color;
915
+ }
916
+ `,GC=`
917
+ attribute vec2 aVertexPosition;
918
+
919
+ uniform mat3 projectionMatrix;
920
+
921
+ varying vec2 v_rgbNW;
922
+ varying vec2 v_rgbNE;
923
+ varying vec2 v_rgbSW;
924
+ varying vec2 v_rgbSE;
925
+ varying vec2 v_rgbM;
926
+
927
+ varying vec2 vFragCoord;
928
+
929
+ uniform vec4 inputSize;
930
+ uniform vec4 outputFrame;
931
+
932
+ vec4 filterVertexPosition( void )
933
+ {
934
+ vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
935
+
936
+ return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
937
+ }
938
+
939
+ void texcoords(vec2 fragCoord, vec2 inverseVP,
940
+ out vec2 v_rgbNW, out vec2 v_rgbNE,
941
+ out vec2 v_rgbSW, out vec2 v_rgbSE,
942
+ out vec2 v_rgbM) {
943
+ v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;
944
+ v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;
945
+ v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;
946
+ v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;
947
+ v_rgbM = vec2(fragCoord * inverseVP);
948
+ }
949
+
950
+ void main(void) {
951
+
952
+ gl_Position = filterVertexPosition();
953
+
954
+ vFragCoord = aVertexPosition * outputFrame.zw;
955
+
956
+ texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
957
+ }
958
+ `;class VC extends ni{constructor(){super(GC,zC)}}var WC=`precision highp float;
959
+
960
+ varying vec2 vTextureCoord;
961
+ varying vec4 vColor;
962
+
963
+ uniform float uNoise;
964
+ uniform float uSeed;
965
+ uniform sampler2D uSampler;
966
+
967
+ float rand(vec2 co)
968
+ {
969
+ return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
970
+ }
971
+
972
+ void main()
973
+ {
974
+ vec4 color = texture2D(uSampler, vTextureCoord);
975
+ float randomValue = rand(gl_FragCoord.xy * uSeed);
976
+ float diff = (randomValue - 0.5) * uNoise;
977
+
978
+ // Un-premultiply alpha before applying the color matrix. See issue #3539.
979
+ if (color.a > 0.0) {
980
+ color.rgb /= color.a;
981
+ }
982
+
983
+ color.r += diff;
984
+ color.g += diff;
985
+ color.b += diff;
986
+
987
+ // Premultiply alpha again.
988
+ color.rgb *= color.a;
989
+
990
+ gl_FragColor = color;
991
+ }
992
+ `;class jC extends ni{constructor(e=.5,t=Math.random()){super($m,WC,{uNoise:0,uSeed:0}),this.noise=e,this.seed=t}get noise(){return this.uniforms.uNoise}set noise(e){this.uniforms.uNoise=e}get seed(){return this.uniforms.uSeed}set seed(e){this.uniforms.uSeed=e}}const lv={AlphaFilter:IC,BlurFilter:FC,BlurFilterPass:ec,ColorMatrixFilter:tc,DisplacementFilter:HC,FXAAFilter:VC,NoiseFilter:jC};Object.entries(lv).forEach(([n,e])=>{Object.defineProperty(lv,n,{get(){return We("7.1.0",`filters.${n} has moved to ${n}`),e}})});class XC{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this.tickerAdded||!this.domElement||(pi.system.add(this.tickerUpdate,this,Mr.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(pi.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const e=this.events.rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY}))}tickerUpdate(e){this._deltaTime+=e,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const Xn=new XC;class Ao{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Ao.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Ye,this.page=new Ye,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,r,s){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class il extends Ao{constructor(){super(...arguments),this.client=new Ye,this.movement=new Ye,this.offset=new Ye,this.global=new Ye,this.screen=new Ye}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,i){return e.worldTransform.applyInverse(i||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,i,r,s,o,a,l,h,u,c,d,f,p,g){throw new Error("Method not implemented.")}}class Ui extends il{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Ts extends il{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ts.DOM_DELTA_PIXEL=0,Ts.DOM_DELTA_LINE=1,Ts.DOM_DELTA_PAGE=2;const YC=2048,qC=new Ye,ic=new Ye;class ZC{constructor(e){this.dispatch=new lo,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(e,t){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((i,r)=>i.priority-r.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let i=0,r=t.length;i<r;i++)t[i].fn(e);else console.warn(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){Xn.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",r=this[i](this.rootTarget,this.rootTarget.eventMode,qC.set(e,t),this.hitTestFn,this.hitPruneFn);return r&&r[0]}propagate(e,t){if(!e.target)return;const i=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let r=0,s=i.length-1;r<s;r++)if(e.currentTarget=i[r],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return;if(e.eventPhase=e.AT_TARGET,e.currentTarget=e.target,this.notifyTarget(e,t),!(e.propagationStopped||e.propagationImmediatelyStopped)){e.eventPhase=e.BUBBLING_PHASE;for(let r=i.length-2;r>=0;r--)if(e.currentTarget=i[r],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,i=this._allInteractiveElements){if(i.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const r=Array.isArray(t)?t:[t];for(let s=i.length-1;s>=0;s--)r.forEach(o=>{e.currentTarget=i[s],this.notifyTarget(e,o)})}propagationPath(e){const t=[e];for(let i=0;i<YC&&e!==this.rootTarget;i++){if(!e.parent)throw new Error("Cannot find propagation path to disconnected target");t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,i,r,s,o=!1){let a=!1;if(this._interactivePrune(e))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Xn.pauseUpdate=!1),e.interactiveChildren&&e.children){const u=e.children;for(let c=u.length-1;c>=0;c--){const d=u[c],f=this.hitTestMoveRecursive(d,this._isInteractive(t)?t:d.eventMode,i,r,s,o||s(e,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=e.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(e),f.push(e)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(t),h=e.isInteractive();return l&&h&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:a?this._hitElements:l&&!s(e,i)&&r(e,i)?h?[e]:[]:null}hitTestRecursive(e,t,i,r,s){if(this._interactivePrune(e)||s(e,i))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Xn.pauseUpdate=!1),e.interactiveChildren&&e.children){const l=e.children;for(let h=l.length-1;h>=0;h--){const u=l[h],c=this.hitTestRecursive(u,this._isInteractive(t)?t:u.eventMode,i,r,s);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=e.isInteractive();return(c.length>0||d)&&c.push(e),c}}}const o=this._isInteractive(t),a=e.isInteractive();return o&&r(e,i)?a?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!!(!e||e.isMask||!e.visible||!e.renderable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren||e.isMask)}hitPruneFn(e,t){var i;if(e.hitArea&&(e.worldTransform.applyInverse(t,ic),!e.hitArea.contains(ic.x,ic.y)))return!0;if(e._mask){const r=e._mask.isMaskData?e._mask.maskObject:e._mask;if(r&&!((i=r.containsPoint)!=null&&i.call(r,t)))return!0}return!1}hitTestFn(e,t){return e.eventMode==="passive"?!1:e.hitArea?!0:e.containsPoint?e.containsPoint(t):!1}notifyTarget(e,t){var i,r;t=t??e.type;const s=`on${t}`;(r=(i=e.currentTarget)[s])==null||r.call(i,e);const o=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this.notifyListeners(e,o),e.eventPhase===e.AT_TARGET&&this.notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof Ui)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),t.pointerType==="touch")this.dispatchEvent(t,"touchstart");else if(t.pointerType==="mouse"||t.pointerType==="pen"){const r=t.button===2;this.dispatchEvent(t,r?"rightdown":"mousedown")}const i=this.trackingData(e.pointerId);i.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){var t,i;if(!(e instanceof Ui)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const r=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const s=r.pointerType==="mouse"||r.pointerType==="pen",o=this.trackingData(e.pointerId),a=this.findMountedTarget(o.overTargets);if(((t=o.overTargets)==null?void 0:t.length)>0&&a!==r.target){const u=e.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(e,u,a);if(this.dispatchEvent(c,"pointerout"),s&&this.dispatchEvent(c,"mouseout"),!r.composedPath().includes(a)){const d=this.createPointerEvent(e,"pointerleave",a);for(d.eventPhase=d.AT_TARGET;d.target&&!r.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),s&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(c)}if(a!==r.target){const u=e.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(r,u);this.dispatchEvent(c,"pointerover"),s&&this.dispatchEvent(c,"mouseover");let d=a?.parent;for(;d&&d!==this.rootTarget.parent&&d!==r.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(r,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==a&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),s&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(c)}const l=[],h=this.enableGlobalMoveEvents??!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(r,"pointermove"),h&&l.push("globalpointermove"),r.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),h&&l.push("globaltouchmove")),s&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),h&&l.push("globalmousemove"),this.cursor=(i=r.target)==null?void 0:i.cursor),l.length>0&&this.all(r,l),this._allInteractiveElements.length=0,this._hitElements.length=0,o.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(e){var t;if(!(e instanceof Ui)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const i=this.trackingData(e.pointerId),r=this.createPointerEvent(e),s=r.pointerType==="mouse"||r.pointerType==="pen";this.dispatchEvent(r,"pointerover"),s&&this.dispatchEvent(r,"mouseover"),r.pointerType==="mouse"&&(this.cursor=(t=r.target)==null?void 0:t.cursor);const o=this.clonePointerEvent(r,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;i.overTargets=r.composedPath(),this.freeEvent(r),this.freeEvent(o)}mapPointerOut(e){if(!(e instanceof Ui)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const i=e.pointerType==="mouse"||e.pointerType==="pen",r=this.findMountedTarget(t.overTargets),s=this.createPointerEvent(e,"pointerout",r);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(e,"pointerleave",r);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;t.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof Ui)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),i=this.createPointerEvent(e);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const r=this.trackingData(e.pointerId),s=this.findMountedTarget(r.pressTargetsByButton[e.button]);let o=s;if(s&&!i.composedPath().includes(s)){let a=s;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete r.pressTargetsByButton[e.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,r.clicksByButton[e.button]||(r.clicksByButton[e.button]={clickCount:0,target:a.target,timeStamp:t});const l=r.clicksByButton[e.button];if(l.target===a.target&&t-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=t,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(e){if(!(e instanceof Ui)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.findMountedTarget(t.pressTargetsByButton[e.button]),r=this.createPointerEvent(e);if(i){let s=i;for(;s;)r.currentTarget=s,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch"?this.notifyTarget(r,"touchendoutside"):(r.pointerType==="mouse"||r.pointerType==="pen")&&this.notifyTarget(r,r.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(r)}mapWheel(e){if(!(e instanceof Ts)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let i=1;i<e.length&&e[i].parent===t;i++)t=e[i];return t}createPointerEvent(e,t,i){const r=this.allocateEvent(Ui);return this.copyPointerData(e,r),this.copyMouseData(e,r),this.copyData(e,r),r.nativeEvent=e.nativeEvent,r.originalEvent=e,r.target=i??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof t=="string"&&(r.type=t),r}createWheelEvent(e){const t=this.allocateEvent(Ts);return this.copyWheelData(e,t),this.copyMouseData(e,t),this.copyData(e,t),t.nativeEvent=e.nativeEvent,t.originalEvent=e,t.target=this.hitTest(t.global.x,t.global.y),t}clonePointerEvent(e,t){const i=this.allocateEvent(Ui);return i.nativeEvent=e.nativeEvent,i.originalEvent=e.originalEvent,this.copyPointerData(e,i),this.copyMouseData(e,i),this.copyData(e,i),i.target=e.target,i.path=e.composedPath().slice(),i.type=t??i.type,i}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof Ui&&t instanceof Ui&&(t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist)}copyMouseData(e,t){e instanceof il&&t instanceof il&&(t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.copyFrom(e.client),t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.copyFrom(e.movement),t.screen.copyFrom(e.screen),t.shiftKey=e.shiftKey,t.global.copyFrom(e.global))}copyData(e,t){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.detail=e.detail,t.view=e.view,t.which=e.which,t.layer.copyFrom(e.layer),t.page.copyFrom(e.page)}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[e]}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);const t=this.eventPool.get(e).pop()||new e(this);return t.eventPhase=t.NONE,t.currentTarget=null,t.path=null,t.target=null,t}freeEvent(e){if(e.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}notifyListeners(e,t){const i=e.currentTarget._events[t];if(i&&e.currentTarget.isInteractive())if("fn"in i)i.once&&e.currentTarget.removeListener(t,i.fn,void 0,!0),i.fn.call(i.context,e);else for(let r=0,s=i.length;r<s&&!e.propagationImmediatelyStopped;r++)i[r].once&&e.currentTarget.removeListener(t,i[r].fn,void 0,!0),i[r].fn.call(i[r].context,e)}}const KC=1,QC={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},nc=class Mc{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new ZC(null),Xn.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Ui(null),this.rootWheelEvent=new Ts(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Mc.defaultEventFeatures},{set:(t,i,r)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),t[i]=r,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{view:t,resolution:i}=this.renderer;this.setTargetElement(t),this.resolution=i,Mc._defaultEventMode=e.eventMode??"auto",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(e){e=e||"default";let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this.currentCursor===e)return;this.currentCursor=e;const i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.domElement.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.domElement.style,i);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this.rootPointerEvent}onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this.normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let i=0,r=t.length;i<r;i++){const s=t[i],o=this.bootstrapEvent(this.rootPointerEvent,s);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Xn.pointerMoved();const t=this.normalizeToPointerData(e);for(let i=0,r=t.length;i<r;i++){const s=this.bootstrapEvent(this.rootPointerEvent,t[i]);this.rootBoundary.mapEvent(s)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const i=t!==this.domElement?"outside":"",r=this.normalizeToPointerData(e);for(let s=0,o=r.length;s<o;s++){const a=this.bootstrapEvent(this.rootPointerEvent,r[s]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this.normalizeToPointerData(e);for(let i=0,r=t.length;i<r;i++){const s=this.bootstrapEvent(this.rootPointerEvent,t[i]);this.rootBoundary.mapEvent(s)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;const t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this.removeEvents(),this.domElement=e,Xn.domElement=e,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Xn.addTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;Xn.removeTickerListener();const e=this.domElement.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(e,t,i){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},s=1/this.resolution;e.x=(t-r.left)*(this.domElement.width/r.width)*s,e.y=(i-r.top)*(this.domElement.height/r.height)*s}normalizeToPointerData(e){const t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let i=0,r=e.changedTouches.length;i<r;i++){const s=e.changedTouches[i];typeof s.button>"u"&&(s.button=0),typeof s.buttons>"u"&&(s.buttons=1),typeof s.isPrimary>"u"&&(s.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof s.width>"u"&&(s.width=s.radiusX||1),typeof s.height>"u"&&(s.height=s.radiusY||1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="touch"),typeof s.pointerId>"u"&&(s.pointerId=s.identifier||0),typeof s.pressure>"u"&&(s.pressure=s.force||.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),typeof s.layerX>"u"&&(s.layerX=s.offsetX=s.clientX),typeof s.layerY>"u"&&(s.layerY=s.offsetY=s.clientY),s.isNormalized=!0,s.type=e.type,t.push(s)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const i=e;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=KC),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,t.push(i)}else t.push(e);return t}normalizeWheelEvent(e){const t=this.rootWheelEvent;return this.transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this.transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=QC[e.type]||e.type),e}transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};nc.extension={name:"events",type:[ue.RendererSystem,ue.CanvasRendererSystem]},nc.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let rc=nc;Te.add(rc);function hv(n){return n==="dynamic"||n==="static"}const JC={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??hv(rc.defaultEventMode)},set interactive(n){We("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=n,this.eventMode=n?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??rc.defaultEventMode},set eventMode(n){this._internalInteractive=hv(n),this._internalEventMode=n},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(n,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,r=typeof t=="object"?t.signal:void 0,s=typeof t=="object"?t.once===!0:!1,o=typeof e=="function"?void 0:e;n=i?`${n}capture`:n;const a=typeof e=="function"?e:e.handleEvent,l=this;r&&r.addEventListener("abort",()=>{l.off(n,a,o)}),s?l.once(n,a,o):l.on(n,a,o)},removeEventListener(n,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,r=typeof e=="function"?void 0:e;n=i?`${n}capture`:n,e=typeof e=="function"?e:e.handleEvent,this.off(n,e,r)},dispatchEvent(n){if(!(n instanceof Ao))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return n.defaultPrevented=!1,n.path=null,n.target=this,n.manager.dispatchEvent(n),!n.defaultPrevented}};gt.mixin(JC);const $C={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};gt.mixin($C);const eP=9,nl=100,tP=0,iP=0,uv=2,cv=1,nP=-1e3,rP=-1e3,sP=2;class dv{constructor(e){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(Tn.tablet||Tn.phone)&&this.createTouchHook();const t=document.createElement("div");t.style.width=`${nl}px`,t.style.height=`${nl}px`,t.style.position="absolute",t.style.top=`${tP}px`,t.style.left=`${iP}px`,t.style.zIndex=uv.toString(),this.div=t,this.renderer=e,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const e=document.createElement("button");e.style.width=`${cv}px`,e.style.height=`${cv}px`,e.style.position="absolute",e.style.top=`${nP}px`,e.style.left=`${rP}px`,e.style.zIndex=sP.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var e;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(e=this.renderer.view.parentNode)==null||e.appendChild(this.div))}deactivate(){var e;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(e=this.div.parentNode)==null||e.removeChild(this.div))}updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&e.isInteractive()&&(e._accessibleActive||this.addChild(e),e.renderId=this.renderId);const t=e.children;if(t)for(let i=0;i<t.length;i++)this.updateAccessibleObjects(t[i])}update(){const e=performance.now();if(Tn.android.device&&e<this.androidUpdateCount||(this.androidUpdateCount=e+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:t,y:i,width:r,height:s}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=r/o*l,u=s/a*l;let c=this.div;c.style.left=`${t}px`,c.style.top=`${i}px`,c.style.width=`${o}px`,c.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,ys(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{c=f._accessibleDiv;let p=f.hitArea;const g=f.worldTransform;f.hitArea?(c.style.left=`${(g.tx+p.x*g.a)*h}px`,c.style.top=`${(g.ty+p.y*g.d)*u}px`,c.style.width=`${p.width*g.a*h}px`,c.style.height=`${p.height*g.d*u}px`):(p=f.getBounds(),this.capHitArea(p),c.style.left=`${p.x*h}px`,c.style.top=`${p.y*u}px`,c.style.width=`${p.width*h}px`,c.style.height=`${p.height*u}px`,c.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(c.title=f.accessibleTitle),c.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&c.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==c.title||f.tabIndex!==c.tabIndex)&&(c.title=f.accessibleTitle,c.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(c))}}this.renderId++}updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this.renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}addChild(e){let t=this.pool.pop();t||(t=document.createElement("button"),t.style.width=`${nl}px`,t.style.height=`${nl}px`,t.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",t.style.position="absolute",t.style.zIndex=uv.toString(),t.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?t.setAttribute("aria-live","off"):t.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?t.setAttribute("aria-relevant","additions"):t.setAttribute("aria-relevant","text"),t.addEventListener("click",this._onClick.bind(this)),t.addEventListener("focus",this._onFocus.bind(this)),t.addEventListener("focusout",this._onFocusOut.bind(this))),t.style.pointerEvents=e.accessiblePointerEvents,t.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?t.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(t.title=`displayObject ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&t.setAttribute("aria-label",e.accessibleHint),this.debug&&this.updateDebugHTML(t),e._accessibleActive=!0,e._accessibleDiv=t,t.displayObject=e,this.children.push(e),this.div.appendChild(e._accessibleDiv),e._accessibleDiv.tabIndex=e.tabIndex}_dispatchEvent(e,t){const{displayObject:i}=e.target,r=this.renderer.events.rootBoundary,s=Object.assign(new Ao(r),{target:i});r.rootTarget=this.renderer.lastObjectRendered,t.forEach(o=>r.dispatchEvent(s,o))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode===eP&&this.activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}dv.extension={name:"accessibility",type:[ue.RendererPlugin,ue.CanvasRendererPlugin]},Te.add(dv);const fv=class Oc{constructor(e){this.stage=new ki,e=Object.assign({forceCanvas:!1},e),this.renderer=Jm(e),Oc._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render(this.stage)}get view(){var e;return(e=this.renderer)==null?void 0:e.view}get screen(){var e;return(e=this.renderer)==null?void 0:e.screen}destroy(e,t){const i=Oc._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};fv._plugins=[];let oP=fv;Te.handleByList(ue.Application,oP._plugins);class pv{static init(e){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let t,i;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:s}=this._resizeTo;t=r,i=s}this.renderer.resize(t,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}pv.extension=ue.Application,Te.add(pv);const gv={loader:ue.LoadParser,resolver:ue.ResolveParser,cache:ue.CacheParser,detection:ue.DetectionParser};Te.handle(ue.Asset,n=>{const e=n.ref;Object.entries(gv).filter(([t])=>!!e[t]).forEach(([t,i])=>Te.add(Object.assign(e[t],{extension:e[t].extension??i})))},n=>{const e=n.ref;Object.keys(gv).filter(t=>!!e[t]).forEach(t=>Te.remove(e[t]))});class aP{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<t;i++)e.push(this._assetList.pop());await this._loader.load(e),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(e){this._isActive!==e&&(this._isActive=e,e&&!this._isLoading&&this._next())}}function Es(n,e){if(Array.isArray(e)){for(const t of e)if(n.startsWith(`data:${t}`))return!0;return!1}return n.startsWith(`data:${e}`)}function Yn(n,e){const t=n.split("?")[0],i=Pt.extname(t).toLowerCase();return Array.isArray(e)?e.includes(i):i===e}const Hi=(n,e,t=!1)=>(Array.isArray(n)||(n=[n]),e?n.map(i=>typeof i=="string"||t?e(i):i):n),sc=(n,e)=>{const t=e.split("?")[1];return t&&(n+=`?${t}`),n};function mv(n,e,t,i,r){const s=e[t];for(let o=0;o<s.length;o++){const a=s[o];t<e.length-1?mv(n.replace(i[t],a),e,t+1,i,r):r.push(n.replace(i[t],a))}}function lP(n){const e=/\{(.*?)\}/g,t=n.match(e),i=[];if(t){const r=[];t.forEach(s=>{const o=s.substring(1,s.length-1).split(",");r.push(o)}),mv(n,r,0,t,i)}else i.push(n);return i}const rl=n=>!Array.isArray(n);class hP{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||console.warn(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const i=Hi(e);let r;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(t)){r=l.getCacheableAssets(i,t);break}}r||(r={},i.forEach(a=>{r[a]=t}));const s=Object.keys(r),o={cacheKeys:s,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),s.forEach(a=>{const l=r?r[a]:t;this._cache.has(a)&&this._cache.get(a)!==l&&console.warn("[Cache] already has key:",a),this._cache.set(a,r[a])}),t instanceof Ee){const a=t;i.forEach(l=>{a.baseTexture!==Ee.EMPTY.baseTexture&&Fe.addToCache(a.baseTexture,l),Ee.addToCache(a,l)})}}remove(e){if(!this._cacheMap.has(e)){console.warn(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(i=>{this._cache.delete(i)}),t.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Or=new hP;class uP{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,i)=>(this._parsersValidated=!1,e[t]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){const i={promise:null,parser:null};return i.promise=(async()=>{var r,s;let o=null,a=null;if(t.loadParser&&(a=this._parserHash[t.loadParser],a||console.warn(`[Assets] specified load parser "${t.loadParser}" not found while loading ${e}`)),!a){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&(r=h.test)!=null&&r.call(h,e,t,this)){a=h;break}}if(!a)return console.warn(`[Assets] ${e} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}o=await a.load(e,t,this),i.parser=a;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((s=h.testParse)==null?void 0:s.call(h,o,t,this))&&(o=await h.parse(o,t,this)||o,i.parser=h)}return o})(),i}async load(e,t){this._parsersValidated||this._validateParsers();let i=0;const r={},s=rl(e),o=Hi(e,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const u=Pt.toAbsolute(h.src);if(!r[h.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,h)),r[h.src]=await this.promiseCache[u].promise,t&&t(++i/a)}catch(c){throw delete this.promiseCache[u],delete r[h.src],new Error(`[Loader.load] Failed to load ${u}.
993
+ ${c}`)}});return await Promise.all(l),s?r[o[0].src]:r}async unload(e){const t=Hi(e,i=>({alias:[i],src:i})).map(async i=>{var r,s;const o=Pt.toAbsolute(i.src),a=this.promiseCache[o];if(a){const l=await a.promise;delete this.promiseCache[o],(s=(r=a.parser)==null?void 0:r.unload)==null||s.call(r,l,i,this)}});await Promise.all(t)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(e=>e.name).reduce((e,t)=>(e[t.name]&&console.warn(`[Assets] loadParser name conflict "${t.name}"`),{...e,[t.name]:t}),{})}}var zi=(n=>(n[n.Low=0]="Low",n[n.Normal=1]="Normal",n[n.High=2]="High",n))(zi||{});const cP=".json",dP="application/json",fP={extension:{type:ue.LoadParser,priority:zi.Low},name:"loadJson",test(n){return Es(n,dP)||Yn(n,cP)},async load(n){return await(await de.ADAPTER.fetch(n)).json()}};Te.add(fP);const pP=".txt",gP="text/plain",mP={name:"loadTxt",extension:{type:ue.LoadParser,priority:zi.Low},test(n){return Es(n,gP)||Yn(n,pP)},async load(n){return await(await de.ADAPTER.fetch(n)).text()}};Te.add(mP);const vP=["normal","bold","100","200","300","400","500","600","700","800","900"],yP=[".ttf",".otf",".woff",".woff2"],_P=["font/ttf","font/otf","font/woff","font/woff2"],xP=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function wP(n){const e=Pt.extname(n),t=Pt.basename(n,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1));let i=t.length>0;for(const s of t)if(!s.match(xP)){i=!1;break}let r=t.join(" ");return i||(r=`"${r.replace(/[\\"]/g,"\\$&")}"`),r}const TP=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function EP(n){return TP.test(n)?n:encodeURI(n)}const bP={extension:{type:ue.LoadParser,priority:zi.Low},name:"loadWebFont",test(n){return Es(n,_P)||Yn(n,yP)},async load(n,e){var t,i,r;const s=de.ADAPTER.getFontFaceSet();if(s){const o=[],a=((t=e.data)==null?void 0:t.family)??wP(n),l=((r=(i=e.data)==null?void 0:i.weights)==null?void 0:r.filter(u=>vP.includes(u)))??["normal"],h=e.data??{};for(let u=0;u<l.length;u++){const c=l[u],d=new FontFace(a,`url(${EP(n)})`,{...h,weight:c});await d.load(),s.add(d),o.push(d)}return o.length===1?o[0]:o}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(n){(Array.isArray(n)?n:[n]).forEach(e=>de.ADAPTER.getFontFaceSet().delete(e))}};Te.add(bP);const SP=`(function() {
994
+ "use strict";
995
+ const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
996
+ async function checkImageBitmap() {
997
+ try {
998
+ if (typeof createImageBitmap != "function")
999
+ return !1;
1000
+ const imageBlob = await (await fetch(WHITE_PNG)).blob(), imageBitmap = await createImageBitmap(imageBlob);
1001
+ return imageBitmap.width === 1 && imageBitmap.height === 1;
1002
+ } catch {
1003
+ return !1;
1004
+ }
1005
+ }
1006
+ checkImageBitmap().then((result) => {
1007
+ self.postMessage(result);
1008
+ });
1009
+ })();
1010
+ `;let bs=null,oc=class{constructor(){bs||(bs=URL.createObjectURL(new Blob([SP],{type:"application/javascript"}))),this.worker=new Worker(bs)}};oc.revokeObjectURL=function(){bs&&(URL.revokeObjectURL(bs),bs=null)};const AP=`(function() {
1011
+ "use strict";
1012
+ async function loadImageBitmap(url) {
1013
+ const response = await fetch(url);
1014
+ if (!response.ok)
1015
+ throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
1016
+ const imageBlob = await response.blob();
1017
+ return await createImageBitmap(imageBlob);
1018
+ }
1019
+ self.onmessage = async (event) => {
1020
+ try {
1021
+ const imageBitmap = await loadImageBitmap(event.data.data[0]);
1022
+ self.postMessage({
1023
+ data: imageBitmap,
1024
+ uuid: event.data.uuid,
1025
+ id: event.data.id
1026
+ }, [imageBitmap]);
1027
+ } catch (e) {
1028
+ self.postMessage({
1029
+ error: e,
1030
+ uuid: event.data.uuid,
1031
+ id: event.data.id
1032
+ });
1033
+ }
1034
+ };
1035
+ })();
1036
+ `;let Ss=null;class vv{constructor(){Ss||(Ss=URL.createObjectURL(new Blob([AP],{type:"application/javascript"}))),this.worker=new Worker(Ss)}}vv.revokeObjectURL=function(){Ss&&(URL.revokeObjectURL(Ss),Ss=null)};let yv=0,ac;class RP{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(e=>{const{worker:t}=new oc;t.addEventListener("message",i=>{t.terminate(),oc.revokeObjectURL(),e(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(e){return this._run("loadImageBitmap",[e])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){ac===void 0&&(ac=navigator.hardwareConcurrency||4);let e=this.workerPool.pop();return!e&&this._createdWorkers<ac&&(this._createdWorkers++,e=new vv().worker,e.addEventListener("message",t=>{this.complete(t.data),this.returnWorker(t.target),this.next()})),e}returnWorker(e){this.workerPool.push(e)}complete(e){e.error!==void 0?this.resolveHash[e.uuid].reject(e.error):this.resolveHash[e.uuid].resolve(e.data),this.resolveHash[e.uuid]=null}async _run(e,t){await this._initWorkers();const i=new Promise((r,s)=>{this.queue.push({id:e,arguments:t,resolve:r,reject:s})});return this.next(),i}next(){if(!this.queue.length)return;const e=this.getWorker();if(!e)return;const t=this.queue.pop(),i=t.id;this.resolveHash[yv]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:yv++,id:i})}}const _v=new RP;function Ro(n,e,t){n.resource.internal=!0;const i=new Ee(n),r=()=>{delete e.promiseCache[t],Or.has(t)&&Or.remove(t)};return i.baseTexture.once("destroyed",()=>{t in e.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),r())}),i.once("destroyed",()=>{n.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const CP=[".jpeg",".jpg",".png",".webp",".avif"],PP=["image/jpeg","image/png","image/webp","image/avif"];async function IP(n){const e=await de.ADAPTER.fetch(n);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${n}: ${e.status} ${e.statusText}`);const t=await e.blob();return await createImageBitmap(t)}const sl={name:"loadTextures",extension:{type:ue.LoadParser,priority:zi.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(n){return Es(n,PP)||Yn(n,CP)},async load(n,e,t){var i;const r=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;r?this.config.preferWorkers&&await _v.isImageBitmapSupported()?s=await _v.loadImageBitmap(n):s=await IP(n):s=await new Promise((l,h)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=n,u.complete?l(u):(u.onload=()=>l(u),u.onerror=c=>h(c))});const o={...e.data};o.resolution??(o.resolution=bn(n)),r&&((i=o.resourceOptions)==null?void 0:i.ownsImageBitmap)===void 0&&(o.resourceOptions={...o.resourceOptions},o.resourceOptions.ownsImageBitmap=!0);const a=new Fe(s,o);return a.resource.src=n,Ro(a,t,n)},unload(n){n.destroy(!0)}};Te.add(sl);const DP=".svg",MP="image/svg+xml",OP={extension:{type:ue.LoadParser,priority:zi.High},name:"loadSVG",test(n){return Es(n,MP)||Yn(n,DP)},async testParse(n){return Ju.test(n)},async parse(n,e,t){var i;const r=new Ju(n,(i=e?.data)==null?void 0:i.resourceOptions);await r.load();const s=new Fe(r,{resolution:bn(n),...e?.data});return s.resource.src=e.src,Ro(s,t,e.src)},async load(n,e){return(await de.ADAPTER.fetch(n)).text()},unload:sl.unload};Te.add(OP);const LP=[".mp4",".m4v",".webm",".ogv"],BP=["video/mp4","video/webm","video/ogg"],FP={name:"loadVideo",extension:{type:ue.LoadParser,priority:zi.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(n){return Es(n,BP)||Yn(n,LP)},async load(n,e,t){var i;let r;const s=await(await de.ADAPTER.fetch(n)).blob(),o=URL.createObjectURL(s);try{const a={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(i=e?.data)==null?void 0:i.resourceOptions,autoLoad:!0},l=new sv(o,a);await l.load();const h=new Fe(l,{alphaMode:await GA(),resolution:bn(n),...e?.data});h.resource.src=n,r=Ro(h,t,n),r.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(o)})}catch(a){throw URL.revokeObjectURL(o),a}return r},unload(n){n.destroy(!0)}};Te.add(FP);class NP{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(t[i])}`).join("&")}}getAlias(e){const{alias:t,name:i,src:r,srcs:s}=e;return Hi(t||i||r||s,o=>typeof o=="string"?o:Array.isArray(o)?o.map(a=>a?.src??a?.srcs??a):o!=null&&o.src||o!=null&&o.srcs?o.src??o.srcs:o,!0)}addManifest(e){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const i=[];Array.isArray(t)?t.forEach(r=>{const s=r.src??r.srcs,o=r.alias??r.name;let a;if(typeof o=="string"){const l=this._createBundleAssetId(e,o);i.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(e,h));i.push(...l),a=[...o,...l]}this.add({...r,alias:a,src:s})}):Object.keys(t).forEach(r=>{const s=[r,this._createBundleAssetId(e,r)];if(typeof t[r]=="string")this.add({alias:s,src:t[r]});else if(Array.isArray(t[r]))this.add({alias:s,src:t[r]});else{const o=t[r],a=o.src??o.srcs;this.add({...o,alias:s,src:Array.isArray(a)?a:[a]})}i.push(...s)}),this._bundles[e]=i}add(e,t,i,r,s){const o=[];typeof e=="string"||Array.isArray(e)&&typeof e[0]=="string"?(We("7.2.0",`Assets.add now uses an object instead of individual parameters.
1037
+ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:e,src:t,data:i,format:r,loadParser:s})):Array.isArray(e)?o.push(...e):o.push(e);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},Hi(o).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:f}=l;const p=Hi(h||u).map(v=>typeof v=="string"?lP(v):Array.isArray(v)?v:[v]),g=this.getAlias(l);Array.isArray(g)?g.forEach(a):a(g);const m=[];p.forEach(v=>{v.forEach(_=>{let y={};if(typeof _!="object"){y.src=_;for(let w=0;w<this._parsers.length;w++){const R=this._parsers[w];if(R.test(_)){y=R.parse(_);break}}}else c=_.data??c,d=_.format??d,f=_.loadParser??f,y={...y,..._};if(!g)throw new Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this.buildResolvedAsset(y,{aliases:g,data:c,format:d,loadParser:f}),m.push(y)})}),g.forEach(v=>{this._assetMap[v]=m})})}resolveBundle(e){const t=rl(e);e=Hi(e);const i={};return e.forEach(r=>{const s=this._bundles[r];if(s){const o=this.resolve(s),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(r,l)]=h}i[r]=a}}),t?i[e[0]]:i}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const i={};for(const r in t)i[r]=t[r].src;return i}return t.src}resolve(e){const t=rl(e);e=Hi(e);const i={};return e.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let s=this._assetMap[r];const o=s[0],a=this._getPreferredOrder(s);a?.priority.forEach(l=>{a.params[l].forEach(h=>{const u=s.filter(c=>c[l]?c[l]===h:!1);u.length&&(s=u)})}),this._resolverHash[r]=s[0]??o}else this._resolverHash[r]=this.buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),t?i[e[0]]:i}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const i=e[0],r=this._preferredOrder.find(s=>s.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}buildResolvedAsset(e,t){const{aliases:i,data:r,loadParser:s,format:o}=t;return(this._basePath||this._rootPath)&&(e.src=Pt.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=i??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...r||{},...e.data},e.loadParser=s??e.loadParser,e.format=o??e.format??Pt.extname(e.src).slice(1),e.srcs=e.src,e.name=e.alias,e}}class kP{constructor(){this._detections=[],this._initialized=!1,this.resolver=new NP,this.loader=new uP,this.cache=Or,this._backgroundLoader=new aP(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){var t,i;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let a=e.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const r=((t=e.texturePreference)==null?void 0:t.resolution)??1,s=typeof r=="number"?[r]:r,o=await this._detectFormats({preferredFormats:(i=e.texturePreference)==null?void 0:i.format,skipDetections:e.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:o,resolution:s}}),e.preferences&&this.setPreferences(e.preferences)}add(e,t,i,r,s){this.resolver.add(e,t,i,r,s)}async load(e,t){this._initialized||await this.init();const i=rl(e),r=Hi(e).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),s=this.resolver.resolve(r),o=await this._mapLoadToResolve(s,t);return i?o[r[0]]:o}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let i=!1;typeof e=="string"&&(i=!0,e=[e]);const r=this.resolver.resolveBundle(e),s={},o=Object.keys(r);let a=0,l=0;const h=()=>{t?.(++a/l)},u=o.map(c=>{const d=r[c];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{s[c]=f})});return await Promise.all(u),i?s[e[0]]:s}async backgroundLoad(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e=="string")return Or.get(e);const t={};for(let i=0;i<e.length;i++)t[i]=Or.get(e[i]);return t}async _mapLoadToResolve(e,t){const i=Object.values(e),r=Object.keys(e);this._backgroundLoader.active=!1;const s=await this.loader.load(i,t);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=s[a.src],u=[a.src];a.alias&&u.push(...a.alias),o[r[l]]=h,Or.set(u,h)}),o}async unload(e){this._initialized||await this.init();const t=Hi(e).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(t);await this._unloadFromResolved(i)}async unloadBundle(e){this._initialized||await this.init(),e=Hi(e);const t=this.resolver.resolveBundle(e),i=Object.keys(t).map(r=>this._unloadFromResolved(t[r]));await Promise.all(i)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach(i=>{Or.remove(i.src)}),await this.loader.unload(t)}async _detectFormats(e){let t=[];e.preferredFormats&&(t=Array.isArray(e.preferredFormats)?e.preferredFormats:[e.preferredFormats]);for(const i of e.detections)e.skipDetections||await i.test()?t=await i.add(t):e.skipDetections||(t=await i.remove(t));return t=t.filter((i,r)=>t.indexOf(i)===r),t}get detections(){return this._detections}get preferWorkers(){return sl.config.preferWorkers}set preferWorkers(e){We("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:e})}setPreferences(e){this.loader.parsers.forEach(t=>{t.config&&Object.keys(t.config).filter(i=>i in e).forEach(i=>{t.config[i]=e[i]})})}}const ol=new kP;Te.handleByList(ue.LoadParser,ol.loader.parsers).handleByList(ue.ResolveParser,ol.resolver.parsers).handleByList(ue.CacheParser,ol.cache.parsers).handleByList(ue.DetectionParser,ol.detections);const UP={extension:ue.CacheParser,test:n=>Array.isArray(n)&&n.every(e=>e instanceof Ee),getCacheableAssets:(n,e)=>{const t={};return n.forEach(i=>{e.forEach((r,s)=>{t[i+(s===0?"":s+1)]=r})}),t}};Te.add(UP);async function xv(n){if("Image"in globalThis)return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=n});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=await(await fetch(n)).blob();await createImageBitmap(e)}catch{return!1}return!0}return!1}const HP={extension:{type:ue.DetectionParser,priority:1},test:async()=>xv("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async n=>[...n,"avif"],remove:async n=>n.filter(e=>e!=="avif")};Te.add(HP);const zP={extension:{type:ue.DetectionParser,priority:0},test:async()=>xv("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async n=>[...n,"webp"],remove:async n=>n.filter(e=>e!=="webp")};Te.add(zP);const wv=["png","jpg","jpeg"],GP={extension:{type:ue.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async n=>[...n,...wv],remove:async n=>n.filter(e=>!wv.includes(e))};Te.add(GP);const VP="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function lc(n){return VP?!1:document.createElement("video").canPlayType(n)!==""}const WP={extension:{type:ue.DetectionParser,priority:0},test:async()=>lc("video/webm"),add:async n=>[...n,"webm"],remove:async n=>n.filter(e=>e!=="webm")};Te.add(WP);const jP={extension:{type:ue.DetectionParser,priority:0},test:async()=>lc("video/mp4"),add:async n=>[...n,"mp4","m4v"],remove:async n=>n.filter(e=>e!=="mp4"&&e!=="m4v")};Te.add(jP);const XP={extension:{type:ue.DetectionParser,priority:0},test:async()=>lc("video/ogg"),add:async n=>[...n,"ogv"],remove:async n=>n.filter(e=>e!=="ogv")};Te.add(XP);const YP={extension:ue.ResolveParser,test:sl.test,parse:n=>{var e;return{resolution:parseFloat(((e=de.RETINA_PREFIX.exec(n))==null?void 0:e[1])??"1"),format:Pt.extname(n).slice(1),src:n}}};Te.add(YP);var Vt=(n=>(n[n.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",n[n.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",n[n.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",n[n.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",n[n.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",n[n.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",n[n.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",n[n.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",n[n.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",n[n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",n[n.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",n[n.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",n[n.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",n[n.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",n[n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",n[n.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",n[n.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",n))(Vt||{});const al={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let an,As;function Tv(){As={bptc:an.getExtension("EXT_texture_compression_bptc"),astc:an.getExtension("WEBGL_compressed_texture_astc"),etc:an.getExtension("WEBGL_compressed_texture_etc"),s3tc:an.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:an.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:an.getExtension("WEBGL_compressed_texture_pvrtc")||an.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:an.getExtension("WEBGL_compressed_texture_etc1"),atc:an.getExtension("WEBGL_compressed_texture_atc")}}const qP={extension:{type:ue.DetectionParser,priority:2},test:async()=>{const n=de.ADAPTER.createCanvas().getContext("webgl");return n?(an=n,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async n=>{As||Tv();const e=[];for(const t in As)As[t]&&e.push(t);return[...e,...n]},remove:async n=>(As||Tv(),n.filter(e=>!(e in As)))};Te.add(qP);class ZP extends Ba{constructor(e,t={width:1,height:1,autoLoad:!0}){let i,r;typeof e=="string"?(i=e,r=new Uint8Array):(i=null,r=e),super(r,t),this.origin=i,this.buffer=r?new Ru(r):null,this._load=null,this.loaded=!1,this.origin!==null&&t.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(e){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(e=>e.blob()).then(e=>e.arrayBuffer()).then(e=>(this.data=new Uint32Array(e),this.buffer=new Ru(e),this.loaded=!0,this.onBlobLoaded(e),this.update(),this)),this._load)}}class Lr extends ZP{constructor(e,t){super(e,t),this.format=t.format,this.levels=t.levels||1,this._width=t.width,this._height=t.height,this._extension=Lr._formatToExtension(this.format),(t.levelBuffers||this.buffer)&&(this._levelBuffers=t.levelBuffers||Lr._createLevelBuffers(e instanceof Uint8Array?e:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(e,t,i){const r=e.gl;if(!e.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;r.pixelStorei(r.UNPACK_ALIGNMENT,4);for(let s=0,o=this.levels;s<o;s++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:u}=this._levelBuffers[s];r.compressedTexImage2D(r.TEXTURE_2D,a,this.format,l,h,0,u)}return!0}onBlobLoaded(){this._levelBuffers=Lr._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(e){if(e>=33776&&e<=33779)return"s3tc";if(e>=35916&&e<=35919)return"s3tc_sRGB";if(e>=37488&&e<=37497)return"etc";if(e>=35840&&e<=35843)return"pvrtc";if(e===36196)return"etc1";if(e===35986||e===35987||e===34798)return"atc";if(e>=36492&&e<=36495)return"bptc";if(e===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${e}`)}static _createLevelBuffers(e,t,i,r,s,o,a){const l=new Array(i);let h=e.byteOffset,u=o,c=a,d=u+r-1&~(r-1),f=c+s-1&~(s-1),p=d*f*al[t];for(let g=0;g<i;g++)l[g]={levelID:g,levelWidth:i>1?u:d,levelHeight:i>1?c:f,levelBuffer:new Uint8Array(e.buffer,h,p)},h+=p,u=u>>1||1,c=c>>1||1,d=u+r-1&~(r-1),f=c+s-1&~(s-1),p=d*f*al[t];return l}}const hc=4,ll=124,KP=32,Ev=20,QP=542327876,hl={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},JP={FOURCC:2},ul={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},$P=1,e2=2,t2=4,i2=64,n2=512,r2=131072,s2=827611204,o2=861165636,a2=894720068,l2=808540228,h2=4,u2={[s2]:Vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[o2]:Vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[a2]:Vt.COMPRESSED_RGBA_S3TC_DXT5_EXT},c2={70:Vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Vt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Vt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Vt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Vt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Vt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Vt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Vt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Vt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Vt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function d2(n){const e=new Uint32Array(n);if(e[0]!==QP)throw new Error("Invalid DDS file magic word");const t=new Uint32Array(n,0,ll/Uint32Array.BYTES_PER_ELEMENT),i=t[hl.HEIGHT],r=t[hl.WIDTH],s=t[hl.MIPMAP_COUNT],o=new Uint32Array(n,hl.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,KP/Uint32Array.BYTES_PER_ELEMENT),a=o[$P];if(a&t2){const l=o[JP.FOURCC];if(l!==l2){const _=u2[l],y=hc+ll,w=new Uint8Array(n,y);return[new Lr(w,{format:_,width:r,height:i,levels:s})]}const h=hc+ll,u=new Uint32Array(e.buffer,h,Ev/Uint32Array.BYTES_PER_ELEMENT),c=u[ul.DXGI_FORMAT],d=u[ul.RESOURCE_DIMENSION],f=u[ul.MISC_FLAG],p=u[ul.ARRAY_SIZE],g=c2[c];if(g===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(f===h2)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const m=new Array,v=hc+ll+Ev;if(p===1)m.push(new Uint8Array(n,v));else{const _=al[g];let y=0,w=r,R=i;for(let C=0;C<s;C++){const O=Math.max(1,w+3&-4),N=Math.max(1,R+3&-4),X=O*N*_;y+=X,w=w>>>1,R=R>>>1}let M=v;for(let C=0;C<p;C++)m.push(new Uint8Array(n,M,y)),M+=y}return m.map(_=>new Lr(_,{format:g,width:r,height:i,levels:s}))}throw a&i2?new Error("DDSParser does not support uncompressed texture data."):a&n2?new Error("DDSParser does not supported YUV uncompressed texture data."):a&r2?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&e2?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const bv=[171,75,84,88,32,49,49,187,13,10,26,10],f2=67305985,Gi={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},uc=64,Sv={[Se.UNSIGNED_BYTE]:1,[Se.UNSIGNED_SHORT]:2,[Se.INT]:4,[Se.UNSIGNED_INT]:4,[Se.FLOAT]:4,[Se.HALF_FLOAT]:8},p2={[re.RGBA]:4,[re.RGB]:3,[re.RG]:2,[re.RED]:1,[re.LUMINANCE]:1,[re.LUMINANCE_ALPHA]:2,[re.ALPHA]:1},g2={[Se.UNSIGNED_SHORT_4_4_4_4]:2,[Se.UNSIGNED_SHORT_5_5_5_1]:2,[Se.UNSIGNED_SHORT_5_6_5]:2};function m2(n,e,t=!1){const i=new DataView(e);if(!v2(n,i))return null;const r=i.getUint32(Gi.ENDIANNESS,!0)===f2,s=i.getUint32(Gi.GL_TYPE,r),o=i.getUint32(Gi.GL_FORMAT,r),a=i.getUint32(Gi.GL_INTERNAL_FORMAT,r),l=i.getUint32(Gi.PIXEL_WIDTH,r),h=i.getUint32(Gi.PIXEL_HEIGHT,r)||1,u=i.getUint32(Gi.PIXEL_DEPTH,r)||1,c=i.getUint32(Gi.NUMBER_OF_ARRAY_ELEMENTS,r)||1,d=i.getUint32(Gi.NUMBER_OF_FACES,r),f=i.getUint32(Gi.NUMBER_OF_MIPMAP_LEVELS,r),p=i.getUint32(Gi.BYTES_OF_KEY_VALUE_DATA,r);if(h===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const g=4,m=4,v=l+3&-4,_=h+3&-4,y=new Array(c);let w=l*h;s===0&&(w=v*_);let R;if(s!==0?Sv[s]?R=Sv[s]*p2[o]:R=g2[s]:R=al[a],R===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const M=t?_2(i,p,r):null;let C=w*R,O=l,N=h,X=v,q=_,L=uc+p;for(let S=0;S<f;S++){const I=i.getUint32(L,r);let B=L+4;for(let j=0;j<c;j++){let U=y[j];U||(U=y[j]=new Array(f)),U[S]={levelID:S,levelWidth:f>1||s!==0?O:X,levelHeight:f>1||s!==0?N:q,levelBuffer:new Uint8Array(e,B,C)},B+=C}L+=I+4,L=L%4!==0?L+4-L%4:L,O=O>>1||1,N=N>>1||1,X=O+g-1&-4,q=N+m-1&-4,C=X*q*R}return s!==0?{uncompressed:y.map(S=>{let I=S[0].levelBuffer,B=!1;return s===Se.FLOAT?I=new Float32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4):s===Se.UNSIGNED_INT?(B=!0,I=new Uint32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)):s===Se.INT&&(B=!0,I=new Int32Array(S[0].levelBuffer.buffer,S[0].levelBuffer.byteOffset,S[0].levelBuffer.byteLength/4)),{resource:new Ba(I,{width:S[0].levelWidth,height:S[0].levelHeight}),type:s,format:B?y2(o):o}}),kvData:M}:{compressed:y.map(S=>new Lr(null,{format:a,width:l,height:h,levels:f,levelBuffers:S})),kvData:M}}function v2(n,e){for(let t=0;t<bv.length;t++)if(e.getUint8(t)!==bv[t])return console.error(`${n} is not a valid *.ktx file!`),!1;return!0}function y2(n){switch(n){case re.RGBA:return re.RGBA_INTEGER;case re.RGB:return re.RGB_INTEGER;case re.RG:return re.RG_INTEGER;case re.RED:return re.RED_INTEGER;default:return n}}function _2(n,e,t){const i=new Map;let r=0;for(;r<e;){const s=n.getUint32(uc+r,t),o=uc+r+4,a=3-(s+3)%4;if(s===0||s>e-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<s&&n.getUint8(o+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const h=new TextDecoder().decode(new Uint8Array(n.buffer,o,l)),u=new DataView(n.buffer,o+l+1,s-l-1);i.set(h,u),r+=4+s+a}return i}const x2={extension:{type:ue.LoadParser,priority:zi.High},name:"loadDDS",test(n){return Yn(n,".dds")},async load(n,e,t){const i=await(await de.ADAPTER.fetch(n)).arrayBuffer(),r=d2(i).map(s=>{const o=new Fe(s,{mipmap:$i.OFF,alphaMode:li.NO_PREMULTIPLIED_ALPHA,resolution:bn(n),...e.data});return Ro(o,t,n)});return r.length===1?r[0]:r},unload(n){Array.isArray(n)?n.forEach(e=>e.destroy(!0)):n.destroy(!0)}};Te.add(x2);const w2={extension:{type:ue.LoadParser,priority:zi.High},name:"loadKTX",test(n){return Yn(n,".ktx")},async load(n,e,t){const i=await(await de.ADAPTER.fetch(n)).arrayBuffer(),{compressed:r,uncompressed:s,kvData:o}=m2(n,i),a=r??s,l={mipmap:$i.OFF,alphaMode:li.NO_PREMULTIPLIED_ALPHA,resolution:bn(n),...e.data},h=a.map(u=>{a===s&&Object.assign(l,{type:u.type,format:u.format});const c=u.resource??u,d=new Fe(c,l);return d.ktxKeyValueData=o,Ro(d,t,n)});return h.length===1?h[0]:h},unload(n){Array.isArray(n)?n.forEach(e=>e.destroy(!0)):n.destroy(!0)}};Te.add(w2);const T2=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],E2={extension:ue.ResolveParser,test:n=>{const e=Pt.extname(n).slice(1);return["basis","ktx","dds"].includes(e)},parse:n=>{var e,t;const i=n.split("."),r=i.pop();if(["ktx","dds"].includes(r)){const s=i.pop();if(T2.includes(s))return{resolution:parseFloat(((e=de.RETINA_PREFIX.exec(n))==null?void 0:e[1])??"1"),format:s,src:n}}return{resolution:parseFloat(((t=de.RETINA_PREFIX.exec(n))==null?void 0:t[1])??"1"),format:r,src:n}}};Te.add(E2);const cl=new Ue,b2=4,Av=class Do{constructor(e){this.renderer=e,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(e,t,i,r){const s=new Image;return s.src=await this.base64(e,t,i,r),s}async base64(e,t,i,r){const s=this.canvas(e,r);if(s.toBlob!==void 0)return new Promise((o,a)=>{s.toBlob(l=>{if(!l){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(l)},t,i)});if(s.toDataURL!==void 0)return s.toDataURL(t,i);if(s.convertToBlob!==void 0){const o=await s.convertToBlob({type:t,quality:i});return new Promise((a,l)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=l,h.readAsDataURL(o)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e,t){const{pixels:i,width:r,height:s,flipY:o,premultipliedAlpha:a}=this._rawPixels(e,t);o&&Do._flipY(i,r,s),a&&Do._unpremultiplyAlpha(i);const l=new rR(r,s,1),h=new ImageData(new Uint8ClampedArray(i.buffer),r,s);return l.context.putImageData(h,0,0),l.canvas}pixels(e,t){const{pixels:i,width:r,height:s,flipY:o,premultipliedAlpha:a}=this._rawPixels(e,t);return o&&Do._flipY(i,r,s),a&&Do._unpremultiplyAlpha(i),i}_rawPixels(e,t){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let r,s=!1,o=!1,a,l=!1;e&&(e instanceof Pr?a=e:(a=i.generateTexture(e,{region:t,resolution:i.resolution,multisample:i.multisample}),l=!0,t&&(cl.width=t.width,cl.height=t.height,t=cl)));const h=i.gl;if(a){if(r=a.baseTexture.resolution,t=t??a.frame,s=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===re.RGBA,!l){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else r=i.resolution,t||(t=cl,t.width=i.width/r,t.height=i.height/r),s=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(t.width*r),1),c=Math.max(Math.round(t.height*r),1),d=new Uint8Array(b2*u*c);return h.readPixels(Math.round(t.x*r),Math.round(t.y*r),u,c,h.RGBA,h.UNSIGNED_BYTE,d),l&&a?.destroy(!0),{pixels:d,width:u,height:c,flipY:s,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(e,t,i){const r=t<<2,s=i>>1,o=new Uint8Array(r);for(let a=0;a<s;a++){const l=a*r,h=(i-a-1)*r;o.set(e.subarray(l,l+r)),e.copyWithin(l,h,h+r),e.set(o,h)}}static _unpremultiplyAlpha(e){e instanceof Uint8ClampedArray&&(e=new Uint8Array(e.buffer));const t=e.length;for(let i=0;i<t;i+=4){const r=e[i+3];if(r!==0){const s=255.001/r;e[i]=e[i]*s+.5,e[i+1]=e[i+1]*s+.5,e[i+2]=e[i+2]*s+.5}}}};Av.extension={name:"extract",type:ue.RendererSystem};let S2=Av;Te.add(S2);const dl={build(n){const e=n.points;let t,i,r,s,o,a;if(n.type===Gt.CIRC){const p=n.shape;t=p.x,i=p.y,o=a=p.radius,r=s=0}else if(n.type===Gt.ELIP){const p=n.shape;t=p.x,i=p.y,o=p.width,a=p.height,r=s=0}else{const p=n.shape,g=p.width/2,m=p.height/2;t=p.x+g,i=p.y+m,o=a=Math.max(0,Math.min(p.radius,Math.min(g,m))),r=g-o,s=m-a}if(!(o>=0&&a>=0&&r>=0&&s>=0)){e.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(r?4:0)+(s?4:0);if(e.length=h,h===0)return;if(l===0){e.length=8,e[0]=e[6]=t+r,e[1]=e[3]=i+s,e[2]=e[4]=t-r,e[5]=e[7]=i-s;return}let u=0,c=l*4+(r?2:0)+2,d=c,f=h;{const p=r+o,g=s,m=t+p,v=t-p,_=i+g;if(e[u++]=m,e[u++]=_,e[--c]=_,e[--c]=v,s){const y=i-g;e[d++]=v,e[d++]=y,e[--f]=y,e[--f]=m}}for(let p=1;p<l;p++){const g=Math.PI/2*(p/l),m=r+Math.cos(g)*o,v=s+Math.sin(g)*a,_=t+m,y=t-m,w=i+v,R=i-v;e[u++]=_,e[u++]=w,e[--c]=w,e[--c]=y,e[d++]=y,e[d++]=R,e[--f]=R,e[--f]=_}{const p=r,g=s+a,m=t+p,v=t-p,_=i+g,y=i-g;e[u++]=m,e[u++]=_,e[--f]=y,e[--f]=m,r&&(e[u++]=v,e[u++]=_,e[--f]=y,e[--f]=v)}},triangulate(n,e){const t=n.points,i=e.points,r=e.indices;if(t.length===0)return;let s=i.length/2;const o=s;let a,l;if(n.type!==Gt.RREC){const u=n.shape;a=u.x,l=u.y}else{const u=n.shape;a=u.x+u.width/2,l=u.y+u.height/2}const h=n.matrix;i.push(n.matrix?h.a*a+h.c*l+h.tx:a,n.matrix?h.b*a+h.d*l+h.ty:l),s++,i.push(t[0],t[1]);for(let u=2;u<t.length;u+=2)i.push(t[u],t[u+1]),r.push(s++,o,s);r.push(o+1,o,s)}};function Rv(n,e=!1){const t=n.length;if(t<6)return;let i=0;for(let r=0,s=n[t-2],o=n[t-1];r<t;r+=2){const a=n[r],l=n[r+1];i+=(a-s)*(l+o),s=a,o=l}if(!e&&i>0||e&&i<=0){const r=t/2;for(let s=r+r%2;s<t;s+=2){const o=t-s-2,a=t-s-1,l=s,h=s+1;[n[o],n[l]]=[n[l],n[o]],[n[a],n[h]]=[n[h],n[a]]}}}const Cv={build(n){n.points=n.shape.points.slice()},triangulate(n,e){let t=n.points;const i=n.holes,r=e.points,s=e.indices;if(t.length>=6){Rv(t,!1);const o=[];for(let h=0;h<i.length;h++){const u=i[h];Rv(u.points,!0),o.push(t.length/2),t=t.concat(u.points)}const a=mS(t,o,2);if(!a)return;const l=r.length/2;for(let h=0;h<a.length;h+=3)s.push(a[h]+l),s.push(a[h+1]+l),s.push(a[h+2]+l);for(let h=0;h<t.length;h++)r.push(t[h])}}},A2={build(n){const e=n.shape,t=e.x,i=e.y,r=e.width,s=e.height,o=n.points;o.length=0,r>=0&&s>=0&&o.push(t,i,t+r,i,t+r,i+s,t,i+s)},triangulate(n,e){const t=n.points,i=e.points;if(t.length===0)return;const r=i.length/2;i.push(t[0],t[1],t[2],t[3],t[6],t[7],t[4],t[5]),e.indices.push(r,r+1,r+2,r+1,r+2,r+3)}},R2={build(n){dl.build(n)},triangulate(n,e){dl.triangulate(n,e)}};var Ci=(n=>(n.MITER="miter",n.BEVEL="bevel",n.ROUND="round",n))(Ci||{}),qn=(n=>(n.BUTT="butt",n.ROUND="round",n.SQUARE="square",n))(qn||{});const Rs={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(n,e=20){if(!this.adaptive||!n||isNaN(n))return e;let t=Math.ceil(n/this.maxLength);return t<this.minSegments?t=this.minSegments:t>this.maxSegments&&(t=this.maxSegments),t}};class Pv{static curveTo(e,t,i,r,s,o){const a=o[o.length-2],l=o[o.length-1]-t,h=a-e,u=r-t,c=i-e,d=Math.abs(l*c-h*u);if(d<1e-8||s===0)return(o[o.length-2]!==e||o[o.length-1]!==t)&&o.push(e,t),null;const f=l*l+h*h,p=u*u+c*c,g=l*u+h*c,m=s*Math.sqrt(f)/d,v=s*Math.sqrt(p)/d,_=m*g/f,y=v*g/p,w=m*c+v*h,R=m*u+v*l,M=h*(v+_),C=l*(v+_),O=c*(m+y),N=u*(m+y),X=Math.atan2(C-R,M-w),q=Math.atan2(N-R,O-w);return{cx:w+e,cy:R+t,radius:s,startAngle:X,endAngle:q,anticlockwise:h*u>c*l}}static arc(e,t,i,r,s,o,a,l,h){const u=a-o,c=Rs._segmentsCount(Math.abs(u)*s,Math.ceil(Math.abs(u)/Na)*40),d=u/(c*2),f=d*2,p=Math.cos(d),g=Math.sin(d),m=c-1,v=m%1/m;for(let _=0;_<=m;++_){const y=_+v*_,w=d+o+f*y,R=Math.cos(w),M=-Math.sin(w);h.push((p*R+g*M)*s+i,(p*-M+g*R)*s+r)}}}class C2{constructor(){this.reset()}begin(e,t,i){this.reset(),this.style=e,this.start=t,this.attribStart=i}end(e,t){this.attribSize=t-this.attribStart,this.size=e-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class cc{static curveLength(e,t,i,r,s,o,a,l){let h=0,u=0,c=0,d=0,f=0,p=0,g=0,m=0,v=0,_=0,y=0,w=e,R=t;for(let M=1;M<=10;++M)u=M/10,c=u*u,d=c*u,f=1-u,p=f*f,g=p*f,m=g*e+3*p*u*i+3*f*c*s+d*a,v=g*t+3*p*u*r+3*f*c*o+d*l,_=w-m,y=R-v,w=m,R=v,h+=Math.sqrt(_*_+y*y);return h}static curveTo(e,t,i,r,s,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const u=Rs._segmentsCount(cc.curveLength(l,h,e,t,i,r,s,o));let c=0,d=0,f=0,p=0,g=0;a.push(l,h);for(let m=1,v=0;m<=u;++m)v=m/u,c=1-v,d=c*c,f=d*c,p=v*v,g=p*v,a.push(f*l+3*d*v*e+3*c*p*i+g*s,f*h+3*d*v*t+3*c*p*r+g*o)}}function Iv(n,e,t,i,r,s,o,a){const l=n-t*r,h=e-i*r,u=n+t*s,c=e+i*s;let d,f;o?(d=i,f=-t):(d=-i,f=t);const p=l+d,g=h+f,m=u+d,v=c+f;return a.push(p,g,m,v),2}function Br(n,e,t,i,r,s,o,a){const l=t-n,h=i-e;let u=Math.atan2(l,h),c=Math.atan2(r-n,s-e);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let d=u;const f=c-u,p=Math.abs(f),g=Math.sqrt(l*l+h*h),m=(15*p*Math.sqrt(g)/Math.PI>>0)+1,v=f/m;if(d+=v,a){o.push(n,e,t,i);for(let _=1,y=d;_<m;_++,y+=v)o.push(n,e,n+Math.sin(y)*g,e+Math.cos(y)*g);o.push(n,e,r,s)}else{o.push(t,i,n,e);for(let _=1,y=d;_<m;_++,y+=v)o.push(n+Math.sin(y)*g,e+Math.cos(y)*g,n,e);o.push(r,s,n,e)}return m*2}function P2(n,e){const t=n.shape;let i=n.points||t.points.slice();const r=e.closePointEps;if(i.length===0)return;const s=n.lineStyle,o=new Ye(i[0],i[1]),a=new Ye(i[i.length-2],i[i.length-1]),l=t.type!==Gt.POLY||t.closeStroke,h=Math.abs(o.x-a.x)<r&&Math.abs(o.y-a.y)<r;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const U=(o.x+a.x)*.5,W=(a.y+o.y)*.5;i.unshift(U,W),i.push(U,W)}const u=e.points,c=i.length/2;let d=i.length;const f=u.length/2,p=s.width/2,g=p*p,m=s.miterLimit*s.miterLimit;let v=i[0],_=i[1],y=i[2],w=i[3],R=0,M=0,C=-(_-w),O=v-y,N=0,X=0,q=Math.sqrt(C*C+O*O);C/=q,O/=q,C*=p,O*=p;const L=s.alignment,S=(1-L)*2,I=L*2;l||(s.cap===qn.ROUND?d+=Br(v-C*(S-I)*.5,_-O*(S-I)*.5,v-C*S,_-O*S,v+C*I,_+O*I,u,!0)+2:s.cap===qn.SQUARE&&(d+=Iv(v,_,C,O,S,I,!0,u))),u.push(v-C*S,_-O*S,v+C*I,_+O*I);for(let U=1;U<c-1;++U){v=i[(U-1)*2],_=i[(U-1)*2+1],y=i[U*2],w=i[U*2+1],R=i[(U+1)*2],M=i[(U+1)*2+1],C=-(_-w),O=v-y,q=Math.sqrt(C*C+O*O),C/=q,O/=q,C*=p,O*=p,N=-(w-M),X=y-R,q=Math.sqrt(N*N+X*X),N/=q,X/=q,N*=p,X*=p;const W=y-v,ee=_-w,z=y-R,H=M-w,K=W*z+ee*H,$=ee*z-H*W,se=$<0;if(Math.abs($)<.001*Math.abs(K)){u.push(y-C*S,w-O*S,y+C*I,w+O*I),K>=0&&(s.join===Ci.ROUND?d+=Br(y,w,y-C*S,w-O*S,y-N*S,w-X*S,u,!1)+4:d+=2,u.push(y-N*I,w-X*I,y+N*S,w+X*S));continue}const fe=(-C+v)*(-O+w)-(-C+y)*(-O+_),te=(-N+R)*(-X+w)-(-N+y)*(-X+M),J=(W*te-z*fe)/$,Y=(H*fe-ee*te)/$,he=(J-y)*(J-y)+(Y-w)*(Y-w),le=y+(J-y)*S,ve=w+(Y-w)*S,Ce=y-(J-y)*I,ze=w-(Y-w)*I,lt=Math.min(W*W+ee*ee,z*z+H*H),me=se?S:I,Ae=lt+me*me*g,x=he<=Ae;let A=s.join;if(A===Ci.MITER&&he/g>m&&(A=Ci.BEVEL),x)switch(A){case Ci.MITER:{u.push(le,ve,Ce,ze);break}case Ci.BEVEL:{se?u.push(le,ve,y+C*I,w+O*I,le,ve,y+N*I,w+X*I):u.push(y-C*S,w-O*S,Ce,ze,y-N*S,w-X*S,Ce,ze),d+=2;break}case Ci.ROUND:{se?(u.push(le,ve,y+C*I,w+O*I),d+=Br(y,w,y+C*I,w+O*I,y+N*I,w+X*I,u,!0)+4,u.push(le,ve,y+N*I,w+X*I)):(u.push(y-C*S,w-O*S,Ce,ze),d+=Br(y,w,y-C*S,w-O*S,y-N*S,w-X*S,u,!1)+4,u.push(y-N*S,w-X*S,Ce,ze));break}}else{switch(u.push(y-C*S,w-O*S,y+C*I,w+O*I),A){case Ci.MITER:{se?u.push(Ce,ze,Ce,ze):u.push(le,ve,le,ve),d+=2;break}case Ci.ROUND:{se?d+=Br(y,w,y+C*I,w+O*I,y+N*I,w+X*I,u,!0)+2:d+=Br(y,w,y-C*S,w-O*S,y-N*S,w-X*S,u,!1)+2;break}}u.push(y-N*S,w-X*S,y+N*I,w+X*I),d+=2}}v=i[(c-2)*2],_=i[(c-2)*2+1],y=i[(c-1)*2],w=i[(c-1)*2+1],C=-(_-w),O=v-y,q=Math.sqrt(C*C+O*O),C/=q,O/=q,C*=p,O*=p,u.push(y-C*S,w-O*S,y+C*I,w+O*I),l||(s.cap===qn.ROUND?d+=Br(y-C*(S-I)*.5,w-O*(S-I)*.5,y-C*S,w-O*S,y+C*I,w+O*I,u,!1)+2:s.cap===qn.SQUARE&&(d+=Iv(y,w,C,O,S,I,!1,u)));const B=e.indices,j=Rs.epsilon*Rs.epsilon;for(let U=f;U<d+f-2;++U)v=u[U*2],_=u[U*2+1],y=u[(U+1)*2],w=u[(U+1)*2+1],R=u[(U+2)*2],M=u[(U+2)*2+1],!(Math.abs(v*(w-M)+y*(M-_)+R*(_-w))<j)&&B.push(U,U+1,U+2)}function I2(n,e){let t=0;const i=n.shape,r=n.points||i.points,s=i.type!==Gt.POLY||i.closeStroke;if(r.length===0)return;const o=e.points,a=e.indices,l=r.length/2,h=o.length/2;let u=h;for(o.push(r[0],r[1]),t=1;t<l;t++)o.push(r[t*2],r[t*2+1]),a.push(u,u+1),u++;s&&a.push(u,h)}function Dv(n,e){n.lineStyle.native?I2(n,e):P2(n,e)}class dc{static curveLength(e,t,i,r,s,o){const a=e-2*i+s,l=t-2*r+o,h=2*i-2*e,u=2*r-2*t,c=4*(a*a+l*l),d=4*(a*h+l*u),f=h*h+u*u,p=2*Math.sqrt(c+d+f),g=Math.sqrt(c),m=2*c*g,v=2*Math.sqrt(f),_=d/g;return(m*p+g*d*(p-v)+(4*f*c-d*d)*Math.log((2*g+_+p)/(_+v)))/(4*m)}static curveTo(e,t,i,r,s){const o=s[s.length-2],a=s[s.length-1],l=Rs._segmentsCount(dc.curveLength(o,a,e,t,i,r));let h=0,u=0;for(let c=1;c<=l;++c){const d=c/l;h=o+(e-o)*d,u=a+(t-a)*d,s.push(h+(e+(i-e)*d-h)*d,u+(t+(r-t)*d-u)*d)}}}const fc={[Gt.POLY]:Cv,[Gt.CIRC]:dl,[Gt.ELIP]:dl,[Gt.RECT]:A2,[Gt.RREC]:R2},Mv=[],fl=[];class pl{constructor(e,t=null,i=null,r=null){this.points=[],this.holes=[],this.shape=e,this.lineStyle=i,this.fillStyle=t,this.matrix=r,this.type=e.type}clone(){return new pl(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Cs=new Ye,Ov=class Ry extends cm{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new tl,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let e=0;e<this.drawCalls.length;e++)this.drawCalls[e].texArray.clear(),fl.push(this.drawCalls[e]);this.drawCalls.length=0;for(let e=0;e<this.batches.length;e++){const t=this.batches[e];t.reset(),Mv.push(t)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(e,t=null,i=null,r=null){const s=new pl(e,t,i,r);return this.graphicsData.push(s),this.dirty++,this}drawHole(e,t=null){if(!this.graphicsData.length)return null;const i=new pl(e,null,null,t),r=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=r.lineStyle,r.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let e=0;e<this.graphicsData.length;++e)this.graphicsData[e].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(e){const t=this.graphicsData;for(let i=0;i<t.length;++i){const r=t[i];if(r.fillStyle.visible&&r.shape&&(r.matrix?r.matrix.applyInverse(e,Cs):Cs.copyFrom(e),r.shape.contains(Cs.x,Cs.y))){let s=!1;if(r.holes){for(let o=0;o<r.holes.length;o++)if(r.holes[o].shape.contains(Cs.x,Cs.y)){s=!0;break}}if(!s)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const e=this.uvs,t=this.graphicsData;let i=null,r=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],r=i.style);for(let l=this.shapeIndex;l<t.length;l++){this.shapeIndex++;const h=t[l],u=h.fillStyle,c=h.lineStyle;fc[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(u.visible||c.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?u:c;if(!f.visible)continue;const p=f.texture.baseTexture,g=this.indices.length,m=this.points.length/2;p.wrapMode=Gn.REPEAT,d===0?this.processFill(h):this.processLine(h);const v=this.points.length/2-m;v!==0&&(i&&!this._compareStyles(r,f)&&(i.end(g,m),i=null),i||(i=Mv.pop()||new C2,i.begin(f,g,m),this.batches.push(i),r=f),this.addUvs(this.points,e,f.texture,m,v,f.matrix))}}const s=this.indices.length,o=this.points.length/2;if(i&&i.end(s,o),this.batches.length===0){this.batchable=!0;return}const a=o>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(e,t){return!(!e||!t||e.texture.baseTexture!==t.texture.baseTexture||e.color+e.alpha!==t.color+t.alpha||!!e.native!=!!t.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let e=0,t=this.graphicsData.length;e<t;e++){const i=this.graphicsData[e],r=i.fillStyle,s=i.lineStyle;if(r&&!r.texture.baseTexture.valid||s&&!s.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const e=this.batches;for(let t=0,i=e.length;t<i;t++){const r=e[t];for(let s=0;s<r.size;s++){const o=r.start+s;this.indicesUint16[o]=this.indicesUint16[o]-r.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const e=this.batches;for(let t=0;t<e.length;t++)if(e[t].style.native)return!1;return this.points.length<Ry.BATCHABLE_SIZE*2}buildDrawCalls(){let e=++Fe._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),fl.push(this.drawCalls[c]);this.drawCalls.length=0;const t=this.colors,i=this.textureIds;let r=fl.pop();r||(r=new Fu,r.texArray=new Gu),r.texArray.count=0,r.start=0,r.size=0,r.type=Ji.TRIANGLES;let s=0,o=null,a=0,l=!1,h=Ji.TRIANGLES,u=0;this.drawCalls.push(r);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],f=8,p=d.style,g=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?Ji.LINES:Ji.TRIANGLES,o=null,s=f,e++),o!==g&&(o=g,g._batchEnabled!==e&&(s===f&&(e++,s=0,r.size>0&&(r=fl.pop(),r||(r=new Fu,r.texArray=new Gu),this.drawCalls.push(r)),r.start=u,r.size=0,r.texArray.count=0,r.type=h),g.touched=1,g._batchEnabled=e,g._batchLocation=s,g.wrapMode=Gn.REPEAT,r.texArray.elements[r.texArray.count++]=g,s++)),r.size+=d.size,u+=d.size,a=g._batchLocation,this.addColors(t,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}Fe._globalBatch=e,this.packAttributes()}packAttributes(){const e=this.points,t=this.uvs,i=this.colors,r=this.textureIds,s=new ArrayBuffer(e.length*3*4),o=new Float32Array(s),a=new Uint32Array(s);let l=0;for(let h=0;h<e.length/2;h++)o[l++]=e[h*2],o[l++]=e[h*2+1],o[l++]=t[h*2],o[l++]=t[h*2+1],a[l++]=i[h],o[l++]=r[h];this._buffer.update(s),this._indexBuffer.update(this.indicesUint16)}processFill(e){e.holes.length?Cv.triangulate(e,this):fc[e.type].triangulate(e,this)}processLine(e){Dv(e,this);for(let t=0;t<e.holes.length;t++)Dv(e.holes[t],this)}processHoles(e){for(let t=0;t<e.length;t++){const i=e[t];fc[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const e=this._bounds;e.clear(),e.addVertexData(this.points,0,this.points.length),e.pad(this.boundsPadding,this.boundsPadding)}transformPoints(e,t){for(let i=0;i<e.length/2;i++){const r=e[i*2],s=e[i*2+1];e[i*2]=t.a*r+t.c*s+t.tx,e[i*2+1]=t.b*r+t.d*s+t.ty}}addColors(e,t,i,r,s=0){const o=nt.shared.setValue(t).toLittleEndianNumber(),a=nt.shared.setValue(o).toPremultiplied(i);e.length=Math.max(e.length,s+r);for(let l=0;l<r;l++)e[s+l]=a}addTextureIds(e,t,i,r=0){e.length=Math.max(e.length,r+i);for(let s=0;s<i;s++)e[r+s]=t}addUvs(e,t,i,r,s,o=null){let a=0;const l=t.length,h=i.frame;for(;a<s;){let c=e[(r+a)*2],d=e[(r+a)*2+1];if(o){const f=o.a*c+o.c*d+o.tx;d=o.b*c+o.d*d+o.ty,c=f}a++,t.push(c/h.width,d/h.height)}const u=i.baseTexture;(h.width<u.width||h.height<u.height)&&this.adjustUvs(t,i,l,s)}adjustUvs(e,t,i,r){const s=t.baseTexture,o=1e-6,a=i+r*2,l=t.frame,h=l.width/s.width,u=l.height/s.height;let c=l.x/l.width,d=l.y/l.height,f=Math.floor(e[i]+o),p=Math.floor(e[i+1]+o);for(let g=i+2;g<a;g+=2)f=Math.min(f,Math.floor(e[g]+o)),p=Math.min(p,Math.floor(e[g+1]+o));c-=f,d-=p;for(let g=i;g<a;g+=2)e[g]=(e[g]+c)*h,e[g+1]=(e[g+1]+d)*u}};Ov.BATCHABLE_SIZE=100;let D2=Ov;class gl{constructor(){this.color=16777215,this.alpha=1,this.texture=Ee.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const e=new gl;return e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.matrix=this.matrix,e.visible=this.visible,e}reset(){this.color=16777215,this.alpha=1,this.texture=Ee.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class pc extends gl{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=qn.BUTT,this.join=Ci.MITER,this.miterLimit=10}clone(){const e=new pc;return e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.matrix=this.matrix,e.visible=this.visible,e.width=this.width,e.alignment=this.alignment,e.native=this.native,e.cap=this.cap,e.join=this.join,e.miterLimit=this.miterLimit,e}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=qn.BUTT,this.join=Ci.MITER,this.miterLimit=10}}const gc={},mc=class Rl extends ki{constructor(e=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new gl,this._lineStyle=new pc,this._matrix=null,this._holeMode=!1,this.state=sn.for2d(),this._geometry=e||new D2,this._geometry.refCount++,this._transformID=-1,this._tintColor=new nt(16777215),this.blendMode=De.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Rl(this._geometry)}set blendMode(e){this.state.blendMode=e}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(e){this._tintColor.setValue(e)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(e=null,t=0,i,r=.5,s=!1){return typeof e=="number"&&(e={width:e,color:t,alpha:i,alignment:r,native:s}),this.lineTextureStyle(e)}lineTextureStyle(e){const t={width:0,texture:Ee.WHITE,color:e!=null&&e.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:qn.BUTT,join:Ci.MITER,miterLimit:10};e=Object.assign(t,e),this.normalizeColor(e),this.currentPath&&this.startPoly();const i=e.width>0&&e.alpha>0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._lineStyle,{visible:i},e)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const e=this.currentPath.points,t=this.currentPath.points.length;t>2&&(this.drawShape(this.currentPath),this.currentPath=new Er,this.currentPath.closeStroke=!1,this.currentPath.points.push(e[t-2],e[t-1]))}else this.currentPath=new Er,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(e,t){return this.startPoly(),this.currentPath.points[0]=e,this.currentPath.points[1]=t,this}lineTo(e,t){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,r=i[i.length-2],s=i[i.length-1];return(r!==e||s!==t)&&i.push(e,t),this}_initCurve(e=0,t=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[e,t]):this.moveTo(e,t)}quadraticCurveTo(e,t,i,r){this._initCurve();const s=this.currentPath.points;return s.length===0&&this.moveTo(0,0),dc.curveTo(e,t,i,r,s),this}bezierCurveTo(e,t,i,r,s,o){return this._initCurve(),cc.curveTo(e,t,i,r,s,o,this.currentPath.points),this}arcTo(e,t,i,r,s){this._initCurve(e,t);const o=this.currentPath.points,a=Pv.curveTo(e,t,i,r,s,o);if(a){const{cx:l,cy:h,radius:u,startAngle:c,endAngle:d,anticlockwise:f}=a;this.arc(l,h,u,c,d,f)}return this}arc(e,t,i,r,s,o=!1){if(r===s)return this;if(!o&&s<=r?s+=Na:o&&r<=s&&(r+=Na),s-r===0)return this;const a=e+Math.cos(r)*i,l=t+Math.sin(r)*i,h=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-a),d=Math.abs(u[u.length-1]-l);c<h&&d<h||u.push(a,l)}else this.moveTo(a,l),u=this.currentPath.points;return Pv.arc(a,l,e,t,i,r,s,o,u),this}beginFill(e=0,t){return this.beginTextureFill({texture:Ee.WHITE,color:e,alpha:t})}normalizeColor(e){const t=nt.shared.setValue(e.color??0);e.color=t.toNumber(),e.alpha??(e.alpha=t.alpha)}beginTextureFill(e){const t={texture:Ee.WHITE,color:16777215,matrix:null};e=Object.assign(t,e),this.normalizeColor(e),this.currentPath&&this.startPoly();const i=e.alpha>0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._fillStyle,{visible:i},e)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(e,t,i,r){return this.drawShape(new Ue(e,t,i,r))}drawRoundedRect(e,t,i,r,s){return this.drawShape(new za(e,t,i,r,s))}drawCircle(e,t,i){return this.drawShape(new Ua(e,t,i))}drawEllipse(e,t,i,r){return this.drawShape(new Ha(e,t,i,r))}drawPolygon(...e){let t,i=!0;const r=e[0];r.points?(i=r.closeStroke,t=r.points):Array.isArray(e[0])?t=e[0]:t=e;const s=new Er(t);return s.closeStroke=i,this.drawShape(s),this}drawShape(e){return this._holeMode?this._geometry.drawHole(e,this._matrix):this._geometry.drawShape(e,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const e=this._geometry.graphicsData;return e.length===1&&e[0].shape.type===Gt.RECT&&!e[0].matrix&&!e[0].holes.length&&!(e[0].lineStyle.visible&&e[0].lineStyle.width)}_render(e){this.finishPoly();const t=this._geometry;t.updateBatches(),t.batchable?(this.batchDirty!==t.batchDirty&&this._populateBatches(),this._renderBatched(e)):(e.batch.flush(),this._renderDirect(e))}_populateBatches(){const e=this._geometry,t=this.blendMode,i=e.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=e.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(e.points);for(let r=0;r<i;r++){const s=e.batches[r],o=s.style.color,a=new Float32Array(this.vertexData.buffer,s.attribStart*4*2,s.attribSize*2),l=new Float32Array(e.uvsFloat32.buffer,s.attribStart*4*2,s.attribSize*2),h=new Uint16Array(e.indicesUint16.buffer,s.start*2,s.size),u={vertexData:a,blendMode:t,indices:h,uvs:l,_batchRGB:nt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:s.style.texture,alpha:s.style.alpha,worldAlpha:1};this.batches[r]=u}}_renderBatched(e){if(this.batches.length){e.batch.setObjectRenderer(e.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let t=0,i=this.batches.length;t<i;t++){const r=this.batches[t];r.worldAlpha=this.worldAlpha*r.alpha,e.plugins[this.pluginName].render(r)}}}_renderDirect(e){const t=this._resolveDirectShader(e),i=this._geometry,r=this.worldAlpha,s=t.uniforms,o=i.drawCalls;s.translationMatrix=this.transform.worldTransform,nt.shared.setValue(this._tintColor).premultiply(r).toArray(s.tint),e.shader.bind(t),e.geometry.bind(i,t),e.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(e,i.drawCalls[a])}_renderDrawCallDirect(e,t){const{texArray:i,type:r,size:s,start:o}=t,a=i.count;for(let l=0;l<a;l++)e.texture.bind(i.elements[l],l);e.geometry.draw(r,s,o)}_resolveDirectShader(e){let t=this.shader;const i=this.pluginName;if(!t){if(!gc[i]){const{maxTextures:r}=e.plugins[i],s=new Int32Array(r);for(let l=0;l<r;l++)s[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new at,default:Ni.from({uSamplers:s},!0)},a=e.plugins[i]._shader.program;gc[i]=new on(a,o)}t=gc[i]}return t}_calculateBounds(){this.finishPoly();const e=this._geometry;if(!e.graphicsData.length)return;const{minX:t,minY:i,maxX:r,maxY:s}=e.bounds;this._bounds.addFrame(this.transform,t,i,r,s)}containsPoint(e){return this.worldTransform.applyInverse(e,Rl._TEMP_POINT),this._geometry.containsPoint(Rl._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let e=0;e<this.batches.length;e++){const t=this.batches[e];t._tintRGB=nt.shared.setValue(this._tintColor).multiply(t._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const e=this.transform._worldID;if(this._transformID===e)return;this._transformID=e;const t=this.transform.worldTransform,i=t.a,r=t.b,s=t.c,o=t.d,a=t.tx,l=t.ty,h=this._geometry.points,u=this.vertexData;let c=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];u[c++]=i*f+s*p+a,u[c++]=o*p+r*f+l}}closePath(){const e=this.currentPath;return e&&(e.closeStroke=!0,this.finishPoly()),this}setMatrix(e){return this._matrix=e,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(e){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(e)}};mc.curves=Rs,mc._TEMP_POINT=new Ye;let Co=mc;class M2{constructor(e,t){this.uvBuffer=e,this.uvMatrix=t,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(e){if(!e&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const t=this.uvBuffer.data;(!this.data||this.data.length!==t.length)&&(this.data=new Float32Array(t.length)),this.uvMatrix.multiplyUvs(t,this.data),this._updateID++}}const vc=new Ye,Lv=new Er,Bv=class Cy extends ki{constructor(e,t,i,r=Ji.TRIANGLES){super(),this.geometry=e,this.shader=t,this.state=i||sn.for2d(),this.drawMode=r,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=de.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(e){this._geometry!==e&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=e,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(e){this.shader=e}get material(){return this.shader}set blendMode(e){this.state.blendMode=e}get blendMode(){return this.state.blendMode}set roundPixels(e){this._roundPixels!==e&&(this._transformID=-1),this._roundPixels=e}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(e){this.shader.tint=e}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(e){this.shader.texture=e}_render(e){const t=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Ji.TRIANGLES&&t.length<Cy.BATCHABLE_SIZE*2?this._renderToBatch(e):this._renderDefault(e)}_renderDefault(e){const t=this.shader;t.alpha=this.worldAlpha,t.update&&t.update(),e.batch.flush(),t.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),e.shader.bind(t),e.state.set(this.state),e.geometry.bind(this.geometry,t),e.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(e){const t=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=t.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const r=this.material.pluginName;e.batch.setObjectRenderer(e.plugins[r]),e.plugins[r].render(this)}calculateVertices(){const e=this.geometry.buffers[0],t=e.data,i=e._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==t.length&&(this.vertexData=new Float32Array(t.length));const r=this.transform.worldTransform,s=r.a,o=r.b,a=r.c,l=r.d,h=r.tx,u=r.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const f=t[d*2],p=t[d*2+1];c[d*2]=s*f+a*p+h,c[d*2+1]=o*f+l*p+u}if(this._roundPixels){const d=de.RESOLUTION;for(let f=0;f<c.length;++f)c[f]=Math.round(c[f]*d)/d}this.vertexDirty=i}calculateUvs(){const e=this.geometry.buffers[1],t=this.shader;t.uvMatrix.isSimple?this.uvs=e.data:(this.batchUvs||(this.batchUvs=new M2(e,t.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(e){if(!this.getBounds().contains(e.x,e.y))return!1;this.worldTransform.applyInverse(e,vc);const t=this.geometry.getBuffer("aVertexPosition").data,i=Lv.points,r=this.geometry.getIndex().data,s=r.length,o=this.drawMode===4?3:1;for(let a=0;a+2<s;a+=o){const l=r[a]*2,h=r[a+1]*2,u=r[a+2]*2;if(i[0]=t[l],i[1]=t[l+1],i[2]=t[h],i[3]=t[h+1],i[4]=t[u],i[5]=t[u+1],Lv.contains(vc.x,vc.y))return!0}return!1}destroy(e){super.destroy(e),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};Bv.BATCHABLE_SIZE=100;let Fv=Bv;class O2 extends jn{constructor(e,t,i){super();const r=new _t(e),s=new _t(t,!0),o=new _t(i,!0,!0);this.addAttribute("aVertexPosition",r,2,!1,Se.FLOAT).addAttribute("aTextureCoord",s,2,!1,Se.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var L2=`varying vec2 vTextureCoord;
1038
+ uniform vec4 uColor;
1039
+
1040
+ uniform sampler2D uSampler;
1041
+
1042
+ void main(void)
1043
+ {
1044
+ gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
1045
+ }
1046
+ `,B2=`attribute vec2 aVertexPosition;
1047
+ attribute vec2 aTextureCoord;
1048
+
1049
+ uniform mat3 projectionMatrix;
1050
+ uniform mat3 translationMatrix;
1051
+ uniform mat3 uTextureMatrix;
1052
+
1053
+ varying vec2 vTextureCoord;
1054
+
1055
+ void main(void)
1056
+ {
1057
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
1058
+
1059
+ vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
1060
+ }
1061
+ `;class Nv extends on{constructor(e,t){const i={uSampler:e,alpha:1,uTextureMatrix:at.IDENTITY,uColor:new Float32Array([1,1,1,1])};t=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},t),t.uniforms&&Object.assign(i,t.uniforms),super(t.program||An.from(B2,L2),i),this._colorDirty=!1,this.uvMatrix=new Mm(e),this.batchable=t.program===void 0,this.pluginName=t.pluginName,this._tintColor=new nt(t.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=t.alpha}get texture(){return this.uniforms.uSampler}set texture(e){this.uniforms.uSampler!==e&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!e.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=e,this.uvMatrix.texture=e)}set alpha(e){e!==this._alpha&&(this._alpha=e,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(e){e!==this.tint&&(this._tintColor.setValue(e),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const e=this.texture.baseTexture.alphaMode;nt.shared.setValue(this._tintColor).premultiply(this._alpha,e).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class kv{constructor(e,t,i){this.geometry=new jn,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let r=0;r<e.length;++r){let s=e[r];s={attributeName:s.attributeName,size:s.size,uploadFunction:s.uploadFunction,type:s.type||Se.FLOAT,offset:s.offset},t[r]?this.dynamicProperties.push(s):this.staticProperties.push(s)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const e=this.geometry;let t=0;this.indexBuffer=new _t(iR(this.size),!0,!0),e.addIndex(this.indexBuffer),this.dynamicStride=0;for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];a.offset=t,t+=a.size,this.dynamicStride+=a.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new _t(this.dynamicData,!1,!1);let r=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=r,r+=a.size,this.staticStride+=a.size}const s=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(s),this.staticDataUint32=new Uint32Array(s),this.staticBuffer=new _t(this.staticData,!0,!1);for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];e.addAttribute(a.attributeName,this.dynamicBuffer,0,a.type===Se.UNSIGNED_BYTE,a.type,this.dynamicStride*4,a.offset*4)}for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];e.addAttribute(a.attributeName,this.staticBuffer,0,a.type===Se.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(e,t,i){for(let r=0;r<this.dynamicProperties.length;r++){const s=this.dynamicProperties[r];s.uploadFunction(e,t,i,s.type===Se.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,s.offset)}this.dynamicBuffer._updateID++}uploadStatic(e,t,i){for(let r=0;r<this.staticProperties.length;r++){const s=this.staticProperties[r];s.uploadFunction(e,t,i,s.type===Se.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,s.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var F2=`varying vec2 vTextureCoord;
1062
+ varying vec4 vColor;
1063
+
1064
+ uniform sampler2D uSampler;
1065
+
1066
+ void main(void){
1067
+ vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
1068
+ gl_FragColor = color;
1069
+ }`,N2=`attribute vec2 aVertexPosition;
1070
+ attribute vec2 aTextureCoord;
1071
+ attribute vec4 aColor;
1072
+
1073
+ attribute vec2 aPositionCoord;
1074
+ attribute float aRotation;
1075
+
1076
+ uniform mat3 translationMatrix;
1077
+ uniform vec4 uColor;
1078
+
1079
+ varying vec2 vTextureCoord;
1080
+ varying vec4 vColor;
1081
+
1082
+ void main(void){
1083
+ float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);
1084
+ float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);
1085
+
1086
+ vec2 v = vec2(x, y);
1087
+ v = v + aPositionCoord;
1088
+
1089
+ gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
1090
+
1091
+ vTextureCoord = aTextureCoord;
1092
+ vColor = aColor * uColor;
1093
+ }
1094
+ `;class Uv extends Xa{constructor(e){super(e),this.shader=null,this.properties=null,this.tempMatrix=new at,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:Se.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=on.from(N2,F2,{}),this.state=sn.for2d()}render(e){const t=e.children,i=e._maxSize,r=e._batchSize,s=this.renderer;let o=t.length;if(o===0)return;o>i&&!e.autoResize&&(o=i);let a=e._buffers;a||(a=e._buffers=this.generateBuffers(e));const l=t[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=em(e.blendMode,h),s.state.set(this.state);const u=s.gl,c=e.worldTransform.copyTo(this.tempMatrix);c.prepend(s.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=nt.shared.setValue(e.tintRgb).premultiply(e.worldAlpha,h).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=l,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,p=0;f<o;f+=r,p+=1){let g=o-f;g>r&&(g=r),p>=a.length&&a.push(this._generateOneMoreBuffer(e));const m=a[p];m.uploadDynamic(t,f,g);const v=e._bufferUpdateIDs[p]||0;d=d||m._updateID<v,d&&(m._updateID=e._updateID,m.uploadStatic(t,f,g)),s.geometry.bind(m.geometry),u.drawElements(u.TRIANGLES,g*6,u.UNSIGNED_SHORT,0)}}generateBuffers(e){const t=[],i=e._maxSize,r=e._batchSize,s=e._properties;for(let o=0;o<i;o+=r)t.push(new kv(this.properties,s,r));return t}_generateOneMoreBuffer(e){const t=e._batchSize,i=e._properties;return new kv(this.properties,i,t)}uploadVertices(e,t,i,r,s,o){let a=0,l=0,h=0,u=0;for(let c=0;c<i;++c){const d=e[t+c],f=d._texture,p=d.scale.x,g=d.scale.y,m=f.trim,v=f.orig;m?(l=m.x-d.anchor.x*v.width,a=l+m.width,u=m.y-d.anchor.y*v.height,h=u+m.height):(a=v.width*(1-d.anchor.x),l=v.width*-d.anchor.x,h=v.height*(1-d.anchor.y),u=v.height*-d.anchor.y),r[o]=l*p,r[o+1]=u*g,r[o+s]=a*p,r[o+s+1]=u*g,r[o+s*2]=a*p,r[o+s*2+1]=h*g,r[o+s*3]=l*p,r[o+s*3+1]=h*g,o+=s*4}}uploadPosition(e,t,i,r,s,o){for(let a=0;a<i;a++){const l=e[t+a].position;r[o]=l.x,r[o+1]=l.y,r[o+s]=l.x,r[o+s+1]=l.y,r[o+s*2]=l.x,r[o+s*2+1]=l.y,r[o+s*3]=l.x,r[o+s*3+1]=l.y,o+=s*4}}uploadRotation(e,t,i,r,s,o){for(let a=0;a<i;a++){const l=e[t+a].rotation;r[o]=l,r[o+s]=l,r[o+s*2]=l,r[o+s*3]=l,o+=s*4}}uploadUvs(e,t,i,r,s,o){for(let a=0;a<i;++a){const l=e[t+a]._texture._uvs;l?(r[o]=l.x0,r[o+1]=l.y0,r[o+s]=l.x1,r[o+s+1]=l.y1,r[o+s*2]=l.x2,r[o+s*2+1]=l.y2,r[o+s*3]=l.x3,r[o+s*3+1]=l.y3,o+=s*4):(r[o]=0,r[o+1]=0,r[o+s]=0,r[o+s+1]=0,r[o+s*2]=0,r[o+s*2+1]=0,r[o+s*3]=0,r[o+s*3+1]=0,o+=s*4)}}uploadTint(e,t,i,r,s,o){for(let a=0;a<i;++a){const l=e[t+a],h=nt.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);r[o]=h,r[o+s]=h,r[o+s*2]=h,r[o+s*3]=h,o+=s*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Uv.extension={name:"particle",type:ue.RendererPlugin},Te.add(Uv);var ml=(n=>(n[n.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",n[n.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",n))(ml||{});const vl={willReadFrequently:!0},ln=class be{static get experimentalLetterSpacingSupported(){let e=be._experimentalLetterSpacingSupported;if(e!==void 0){const t=de.ADAPTER.getCanvasRenderingContext2D().prototype;e=be._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,i,r,s,o,a,l,h){this.text=e,this.style=t,this.width=i,this.height=r,this.lines=s,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(e,t,i,r=be._canvas){i=i??t.wordWrap;const s=t.toFontString(),o=be.measureFont(s);o.fontSize===0&&(o.fontSize=t.fontSize,o.ascent=t.fontSize);const a=r.getContext("2d",vl);a.font=s;const l=(i?be.wordWrap(e,t,r):e).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let p=0;p<l.length;p++){const g=be._measureText(l[p],t.letterSpacing,a);h[p]=g,u=Math.max(u,g)}let c=u+t.strokeThickness;t.dropShadow&&(c+=t.dropShadowDistance);const d=t.lineHeight||o.fontSize+t.strokeThickness;let f=Math.max(d,o.fontSize+t.strokeThickness*2)+t.leading+(l.length-1)*(d+t.leading);return t.dropShadow&&(f+=t.dropShadowDistance),new be(e,t,c,f,l,h,d+t.leading,u,o)}static _measureText(e,t,i){let r=!1;be.experimentalLetterSpacingSupported&&(be.experimentalLetterSpacing?(i.letterSpacing=`${t}px`,i.textLetterSpacing=`${t}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let s=i.measureText(e).width;return s>0&&(r?s-=t:s+=(be.graphemeSegmenter(e).length-1)*t),s}static wordWrap(e,t,i=be._canvas){const r=i.getContext("2d",vl);let s=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=t,c=be.collapseSpaces(u),d=be.collapseNewlines(u);let f=!c;const p=t.wordWrapWidth+h,g=be.tokenize(e);for(let m=0;m<g.length;m++){let v=g[m];if(be.isNewline(v)){if(!d){a+=be.addLine(o),f=!c,o="",s=0;continue}v=" "}if(c){const y=be.isBreakingSpace(v),w=be.isBreakingSpace(o[o.length-1]);if(y&&w)continue}const _=be.getFromCache(v,h,l,r);if(_>p)if(o!==""&&(a+=be.addLine(o),o="",s=0),be.canBreakWords(v,t.breakWords)){const y=be.wordWrapSplit(v);for(let w=0;w<y.length;w++){let R=y[w],M=R,C=1;for(;y[w+C];){const N=y[w+C];if(!be.canBreakChars(M,N,v,w,t.breakWords))R+=N;else break;M=N,C++}w+=C-1;const O=be.getFromCache(R,h,l,r);O+s>p&&(a+=be.addLine(o),f=!1,o="",s=0),o+=R,s+=O}}else{o.length>0&&(a+=be.addLine(o),o="",s=0);const y=m===g.length-1;a+=be.addLine(v,!y),f=!1,o="",s=0}else _+s>p&&(f=!1,a+=be.addLine(o),o="",s=0),(o.length>0||!be.isBreakingSpace(v)||f)&&(o+=v,s+=_)}return a+=be.addLine(o,!1),a}static addLine(e,t=!0){return e=be.trimRight(e),e=t?`${e}
1095
+ `:e,e}static getFromCache(e,t,i,r){let s=i[e];return typeof s!="number"&&(s=be._measureText(e,t,r)+t,i[e]=s),s}static collapseSpaces(e){return e==="normal"||e==="pre-line"}static collapseNewlines(e){return e==="normal"}static trimRight(e){if(typeof e!="string")return"";for(let t=e.length-1;t>=0;t--){const i=e[t];if(!be.isBreakingSpace(i))break;e=e.slice(0,-1)}return e}static isNewline(e){return typeof e!="string"?!1:be._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,t){return typeof e!="string"?!1:be._breakingSpaces.includes(e.charCodeAt(0))}static tokenize(e){const t=[];let i="";if(typeof e!="string")return t;for(let r=0;r<e.length;r++){const s=e[r],o=e[r+1];if(be.isBreakingSpace(s,o)||be.isNewline(s)){i!==""&&(t.push(i),i=""),t.push(s);continue}i+=s}return i!==""&&t.push(i),t}static canBreakWords(e,t){return t}static canBreakChars(e,t,i,r,s){return!0}static wordWrapSplit(e){return be.graphemeSegmenter(e)}static measureFont(e){if(be._fonts[e])return be._fonts[e];const t={ascent:0,descent:0,fontSize:0},i=be._canvas,r=be._context;r.font=e;const s=be.METRICS_STRING+be.BASELINE_SYMBOL,o=Math.ceil(r.measureText(s).width);let a=Math.ceil(r.measureText(be.BASELINE_SYMBOL).width);const l=Math.ceil(be.HEIGHT_MULTIPLIER*a);if(a=a*be.BASELINE_MULTIPLIER|0,o===0||l===0)return be._fonts[e]=t,t;i.width=o,i.height=l,r.fillStyle="#f00",r.fillRect(0,0,o,l),r.font=e,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(s,0,a);const h=r.getImageData(0,0,o,l).data,u=h.length,c=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let g=0;g<c;g+=4)if(h[f+g]!==255){p=!0;break}if(!p)f+=c;else break}for(t.ascent=a-d,f=u-c,p=!1,d=l;d>a;--d){for(let g=0;g<c;g+=4)if(h[f+g]!==255){p=!0;break}if(!p)f-=c;else break}return t.descent=d-a,t.fontSize=t.ascent+t.descent,be._fonts[e]=t,t}static clearMetrics(e=""){e?delete be._fonts[e]:be._fonts={}}static get _canvas(){var e;if(!be.__canvas){let t;try{const i=new OffscreenCanvas(0,0);if((e=i.getContext("2d",vl))!=null&&e.measureText)return be.__canvas=i,i;t=de.ADAPTER.createCanvas()}catch{t=de.ADAPTER.createCanvas()}t.width=t.height=10,be.__canvas=t}return be.__canvas}static get _context(){return be.__context||(be.__context=be._canvas.getContext("2d",vl)),be.__context}};ln.METRICS_STRING="|ÉqÅ",ln.BASELINE_SYMBOL="M",ln.BASELINE_MULTIPLIER=1.4,ln.HEIGHT_MULTIPLIER=2,ln.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const n=new Intl.Segmenter;return e=>[...n.segment(e)].map(t=>t.segment)}return n=>[...n]})(),ln.experimentalLetterSpacing=!1,ln._fonts={},ln._newlines=[10,13],ln._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Zn=ln;const k2=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Hv=class Mo{constructor(e){this.styleID=0,this.reset(),_c(this,e,e)}clone(){const e={};return _c(e,this,Mo.defaultStyle),new Mo(e)}reset(){_c(this,Mo.defaultStyle,Mo.defaultStyle)}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(this._dropShadow=e,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(e){this._dropShadowAlpha!==e&&(this._dropShadowAlpha=e,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(e){this._dropShadowAngle!==e&&(this._dropShadowAngle=e,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(e){this._dropShadowBlur!==e&&(this._dropShadowBlur=e,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(e){const t=yc(e);this._dropShadowColor!==t&&(this._dropShadowColor=t,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(e){this._dropShadowDistance!==e&&(this._dropShadowDistance=e,this.styleID++)}get fill(){return this._fill}set fill(e){const t=yc(e);this._fill!==t&&(this._fill=t,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(e){this._fillGradientType!==e&&(this._fillGradientType=e,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(e){U2(this._fillGradientStops,e)||(this._fillGradientStops=e,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(e){this.fontFamily!==e&&(this._fontFamily=e,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(this._fontSize=e,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.styleID++)}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(e){this._lineJoin!==e&&(this._lineJoin=e,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(e){this._miterLimit!==e&&(this._miterLimit=e,this.styleID++)}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.styleID++)}get stroke(){return this._stroke}set stroke(e){const t=yc(e);this._stroke!==t&&(this._stroke=t,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(e){this._strokeThickness!==e&&(this._strokeThickness=e,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.styleID++)}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.styleID++)}toFontString(){const e=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let t=this.fontFamily;Array.isArray(this.fontFamily)||(t=this.fontFamily.split(","));for(let i=t.length-1;i>=0;i--){let r=t[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!k2.includes(r)&&(r=`"${r}"`),t[i]=r}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${e} ${t.join(",")}`}};Hv.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:ml.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Kn=Hv;function yc(n){const e=nt.shared,t=i=>{const r=e.setValue(i);return r.alpha===1?r.toHex():r.toRgbaString()};return Array.isArray(n)?n.map(t):t(n)}function U2(n,e){if(!Array.isArray(n)||!Array.isArray(e)||n.length!==e.length)return!1;for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}function _c(n,e,t){for(const i in t)Array.isArray(e[i])?n[i]=e[i].slice():n[i]=e[i]}const H2={texture:!0,children:!1,baseTexture:!0},zv=class Lc extends ws{constructor(e,t,i){let r=!1;i||(i=de.ADAPTER.createCanvas(),r=!0),i.width=3,i.height=3;const s=Ee.from(i);s.orig=new Ue,s.trim=new Ue,super(s),this._ownCanvas=r,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Lc.defaultResolution??de.RESOLUTION,this._autoResolution=Lc.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=e,this.style=t,this.localStyleID=-1}static get experimentalLetterSpacing(){return Zn.experimentalLetterSpacing}static set experimentalLetterSpacing(e){We("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Zn.experimentalLetterSpacing=e}updateText(e){const t=this._style;if(this.localStyleID!==t.styleID&&(this.dirty=!0,this.localStyleID=t.styleID),!this.dirty&&e)return;this._font=this._style.toFontString();const i=this.context,r=Zn.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),s=r.width,o=r.height,a=r.lines,l=r.lineHeight,h=r.lineWidths,u=r.maxLineWidth,c=r.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,s)+t.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+t.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=t.strokeThickness,i.textBaseline=t.textBaseline,i.lineJoin=t.lineJoin,i.miterLimit=t.miterLimit;let d,f;const p=t.dropShadow?2:1;for(let g=0;g<p;++g){const m=t.dropShadow&&g===0,v=m?Math.ceil(Math.max(1,o)+t.padding*2):0,_=v*this._resolution;if(m){i.fillStyle="black",i.strokeStyle="black";const w=t.dropShadowColor,R=t.dropShadowBlur*this._resolution,M=t.dropShadowDistance*this._resolution;i.shadowColor=nt.shared.setValue(w).setAlpha(t.dropShadowAlpha).toRgbaString(),i.shadowBlur=R,i.shadowOffsetX=Math.cos(t.dropShadowAngle)*M,i.shadowOffsetY=Math.sin(t.dropShadowAngle)*M+_}else i.fillStyle=this._generateFillStyle(t,a,r),i.strokeStyle=t.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let y=(l-c.fontSize)/2;l-c.fontSize<0&&(y=0);for(let w=0;w<a.length;w++)d=t.strokeThickness/2,f=t.strokeThickness/2+w*l+c.ascent+y,t.align==="right"?d+=u-h[w]:t.align==="center"&&(d+=(u-h[w])/2),t.stroke&&t.strokeThickness&&this.drawLetterSpacing(a[w],d+t.padding,f+t.padding-v,!0),t.fill&&this.drawLetterSpacing(a[w],d+t.padding,f+t.padding-v)}this.updateTexture()}drawLetterSpacing(e,t,i,r=!1){const s=this._style.letterSpacing;let o=!1;if(Zn.experimentalLetterSpacingSupported&&(Zn.experimentalLetterSpacing?(this.context.letterSpacing=`${s}px`,this.context.textLetterSpacing=`${s}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),s===0||o){r?this.context.strokeText(e,t,i):this.context.fillText(e,t,i);return}let a=t;const l=Zn.graphemeSegmenter(e);let h=this.context.measureText(e).width,u=0;for(let c=0;c<l.length;++c){const d=l[c];r?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let p=c+1;p<l.length;++p)f+=l[p];u=this.context.measureText(f).width,a+=h-u+s,h=u}}updateTexture(){const e=this.canvas;if(this._style.trim){const o=oR(e);o.data&&(e.width=o.width,e.height=o.height,this.context.putImageData(o.data,0,0))}const t=this._texture,i=this._style,r=i.trim?0:i.padding,s=t.baseTexture;t.trim.width=t._frame.width=e.width/this._resolution,t.trim.height=t._frame.height=e.height/this._resolution,t.trim.x=-r,t.trim.y=-r,t.orig.width=t._frame.width-r*2,t.orig.height=t._frame.height-r*2,this._onTextureUpdate(),s.setRealSize(e.width,e.height,this._resolution),t.updateUvs(),this.dirty=!1}_render(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),super._render(e)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(e,t){return this.updateText(!0),this._textureID===-1&&(e=!1),super.getBounds(e,t)}getLocalBounds(e){return this.updateText(!0),super.getLocalBounds.call(this,e)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(e,t,i){const r=e.fill;if(Array.isArray(r)){if(r.length===1)return r[0]}else return r;let s;const o=e.dropShadow?e.dropShadowDistance:0,a=e.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,u=r.slice(),c=e.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let f=1;f<d;++f)c.push(f/d)}if(u.unshift(r[0]),c.unshift(0),u.push(r[r.length-1]),c.push(1),e.fillGradientType===ml.LINEAR_VERTICAL){s=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+e.strokeThickness;for(let f=0;f<t.length;f++){const p=i.lineHeight*(f-1)+d,g=i.lineHeight*f;let m=g;f>0&&p>g&&(m=(g+p)/2);const v=g+d,_=i.lineHeight*(f+1);let y=v;f+1<t.length&&_<v&&(y=(v+_)/2);const w=(y-m)/h;for(let R=0;R<u.length;R++){let M=0;typeof c[R]=="number"?M=c[R]:M=R/u.length;let C=Math.min(1,Math.max(0,m/h+M*w));C=Number(C.toFixed(5)),s.addColorStop(C,u[R])}}}else{s=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=u.length+1;let f=1;for(let p=0;p<u.length;p++){let g;typeof c[p]=="number"?g=c[p]:g=f/d,s.addColorStop(g,u[p]),f++}}return s}destroy(e){typeof e=="boolean"&&(e={children:e}),e=Object.assign({},H2,e),super.destroy(e),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this.updateText(!0);const t=Vn(this.scale.x)||1;this.scale.x=t*e/this._texture.orig.width,this._width=e}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this.updateText(!0);const t=Vn(this.scale.y)||1;this.scale.y=t*e/this._texture.orig.height,this._height=e}get style(){return this._style}set style(e){e=e||{},e instanceof Kn?this._style=e:this._style=new Kn(e),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(e){e=String(e??""),this._text!==e&&(this._text=e,this.dirty=!0)}get resolution(){return this._resolution}set resolution(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)}};zv.defaultAutoResolution=!0;let Gv=zv;class z2{constructor(e){this.maxItemsPerFrame=e,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function G2(n,e){var t;let i=!1;if((t=n?._textures)!=null&&t.length){for(let r=0;r<n._textures.length;r++)if(n._textures[r]instanceof Ee){const s=n._textures[r].baseTexture;e.includes(s)||(e.push(s),i=!0)}}return i}function V2(n,e){if(n.baseTexture instanceof Fe){const t=n.baseTexture;return e.includes(t)||e.push(t),!0}return!1}function W2(n,e){if(n._texture&&n._texture instanceof Ee){const t=n._texture.baseTexture;return e.includes(t)||e.push(t),!0}return!1}function j2(n,e){return e instanceof Gv?(e.updateText(!0),!0):!1}function X2(n,e){if(e instanceof Kn){const t=e.toFontString();return Zn.measureFont(t),!0}return!1}function Y2(n,e){if(n instanceof Gv){e.includes(n.style)||e.push(n.style),e.includes(n)||e.push(n);const t=n._texture.baseTexture;return e.includes(t)||e.push(t),!0}return!1}function q2(n,e){return n instanceof Kn?(e.includes(n)||e.push(n),!0):!1}const Vv=class Py{constructor(e){this.limiter=new z2(Py.uploadsPerFrame),this.renderer=e,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(Y2),this.registerFindHook(q2),this.registerFindHook(G2),this.registerFindHook(V2),this.registerFindHook(W2),this.registerUploadHook(j2),this.registerUploadHook(X2)}upload(e){return new Promise(t=>{e&&this.add(e),this.queue.length?(this.completes.push(t),this.ticking||(this.ticking=!0,pi.system.addOnce(this.tick,this,Mr.UTILITY))):t()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const e=this.queue[0];let t=!1;if(e&&!e._destroyed){for(let i=0,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,e)){this.queue.shift(),t=!0;break}}t||this.queue.shift()}if(this.queue.length)pi.system.addOnce(this.tick,this,Mr.UTILITY);else{this.ticking=!1;const e=this.completes.slice(0);this.completes.length=0;for(let t=0,i=e.length;t<i;t++)e[t]()}}registerFindHook(e){return e&&this.addHooks.push(e),this}registerUploadHook(e){return e&&this.uploadHooks.push(e),this}add(e){for(let t=0,i=this.addHooks.length;t<i&&!this.addHooks[t](e,this.queue);t++);if(e instanceof ki)for(let t=e.children.length-1;t>=0;t--)this.add(e.children[t]);return this}destroy(){this.ticking&&pi.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};Vv.uploadsPerFrame=4;let xc=Vv;Object.defineProperties(de,{UPLOADS_PER_FRAME:{get(){return xc.uploadsPerFrame},set(n){We("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),xc.uploadsPerFrame=n}}});function Wv(n,e){return e instanceof Fe?(e._glTextures[n.CONTEXT_UID]||n.texture.bind(e),!0):!1}function Z2(n,e){if(!(e instanceof Co))return!1;const{geometry:t}=e;e.finishPoly(),t.updateBatches();const{batches:i}=t;for(let r=0;r<i.length;r++){const{texture:s}=i[r].style;s&&Wv(n,s.baseTexture)}return t.batchable||n.geometry.bind(t,e._resolveDirectShader(n)),!0}function K2(n,e){return n instanceof Co?(e.push(n),!0):!1}class jv extends xc{constructor(e){super(e),this.uploadHookHelper=this.renderer,this.registerFindHook(K2),this.registerUploadHook(Wv),this.registerUploadHook(Z2)}}jv.extension={name:"prepare",type:ue.RendererSystem},Te.add(jv);var Q2=`#version 300 es
1096
+ #define SHADER_NAME Tiling-Sprite-100
1097
+
1098
+ precision lowp float;
1099
+
1100
+ in vec2 vTextureCoord;
1101
+
1102
+ out vec4 fragmentColor;
1103
+
1104
+ uniform sampler2D uSampler;
1105
+ uniform vec4 uColor;
1106
+ uniform mat3 uMapCoord;
1107
+ uniform vec4 uClampFrame;
1108
+ uniform vec2 uClampOffset;
1109
+
1110
+ void main(void)
1111
+ {
1112
+ vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
1113
+ coord = (uMapCoord * vec3(coord, 1.0)).xy;
1114
+ vec2 unclamped = coord;
1115
+ coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
1116
+
1117
+ vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0
1118
+
1119
+ fragmentColor = texSample * uColor;
1120
+ }
1121
+ `,J2=`#version 300 es
1122
+ #define SHADER_NAME Tiling-Sprite-300
1123
+
1124
+ precision lowp float;
1125
+
1126
+ in vec2 aVertexPosition;
1127
+ in vec2 aTextureCoord;
1128
+
1129
+ uniform mat3 projectionMatrix;
1130
+ uniform mat3 translationMatrix;
1131
+ uniform mat3 uTransform;
1132
+
1133
+ out vec2 vTextureCoord;
1134
+
1135
+ void main(void)
1136
+ {
1137
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
1138
+
1139
+ vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1140
+ }
1141
+ `,$2=`#version 100
1142
+ #ifdef GL_EXT_shader_texture_lod
1143
+ #extension GL_EXT_shader_texture_lod : enable
1144
+ #endif
1145
+ #define SHADER_NAME Tiling-Sprite-100
1146
+
1147
+ precision lowp float;
1148
+
1149
+ varying vec2 vTextureCoord;
1150
+
1151
+ uniform sampler2D uSampler;
1152
+ uniform vec4 uColor;
1153
+ uniform mat3 uMapCoord;
1154
+ uniform vec4 uClampFrame;
1155
+ uniform vec2 uClampOffset;
1156
+
1157
+ void main(void)
1158
+ {
1159
+ vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
1160
+ coord = (uMapCoord * vec3(coord, 1.0)).xy;
1161
+ vec2 unclamped = coord;
1162
+ coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
1163
+
1164
+ #ifdef GL_EXT_shader_texture_lod
1165
+ vec4 texSample = unclamped == coord
1166
+ ? texture2D(uSampler, coord)
1167
+ : texture2DLodEXT(uSampler, coord, 0);
1168
+ #else
1169
+ vec4 texSample = texture2D(uSampler, coord);
1170
+ #endif
1171
+
1172
+ gl_FragColor = texSample * uColor;
1173
+ }
1174
+ `,Xv=`#version 100
1175
+ #define SHADER_NAME Tiling-Sprite-100
1176
+
1177
+ precision lowp float;
1178
+
1179
+ attribute vec2 aVertexPosition;
1180
+ attribute vec2 aTextureCoord;
1181
+
1182
+ uniform mat3 projectionMatrix;
1183
+ uniform mat3 translationMatrix;
1184
+ uniform mat3 uTransform;
1185
+
1186
+ varying vec2 vTextureCoord;
1187
+
1188
+ void main(void)
1189
+ {
1190
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
1191
+
1192
+ vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1193
+ }
1194
+ `,eI=`#version 100
1195
+ #define SHADER_NAME Tiling-Sprite-Simple-100
1196
+
1197
+ precision lowp float;
1198
+
1199
+ varying vec2 vTextureCoord;
1200
+
1201
+ uniform sampler2D uSampler;
1202
+ uniform vec4 uColor;
1203
+
1204
+ void main(void)
1205
+ {
1206
+ vec4 texSample = texture2D(uSampler, vTextureCoord);
1207
+ gl_FragColor = texSample * uColor;
1208
+ }
1209
+ `;const yl=new at;class Yv extends Xa{constructor(e){super(e),e.runners.contextChange.add(this),this.quad=new Rm,this.state=sn.for2d()}contextChange(){const e=this.renderer,t={globals:e.globalUniforms};this.simpleShader=on.from(Xv,eI,t),this.shader=e.context.webGLVersion>1?on.from(J2,Q2,t):on.from(Xv,$2,t)}render(e){const t=this.renderer,i=this.quad;let r=i.vertices;r[0]=r[6]=e._width*-e.anchor.x,r[1]=r[3]=e._height*-e.anchor.y,r[2]=r[4]=e._width*(1-e.anchor.x),r[5]=r[7]=e._height*(1-e.anchor.y);const s=e.uvRespectAnchor?e.anchor.x:0,o=e.uvRespectAnchor?e.anchor.y:0;r=i.uvs,r[0]=r[6]=-s,r[1]=r[3]=-o,r[2]=r[4]=1-s,r[5]=r[7]=1-o,i.invalidate();const a=e._texture,l=a.baseTexture,h=l.alphaMode>0,u=e.tileTransform.localTransform,c=e.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[t.CONTEXT_UID]?d=l.wrapMode!==Gn.CLAMP:l.wrapMode===Gn.CLAMP&&(l.wrapMode=Gn.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,g=a.height,m=e._width,v=e._height;yl.set(u.a*p/m,u.b*p/v,u.c*g/m,u.d*g/v,u.tx/m,u.ty/v),yl.invert(),d?yl.prepend(c.mapCoord):(f.uniforms.uMapCoord=c.mapCoord.toArray(!0),f.uniforms.uClampFrame=c.uClampFrame,f.uniforms.uClampOffset=c.uClampOffset),f.uniforms.uTransform=yl.toArray(!0),f.uniforms.uColor=nt.shared.setValue(e.tint).premultiply(e.worldAlpha,h).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=e.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,t.shader.bind(f),t.geometry.bind(i),this.state.blendMode=em(e.blendMode,h),t.state.set(this.state),t.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Yv.extension={name:"tilingSprite",type:ue.RendererPlugin},Te.add(Yv);const qv=class Oo{constructor(e,t,i){this.linkedSheets=[],(e instanceof Fe||e instanceof Ee)&&(e={texture:e,data:t,resolutionFilename:i});const{texture:r,data:s,resolutionFilename:o=null,cachePrefix:a=""}=e;this.cachePrefix=a,this._texture=r instanceof Ee?r:null,this.baseTexture=r instanceof Fe?r:this._texture.baseTexture,this.textures={},this.animations={},this.data=s;const l=this.baseTexture.resource;this.resolution=this._updateResolution(o||(l?l.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(e=null){const{scale:t}=this.data.meta;let i=bn(e,null);return i===null&&(i=typeof t=="number"?t:parseFloat(t??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=Oo.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let t=e;const i=Oo.BATCH_SIZE;for(;t-e<i&&t<this._frameKeys.length;){const r=this._frameKeys[t],s=this._frames[r],o=s.frame;if(o){let a=null,l=null;const h=s.trimmed!==!1&&s.sourceSize?s.sourceSize:s.frame,u=new Ue(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);s.rotated?a=new Ue(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 Ue(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),s.trimmed!==!1&&s.spriteSourceSize&&(l=new Ue(Math.floor(s.spriteSourceSize.x)/this.resolution,Math.floor(s.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[r]=new Ee(this.baseTexture,a,u,l,s.rotated?2:0,s.anchor,s.borders),Ee.addToCache(this.textures[r],this.cachePrefix+r.toString())}t++}}_processAnimations(){const e=this.data.animations||{};for(const t in e){this.animations[t]=[];for(let i=0;i<e[t].length;i++){const r=e[t][i];this.animations[t].push(this.textures[r])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Oo.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Oo.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){var t;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&((t=this._texture)==null||t.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};qv.BATCH_SIZE=1e3;let Zv=qv;const tI=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function Kv(n,e,t){const i={};if(n.forEach(r=>{i[r]=e}),Object.keys(e.textures).forEach(r=>{i[`${e.cachePrefix}${r}`]=e.textures[r]}),!t){const r=Pt.dirname(n[0]);e.linkedSheets.forEach((s,o)=>{Object.assign(i,Kv([`${r}/${e.data.meta.related_multi_packs[o]}`],s,!0))})}return i}const iI={extension:ue.Asset,cache:{test:n=>n instanceof Zv,getCacheableAssets:(n,e)=>Kv(n,e,!1)},resolver:{test:n=>{const e=n.split("?")[0].split("."),t=e.pop(),i=e.pop();return t==="json"&&tI.includes(i)},parse:n=>{var e;const t=n.split(".");return{resolution:parseFloat(((e=de.RETINA_PREFIX.exec(n))==null?void 0:e[1])??"1"),format:t[t.length-2],src:n}}},loader:{name:"spritesheetLoader",extension:{type:ue.LoadParser,priority:zi.Normal},async testParse(n,e){return Pt.extname(e.src).toLowerCase()===".json"&&!!n.frames},async parse(n,e,t){var i,r;const{texture:s,imageFilename:o,cachePrefix:a}=e?.data??{};let l=Pt.dirname(e.src);l&&l.lastIndexOf("/")!==l.length-1&&(l+="/");let h;if(s&&s.baseTexture)h=s;else{const d=sc(l+(o??n.meta.image),e.src);h=(await t.load([d]))[d]}const u=new Zv({texture:h.baseTexture,data:n,resolutionFilename:e.src,cachePrefix:a});await u.parse();const c=(i=n?.meta)==null?void 0:i.related_multi_packs;if(Array.isArray(c)){const d=[];for(const p of c){if(typeof p!="string")continue;let g=l+p;(r=e.data)!=null&&r.ignoreMultiPack||(g=sc(g,e.src),d.push(t.load({src:g,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);u.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[u].concat(u.linkedSheets.filter(g=>g!==p))})}return u},unload(n){n.destroy(!0)}}};Te.add(iI);class _l{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class xl{static test(e){return typeof e=="string"&&e.startsWith("info face=")}static parse(e){const t=e.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const s in t){const o=t[s].match(/^[a-z]+/gm)[0],a=t[s].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const u=a[h].split("="),c=u[0],d=u[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;l[c]=p}i[o].push(l)}const r=new _l;return i.info.forEach(s=>r.info.push({face:s.face,size:parseInt(s.size,10)})),i.common.forEach(s=>r.common.push({lineHeight:parseInt(s.lineHeight,10)})),i.page.forEach(s=>r.page.push({id:parseInt(s.id,10),file:s.file})),i.char.forEach(s=>r.char.push({id:parseInt(s.id,10),page:parseInt(s.page,10),x:parseInt(s.x,10),y:parseInt(s.y,10),width:parseInt(s.width,10),height:parseInt(s.height,10),xoffset:parseInt(s.xoffset,10),yoffset:parseInt(s.yoffset,10),xadvance:parseInt(s.xadvance,10)})),i.kerning.forEach(s=>r.kerning.push({first:parseInt(s.first,10),second:parseInt(s.second,10),amount:parseInt(s.amount,10)})),i.distanceField.forEach(s=>r.distanceField.push({distanceRange:parseInt(s.distanceRange,10),fieldType:s.fieldType})),r}}class wc{static test(e){const t=e;return typeof e!="string"&&"getElementsByTagName"in e&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(e){const t=new _l,i=e.getElementsByTagName("info"),r=e.getElementsByTagName("common"),s=e.getElementsByTagName("page"),o=e.getElementsByTagName("char"),a=e.getElementsByTagName("kerning"),l=e.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)t.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<r.length;h++)t.common.push({lineHeight:parseInt(r[h].getAttribute("lineHeight"),10)});for(let h=0;h<s.length;h++)t.page.push({id:parseInt(s[h].getAttribute("id"),10)||0,file:s[h].getAttribute("file")});for(let h=0;h<o.length;h++){const u=o[h];t.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)t.kerning.push({first:parseInt(a[h].getAttribute("first"),10),second:parseInt(a[h].getAttribute("second"),10),amount:parseInt(a[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)t.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return t}}class Tc{static test(e){return typeof e=="string"&&e.includes("<font>")?wc.test(de.ADAPTER.parseXML(e)):!1}static parse(e){return wc.parse(de.ADAPTER.parseXML(e))}}const Ec=[xl,wc,Tc];function nI(n){for(let e=0;e<Ec.length;e++)if(Ec[e].test(n))return Ec[e];return null}function rI(n,e,t,i,r,s){const o=t.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=t.dropShadow?t.dropShadowDistance:0,h=t.padding||0,u=n.width/i-l-h*2,c=n.height/i-l-h*2,d=o.slice(),f=t.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let g=1;g<p;++g)f.push(g/p)}if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),t.fillGradientType===ml.LINEAR_VERTICAL){a=e.createLinearGradient(u/2,h,u/2,c+h);let p=0;const g=(s.fontProperties.fontSize+t.strokeThickness)/c;for(let m=0;m<r.length;m++){const v=s.lineHeight*m;for(let _=0;_<d.length;_++){let y=0;typeof f[_]=="number"?y=f[_]:y=_/d.length;const w=v/c+y*g;let R=Math.max(p,w);R=Math.min(R,1),a.addColorStop(R,d[_]),p=R}}}else{a=e.createLinearGradient(h,c/2,u+h,c/2);const p=d.length+1;let g=1;for(let m=0;m<d.length;m++){let v;typeof f[m]=="number"?v=f[m]:v=g/p,a.addColorStop(v,d[m]),g++}}return a}function sI(n,e,t,i,r,s,o){const a=t.text,l=t.fontProperties;e.translate(i,r),e.scale(s,s);const h=o.strokeThickness/2,u=-(o.strokeThickness/2);if(e.font=o.toFontString(),e.lineWidth=o.strokeThickness,e.textBaseline=o.textBaseline,e.lineJoin=o.lineJoin,e.miterLimit=o.miterLimit,e.fillStyle=rI(n,e,o,s,[a],t),e.strokeStyle=o.stroke,o.dropShadow){const c=o.dropShadowColor,d=o.dropShadowBlur*s,f=o.dropShadowDistance*s;e.shadowColor=nt.shared.setValue(c).setAlpha(o.dropShadowAlpha).toRgbaString(),e.shadowBlur=d,e.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,e.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else e.shadowColor="black",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0;o.stroke&&o.strokeThickness&&e.strokeText(a,h,u+t.lineHeight-l.descent),o.fill&&e.fillText(a,h,u+t.lineHeight-l.descent),e.setTransform(1,0,0,1,0,0),e.fillStyle="rgba(0, 0, 0, 0)"}function wl(n){return n.codePointAt?n.codePointAt(0):n.charCodeAt(0)}function Qv(n){return Array.from?Array.from(n):n.split("")}function oI(n){typeof n=="string"&&(n=[n]);const e=[];for(let t=0,i=n.length;t<i;t++){const r=n[t];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);const s=r[0].charCodeAt(0),o=r[1].charCodeAt(0);if(o<s)throw new Error("[BitmapFont]: Invalid character range.");for(let a=s,l=o;a<=l;a++)e.push(String.fromCharCode(a))}else e.push(...Qv(r))}if(e.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}const Qn=class hn{constructor(e,t,i){var r;const[s]=e.info,[o]=e.common,[a]=e.page,[l]=e.distanceField,h=bn(a.file),u={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=o.lineHeight/h,this.chars={},this.pageTextures=u;for(let c=0;c<e.page.length;c++){const{id:d,file:f}=e.page[c];u[d]=t instanceof Array?t[c]:t[f],l!=null&&l.fieldType&&l.fieldType!=="none"&&(u[d].baseTexture.alphaMode=li.NO_PREMULTIPLIED_ALPHA,u[d].baseTexture.mipmap=$i.OFF)}for(let c=0;c<e.char.length;c++){const{id:d,page:f}=e.char[c];let{x:p,y:g,width:m,height:v,xoffset:_,yoffset:y,xadvance:w}=e.char[c];p/=h,g/=h,m/=h,v/=h,_/=h,y/=h,w/=h;const R=new Ue(p+u[f].frame.x/h,g+u[f].frame.y/h,m,v);this.chars[d]={xOffset:_,yOffset:y,xAdvance:w,kerning:{},texture:new Ee(u[f].baseTexture,R),page:f}}for(let c=0;c<e.kerning.length;c++){let{first:d,second:f,amount:p}=e.kerning[c];d/=h,f/=h,p/=h,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=l?.distanceRange,this.distanceFieldType=((r=l?.fieldType)==null?void 0:r.toLowerCase())??"none"}destroy(){for(const e in this.chars)this.chars[e].texture.destroy(),this.chars[e].texture=null;for(const e in this.pageTextures)this._ownsTextures&&this.pageTextures[e].destroy(!0),this.pageTextures[e]=null;this.chars=null,this.pageTextures=null}static install(e,t,i){let r;if(e instanceof _l)r=e;else{const o=nI(e);if(!o)throw new Error("Unrecognized data format for font.");r=o.parse(e)}t instanceof Ee&&(t=[t]);const s=new hn(r,t,i);return hn.available[s.font]=s,s}static uninstall(e){const t=hn.available[e];if(!t)throw new Error(`No font found named '${e}'`);t.destroy(),delete hn.available[e]}static from(e,t,i){if(!e)throw new Error("[BitmapFont] Property `name` is required.");const{chars:r,padding:s,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},hn.defaultOptions,i),u=oI(r),c=t instanceof Kn?t:new Kn(t),d=a,f=new _l;f.info[0]={face:c.fontFamily,size:c.fontSize},f.common[0]={lineHeight:c.fontSize};let p=0,g=0,m,v,_,y=0;const w=[];for(let M=0;M<u.length;M++){m||(m=de.ADAPTER.createCanvas(),m.width=a,m.height=l,v=m.getContext("2d"),_=new Fe(m,{resolution:o,...h}),w.push(new Ee(_)),f.page.push({id:w.length-1,file:""}));const C=u[M],O=Zn.measureText(C,c,!1,m),N=O.width,X=Math.ceil(O.height),q=Math.ceil((c.fontStyle==="italic"?2:1)*N);if(g>=l-X*o){if(g===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${C}')`);--M,m=null,v=null,_=null,g=0,p=0,y=0;continue}if(y=Math.max(X+O.fontProperties.descent,y),q*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${C}')`);--M,g+=y*o,g=Math.ceil(g),p=0,y=0;continue}sI(m,v,O,p,g,o,c);const L=wl(O.text);f.char.push({id:L,page:w.length-1,x:p/o,y:g/o,width:q,height:X,xoffset:0,yoffset:0,xadvance:N-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),p+=(q+2*s)*o,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let M=0,C=u.length;M<C;M++){const O=u[M];for(let N=0;N<C;N++){const X=u[N],q=v.measureText(O).width,L=v.measureText(X).width,S=v.measureText(O+X).width-(q+L);S&&f.kerning.push({first:wl(O),second:wl(X),amount:S})}}const R=new hn(f,w,!0);return hn.available[e]!==void 0&&hn.uninstall(e),hn.available[e]=R,R}};Qn.ALPHA=[["a","z"],["A","Z"]," "],Qn.NUMERIC=[["0","9"]],Qn.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Qn.ASCII=[[" ","~"]],Qn.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Qn.ALPHANUMERIC},Qn.available={};let Jn=Qn;var aI=`// Pixi texture info\r
1210
+ varying vec2 vTextureCoord;\r
1211
+ uniform sampler2D uSampler;\r
1212
+ \r
1213
+ // Tint\r
1214
+ uniform vec4 uColor;\r
1215
+ \r
1216
+ // on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r
1217
+ uniform float uFWidth;\r
1218
+ \r
1219
+ void main(void) {\r
1220
+ \r
1221
+ // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r
1222
+ vec4 texColor = texture2D(uSampler, vTextureCoord);\r
1223
+ \r
1224
+ // MSDF\r
1225
+ float median = texColor.r + texColor.g + texColor.b -\r
1226
+ min(texColor.r, min(texColor.g, texColor.b)) -\r
1227
+ max(texColor.r, max(texColor.g, texColor.b));\r
1228
+ // SDF\r
1229
+ median = min(median, texColor.a);\r
1230
+ \r
1231
+ float screenPxDistance = uFWidth * (median - 0.5);\r
1232
+ float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r
1233
+ if (median < 0.01) {\r
1234
+ alpha = 0.0;\r
1235
+ } else if (median > 0.99) {\r
1236
+ alpha = 1.0;\r
1237
+ }\r
1238
+ \r
1239
+ // Gamma correction for coverage-like alpha\r
1240
+ float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r
1241
+ float gamma = mix(1.0, 1.0 / 2.2, luma);\r
1242
+ float coverage = pow(uColor.a * alpha, gamma); \r
1243
+ \r
1244
+ // NPM Textures, NPM outputs\r
1245
+ gl_FragColor = vec4(uColor.rgb, coverage);\r
1246
+ }\r
1247
+ `,lI=`// Mesh material default fragment\r
1248
+ attribute vec2 aVertexPosition;\r
1249
+ attribute vec2 aTextureCoord;\r
1250
+ \r
1251
+ uniform mat3 projectionMatrix;\r
1252
+ uniform mat3 translationMatrix;\r
1253
+ uniform mat3 uTextureMatrix;\r
1254
+ \r
1255
+ varying vec2 vTextureCoord;\r
1256
+ \r
1257
+ void main(void)\r
1258
+ {\r
1259
+ gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r
1260
+ \r
1261
+ vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
1262
+ }\r
1263
+ `;const Jv=[],$v=[],ey=[],hI=class Iy extends ki{constructor(e,t={}){super();const{align:i,tint:r,maxWidth:s,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Iy.styleDefaults,t);if(!Jn.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new nt(r),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=e,this._maxWidth=s,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new Sn(()=>{this.dirty=!0},this,0,0),this._roundPixels=de.ROUND_PIXELS,this.dirty=!0,this._resolution=de.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var e;const t=Jn.available[this._fontName],i=this.fontSize,r=i/t.size,s=new Ye,o=[],a=[],l=[],h=this._text.replace(/(?:\r\n|\r)/g,`
1264
+ `)||" ",u=Qv(h),c=this._maxWidth*t.size/i,d=t.distanceFieldType==="none"?Jv:$v;let f=null,p=0,g=0,m=0,v=-1,_=0,y=0,w=0,R=0;for(let L=0;L<u.length;L++){const S=u[L],I=wl(S);if(/(?:\s)/.test(S)&&(v=L,_=p,R++),S==="\r"||S===`
1265
+ `){a.push(p),l.push(-1),g=Math.max(g,p),++m,++y,s.x=0,s.y+=t.lineHeight,f=null,R=0;continue}const B=t.chars[I];if(!B)continue;f&&B.kerning[f]&&(s.x+=B.kerning[f]);const j=ey.pop()||{texture:Ee.EMPTY,line:0,charCode:0,prevSpaces:0,position:new Ye};j.texture=B.texture,j.line=m,j.charCode=I,j.position.x=Math.round(s.x+B.xOffset+this._letterSpacing/2),j.position.y=Math.round(s.y+B.yOffset),j.prevSpaces=R,o.push(j),p=j.position.x+Math.max(B.xAdvance-B.xOffset,B.texture.orig.width),s.x+=B.xAdvance+this._letterSpacing,w=Math.max(w,B.yOffset+B.texture.height),f=I,v!==-1&&c>0&&s.x>c&&(++y,ys(o,1+v-y,1+L-v),L=v,v=-1,a.push(_),l.push(o.length>0?o[o.length-1].prevSpaces:0),g=Math.max(g,_),m++,s.x=0,s.y+=t.lineHeight,f=null,R=0)}const M=u[u.length-1];M!=="\r"&&M!==`
1266
+ `&&(/(?:\s)/.test(M)&&(p=_),a.push(p),g=Math.max(g,p),l.push(-1));const C=[];for(let L=0;L<=m;L++){let S=0;this._align==="right"?S=g-a[L]:this._align==="center"?S=(g-a[L])/2:this._align==="justify"&&(S=l[L]<0?0:(g-a[L])/l[L]),C.push(S)}const O=o.length,N={},X=[],q=this._activePagesMeshData;d.push(...q);for(let L=0;L<O;L++){const S=o[L].texture,I=S.baseTexture.uid;if(!N[I]){let B=d.pop();if(!B){const U=new O2;let W,ee;t.distanceFieldType==="none"?(W=new Nv(Ee.EMPTY),ee=De.NORMAL):(W=new Nv(Ee.EMPTY,{program:An.from(lI,aI),uniforms:{uFWidth:0}}),ee=De.NORMAL_NPM);const z=new Fv(U,W);z.blendMode=ee,B={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:z,vertices:null,uvs:null,indices:null}}B.index=0,B.indexCount=0,B.vertexCount=0,B.uvsCount=0,B.total=0;const{_textureCache:j}=this;j[I]=j[I]||new Ee(S.baseTexture),B.mesh.texture=j[I],B.mesh.tint=this._tintColor.value,X.push(B),N[I]=B}N[I].total++}for(let L=0;L<q.length;L++)X.includes(q[L])||this.removeChild(q[L].mesh);for(let L=0;L<X.length;L++)X[L].mesh.parent!==this&&this.addChild(X[L].mesh);this._activePagesMeshData=X;for(const L in N){const S=N[L],I=S.total;if(!(((e=S.indices)==null?void 0:e.length)>6*I)||S.vertices.length<Fv.BATCHABLE_SIZE*2)S.vertices=new Float32Array(8*I),S.uvs=new Float32Array(8*I),S.indices=new Uint16Array(6*I);else{const B=S.total,j=S.vertices;for(let U=B*4*2;U<j.length;U++)j[U]=0}S.mesh.size=6*I}for(let L=0;L<O;L++){const S=o[L];let I=S.position.x+C[S.line]*(this._align==="justify"?S.prevSpaces:1);this._roundPixels&&(I=Math.round(I));const B=I*r,j=S.position.y*r,U=S.texture,W=N[U.baseTexture.uid],ee=U.frame,z=U._uvs,H=W.index++;W.indices[H*6+0]=0+H*4,W.indices[H*6+1]=1+H*4,W.indices[H*6+2]=2+H*4,W.indices[H*6+3]=0+H*4,W.indices[H*6+4]=2+H*4,W.indices[H*6+5]=3+H*4,W.vertices[H*8+0]=B,W.vertices[H*8+1]=j,W.vertices[H*8+2]=B+ee.width*r,W.vertices[H*8+3]=j,W.vertices[H*8+4]=B+ee.width*r,W.vertices[H*8+5]=j+ee.height*r,W.vertices[H*8+6]=B,W.vertices[H*8+7]=j+ee.height*r,W.uvs[H*8+0]=z.x0,W.uvs[H*8+1]=z.y0,W.uvs[H*8+2]=z.x1,W.uvs[H*8+3]=z.y1,W.uvs[H*8+4]=z.x2,W.uvs[H*8+5]=z.y2,W.uvs[H*8+6]=z.x3,W.uvs[H*8+7]=z.y3}this._textWidth=g*r,this._textHeight=(s.y+t.lineHeight)*r;for(const L in N){const S=N[L];if(this.anchor.x!==0||this.anchor.y!==0){let U=0;const W=this._textWidth*this.anchor.x,ee=this._textHeight*this.anchor.y;for(let z=0;z<S.total;z++)S.vertices[U++]-=W,S.vertices[U++]-=ee,S.vertices[U++]-=W,S.vertices[U++]-=ee,S.vertices[U++]-=W,S.vertices[U++]-=ee,S.vertices[U++]-=W,S.vertices[U++]-=ee}this._maxLineHeight=w*r;const I=S.mesh.geometry.getBuffer("aVertexPosition"),B=S.mesh.geometry.getBuffer("aTextureCoord"),j=S.mesh.geometry.getIndex();I.data=S.vertices,B.data=S.uvs,j.data=S.indices,I.update(),B.update(),j.update()}for(let L=0;L<o.length;L++)ey.push(o[L]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0);const{distanceFieldRange:t,distanceFieldType:i,size:r}=Jn.available[this._fontName];if(i!=="none"){const{a:s,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(s*s+o*o),u=Math.sqrt(a*a+l*l),c=(Math.abs(h)+Math.abs(u))/2,d=this.fontSize/r,f=e._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=c*t*d*f}super._render(e)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const e=Jn.available[this._fontName];if(!e)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==e&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(e){if(this.tint!==e){this._tintColor.setValue(e);for(let t=0;t<this._activePagesMeshData.length;t++)this._activePagesMeshData[t].mesh.tint=e}}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.dirty=!0)}get fontName(){return this._fontName}set fontName(e){if(!Jn.available[e])throw new Error(`Missing BitmapFont "${e}"`);this._fontName!==e&&(this._fontName=e,this.dirty=!0)}get fontSize(){return this._fontSize??Jn.available[this._fontName].size}set fontSize(e){this._fontSize!==e&&(this._fontSize=e,this.dirty=!0)}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get text(){return this._text}set text(e){e=String(e??""),this._text!==e&&(this._text=e,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(e){this._maxWidth!==e&&(this._maxWidth=e,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(e){e!==this._roundPixels&&(this._roundPixels=e,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)}destroy(e){const{_textureCache:t}=this,i=Jn.available[this._fontName].distanceFieldType==="none"?Jv:$v;i.push(...this._activePagesMeshData);for(const r of this._activePagesMeshData)this.removeChild(r.mesh);this._activePagesMeshData=[],i.filter(r=>t[r.mesh.texture.baseTexture.uid]).forEach(r=>{r.mesh.texture=Ee.EMPTY});for(const r in t)t[r].destroy(),delete t[r];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(e)}};hI.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const uI=[".xml",".fnt"],cI={extension:{type:ue.LoadParser,priority:zi.Normal},name:"loadBitmapFont",test(n){return uI.includes(Pt.extname(n).toLowerCase())},async testParse(n){return xl.test(n)||Tc.test(n)},async parse(n,e,t){const i=xl.test(n)?xl.parse(n):Tc.parse(n),{src:r}=e,{page:s}=i,o=[];for(let h=0;h<s.length;++h){const u=s[h].file;let c=Pt.join(Pt.dirname(r),u);c=sc(c,r),o.push(c)}const a=await t.load(o),l=o.map(h=>a[h]);return Jn.install(i,l,!0)},async load(n,e){return(await de.ADAPTER.fetch(n)).text()},unload(n){n.destroy()}};Te.add(cI);const bc=class Ls extends Kn{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(e){return new Ls(Object.keys(Ls.defaultOptions).reduce((t,i)=>({...t,[i]:e[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(e=>{URL.revokeObjectURL(e.src),e.refs--,e.refs===0&&(e.fontFace&&document.fonts.delete(e.fontFace),delete Ls.availableFonts[e.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(e,t={}){const{availableFonts:i}=Ls;if(i[e]){const r=i[e];return this._fonts.push(r),r.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return de.ADAPTER.fetch(e).then(r=>r.blob()).then(async r=>new Promise((s,o)=>{const a=URL.createObjectURL(r),l=new FileReader;l.onload=()=>s([a,l.result]),l.onerror=o,l.readAsDataURL(r)})).then(async([r,s])=>{const o=Object.assign({family:Pt.basename(e,Pt.extname(e)),weight:"normal",style:"normal",display:"auto",src:r,dataSrc:s,refs:1,originalUrl:e,fontFace:null},t);i[e]=o,this._fonts.push(o),this.styleID++;const a=new FontFace(o.family,`url(${o.src})`,{weight:o.weight,style:o.style,display:o.display});o.fontFace=a,await a.load(),document.fonts.add(a),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...e){const t=e.filter(i=>!this._overrides.includes(i));t.length>0&&(this._overrides.push(...t),this.styleID++)}removeOverride(...e){const t=e.filter(i=>this._overrides.includes(i));t.length>0&&(this._overrides=this._overrides.filter(i=>!t.includes(i)),this.styleID++)}toCSS(e){return[`transform: scale(${e})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((e,t)=>`${e}
1267
+ @font-face {
1268
+ font-family: "${t.family}";
1269
+ src: url('${t.dataSrc}');
1270
+ font-weight: ${t.weight};
1271
+ font-style: ${t.style};
1272
+ font-display: ${t.display};
1273
+ }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(e){this._stylesheet!==e&&(this._stylesheet=e,this.styleID++)}normalizeColor(e){return Array.isArray(e)&&(e=eR(e)),typeof e=="number"?$A(e):e}dropShadowToCSS(){let e=this.normalizeColor(this.dropShadowColor);const t=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),r=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);e.startsWith("#")&&t<1&&(e+=(t*255|0).toString(16).padStart(2,"0"));const s=`${i}px ${r}px`;return this.dropShadowBlur>0?`text-shadow: ${s} ${this.dropShadowBlur}px ${e}`:`text-shadow: ${s} ${e}`}reset(){Object.assign(this,Ls.defaultOptions)}onBeforeDraw(){const{fontsDirty:e}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&e?new Promise(t=>setTimeout(t,100)):Promise.resolve()}get isSafari(){const{userAgent:e}=de.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}set fillGradientStops(e){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(e){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(e){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(e){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(e){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(e){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(e){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};bc.availableFonts={},bc.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let Sc=bc;const Tl=class Bs extends ws{constructor(e="",t={}){super(Ee.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,r=Ee.from(i,{scaleMode:de.SCALE_MODE,resourceOptions:{autoLoad:!1}});r.orig=new Ue,r.trim=new Ue,this.texture=r;const s="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(s,"svg"),l=document.createElementNS(s,"foreignObject"),h=document.createElementNS(o,"div"),u=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Bs.defaultMaxWidth,this.maxHeight=Bs.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Bs.defaultAutoResolution,this._resolution=Bs.defaultResolution??de.RESOLUTION,this.text=e,this.style=t}measureText(e){var t,i;const{text:r,style:s,resolution:o}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},e);Object.assign(this._domElement,{innerHTML:r,style:s.toCSS(o)}),this._styleElement.textContent=s.toGlobalCSS(),document.body.appendChild(this._svgRoot);const a=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:l,height:h}=a;(l>this.maxWidth||h>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const u=Math.min(this.maxWidth,Math.ceil(l)),c=Math.min(this.maxHeight,Math.ceil(h));return this._svgRoot.setAttribute("width",u.toString()),this._svgRoot.setAttribute("height",c.toString()),r!==this._text&&(this._domElement.innerHTML=this._text),s!==this._style&&(Object.assign(this._domElement,{style:(t=this._style)==null?void 0:t.toCSS(o)}),this._styleElement.textContent=(i=this._style)==null?void 0:i.toGlobalCSS()),{width:u+s.padding*2,height:c+s.padding*2}}async updateText(e=!0){const{style:t,_image:i,_loadImage:r}=this;if(this.localStyleID!==t.styleID&&(this.dirty=!0,this.localStyleID=t.styleID),!this.dirty&&e)return;const{width:s,height:o}=this.measureText();i.width=r.width=Math.ceil(Math.max(1,s)),i.height=r.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{r.onload=async()=>{if(a<this._updateID){l();return}await t.onBeforeDraw(),i.src=r.src,r.onload=null,r.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:e,texture:t,_image:i,resolution:r}=this,{padding:s}=e,{baseTexture:o}=t;t.trim.width=t._frame.width=i.width/r,t.trim.height=t._frame.height=i.height/r,t.trim.x=-s,t.trim.y=-s,t.orig.width=t._frame.width-s*2,t.orig.height=t._frame.height-s*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,r),this.dirty=!1}_render(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),super._render(e)}_renderCanvas(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(e)}getLocalBounds(e){return this.updateText(!0),super.getLocalBounds(e)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(e){var t,i,r,s,o;typeof e=="boolean"&&(e={children:e}),e=Object.assign({},Bs.defaultDestroyOptions,e),super.destroy(e);const a=null;this.ownsStyle&&((t=this._style)==null||t.cleanFonts()),this._style=a,(i=this._svgRoot)==null||i.remove(),this._svgRoot=a,(r=this._domElement)==null||r.remove(),this._domElement=a,(s=this._foreignObject)==null||s.remove(),this._foreignObject=a,(o=this._styleElement)==null||o.remove(),this._styleElement=a,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=a,this._image.src="",this._image=a}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(e){this.updateText(!0);const t=Vn(this.scale.x)||1;this.scale.x=t*e/this._image.width/this.resolution,this._width=e}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(e){this.updateText(!0);const t=Vn(this.scale.y)||1;this.scale.y=t*e/this._image.height/this.resolution,this._height=e}get style(){return this._style}set style(e){this._style!==e&&(e=e||{},e instanceof Sc?(this.ownsStyle=!1,this._style=e):e instanceof Kn?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Sc.from(e)):(this.ownsStyle=!0,this._style=new Sc(e)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(e){e=String(e===""||e===null||e===void 0?" ":e),e=this.sanitiseText(e),this._text!==e&&(this._text=e,this.dirty=!0)}get resolution(){return this._resolution}set resolution(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)}sanitiseText(e){return e.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};Tl.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Tl.defaultMaxWidth=2024,Tl.defaultMaxHeight=2024,Tl.defaultAutoResolution=!0;const dI=16777215,fI=.25,pI=16777215,gI=1,mI=1.5;let $n=!1,Ps;const Ac=n=>{const e={tint:n!=null&&n.fill?new nt(n.fill).toNumber():dI,alpha:n?.fillOpacity!==void 0?Math.min(n.fillOpacity,1):String(n?.fill).toLowerCase().startsWith("rgba(")?new nt(n?.fill).alpha:fI},t={tint:n!=null&&n.stroke?new nt(n.stroke).toNumber():pI,alpha:n?.strokeOpacity!==void 0?Math.min(n.strokeOpacity,1):String(n?.stroke).toLowerCase().startsWith("rgba(")?new nt(n?.stroke).alpha:gI,lineWidth:n?.strokeWidth===void 0?mI:n.strokeWidth};return{fillStyle:e,strokeStyle:t}},Is=n=>(e,t,i,r={})=>{const{fillStyle:s,strokeStyle:o}=Ac(i),a=new Co;r.strokeOnly||(a.beginFill(16777215),n(t,a),a.endFill(),a.tint=s.tint,a.alpha=s.alpha),e.addChild(a);const l=new Co,h=o.lineWidth===1?1:o.lineWidth/Ps;return l.lineStyle(h,16777215,1,.5,o.lineWidth===1),n(t,l),l.tint=o.tint||16777215,l.alpha=o.alpha,e.addChild(l),{fill:a,stroke:l,strokeWidth:o.lineWidth}},vI=Is((n,e)=>{const{x:t,y:i,w:r,h:s}=n.geometry;e.drawRect(t,i,r,s)}),yI=Is((n,e)=>{const{cx:t,cy:i,rx:r,ry:s}=n.geometry;e.drawEllipse(t,i,r,s)}),_I=Is((n,e)=>{const[[t,i],[r,s]]=n.geometry.points;e.moveTo(t,i),e.lineTo(r,s),e.closePath()}),xI=Is((n,e)=>{const t=n.geometry.points.reduce((i,r)=>[...i,...r],[]);e.drawPolygon(t)}),wI=Is((n,e)=>{const{points:t,closed:i}=n.geometry;if(t.length===0)return;i||e.beginFill(0,0);const r=(o,a)=>{const[l,h]=o.point,[u,c]=a.point;if(o.type==="CURVE"||a.type==="CURVE"){const d=o.type==="CURVE"&&o.outHandle?o.outHandle[0]:l,f=o.type==="CURVE"&&o.outHandle?o.outHandle[1]:h,p=a.type==="CURVE"&&a.inHandle?a.inHandle[0]:u,g=a.type==="CURVE"&&a.inHandle?a.inHandle[1]:c;e.bezierCurveTo(d,f,p,g,u,c)}else e.lineTo(u,c)},s=t[0];e.moveTo(s.point[0],s.point[1]);for(let o=1;o<t.length;o++){const a=t[o-1],l=t[o];r(a,l)}if(i&&t.length>2){const o=t[t.length-1],a=t[0];r(o,a),e.closePath()}else e.endFill()}),TI=Is((n,e)=>{const t=i=>i.points.reduce((r,s)=>[...r,...s],[]);n.geometry.polygons.forEach(i=>{const[r,...s]=i.rings;e.drawPolygon(t(r)),s.forEach(o=>{e.beginHole(),e.drawPolygon(t(o)),e.endHole()})})}),ty=n=>{const e=n.viewport.getContainerSize().x;return n.viewport.getZoom(!0)*e/n.world.getContentFactor()},iy=(n,e,t,i)=>()=>{const r=n.viewport.viewportToImageRectangle(n.viewport.getBounds(!0)),s=ty(n);(s!==Ps||!$n)&&($n=!0,t.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?($n=s===Ps,p.width=f/s,p.native=!1,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),Ps=s;const o=n.viewport.getFlip();let a=Math.PI*n.viewport.getRotation(!0)/180;a<0&&(a+=2*Math.PI),a>2*Math.PI&&(a-=2*Math.PI);const l=o?n.viewport._containerInnerSize.x+r.x*s:-r.x*s,h=-r.y*s;let u,c;a>0&&a<=Math.PI/2?(u=r.height*s,c=0):a>Math.PI/2&&a<=Math.PI?(u=r.width*s,c=r.height*s):a>Math.PI&&a<=Math.PI*1.5?(u=0,c=r.width*s):(u=0,c=0),e.position.x=u+l*Math.cos(a)-h*Math.sin(a),e.position.y=c+l*Math.sin(a)+h*Math.cos(a),e.scale.set(o?-s:s,s),e.rotation=a,i.render(e)},EI=(n,e)=>{const t=new Co,i=Jm({width:e.width,height:e.height,backgroundAlpha:0,view:e,antialias:!0,resolution:2}),r=new Map;let s=new Set,o,a;Ps=ty(n);const l=(_,y)=>{$n=!1;const w=r.get(_.id);w&&(w.fill.destroy(),w.stroke.destroy());const{selector:R}=_.target,M=typeof a=="function"?a(_,y):a;let C;if(R.type===Ie.RECTANGLE)C=vI(t,R,M);else if(R.type===Ie.POLYGON)C=xI(t,R,M);else if(R.type===Ie.ELLIPSE)C=yI(t,R,M);else if(R.type===Ie.MULTIPOLYGON)C=TI(t,R,M);else if(R.type===Ie.POLYLINE){const O=R;C=wI(t,O,M,{strokeOnly:!O.geometry.closed})}else R.type===Ie.LINE?C=_I(t,R,M):console.warn(`Unsupported shape type: ${R.type}`);C&&r.set(_.id,{annotation:_,...C})},h=_=>{const y=r.get(_.id);y&&(r.delete(_.id),y.fill.destroy(),y.stroke.destroy())},u=(_,y,w)=>{$n=!1;const R=r.get(_.id);if(R&&(r.delete(_.id),R.fill.destroy(),R.stroke.destroy(),l(y,w),s.has(y.id))){const{fill:M,stroke:C}=r.get(y.id);t.removeChild(M),t.removeChild(C)}},c=(_,y)=>{const w=r.get(_);w&&(r.delete(_),w.fill.destroy(),w.stroke.destroy(),l(w.annotation,y))},d=(_,y)=>{i.resize(_,y),i.render(t)},f=_=>{$n=!1;const{children:y}=t;r.forEach(({fill:w,stroke:R,annotation:M})=>{const C=_?s.has(M.id)||_(M):!0;C&&!y.includes(w)?(t.addChild(w),t.addChild(R)):!C&&y.includes(w)&&(t.removeChild(w),t.removeChild(R))}),i.render(t)},p=_=>{const y=new Set(_.selected.map(M=>M.id)),w=_.selected.filter(({id:M})=>!s.has(M)),R=[...s].filter(M=>!y.has(M));w.forEach(({id:M,editable:C})=>{if(C){const O=r.get(M);O&&Fh(O.annotation.target.selector)&&(t.removeChild(O.fill),t.removeChild(O.stroke))}else c(M,{selected:!0,hovered:M===o})}),R.forEach(M=>c(M,{hovered:M===o})),s=y,i.render(t)},g=_=>{o!==_&&(_&&s.has(_)||(o&&!s.has(o)&&c(o,{selected:s.has(o)}),_&&c(_,{selected:s.has(_),hovered:!0}),o=_,i.render(t)))},m=_=>{if(typeof _=="function")r.forEach(({annotation:y,fill:w,stroke:R,strokeWidth:M},C)=>{M>1&&($n=!1);const O={selected:s.has(y.id),hovered:o===y.id},{fillStyle:N,strokeStyle:X}=Ac(_(y,O));w.tint=N.tint,w.alpha=N.alpha,R.tint=X.tint||16777215,R.alpha=X.alpha,r.set(y.id,{annotation:y,fill:w,stroke:R,strokeWidth:X.lineWidth})});else{const{fillStyle:y,strokeStyle:w}=Ac(_);w.lineWidth>1&&($n=!1),r.forEach(({annotation:R,fill:M,stroke:C,strokeWidth:O},N)=>{M.tint=y.tint,M.alpha=y.alpha,C.tint=w.tint||16777215,C.alpha=w.alpha,r.set(R.id,{annotation:R,fill:M,stroke:C,strokeWidth:w.lineWidth})})}a=_,i.render(t),iy(n,t,r,i)()},v=_=>{_?e.classList.remove("hidden"):e.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),getScale:()=>Ps,redraw:iy(n,t,r,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:g,setSelected:p,setStyle:m,setVisible:v,updateAnnotation:u}};function bI(n,e,t){let i,r,{filter:s}=e,{state:o}=e,{style:a}=e,{viewer:l}=e,{visible:h=!0}=e;const{store:u,hover:c,selection:d,viewport:f}=o;ro(n,c,O=>t(11,i=O)),ro(n,d,O=>t(8,r=O));const p=jh(),g=Ei?10:2;let m,v;const _=O=>{const N=new dr.Point(O.x,O.y),{x:X,y:q}=l.viewport.pointFromPixel(N);return l.viewport.viewportToImageCoordinates(X,q)},y=()=>g/m.getScale(),w=O=>{const{x:N,y:X}=O.position;v={x:N,y:X}},R=O=>N=>{const{x:X,y:q}=_(new dr.Point(N.offsetX,N.offsetY)),L=y(),S=u.getAt(X,q,s,L);S?(O.classList.add("hover"),i!==S.id&&(c.set(S.id),m.setHovered(S.id))):(O.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},M=O=>{if(!v)return;const N=O.originalEvent,{x:X,y:q}=O.position,L=X-v.x,S=q-v.y;if(Math.sqrt(L*L+S*S)<5){const{x:I,y:B}=_(O.position),j=y(),U=u.getAt(I,B,s,j);U?p("click",{originalEvent:N,annotation:U}):p("click",{originalEvent:N})}v=void 0};let C;return ao(()=>{var O;const{offsetWidth:N,offsetHeight:X}=l.canvas,q=document.createElement("canvas");q.width=N,q.height=X,q.className="a9s-gl-canvas",(O=l.element.querySelector(".openseadragon-canvas"))==null||O.appendChild(q),t(7,m=EI(l,q));const L=R(q);q.addEventListener("pointermove",L);const S=new ResizeObserver(ee=>{try{const{width:z,height:H}=ee[0].contentRect;q.width=z,q.height=H,m.resize(z,H)}catch{console.warn("WebGL canvas already disposed")}});S.observe(q);const I=()=>{const ee=l.viewport.getBounds();C=l.viewport.viewportToImageRectangle(ee);const{x:z,y:H,width:K,height:$}=C,se=u.getIntersecting(z,H,K,$);f.set(se.map(fe=>fe.id))};l.addHandler("canvas-press",w),l.addHandler("canvas-release",M),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",I);const B=ee=>ee.filter(z=>Ti(z)),j=ee=>Ti(ee.oldValue)&&Ti(ee.newValue),U=ee=>{const{selector:z}=ee.target;if(z.type===Ie.POLYGON){const H=N1(z);return{...ee,target:{...ee.target,selector:{...H}}}}else if(z.type===Ie.MULTIPOLYGON){const H=B1(z);return{...ee,target:{...ee.target,selector:{...H}}}}else return ee},W=ee=>{const{created:z,updated:H,deleted:K}=ee.changes,$=(z||[]).filter(se=>Ti(se)).map(U);if(B(K||[]).forEach(se=>m.removeAnnotation(se)),$.forEach(se=>m.addAnnotation(se)),(H||[]).filter(se=>j(se)).map(({oldValue:se,newValue:fe})=>({oldValue:se,newValue:U(fe)})).forEach(({oldValue:se,newValue:fe})=>m.updateAnnotation(se,fe)),C){const{x:se,y:fe,width:te,height:J}=C,Y=u.getIntersecting(se,fe,te,J);f.set(Y.map(he=>he.id))}else f.set(u.all().map(se=>se.id));m.redraw()};return u.observe(W),()=>{var ee;q.removeEventListener("pointermove",L),S.disconnect(),l.removeHandler("canvas-press",w),l.removeHandler("canvas-release",M),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",I),u.unobserve(W),m.destroy(),(ee=q.parentNode)==null||ee.removeChild(q)}}),n.$$set=O=>{"filter"in O&&t(2,s=O.filter),"state"in O&&t(3,o=O.state),"style"in O&&t(4,a=O.style),"viewer"in O&&t(5,l=O.viewer),"visible"in O&&t(6,h=O.visible)},n.$$.update=()=>{n.$$.dirty&132&&m?.setFilter(s),n.$$.dirty&384&&m?.setSelected(r),n.$$.dirty&144&&m?.setStyle(a),n.$$.dirty&192&&m?.setVisible(h)},[c,d,s,o,a,l,h,m,r]}class SI extends Kt{constructor(e){super(),Zt(this,e,bI,null,Rt,{filter:2,state:3,style:4,viewer:5,visible:6})}}const ny=(n,e,t,i)=>{if(!i)return n;if(e.shiftKey||e.ctrlKey||e.metaKey){const r=(t.selected||[]).map(s=>s.id);return r.includes(n)?r.filter(s=>s!==n):[...r,n]}else return n},AI=n=>({transform:n&2,scale:n&1}),ry=n=>({transform:n[1],scale:n[0]});function RI(n){let e;const t=n[4].default,i=d1(t,n,n[3],ry);return{c(){i&&i.c()},m(r,s){i&&i.m(r,s),e=!0},p(r,[s]){i&&i.p&&(!e||s&11)&&p1(i,t,r,r[3],e?f1(t,r[3],s,AI):g1(r[3]),ry)},i(r){e||(Oe(i,r),e=!0)},o(r){He(i,r),e=!1},d(r){i&&i.d(r)}}}function CI(n,e,t){let{$$slots:i={},$$scope:r}=e,{viewer:s}=e,o=1,a;const l=()=>{const h=s.viewport.getContainerSize().x,u=s.viewport.getZoom(!0),c=s.viewport.getFlip(),d=s.viewport.pixelFromPoint(new dr.Point(0,0),!0);c&&(d.x=h-d.x);const f=u*h/s.world.getContentFactor(),p=c?-f:f,g=s.viewport.getRotation(!0);t(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${g})`),t(0,o=u*h/s.world.getContentFactor())};return ao(()=>(s.addHandler("update-viewport",l),()=>{s.removeHandler("update-viewport",l)})),n.$$set=h=>{"viewer"in h&&t(2,s=h.viewer),"$$scope"in h&&t(3,r=h.$$scope)},[o,a,s,r,i]}class Rc extends Kt{constructor(e){super(),Zt(this,e,CI,RI,Rt,{viewer:2})}}function PI(n,e,t){const i=jh();let{drawingMode:r}=e,{opts:s}=e,{target:o}=e,{tool:a}=e,{transform:l}=e,{viewer:h}=e,{viewportScale:u}=e,c;return ao(()=>{const d=o.closest("svg"),f=[],p=(g,m,v)=>{if(d?.addEventListener(g,m,v),f.push(()=>d?.removeEventListener(g,m,v)),g==="pointerup"||g==="dblclick"){const _=w=>{const{originalEvent:R}=w;m(R)},y=g==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(y,_),f.push(()=>h.removeHandler(y,_))}else if(g==="pointermove"){const _=y=>{const{originalEvent:w}=y;m(w)};h.addHandler("canvas-drag",_),f.push(()=>h.removeHandler("canvas-drag",_))}};return t(7,c=new a({target:o,props:{addEventListener:p,drawingMode:r,opts:s,transform:l,viewportScale:u,svgEl:d}})),c.$on("create",g=>i("create",g.detail)),()=>{f.forEach(g=>g()),c.$destroy()}}),n.$$set=d=>{"drawingMode"in d&&t(0,r=d.drawingMode),"opts"in d&&t(1,s=d.opts),"target"in d&&t(2,o=d.target),"tool"in d&&t(3,a=d.tool),"transform"in d&&t(4,l=d.transform),"viewer"in d&&t(5,h=d.viewer),"viewportScale"in d&&t(6,u=d.viewportScale)},n.$$.update=()=>{n.$$.dirty&144&&c&&c.$set({transform:l}),n.$$.dirty&192&&c&&c.$set({viewportScale:u})},[r,s,o,a,l,h,u,c]}class II extends Kt{constructor(e){super(),Zt(this,e,PI,null,Rt,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}const{Boolean:DI}=Vh;function sy(n,e,t){const i=n.slice();i[41]=e[t];const r=i[19](i[41].target.selector);return i[42]=r,i}function MI(n){let e=`${n[2]}-${n[7]}`,t,i,r=oy(n);return{c(){r.c(),t=_n()},m(s,o){r.m(s,o),ct(s,t,o),i=!0},p(s,o){o[0]&132&&Rt(e,e=`${s[2]}-${s[7]}`)?(bi(),He(r,1,1,yt),Si(),r=oy(s),r.c(),Oe(r,1),r.m(t.parentNode,t)):r.p(s,o)},i(s){i||(Oe(r),i=!0)},o(s){He(r),i=!1},d(s){s&&ht(t),r.d(s)}}}function OI(n){let e,t,i=zn(n[9].filter(n[29])),r=[];for(let o=0;o<i.length;o+=1)r[o]=hy(sy(n,i,o));const s=o=>He(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=_n()},m(o,a){for(let l=0;l<r.length;l+=1)r[l]&&r[l].m(o,a);ct(o,e,a),t=!0},p(o,a){if(a[0]&713474|a[1]&512){i=zn(o[9].filter(o[29]));let l;for(l=0;l<i.length;l+=1){const h=sy(o,i,l);r[l]?(r[l].p(h,a),Oe(r[l],1)):(r[l]=hy(h),r[l].c(),Oe(r[l],1),r[l].m(e.parentNode,e))}for(bi(),l=i.length;l<r.length;l+=1)s(l);Si()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)Oe(r[a]);t=!0}},o(o){r=r.filter(DI);for(let a=0;a<r.length;a+=1)He(r[a]);t=!1},d(o){o&&ht(e),ma(r,o)}}}function oy(n){let e,t;return e=new II({props:{target:n[8],tool:n[10],drawingMode:n[4],transform:{elementToImage:n[13]},viewer:n[3],viewportScale:n[40],opts:n[5]}}),e.$on("create",n[18]),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r[0]&256&&(s.target=i[8]),r[0]&1024&&(s.tool=i[10]),r[0]&16&&(s.drawingMode=i[4]),r[0]&8&&(s.viewer=i[3]),r[1]&512&&(s.viewportScale=i[40]),r[0]&32&&(s.opts=i[5]),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function ay(n){let e=n[41].id,t,i,r=ly(n);return{c(){r.c(),t=_n()},m(s,o){r.m(s,o),ct(s,t,o),i=!0},p(s,o){o[0]&512&&Rt(e,e=s[41].id)?(bi(),He(r,1,1,yt),Si(),r=ly(s),r.c(),Oe(r,1),r.m(t.parentNode,t)):r.p(s,o)},i(s){i||(Oe(r),i=!0)},o(s){He(r),i=!1},d(s){s&&ht(t),r.d(s)}}}function ly(n){let e,t;return e=new Z1({props:{target:n[8],editor:n[19](n[41].target.selector),annotation:n[41],style:n[1],transform:{elementToImage:n[13]},viewportScale:n[40]}}),e.$on("grab",n[14]),e.$on("change",function(){Gh(n[17](n[41]))&&n[17](n[41]).apply(this,arguments)}),e.$on("release",n[15]),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&256&&(s.target=n[8]),r[0]&512&&(s.editor=n[19](n[41].target.selector)),r[0]&512&&(s.annotation=n[41]),r[0]&2&&(s.style=n[1]),r[1]&512&&(s.viewportScale=n[40]),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function hy(n){let e,t,i=n[42]&&ay(n);return{c(){i&&i.c(),e=_n()},m(r,s){i&&i.m(r,s),ct(r,e,s),t=!0},p(r,s){r[42]?i?(i.p(r,s),s[0]&512&&Oe(i,1)):(i=ay(r),i.c(),Oe(i,1),i.m(e.parentNode,e)):i&&(bi(),He(i,1,1,()=>{i=null}),Si())},i(r){t||(Oe(i),t=!0)},o(r){He(i),t=!1},d(r){r&&ht(e),i&&i.d(r)}}}function LI(n){let e,t,i,r,s,o,a,l;const h=[OI,MI],u=[];function c(d,f){var p;return d[8]&&((p=d[9])==null?void 0:p.length)===1?0:d[8]&&d[10]&&d[0]?1:-1}return~(i=c(n))&&(r=u[i]=h[i](n)),{c(){e=dt("svg"),t=dt("g"),r&&r.c(),ie(t,"transform",s=n[39]),ie(t,"class","svelte-g4ws1v"),ie(e,"tabindex",0),ie(e,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-g4ws1v"),ss(e,"drawing",n[0]),ss(e,"editing",n[9]),ss(e,"hover",n[6])},m(d,f){ct(d,e,f),Ki(e,t),~i&&u[i].m(t,null),n[30](t),o=!0,a||(l=m1(e,"pointermove",n[16]),a=!0)},p(d,f){let p=i;i=c(d),i===p?~i&&u[i].p(d,f):(r&&(bi(),He(u[p],1,1,()=>{u[p]=null}),Si()),~i?(r=u[i],r?r.p(d,f):(r=u[i]=h[i](d),r.c()),Oe(r,1),r.m(t,null)):r=null),(!o||f[1]&256&&s!==(s=d[39]))&&ie(t,"transform",s),(!o||f[0]&1)&&ss(e,"drawing",d[0]),(!o||f[0]&512)&&ss(e,"editing",d[9]),(!o||f[0]&64)&&ss(e,"hover",d[6])},i(d){o||(Oe(r),o=!0)},o(d){He(r),o=!1},d(d){d&&ht(e),~i&&u[i].d(),n[30](null),a=!1,l()}}}function BI(n){let e,t;return e=new Rc({props:{viewer:n[3],$$slots:{default:[LI,({transform:i,scale:r})=>({39:i,40:r}),({transform:i,scale:r})=>[0,(i?256:0)|(r?512:0)]]},$$scope:{ctx:n}}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r[0]&8&&(s.viewer=i[3]),r[0]&2047|r[1]&17152&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function FI(n,e,t){let i,r,s,o,a,{drawingEnabled:l}=e,{filter:h}=e,{multiSelect:u}=e,{preferredDrawingMode:c}=e,{state:d}=e,{style:f=void 0}=e,{toolName:p=da()[0]}=e,{user:g}=e,{viewer:m}=e;const v=Ei?10:2;let _=!1,y=0;const w=()=>t(7,y+=1),R=()=>p,M=()=>l;let C;const{store:O,selection:N,hover:X}=d;ro(n,N,te=>t(28,o=te)),ro(n,X,te=>t(33,a=te));let q,L,S;const I=te=>{O.unobserve(q);const J=te.filter(({editable:Y})=>Y).map(({id:Y})=>Y);J.length>0?(t(9,L=J.map(Y=>O.getAnnotation(Y))),q=Y=>{const{updated:he}=Y.changes;t(9,L=(he||[]).map(le=>le.newValue))},O.observe(q,{annotations:J}),m.forceRedraw()):t(9,L=void 0)},B=(te,J)=>{const{x:Y,y:he}=m.viewport.viewerElementToImageCoordinates(new dr.Point(te,J));return[Y,he]},j=()=>{const te=m.viewport.getContainerSize().x;return m.viewport.getZoom(!0)*te/m.world.getContentFactor()},U=()=>v/j(),W=te=>{m.setMouseNavEnabled(!1),S=te.timeStamp},ee=te=>{if(m.setMouseNavEnabled(!0),performance.now()-(S||0)<300){const{offsetX:J,offsetY:Y}=te.detail,[he,le]=B(J,Y),ve=U(),Ce=O.getAt(he,le,void 0,ve);if(Ce&&(!h||h(Ce))&&!L.find(ze=>ze.id===Ce.id)){X.set(Ce.id);const ze=ny(Ce.id,te.detail,N,u);N.userSelect(ze)}}},z=te=>{const J=new dr.Point(te.offsetX,te.offsetY),Y=m.viewport.pointFromPixel(J),{x:he,y:le}=m.viewport.viewportToImageCoordinates(Y.x,Y.y),ve=U(),Ce=O.getAt(he,le,h,ve);Ce?a!==Ce.id&&X.set(Ce.id):a&&X.set(void 0)},H=te=>J=>{var Y;const{target:he}=te,le=600*1e3,ve=((Y=he.creator)==null?void 0:Y.id)!==g.id||!he.created||new Date().getTime()-he.created.getTime()>le;O.updateTarget({...he,selector:J.detail,created:ve?he.created:new Date,updated:ve?new Date:void 0,updatedBy:ve?g:void 0})},K=te=>{const J=X1(),Y={id:J,bodies:[],target:{annotation:J,selector:te.detail,creator:g,created:new Date}};O.addAnnotation(Y),N.setSelected(Y.id),m.setMouseNavEnabled(!0)},$=te=>Fh(te);ao(()=>{const te=J=>{if(o.selected.length===0)return;const{offsetX:Y,offsetY:he}=J,le=m.viewport.pointFromPixel(new dr.Point(Y,he)),{x:ve,y:Ce}=m.viewport.viewportToImageCoordinates(le.x,le.y),ze=U();t(6,_=!!O.getAt(ve,Ce,h,ze))};return m.element.addEventListener("pointermove",te),()=>{var J;(J=m.element)==null||J.removeEventListener("pointermove",te)}});const se=te=>Ti(te);function fe(te){va[te?"unshift":"push"](()=>{C=te,t(8,C)})}return n.$$set=te=>{"drawingEnabled"in te&&t(0,l=te.drawingEnabled),"filter"in te&&t(20,h=te.filter),"multiSelect"in te&&t(21,u=te.multiSelect),"preferredDrawingMode"in te&&t(22,c=te.preferredDrawingMode),"state"in te&&t(23,d=te.state),"style"in te&&t(1,f=te.style),"toolName"in te&&t(2,p=te.toolName),"user"in te&&t(24,g=te.user),"viewer"in te&&t(3,m=te.viewer)},n.$$.update=()=>{n.$$.dirty[0]&4&&t(10,{tool:i,opts:r}=fa(p)||{tool:void 0,opts:void 0},i,(t(5,r),t(2,p))),n.$$.dirty[0]&4194336&&t(4,s=r?.drawingMode||c),n.$$.dirty[0]&25&&(l&&s==="drag"?m.setMouseNavEnabled(!1):m.setMouseNavEnabled(!0)),n.$$.dirty[0]&1&&l&&N.clear(),n.$$.dirty[0]&268435481&&o.selected.length===0&&s==="drag"&&l&&m.setMouseNavEnabled(!1),n.$$.dirty[0]&268435456&&I(o.selected)},[l,f,p,m,s,r,_,y,C,L,i,N,X,B,W,ee,z,H,K,$,h,u,c,d,g,w,R,M,o,se,fe]}class NI extends Kt{constructor(e){super(),Zt(this,e,FI,BI,Rt,{drawingEnabled:0,filter:20,multiSelect:21,preferredDrawingMode:22,state:23,style:1,toolName:2,user:24,viewer:3,cancelDrawing:25,getDrawingTool:26,isDrawingEnabled:27},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[25]}get getDrawingTool(){return this.$$.ctx[26]}get isDrawingEnabled(){return this.$$.ctx[27]}}function kI(n){let e,t,i,r,s,o,a,l=n[2].appearance.label+"",h,u,c,d;return{c(){e=dt("g"),t=dt("rect"),a=dt("text"),h=Np(l),ie(t,"class","a9s-presence-label-bg svelte-1rehw2p"),ie(t,"x",n[0]),ie(t,"y",i=n[1]-18/n[3]),ie(t,"height",r=18/n[3]),ie(t,"fill",s=n[2].appearance.color),ie(t,"stroke",o=n[2].appearance.color),ie(a,"font-size",u=12/n[3]),ie(a,"x",c=n[0]+Math.round(5/n[3])),ie(a,"y",d=n[1]-5/n[3]),ie(a,"class","svelte-1rehw2p"),ie(e,"class","a9s-presence-label")},m(f,p){ct(f,e,p),Ki(e,t),Ki(e,a),Ki(a,h),n[6](e)},p(f,[p]){p&1&&ie(t,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&ie(t,"y",i),p&8&&r!==(r=18/f[3])&&ie(t,"height",r),p&4&&s!==(s=f[2].appearance.color)&&ie(t,"fill",s),p&4&&o!==(o=f[2].appearance.color)&&ie(t,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&y1(h,l),p&8&&u!==(u=12/f[3])&&ie(a,"font-size",u),p&9&&c!==(c=f[0]+Math.round(5/f[3]))&&ie(a,"x",c),p&10&&d!==(d=f[1]-5/f[3])&&ie(a,"y",d)},i:yt,o:yt,d(f){f&&ht(e),n[6](null)}}}function UI(n,e,t){let{x:i}=e,{y:r}=e,{user:s}=e,{scale:o}=e,{hAlign:a=null}=e,l;const h=c=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/c;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function u(c){va[c?"unshift":"push"](()=>{l=c,t(4,l)})}return n.$$set=c=>{"x"in c&&t(0,i=c.x),"y"in c&&t(1,r=c.y),"user"in c&&t(2,s=c.user),"scale"in c&&t(3,o=c.scale),"hAlign"in c&&t(5,a=c.hAlign)},n.$$.update=()=>{n.$$.dirty&24&&l&&h(o)},[i,r,s,o,l,a,u]}class uy extends Kt{constructor(e){super(),Zt(this,e,UI,kI,Rt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function HI(n){let e,t,i,r,s,o;return t=new uy({props:{scale:n[1],user:n[0],x:n[3][0],y:n[3][1],hAlign:"CENTER"}}),{c(){e=dt("g"),ii(t.$$.fragment),i=dt("polygon"),ie(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),ie(i,"stroke",r=n[0].appearance.color),ie(i,"fill","transparent"),ie(i,"points",s=n[2].points.map(cy).join(" ")),ie(e,"class","a9s-presence-overlay")},m(a,l){ct(a,e,l),Yt(t,e,null),Ki(e,i),o=!0},p(a,[l]){const h={};l&2&&(h.scale=a[1]),l&1&&(h.user=a[0]),l&8&&(h.x=a[3][0]),l&8&&(h.y=a[3][1]),t.$set(h),(!o||l&1&&r!==(r=a[0].appearance.color))&&ie(i,"stroke",r),(!o||l&4&&s!==(s=a[2].points.map(cy).join(" ")))&&ie(i,"points",s)},i(a){o||(Oe(t.$$.fragment,a),o=!0)},o(a){He(t.$$.fragment,a),o=!1},d(a){a&&ht(e),qt(t)}}}const cy=n=>n.join(",");function zI(n,e,t){let i,r,{annotation:s}=e,{user:o}=e,{scale:a}=e;const l=h=>{let[u,...c]=h.points;return c.forEach(([d,f])=>{f<u[1]&&(u=[d,f])}),u};return n.$$set=h=>{"annotation"in h&&t(4,s=h.annotation),"user"in h&&t(0,o=h.user),"scale"in h&&t(1,a=h.scale)},n.$$.update=()=>{n.$$.dirty&16&&t(2,i=s.target.selector.geometry),n.$$.dirty&4&&t(3,r=l(i))},[o,a,i,r,s]}class GI extends Kt{constructor(e){super(),Zt(this,e,zI,HI,Rt,{annotation:4,user:0,scale:1})}}function VI(n){let e,t,i,r,s,o,a,l,h;return t=new uy({props:{scale:n[1],user:n[0],x:n[2].x,y:n[2].y}}),{c(){e=dt("g"),ii(t.$$.fragment),i=dt("rect"),ie(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),ie(i,"stroke",r=n[0].appearance.color),ie(i,"fill","transparent"),ie(i,"x",s=n[2].x),ie(i,"y",o=n[2].y),ie(i,"width",a=n[2].w),ie(i,"height",l=n[2].h),ie(e,"class","a9s-presence-overlay")},m(u,c){ct(u,e,c),Yt(t,e,null),Ki(e,i),h=!0},p(u,[c]){const d={};c&2&&(d.scale=u[1]),c&1&&(d.user=u[0]),c&4&&(d.x=u[2].x),c&4&&(d.y=u[2].y),t.$set(d),(!h||c&1&&r!==(r=u[0].appearance.color))&&ie(i,"stroke",r),(!h||c&4&&s!==(s=u[2].x))&&ie(i,"x",s),(!h||c&4&&o!==(o=u[2].y))&&ie(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&ie(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&ie(i,"height",l)},i(u){h||(Oe(t.$$.fragment,u),h=!0)},o(u){He(t.$$.fragment,u),h=!1},d(u){u&&ht(e),qt(t)}}}function WI(n,e,t){let i,{annotation:r}=e,{user:s}=e,{scale:o}=e;return n.$$set=a=>{"annotation"in a&&t(3,r=a.annotation),"user"in a&&t(0,s=a.user),"scale"in a&&t(1,o=a.scale)},n.$$.update=()=>{n.$$.dirty&8&&t(2,i=r.target.selector.geometry)},[s,o,i,r]}class jI extends Kt{constructor(e){super(),Zt(this,e,WI,VI,Rt,{annotation:3,user:0,scale:1})}}const{Boolean:XI}=Vh;function dy(n,e,t){const i=n.slice();return i[8]=e[t],i}function fy(n){let e,t;return e=new Rc({props:{viewer:n[0],$$slots:{default:[ZI,({transform:i,scale:r})=>({6:i,7:r}),({transform:i,scale:r})=>(i?64:0)|(r?128:0)]},$$scope:{ctx:n}}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r&1&&(s.viewer=i[0]),r&2244&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function py(n){let e,t,i=zn(n[2]),r=[];for(let o=0;o<i.length;o+=1)r[o]=gy(dy(n,i,o));const s=o=>He(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=_n()},m(o,a){for(let l=0;l<r.length;l+=1)r[l]&&r[l].m(o,a);ct(o,e,a),t=!0},p(o,a){if(a&132){i=zn(o[2]);let l;for(l=0;l<i.length;l+=1){const h=dy(o,i,l);r[l]?(r[l].p(h,a),Oe(r[l],1)):(r[l]=gy(h),r[l].c(),Oe(r[l],1),r[l].m(e.parentNode,e))}for(bi(),l=i.length;l<r.length;l+=1)s(l);Si()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)Oe(r[a]);t=!0}},o(o){r=r.filter(XI);for(let a=0;a<r.length;a+=1)He(r[a]);t=!1},d(o){o&&ht(e),ma(r,o)}}}function YI(n){let e,t;return e=new GI({props:{annotation:n[8].annotation,user:n[8].selectedBy,scale:n[7]}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r&4&&(s.annotation=i[8].annotation),r&4&&(s.user=i[8].selectedBy),r&128&&(s.scale=i[7]),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function qI(n){let e,t;return e=new jI({props:{annotation:n[8].annotation,user:n[8].selectedBy,scale:n[7]}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r&4&&(s.annotation=i[8].annotation),r&4&&(s.user=i[8].selectedBy),r&128&&(s.scale=i[7]),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function gy(n){let e,t,i,r;const s=[qI,YI],o=[];function a(l,h){return l[8].annotation.target.selector.type===Ie.RECTANGLE?0:l[8].annotation.target.selector.type===Ie.POLYGON?1:-1}return~(e=a(n))&&(t=o[e]=s[e](n)),{c(){t&&t.c(),i=_n()},m(l,h){~e&&o[e].m(l,h),ct(l,i,h),r=!0},p(l,h){let u=e;e=a(l),e===u?~e&&o[e].p(l,h):(t&&(bi(),He(o[u],1,1,()=>{o[u]=null}),Si()),~e?(t=o[e],t?t.p(l,h):(t=o[e]=s[e](l),t.c()),Oe(t,1),t.m(i.parentNode,i)):t=null)},i(l){r||(Oe(t),r=!0)},o(l){He(t),r=!1},d(l){l&&ht(i),~e&&o[e].d(l)}}}function ZI(n){let e,t,i,r,s=n[2].length>0&&py(n);return{c(){e=dt("svg"),t=dt("g"),s&&s.c(),ie(t,"transform",i=n[6]),ie(e,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ct(o,e,a),Ki(e,t),s&&s.m(t,null),r=!0},p(o,a){o[2].length>0?s?(s.p(o,a),a&4&&Oe(s,1)):(s=py(o),s.c(),Oe(s,1),s.m(t,null)):s&&(bi(),He(s,1,1,()=>{s=null}),Si()),(!r||a&64&&i!==(i=o[6]))&&ie(t,"transform",i)},i(o){r||(Oe(s),r=!0)},o(o){He(s),r=!1},d(o){o&&ht(e),s&&s.d()}}}function KI(n){let e=!!n[1],t,i,r=e&&fy(n);return{c(){r&&r.c(),t=_n()},m(s,o){r&&r.m(s,o),ct(s,t,o),i=!0},p(s,[o]){o&2&&(e=!!s[1]),e?r?(r.p(s,o),o&2&&Oe(r,1)):(r=fy(s),r.c(),Oe(r,1),r.m(t.parentNode,t)):r&&(bi(),He(r,1,1,()=>{r=null}),Si())},i(s){i||(Oe(r),i=!0)},o(s){He(r),i=!1},d(s){s&&ht(t),r&&r.d(s)}}}function QI(n,e,t){let{store:i}=e,{viewer:r}=e,{provider:s}=e,o=[],a;const l=(h,u)=>{t(2,o=[...o.filter(({selectedBy:c})=>c.presenceKey!==h.presenceKey),...(u||[]).map(c=>({annotation:i.getAnnotation(c),selectedBy:h}))].filter(({annotation:c})=>(c||console.warn("Selection event on unknown annotation"),!!c))),a&&i.unobserve(a),a=c=>{const{deleted:d,updated:f}=c.changes,p=new Set((d||[]).map(m=>m.id)),g=o.filter(({annotation:m})=>!p.has(m.id)).map(m=>{const v=(f||[]).find(_=>_.oldValue.id===m.annotation.id);return v?{selectedBy:m.selectedBy,annotation:v.newValue}:m});t(2,o=g)},i.observe(a,{annotations:o.map(c=>c.annotation.id)})};return x1(()=>{a&&i.unobserve(a)}),n.$$set=h=>{"store"in h&&t(3,i=h.store),"viewer"in h&&t(0,r=h.viewer),"provider"in h&&t(1,s=h.provider)},n.$$.update=()=>{n.$$.dirty&2&&s&&s.on("selectionChange",l)},[r,s,o,i]}class JI extends Kt{constructor(e){super(),Zt(this,e,QI,KI,Rt,{store:3,viewer:0,provider:1})}}function $I(n){let e,t,i,r,s;return{c(){e=dt("ellipse"),ie(e,"cx",t=n[0].cx),ie(e,"cy",i=n[0].cy),ie(e,"rx",r=n[0].rx),ie(e,"ry",s=n[0].ry)},m(o,a){ct(o,e,a)},p(o,[a]){a&1&&t!==(t=o[0].cx)&&ie(e,"cx",t),a&1&&i!==(i=o[0].cy)&&ie(e,"cy",i),a&1&&r!==(r=o[0].rx)&&ie(e,"rx",r),a&1&&s!==(s=o[0].ry)&&ie(e,"ry",s)},i:yt,o:yt,d(o){o&&ht(e)}}}function eD(n,e,t){let i,{annotation:r}=e;return n.$$set=s=>{"annotation"in s&&t(1,r=s.annotation)},n.$$.update=()=>{n.$$.dirty&2&&t(0,i=r.target.selector.geometry)},[i,r]}class tD extends Kt{constructor(e){super(),Zt(this,e,eD,$I,Rt,{annotation:1})}}function iD(n){let e,t,i,r,s;return{c(){e=dt("line"),ie(e,"x1",t=n[0].points[0][0]),ie(e,"y1",i=n[0].points[0][1]),ie(e,"x2",r=n[0].points[1][0]),ie(e,"y2",s=n[0].points[1][1])},m(o,a){ct(o,e,a)},p(o,[a]){a&1&&t!==(t=o[0].points[0][0])&&ie(e,"x1",t),a&1&&i!==(i=o[0].points[0][1])&&ie(e,"y1",i),a&1&&r!==(r=o[0].points[1][0])&&ie(e,"x2",r),a&1&&s!==(s=o[0].points[1][1])&&ie(e,"y2",s)},i:yt,o:yt,d(o){o&&ht(e)}}}function nD(n,e,t){let i,{annotation:r}=e;return n.$$set=s=>{"annotation"in s&&t(1,r=s.annotation)},n.$$.update=()=>{n.$$.dirty&2&&t(0,i=r.target.selector.geometry)},[i,r]}class rD extends Kt{constructor(e){super(),Zt(this,e,nD,iD,Rt,{annotation:1})}}function my(n,e,t){const i=n.slice();return i[2]=e[t],i}function vy(n){let e,t;return{c(){e=dt("path"),t=dt("path"),ie(e,"fill-rule","evenodd"),ie(e,"d",Oi(n[2])),ie(t,"class","a9s-inner"),ie(t,"fill-rule","evenodd"),ie(t,"d",Oi(n[2]))},m(i,r){ct(i,e,r),ct(i,t,r)},p:yt,d(i){i&&(ht(e),ht(t))}}}function sD(n){let e,t=zn(n[0]),i=[];for(let r=0;r<t.length;r+=1)i[r]=vy(my(n,t,r));return{c(){e=dt("g");for(let r=0;r<i.length;r+=1)i[r].c()},m(r,s){ct(r,e,s);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(e,null)},p(r,[s]){if(s&1){t=zn(r[0]);let o;for(o=0;o<t.length;o+=1){const a=my(r,t,o);i[o]?i[o].p(a,s):(i[o]=vy(a),i[o].c(),i[o].m(e,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=t.length}},i:yt,o:yt,d(r){r&&ht(e),ma(i,r)}}}function oD(n,e,t){let{annotation:i}=e;const{polygons:r}=i.target.selector.geometry;return n.$$set=s=>{"annotation"in s&&t(1,i=s.annotation)},[r,i]}class aD extends Kt{constructor(e){super(),Zt(this,e,oD,sD,Rt,{annotation:1})}}function lD(n){let e,t;return{c(){e=dt("polygon"),ie(e,"points",t=n[0].points.map(yy).join(" "))},m(i,r){ct(i,e,r)},p(i,[r]){r&1&&t!==(t=i[0].points.map(yy).join(" "))&&ie(e,"points",t)},i:yt,o:yt,d(i){i&&ht(e)}}}const yy=n=>n.join(",");function hD(n,e,t){let i,{annotation:r}=e;return n.$$set=s=>{"annotation"in s&&t(1,r=s.annotation)},n.$$.update=()=>{n.$$.dirty&2&&t(0,i=r.target.selector.geometry)},[i,r]}class uD extends Kt{constructor(e){super(),Zt(this,e,hD,lD,Rt,{annotation:1})}}function cD(n){let e;return{c(){e=dt("path"),ie(e,"d",n[0])},m(t,i){ct(t,e,i)},p(t,[i]){i&1&&ie(e,"d",t[0])},i:yt,o:yt,d(t){t&&ht(e)}}}function dD(n,e,t){let i,r,{annotation:s}=e;return n.$$set=o=>{"annotation"in o&&t(1,s=o.annotation)},n.$$.update=()=>{n.$$.dirty&2&&t(2,i=s.target.selector.geometry),n.$$.dirty&4&&t(0,r=Th(i))},[r,s,i]}class fD extends Kt{constructor(e){super(),Zt(this,e,dD,cD,Rt,{annotation:1})}}function pD(n){let e,t,i,r,s;return{c(){e=dt("rect"),ie(e,"x",t=n[0].x),ie(e,"y",i=n[0].y),ie(e,"width",r=n[0].w),ie(e,"height",s=n[0].h)},m(o,a){ct(o,e,a)},p(o,[a]){a&1&&t!==(t=o[0].x)&&ie(e,"x",t),a&1&&i!==(i=o[0].y)&&ie(e,"y",i),a&1&&r!==(r=o[0].w)&&ie(e,"width",r),a&1&&s!==(s=o[0].h)&&ie(e,"height",s)},i:yt,o:yt,d(o){o&&ht(e)}}}function gD(n,e,t){let i,{annotation:r}=e;return n.$$set=s=>{"annotation"in s&&t(1,r=s.annotation)},n.$$.update=()=>{n.$$.dirty&2&&t(0,i=r.target.selector.geometry)},[i,r]}class mD extends Kt{constructor(e){super(),Zt(this,e,gD,pD,Rt,{annotation:1})}}const{Boolean:vD}=Vh;function _y(n,e,t){const i=n.slice();return i[10]=e[t],i}function xy(n){let e,t;return e=new Rc({props:{viewer:n[0],$$slots:{default:[bD,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:n}}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r&1&&(s.viewer=i[0]),r&8710&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function yD(n){let e,t;return e=new rD({props:{annotation:n[10]}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function _D(n){let e,t;return e=new tD({props:{annotation:n[10]}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function xD(n){let e,t;return e=new fD({props:{annotation:n[10]}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function wD(n){let e,t;return e=new aD({props:{annotation:n[10]}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function TD(n){let e,t;return e=new uD({props:{annotation:n[10]}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function ED(n){let e,t;return e=new mD({props:{annotation:n[10]}}),{c(){ii(e.$$.fragment)},m(i,r){Yt(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Oe(e.$$.fragment,i),t=!0)},o(i){He(e.$$.fragment,i),t=!1},d(i){qt(e,i)}}}function wy(n){let e,t,i,r;const s=[ED,TD,wD,xD,_D,yD],o=[];function a(l,h){return l[10].target.selector.type===Ie.RECTANGLE?0:l[10].target.selector.type===Ie.POLYGON?1:l[10].target.selector.type===Ie.MULTIPOLYGON?2:l[10].target.selector.type===Ie.POLYLINE?3:l[10].target.selector.type===Ie.ELLIPSE?4:l[10].target.selector.type===Ie.LINE?5:-1}return~(e=a(n))&&(t=o[e]=s[e](n)),{c(){t&&t.c(),i=_n()},m(l,h){~e&&o[e].m(l,h),ct(l,i,h),r=!0},p(l,h){let u=e;e=a(l),e===u?~e&&o[e].p(l,h):(t&&(bi(),He(o[u],1,1,()=>{o[u]=null}),Si()),~e?(t=o[e],t?t.p(l,h):(t=o[e]=s[e](l),t.c()),Oe(t,1),t.m(i.parentNode,i)):t=null)},i(l){r||(Oe(t),r=!0)},o(l){He(t),r=!1},d(l){l&&ht(i),~e&&o[e].d(l)}}}function bD(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g=zn(n[1].filter(n[6])),m=[];for(let _=0;_<g.length;_+=1)m[_]=wy(_y(n,g,_));const v=_=>He(m[_],1,1,()=>{m[_]=null});return{c(){var _,y,w,R;e=dt("svg"),t=dt("g"),i=dt("rect"),l=dt("rect");for(let M=0;M<m.length;M+=1)m[M].c();ie(i,"class","a9s-union-bg svelte-jwrce3"),ie(i,"x",r=(_=n[2])==null?void 0:_.minX),ie(i,"y",s=(y=n[2])==null?void 0:y.minY),ie(i,"width",o=n[2]?n[2].maxX-n[2].minX:0),ie(i,"height",a=n[2]?n[2].maxY-n[2].minY:0),ie(l,"class","a9s-union-fg svelte-jwrce3"),ie(l,"x",h=(w=n[2])==null?void 0:w.minX),ie(l,"y",u=(R=n[2])==null?void 0:R.minY),ie(l,"width",c=n[2]?n[2].maxX-n[2].minX:0),ie(l,"height",d=n[2]?n[2].maxY-n[2].minY:0),ie(t,"transform",f=n[9]),ie(e,"class","a9s-osd-selectionlayer svelte-jwrce3")},m(_,y){ct(_,e,y),Ki(e,t),Ki(t,i),Ki(t,l);for(let w=0;w<m.length;w+=1)m[w]&&m[w].m(t,null);p=!0},p(_,y){var w,R,M,C;if((!p||y&4&&r!==(r=(w=_[2])==null?void 0:w.minX))&&ie(i,"x",r),(!p||y&4&&s!==(s=(R=_[2])==null?void 0:R.minY))&&ie(i,"y",s),(!p||y&4&&o!==(o=_[2]?_[2].maxX-_[2].minX:0))&&ie(i,"width",o),(!p||y&4&&a!==(a=_[2]?_[2].maxY-_[2].minY:0))&&ie(i,"height",a),(!p||y&4&&h!==(h=(M=_[2])==null?void 0:M.minX))&&ie(l,"x",h),(!p||y&4&&u!==(u=(C=_[2])==null?void 0:C.minY))&&ie(l,"y",u),(!p||y&4&&c!==(c=_[2]?_[2].maxX-_[2].minX:0))&&ie(l,"width",c),(!p||y&4&&d!==(d=_[2]?_[2].maxY-_[2].minY:0))&&ie(l,"height",d),y&2){g=zn(_[1].filter(_[6]));let O;for(O=0;O<g.length;O+=1){const N=_y(_,g,O);m[O]?(m[O].p(N,y),Oe(m[O],1)):(m[O]=wy(N),m[O].c(),Oe(m[O],1),m[O].m(t,null))}for(bi(),O=g.length;O<m.length;O+=1)v(O);Si()}(!p||y&512&&f!==(f=_[9]))&&ie(t,"transform",f)},i(_){if(!p){for(let y=0;y<g.length;y+=1)Oe(m[y]);p=!0}},o(_){m=m.filter(vD);for(let y=0;y<m.length;y+=1)He(m[y]);p=!1},d(_){_&&ht(e),ma(m,_)}}}function SD(n){let e=!!n[2],t,i,r=e&&xy(n);return{c(){r&&r.c(),t=_n()},m(s,o){r&&r.m(s,o),ct(s,t,o),i=!0},p(s,[o]){o&4&&(e=!!s[2]),e?r?(r.p(s,o),o&4&&Oe(r,1)):(r=xy(s),r.c(),Oe(r,1),r.m(t.parentNode,t)):r&&(bi(),He(r,1,1,()=>{r=null}),Si())},i(s){i||(Oe(r),i=!0)},o(s){He(r),i=!1},d(s){s&&ht(t),r&&r.d(s)}}}function AD(n,e,t){let i,r,s,{state:o}=e,{viewer:a}=e;const{store:l}=o,{selection:h}=o;ro(n,h,d=>t(5,s=d));const u=d=>{let f=-1/0,p=-1/0,g=1/0,m=1/0;for(let v of d.filter(_=>Ti(_))){const{bounds:_}=v.target.selector.geometry;_.maxX>f&&(f=_.maxX),_.maxY>p&&(p=_.maxY),_.minX<g&&(g=_.minX),_.minY<m&&(m=_.minY)}return a.forceRedraw(),{maxX:f,maxY:p,minX:g,minY:m}},c=d=>Ti(d);return n.$$set=d=>{"state"in d&&t(4,o=d.state),"viewer"in d&&t(0,a=d.viewer)},n.$$.update=()=>{n.$$.dirty&32&&t(1,i=s.selected.map(({id:d})=>l.getAnnotation(d))),n.$$.dirty&2&&t(2,r=i.length>1?u(i):void 0)},[a,i,r,h,o,s,c]}class RD extends Kt{constructor(e){super(),Zt(this,e,AD,SD,Rt,{state:4,viewer:0})}}const Ty=(n,e)=>{e==="auto"?n.addHandler("open",t=>{const i=n.world.getItemCount();n.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",r=>{const{fullyLoaded:s}=r;if(s){const o=n.canvas.querySelector("canvas"),a=Pp(o);n.element.setAttribute("data-theme",a)}})}):n.element.setAttribute("data-theme",e)},Ey=(n,e,t)=>(i,r={})=>{const s=typeof i=="string"?i:i.id,o=e.getAnnotation(s);if(!o||!Ti(o))return;const a=n.container.getBoundingClientRect(),{padding:l}=r;let[h,u,c,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,u=u/a.width,c=c/a.height,d=d/a.width;const{minX:f,minY:p,maxX:g,maxY:m}=o.target.selector.geometry.bounds,v=g-f,_=m-p,y=f-d*v,w=p-h*_,R=v+(u+d)*v,M=_+(h+c)*_,C=n.viewport.imageToViewportRectangle(y,w,R,M);n.viewport[t](C,r.immediately)},CD=(n,e)=>Ey(n,e,"fitBounds"),PD=(n,e)=>Ey(n,e,"fitBoundsWithConstraints"),ID=Object.freeze(Object.defineProperty({__proto__:null,ShapeType:Ie,UserSelectAction:uh,W3CImageFormat:EE,chainStyles:fE,computeStyle:dE,createBody:Iw,createImageAnnotator:l1,createOSDAnnotator:(n,e={})=>{const t=Dp(e,{drawingEnabled:!1,drawingMode:Ei?"drag":"click",userSelectAction:uh.EDIT,theme:"light"}),i=Cp(t),{hover:r,selection:s,store:o}=i,a=Uw(o,t.initialHistory),l=Hw(i,a,t.adapter,t.autoSave);let h=qw(),u=t.drawingEnabled,c=t.drawingMode,d=t.modalSelect;const f=Op(a,n.element),p=new SI({target:n.element,props:{state:i,viewer:n,style:t.style,filter:void 0}}),g=new JI({target:n.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:n}}),m=new NI({target:n.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!u,filter:void 0,multiSelect:t.multiSelect,preferredDrawingMode:c,state:i,style:t.style,user:h,viewer:n}}),v=e.multiSelect?new RD({target:n.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:n}}):void 0;p.$on("click",K=>{const{originalEvent:$,annotation:se}=K.detail,fe=te=>ny(te.id,$,s,t.multiSelect);d?s.isEmpty()&&se&&s.userSelect(fe(se),$):se&&!(c==="click"&&u)?s.userSelect(fe(se),$):s.isEmpty()||(t.multiSelect?$.metaKey||$.shiftKey||$.ctrlKey||s.userSelect([],$):s.userSelect([],$))}),n.element.addEventListener("pointerdown",K=>{if(r.current){const $=o.getAnnotation(r.current);l.emit("clickAnnotation",$,K)}}),Ty(n,t.theme);const _=Gw(i,a,t.adapter),y=()=>m.cancelDrawing(),w=()=>{p.$destroy(),g.$destroy(),m.$destroy(),v?.$destroy(),f.destroy(),a.destroy()},R=CD(n,o),M=PD(n,o),C=()=>m.getDrawingTool(),O=()=>h,N=()=>m.isDrawingEnabled(),X=(K,$,se)=>fp(K,$,se),q=(K,$)=>hp(K,$),L=K=>{if(!fa(K))throw`No drawing tool named ${K}`;m.$set({toolName:K})},S=K=>{u=K,m.$set({drawingEnabled:K})},I=K=>{c=K,m.$set({preferredDrawingMode:K})},B=K=>{p.$set({filter:K}),m.$set({filter:K})},j=K=>d=K,U=K=>{p.$set({style:K}),m.$set({style:K})},W=K=>g.$set({provider:K}),ee=K=>Ty(n,K),z=K=>{h=K,m.$set({user:K})},H=K=>p.$set({visible:K});return{..._,cancelDrawing:y,destroy:w,fitBounds:R,fitBoundsWithConstraints:M,getDrawingTool:C,getUser:O,isDrawingEnabled:N,listDrawingTools:da,on:l.on,off:l.off,registerDrawingTool:X,registerShapeEditor:q,setDrawingEnabled:S,setDrawingMode:I,setDrawingTool:L,setFilter:B,setModalSelect:j,setPresenceProvider:W,setStyle:U,setTheme:ee,setUser:z,setVisible:H,state:i,viewer:n}},defaultColorProvider:Kw},Symbol.toStringTag,{value:"Module"}))})();