route-graphics 0.0.2-rc18 → 0.0.2-rc19
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/RouteGraphics.js +1 -1
- package/package.json +1 -1
package/dist/RouteGraphics.js
CHANGED
|
@@ -1139,4 +1139,4 @@ ${u}`)}});return await Promise.all(c),o?s[n[0].src]:s}async unload(t){let r=Wt(t
|
|
|
1139
1139
|
})();
|
|
1140
1140
|
`,zi=null,jo=class{constructor(){zi||(zi=URL.createObjectURL(new Blob([YP],{type:"application/javascript"}))),this.worker=new Worker(zi)}};jo.revokeObjectURL=function(){zi&&(URL.revokeObjectURL(zi),zi=null)};var iT=0,ud,dd=class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{let{worker:e}=new Wi;e.addEventListener("message",r=>{e.terminate(),Wi.revokeObjectURL(),t(r.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){ud===void 0&&(ud=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<ud&&(this._createdWorkers++,t=new jo().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();let r=new Promise((s,o)=>{this._queue.push({id:t,arguments:e,resolve:s,reject:o})});return this._next(),r}_next(){if(!this._queue.length)return;let t=this._getWorker();if(!t)return;let e=this._queue.pop(),r=e.id;this._resolveHash[iT]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:iT++,id:r})}},fd=new dd;ze();var KP=[".jpeg",".jpg",".png",".webp",".avif"],qP=["image/jpeg","image/png","image/webp","image/avif"];async function ZP(i,t){let e=await D.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);let r=await e.blob();return t?.data?.alphaMode==="premultiplied-alpha"?createImageBitmap(r,{premultiplyAlpha:"none"}):createImageBitmap(r)}var rc={name:"loadTextures",extension:{type:x.LoadParser,priority:Et.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return de(i,qP)||fe(i,KP)},async load(i,t,e){let r=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await fd.isImageBitmapSupported()?r=await fd.loadImageBitmap(i,t):r=await ZP(i,t):r=await new Promise((o,n)=>{r=new Image,r.crossOrigin=this.config.crossOrigin,r.src=i,r.complete?o(r):(r.onload=()=>{o(r)},r.onerror=n)});let s=new Zt({resource:r,alphaMode:"premultiply-alpha-on-upload",resolution:t.data?.resolution||Li(i),...t.data});return Ni(s,e,i)},unload(i){i.destroy(!0)}};E();Al();El();var sT=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],QP=sT.map(i=>`video/${i.substring(1)}`);function JP(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=eE(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function tE(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",r),i.addEventListener("error",s),i.load();function r(){o(),t()}function s(n){o(),e(n)}function o(){i.removeEventListener("canplaythrough",r),i.removeEventListener("error",s)}})}function eE(i,t=globalThis.location){if(i.startsWith("data:"))return"";t||(t=globalThis.location);let e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}var oT={name:"loadVideo",extension:{type:x.LoadParser,name:"loadVideo"},test(i){let t=de(i,QP),e=fe(i,sT);return t||e},async load(i,t,e){let r={...ei.defaultOptions,resolution:t.data?.resolution||Li(i),alphaMode:t.data?.alphaMode||await Mn(),...t.data},s=document.createElement("video"),o={preload:r.autoLoad!==!1?"auto":void 0,"webkit-playsinline":r.playsinline!==!1?"":void 0,playsinline:r.playsinline!==!1?"":void 0,muted:r.muted===!0?"":void 0,loop:r.loop===!0?"":void 0,autoplay:r.autoPlay!==!1?"":void 0};Object.keys(o).forEach(c=>{let l=o[c];l!==void 0&&s.setAttribute(c,l)}),r.muted===!0&&(s.muted=!0),JP(s,i,r.crossorigin);let n=document.createElement("source"),a;if(i.startsWith("data:"))a=i.slice(5,i.indexOf(";"));else if(!i.startsWith("blob:")){let c=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();a=ei.MIME_TYPES[c]||`video/${c}`}return n.src=i,a&&(n.type=a),new Promise(c=>{let l=async()=>{let h=new ei({...r,resource:s});s.removeEventListener("canplay",l),t.data.preload&&await tE(s),c(Ni(h,e,i))};s.addEventListener("canplay",l),s.appendChild(n)})},unload(i){i.destroy(!0)}};E();Qr();E();Qr();var ic={extension:{type:x.ResolveParser,name:"resolveTexture"},test:rc.test,parse:i=>({resolution:parseFloat(se.RETINA_PREFIX.exec(i)?.[1]??"1"),format:i.split(".").pop(),src:i})};var nT={extension:{type:x.ResolveParser,priority:-2,name:"resolveJson"},test:i=>se.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:ic.parse};Qr();ps();Sn();var sc=class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new se,this.loader=new ec,this.cache=Q,this._backgroundLoader=new Ja(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized){k("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}let e=t.texturePreference?.resolution??1,r=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:r}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();let r=Er(t),s=Wt(t).map(a=>{if(typeof a!="string"){let c=this.resolver.getAlias(a);return c.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(c)?c[0]:c}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),o=this.resolver.resolve(s),n=await this._mapLoadToResolve(o,e);return r?n[s[0]]:n}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let r=!1;typeof t=="string"&&(r=!0,t=[t]);let s=this.resolver.resolveBundle(t),o={},n=Object.keys(s),a=0,c=0,l=()=>{e?.(++a/c)},h=n.map(u=>{let d=s[u];return c+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(f=>{o[u]=f})});return await Promise.all(h),r?o[t[0]]:o}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);let e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);let e=this.resolver.resolveBundle(t);Object.values(e).forEach(r=>{this._backgroundLoader.add(Object.values(r))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Q.get(t);let e={};for(let r=0;r<t.length;r++)e[r]=Q.get(t[r]);return e}async _mapLoadToResolve(t,e){let r=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;let s=await this.loader.load(r,e);this._backgroundLoader.active=!0;let o={};return r.forEach(n=>{let a=s[n.src],c=[n.src];n.alias&&c.push(...n.alias),c.forEach(l=>{o[l]=a}),Q.set(c,a)}),o}async unload(t){this._initialized||await this.init();let e=Wt(t).map(s=>typeof s!="string"?s.src:s),r=this.resolver.resolve(e);await this._unloadFromResolved(r)}async unloadBundle(t){this._initialized||await this.init(),t=Wt(t);let e=this.resolver.resolveBundle(t),r=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(r)}async _unloadFromResolved(t){let e=Object.values(t);e.forEach(r=>{Q.remove(r.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(let r of t.detections)t.skipDetections||await r.test()?e=await r.add(e):t.skipDetections||(e=await r.remove(e));return e=e.filter((r,s)=>e.indexOf(r)===s),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(r=>r in t).forEach(r=>{e.config[r]=t[r]})})}},ve=new sc;I.handleByList(x.LoadParser,ve.loader.parsers).handleByList(x.ResolveParser,ve.resolver.parsers).handleByList(x.CacheParser,ve.cache.parsers).handleByList(x.DetectionParser,ve.detections);I.add(X0,Y0,j0,Q0,K0,q0,Z0,J0,tT,eT,rT,rc,oT,V0,z0,ic,nT);var aT={loader:x.LoadParser,resolver:x.ResolveParser,cache:x.CacheParser,detection:x.DetectionParser};I.handle(x.Asset,i=>{let t=i.ref;Object.entries(aT).filter(([e])=>!!t[e]).forEach(([e,r])=>I.add(Object.assign(t[e],{extension:t[e].extension??r})))},i=>{let t=i.ref;Object.keys(aT).filter(e=>!!t[e]).forEach(e=>I.remove(t[e]))});rn();ft();Tn();var oc=class extends Je{constructor(t,e){let{text:r,resolution:s,style:o,anchor:n,width:a,height:c,roundPixels:l,...h}=t;super({...h}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=r??"",this.style=o,this.resolution=s??null,this.allowChildren=!1,this._anchor=new It({_onUpdate:()=>{this.onViewUpdate()}}),n&&(this.anchor=n),this.roundPixels=l??!1,a!==void 0&&(this.width=a),c!==void 0&&(this.height=c)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){t||(t={}),this._style?.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){let e=this.bounds.width,r=this.bounds.height,s=-e*this.anchor.x,o=0;return t.x>=s&&t.x<=s+e&&(o=-r*this.anchor.y,t.y>=o&&t.y<=o+r)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t?.style)&&this._style.destroy(t),this._style=null,this._text=null}};function cT(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(U(H,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}Ls();Fr();var ur=class extends oc{constructor(...t){let e=cT(t,"Text");super(e,St),this.renderPipeId="text"}updateBounds(){let t=this._bounds,e=this._anchor,r=Ct.measureText(this._text,this._style),{width:s,height:o}=r;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*o,t.maxY=t.minY+o}};ze();vt();et();Bl();ge();$h();En();Ls();Fr();Dt();var rE=Jo(sh(),1);I.add(gy,_y);var Bt={Add:"add",Remove:"remove",Update:"update"},nc=class{init(t){throw new Error("Method not implemented.")}render(t){throw new Error("Method not implemented.")}},dr=class{rendererName;rendererType;add=(t,e)=>{throw new Error("Method not implemented.")};remove=(t,e)=>{throw new Error("Method not implemented.")};update=(t,e)=>{throw new Error("Method not implemented.")}};var ac=(i=[],t=[])=>{let e=[],r=[],s=[],o=i.filter(a=>!a.hidden),n=t.filter(a=>!a.hidden);for(let a of o){let c=n.find(l=>l.id===a.id&&l.type===a.type);c?r.push({prev:a,next:c}):e.push(a)}for(let a of n)o.find(l=>l.id===a.id&&l.type===a.type)||s.push(a);for(let a of i){let c=t.find(l=>l.id===a.id&&l.type===a.type);c&&c.hidden&&!a.hidden&&e.push(a)}return{toDeleteElements:e,toUpdateElements:r,toAddElements:s}};var Or=new(window.AudioContext||window.webkitAudioContext),Vi=class i{static loadedAssets={};static load=async(t,e)=>{if(!i.loadedAssets[t]&&e.byteLength!==0)try{let r=await Or.decodeAudioData(e);i.loadedAssets[t]=r}catch(r){console.error(`AudioAsset.load: Failed to decode ${t}:`,r)}};static getAsset=t=>i.loadedAssets[t]},pd=class{_audioSource;_gainNode;volume=1;id;url;loop=!1;constructor(t,e){this.id=t,this.url=e.url,this.loop=e.loop||!1,this.volume=e.volume??1,this._gainNode=Or.createGain(),this._gainNode.gain.value=this.volume,this._gainNode.connect(Or.destination)}play=()=>{let t=Vi.getAsset(this.url);if(!t){console.warn("AudioPlayer.play: Asset not found",this.url);return}this._audioSource=Or.createBufferSource(),this._audioSource.buffer=t,this._audioSource.loop=this.loop,this._gainNode.gain.setValueAtTime(this.volume,Or.currentTime),this._audioSource.connect(this._gainNode),this._audioSource.start(0)};stop=()=>{this._audioSource&&(this._audioSource.stop(),this._audioSource.disconnect(),this._gainNode.disconnect(),this._gainNode=Or.createGain(),this._gainNode.gain.value=this.volume,this._gainNode.connect(Or.destination))}},cc=class{audioPlayers=[];stageAudios=[];add=t=>{this.stageAudios.push(t)};remove=t=>{this.stageAudios=this.stageAudios.filter(e=>e.id!==t)};getById=t=>this.stageAudios.find(e=>e.id===t);tick=()=>{for(let e of this.stageAudios){let r=this.audioPlayers.find(s=>s.id===e.id);if(!r){let s=new pd(e.id,{url:e.url,loop:e.loop,volume:e.volume??1});this.audioPlayers.push(s),s.play();return}(r.url!==e.url||r.loop!==e.loop)&&(r.stop(),r.url=e.url,r.loop=e.loop??!1,r.play()),r.volume!==(e.volume??1)&&(r.volume=e.volume??1,r._gainNode.gain.value=r.volume)}let t=[];for(let e of this.audioPlayers)this.stageAudios.find(r=>r.id===e.id)||(e.stop(),t.push(e.id));this.audioPlayers=this.audioPlayers.filter(e=>!t.includes(e.id))};destroy=()=>{for(let t of this.audioPlayers)t.stop();this.audioPlayers=[],this.stageAudios=[]}};var md=function(i,t){return md=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},md(i,t)};function $o(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");md(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function lT(i,t,e,r){function s(o){return o instanceof e?o:new e(function(n){n(o)})}return new(e||(e=Promise))(function(o,n){function a(h){try{l(r.next(h))}catch(u){n(u)}}function c(h){try{l(r.throw(h))}catch(u){n(u)}}function l(h){h.done?o(h.value):s(h.value).then(a,c)}l((r=r.apply(i,t||[])).next())})}function lc(i,t){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=a(0),n.throw=a(1),n.return=a(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function a(l){return function(h){return c([l,h])}}function c(l){if(r)throw new TypeError("Generator is already executing.");for(;n&&(n=0,l[0]&&(e=0)),e;)try{if(r=1,s&&(o=l[0]&2?s.return:l[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,l[1])).done)return o;switch(s=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,s=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){e.label=l[1];break}if(l[0]===6&&e.label<o[1]){e.label=o[1],o=l;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(l);break}o[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(i,e)}catch(h){l=[6,h],s=0}finally{r=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Lr(i){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&i[t],r=0;if(e)return e.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&r>=i.length&&(i=void 0),{value:i&&i[r++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Xi(i,t){var e=typeof Symbol=="function"&&i[Symbol.iterator];if(!e)return i;var r=e.call(i),s,o=[],n;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){n={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(n)throw n.error}}return o}function ji(i,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return i.concat(o||Array.prototype.slice.call(t))}function Nr(i){return this instanceof Nr?(this.v=i,this):new Nr(i)}function hT(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(i,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",n),s[Symbol.asyncIterator]=function(){return this},s;function n(f){return function(p){return Promise.resolve(p).then(f,u)}}function a(f,p){r[f]&&(s[f]=function(g){return new Promise(function(_,b){o.push([f,g,_,b])>1||c(f,g)})},p&&(s[f]=p(s[f])))}function c(f,p){try{l(r[f](p))}catch(g){d(o[0][3],g)}}function l(f){f.value instanceof Nr?Promise.resolve(f.value.v).then(h,u):d(o[0][2],f)}function h(f){c("next",f)}function u(f){c("throw",f)}function d(f,p){f(p),o.shift(),o.length&&c(o[0][0],o[0][1])}}function uT(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],e;return t?t.call(i):(i=typeof Lr=="function"?Lr(i):i[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=i[o]&&function(n){return new Promise(function(a,c){n=i[o](n),s(a,c,n.done,n.value)})}}function s(o,n,a,c){Promise.resolve(c).then(function(l){o({value:l,done:a})},n)}}function rt(i){return typeof i=="function"}function dT(i){var t=function(r){Error.call(r),r.stack=new Error().stack},e=i(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var hc=dT(function(i){return function(e){i(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
1141
1141
|
`+e.map(function(r,s){return s+1+") "+r.toString()}).join(`
|
|
1142
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function gd(i,t){if(i){var e=i.indexOf(t);0<=e&&i.splice(e,1)}}var uc=function(){function i(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return i.prototype.unsubscribe=function(){var t,e,r,s,o;if(!this.closed){this.closed=!0;var n=this._parentage;if(n)if(this._parentage=null,Array.isArray(n))try{for(var a=Lr(n),c=a.next();!c.done;c=a.next()){var l=c.value;l.remove(this)}}catch(g){t={error:g}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else n.remove(this);var h=this.initialTeardown;if(rt(h))try{h()}catch(g){o=g instanceof hc?g.errors:[g]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var d=Lr(u),f=d.next();!f.done;f=d.next()){var p=f.value;try{fT(p)}catch(g){o=o??[],g instanceof hc?o=ji(ji([],Xi(o)),Xi(g.errors)):o.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}if(o)throw new hc(o)}},i.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)fT(t);else{if(t instanceof i){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},i.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},i.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},i.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&gd(e,t)},i.prototype.remove=function(t){var e=this._finalizers;e&&gd(e,t),t instanceof i&&t._removeParent(this)},i.EMPTY=function(){var t=new i;return t.closed=!0,t}(),i}();var $Y=uc.EMPTY;function dc(i){return i instanceof uc||i&&"closed"in i&&rt(i.remove)&&rt(i.add)&&rt(i.unsubscribe)}function fT(i){rt(i)?i():i.unsubscribe()}var Te={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var $i={setTimeout:function(i,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var s=$i.delegate;return s?.setTimeout?s.setTimeout.apply(s,ji([i,t],Xi(e))):setTimeout.apply(void 0,ji([i,t],Xi(e)))},clearTimeout:function(i){var t=$i.delegate;return(t?.clearTimeout||clearTimeout)(i)},delegate:void 0};function fc(i){$i.setTimeout(function(){var t=Te.onUnhandledError;if(t)t(i);else throw i})}function xd(){}var pT=function(){return _d("C",void 0,void 0)}();function mT(i){return _d("E",void 0,i)}function gT(i){return _d("N",i,void 0)}function _d(i,t,e){return{kind:i,value:t,error:e}}var Hr=null;function xT(i){if(Te.useDeprecatedSynchronousErrorHandling){var t=!Hr;if(t&&(Hr={errorThrown:!1,error:null}),i(),t){var e=Hr,r=e.errorThrown,s=e.error;if(Hr=null,r)throw s}}else i()}function _T(i){Te.useDeprecatedSynchronousErrorHandling&&Hr&&(Hr.errorThrown=!0,Hr.error=i)}var Yo=function(i){$o(t,i);function t(e){var r=i.call(this)||this;return r.isStopped=!1,e?(r.destination=e,dc(e)&&e.add(r)):r.destination=nE,r}return t.create=function(e,r,s){return new mc(e,r,s)},t.prototype.next=function(e){this.isStopped?bd(gT(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?bd(mT(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?bd(pT,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,i.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(uc);var iE=Function.prototype.bind;function yd(i,t){return iE.call(i,t)}var sE=function(){function i(t){this.partialObserver=t}return i.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){pc(r)}},i.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){pc(r)}else pc(t)},i.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){pc(e)}},i}(),mc=function(i){$o(t,i);function t(e,r,s){var o=i.call(this)||this,n;if(rt(e)||!e)n={next:e??void 0,error:r??void 0,complete:s??void 0};else{var a;o&&Te.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return o.unsubscribe()},n={next:e.next&&yd(e.next,a),error:e.error&&yd(e.error,a),complete:e.complete&&yd(e.complete,a)}):n=e}return o.destination=new sE(n),o}return t}(Yo);function pc(i){Te.useDeprecatedSynchronousErrorHandling?_T(i):fc(i)}function oE(i){throw i}function bd(i,t){var e=Te.onStoppedNotification;e&&$i.setTimeout(function(){return e(i,t)})}var nE={closed:!0,next:xd,error:oE,complete:xd};var Yi=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function yT(i){return i}function bT(i){return i.length===0?yT:i.length===1?i[0]:function(e){return i.reduce(function(r,s){return s(r)},e)}}var J=function(){function i(t){t&&(this._subscribe=t)}return i.prototype.lift=function(t){var e=new i;return e.source=this,e.operator=t,e},i.prototype.subscribe=function(t,e,r){var s=this,o=cE(t)?t:new mc(t,e,r);return xT(function(){var n=s,a=n.operator,c=n.source;o.add(a?a.call(o,c):c?s._subscribe(o):s._trySubscribe(o))}),o},i.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},i.prototype.forEach=function(t,e){var r=this;return e=vT(e),new e(function(s,o){var n=new mc({next:function(a){try{t(a)}catch(c){o(c),n.unsubscribe()}},error:o,complete:s});r.subscribe(n)})},i.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},i.prototype[Yi]=function(){return this},i.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return bT(t)(this)},i.prototype.toPromise=function(t){var e=this;return t=vT(t),new t(function(r,s){var o;e.subscribe(function(n){return o=n},function(n){return s(n)},function(){return r(o)})})},i.create=function(t){return new i(t)},i}();function vT(i){var t;return(t=i??Te.Promise)!==null&&t!==void 0?t:Promise}function aE(i){return i&&rt(i.next)&&rt(i.error)&&rt(i.complete)}function cE(i){return i&&i instanceof Yo||aE(i)&&dc(i)}function lE(i){return rt(i?.lift)}function Fe(i){return function(t){if(lE(t))return t.lift(function(e){try{return i(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Wr(i,t,e,r,s){return new hE(i,t,e,r,s)}var hE=function(i){$o(t,i);function t(e,r,s,o,n,a){var c=i.call(this,e)||this;return c.onFinalize=n,c.shouldUnsubscribe=a,c._next=r?function(l){try{r(l)}catch(h){e.error(h)}}:i.prototype._next,c._error=o?function(l){try{o(l)}catch(h){e.error(h)}finally{this.unsubscribe()}}:i.prototype._error,c._complete=s?function(){try{s()}catch(l){e.error(l)}finally{this.unsubscribe()}}:i.prototype._complete,c}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;i.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(Yo);var gc=function(i){return i&&typeof i.length=="number"&&typeof i!="function"};function xc(i){return rt(i?.then)}function _c(i){return rt(i[Yi])}function yc(i){return Symbol.asyncIterator&&rt(i?.[Symbol.asyncIterator])}function bc(i){return new TypeError("You provided "+(i!==null&&typeof i=="object"?"an invalid object":"'"+i+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function uE(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var vc=uE();function Tc(i){return rt(i?.[vc])}function Sc(i){return hT(this,arguments,function(){var e,r,s,o;return lc(this,function(n){switch(n.label){case 0:e=i.getReader(),n.label=1;case 1:n.trys.push([1,,9,10]),n.label=2;case 2:return[4,Nr(e.read())];case 3:return r=n.sent(),s=r.value,o=r.done,o?[4,Nr(void 0)]:[3,5];case 4:return[2,n.sent()];case 5:return[4,Nr(s)];case 6:return[4,n.sent()];case 7:return n.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function wc(i){return rt(i?.getReader)}function Ue(i){if(i instanceof J)return i;if(i!=null){if(_c(i))return dE(i);if(gc(i))return fE(i);if(xc(i))return pE(i);if(yc(i))return TT(i);if(Tc(i))return mE(i);if(wc(i))return gE(i)}throw bc(i)}function dE(i){return new J(function(t){var e=i[Yi]();if(rt(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function fE(i){return new J(function(t){for(var e=0;e<i.length&&!t.closed;e++)t.next(i[e]);t.complete()})}function pE(i){return new J(function(t){i.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,fc)})}function mE(i){return new J(function(t){var e,r;try{for(var s=Lr(i),o=s.next();!o.done;o=s.next()){var n=o.value;if(t.next(n),t.closed)return}}catch(a){e={error:a}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}t.complete()})}function TT(i){return new J(function(t){xE(i,t).catch(function(e){return t.error(e)})})}function gE(i){return TT(Sc(i))}function xE(i,t){var e,r,s,o;return lT(this,void 0,void 0,function(){var n,a;return lc(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),e=uT(i),c.label=1;case 1:return[4,e.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(n=r.value,t.next(n),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),s={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(o=e.return)?[4,o.call(e)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function pe(i,t,e,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){e(),s?i.add(this.schedule(null,r)):this.unsubscribe()},r);if(i.add(o),!s)return o}function Pc(i,t){return t===void 0&&(t=0),Fe(function(e,r){e.subscribe(Wr(r,function(s){return pe(r,i,function(){return r.next(s)},t)},function(){return pe(r,i,function(){return r.complete()},t)},function(s){return pe(r,i,function(){return r.error(s)},t)}))})}function Ec(i,t){return t===void 0&&(t=0),Fe(function(e,r){r.add(i.schedule(function(){return e.subscribe(r)},t))})}function ST(i,t){return Ue(i).pipe(Ec(t),Pc(t))}function wT(i,t){return Ue(i).pipe(Ec(t),Pc(t))}function PT(i,t){return new J(function(e){var r=0;return t.schedule(function(){r===i.length?e.complete():(e.next(i[r++]),e.closed||this.schedule())})})}function ET(i,t){return new J(function(e){var r;return pe(e,t,function(){r=i[vc](),pe(e,t,function(){var s,o,n;try{s=r.next(),o=s.value,n=s.done}catch(a){e.error(a);return}n?e.complete():e.next(o)},0,!0)}),function(){return rt(r?.return)&&r.return()}})}function Ac(i,t){if(!i)throw new Error("Iterable cannot be null");return new J(function(e){pe(e,t,function(){var r=i[Symbol.asyncIterator]();pe(e,t,function(){r.next().then(function(s){s.done?e.complete():e.next(s.value)})},0,!0)})})}function AT(i,t){return Ac(Sc(i),t)}function CT(i,t){if(i!=null){if(_c(i))return ST(i,t);if(gc(i))return PT(i,t);if(xc(i))return wT(i,t);if(yc(i))return Ac(i,t);if(Tc(i))return ET(i,t);if(wc(i))return AT(i,t)}throw bc(i)}function Rt(i,t){return t?CT(i,t):Ue(i)}function MT(i,t){return Fe(function(e,r){var s=0;e.subscribe(Wr(r,function(o){r.next(i.call(t,o,s++))}))})}function BT(i,t,e,r,s,o,n,a){var c=[],l=0,h=0,u=!1,d=function(){u&&!c.length&&!l&&t.complete()},f=function(g){return l<r?p(g):c.push(g)},p=function(g){o&&t.next(g),l++;var _=!1;Ue(e(g,h++)).subscribe(Wr(t,function(b){s?.(b),o?f(b):t.next(b)},function(){_=!0},void 0,function(){if(_)try{l--;for(var b=function(){var y=c.shift();n?pe(t,n,function(){return p(y)}):p(y)};c.length&&l<r;)b();d()}catch(y){t.error(y)}}))};return i.subscribe(Wr(t,f,function(){u=!0,d()})),function(){a?.()}}function wt(i,t,e){return e===void 0&&(e=1/0),rt(t)?wt(function(r,s){return MT(function(o,n){return t(r,o,s,n)})(Ue(i(r,s)))},e):(typeof t=="number"&&(e=t),Fe(function(r,s){return BT(r,s,i,e)}))}function Ko(i){return Fe(function(t,e){try{t.subscribe(e)}finally{e.add(i)}})}var _E=i=>i.split("/").pop(),vd=class{name="advancedBufferLoader";priority=2;constructor(t){this.bufferMap=t}test(t){return!0}async load(t){let e=t.startsWith("file:")?t:_E(t),r=this.bufferMap[e];if(!r)throw new Error(`Buffer not found for key: ${e}`);return{data:r.buffer,type:r.type,metadata:null}}async testParse(t){return!0}async parse(t){if(t instanceof M)return t;let e=new Blob([t.data],{type:t.type}),r=await createImageBitmap(e);return new M.from(r)}async unload(t){t.destroy(!0)}},Td=class i extends nc{static rendererName="pixi";_app;_audioStage=new cc;_state={elements:[]};_eventHandler;_plugins;_currentSubscription;_advancedLoader;get canvas(){return this._app.canvas}init=async t=>{let{eventHandler:e,plugins:r,width:s,height:o,backgroundColor:n}=t;for(let c of r)if(c.rendererName!==i.rendererName)throw new Error("Plugin does not match renderer name");this._plugins=r,this._eventHandler=e,this._app=new Za,this._app.audioStage=this._audioStage,await this._app.init({width:s,height:o,backgroundColor:n});let a=new jt;return a.rect(0,0,s,o),a.fill(n||0),this._app.stage.addChild(a),this._app.stage.width=s,this._app.stage.height=o,this._app.ticker.add(this._app.audioStage.tick),this};destroy=()=>{this._app.audioStage.destroy(),this._app.destroy()};_classifyAsset=t=>t?t.startsWith("audio/")?"audio":t.startsWith("font/")||["application/font-woff","application/font-woff2","application/x-font-ttf","application/x-font-otf"].includes(t)?"font":"texture":"texture";loadAssets=async t=>{if(!t)throw new Error("assetBufferMap is required");let e={audio:{},font:{},texture:{}};for(let[s,o]of Object.entries(t)){let n=this._classifyAsset(o.type);e[n][s]=o}await Promise.all(Object.entries(e.audio).map(([s,o])=>Vi.load(s,o.buffer))),await Promise.all(Object.entries(e.font).map(async([s,o])=>{let n=new Blob([o.buffer],{type:o.type}),a=URL.createObjectURL(n),c=new FontFace(s,`url(${a})`);try{await c.load(),document.fonts.add(c),console.log(`Font loaded successfully: ${s}`)}catch(l){console.error(`Failed to load font ${s}:`,l)}finally{URL.revokeObjectURL(a)}})),this._advancedLoader?Object.assign(this._advancedLoader.bufferMap,e.texture):(this._advancedLoader=new vd(e.texture),ve.loader.parsers.length=0,ve.reset(),I.add({name:"advanced-buffer-loader",extension:x.Asset,priority:Et.High,loader:this._advancedLoader}),typeof ve.registerPlugin=="function"&&ve.registerPlugin(this._advancedLoader));let r=Object.keys(e.texture);return Promise.all(r.map(s=>ve.load(s)))};loadAudioAssets=async t=>Promise.all(t.map(async e=>{let s=await(await fetch(e)).arrayBuffer();return Vi.load(e,s)}));updatedBackgroundColor=t=>{this._app.renderer.background.color=t};render=t=>{this._render(this._app,this._app.stage,this._state,t,this._eventHandler),this._state=t};_getRendererByElement=t=>{for(let e of this._plugins)if(e.rendererType===t.type)return e;throw new Error(`No renderer found for element type: ${t.type}`)};_getTransitionByType=t=>{for(let e of this._plugins)if(e.transitionType===t)return e;throw new Error(`No transition found for transition type: ${t}`)};_render=async(t,e,r,s,o)=>{let n=Date.now(),{toAddElements:a,toUpdateElements:c,toDeleteElements:l}=ac(r.elements,s.elements),h=[];for(let u of l){let d=this._getRendererByElement(u);h.push(d.remove(t,{parent:e,element:u,transitions:s.transitions,getRendererByElement:this._getRendererByElement,getTransitionByType:this._getTransitionByType,eventHandler:o}))}for(let u of a){let d=this._getRendererByElement(u);h.push(d.add(t,{parent:e,element:u,getRendererByElement:this._getRendererByElement,transitions:s.transitions,getTransitionByType:this._getTransitionByType,eventHandler:o}))}for(let u of c){let d=this._getRendererByElement(u.next);h.push(d.update(t,{parent:e,prevElement:u.prev,nextElement:u.next,getRendererByElement:this._getRendererByElement,transitions:s.transitions,getTransitionByType:this._getTransitionByType,eventHandler:o}))}t.stage.children.sort((u,d)=>{let f=s.elements.findIndex(g=>g.id===u.label),p=s.elements.findIndex(g=>g.id===d.label);return f-p}),this._currentSubscription&&(this._currentSubscription.closed||this._currentSubscription.unsubscribe()),this._currentSubscription=Rt(h).pipe(wt(u=>u),Ko(()=>{o&&o("completed",{id:s.id,diffTime:Date.now()-n}),this._currentSubscription=void 0})).subscribe({error:u=>{console.error("Error:",u)}})}},RT=Td;var Sd=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="sprite";add=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e,l=o.url?M.from(o.url):M.EMPTY,h,u,d=o.scaleX??1,f=o.scaleY??1;o.hoverUrl&&(h=M.from(o.hoverUrl)),o.clickUrl&&(u=M.from(o.clickUrl));let p=new zt(l);p.label=o.id,(o.eventName||o.hoverUrl||o.clickUrl)&&(p.cursor="pointer",p.eventMode="static"),o.width!==void 0?p.width=o.width*d:p.width*=d,o.height!==void 0?p.height=o.height*f:p.height*=f,o.anchorX!==void 0&&(p.pivot.x=p.width*o.anchorX),o.anchorY!==void 0&&(p.pivot.y=p.height*o.anchorY),o.rotation!==void 0&&(p.rotation=o.rotation*Math.PI/180),o.x!==void 0&&(p.x=o.x),o.y!==void 0&&(p.y=o.y),o.zIndex!==void 0&&(p.zIndex=o.zIndex),o.alpha!==void 0&&(p.alpha=o.alpha),(h||u)&&p.on("pointerup",()=>{p.texture=l}).on("pointerupoutside",()=>{p.texture=l}).on("pointerleave",()=>{p.texture=l}),u&&p.on("pointerdown",()=>{p.texture=u}),h&&p.on("pointerenter",()=>{p.texture=h}),p.on("pointerup",b=>{b.stopPropagation();let y=b.button;y===0?c&&c(o.eventName,o.eventPayload):y===2&&(o.rightClickEventName&&c?c(o.rightClickEventName):t.stage.emit("rightclick",event))});let g=[];for(let b of n)if(b.elementId===o.id&&b.event===Bt.Add){let y=a(b.type);if(!y)throw new Error(`Transition class not found for type ${b.type}`);g.push(y.add(t,p,b))}s.addChild(p);let _=Rt(g).pipe(wt(b=>b)).subscribe({error:b=>{console.error("Error:",b)},complete:()=>r.complete()});return()=>{_.unsubscribe()}});remove=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,c=s.getChildByName(o.id);if(!c)throw new Error(`Sprite with id ${o.id} not found`);let l=[];for(let u of n)if(u.elementId===o.id&&u.event===Bt.Remove){let d=a(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);l.push(d.remove(t,c,u))}let h=Rt(l).pipe(wt(u=>u)).subscribe({error:u=>{console.error("Error:",u)},complete:()=>{r.complete(),c&&c.destroy()}});return()=>{h.unsubscribe(),c&&c.destroy()}});update=(t,{parent:e,prevElement:r,nextElement:s,transitions:o=[],getTransitionByType:n,eventHandler:a})=>new J(c=>{let l=e.getChildByName(r.id);if(!l)throw new Error(`Sprite with id ${r.id} not found`);let h=[];for(let f of o)if(f.elementId===r.id&&f.event===Bt.Update){let p=n(f.type);if(!p)throw new Error(`Transition class not found for type ${f.type}`);h.push(p.add(t,l,f))}if(h.length>0){let f=Rt(h).pipe(wt(p=>p)).subscribe({error:p=>{console.error("Error:",p)},complete:()=>{u(),c.complete()}});return()=>{f.unsubscribe()}}else return d(),c.complete(),()=>{};function u(){if(r.url!==s.url||r.hoverUrl!==s.hoverUrl||r.clickUrl!==s.clickUrl){if(s.url){let _=M.from(s.url);if(l.texture=_,!r.url&&s.url)if(_.baseTexture.valid){let b=s.scaleX??1,y=s.scaleY??1;l.width=(s.width??_.width)*b,l.height=(s.height??_.height)*y}else _.baseTexture.once("loaded",()=>{let b=s.scaleX??1,y=s.scaleY??1;l.width=(s.width??_.width)*b,l.height=(s.height??_.height)*y})}let p=r.hoverUrl||r.clickUrl,g=s.hoverUrl||s.clickUrl;if(!p&&g){let _=l.texture;l.on("pointerup",()=>{l.texture=_}).on("pointerupoutside",()=>{l.texture=_}).on("pointerleave",()=>{l.texture=_})}if(s.hoverUrl){let _=M.from(s.hoverUrl);l.off("pointerenter"),l.on("pointerenter",()=>{l.texture=_})}if(s.clickUrl){let _=M.from(s.clickUrl);l.off("pointerdown"),l.on("pointerdown",()=>{l.texture=_})}}(s.eventName||s.hoverUrl||s.clickUrl)&&(l.cursor="pointer",l.eventMode="static")}function d(){if(r.url!==s.url||r.hoverUrl!==s.hoverUrl||r.clickUrl!==s.clickUrl){if(s.url){let y=M.from(s.url);if(l.texture=y,!r.url&&s.url)if(y.baseTexture.valid){let v=s.scaleX??1,S=s.scaleY??1;l.width=(s.width??y.width)*v,l.height=(s.height??y.height)*S}else y.baseTexture.once("loaded",()=>{let v=s.scaleX??1,S=s.scaleY??1;l.width=(s.width??y.width)*v,l.height=(s.height??y.height)*S})}let _=r.hoverUrl||r.clickUrl,b=s.hoverUrl||s.clickUrl;if(!_&&b){let y=l.texture;l.on("pointerup",()=>{l.texture=y}).on("pointerupoutside",()=>{l.texture=y}).on("pointerleave",()=>{l.texture=y})}if(s.hoverUrl){let y=M.from(s.hoverUrl);l.off("pointerenter"),l.on("pointerenter",()=>{l.texture=y})}if(s.clickUrl){let y=M.from(s.clickUrl);l.off("pointerdown"),l.on("pointerdown",()=>{l.texture=y})}}s.x!==void 0&&s.x!==r.x&&(l.x=s.x),s.y!==void 0&&s.y!==r.y&&(l.y=s.y),s.rotation!==void 0&&s.rotation!==r.rotation&&(l.rotation=s.rotation*Math.PI/180);let p=s.scaleX??1,g=s.scaleY??1;s.width!==void 0&&(s.width!==r.width||p!==(r.scaleX??1))&&(l.width=s.width*p),s.height!==void 0&&(s.height!==r.height||g!==(r.scaleY??1))&&(l.height=s.height*g),s.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=l.width*s.anchorX/p),s.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=l.height*s.anchorY/g),s.zIndex!==void 0&&s.zIndex!==r.zIndex&&(l.zIndex=s.zIndex),s.alpha!==void 0&&s.alpha!==r.alpha&&(l.alpha=s.alpha),(s.eventName||s.hoverUrl||s.clickUrl)&&(l.cursor="pointer",l.eventMode="static")}})};var Cc=i=>new St({wordWrap:i.wordWrap||!0,breakWords:i.breakWords||!1,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),wd=class{static rendererName="pixi";rendererName="pixi";rendererType="text";add=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e,l=Cc(o.style),h=new ur({text:o.text,style:l}),u;o.hoverStyle&&(u=Cc(o.hoverStyle));let d;if(o.clickedStyle&&(d=Cc(o.clickedStyle)),(o.eventName||o.clickedStyle||o.hoverStyle)&&(h.cursor="pointer",h.eventMode="static"),h.label=o.id,o.x!==void 0&&(h.x=o.x),o.y!==void 0&&(h.y=o.y),o.anchorX!==void 0&&(h.anchor.x=o.anchorX),o.anchorY!==void 0&&(h.anchor.y=o.anchorY),o.anchorX!==void 0||o.anchorY!==void 0){let g=h.getLocalBounds();h.hitArea=new z(-g.width*h.anchor.x,-g.height*h.anchor.y,g.width,g.height)}h.on("pointerupoutside",()=>{h.style=l}).on("pointerup",()=>{h.style=l}).on("pointerleave",()=>{h.style=l}),h.on("pointerup",g=>{o.clickSoundUrl&&t.soundStage&&t.soundStage.add({id:`${o.id}-click-${Math.random()}`,url:o.clickSoundUrl,loop:!1,volume:o.clickSoundVolume??50/100}),g.stopPropagation(),c&&c(o.eventName,o.eventPayload)}),d&&h.on("pointerdown",()=>{h.style=d}),u&&h.on("pointerenter",()=>{h.style=u,o.hoverSoundUrl&&t.soundStage&&o.hoverSoundVolume!==void 0&&t.soundStage.add({id:`${o.id}-hover-${Math.random()}`,url:o.hoverSoundUrl,loop:!1,volume:o.hoverSoundVolume/100})});let f=[];for(let g of n)if(g.elementId===o.id&&g.event===Bt.Add){let _=a(g.type);if(!_)throw new Error(`Transition class not found for type ${g.type}`);f.push(_.add(t,h,g))}s.addChild(h);let p=Rt(f).pipe(wt(g=>g)).subscribe({error:g=>{console.error("Error:",g),r.error(g)},complete:()=>r.complete()});return()=>{p.unsubscribe()}});remove=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,c=s.getChildByName(o.id);if(!c){console.warn(`Text with id ${o.id} not found`),r.complete();return}let l=[];for(let u of n)if(u.elementId===o.id&&u.event===Bt.Remove){let d=a(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);l.push(d.remove(t,c,u))}let h=Rt(l).pipe(wt(u=>u)).subscribe({error:u=>{console.error("Error:",u),r.error(u)},complete:()=>{c.destroy(),r.complete()}});return()=>{h.unsubscribe(),c&&c.destroy()}});update=(t,e)=>new J(r=>{let{parent:s,prevElement:o,nextElement:n,transitions:a,getTransitionByType:c,eventHandler:l}=e,h=s.getChildByName(o.id);if(!h){console.warn(`Text with id ${o.id} not found`),r.complete();return}if(JSON.stringify(o)!==JSON.stringify(n)){let u=[this.add(t,{parent:s,element:n,transitions:a,getTransitionByType:c,eventHandler:l}),this.remove(t,{parent:s,element:o,transitions:a,getTransitionByType:c})],d=Rt(u).pipe(wt(f=>f)).subscribe({error:f=>{console.error("Error:",f),r.error(f)},complete:()=>r.complete()});return()=>{d.unsubscribe()}}else o.text!==n.text&&(h.text=n.text),JSON.stringify(o.style)!==JSON.stringify(n.style)&&(h.style=Cc(n?.style)),n.x!==void 0&&(h.x=n.x),n.y!==void 0&&(h.y=n.y),r.complete();return()=>{}})};var Ki=(i,t=!1)=>new St({wordWrap:i.wordWrap||!0,breakWords:t,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),Pd=class{static rendererName="pixi";rendererName="pixi";rendererType="text-revealing";add=async(t,{parent:e,element:r})=>{let s=Ki(r.style,r.text),o=new ur({text:"",style:s});o.label=r.id,o.text_id=r.text;let n=new at;r.x!==void 0&&(n.x=r.x),r.y!==void 0&&(n.y=r.y),n.addChild(o),n.label=r.id,e.addChild(n);let a=r.style.wordWrapWidth||500,c=r.text?[{text:r.text,style:r.style}]:r.segments,l=[],h=[],u=0,d=0,f=0;for(;;){let T=c[0];if(!T){h.length>0&&l.push({lineParts:h,y:d});break}if(d>1e4)break;let P={...T.style,wordWrapWidth:a-u},A=Ct.measureText(T.text,Ki(P));A.lineHeight>f&&(f=A.lineHeight);let R=Ct.measureText("a",Ki(P)),G=Ct.measureText("a a",Ki(P)).width-R.width*2;if(A.lineWidths[0]+u>a){u=0,l.push({lineParts:h,y:d}),d+=f,f=0,h=[];continue}let L=A.lines[0],Y=A.lines.slice(1).join(" "),ht={text:L,style:P,x:u,y:0};if(h.push(ht),Y&&Y.length>0?T.text=Y:c.shift(),!(!L||L.length===0)){if(T.furigana){let Ft=Ct.measureText(T.furigana.text,Ki(T.furigana.style)),N={text:T.furigana.text,style:T.furigana.style,x:u+(A.width-Ft.width)/2,y:-10};h.push(N)}u+=A.lineWidths[0]+G}}l.forEach(T=>{let P=new at;P.y=T.y,P.alpha=0,T.lineParts.forEach(A=>{let R=new ur({text:A.text,style:Ki(A.style),x:A.x,y:A.y});P.addChild(R)}),n.addChild(P)});let p=new jt,g=1e3,_=a/2,b=a/2;p.fill({color:16777215,alpha:1}),p.rect(0,0,_,g);for(let T=0;T<b;T++)p.fill({color:16777215,alpha:1-T/b}),p.rect(_+T,0,_+1,g);let y=t.renderer.generateTexture(p),v=new zt(y);v.x=-1.35*_-b,t.stage.addChild(v);let S=0,w=1;if(l.length!==0){if(r.displaySpeed===100||r.hasEnded){n.children.forEach(T=>{t.stage.removeChild(v),T.mask=null,T.alpha=1});return}await new Promise(T=>{let P=A=>{if(w>n.children.length){T();return}n.getChildAt(w).mask||(n.getChildAt(w).mask=v,n.getChildAt(w).alpha=1),S+=A.deltaMS;let C=(r.displaySpeed||50)/1e3;v.x+=C*S,v.x>=0&&(n.getChildAt(w).mask=null,v.x=-1.35*_-b,w=w+1,S=0,w>=n.children.length&&(n.getChildAt(w-1).mask=null,t.ticker.remove(P),T()))};t.ticker.add(P)})}};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Text with id ${s.id} not found`,{parent:r});return}let c=[];for(let l of o)if(l.elementId===s.id&&l.event===Bt.Remove){let h=n(l.type);if(!h)throw new Error(`Transition class not found for type ${l.type}`);c.push(h.remove(t,a,l))}await Promise.all(c),a.destroy()};update=async(t,e)=>{let{parent:r,prevElement:s,nextElement:o}=e;if(!r.getChildByName(s.id)){console.warn(`Text with id ${s.id} not found`,{parent:r});return}await this.remove(t,{parent:r,element:s}),await this.add(t,{parent:r,element:o})}};var Ed=class{static rendererName="pixi";rendererName="pixi";rendererType="container";add=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,getRendererByElement:c,eventHandler:l}=e,h=structuredClone(o),u=new at;u.label=h.id;let d={};h.x!==void 0&&(typeof h.x=="string"&&h.x.endsWith("%")?u.x=Number(h.x.replace("%",""))*t.screen.width/100:u.x=h.x),h.y!==void 0&&(typeof h.y=="string"&&h.y.endsWith("%")?u.y=Number(h.y.replace("%",""))*t.screen.height/100:u.y=h.y),h.scaleX!==void 0&&(u.scale.x=h.scaleX),h.scaleY!==void 0&&(u.scale.y=h.scaleY),h.zIndex!==void 0&&(u.zIndex=h.zIndex),h.rotation!==void 0&&(u.rotation=h.rotation*Math.PI/180),h.propagateEvents&&(u.eventMode="static",["pointerup","pointerupoutside","pointerleave","pointerdown","pointerenter"].forEach(w=>{u.on(w,T=>{T.stopPropagation();for(let P of u.children)P.emit(w)})}));let f=h.gap||0,p=new jt().roundRect(0,0,h.width||0,h.height||0,1).fill(h.fill?h.fill.color:"transparent"),g=[0,.5,1],_=h.anchorX??0,b=h.anchorY??0;if(!g.includes(_))throw new Error(`Invalid anchorX value: ${_}. Must be 0, 0.5, or 1`);if(!g.includes(b))throw new Error(`Invalid anchorY value: ${b}. Must be 0, 0.5, or 1`);if(h.direction){let w,T;h.direction==="horizontal"?(w=h.children.reduce((A,R)=>A+R.width+f,0),T=h.children.reduce((A,R)=>Math.max(A,R.height||0),0)):h.direction==="vertical"&&(w=h.children.reduce((A,R)=>Math.max(A,R.width||0),0),T=h.children.reduce((A,R)=>A+R.height+f,0));let P={x:_,y:b};h.direction==="horizontal"?this.layoutChildren({element:h,anchor:P,totalWidth:w,totalHeight:T,gap:f,direction:"horizontal",scroll:h.scroll}):h.direction==="vertical"&&this.layoutChildren({element:h,anchor:P,totalWidth:w,totalHeight:T,gap:f,direction:"vertical",scroll:h.scroll}),this.setupScrolling({container:u,element:h,totalHeight:T,totalWidth:w,eventHandler:l,sliderRef:d}),p=this.createContainerGraphic(h,w,T,P)}p.label=`${h.id}-container-background`,u.addChild(p);let y=[];(h.children||[]).forEach(w=>{let T=c(w),P=h.width||0,A=h.height||0,R=_*P,C=b*A,G={zIndex:h.zIndex,...w,x:(w.x||0)+R,y:(w.y||0)+C};y.push(T.add(t,{parent:u,element:G,transitions:n,getTransitionByType:a,getRendererByElement:c,eventHandler:l}))});let v=[];for(let w of n)if(w.elementId===h.id&&w.event===Bt.Add){let T=a(w.type);if(!T)throw new Error(`Transition class not found for type ${w.type}`);v.push(T.add(t,u,w))}s.addChild(u);let S=Rt(y).pipe(wt(w=>w)).subscribe({error:w=>{console.error("Error:",w)},complete:()=>{let{width:w,height:T}=this.getContainerDimensions(h,u),P=_*w,A=b*T;u.pivot.x=P,u.pivot.y=A,r.complete()}});return()=>{S.unsubscribe()}});remove=(t,e)=>(console.log("remove container 11111111111"),new J(r=>{let{parent:s,element:o}=e,n=s.getChildByName(o.id);if(!n){console.warn(`Container with id ${o.id} not found`);return}return n.destroy(),()=>{n.destroy()}}));update=(t,e)=>new J(r=>{let{parent:s,prevElement:o,nextElement:n,getRendererByElement:a,transitions:c=[],getTransitionByType:l,eventHandler:h}=e,u=structuredClone(o),d=structuredClone(n),f=s.getChildByName(u.id);if(!f){console.warn(`Container with id ${u.id} not found`);return}d.x!==void 0&&d.x!==u.x&&(f.x=d.x),d.y!==void 0&&d.y!==u.y&&(f.y=d.y),d.rotation!==void 0&&d.rotation!==u.rotation&&(f.rotation=d.rotation*Math.PI/180);let p=[0,.5,1],g=d.anchorX??0,_=d.anchorY??0;if(!p.includes(g))throw new Error(`Invalid anchorX value: ${g}. Must be 0, 0.5, or 1`);if(!p.includes(_))throw new Error(`Invalid anchorY value: ${_}. Must be 0, 0.5, or 1`);if(d.direction){let w=d.gap||0,T,P;d.direction==="horizontal"?(T=d.children.reduce((C,G)=>C+G.width+w,0),P=d.children.reduce((C,G)=>Math.max(C,G.height||0),0)):d.direction==="vertical"&&(T=d.children.reduce((C,G)=>Math.max(C,G.width||0),0),P=d.children.reduce((C,G)=>C+G.height+w,0));let A={x:g,y:_};d.direction==="horizontal"?this.layoutChildren({element:d,anchor:A,totalWidth:T,totalHeight:P,gap:w,direction:"horizontal",scroll:d.scroll}):d.direction==="vertical"&&this.layoutChildren({element:d,anchor:A,totalWidth:T,totalHeight:P,gap:w,direction:"vertical",scroll:d.scroll});let R=f.children.find(C=>C.label===`${d.id}-container-background`);if(R){R.destroy();let C=this.createContainerGraphic(d,T,P,A);C.label=`${d.id}-container-background`,f.addChildAt(C,0)}u.scroll!==d.scroll&&this.setupScrolling({container:f,element:d,totalHeight:P,totalWidth:T,eventHandler:h,sliderRef:{}})}let b=[],{toAddElements:y,toUpdateElements:v,toDeleteElements:S}=ac(u.children,d.children);for(let w of S){let T=a(w);b.push(T.remove(t,{parent:f,element:w,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}for(let w of y){let T=a(w),P=d.width||0,A=d.height||0,R=g*P,C=_*A,G={...w,x:(w.x||0)+R,y:(w.y||0)+C};b.push(T.add(t,{parent:f,element:G,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}for(let w of v){let T=a(w.next),P=d.width||0,A=d.height||0,R=g*P,C=_*A,G=u.anchorX??0,L=u.anchorY??0,Y=u.width||0,ht=u.height||0,Ft=G*Y,N=L*ht,F={...w.prev,x:(w.prev.x||0)+Ft,y:(w.prev.y||0)+N},oe={...w.next,x:(w.next.x||0)+R,y:(w.next.y||0)+C};b.push(T.update(t,{parent:f,prevElement:F,nextElement:oe,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}return f.children.sort((w,T)=>{let P=d.children?.findIndex(R=>R.id===w.label),A=d.children?.findIndex(R=>R.id===T.label);return P-A}),this._currentSubscription=Rt(b).pipe(wt(w=>w),Ko(()=>{let{width:w,height:T}=this.getContainerDimensions(d,f),P=g*w,A=_*T;f.pivot.x=P,f.pivot.y=A,r.complete()})).subscribe({error:w=>{r.error(w),console.error("Error:",w)}}),()=>{this._currentSubscription?.unsubscribe()}});layoutChildren({element:t,anchor:e,totalWidth:r,totalHeight:s,gap:o,direction:n,scroll:a}){let c=n==="horizontal",l=c?"x":"y",h=c?"y":"x",u=c?"width":"height",d=c?"height":"width",f=c?r:s,p=c?s:r,g=c?e.x:e.y,_=c?e.y:e.x;if(!a&&t[u]!==void 0&&t[u]<f){let y=0,v=0,S=0,w=0;(t.children||[]).forEach((T,P)=>{y>0&&y+T[u]>t[u]&&(this.alignRowElements(t.children.slice(w,P),l,g,t[u]),y=0,v+=S+o,S=0,w=P),T[l]=y,T[h]=v,y+=T[u]+o,S=Math.max(S,T[d]||0)}),w<t.children.length&&this.alignRowElements(t.children.slice(w),l,g,t[u])}else{if(g===0){let y=0;(t.children||[]).forEach(v=>{v[l]=y,y+=v[u]+o})}else if(g===1){let y=-f;(t.children||[]).forEach(v=>{v[l]=y,y+=v[u]+o})}else if(g===.5){let y=-f/2;(t.children||[]).forEach(v=>{v[l]=y,y+=v[u]+o})}_===0?(t.children||[]).forEach(y=>{y[h]=0}):_===.5?(t.children||[]).forEach(y=>{y[h]=-p/2}):_===1&&(t.children||[]).forEach(y=>{y[h]=-p})}}alignRowElements(t,e,r,s){if(!t.length)return;let o=t.reduce((n,a,c)=>n+a[e==="x"?"width":"height"]+(c>0,0),0);if(r===.5){let a=(s-o)/2;t.forEach(c=>{c[e]=a,a+=c[e==="x"?"width":"height"]+0})}else if(r===1){let a=s-o;t.forEach(c=>{c[e]=a,a+=c[e==="x"?"width":"height"]+0})}}createContainerGraphic(t,e,r,s){let o=new jt().roundRect(0,0,e,r,1).fill(t.fill?t.fill.color:"transparent");return s.x===1&&(o.x-=t.width),s.x===.5&&(o.x-=t.width/2),s.y===1&&(o.y-=t.height),s.y===.5&&(o.y-=t.height/2),o}getContainerDimensions(t,e){let r=t.width||0,s=t.height||0;if(!t.direction&&(!t.width||!t.height)&&e.children&&e.children.length>0){let o=1/0,n=-1/0,a=1/0,c=-1/0;e.children.forEach(l=>{let h=l.x||0,u=l.y||0,d=l.width||0,f=l.height||0;o=Math.min(o,h),n=Math.max(n,h+d),a=Math.min(a,u),c=Math.max(c,u+f)}),t.width||(r=n-o,(isNaN(r)||!isFinite(r))&&(r=0)),t.height||(s=c-a,(isNaN(s)||!isFinite(s))&&(s=0))}return{width:r,height:s}}setupScrolling({container:t,element:e,totalHeight:r,totalWidth:s,eventHandler:o,sliderRef:n}){let a=e.scroll&&e.height&&r>e.height,c=e.scroll&&e.width&&s>e.width;if(a||c){let l=0,h=0,u=-r+e.height,d=-s+e.width,f=new jt().rect(0,0,e.width||s,e.height||r).fill("red");t.mask=f,t.eventMode="static",t.addChild(f),t.on("wheel",p=>{if(a&&p.deltaY!==0&&(l-p.deltaY>0||l-p.deltaY<u||(l-=p.deltaY,t.y-=p.deltaY,f.y+=p.deltaY)),c&&(p.deltaX!==0||p.shiftKey&&p.deltaY!==0)){let g=p.deltaX!==0?p.deltaX:p.deltaY;if(h-g>0||h-g<d)return;h-=g,t.x-=g,f.x+=g}})}}};var yE={linear:i=>i},bE=(i,t,e,r)=>i+(t-i)*yE[r](e);function GT(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s of t){if(r==null)return e;r=r[s]}return r===void 0?e:r}function IT(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s=0;s<t.length-1;s++){let o=t[s];o in r||(r[o]={}),r=r[o]}return r[t[t.length-1]]=e,i}var vE=(i,t)=>{let e=[],r=0,s;i.forEach(({value:n,duration:a,easing:c,relative:l},h)=>{h===0?(s=n,e.push({time:r,value:n,easing:"linear"})):a!==void 0&&c!==void 0&&(r+=a,l?s=s+n:s=n,e.push({time:r,value:s,easing:c}))});let o=0;for(let n=0;n<e.length-1;n++){let{time:a,value:c,easing:l}=e[n],{time:h,value:u}=e[n+1];if(t>=a&&t<=h){let d=(t-a)/(h-a);o=bE(c,u,d,l);break}else t>h&&(o=u)}return o};function TE(i){return Math.max.apply(null,i)}var Ad=class{static rendererName="pixi";rendererName="pixi";transitionType="keyframes";_transition=(t,e,r)=>(console.log("keyframe transition setup"),new J(s=>{console.log("keyframe transition start");let{animationProperties:o}=r,n=Array.isArray(o)?o:Object.entries(o).map(([d,f])=>({...f,property:d})),a=n.map(d=>d.keyframes.reduce((f,p)=>f+p.duration||0,0)),c=TE(a),l=0,h={};n.forEach(d=>{h[d.property]=GT(e,d.property)});let u=d=>{if(l+=d.deltaMS,l>=c){t.ticker.remove(u),s.complete();return}let f={};n.forEach(p=>{let g=[];p.initialValue!==void 0?g=[{value:p.initialValue,duration:0}]:g=[{value:h[p.property],duration:0}],g=g.concat(p.keyframes),IT(f,p.property,vE(g,l))}),n.forEach(p=>{let{property:g}=p;e&&!e.destroyed&&IT(e,g,GT(f,g))})};return t.ticker.add(u),()=>{t.ticker.remove(u),u({deltaMS:c-l})}}));add=(t,e,r)=>this._transition(t,e,r);remove=(t,e,r)=>this._transition(t,e,r)};var Cd=class{static rendererName="pixi";rendererName="pixi";rendererType="rect";add=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e,l=new jt;l.label=o.id,o.x!==void 0&&(l.x=o.x),o.y!==void 0&&(l.y=o.y),o.alpha!==void 0&&(l.alpha=o.alpha),o.scaleX!==void 0&&(l.scale.x=o.scaleX),o.scaleY!==void 0&&(l.scale.y=o.scaleY),o.rotation!==void 0&&(l.rotation=o.rotation*Math.PI/180);let h=o.width,u=o.height;l.rect(0,0,h,u),l.fill(o.fill),o.anchorX!==void 0&&(l.pivot.x=h*o.anchorX),o.anchorY!==void 0&&(l.pivot.y=u*o.anchorY),(o.clickEventName||o.rightClickEventName)&&c&&(l.eventMode="static",l.on("pointerup",p=>{p.button===0?c(o.clickEventName):p.button===2&&c(o.rightClickEventName)})),o.wheelEventName&&c&&(l.eventMode="static",l.on("wheel",p=>{c(o.wheelEventName,{deltaY:p.deltaY})}));let d=[];for(let p of n)if(p.elementId===o.id&&p.event===Bt.Add){let g=a(p.type);if(!g)throw new Error(`Transition class not found for type ${p.type}`);d.push(g.add(t,l,p))}s.addChild(l);let f=Rt(d).pipe(wt(p=>p)).subscribe({error:p=>{console.error("Error:",p)},complete:()=>r.complete()});return()=>{f.unsubscribe()}});remove=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,c=s.getChildByName(o.id);if(!c)throw new Error(`Rect with id ${o.id} not found`);let l=[];for(let u of n)if(u.elementId===o.id&&u.event===Bt.Remove){let d=a(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);l.push(d.remove(t,c,u))}let h=Rt(l).pipe(wt(u=>u)).subscribe({error:u=>{console.error("Error:",u)},complete:()=>{r.complete(),c&&c.destroy()}});return()=>{h.unsubscribe(),c&&c.destroy()}});update=(t,{parent:e,prevElement:r,nextElement:s,transitions:o=[],getTransitionByType:n,eventHandler:a})=>new J(c=>{let l=e.getChildByName(r.id);if(!l)throw new Error(`Rect with id ${r.id} not found`);let h=[];for(let u of o)if(u.elementId===r.id&&u.event===Bt.Update){let d=n(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);h.push(d.add(t,l,u))}if(h.length>0){let u=Rt(h).pipe(wt(d=>d)).subscribe({error:d=>{console.error("Error:",d)},complete:()=>{(r.width!==s.width||r.height!==s.height||r.fill!==s.fill)&&(l.clear(),l.rect(0,0,s.width,s.height),l.fill(s.fill)),r.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=s.width*s.anchorX),r.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=s.height*s.anchorY),c.complete()}});return()=>{u.unsubscribe()}}else return r.x!==void 0&&s.x!==r.x&&(l.x=s.x),r.y!==void 0&&s.y!==r.y&&(l.y=s.y),r.alpha!==void 0&&s.alpha!==r.alpha&&(l.alpha=s.alpha),r.scaleX!==void 0&&s.scaleX!==r.scaleX&&(l.scale.x=s.scaleX),r.scaleY!==void 0&&s.scaleY!==r.scaleY&&(l.scale.y=s.scaleY),r.rotation!==void 0&&s.rotation!==r.rotation&&(l.rotation=s.rotation*Math.PI/180),(r.width!==s.width||r.height!==s.height||r.fill!==s.fill)&&(l.clear(),l.rect(0,0,s.width,s.height),l.fill(s.fill)),r.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=s.width*s.anchorX),r.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=s.height*s.anchorY),c.complete(),()=>{}})};var Md=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="slider";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o,eventHandler:n,ref:a})=>{let{direction:c,idleThumb:l,hoverThumb:h,idleBar:u,hoverBar:d,dragEndEventName:f,dragEventName:p,dragEventPayload:g,initialValue:_}=r,b={horizontal:{axis:"x",size:"width"},vertical:{axis:"y",size:"height"}},y=b[c].axis,v=b[c].size,S=M.from(l),w=M.from(h),T=M.from(u),P=M.from(d),A=new zt({texture:T,anchor:{x:0,y:0}});A.label=r.id;let R=A[v];A.x=r.x||0,A.y=r.y||0;let C=new zt({texture:S,anchor:{x:.5,y:.5}});if(C.y=A.height/2,C.x=A.width/2,C.eventMode="static",C.cursor="pointer",A.eventMode="static",A.cursor="pointer",C.on("pointerdown",Y).on("pointerup",ht).on("pointerupoutside",ht),A.on("pointerdown",G).on("pointerup",L).on("pointerupoutside",L),A.addChild(C),_!==void 0){let F=C[v]/2;C[y]=_/100*(R-C[v])+F}function G(F){C.texture=w,A.texture=P,Ft(F),t.stage.eventMode="static",t.stage.addEventListener("pointermove",Ft)}function L(F){C.texture=S,A.texture=T,Ft(F),t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",Ft)}function Y(F){F.stopPropagation(),C.texture=w,A.texture=P,t.stage.eventMode="static",t.stage.addEventListener("pointermove",Ft)}function ht(F){if(C.texture=S,A.texture=T,t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",Ft),f){let oe=A.toLocal(F.global)[y],q=C[v]/2;C[y]=Math.max(0+q,Math.min(oe,R-q));let ee=Math.floor((C[y]-q)/(R-C[v])*100),De=JSON.stringify(g);n&&n(f,JSON.parse(De.replace('"{{ value }}"',String(ee))))}}function Ft(F){let oe=A.toLocal(F.global)[y],q=C[v]/2;C[y]=Math.max(0+q,Math.min(oe,R-q));let ee=Math.floor((C[y]-q)/(R-C[v])*100);if(p){let De=JSON.stringify(g);n&&n(p,JSON.parse(De.replace('"{{ value }}"',String(ee))))}return ee}a&&(a.current={updateValue:F=>{let oe=C[v]/2;C[y]=F/100*(R-C[v])+oe}});let N=[];for(let F of s)if(F.elementId===r.id&&F.event===Bt.Add){let oe=o(F.type);if(!oe)throw new Error(`Transition class not found for type ${F.type}`);N.push(oe.add(t,A,F))}e.addChild(A),await Promise.all(N)};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Sprite with id ${s.id} not found`);return}let c=[];for(let l of o)if(l.elementId===s.id&&l.event===Bt.Remove){let h=n(l.type);if(!h)throw new Error(`Transition class not found for type ${l.type}`);c.push(h.remove(t,a,l))}await Promise.all(c),a.destroy()};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n,eventHandler:a})=>{if(!e.getChildByName(r.id)){console.warn(`Slider with id ${r.id} not found`,{parent:e});return}JSON.stringify(r)!==JSON.stringify(s)&&await Promise.all([this.remove(t,{parent:e,element:r,transitions:o,getTransitionByType:n,eventHandler:a}),this.add(t,{parent:e,element:s,transitions:o,getTransitionByType:n,eventHandler:a})])}};var Bd=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="audio";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o})=>{r.delay?setTimeout(()=>{t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})},r.delay):t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})};remove=async(t,e)=>{let{element:r}=e;t.audioStage.remove(r.id)};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n})=>{if(r.url!==s.url||r.volume!==s.volume){let a=t.audioStage.getById(r.id);a&&(a.url=s.url,a.volume=s.volume??1)}}};var Rd=class{constructor(){this.cache=new Map}async load(t){let e=[];for(let[r,s]of Object.entries(t))this.cache.has(r)||e.push([r,s]);e.length>0&&await Promise.all(e.map(async([r,s])=>{let a={buffer:await(await fetch(s.url)).arrayBuffer(),type:s.type};this.cache.set(r,a)}))}getBufferMap(){let t={};for(let[e,r]of this.cache.entries())t[e]=r;return t}clear(){this.cache.clear()}size(){return this.cache.size}has(t){return this.cache.has(t)}},SE=()=>new Rd;var g7=RT;export{Bd as AudioPlugin,Ed as ContainerRendererPlugin,Ad as KeyframeTransitionPlugin,Cd as RectRendererPlugin,Md as SliderRendererPlugin,Sd as SpriteRendererPlugin,wd as TextRendererPlugin,Pd as TextRevealingRendererPlugin,SE as createAssetBufferManager,g7 as default};
|
|
1142
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function gd(i,t){if(i){var e=i.indexOf(t);0<=e&&i.splice(e,1)}}var uc=function(){function i(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return i.prototype.unsubscribe=function(){var t,e,r,s,o;if(!this.closed){this.closed=!0;var n=this._parentage;if(n)if(this._parentage=null,Array.isArray(n))try{for(var a=Lr(n),c=a.next();!c.done;c=a.next()){var l=c.value;l.remove(this)}}catch(g){t={error:g}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else n.remove(this);var h=this.initialTeardown;if(rt(h))try{h()}catch(g){o=g instanceof hc?g.errors:[g]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var d=Lr(u),f=d.next();!f.done;f=d.next()){var p=f.value;try{fT(p)}catch(g){o=o??[],g instanceof hc?o=ji(ji([],Xi(o)),Xi(g.errors)):o.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}if(o)throw new hc(o)}},i.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)fT(t);else{if(t instanceof i){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},i.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},i.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},i.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&gd(e,t)},i.prototype.remove=function(t){var e=this._finalizers;e&&gd(e,t),t instanceof i&&t._removeParent(this)},i.EMPTY=function(){var t=new i;return t.closed=!0,t}(),i}();var $Y=uc.EMPTY;function dc(i){return i instanceof uc||i&&"closed"in i&&rt(i.remove)&&rt(i.add)&&rt(i.unsubscribe)}function fT(i){rt(i)?i():i.unsubscribe()}var Te={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var $i={setTimeout:function(i,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var s=$i.delegate;return s?.setTimeout?s.setTimeout.apply(s,ji([i,t],Xi(e))):setTimeout.apply(void 0,ji([i,t],Xi(e)))},clearTimeout:function(i){var t=$i.delegate;return(t?.clearTimeout||clearTimeout)(i)},delegate:void 0};function fc(i){$i.setTimeout(function(){var t=Te.onUnhandledError;if(t)t(i);else throw i})}function xd(){}var pT=function(){return _d("C",void 0,void 0)}();function mT(i){return _d("E",void 0,i)}function gT(i){return _d("N",i,void 0)}function _d(i,t,e){return{kind:i,value:t,error:e}}var Hr=null;function xT(i){if(Te.useDeprecatedSynchronousErrorHandling){var t=!Hr;if(t&&(Hr={errorThrown:!1,error:null}),i(),t){var e=Hr,r=e.errorThrown,s=e.error;if(Hr=null,r)throw s}}else i()}function _T(i){Te.useDeprecatedSynchronousErrorHandling&&Hr&&(Hr.errorThrown=!0,Hr.error=i)}var Yo=function(i){$o(t,i);function t(e){var r=i.call(this)||this;return r.isStopped=!1,e?(r.destination=e,dc(e)&&e.add(r)):r.destination=nE,r}return t.create=function(e,r,s){return new mc(e,r,s)},t.prototype.next=function(e){this.isStopped?bd(gT(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?bd(mT(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?bd(pT,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,i.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(uc);var iE=Function.prototype.bind;function yd(i,t){return iE.call(i,t)}var sE=function(){function i(t){this.partialObserver=t}return i.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){pc(r)}},i.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){pc(r)}else pc(t)},i.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){pc(e)}},i}(),mc=function(i){$o(t,i);function t(e,r,s){var o=i.call(this)||this,n;if(rt(e)||!e)n={next:e??void 0,error:r??void 0,complete:s??void 0};else{var a;o&&Te.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return o.unsubscribe()},n={next:e.next&&yd(e.next,a),error:e.error&&yd(e.error,a),complete:e.complete&&yd(e.complete,a)}):n=e}return o.destination=new sE(n),o}return t}(Yo);function pc(i){Te.useDeprecatedSynchronousErrorHandling?_T(i):fc(i)}function oE(i){throw i}function bd(i,t){var e=Te.onStoppedNotification;e&&$i.setTimeout(function(){return e(i,t)})}var nE={closed:!0,next:xd,error:oE,complete:xd};var Yi=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function yT(i){return i}function bT(i){return i.length===0?yT:i.length===1?i[0]:function(e){return i.reduce(function(r,s){return s(r)},e)}}var J=function(){function i(t){t&&(this._subscribe=t)}return i.prototype.lift=function(t){var e=new i;return e.source=this,e.operator=t,e},i.prototype.subscribe=function(t,e,r){var s=this,o=cE(t)?t:new mc(t,e,r);return xT(function(){var n=s,a=n.operator,c=n.source;o.add(a?a.call(o,c):c?s._subscribe(o):s._trySubscribe(o))}),o},i.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},i.prototype.forEach=function(t,e){var r=this;return e=vT(e),new e(function(s,o){var n=new mc({next:function(a){try{t(a)}catch(c){o(c),n.unsubscribe()}},error:o,complete:s});r.subscribe(n)})},i.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},i.prototype[Yi]=function(){return this},i.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return bT(t)(this)},i.prototype.toPromise=function(t){var e=this;return t=vT(t),new t(function(r,s){var o;e.subscribe(function(n){return o=n},function(n){return s(n)},function(){return r(o)})})},i.create=function(t){return new i(t)},i}();function vT(i){var t;return(t=i??Te.Promise)!==null&&t!==void 0?t:Promise}function aE(i){return i&&rt(i.next)&&rt(i.error)&&rt(i.complete)}function cE(i){return i&&i instanceof Yo||aE(i)&&dc(i)}function lE(i){return rt(i?.lift)}function Fe(i){return function(t){if(lE(t))return t.lift(function(e){try{return i(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Wr(i,t,e,r,s){return new hE(i,t,e,r,s)}var hE=function(i){$o(t,i);function t(e,r,s,o,n,a){var c=i.call(this,e)||this;return c.onFinalize=n,c.shouldUnsubscribe=a,c._next=r?function(l){try{r(l)}catch(h){e.error(h)}}:i.prototype._next,c._error=o?function(l){try{o(l)}catch(h){e.error(h)}finally{this.unsubscribe()}}:i.prototype._error,c._complete=s?function(){try{s()}catch(l){e.error(l)}finally{this.unsubscribe()}}:i.prototype._complete,c}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;i.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(Yo);var gc=function(i){return i&&typeof i.length=="number"&&typeof i!="function"};function xc(i){return rt(i?.then)}function _c(i){return rt(i[Yi])}function yc(i){return Symbol.asyncIterator&&rt(i?.[Symbol.asyncIterator])}function bc(i){return new TypeError("You provided "+(i!==null&&typeof i=="object"?"an invalid object":"'"+i+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function uE(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var vc=uE();function Tc(i){return rt(i?.[vc])}function Sc(i){return hT(this,arguments,function(){var e,r,s,o;return lc(this,function(n){switch(n.label){case 0:e=i.getReader(),n.label=1;case 1:n.trys.push([1,,9,10]),n.label=2;case 2:return[4,Nr(e.read())];case 3:return r=n.sent(),s=r.value,o=r.done,o?[4,Nr(void 0)]:[3,5];case 4:return[2,n.sent()];case 5:return[4,Nr(s)];case 6:return[4,n.sent()];case 7:return n.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function wc(i){return rt(i?.getReader)}function Ue(i){if(i instanceof J)return i;if(i!=null){if(_c(i))return dE(i);if(gc(i))return fE(i);if(xc(i))return pE(i);if(yc(i))return TT(i);if(Tc(i))return mE(i);if(wc(i))return gE(i)}throw bc(i)}function dE(i){return new J(function(t){var e=i[Yi]();if(rt(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function fE(i){return new J(function(t){for(var e=0;e<i.length&&!t.closed;e++)t.next(i[e]);t.complete()})}function pE(i){return new J(function(t){i.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,fc)})}function mE(i){return new J(function(t){var e,r;try{for(var s=Lr(i),o=s.next();!o.done;o=s.next()){var n=o.value;if(t.next(n),t.closed)return}}catch(a){e={error:a}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}t.complete()})}function TT(i){return new J(function(t){xE(i,t).catch(function(e){return t.error(e)})})}function gE(i){return TT(Sc(i))}function xE(i,t){var e,r,s,o;return lT(this,void 0,void 0,function(){var n,a;return lc(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),e=uT(i),c.label=1;case 1:return[4,e.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(n=r.value,t.next(n),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),s={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(o=e.return)?[4,o.call(e)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function pe(i,t,e,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){e(),s?i.add(this.schedule(null,r)):this.unsubscribe()},r);if(i.add(o),!s)return o}function Pc(i,t){return t===void 0&&(t=0),Fe(function(e,r){e.subscribe(Wr(r,function(s){return pe(r,i,function(){return r.next(s)},t)},function(){return pe(r,i,function(){return r.complete()},t)},function(s){return pe(r,i,function(){return r.error(s)},t)}))})}function Ec(i,t){return t===void 0&&(t=0),Fe(function(e,r){r.add(i.schedule(function(){return e.subscribe(r)},t))})}function ST(i,t){return Ue(i).pipe(Ec(t),Pc(t))}function wT(i,t){return Ue(i).pipe(Ec(t),Pc(t))}function PT(i,t){return new J(function(e){var r=0;return t.schedule(function(){r===i.length?e.complete():(e.next(i[r++]),e.closed||this.schedule())})})}function ET(i,t){return new J(function(e){var r;return pe(e,t,function(){r=i[vc](),pe(e,t,function(){var s,o,n;try{s=r.next(),o=s.value,n=s.done}catch(a){e.error(a);return}n?e.complete():e.next(o)},0,!0)}),function(){return rt(r?.return)&&r.return()}})}function Ac(i,t){if(!i)throw new Error("Iterable cannot be null");return new J(function(e){pe(e,t,function(){var r=i[Symbol.asyncIterator]();pe(e,t,function(){r.next().then(function(s){s.done?e.complete():e.next(s.value)})},0,!0)})})}function AT(i,t){return Ac(Sc(i),t)}function CT(i,t){if(i!=null){if(_c(i))return ST(i,t);if(gc(i))return PT(i,t);if(xc(i))return wT(i,t);if(yc(i))return Ac(i,t);if(Tc(i))return ET(i,t);if(wc(i))return AT(i,t)}throw bc(i)}function Rt(i,t){return t?CT(i,t):Ue(i)}function MT(i,t){return Fe(function(e,r){var s=0;e.subscribe(Wr(r,function(o){r.next(i.call(t,o,s++))}))})}function BT(i,t,e,r,s,o,n,a){var c=[],l=0,h=0,u=!1,d=function(){u&&!c.length&&!l&&t.complete()},f=function(g){return l<r?p(g):c.push(g)},p=function(g){o&&t.next(g),l++;var _=!1;Ue(e(g,h++)).subscribe(Wr(t,function(b){s?.(b),o?f(b):t.next(b)},function(){_=!0},void 0,function(){if(_)try{l--;for(var b=function(){var y=c.shift();n?pe(t,n,function(){return p(y)}):p(y)};c.length&&l<r;)b();d()}catch(y){t.error(y)}}))};return i.subscribe(Wr(t,f,function(){u=!0,d()})),function(){a?.()}}function wt(i,t,e){return e===void 0&&(e=1/0),rt(t)?wt(function(r,s){return MT(function(o,n){return t(r,o,s,n)})(Ue(i(r,s)))},e):(typeof t=="number"&&(e=t),Fe(function(r,s){return BT(r,s,i,e)}))}function Ko(i){return Fe(function(t,e){try{t.subscribe(e)}finally{e.add(i)}})}var _E=i=>i.split("/").pop(),vd=class{name="advancedBufferLoader";priority=2;constructor(t){this.bufferMap=t}test(t){return!0}async load(t){let e=t.startsWith("file:")?t:_E(t),r=this.bufferMap[e];if(!r)throw new Error(`Buffer not found for key: ${e}`);return{data:r.buffer,type:r.type,metadata:null}}async testParse(t){return!0}async parse(t){if(t instanceof M)return t;let e=new Blob([t.data],{type:t.type}),r=await createImageBitmap(e);return new M.from(r)}async unload(t){t.destroy(!0)}},Td=class i extends nc{static rendererName="pixi";_app;_audioStage=new cc;_state={elements:[]};_eventHandler;_plugins;_currentSubscription;_advancedLoader;get canvas(){return this._app.canvas}init=async t=>{let{eventHandler:e,plugins:r,width:s,height:o,backgroundColor:n}=t;for(let c of r)if(c.rendererName!==i.rendererName)throw new Error("Plugin does not match renderer name");this._plugins=r,this._eventHandler=e,this._app=new Za,this._app.audioStage=this._audioStage,await this._app.init({width:s,height:o,backgroundColor:n});let a=new jt;return a.rect(0,0,s,o),a.fill(n||0),this._app.stage.addChild(a),this._app.stage.width=s,this._app.stage.height=o,this._app.ticker.add(this._app.audioStage.tick),this};destroy=()=>{this._app.audioStage.destroy(),this._app.destroy()};_classifyAsset=t=>t?t.startsWith("audio/")?"audio":t.startsWith("font/")||["application/font-woff","application/font-woff2","application/x-font-ttf","application/x-font-otf"].includes(t)?"font":"texture":"texture";loadAssets=async t=>{if(!t)throw new Error("assetBufferMap is required");let e={audio:{},font:{},texture:{}};for(let[s,o]of Object.entries(t)){let n=this._classifyAsset(o.type);e[n][s]=o}await Promise.all(Object.entries(e.audio).map(([s,o])=>Vi.load(s,o.buffer))),await Promise.all(Object.entries(e.font).map(async([s,o])=>{let n=new Blob([o.buffer],{type:o.type}),a=URL.createObjectURL(n),c=new FontFace(s,`url(${a})`);try{await c.load(),document.fonts.add(c),console.log(`Font loaded successfully: ${s}`)}catch(l){console.error(`Failed to load font ${s}:`,l)}finally{URL.revokeObjectURL(a)}})),this._advancedLoader?Object.assign(this._advancedLoader.bufferMap,e.texture):(this._advancedLoader=new vd(e.texture),ve.loader.parsers.length=0,ve.reset(),I.add({name:"advanced-buffer-loader",extension:x.Asset,priority:Et.High,loader:this._advancedLoader}),typeof ve.registerPlugin=="function"&&ve.registerPlugin(this._advancedLoader));let r=Object.keys(e.texture);return Promise.all(r.map(s=>ve.load(s)))};loadAudioAssets=async t=>Promise.all(t.map(async e=>{let s=await(await fetch(e)).arrayBuffer();return Vi.load(e,s)}));updatedBackgroundColor=t=>{this._app.renderer.background.color=t};render=t=>{this._render(this._app,this._app.stage,this._state,t,this._eventHandler),this._state=t};_getRendererByElement=t=>{for(let e of this._plugins)if(e.rendererType===t.type)return e;throw new Error(`No renderer found for element type: ${t.type}`)};_getTransitionByType=t=>{for(let e of this._plugins)if(e.transitionType===t)return e;throw new Error(`No transition found for transition type: ${t}`)};_render=async(t,e,r,s,o)=>{let n=Date.now(),{toAddElements:a,toUpdateElements:c,toDeleteElements:l}=ac(r.elements,s.elements),h=[];for(let u of l){let d=this._getRendererByElement(u);h.push(d.remove(t,{parent:e,element:u,transitions:s.transitions,getRendererByElement:this._getRendererByElement,getTransitionByType:this._getTransitionByType,eventHandler:o}))}for(let u of a){let d=this._getRendererByElement(u);h.push(d.add(t,{parent:e,element:u,getRendererByElement:this._getRendererByElement,transitions:s.transitions,getTransitionByType:this._getTransitionByType,eventHandler:o}))}for(let u of c){let d=this._getRendererByElement(u.next);h.push(d.update(t,{parent:e,prevElement:u.prev,nextElement:u.next,getRendererByElement:this._getRendererByElement,transitions:s.transitions,getTransitionByType:this._getTransitionByType,eventHandler:o}))}t.stage.children.sort((u,d)=>{let f=s.elements.findIndex(g=>g.id===u.label),p=s.elements.findIndex(g=>g.id===d.label);return f-p}),this._currentSubscription&&(this._currentSubscription.closed||this._currentSubscription.unsubscribe()),this._currentSubscription=Rt(h).pipe(wt(u=>u),Ko(()=>{o&&o("completed",{id:s.id,diffTime:Date.now()-n}),this._currentSubscription=void 0})).subscribe({error:u=>{console.error("Error:",u)}})}},RT=Td;var Sd=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="sprite";add=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e,l=o.url?M.from(o.url):M.EMPTY,h,u,d=o.scaleX??1,f=o.scaleY??1;o.hoverUrl&&(h=M.from(o.hoverUrl)),o.clickUrl&&(u=M.from(o.clickUrl));let p=new zt(l);p.label=o.id,(o.eventName||o.hoverUrl||o.clickUrl)&&(p.cursor="pointer",p.eventMode="static"),o.width!==void 0?p.width=o.width*d:p.width*=d,o.height!==void 0?p.height=o.height*f:p.height*=f,o.anchorX!==void 0&&(p.pivot.x=p.width*o.anchorX),o.anchorY!==void 0&&(p.pivot.y=p.height*o.anchorY),o.rotation!==void 0&&(p.rotation=o.rotation*Math.PI/180),o.x!==void 0&&(p.x=o.x),o.y!==void 0&&(p.y=o.y),o.zIndex!==void 0&&(p.zIndex=o.zIndex),o.alpha!==void 0&&(p.alpha=o.alpha),(h||u)&&p.on("pointerup",()=>{p.texture=l}).on("pointerupoutside",()=>{p.texture=l}).on("pointerleave",()=>{p.texture=l}),u&&p.on("pointerdown",()=>{p.texture=u}),h&&p.on("pointerenter",()=>{p.texture=h}),p.on("pointerup",b=>{b.stopPropagation();let y=b.button;y===0?c&&c(o.eventName,o.eventPayload):y===2&&(o.rightClickEventName&&c?c(o.rightClickEventName):t.stage.emit("rightclick",event))});let g=[];for(let b of n)if(b.elementId===o.id&&b.event===Bt.Add){let y=a(b.type);if(!y)throw new Error(`Transition class not found for type ${b.type}`);g.push(y.add(t,p,b))}s.addChild(p);let _=Rt(g).pipe(wt(b=>b)).subscribe({error:b=>{console.error("Error:",b)},complete:()=>r.complete()});return()=>{_.unsubscribe()}});remove=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,c=s.getChildByName(o.id);if(!c)throw new Error(`Sprite with id ${o.id} not found`);let l=[];for(let u of n)if(u.elementId===o.id&&u.event===Bt.Remove){let d=a(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);l.push(d.remove(t,c,u))}let h=Rt(l).pipe(wt(u=>u)).subscribe({error:u=>{console.error("Error:",u)},complete:()=>{r.complete(),c&&c.destroy()}});return()=>{h.unsubscribe(),c&&c.destroy()}});update=(t,{parent:e,prevElement:r,nextElement:s,transitions:o=[],getTransitionByType:n,eventHandler:a})=>new J(c=>{let l=e.getChildByName(r.id);if(!l)throw new Error(`Sprite with id ${r.id} not found`);let h=[];for(let f of o)if(f.elementId===r.id&&f.event===Bt.Update){let p=n(f.type);if(!p)throw new Error(`Transition class not found for type ${f.type}`);h.push(p.add(t,l,f))}if(h.length>0){let f=Rt(h).pipe(wt(p=>p)).subscribe({error:p=>{console.error("Error:",p)},complete:()=>{u(),c.complete()}});return()=>{f.unsubscribe()}}else return d(),c.complete(),()=>{};function u(){if(r.url!==s.url||r.hoverUrl!==s.hoverUrl||r.clickUrl!==s.clickUrl){if(s.url){let _=M.from(s.url);if(l.texture=_,!r.url&&s.url)if(_.baseTexture.valid){let b=s.scaleX??1,y=s.scaleY??1;l.width=(s.width??_.width)*b,l.height=(s.height??_.height)*y}else _.baseTexture.once("loaded",()=>{let b=s.scaleX??1,y=s.scaleY??1;l.width=(s.width??_.width)*b,l.height=(s.height??_.height)*y})}let p=r.hoverUrl||r.clickUrl,g=s.hoverUrl||s.clickUrl;if(!p&&g){let _=l.texture;l.on("pointerup",()=>{l.texture=_}).on("pointerupoutside",()=>{l.texture=_}).on("pointerleave",()=>{l.texture=_})}if(s.hoverUrl){let _=M.from(s.hoverUrl);l.off("pointerenter"),l.on("pointerenter",()=>{l.texture=_})}if(s.clickUrl){let _=M.from(s.clickUrl);l.off("pointerdown"),l.on("pointerdown",()=>{l.texture=_})}}(s.eventName||s.hoverUrl||s.clickUrl)&&(l.cursor="pointer",l.eventMode="static")}function d(){if(r.url!==s.url||r.hoverUrl!==s.hoverUrl||r.clickUrl!==s.clickUrl){if(s.url){let y=M.from(s.url);if(l.texture=y,!r.url&&s.url)if(y.baseTexture.valid){let v=s.scaleX??1,S=s.scaleY??1;l.width=(s.width??y.width)*v,l.height=(s.height??y.height)*S}else y.baseTexture.once("loaded",()=>{let v=s.scaleX??1,S=s.scaleY??1;l.width=(s.width??y.width)*v,l.height=(s.height??y.height)*S})}let _=r.hoverUrl||r.clickUrl,b=s.hoverUrl||s.clickUrl;if(!_&&b){let y=l.texture;l.on("pointerup",()=>{l.texture=y}).on("pointerupoutside",()=>{l.texture=y}).on("pointerleave",()=>{l.texture=y})}if(s.hoverUrl){let y=M.from(s.hoverUrl);l.off("pointerenter"),l.on("pointerenter",()=>{l.texture=y})}if(s.clickUrl){let y=M.from(s.clickUrl);l.off("pointerdown"),l.on("pointerdown",()=>{l.texture=y})}}s.x!==void 0&&s.x!==r.x&&(l.x=s.x),s.y!==void 0&&s.y!==r.y&&(l.y=s.y),s.rotation!==void 0&&s.rotation!==r.rotation&&(l.rotation=s.rotation*Math.PI/180);let p=s.scaleX??1,g=s.scaleY??1;s.width!==void 0&&(s.width!==r.width||p!==(r.scaleX??1))&&(l.width=s.width*p),s.height!==void 0&&(s.height!==r.height||g!==(r.scaleY??1))&&(l.height=s.height*g),s.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=l.width*s.anchorX/p),s.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=l.height*s.anchorY/g),s.zIndex!==void 0&&s.zIndex!==r.zIndex&&(l.zIndex=s.zIndex),s.alpha!==void 0&&s.alpha!==r.alpha&&(l.alpha=s.alpha),(s.eventName||s.hoverUrl||s.clickUrl)&&(l.cursor="pointer",l.eventMode="static")}})};var Cc=i=>new St({wordWrap:i.wordWrap||!0,breakWords:i.breakWords||!1,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),wd=class{static rendererName="pixi";rendererName="pixi";rendererType="text";add=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e,l=Cc(o.style),h=new ur({text:o.text,style:l}),u;o.hoverStyle&&(u=Cc(o.hoverStyle));let d;if(o.clickedStyle&&(d=Cc(o.clickedStyle)),(o.eventName||o.clickedStyle||o.hoverStyle)&&(h.cursor="pointer",h.eventMode="static"),h.label=o.id,o.x!==void 0&&(h.x=o.x),o.y!==void 0&&(h.y=o.y),o.anchorX!==void 0&&(h.anchor.x=o.anchorX),o.anchorY!==void 0&&(h.anchor.y=o.anchorY),o.anchorX!==void 0||o.anchorY!==void 0){let g=h.getLocalBounds();h.hitArea=new z(-g.width*h.anchor.x,-g.height*h.anchor.y,g.width,g.height)}h.on("pointerupoutside",()=>{h.style=l}).on("pointerup",()=>{h.style=l}).on("pointerleave",()=>{h.style=l}),h.on("pointerup",g=>{o.clickSoundUrl&&t.soundStage&&t.soundStage.add({id:`${o.id}-click-${Math.random()}`,url:o.clickSoundUrl,loop:!1,volume:o.clickSoundVolume??50/100}),g.stopPropagation(),c&&c(o.eventName,o.eventPayload)}),d&&h.on("pointerdown",()=>{h.style=d}),u&&h.on("pointerenter",()=>{h.style=u,o.hoverSoundUrl&&t.soundStage&&o.hoverSoundVolume!==void 0&&t.soundStage.add({id:`${o.id}-hover-${Math.random()}`,url:o.hoverSoundUrl,loop:!1,volume:o.hoverSoundVolume/100})});let f=[];for(let g of n)if(g.elementId===o.id&&g.event===Bt.Add){let _=a(g.type);if(!_)throw new Error(`Transition class not found for type ${g.type}`);f.push(_.add(t,h,g))}s.addChild(h);let p=Rt(f).pipe(wt(g=>g)).subscribe({error:g=>{console.error("Error:",g),r.error(g)},complete:()=>r.complete()});return()=>{p.unsubscribe()}});remove=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,c=s.getChildByName(o.id);if(!c){console.warn(`Text with id ${o.id} not found`),r.complete();return}let l=[];for(let u of n)if(u.elementId===o.id&&u.event===Bt.Remove){let d=a(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);l.push(d.remove(t,c,u))}let h=Rt(l).pipe(wt(u=>u)).subscribe({error:u=>{console.error("Error:",u),r.error(u)},complete:()=>{c.destroy(),r.complete()}});return()=>{h.unsubscribe(),c&&c.destroy()}});update=(t,e)=>new J(r=>{let{parent:s,prevElement:o,nextElement:n,transitions:a,getTransitionByType:c,eventHandler:l}=e,h=s.getChildByName(o.id);if(!h){console.warn(`Text with id ${o.id} not found`),r.complete();return}if(JSON.stringify(o)!==JSON.stringify(n)){let u=[this.add(t,{parent:s,element:n,transitions:a,getTransitionByType:c,eventHandler:l}),this.remove(t,{parent:s,element:o,transitions:a,getTransitionByType:c})],d=Rt(u).pipe(wt(f=>f)).subscribe({error:f=>{console.error("Error:",f),r.error(f)},complete:()=>r.complete()});return()=>{d.unsubscribe()}}else o.text!==n.text&&(h.text=n.text),JSON.stringify(o.style)!==JSON.stringify(n.style)&&(h.style=Cc(n?.style)),n.x!==void 0&&(h.x=n.x),n.y!==void 0&&(h.y=n.y),r.complete();return()=>{}})};var Ki=(i,t=!1)=>new St({wordWrap:i.wordWrap||!0,breakWords:t,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),Pd=class{static rendererName="pixi";rendererName="pixi";rendererType="text-revealing";add=async(t,{parent:e,element:r})=>{let s=Ki(r.style,r.text),o=new ur({text:"",style:s});o.label=r.id,o.text_id=r.text;let n=new at;r.x!==void 0&&(n.x=r.x),r.y!==void 0&&(n.y=r.y),n.addChild(o),n.label=r.id,e.addChild(n);let a=r.style.wordWrapWidth||500,c=r.text?[{text:r.text,style:r.style}]:r.segments,l=[],h=[],u=0,d=0,f=0;for(;;){let T=c[0];if(!T){h.length>0&&l.push({lineParts:h,y:d});break}if(d>1e4)break;let P={...T.style,wordWrapWidth:a-u},A=Ct.measureText(T.text,Ki(P));A.lineHeight>f&&(f=A.lineHeight);let R=Ct.measureText("a",Ki(P)),G=Ct.measureText("a a",Ki(P)).width-R.width*2;if(A.lineWidths[0]+u>a){u=0,l.push({lineParts:h,y:d}),d+=f,f=0,h=[];continue}let L=A.lines[0],Y=A.lines.slice(1).join(" "),ht={text:L,style:P,x:u,y:0};if(h.push(ht),Y&&Y.length>0?T.text=Y:c.shift(),!(!L||L.length===0)){if(T.furigana){let Ft=Ct.measureText(T.furigana.text,Ki(T.furigana.style)),N={text:T.furigana.text,style:T.furigana.style,x:u+(A.width-Ft.width)/2,y:-10};h.push(N)}u+=A.lineWidths[0]+G}}l.forEach(T=>{let P=new at;P.y=T.y,P.alpha=0,T.lineParts.forEach(A=>{let R=new ur({text:A.text,style:Ki(A.style),x:A.x,y:A.y});P.addChild(R)}),n.addChild(P)});let p=new jt,g=1e3,_=a/2,b=a/2;p.fill({color:16777215,alpha:1}),p.rect(0,0,_,g);for(let T=0;T<b;T++)p.fill({color:16777215,alpha:1-T/b}),p.rect(_+T,0,_+1,g);let y=t.renderer.generateTexture(p),v=new zt(y);v.x=-1.35*_-b,t.stage.addChild(v);let S=0,w=1;if(l.length!==0){if(r.displaySpeed===100||r.hasEnded){n.children.forEach(T=>{t.stage.removeChild(v),T.mask=null,T.alpha=1});return}await new Promise(T=>{let P=A=>{if(w>n.children.length){T();return}n.getChildAt(w).mask||(n.getChildAt(w).mask=v,n.getChildAt(w).alpha=1),S+=A.deltaMS;let C=(r.displaySpeed||50)/1e3;v.x+=C*S,v.x>=0&&(n.getChildAt(w).mask=null,v.x=-1.35*_-b,w=w+1,S=0,w>=n.children.length&&(n.getChildAt(w-1).mask=null,t.ticker.remove(P),T()))};t.ticker.add(P)})}};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Text with id ${s.id} not found`,{parent:r});return}let c=[];for(let l of o)if(l.elementId===s.id&&l.event===Bt.Remove){let h=n(l.type);if(!h)throw new Error(`Transition class not found for type ${l.type}`);c.push(h.remove(t,a,l))}await Promise.all(c),a.destroy()};update=async(t,e)=>{let{parent:r,prevElement:s,nextElement:o}=e;if(!r.getChildByName(s.id)){console.warn(`Text with id ${s.id} not found`,{parent:r});return}await this.remove(t,{parent:r,element:s}),await this.add(t,{parent:r,element:o})}};var Ed=class{static rendererName="pixi";rendererName="pixi";rendererType="container";add=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,getRendererByElement:c,eventHandler:l}=e,h=structuredClone(o),u=new at;u.label=h.id;let d={};h.x!==void 0&&(typeof h.x=="string"&&h.x.endsWith("%")?u.x=Number(h.x.replace("%",""))*t.screen.width/100:u.x=h.x),h.y!==void 0&&(typeof h.y=="string"&&h.y.endsWith("%")?u.y=Number(h.y.replace("%",""))*t.screen.height/100:u.y=h.y),h.scaleX!==void 0&&(u.scale.x=h.scaleX),h.scaleY!==void 0&&(u.scale.y=h.scaleY),h.zIndex!==void 0&&(u.zIndex=h.zIndex),h.rotation!==void 0&&(u.rotation=h.rotation*Math.PI/180),h.propagateEvents&&(u.eventMode="static",["pointerup","pointerupoutside","pointerleave","pointerdown","pointerenter"].forEach(w=>{u.on(w,T=>{T.stopPropagation();for(let P of u.children)P.emit(w)})}));let f=h.gap||0,p=new jt().roundRect(0,0,h.width||0,h.height||0,1).fill(h.fill?h.fill.color:"transparent"),g=[0,.5,1],_=h.anchorX??0,b=h.anchorY??0;if(!g.includes(_))throw new Error(`Invalid anchorX value: ${_}. Must be 0, 0.5, or 1`);if(!g.includes(b))throw new Error(`Invalid anchorY value: ${b}. Must be 0, 0.5, or 1`);if(h.direction){let w,T;h.direction==="horizontal"?(w=h.children.reduce((A,R)=>A+R.width+f,0),T=h.children.reduce((A,R)=>Math.max(A,R.height||0),0)):h.direction==="vertical"&&(w=h.children.reduce((A,R)=>Math.max(A,R.width||0),0),T=h.children.reduce((A,R)=>A+R.height+f,0));let P={x:_,y:b};h.direction==="horizontal"?this.layoutChildren({element:h,anchor:P,totalWidth:w,totalHeight:T,gap:f,direction:"horizontal",scroll:h.scroll}):h.direction==="vertical"&&this.layoutChildren({element:h,anchor:P,totalWidth:w,totalHeight:T,gap:f,direction:"vertical",scroll:h.scroll}),this.setupScrolling({container:u,element:h,totalHeight:T,totalWidth:w,eventHandler:l,sliderRef:d}),p=this.createContainerGraphic(h,w,T,P)}p.label=`${h.id}-container-background`,u.addChild(p);let y=[];(h.children||[]).forEach(w=>{let T=c(w),P=h.width||0,A=h.height||0,R=_*P,C=b*A,G={zIndex:h.zIndex,...w,x:(w.x||0)+R,y:(w.y||0)+C};y.push(T.add(t,{parent:u,element:G,transitions:n,getTransitionByType:a,getRendererByElement:c,eventHandler:l}))});let v=[];for(let w of n)if(w.elementId===h.id&&w.event===Bt.Add){let T=a(w.type);if(!T)throw new Error(`Transition class not found for type ${w.type}`);v.push(T.add(t,u,w))}s.addChild(u);let S=Rt(y).pipe(wt(w=>w)).subscribe({error:w=>{console.error("Error:",w)},complete:()=>{let{width:w,height:T}=this.getContainerDimensions(h,u),P=_*w,A=b*T;u.pivot.x=P,u.pivot.y=A,r.complete()}});return()=>{S.unsubscribe()}});remove=(t,e)=>(console.log("remove container 11111111111"),new J(r=>{let{parent:s,element:o}=e,n=s.getChildByName(o.id);if(!n){console.warn(`Container with id ${o.id} not found`);return}return n.destroy(),()=>{n.destroy()}}));update=(t,e)=>new J(r=>{let{parent:s,prevElement:o,nextElement:n,getRendererByElement:a,transitions:c=[],getTransitionByType:l,eventHandler:h}=e,u=structuredClone(o),d=structuredClone(n),f=s.getChildByName(u.id);if(!f){console.warn(`Container with id ${u.id} not found`);return}d.x!==void 0&&d.x!==u.x&&(f.x=d.x),d.y!==void 0&&d.y!==u.y&&(f.y=d.y),d.rotation!==void 0&&d.rotation!==u.rotation&&(f.rotation=d.rotation*Math.PI/180);let p=[0,.5,1],g=d.anchorX??0,_=d.anchorY??0;if(!p.includes(g))throw new Error(`Invalid anchorX value: ${g}. Must be 0, 0.5, or 1`);if(!p.includes(_))throw new Error(`Invalid anchorY value: ${_}. Must be 0, 0.5, or 1`);if(d.direction){let w=d.gap||0,T,P;d.direction==="horizontal"?(T=d.children.reduce((C,G)=>C+G.width+w,0),P=d.children.reduce((C,G)=>Math.max(C,G.height||0),0)):d.direction==="vertical"&&(T=d.children.reduce((C,G)=>Math.max(C,G.width||0),0),P=d.children.reduce((C,G)=>C+G.height+w,0));let A={x:g,y:_};d.direction==="horizontal"?this.layoutChildren({element:d,anchor:A,totalWidth:T,totalHeight:P,gap:w,direction:"horizontal",scroll:d.scroll}):d.direction==="vertical"&&this.layoutChildren({element:d,anchor:A,totalWidth:T,totalHeight:P,gap:w,direction:"vertical",scroll:d.scroll});let R=f.children.find(C=>C.label===`${d.id}-container-background`);if(R){R.destroy();let C=this.createContainerGraphic(d,T,P,A);C.label=`${d.id}-container-background`,f.addChildAt(C,0)}u.scroll!==d.scroll&&this.setupScrolling({container:f,element:d,totalHeight:P,totalWidth:T,eventHandler:h,sliderRef:{}})}let b=[],{toAddElements:y,toUpdateElements:v,toDeleteElements:S}=ac(u.children,d.children);for(let w of S){let T=a(w);b.push(T.remove(t,{parent:f,element:w,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}for(let w of y){let T=a(w),P=d.width||0,A=d.height||0,R=g*P,C=_*A,G={...w,x:(w.x||0)+R,y:(w.y||0)+C};b.push(T.add(t,{parent:f,element:G,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}for(let w of v){let T=a(w.next),P=d.width||0,A=d.height||0,R=g*P,C=_*A,G=u.anchorX??0,L=u.anchorY??0,Y=u.width||0,ht=u.height||0,Ft=G*Y,N=L*ht,F={...w.prev,x:(w.prev.x||0)+Ft,y:(w.prev.y||0)+N},oe={...w.next,x:(w.next.x||0)+R,y:(w.next.y||0)+C};b.push(T.update(t,{parent:f,prevElement:F,nextElement:oe,transitions:c,getTransitionByType:l,getRendererByElement:a,eventHandler:h}))}return f.children.sort((w,T)=>{let P=d.children?.findIndex(R=>R.id===w.label),A=d.children?.findIndex(R=>R.id===T.label);return P-A}),this._currentSubscription=Rt(b).pipe(wt(w=>w),Ko(()=>{let{width:w,height:T}=this.getContainerDimensions(d,f),P=g*w,A=_*T;f.pivot.x=P,f.pivot.y=A,r.complete()})).subscribe({error:w=>{r.error(w),console.error("Error:",w)}}),()=>{this._currentSubscription?.unsubscribe()}});layoutChildren({element:t,anchor:e,totalWidth:r,totalHeight:s,gap:o,direction:n,scroll:a}){let c=n==="horizontal",l=c?"x":"y",h=c?"y":"x",u=c?"width":"height",d=c?"height":"width",f=c?r:s,p=c?s:r,g=c?e.x:e.y,_=c?e.y:e.x;if(!a&&t[u]!==void 0&&t[u]<f){let y=0,v=0,S=0,w=0;(t.children||[]).forEach((T,P)=>{y>0&&y+T[u]>t[u]&&(this.alignRowElements(t.children.slice(w,P),l,g,t[u]),y=0,v+=S+o,S=0,w=P),T[l]=y,T[h]=v,y+=T[u]+o,S=Math.max(S,T[d]||0)}),w<t.children.length&&this.alignRowElements(t.children.slice(w),l,g,t[u])}else{if(g===0){let y=0;(t.children||[]).forEach(v=>{v[l]=y,y+=v[u]+o})}else if(g===1){let y=-f;(t.children||[]).forEach(v=>{v[l]=y,y+=v[u]+o})}else if(g===.5){let y=-f/2;(t.children||[]).forEach(v=>{v[l]=y,y+=v[u]+o})}_===0?(t.children||[]).forEach(y=>{y[h]=0}):_===.5?(t.children||[]).forEach(y=>{y[h]=-p/2}):_===1&&(t.children||[]).forEach(y=>{y[h]=-p})}}alignRowElements(t,e,r,s){if(!t.length)return;let o=t.reduce((n,a,c)=>n+a[e==="x"?"width":"height"]+(c>0,0),0);if(r===.5){let a=(s-o)/2;t.forEach(c=>{c[e]=a,a+=c[e==="x"?"width":"height"]+0})}else if(r===1){let a=s-o;t.forEach(c=>{c[e]=a,a+=c[e==="x"?"width":"height"]+0})}}createContainerGraphic(t,e,r,s){let o=new jt().roundRect(0,0,e,r,1).fill(t.fill?t.fill.color:"transparent");return s.x===1&&(o.x-=t.width),s.x===.5&&(o.x-=t.width/2),s.y===1&&(o.y-=t.height),s.y===.5&&(o.y-=t.height/2),o}getContainerDimensions(t,e){let r=t.width||0,s=t.height||0;if(!t.direction&&(!t.width||!t.height)&&e.children&&e.children.length>0){let o=1/0,n=-1/0,a=1/0,c=-1/0;e.children.forEach(l=>{let h=l.x||0,u=l.y||0,d=l.width||0,f=l.height||0;o=Math.min(o,h),n=Math.max(n,h+d),a=Math.min(a,u),c=Math.max(c,u+f)}),t.width||(r=n-o,(isNaN(r)||!isFinite(r))&&(r=0)),t.height||(s=c-a,(isNaN(s)||!isFinite(s))&&(s=0))}return{width:r,height:s}}setupScrolling({container:t,element:e,totalHeight:r,totalWidth:s,eventHandler:o,sliderRef:n}){let a=e.scroll&&e.height&&r>e.height,c=e.scroll&&e.width&&s>e.width;if(a||c){let l=0,h=0,u=-r+e.height,d=-s+e.width,f=new jt().rect(0,0,e.width||s,e.height||r).fill("red");t.mask=f,t.eventMode="static",t.addChild(f),t.on("wheel",p=>{if(a&&p.deltaY!==0&&(l-p.deltaY>0||l-p.deltaY<u||(l-=p.deltaY,t.y-=p.deltaY,f.y+=p.deltaY)),c&&(p.deltaX!==0||p.shiftKey&&p.deltaY!==0)){let g=p.deltaX!==0?p.deltaX:p.deltaY;if(h-g>0||h-g<d)return;h-=g,t.x-=g,f.x+=g}})}}};var yE={linear:i=>i},bE=(i,t,e,r)=>i+(t-i)*yE[r](e);function GT(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s of t){if(r==null)return e;r=r[s]}return r===void 0?e:r}function IT(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s=0;s<t.length-1;s++){let o=t[s];o in r||(r[o]={}),r=r[o]}return r[t[t.length-1]]=e,i}var vE=(i,t)=>{let e=[],r=0,s;i.forEach(({value:n,duration:a,easing:c,relative:l},h)=>{h===0?(s=n,e.push({time:r,value:n,easing:"linear"})):a!==void 0&&c!==void 0&&(r+=a,l?s=s+n:s=n,e.push({time:r,value:s,easing:c}))});let o=0;for(let n=0;n<e.length-1;n++){let{time:a,value:c,easing:l}=e[n],{time:h,value:u}=e[n+1];if(t>=a&&t<=h){let d=(t-a)/(h-a);o=bE(c,u,d,l);break}else t>h&&(o=u)}return o};function TE(i){return Math.max.apply(null,i)}var Ad=class{static rendererName="pixi";rendererName="pixi";transitionType="keyframes";_transition=(t,e,r)=>new J(s=>{let{properties:o}=r,n=Array.isArray(o)?o:Object.entries(o).map(([d,f])=>({...f,property:d})),a=n.map(d=>d.keyframes.reduce((f,p)=>f+p.duration||0,0)),c=TE(a),l=0,h={};n.forEach(d=>{h[d.property]=GT(e,d.property)});let u=d=>{if(l+=d.deltaMS,l>=c){t.ticker.remove(u),s.complete();return}let f={};n.forEach(p=>{let g=[];p.initialValue!==void 0?g=[{value:p.initialValue,duration:0}]:g=[{value:h[p.property],duration:0}],g=g.concat(p.keyframes),IT(f,p.property,vE(g,l))}),n.forEach(p=>{let{property:g}=p;e&&!e.destroyed&&IT(e,g,GT(f,g))})};return t.ticker.add(u),()=>{t.ticker.remove(u),u({deltaMS:c-l})}});add=(t,e,r)=>this._transition(t,e,r);remove=(t,e,r)=>this._transition(t,e,r)};var Cd=class{static rendererName="pixi";rendererName="pixi";rendererType="rect";add=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:c}=e,l=new jt;l.label=o.id,o.x!==void 0&&(l.x=o.x),o.y!==void 0&&(l.y=o.y),o.alpha!==void 0&&(l.alpha=o.alpha),o.scaleX!==void 0&&(l.scale.x=o.scaleX),o.scaleY!==void 0&&(l.scale.y=o.scaleY),o.rotation!==void 0&&(l.rotation=o.rotation*Math.PI/180);let h=o.width,u=o.height;l.rect(0,0,h,u),l.fill(o.fill),o.anchorX!==void 0&&(l.pivot.x=h*o.anchorX),o.anchorY!==void 0&&(l.pivot.y=u*o.anchorY),(o.clickEventName||o.rightClickEventName)&&c&&(l.eventMode="static",l.on("pointerup",p=>{p.button===0?c(o.clickEventName):p.button===2&&c(o.rightClickEventName)})),o.wheelEventName&&c&&(l.eventMode="static",l.on("wheel",p=>{c(o.wheelEventName,{deltaY:p.deltaY})}));let d=[];for(let p of n)if(p.elementId===o.id&&p.event===Bt.Add){let g=a(p.type);if(!g)throw new Error(`Transition class not found for type ${p.type}`);d.push(g.add(t,l,p))}s.addChild(l);let f=Rt(d).pipe(wt(p=>p)).subscribe({error:p=>{console.error("Error:",p)},complete:()=>r.complete()});return()=>{f.unsubscribe()}});remove=(t,e)=>new J(r=>{let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,c=s.getChildByName(o.id);if(!c)throw new Error(`Rect with id ${o.id} not found`);let l=[];for(let u of n)if(u.elementId===o.id&&u.event===Bt.Remove){let d=a(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);l.push(d.remove(t,c,u))}let h=Rt(l).pipe(wt(u=>u)).subscribe({error:u=>{console.error("Error:",u)},complete:()=>{r.complete(),c&&c.destroy()}});return()=>{h.unsubscribe(),c&&c.destroy()}});update=(t,{parent:e,prevElement:r,nextElement:s,transitions:o=[],getTransitionByType:n,eventHandler:a})=>new J(c=>{let l=e.getChildByName(r.id);if(!l)throw new Error(`Rect with id ${r.id} not found`);let h=[];for(let u of o)if(u.elementId===r.id&&u.event===Bt.Update){let d=n(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);h.push(d.add(t,l,u))}if(h.length>0){let u=Rt(h).pipe(wt(d=>d)).subscribe({error:d=>{console.error("Error:",d)},complete:()=>{(r.width!==s.width||r.height!==s.height||r.fill!==s.fill)&&(l.clear(),l.rect(0,0,s.width,s.height),l.fill(s.fill)),r.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=s.width*s.anchorX),r.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=s.height*s.anchorY),c.complete()}});return()=>{u.unsubscribe()}}else return r.x!==void 0&&s.x!==r.x&&(l.x=s.x),r.y!==void 0&&s.y!==r.y&&(l.y=s.y),r.alpha!==void 0&&s.alpha!==r.alpha&&(l.alpha=s.alpha),r.scaleX!==void 0&&s.scaleX!==r.scaleX&&(l.scale.x=s.scaleX),r.scaleY!==void 0&&s.scaleY!==r.scaleY&&(l.scale.y=s.scaleY),r.rotation!==void 0&&s.rotation!==r.rotation&&(l.rotation=s.rotation*Math.PI/180),(r.width!==s.width||r.height!==s.height||r.fill!==s.fill)&&(l.clear(),l.rect(0,0,s.width,s.height),l.fill(s.fill)),r.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=s.width*s.anchorX),r.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=s.height*s.anchorY),c.complete(),()=>{}})};var Md=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="slider";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o,eventHandler:n,ref:a})=>{let{direction:c,idleThumb:l,hoverThumb:h,idleBar:u,hoverBar:d,dragEndEventName:f,dragEventName:p,dragEventPayload:g,initialValue:_}=r,b={horizontal:{axis:"x",size:"width"},vertical:{axis:"y",size:"height"}},y=b[c].axis,v=b[c].size,S=M.from(l),w=M.from(h),T=M.from(u),P=M.from(d),A=new zt({texture:T,anchor:{x:0,y:0}});A.label=r.id;let R=A[v];A.x=r.x||0,A.y=r.y||0;let C=new zt({texture:S,anchor:{x:.5,y:.5}});if(C.y=A.height/2,C.x=A.width/2,C.eventMode="static",C.cursor="pointer",A.eventMode="static",A.cursor="pointer",C.on("pointerdown",Y).on("pointerup",ht).on("pointerupoutside",ht),A.on("pointerdown",G).on("pointerup",L).on("pointerupoutside",L),A.addChild(C),_!==void 0){let F=C[v]/2;C[y]=_/100*(R-C[v])+F}function G(F){C.texture=w,A.texture=P,Ft(F),t.stage.eventMode="static",t.stage.addEventListener("pointermove",Ft)}function L(F){C.texture=S,A.texture=T,Ft(F),t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",Ft)}function Y(F){F.stopPropagation(),C.texture=w,A.texture=P,t.stage.eventMode="static",t.stage.addEventListener("pointermove",Ft)}function ht(F){if(C.texture=S,A.texture=T,t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",Ft),f){let oe=A.toLocal(F.global)[y],q=C[v]/2;C[y]=Math.max(0+q,Math.min(oe,R-q));let ee=Math.floor((C[y]-q)/(R-C[v])*100),De=JSON.stringify(g);n&&n(f,JSON.parse(De.replace('"{{ value }}"',String(ee))))}}function Ft(F){let oe=A.toLocal(F.global)[y],q=C[v]/2;C[y]=Math.max(0+q,Math.min(oe,R-q));let ee=Math.floor((C[y]-q)/(R-C[v])*100);if(p){let De=JSON.stringify(g);n&&n(p,JSON.parse(De.replace('"{{ value }}"',String(ee))))}return ee}a&&(a.current={updateValue:F=>{let oe=C[v]/2;C[y]=F/100*(R-C[v])+oe}});let N=[];for(let F of s)if(F.elementId===r.id&&F.event===Bt.Add){let oe=o(F.type);if(!oe)throw new Error(`Transition class not found for type ${F.type}`);N.push(oe.add(t,A,F))}e.addChild(A),await Promise.all(N)};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Sprite with id ${s.id} not found`);return}let c=[];for(let l of o)if(l.elementId===s.id&&l.event===Bt.Remove){let h=n(l.type);if(!h)throw new Error(`Transition class not found for type ${l.type}`);c.push(h.remove(t,a,l))}await Promise.all(c),a.destroy()};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n,eventHandler:a})=>{if(!e.getChildByName(r.id)){console.warn(`Slider with id ${r.id} not found`,{parent:e});return}JSON.stringify(r)!==JSON.stringify(s)&&await Promise.all([this.remove(t,{parent:e,element:r,transitions:o,getTransitionByType:n,eventHandler:a}),this.add(t,{parent:e,element:s,transitions:o,getTransitionByType:n,eventHandler:a})])}};var Bd=class extends dr{static rendererName="pixi";rendererName="pixi";rendererType="audio";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o})=>{r.delay?setTimeout(()=>{t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})},r.delay):t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})};remove=async(t,e)=>{let{element:r}=e;t.audioStage.remove(r.id)};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n})=>{if(r.url!==s.url||r.volume!==s.volume){let a=t.audioStage.getById(r.id);a&&(a.url=s.url,a.volume=s.volume??1)}}};var Rd=class{constructor(){this.cache=new Map}async load(t){let e=[];for(let[r,s]of Object.entries(t))this.cache.has(r)||e.push([r,s]);e.length>0&&await Promise.all(e.map(async([r,s])=>{let a={buffer:await(await fetch(s.url)).arrayBuffer(),type:s.type};this.cache.set(r,a)}))}getBufferMap(){let t={};for(let[e,r]of this.cache.entries())t[e]=r;return t}clear(){this.cache.clear()}size(){return this.cache.size}has(t){return this.cache.has(t)}},SE=()=>new Rd;var g7=RT;export{Bd as AudioPlugin,Ed as ContainerRendererPlugin,Ad as KeyframeTransitionPlugin,Cd as RectRendererPlugin,Md as SliderRendererPlugin,Sd as SpriteRendererPlugin,wd as TextRendererPlugin,Pd as TextRevealingRendererPlugin,SE as createAssetBufferManager,g7 as default};
|
package/package.json
CHANGED