@omnimedia/omnitool
Version:
open source video processing tools
85 lines (70 loc) • 39.7 kB
JavaScript
import{b as de}from"./chunk-73DDAAII.js";import{d as D,e as $,f as ne,i as ae,j as y,o as ue,q as B,t as Y,u as ce,w as Ae}from"./chunk-TT2DOKKC.js";import{a as C,b as P}from"./chunk-R6QFK4E5.js";import{a as fe}from"./chunk-ASDTIIJ2.js";import{a as he}from"./chunk-UYPHPFEQ.js";import{B as le,D as b,E as V,H as pe,J as me,K as _e,L as xe,M as ge,Q as be,d as _,e as E,k as L,p as F,s as w,t as v,z as S}from"./chunk-ERLCDDYH.js";var W=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(W||{});function T(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function R(r){return r.split("?")[0].split("#")[0]}function Oe(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(r,e,t){return r.replace(new RegExp(Oe(e),"g"),t)}function Le(r,e){let t="",s=0,i=-1,o=0,n=-1;for(let a=0;a<=r.length;++a){if(a<r.length)n=r.charCodeAt(a);else{if(n===47)break;n=47}if(n===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(t.length<2||s!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){let l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",s=0):(t=t.slice(0,l),s=t.length-1-t.lastIndexOf("/")),i=a,o=0;continue}}else if(t.length===2||t.length===1){t="",s=0,i=a,o=0;continue}}e&&(t.length>0?t+="/..":t="..",s=2)}else t.length>0?t+=`/${r.slice(i+1,a)}`:t=r.slice(i+1,a),s=a-i-1;i=a,o=0}else n===46&&o!==-1?++o:o=-1}return t}var k={toPosix(r){return Ge(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){T(r),r=this.toPosix(r);let e=/^file:\/\/\//.exec(r);if(e)return e[0];let t=/^[^/:]+:\/{0,2}/.exec(r);return t?t[0]:""},toAbsolute(r,e,t){if(T(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;let s=R(this.toPosix(e??V.get().getBaseUrl())),i=R(this.toPosix(t??this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?k.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(T(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let e="",t=r.startsWith("/");this.hasProtocol(r)&&(e=this.rootname(r),r=r.slice(e.length));let s=r.endsWith("/");return r=Le(r,!1),r.length>0&&s&&(r+="/"),t?`/${r}`:e+r},isAbsolute(r){return T(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let e;for(let t=0;t<r.length;++t){let s=r[t];if(T(s),s.length>0)if(e===void 0)e=s;else{let i=r[t-1]??"";this.joinExtensions.includes(this.extname(i).toLowerCase())?e+=`/../${s}`:e+=`/${s}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(T(r),r.length===0)return".";r=this.toPosix(r);let e=r.charCodeAt(0),t=e===47,s=-1,i=!0,o=this.getProtocol(r),n=r;r=r.slice(o.length);for(let a=r.length-1;a>=1;--a)if(e=r.charCodeAt(a),e===47){if(!i){s=a;break}}else i=!1;return s===-1?t?"/":this.isUrl(n)?o+r:o:t&&s===1?"//":o+r.slice(0,s)},rootname(r){T(r),r=this.toPosix(r);let e="";if(r.startsWith("/")?e="/":e=this.getProtocol(r),this.isUrl(r)){let t=r.indexOf("/",e.length);t!==-1?e=r.slice(0,t):e=r,e.endsWith("/")||(e+="/")}return e},basename(r,e){T(r),e&&T(e),r=R(this.toPosix(r));let t=0,s=-1,i=!0,o;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e.length===r.length&&e===r)return"";let n=e.length-1,a=-1;for(o=r.length-1;o>=0;--o){let l=r.charCodeAt(o);if(l===47){if(!i){t=o+1;break}}else a===-1&&(i=!1,a=o+1),n>=0&&(l===e.charCodeAt(n)?--n===-1&&(s=o):(n=-1,s=a))}return t===s?s=a:s===-1&&(s=r.length),r.slice(t,s)}for(o=r.length-1;o>=0;--o)if(r.charCodeAt(o)===47){if(!i){t=o+1;break}}else s===-1&&(i=!1,s=o+1);return s===-1?"":r.slice(t,s)},extname(r){T(r),r=R(this.toPosix(r));let e=-1,t=0,s=-1,i=!0,o=0;for(let n=r.length-1;n>=0;--n){let a=r.charCodeAt(n);if(a===47){if(!i){t=n+1;break}continue}s===-1&&(i=!1,s=n+1),a===46?e===-1?e=n:o!==1&&(o=1):e!==-1&&(o=-1)}return e===-1||s===-1||o===0||o===1&&e===s-1&&e===t+1?"":r.slice(e,s)},parse(r){T(r);let e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;r=R(this.toPosix(r));let t=r.charCodeAt(0),s=this.isAbsolute(r),i,o="";e.root=this.rootname(r),s||this.hasProtocol(r)?i=1:i=0;let n=-1,a=0,l=-1,u=!0,d=r.length-1,h=0;for(;d>=i;--d){if(t=r.charCodeAt(d),t===47){if(!u){a=d+1;break}continue}l===-1&&(u=!1,l=d+1),t===46?n===-1?n=d:h!==1&&(h=1):n!==-1&&(h=-1)}return n===-1||l===-1||h===0||h===1&&n===l-1&&n===a+1?l!==-1&&(a===0&&s?e.base=e.name=r.slice(1,l):e.base=e.name=r.slice(a,l)):(a===0&&s?(e.name=r.slice(1,n),e.base=r.slice(1,l)):(e.name=r.slice(a,n),e.base=r.slice(a,l)),e.ext=r.slice(n,l)),e.dir=this.dirname(r),o&&(e.dir=o+e.dir),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function Te(r,e,t,s,i){let o=e[t];for(let n=0;n<o.length;n++){let a=o[n];t<e.length-1?Te(r.replace(s[t],a),e,t+1,s,i):i.push(r.replace(s[t],a))}}function ye(r){let e=/\{(.*?)\}/g,t=r.match(e),s=[];if(t){let i=[];t.forEach(o=>{let n=o.substring(1,o.length-1).split(",");i.push(n)}),Te(r,i,0,t,s)}else s.push(r);return s}var X=r=>!Array.isArray(r);var I=class{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{let t=e;this._defaultSearchParams=Object.keys(t).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(t[s])}`).join("&")}}getAlias(e){let{alias:t,src:s}=e;return C(t||s,o=>typeof o=="string"?o:Array.isArray(o)?o.map(n=>n?.src??n):o?.src?o.src:o,!0)}removeAlias(e,t){this._assetMap[e]&&(t&&t!==this._resolverHash[e]||(delete this._resolverHash[e],delete this._assetMap[e]))}addManifest(e){this._manifest&&F("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){let s=[],i=t;Array.isArray(t)||(i=Object.entries(t).map(([o,n])=>typeof n=="string"||Array.isArray(n)?{alias:o,src:n}:{alias:o,...n})),i.forEach(o=>{let n=o.src,a=o.alias,l;if(typeof a=="string"){let u=this._createBundleAssetId(e,a);s.push(u),l=[a,u]}else{let u=a.map(d=>this._createBundleAssetId(e,d));s.push(...u),l=[...a,...u]}this.add({...o,alias:l,src:n})}),this._bundles[e]=s}add(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e);let s;s=o=>{this.hasKey(o)&&F(`[Resolver] already has key: ${o} overwriting`)},C(t).forEach(o=>{let{src:n}=o,{data:a,format:l,loadParser:u,parser:d}=o,h=C(n).map(p=>typeof p=="string"?ye(p):Array.isArray(p)?p:[p]),c=this.getAlias(o);Array.isArray(c)?c.forEach(s):s(c);let f=[],x=p=>{let g=this._parsers.find(m=>m.test(p));return{src:p,...g?.parse(p)}};h.forEach(p=>{p.forEach(g=>{let m={};if(typeof g!="object"?m=x(g):(a=g.data??a,l=g.format??l,(g.loadParser||g.parser)&&(u=g.loadParser??u,d=g.parser??d),m={...x(g.src),...g}),!c)throw new Error(`[Resolver] alias is undefined for this asset: ${m.src}`);m=this._buildResolvedAsset(m,{aliases:c,data:a,format:l,loadParser:u,parser:d,progressSize:o.progressSize}),f.push(m)})}),c.forEach(p=>{this._assetMap[p]=f})})}resolveBundle(e){let t=X(e);e=C(e);let s={};return e.forEach(i=>{let o=this._bundles[i];if(o){let n=this.resolve(o),a={};for(let l in n){let u=n[l];a[this._extractAssetIdFromBundle(i,l)]=u}s[i]=a}}),t?s[e[0]]:s}resolveUrl(e){let t=this.resolve(e);if(typeof e!="string"){let s={};for(let i in t)s[i]=t[i].src;return s}return t.src}resolve(e){let t=X(e);e=C(e);let s={};return e.forEach(i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let o=this._assetMap[i],n=this._getPreferredOrder(o);n?.priority.forEach(a=>{n.params[a].forEach(l=>{let u=o.filter(d=>d[a]?d[a]===l:!1);u.length&&(o=u)})}),this._resolverHash[i]=o[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});s[i]=this._resolverHash[i]}),t?s[e[0]]:s}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){let s=e[t],i=this._preferredOrder.find(o=>o.params.format.includes(s.format));if(i)return i}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;let t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}_buildResolvedAsset(e,t){let{aliases:s,data:i,loadParser:o,parser:n,format:a,progressSize:l}=t;return(this._basePath||this._rootPath)&&(e.src=k.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=s??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...i||{},...e.data},e.loadParser=o??e.loadParser,e.parser=n??e.parser,e.format=a??e.format??Ve(e.src),l!==void 0&&(e.progressSize=l),e}};I.RETINA_PREFIX=/@([0-9\.]+)x/;function Ve(r){return r.split(".").pop().split("?").shift().split("#").shift()}var Q=(r,e)=>{let t=e.split("?")[1];return t&&(r+=`?${t}`),r};var ve=class M{constructor(e,t){this.linkedSheets=[];let s=e;e?.source instanceof S&&(s={texture:e,data:t});let{texture:i,data:o,cachePrefix:n=""}=s;this.cachePrefix=n,this._texture=i instanceof b?i:null,this.textureSource=i.source,this.textures={},this.animations={},this.data=o;let a=parseFloat(o.meta.scale);a?(this.resolution=a,i.source.resolution=this.resolution):this.resolution=i.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=M.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(e,t=!1){let s=e,i=t?1/0:M.BATCH_SIZE;for(;s-e<i&&s<this._frameKeys.length;){let o=this._frameKeys[s],n=this._frames[o],a=n.frame;if(a){let l=null,u=null,d=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,h=new w(0,0,Math.floor(d.w)/this.resolution,Math.floor(d.h)/this.resolution);n.rotated?l=new w(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):l=new w(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(u=new w(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[o]=new b({source:this.textureSource,frame:l,orig:h,trim:u,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:o.toString()})}s++}}_processAnimations(){let e=this.data.animations||{};for(let t in e){this.animations[t]=[];for(let s=0;s<e[t].length;s++){let i=e[t][s];this.animations[t].push(this.textures[i])}}}_parseComplete(){let e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*M.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*M.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){for(let t in this.textures)this.textures[t].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};ve.BATCH_SIZE=1e3;var Z=ve;var He=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Se(r,e,t){let s={};if(r.forEach(i=>{s[i]=e}),Object.keys(e.textures).forEach(i=>{s[`${e.cachePrefix}${i}`]=e.textures[i]}),!t){let i=k.dirname(r[0]);e.linkedSheets.forEach((o,n)=>{let a=Se([`${i}/${e.data.meta.related_multi_packs[n]}`],o,!0);Object.assign(s,a)})}return s}var Fe={extension:_.Asset,cache:{test:r=>r instanceof Z,getCacheableAssets:(r,e)=>Se(r,e,!1)},resolver:{extension:{type:_.ResolveParser,name:"resolveSpritesheet"},test:r=>{let t=r.split("?")[0].split("."),s=t.pop(),i=t.pop();return s==="json"&&He.includes(i)},parse:r=>{let e=r.split(".");return{resolution:parseFloat(I.RETINA_PREFIX.exec(r)?.[1]??"1"),format:e[e.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:_.LoadParser,priority:W.Normal,name:"spritesheetLoader"},async testParse(r,e){return k.extname(e.src).toLowerCase()===".json"&&!!r.frames},async parse(r,e,t){let{texture:s,imageFilename:i,textureOptions:o,cachePrefix:n}=e?.data??{},a=k.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let l;if(s instanceof b)l=s;else{let h=Q(a+(i??r.meta.image),e.src);l=(await t.load([{src:h,data:o}]))[h]}let u=new Z({texture:l.source,data:r,cachePrefix:n});await u.parse();let d=r?.meta?.related_multi_packs;if(Array.isArray(d)){let h=[];for(let f of d){if(typeof f!="string")continue;let x=a+f;e.data?.ignoreMultiPack||(x=Q(x,e.src),h.push(t.load({src:x,data:{textureOptions:o,ignoreMultiPack:!0}})))}let c=await Promise.all(h);u.linkedSheets=c,c.forEach(f=>{f.linkedSheets=[u].concat(u.linkedSheets.filter(x=>x!==f))})}return u},async unload(r,e,t){await t.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};E.add(Fe);var Ne=new v;function H(r,e,t){let s=Ne;r.measurable=!0,ne(r,t,s),e.addBoundsMask(s),r.measurable=!1}function N(r,e,t){let s=$.get();r.measurable=!0;let i=D.get().identity(),o=Pe(r,t,i);ae(r,s,o),r.measurable=!1,e.addBoundsMask(s),D.return(i),$.return(s)}function Pe(r,e,t){return r?(r!==e&&(Pe(r.parent,e,t),r.updateLocalTransform(),t.append(r.localTransform)),t):(F("Mask bounds, renderable is not inside the root container"),t)}var U=class{constructor(e){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof Y),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(e,t){this.inverse||H(this.mask,e,t)}addLocalBounds(e,t){N(this.mask,e,t)}containsPoint(e,t){let s=this.mask;return t(s,e)}destroy(){this.reset()}static test(e){return e instanceof Y}};U.extension=_.MaskEffect;var O=class{constructor(e){this.priority=0,this.pipe="colorMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e=="number"}};O.extension=_.MaskEffect;var G=class{constructor(e){this.priority=0,this.pipe="stencilMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(e,t){H(this.mask,e,t)}addLocalBounds(e,t){N(this.mask,e,t)}containsPoint(e,t){let s=this.mask;return t(s,e)}destroy(){this.reset()}static test(e){return e instanceof ue}};G.extension=_.MaskEffect;var K;async function ke(){return K??(K=(async()=>{let e=V.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";let t=await new Promise(n=>{let a=document.createElement("video");a.onloadeddata=()=>n(a),a.onerror=()=>n(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!t)return"premultiply-alpha-on-upload";let s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s);let i=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,s,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);let o=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,o),e.deleteFramebuffer(i),e.deleteTexture(s),e.getExtension("WEBGL_lose_context")?.loseContext(),o[0]<=o[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),K}var z=class Ee extends S{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...Ee.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this.alphaMode=e.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),e.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){let e=B.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;let e=this.resource,t=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(t.preload||e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlayThrough),e.addEventListener("error",this._onError,!0)),this.isValid||e.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await ke(),this._load=new Promise((s,i)=>{this.isValid?s(this):(this._resolve=s,this._reject=i,t.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${t.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){let e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){let e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();let e=this.resource;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlayThrough),e.removeEventListener("loadedmetadata",this._onLoadedMetadata),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(B.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(B.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(B.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};z.extension=_.TextureSource;z.defaultOptions={...S.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};z.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};var Ce=z;var J=[];E.handleByList(_.TextureSource,J);function we(r={}){let e=r&&r.resource,t=e?r.resource:r,s=e?r:{resource:r};for(let i=0;i<J.length;i++){let o=J[i];if(o.test(t))return new o(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function ze(r={},e=!1){let t=r&&r.resource,s=t?r.resource:r,i=t?r:{resource:r};if(!e&&P.has(s))return P.get(s);let o=new b({source:we(i)});return o.on("destroy",()=>{P.has(s)&&P.remove(s)}),e||P.set(s,o),o}function je(r,e=!1){return typeof r=="string"?P.get(r):r instanceof S?new b({source:r}):ze(r,e)}b.from=je;S.from=we;E.add(U,O,G,Ce,he,ce,le);var Be=new L;function j(r,e){e.clear();let t=e.matrix;for(let s=0;s<r.length;s++){let i=r[s];if(i.globalDisplayStatus<7)continue;let o=i.renderGroup??i.parentRenderGroup;o?.isCachedAsTexture?e.matrix=Be.copyFrom(o.textureOffsetInverseTransform).append(i.worldTransform):o?._parentCacheAsTextureRenderGroup?e.matrix=Be.copyFrom(o._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform):e.matrix=i.worldTransform,e.addBounds(i.bounds)}return e.matrix=t,e}var qe=new v;function Re(r,e,t,s,i=!1){let o=qe;o.minX=0,o.minY=0,o.maxX=r.width/s|0,o.maxY=r.height/s|0;let n=y.getOptimalTexture(o.width,o.height,s,!1,i);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=e/s,n.frame.height=t/s,n.source.emit("update",n.source),n.updateUvs(),n}function Ie(r){return typeof r.getCanvasFilterString=="function"}var ee=class{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new v,this.cssFilterString=""}},te=class{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){let t=this._pushFilterFrame(),s=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=s,t.container=e.container,t.cssFilterString="",s.every(l=>!l.enabled)){t.skip=!0;return}let i=[],o=1;for(let l of s){if(!l.enabled)continue;if(!Ie(l)){this._warnUnsupportedFilter(l);continue}let u=l.getCanvasFilterString();if(u===null){this._warnUnsupportedFilter(l);continue}u&&i.push(u)}if(i.length===0&&o===1){t.skip=!0;return}t.cssFilterString=i.join(" "),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;let n=this.renderer.canvasContext.activeContext,a=n.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){let l=this.renderer.canvasContext.activeResolution||1;n.save(),n.setTransform(1,0,0,1,0,0),n.beginPath(),n.rect(t.bounds.x*l,t.bounds.y*l,t.bounds.width*l,t.bounds.height*l),n.clip()}else t.useClip=!1;o!==1&&(this._alphaMultiplier*=o),t.cssFilterString&&(n.filter=a!=="none"?`${a} ${t.cssFilterString}`:t.cssFilterString)}pop(){let e=this._popFilterFrame();if(e.skip)return;let t=this._savedStates.pop();if(!t)return;let s=this.renderer.canvasContext.activeContext;e.useClip?s.restore():s.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every(m=>!m.enabled))return e;let s=[],i=1;for(let m of t){if(!m.enabled)continue;if(!Ie(m)){this._warnUnsupportedFilter(m);continue}let A=m.getCanvasFilterString();if(A===null){this._warnUnsupportedFilter(m);continue}A&&s.push(A)}if(s.length===0&&i===1)return e;let o=de.getCanvasSource(e);if(!o)return e;let n=e.frame,a=e.source._resolution??e.source.resolution??1,l=n.width,u=n.height,d=fe.getOptimalCanvasAndContext(l,u,a),{canvas:h,context:c}=d;c.setTransform(1,0,0,1,0,0),c.clearRect(0,0,h.width,h.height),s.length&&(c.filter=s.join(" ")),i!==1&&(c.globalAlpha=i);let f=n.x*a,x=n.y*a,p=l*a,g=u*a;return c.drawImage(o,f,x,p,g,0,0,p,g),c.filter="none",c.globalAlpha=1,Re(h,l,u,a)}_calculateFilterArea(e,t){if(e.renderables?j(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){let i=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;i&&t.applyMatrix(i)}}_warnUnsupportedFilter(e){let t=e?.constructor?.name||"Filter";this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new ee),this._filterStackIndex++,e}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}};te.extension={type:[_.CanvasSystem],name:"filter"};var re=class{constructor(e){this._renderer=e}push(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){e.action==="pushFilter"?this._renderer.filter.push(e):e.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}};re.extension={type:[_.WebGLPipes,_.WebGPUPipes,_.CanvasPipes],name:"filter"};var Me=`in vec2 aPosition;
out vec2 vTextureCoord;
uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
vec4 filterVertexPosition( void )
{
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
vec2 filterTextureCoord( void )
{
return aPosition * (uOutputFrame.zw * uInputSize.zw);
}
void main(void)
{
gl_Position = filterVertexPosition();
vTextureCoord = filterTextureCoord();
}
`;var Ue=`in vec2 vTextureCoord;
out vec4 finalColor;
uniform sampler2D uTexture;
void main() {
finalColor = texture(uTexture, vTextureCoord);
}
`;var se=`struct GlobalFilterUniforms {
uInputSize: vec4<f32>,
uInputPixel: vec4<f32>,
uInputClamp: vec4<f32>,
uOutputFrame: vec4<f32>,
uGlobalFrame: vec4<f32>,
uOutputTexture: vec4<f32>,
};
@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler: sampler;
struct VSOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv: vec2<f32>
};
fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
{
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
return vec4(position, 0.0, 1.0);
}
fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
@vertex
fn mainVertex(
@location(0) aPosition: vec2<f32>,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition)
);
}
@fragment
fn mainFragment(
@location(0) uv: vec2<f32>,
) -> @location(0) vec4<f32> {
return textureSample(uTexture, uSampler, uv);
}
`;var q=class extends Ae{constructor(){let e=me.from({vertex:{source:se,entryPoint:"mainVertex"},fragment:{source:se,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=pe.from({vertex:Me,fragment:Ue,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}};var De=new be({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),ie=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new v,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}},oe=class{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new ge({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new _e({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){let t=this.renderer,s=e.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=s,i.container=e.container,i.outputRenderSurface=t.renderTarget.renderSurface;let o=t.renderTarget.renderTarget.colorTexture.source,n=o.resolution,a=o.antialias;if(s.every(f=>!f.enabled)){i.skip=!0;return}let l=i.bounds;if(this._calculateFilterArea(e,l),this._calculateFilterBounds(i,t.renderTarget.rootViewPort,a,n,1),i.skip)return;let u=this._getPreviousFilterData(),d=this._findFilterResolution(n),h=0,c=0;u&&(h=u.bounds.minX,c=u.bounds.minY),this._calculateGlobalFrame(i,h,c,d,o.width,o.height),this._setupFilterTextures(i,l,t,u)}generateFilteredTexture({texture:e,filters:t}){let s=this._pushFilterData();this._activeFilterData=s,s.skip=!1,s.filters=t;let i=e.source,o=i.resolution,n=i.antialias;if(t.every(f=>!f.enabled))return s.skip=!0,e;let a=s.bounds;if(a.addRect(e.frame),this._calculateFilterBounds(s,a.rectangle,n,o,0),s.skip)return e;let l=o;this._calculateGlobalFrame(s,0,0,l,i.width,i.height),s.outputRenderSurface=y.getOptimalTexture(a.width,a.height,s.resolution,s.antialias),s.backTexture=b.EMPTY,s.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(s,!0);let c=s.outputRenderSurface;return c.source.alphaMode="premultiplied-alpha",c}pop(){let e=this.renderer,t=this._popFilterData();t.skip||(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired&&y.returnTexture(t.backTexture),y.returnTexture(t.inputTexture))}getBackTexture(e,t,s){let i=e.colorTexture.source._resolution,o=y.getOptimalTexture(t.width,t.height,i,!1),n=t.minX,a=t.minY;s&&(n-=s.minX,a-=s.minY),n=Math.floor(n*i),a=Math.floor(a*i);let l=Math.ceil(t.width*i),u=Math.ceil(t.height*i);return this.renderer.renderTarget.copyToTexture(e,o,{x:n,y:a},{width:l,height:u},{x:0,y:0}),o}applyFilter(e,t,s,i){let o=this.renderer,n=this._activeFilterData,l=n.outputRenderSurface===s,u=o.renderTarget.rootRenderTarget.colorTexture.source._resolution,d=this._findFilterResolution(u),h=0,c=0;if(l){let x=this._findPreviousFilterOffset();h=x.x,c=x.y}this._updateFilterUniforms(t,s,n,h,c,d,l,i);let f=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(f,t,o)}calculateSpriteMatrix(e,t){let s=this._activeFilterData,i=e.set(s.inputTexture._source.width,0,0,s.inputTexture._source.height,s.bounds.minX,s.bounds.minY),o=t.worldTransform.copyTo(L.shared),n=t.renderGroup||t.parentRenderGroup;return n&&n.cacheToLocalTransform&&o.prepend(n.cacheToLocalTransform),o.invert(),i.prepend(o),i.scale(1/t.texture.orig.width,1/t.texture.orig.height),i.translate(t.anchor.x,t.anchor.y),i}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new q),this._passthroughFilter}_setupBindGroupsAndRender(e,t,s){if(s.renderPipes.uniformBatch){let i=s.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(i,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,s.encoder.draw({geometry:De,shader:e,state:e._state,topology:"triangle-list"}),s.type===xe.WEBGL&&s.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,s,i){if(e.backTexture=b.EMPTY,e.inputTexture=y.getOptimalTexture(t.width,t.height,e.resolution,e.antialias),e.blendRequired){s.renderTarget.finishRenderPass();let o=s.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(o,t,i?.bounds)}s.renderTarget.bind(e.inputTexture,!0),s.globalUniforms.push({offset:t})}_calculateGlobalFrame(e,t,s,i,o,n){let a=e.globalFrame;a.x=t*i,a.y=s*i,a.width=o*i,a.height=n*i}_updateFilterUniforms(e,t,s,i,o,n,a,l){let u=this._filterGlobalUniforms.uniforms,d=u.uOutputFrame,h=u.uInputSize,c=u.uInputPixel,f=u.uInputClamp,x=u.uGlobalFrame,p=u.uOutputTexture;a?(d[0]=s.bounds.minX-i,d[1]=s.bounds.minY-o):(d[0]=0,d[1]=0),d[2]=e.frame.width,d[3]=e.frame.height,h[0]=e.source.width,h[1]=e.source.height,h[2]=1/h[0],h[3]=1/h[1],c[0]=e.source.pixelWidth,c[1]=e.source.pixelHeight,c[2]=1/c[0],c[3]=1/c[1],f[0]=.5*c[2],f[1]=.5*c[3],f[2]=e.frame.width*h[2]-.5*c[2],f[3]=e.frame.height*h[3]-.5*c[3];let g=this.renderer.renderTarget.rootRenderTarget.colorTexture;x[0]=i*n,x[1]=o*n,x[2]=g.source.width*n,x[3]=g.source.height*n,t instanceof b&&(t.source.resource=null);let m=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind(t,!!l),t instanceof b?(p[0]=t.frame.width,p[1]=t.frame.height):(p[0]=m.width,p[1]=m.height),p[2]=m.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(e){let t=this._filterStackIndex-1;for(;t>0&&this._filterStack[t].skip;)--t;return t>0&&this._filterStack[t].inputTexture?this._filterStack[t].inputTexture.source._resolution:e}_findPreviousFilterOffset(){let e=0,t=0,s=this._filterStackIndex;for(;s>0;){s--;let i=this._filterStack[s];if(!i.skip){e=i.bounds.minX,t=i.bounds.minY;break}}return{x:e,y:t}}_calculateFilterArea(e,t){if(e.renderables?j(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){let i=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;i&&t.applyMatrix(i)}}_applyFiltersToTexture(e,t){let s=e.inputTexture,i=e.bounds,o=e.filters,n=e.firstEnabledIndex,a=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(s.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),n===a)o[n].apply(this,s,e.outputRenderSurface,t);else{let l=e.inputTexture,u=y.getOptimalTexture(i.width,i.height,l.source._resolution,!1),d=u;for(let h=n;h<a;h++){let c=o[h];if(!c.enabled)continue;c.apply(this,l,d,!0);let f=l;l=d,d=f}o[a].apply(this,l,e.outputRenderSurface,t),y.returnTexture(u)}}_calculateFilterBounds(e,t,s,i,o){let n=this.renderer,a=e.bounds,l=e.filters,u=1/0,d=0,h=!0,c=!1,f=!1,x=!0,p=-1,g=-1;for(let m=0;m<l.length;m++){let A=l[m];if(!A.enabled)continue;if(p===-1&&(p=m),g=m,u=Math.min(u,A.resolution==="inherit"?i:A.resolution),d+=A.padding,A.antialias==="off"?h=!1:A.antialias==="inherit"&&h&&(h=s),A.clipToViewport||(x=!1),!!!(A.compatibleRenderers&n.type)){f=!1;break}if(A.blendRequired&&!(n.backBuffer?.useBackBuffer??!0)){F("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),f=!1;break}f=!0,c||(c=A.blendRequired)}if(!f){e.skip=!0;return}if(x&&a.fitBounds(0,t.width/i,0,t.height/i),a.scale(u).ceil().scale(1/u).pad((d|0)*o),!a.isPositive){e.skip=!0;return}e.antialias=h,e.resolution=u,e.blendRequired=c,e.firstEnabledIndex=p,e.lastEnabledIndex=g}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let e,t=this._filterStackIndex-1;for(;t>0&&(t--,e=this._filterStack[t],!!e.skip););return e}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new ie),this._filterStackIndex++,e}};oe.extension={type:[_.WebGLSystem,_.WebGPUSystem],name:"filter"};export{Re as a,te as b,re as c,Me as d,oe as e};
//# sourceMappingURL=chunk-R5JR5S25.js.map