From 214a47bb909a6444d00d950c64d9d2646d2b181a Mon Sep 17 00:00:00 2001 From: ienaga Date: Sun, 26 Dec 2021 10:17:04 +0900 Subject: [PATCH] update 1.4.15 --- next2d.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/next2d.js b/next2d.js index 78836d9b..50e8ba6a 100644 --- a/next2d.js +++ b/next2d.js @@ -1,7 +1,7 @@ /*! * licenses: MIT Licenses. - * version: 1.4.14 + * version: 1.4.15 * author: Toshiyuki Ienaga * copyright: (c) 2020-2021 Toshiyuki Ienaga. */ -"next2d"in window||function(t){"use strict";let e=0,i=0;const s={$PREFIX:"__next2d__"};s.$MAX_VALUE=t.Number.MAX_VALUE,s.$MIN_VALUE=t.Number.MIN_VALUE,s.$HIGH_SAMPLES=4,s.$MEDIUM_SAMPLES=2,s.$LOW_SAMPLES=0,s.$LOAD_START="loadstart",s.$PROGRESS="progress",s.$LOADEND="loadend",s.$TOUCH_START="touchstart",s.$TOUCH_MOVE="touchmove",s.$TOUCH_END="touchend",s.$MOUSE_DOWN="mousedown",s.$MOUSE_MOVE="mousemove",s.$MOUSE_UP="mouseup",s.$MOUSE_WHEEL="wheel",s.$DOUBLE_CLICK="dblclick",s.$MOUSE_LEAVE="mouseleave",s.$KEY_DOWN="keydown",s.$KEY_UP="keyup",s.$SCROLL="scroll",s.$P_TAG=t.document.createElement("p"),s.$COLOR_ARRAY_IDENTITY=new Float32Array([1,1,1,1,0,0,0,0]),s.$COLOR_MATRIX_FILTER=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],s.$soundMixerVolume=1,s.$bezierConverterBuffer=new Array(32),s.$window=t,s.$document=t.document,s.$navigator=t.navigator,s.$userAgent=t.navigator.userAgent,s.$location=t.location,s.$RegExp=t.RegExp,s.$isNaN=t.isNaN,s.$min=Math.min,s.$max=Math.max,s.$sin=Math.sin,s.$cos=Math.cos,s.$tan=Math.tan,s.$sqrt=Math.sqrt,s.$pow=Math.pow,s.$abs=Math.abs,s.$sign=Math.sign,s.$ceil=Math.ceil,s.$atan2=Math.atan2,s.$floor=Math.floor,s.$round=Math.round,s.$SQRT2=Math.SQRT2,s.$PI=Math.PI,s.$Deg2Rad=s.$PI/180,s.$Rad2Deg=180/s.$PI,s.$Array=t.Array,s.$Map=t.Map,s.$Image=t.Image,s.$URL=t.URL,s.$Blob=t.Blob,s.$parseFloat=t.parseFloat,s.$setTimeout=t.setTimeout,s.$encodeURIComponent=t.encodeURIComponent,s.$Infinity=t.Infinity,s.$WebGLTexture=t.WebGLTexture,s.$clearTimeout=t.clearTimeout,s.$setTimeout=t.setTimeout,s.$audioContext=null,s.$CanvasRenderingContext2D=t.CanvasRenderingContext2D,s.$requestAnimationFrame=t.requestAnimationFrame,s.$cancelAnimationFrame=t.cancelAnimationFrame,s.$performance=t.performance,s.$Float32Array=t.Float32Array,s.$Int16Array=t.Int16Array,s.$variables=new Map,s.$loadedImages=new Map,s.$isUpdated=!1,s.$event=null,s.$dropTarget=null,s.$dragRules={lock:!1,position:{x:0,y:0},bounds:null},s.$rgbToLinearTable=new s.$Float32Array(256),s.$rgbIdentityTable=new s.$Float32Array(256);for(let t=0;t<256;++t)s.$rgbToLinearTable[t]=s.$pow(t/255,2.23333333),s.$rgbIdentityTable[t]=t/255;s.$SHORT_INT_MIN=-32768,s.$SHORT_INT_MAX=32767,s.$devicePixelRatio=s.$min(2,t.devicePixelRatio),s.$MATRIX_HIT_ARRAY_IDENTITY=new Float32Array([1,0,0,1,0,0]),s.$MATRIX_ARRAY_IDENTITY=new Float32Array([1,0,0,1,0,0]),s.$MATRIX_ARRAY_RATIO_0_0_RATIO_0_0=new Float32Array([s.$devicePixelRatio,0,0,s.$devicePixelRatio,0,0]),s.$bounds=[],s.$arrays=[],s.$audios=[],s.$maps=[],s.$preObjects=[],s.$matrices=[],s.$colors=[],s.$float32Array4=[],s.$float32Array6=[],s.$float32Array8=[],s.$float32Array9=[],s.$isAndroid=s.$userAgent.indexOf("Android")>-1,s.isiOS=s.$userAgent.indexOf("iPhone")>-1||s.$userAgent.indexOf("iPod")>-1,s.$isTouch=s.$isAndroid||s.isiOS,s.$isChrome=s.$userAgent.indexOf("Chrome")>-1,s.$isFireFox=s.$userAgent.indexOf("Firefox")>-1,s.$isSafari=-1===s.$userAgent.indexOf("Chrome")&&s.$userAgent.indexOf("Safari")>-1,s.$isEdge=s.$userAgent.indexOf("Edge")>-1,s.$isMac=s.$userAgent.indexOf("Mac")>-1,s.$isWindows=!1===s.$isMac,s.$currentLoaderInfo=null;const r=t.document.createElement("canvas");r.width=1,r.height=1,s.$hitContext=r.getContext("2d"),s.$hitContext.globalAlpha=0,s.$hitContext.imageSmoothingEnabled=!1;const n=t.document.createElement("canvas");n.width=1,n.height=1,s.$textContext=n.getContext("2d"),s.$hitContext.globalAlpha=0,s.$hitContext.imageSmoothingEnabled=!1,s.$DIV=null,s.$isArray=t=>s.$Array.isArray(t),s.$getArray=(...t)=>{const e=s.$arrays.pop()||[];return t.length&&e.push.apply(e,t),e},s.$poolArray=t=>{t.length&&(t.length=0),s.$arrays.push(t)},s.$clamp=(t,e,i,r=null)=>{const n=+t;return s.$isNaN(n)&&null!==r?r:s.$min(s.$max(e,s.$isNaN(n)?0:n),i)},s.$multiplicationColor=(t,e)=>s.$getFloat32Array8(t[0]*e[0],t[1]*e[1],t[2]*e[2],t[3]*e[3],t[0]*e[4]+t[4],t[1]*e[5]+t[5],t[2]*e[6]+t[6],t[3]*e[7]+t[7]),s.$multiplicationMatrix=(t,e)=>s.$getFloat32Array6(t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]),s.$getBoundsObject=(t=0,e=0,i=0,r=0)=>{const n=s.$bounds.pop()||{xMin:0,xMax:0,yMin:0,yMax:0};return n.xMin=t,n.xMax=e,n.yMin=i,n.yMax=r,n},s.$poolBoundsObject=t=>{s.$bounds.push(t)},s.$poolMap=t=>{t.size&&t.clear(),s.$maps.push(t)},s.$getMap=()=>s.$maps.pop()||new s.$Map,s.$getFloat32Array4=(t=0,e=0,i=0,r=0)=>{const n=s.$float32Array4.pop()||new s.$window.Float32Array(4);return n[0]=t,n[1]=e,n[2]=i,n[3]=r,n},s.$poolFloat32Array4=t=>{s.$float32Array4.push(t)},s.$getFloat32Array6=(t=0,e=0,i=0,r=0,n=0,a=0)=>{const o=s.$float32Array6.pop()||new s.$window.Float32Array(6);return o[0]=t,o[1]=e,o[2]=i,o[3]=r,o[4]=n,o[5]=a,o},s.$poolFloat32Array6=t=>{s.$float32Array6.push(t)},s.$getFloat32Array8=(t=1,e=1,i=1,r=1,n=0,a=0,o=0,h=0)=>{const l=s.$float32Array8.pop()||new s.$window.Float32Array(8);return l[0]=t,l[1]=e,l[2]=i,l[3]=r,l[4]=n,l[5]=a,l[6]=o,l[7]=h,l},s.$poolFloat32Array8=t=>{s.$float32Array8.push(t)},s.$getFloat32Array9=(t=0,e=0,i=0,r=0,n=0,a=0,o=0,h=0,l=0)=>{const $=s.$float32Array9.pop()||new s.$window.Float32Array(9);return $[0]=t,$[1]=e,$[2]=i,$[3]=r,$[4]=n,$[5]=a,$[6]=o,$[7]=h,$[8]=l,$},s.$poolFloat32Array9=t=>{s.$float32Array9.push(t)},s.$currentPlayer=()=>t.next2d._$player,s.$currentMousePoint=()=>{const t=s.$currentPlayer();let e=s.$window.pageXOffset,i=s.$window.pageYOffset;const r=s.$document.getElementById(t.contentElementId);if(r){const t=r.getBoundingClientRect();e+=t.left,i+=t.top}let n=s.$event.pageX,a=s.$event.pageY;if(s.$isTouch){const t=s.$event.changedTouches[0];n=t.pageX,a=t.pageY}const o=(n-e)/t._$scale|0,h=(a-i)/t._$scale|0;return new m(o,h)},s.$boundsMatrix=(t,e)=>{const i=t.xMax*e[0]+t.yMax*e[2]+e[4],r=t.xMax*e[0]+t.yMin*e[2]+e[4],n=t.xMin*e[0]+t.yMax*e[2]+e[4],a=t.xMin*e[0]+t.yMin*e[2]+e[4],o=t.xMax*e[1]+t.yMax*e[3]+e[5],h=t.xMax*e[1]+t.yMin*e[3]+e[5],l=t.xMin*e[1]+t.yMax*e[3]+e[5],$=t.xMin*e[1]+t.yMin*e[3]+e[5],_=s.$min(s.$MAX_VALUE,i,r,n,a),c=s.$max(-s.$MAX_VALUE,i,r,n,a),u=s.$min(s.$MAX_VALUE,o,h,l,$),d=s.$max(-s.$MAX_VALUE,o,h,l,$);return s.$getBoundsObject(_,c,u,d)},s.$upperPowerOfTwo=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t),s.$getMatrix=(t=1,e=0,i=0,r=1,n=0,a=0)=>{if(!s.$matrices.length)return new f(t,e,i,r,n,a);const o=s.$matrices.pop();return o._$matrix=s.$getFloat32Array6(t,e,i,r,n,a),o},s.$poolMatrix=t=>{s.$poolFloat32Array6(t._$matrix),t._$matrix=null,s.$matrices.push(t)},s.$toBoolean=(t=!1)=>{switch(typeof t){case"boolean":return t;case"function":return!0;case"object":case"string":case"number":return!!t;default:return!1}},s.$getColorTransform=(t=1,e=1,i=1,r=1,n=0,a=0,o=0,h=0)=>{if(!s.$colors.length)return new g(t,e,i,r,n,a,o,h);const l=s.$colors.pop();return l._$colorTransform=s.$getFloat32Array8(t,e,i,r,n,a,o,h),l},s.$poolColorTransform=t=>{s.$poolFloat32Array8(t._$colorTransform),t._$colorTransform=null,s.$colors.push(t)},s.$toColorInt=t=>s.$isNaN(+t)?s.$colorStringToInt(t):+t,s.$colorStringToInt=t=>{s.$hitContext.fillStyle=t;const e=s.$hitContext.fillStyle.substr(1);return s.$hitContext.fillStyle="rgba(0, 0, 0, 1)",0|`0x${e}`},s.$intToR=(t,e,i)=>(t>>16)*(i?e:1)/255,s.$intToG=(t,e,i)=>(t>>8&255)*(i?e:1)/255,s.$intToB=(t,e,i)=>(255&t)*(i?e:1)/255,s.$uintToRGBA=t=>({A:t>>>24,R:(16711680&t)>>16,G:(65280&t)>>8,B:255&t}),s.$intToRGBA=(t,e=1)=>({R:(16711680&t)>>16,G:(65280&t)>>8,B:255&t,A:255*e}),s.$generateColorTransform=(t,e)=>({R:s.$max(0,s.$min(t.R*e[0]+e[4],255)),G:s.$max(0,s.$min(t.G*e[1]+e[5],255)),B:s.$max(0,s.$min(t.B*e[2]+e[6],255)),A:s.$max(0,s.$min(255*t.A*e[3]+e[7],255))/255}),s.$cacheStore=()=>s.$currentPlayer()._$cacheStore,s.$inverseMatrix=t=>{const e=1/(t[0]*t[4]-t[3]*t[1]),i=t[3]*t[7]-t[4]*t[6],r=t[1]*t[6]-t[0]*t[7];return s.$getFloat32Array9(t[4]*e,-t[1]*e,0,-t[3]*e,t[0]*e,0,i*e,r*e,1)},s.$decodeAudioFailed=function(){const t=this._$character?this._$character.buffer:this._$buffer;let e=0;for(;e=t.indexOf(255,e),-1!==e&&224!=(224&t[e+1]);)++e;e>-1&&s.$audioContext.decodeAudioData(t.buffer.subarray(e),s.$decodeAudioSuccess.bind(this))},s.$decodeAudioSuccess=function(t){this._$character?(this._$character.buffer=null,this._$character.audioBuffer=t):(this._$buffer=null,this._$audioBuffer=t)},s.$decodeAudioData=t=>{const e=t._$character?t._$character.buffer:t._$buffer;e&&s.$audioContext.decodeAudioData(e.buffer,s.$decodeAudioSuccess.bind(t),s.$decodeAudioFailed.bind(t))},s.$loadAudioData=()=>{if(s.$audioContext||(s.$audioContext=new s.$window.AudioContext,s.$audioContext.resume()),s.$audioContext){const t=s.$audios.length;for(let e=0;e255===t[0]&&216===t[1]?"jpeg":71===t[0]&&73===t[1]&&70===t[2]?"gif":137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]&&13===t[4]&&10===t[5]&&26===t[6]&&10===t[7]?"png":66===t[0]&&77===t[1]?"bmp":null,s.$resizeTimerId=0,s.$resize=()=>{(0,s.$clearTimeout)(s.$resizeTimerId);const t=s.$setTimeout;s.$resizeTimerId=t(s.$resizeExecute,300)},s.$resizeExecute=()=>{const t=s.$currentPlayer();if(t._$loadStatus===ee.LOAD_END){t._$resize();const e=t._$stage;e.willTrigger(a.RESIZE)&&e.dispatchEvent(new a(a.RESIZE))}},s.$window.addEventListener("resize",s.$resize),s.$resetContext=t=>{const e=t._$contextStyle;switch(e._$fillStyle.constructor){case Ft:case Lt:e._$fillStyle=s.$getFloat32Array4(1,1,1,1);break;default:e._$fillStyle[0]=1,e._$fillStyle[1]=1,e._$fillStyle[2]=1,e._$fillStyle[3]=1}switch(e._$strokeStyle.constructor){case Ft:case Lt:e._$strokeStyle=s.$getFloat32Array4(1,1,1,1);break;default:e._$strokeStyle[0]=1,e._$strokeStyle[1]=1,e._$strokeStyle[2]=1,e._$strokeStyle[3]=1}t._$style=e,t._$globalAlpha=1,t._$globalCompositeOperation=C.NORMAL,t._$imageSmoothingEnabled=!1},s.$getPreObject=()=>s.$preObjects.pop()||{isFilter:!1,isUpdated:null,canApply:null,matrix:null,color:null,basePosition:{x:0,y:0},position:{dx:0,dy:0},baseMatrix:null,baseColor:null,currentAttachment:null,currentMaskBuffer:null,currentMaskBounds:null,cacheCurrentBounds:null,blendMode:null,filters:null,layerWidth:null,layerHeight:null},s.$poolPreObject=t=>{t.isFilter=!1,t.isUpdated=null,t.canApply=null,t.matrix=null,t.color=null,t.baseMatrix=null,t.baseColor=null,t.currentAttachment=null,t.currentMaskBuffer=null,t.currentMaskBounds=null,t.cacheCurrentBounds=null,t.blendMode=null,t.filters=null,t.layerWidth=null,t.layerHeight=null,s.$preObjects.push(t)},s.$cross=(t,e,i,s)=>t*s-i*e,s.$linearGradientXY=t=>{const e=-819.2*t[0]-819.2*t[2]+t[4],i=819.2*t[0]-819.2*t[2]+t[4],r=-819.2*t[0]+819.2*t[2]+t[4],n=-819.2*t[1]-819.2*t[3]+t[5],a=819.2*t[1]-819.2*t[3]+t[5];let o=r-e,h=-819.2*t[1]+819.2*t[3]+t[5]-n;const l=s.$sqrt(o*o+h*h);l?(o/=l,h/=l):(o=0,h=0);const $=(i-e)*o+(a-n)*h;return s.$getArray(e+$*o,n+$*h,i,a)},s.$ajax=(t=null)=>{t||(t={method:"GET"}),"method"in t||(t.method="GET");let e=null;switch(t.method.toUpperCase()){case dt.GET:if(t.data){const e=t.url.split("?");e[1]=1===e.length?t.data.toString():e[1]+"&"+t.data.toString(),t.url=e.join("?")}break;case dt.PUT:case dt.POST:e=t.data?t.data.toString():null}const i=new XMLHttpRequest;if(i.open(t.method,t.url,!0),t.withCredentials&&(i.withCredentials=!0),t.event){const e=Object.keys(t.event),r=e.length;for(let s=0;s{const e=s.$getArray();if(t){const i=t.trim().split("\n"),s=i.length;for(let t=0;t{const e=t.split(".");let i=s.$window;for(let t=0;t{throw new Error("image encoding error")}))}else s.$imageWorkerActive=!1},s.$unzipURL=URL.createObjectURL(new Blob(['/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function(){"use strict";var t=void 0,r=this;function i(i,e){var s,h=i.split("."),n=r;!(h[0]in n)&&n.execScript&&n.execScript("var "+h[0]);for(;h.length&&(s=h.shift());)h.length||e===t?n=n[s]?n[s]:n[s]={}:n[s]=e}var e="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;function s(t){var r,i,s,h,n,a,o,f,l,u,c=t.length,b=0,y=Number.POSITIVE_INFINITY;for(f=0;fb&&(b=t[f]),t[f]>=1;for(u=s<<16|f,l=a;l>>=1){case 0:var i=this.input,h=this.a,o=this.c,f=this.b,l=i.length,u=t,b=o.length,y=t;if(this.d=this.f=0,h+1>=l)throw Error("invalid uncompressed block header: LEN");if(u=i[h++]|i[h++]<<8,h+1>=l)throw Error("invalid uncompressed block header: NLEN");if(u===~(i[h++]|i[h++]<<8))throw Error("invalid uncompressed block header: length verify");if(h+u>i.length)throw Error("input buffer is broken");switch(this.i){case n:for(;f+u>o.length;){if(u-=y=b-f,e)o.set(i.subarray(h,h+y),f),f+=y,h+=y;else for(;y--;)o[f++]=i[h++];this.b=f,o=this.e(),f=this.b}break;case a:for(;f+u>o.length;)o=this.e({p:2});break;default:throw Error("invalid inflate mode")}if(e)o.set(i.subarray(h,h+u),f),f+=u,h+=u;else for(;u--;)o[f++]=i[h++];this.a=h,this.b=f,this.c=o;break;case 1:this.j(E,z);break;case 2:var p,d,g,v,w=S(this,5)+257,A=S(this,5)+1,k=S(this,4)+4,U=new(e?Uint8Array:Array)(c.length),m=t,I=t,x=t,N=t,j=t;for(j=0;j=f?8:255>=f?9:279>=f?7:8;var U,m,E=s(k),I=new(e?Uint8Array:Array)(30);for(U=0,m=I.length;U=a)throw Error("input buffer is broken");e|=h[n++]<>>r,t.d=s-r,t.a=n,i}function T(t,r){for(var i,e,s=t.f,h=t.d,n=t.input,a=t.a,o=n.length,f=r[0],l=r[1];h=o);)s|=n[a++]<>>16)>h)throw Error("invalid code length: "+e);return t.f=s>>e,t.d=h-e,t.a=a,65535&i}function x(t,r){var i,e;if(this.input=t,this.a=0,!r&&(r={})||(r.index&&(this.a=r.index),r.verify&&(this.A=r.verify)),i=t[this.a++],e=t[this.a++],(15&i)!==N)throw Error("unsupported compression method");if(this.method=N,0!=((i<<8)+e)%31)throw Error("invalid fcheck flag:"+((i<<8)+e)%31);if(32&e)throw Error("fdict flag is not supported");this.q=new h(t,{index:this.a,bufferSize:r.bufferSize,bufferType:r.bufferType,resize:r.resize})}h.prototype.j=function(t,r){var i=this.c,e=this.b;this.o=t;for(var s,h,n,a,o=i.length-258;256!==(s=T(this,t));)if(256>s)e>=o&&(this.b=e,i=this.e(),e=this.b),i[e++]=s;else for(a=y[h=s-257],0=o&&(this.b=e,i=this.e(),e=this.b);a--;)i[e]=i[e++-n];for(;8<=this.d;)this.d-=8,this.a--;this.b=e},h.prototype.w=function(t,r){var i=this.c,e=this.b;this.o=t;for(var s,h,n,a,o=i.length;256!==(s=T(this,t));)if(256>s)e>=o&&(o=(i=this.e()).length),i[e++]=s;else for(a=y[h=s-257],0o&&(o=(i=this.e()).length);a--;)i[e]=i[e++-n];for(;8<=this.d;)this.d-=8,this.a--;this.b=e},h.prototype.e=function(){var t,r,i=new(e?Uint8Array:Array)(this.b-32768),s=this.b-32768,h=this.c;if(e)i.set(h.subarray(32768,i.length));else for(t=0,r=i.length;tt;++t)h[t]=h[s+t];return this.b=32768,h},h.prototype.z=function(t){var r,i,s,h=this.input.length/this.a+1|0,n=this.input,a=this.c;return t&&("number"==typeof t.p&&(h=t.p),"number"==typeof t.u&&(h+=t.u)),2>h?i=(s=(n.length-this.a)/this.o[2]/2*258|0)r&&(this.c.length=r),t=this.c),this.buffer=t},x.prototype.k=function(){var t,r,i=this.input;if(t=this.q.k(),this.a=this.q.a,this.A){r=(i[this.a++]<<24|i[this.a++]<<16|i[this.a++]<<8|i[this.a++])>>>0;var e=t;if("string"==typeof e){var s,h,n=e.split("");for(s=0,h=n.length;s>>0;e=n}for(var a,o=1,f=0,l=e.length,u=0;0>>0)throw Error("invalid adler-32 checksum")}return t};var N=8;i("Zlib.Inflate",x),i("Zlib.Inflate.prototype.decompress",x.prototype.k);var j,C,O,L,Z={ADAPTIVE:o.s,BLOCK:o.t};if(Object.keys)j=Object.keys(Z);else for(C in j=[],O=0,Z)j[O++]=C;for(O=0,L=j.length;O{t.display={BitmapData:A,BitmapDataChannel:M,BlendMode:C,CapsStyle:S,DisplayObject:b,DisplayObjectContainer:v,FrameLabel:R,GradientType:w,Graphics:O,GraphicsGradientFill:B,InteractiveObject:T,InterpolationMethod:F,JointStyle:L,Loader:P,LoaderInfo:D,MovieClip:E,Shape:N,SpreadMethod:U,Sprite:y,Stage:k},t.events={Event:a,EventDispatcher:o,EventPhase:h,FocusEvent:l,HTTPStatusEvent:$,IOErrorEvent:_,MouseEvent:c,ProgressEvent:u,VideoEvent:d},t.filters={BevelFilter:V,BitmapFilterQuality:Y,BitmapFilterType:H,BlurFilter:z,ColorMatrixFilter:W,ConvolutionFilter:q,DisplacementMapFilter:K,DisplacementMapFilterMode:j,DropShadowFilter:Q,GlowFilter:J,GradientBevelFilter:Z,GradientGlowFilter:tt},t.geom={ColorTransform:g,Matrix:f,Point:m,Rectangle:p,Transform:x},t.media={Sound:ot,SoundMixer:ht,SoundTransform:lt,Video:$t},t.net={URLLoaderDataFormat:_t,URLRequest:ct,URLRequestHeader:ut,URLRequestMethod:dt},t.text={TextField:st,TextFieldAutoSize:it,TextFieldType:rt,TextFormat:nt,TextFormatAlign:et,TextFormatVerticalAlign:at},t.ui={Easing:gt,Job:ft,Tween:mt}};class a{constructor(t,e=!1,i=!1){this._$type=`${t}`,this._$bubbles=!!e,this._$cancelable=!!i,this._$target=null,this._$currentTarget=null,this._$eventPhase=h.AT_TARGET,this._$listener=null,this._$stopImmediatePropagation=!1,this._$stopPropagation=!1,this._$preventDefault=!1}static toString(){return"[class Event]"}static get namespace(){return"next2d.events.Event"}toString(){return this.formatToString("Event","type","bubbles","cancelable","eventPhase")}get namespace(){return"next2d.events.Event"}static get ACTIVATE(){return"activate"}static get ADDED(){return"added"}static get ADDED_TO_STAGE(){return"addedToStage"}static get CHANGE(){return"change"}static get COMPLETE(){return"complete"}static get DEACTIVATE(){return"deactivate"}static get ENTER_FRAME(){return"enterFrame"}static get EXIT_FRAME(){return"exitFrame"}static get FRAME_CONSTRUCTED(){return"frameConstructed"}static get FRAME_LABEL(){return"frameLabel"}static get INIT(){return"init"}static get MOUSE_LEAVE(){return"mouseLeave"}static get REMOVED(){return"removed"}static get REMOVED_FROM_STAGE(){return"removedFromStage"}static get RENDER(){return"render"}static get RESIZE(){return"resize"}static get SCROLL(){return"scroll"}static get STOP(){return"stop"}static get SOUND_COMPLETE(){return"soundComplete"}static get UPDATE(){return"update"}get bubbles(){return this._$bubbles}get cancelable(){return this._$cancelable}get currentTarget(){return this._$currentTarget}get eventPhase(){return this._$eventPhase}get listener(){return this._$listener}get target(){return this._$target?this._$target:this._$currentTarget}get type(){return this._$type}formatToString(){let t=`[${arguments[0]}`;for(let e=1;ee.priority:return-1;case t.prioritye.priority:return-1;case t.prioritye.priority:return-1;case t.priorityt&&this.bottom>e}containsPoint(t){return this.x<=t.x&&this.y<=t.y&&this.right>t.x&&this.bottom>t.y}containsRect(t){return this.x<=t.x&&this.y<=t.y&&this.right>=t.right&&this.bottom>=t.bottom}copyFrom(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}inflate(t,e){this.x=this.x-+t,this.width=this.width+2*+t,this.y=this.y-+e,this.height=this.height+2*+e}inflatePoint(t){this.x=this.x-t.x,this.width=this.width+2*t.x,this.y=this.y-t.y,this.height=this.height+2*t.y}intersection(t){const e=s.$max(this.x,t.x),i=s.$max(this.y,t.y),r=s.$min(this.right,t.right)-e,n=s.$min(this.bottom,t.bottom)-i;return r>0&&n>0?new p(e,i,r,n):new p(0,0,0,0)}intersects(t){const e=s.$max(this.x,t.x),i=s.$max(this.y,t.y),r=s.$min(this.right,t.right),n=s.$min(this.bottom,t.bottom);return r-e>0&&n-i>0}isEmpty(){return this.width<=0||this.height<=0}offset(t,e){this.x+=t,this.y+=e}offsetPoint(t){this.x+=t.x,this.y+=t.y}setEmpty(){this._$x=0,this._$y=0,this._$width=0,this._$height=0}setTo(t,e,i,s){this.x=t,this.y=e,this.width=i,this.height=s}union(t){return this.isEmpty()?t.clone():t.isEmpty()?this.clone():new p(s.$min(this.x,t.x),s.$min(this.y,t.y),s.$max(this.right-t.left,t.right-this.left),s.$max(this.bottom-t.top,t.bottom-this.top))}}class x{constructor(t){if(!(t instanceof b))throw new Error("Transform params is DisplayObject only.");this._$displayObject=t,this._$matrix=null,this._$colorTransform=null,this._$blendMode=null,this._$filters=null}static toString(){return"[class Transform]"}static get namespace(){return"next2d.geom.Transform"}toString(){return"[object Transform]"}get namespace(){return"next2d.geom.Transform"}get colorTransform(){if(this._$colorTransform)return this._$colorTransform._$clone();const t=this._$displayObject._$getPlaceObject();if(t){const e=t.colorTransform,i=new g;return i._$colorTransform=s.$getFloat32Array8(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]),i}return this._$transform(),this._$colorTransform._$clone()}set colorTransform(t){t instanceof g&&this._$transform(null,t._$colorTransform)}get concatenatedColorTransform(){let t=this._$rawColorTransform(),e=this._$displayObject._$parent;for(;e;)t=s.$multiplicationColor(e._$transform._$rawColorTransform(),t),e=e._$parent;return s.$getColorTransform(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7])}get matrix(){if(this._$matrix)return this._$matrix._$clone();const t=this._$displayObject._$getPlaceObject();if(t){const e=t.matrix;return s.$getMatrix(e[0],e[1],e[2],e[3],e[4],e[5])}return this._$transform(),this._$matrix._$clone()}set matrix(t){t instanceof f&&this._$transform(t._$matrix,null)}get concatenatedMatrix(){let t=this._$rawMatrix(),e=this._$displayObject._$parent;for(;e;)t=s.$multiplicationMatrix(e._$transform._$rawMatrix(),t),e=e._$parent;return s.$getMatrix(t[0],t[1],t[2],t[3],t[4],t[5])}pixelBounds(){const t=new p(0,0,0,0);if(!this._$displayObject)return t;const e=this._$displayObject._$getBounds(null);return t._$x=e.xMin,t._$y=e.yMin,t._$width=+s.$abs(e.xMax-e.xMin),t._$height=+s.$abs(e.yMax-e.yMin),s.$poolBoundsObject(e),t}_$rawMatrix(){if(null!==this._$matrix)return this._$matrix._$matrix;const t=this._$displayObject._$getPlaceObject();return t?t.matrix:s.$MATRIX_ARRAY_IDENTITY}_$rawColorTransform(){if(null!==this._$colorTransform)return this._$colorTransform._$colorTransform;const t=this._$displayObject._$getPlaceObject();return t?t.colorTransform:s.$COLOR_ARRAY_IDENTITY}_$transform(t=null,e=null,i=null,s=""){const r=this._$displayObject._$getPlaceObject();this._$setMatrix(t,r),this._$setColorTransform(e,r),this._$setFilters(i,r),this._$setBlendMode(s,r)}_$setMatrix(t=null,e=null){if((t||e)&&(this._$displayObject._$doChanged(),s.$isUpdated=!0),this._$matrix||(this._$matrix=s.$getMatrix(1,0,0,1,0,0),!t&&e&&(t=e.matrix)),t){const e=this._$matrix._$matrix;e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]}}_$setColorTransform(t=null,e=null){if((t||e)&&(this._$displayObject._$doChanged(),s.$isUpdated=!0),this._$colorTransform||(this._$colorTransform=s.$getColorTransform(1,1,1,1,0,0,0,0),!t&&e&&(t=e.colorTransform)),t){const e=this._$colorTransform._$colorTransform;e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7]}}_$setFilters(t=null,e=null){if(s.$isArray(t))return this._$filters&&s.$poolArray(this._$filters),this._$filters=t.slice(0),this._$displayObject._$doChanged(),void(s.$isUpdated=!0);if(!this._$filters)if(e){if(e.filters)this._$filters=e.filters.slice(0);else if(e.surfaceFilterList){const t=s.$getArray(),i=e.surfaceFilterList.length;for(let s=0;s-1){const e=this.rotation?s.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()):this._$getBounds(null),i=s.$abs(e.yMax-e.yMin);switch(s.$poolBoundsObject(e),i){case 0:case s.$Infinity:case-s.$Infinity:this.scaleY=0;break;default:this.scaleY=t/i}}}get loaderInfo(){return this._$loaderInfo}get mask(){return this._$mask}set mask(t){t!==this._$mask&&(this._$mask&&(this._$mask._$isMask=!1,this._$mask=null),t instanceof b&&(t._$isMask=!0,this._$mask=t),this._$doChanged())}get mouseX(){return s.$event?this.globalToLocal(s.$currentMousePoint()).x:0}get mouseY(){return s.$event?this.globalToLocal(s.$currentMousePoint()).y:0}get name(){return this._$name?this._$name:`instance${this._$instanceId}`}set name(t){this._$name=`${t}`;const e=this._$parent;if(e&&e._$names){e._$names.clear();const t=e._$getChildren(),i=t.length;for(let s=0;st[0]?-1*e:e}set scaleX(t){const e=this._$transform,i=e.matrix;if(0===i.b||s.$isNaN(i.b))i.a=t;else{const e=s.$atan2(i.b,i.a);i.b=t*s.$sin(e),i.a=1===i.b||-1===i.b?0:t*s.$cos(e)}e.matrix=i,s.$poolMatrix(i)}get scaleY(){const t=this._$transform._$rawMatrix(),e=s.$sqrt(t[2]*t[2]+t[3]*t[3]);return 0>t[3]?-1*e:e}set scaleY(t){const e=this._$transform,i=e.matrix;if(0===i.c||s.$isNaN(i.c))i.d=t;else{const e=s.$atan2(-i.c,i.d);i.c=-t*s.$sin(e),i.d=1===i.c||-1===i.c?0:t*s.$cos(e)}e.matrix=i,s.$poolMatrix(i)}get stage(){if(this._$stage)return this._$stage;const t=this._$parent;return t?t instanceof k?t:t._$stage:null}get transform(){return this._$transform}set transform(t){t instanceof x&&(this._$transform=t)}get visible(){return this._$visible}set visible(t){t=!!t,this._$visible!==t&&(this._$doChanged(),s.$isUpdated=!0),this._$visible=!!t}get width(){const t=s.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()),e=s.$abs(t.xMax-t.xMin);switch(s.$poolBoundsObject(t),!0){case 0===e:case e===s.$Infinity:case e===-s.$Infinity:return 0;default:return e}}set width(t){if(t=+t,!s.$isNaN(t)&&t>-1){const e=this.rotation?s.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()):this._$getBounds(null),i=s.$abs(e.xMax-e.xMin);switch(s.$poolBoundsObject(e),!0){case 0===i:case i===s.$Infinity:case i===-s.$Infinity:this.scaleX=0;break;default:this.scaleX=t/i}}}get x(){return this._$transform._$rawMatrix()[4]}set x(t){const e=this._$transform,i=this._$transform.matrix;i.tx=t,e.matrix=i,s.$poolMatrix(i)}get y(){return this._$transform._$rawMatrix()[5]}set y(t){const e=this._$transform,i=e.matrix;i.ty=t,e.matrix=i,s.$poolMatrix(i)}getBounds(t=null){const e=this._$getBounds(null),i=this._$transform.concatenatedMatrix,r=s.$boundsMatrix(e,i._$matrix);s.$poolMatrix(i),s.$poolBoundsObject(e);const n=s.$getBoundsObject(r.xMin,r.xMax,r.yMin,r.yMax);s.$poolBoundsObject(r),t||(t=this);const a=t._$transform.concatenatedMatrix;a.invert();const o=s.$boundsMatrix(n,a._$matrix),h=o.xMin,l=o.yMin,$=o.xMax,_=o.yMax;return s.$poolBoundsObject(n),s.$poolBoundsObject(o),s.$poolMatrix(a),new p(h,l,s.$abs($-h),s.$abs(_-l))}globalToLocal(t){const e=this._$transform.concatenatedMatrix;e.invert();const i=new m(t.x*e.a+t.y*e.c+e.tx,t.x*e.b+t.y*e.d+e.ty);return s.$poolMatrix(e),i}hitTestObject(t){const e=this._$getBounds(null),i=this._$transform.concatenatedMatrix,r=s.$boundsMatrix(e,i._$matrix);s.$poolMatrix(i),s.$poolBoundsObject(e);const n=t._$getBounds(null),a=t._$transform.concatenatedMatrix,o=s.$boundsMatrix(n,a._$matrix);s.$poolMatrix(a),s.$poolBoundsObject(n);const h=s.$max(r.xMin,o.xMin),l=s.$max(r.yMin,o.yMin),$=s.$min(r.xMax,o.xMax),_=s.$min(r.yMax,o.yMax);return s.$poolBoundsObject(r),s.$poolBoundsObject(o),$-h>=0&&_-l>=0}hitTestPoint(t,e,i=!1){if(i){let i=s.$MATRIX_ARRAY_IDENTITY,r=this._$parent;for(;r;)i=s.$multiplicationMatrix(r._$transform._$rawMatrix(),i),r=r._$parent;s.$hitContext.setTransform(1,0,0,1,0,0),s.$hitContext.beginPath();const n=this._$hit(s.$hitContext,i,{x:t,y:e},!0);return s.$poolFloat32Array6(i),n}const r=this._$getBounds(null),n=s.$boundsMatrix(r,this._$transform._$rawMatrix()),a=n.xMin,o=n.yMin,h=n.xMax-n.xMin,l=n.yMax-n.yMin,$=this._$parent?this._$parent.globalToLocal(new m(t,e)):new m(t,e);return s.$poolBoundsObject(n),s.$poolBoundsObject(r),new p(a,o,h,l).containsPoint($)}localToGlobal(t){const e=this._$transform.concatenatedMatrix,i=new m(t.x*e.a+t.y*e.c+e.tx,t.x*e.b+t.y*e.d+e.ty);return s.$poolMatrix(e),i}getLocalVariable(t){return this._$variables?this._$variables.has(t)?this._$variables.get(t):void 0:null}setLocalVariable(t,e){this._$variables||(this._$variables=s.$getMap()),this._$variables.set(t,e)}hasLocalVariable(t){return!!this._$variables&&this._$variables.has(t)}deleteLocalVariable(t){this._$variables&&this._$variables.has(t)&&(this._$variables.delete(t),this._$variables.size||(s.$poolMap(this._$variables),this._$variables=null))}getGlobalVariable(t){return s.$variables.has(t)?s.$variables.get(t):null}setGlobalVariable(t,e){s.$variables.set(t,e)}hasGlobalVariable(t){return s.$variables.has(t)}deleteGlobalVariable(t){s.$variables.has(t)&&s.$variables.delete(t)}clearGlobalVariable(){return s.$variables.clear()}_$getPlaceObject(){if(!this._$placeObject){const t=this._$placeId;if(null===t)return null;const e=this._$parent;if(!e)return null;const i=e._$placeMap;if(!i||!i.length)return null;const s=i[e._$currentFrame||1];if(!s)return null;this._$placeObject=e._$placeObjects[s[t]]}return this._$placeObject}_$sync(){const t=this.contentName;let e=null;if(next2d.fw.response.has(t)&&(e=next2d.fw.response.get(t)._$loaderInfo),!e&&next2d.fw.cache.has(t)&&(e=next2d.fw.cache.get(t)._$loaderInfo),e||(e=this._$loaderInfo||s.$currentLoaderInfo),!e)return null;const i=e._$data.symbols.get(this.namespace),r=e._$data.characters[i];return this._$characterId=i,this._$loaderInfo=e,r}_$build(t,e){const i=e._$loaderInfo;return this._$parent=e,this._$root=e._$root,this._$stage=e._$stage,this._$loaderInfo=i,this._$characterId=0|t.characterId,this._$clipDepth=0|t.clipDepth,this._$startFrame=0|t.startFrame,this._$endFrame=0|t.endFrame,this._$name=t.name||"",i._$data.characters[t.characterId]}_$isUpdated(){return this._$updated}_$updateState(){this._$isNext=!0;let t=this._$parent;t&&t._$updateState()}_$doChanged(){this._$isNext=!0,this._$updated=!0;let t=this._$parent;t&&t._$doChanged()}_$getLayerBounds(t=null){const e=this._$getBounds(t);if(!t)return e;const i=this._$filters||this.filters,r=i.length;if(!r)return e;let n=new p(e.xMin,e.yMin,e.xMax-e.xMin,e.yMax-e.yMin);s.$poolBoundsObject(e);for(let t=0;t0||h!==C.NORMAL){const e=this._$getBounds(null),l=s.$boundsMatrix(e,n),$=+l.xMax,_=+l.xMin,c=+l.yMax,u=+l.yMin;s.$poolBoundsObject(e),s.$poolBoundsObject(l);const d=s.$abs($-_),g=s.$abs(c-u);if(0>=d||0>=g)return!1;if(0>_+d||0>u+g)return!1;const f=t.frameBuffer.currentAttachment;if(_>f.width||u>f.height)return!1;a.basePosition.x=r[4],a.basePosition.y=r[5];let m=this._$getLayerBounds(null);const p=s.$boundsMatrix(m,n);let x=s.$abs(p.xMax-p.xMin),b=s.$abs(p.yMax-p.yMin);s.$poolBoundsObject(p),x===d&&b===g&&(s.$poolBoundsObject(m),m=null);let T=n[4]-s.$floor(_),v=n[5]-s.$floor(u),y=null;if(m){const t=s.$getFloat32Array6(n[0],n[1],n[2],n[3],0,0);y=s.$boundsMatrix(m,t),s.$poolBoundsObject(m),s.$poolFloat32Array6(t),T+=-s.$floor(y.xMin)-T,v+=-s.$floor(y.yMin)-v}let E=s.$floor(_),A=s.$floor(u),M=_,C=u;if(y&&(E-=-s.$floor(y.xMin)-(n[4]-E),A-=-s.$floor(y.yMin)-(n[5]-A),M-=-y.xMin-(n[4]-M),C-=-y.yMin-(n[5]-C),s.$poolBoundsObject(y)),a.position.dx=E>0?E:0,a.position.dy=A>0?A:0,x+M>f.texture.width&&(x-=x-f.texture.width+M),b+C>f.texture.height&&(b-=b-f.texture.height+C),0>E&&(T+=E,x+=M),0>A&&(v+=A,b+=C),0>=x||0>=b||!x||!b)return s.$poolPreObject(a),!1;t._$startLayer(s.$getBoundsObject(M,0,C,0)),a.canApply=this._$canApply(o);let S=this._$isFilterUpdated(x,b,n,i,o,a.canApply,a.basePosition.x,a.basePosition.y);const R=t._$cacheCurrentBuffer;t._$cacheCurrentBuffer=null;const w=t._$cacheCurrentBounds,O=s.$getBoundsObject(w.x,w.w,w.y,w.h);S&&(this._$buffer=t.frameBuffer.createCacheAttachment(s.$ceil(x),s.$ceil(b),!1),t._$bind(this._$buffer)),a.isFilter=!0,a.isUpdated=S,a.color=s.$getFloat32Array8(),a.baseMatrix=n,a.baseColor=i,a.currentAttachment=f,a.currentMaskBuffer=R,a.currentMaskBounds=O,a.filters=o,a.blendMode=h,a.layerWidth=x,a.layerHeight=b,a.matrix=s.$getFloat32Array6(n[0],n[1],n[2],n[3],T,v)}return a}_$postDraw(t,e,i,r){const n=[this._$instanceId,"f"];let a=null;if(this._$buffer){a=t.frameBuffer.getTextureFromCurrentAttachment();const e=s.$cacheStore().get(n);e&&(s.$cacheStore().set(n,null),t.frameBuffer.releaseTexture(e))}else a=s.$cacheStore().get(n);r.canApply||(a._$offsetX=0,a._$offsetY=0);let o=a._$offsetX,h=a._$offsetY;if(r.isUpdated&&r.canApply){let i=s.$cacheStore().get(n);i&&(s.$cacheStore().set(n,null),i.layerWidth=0,i.layerHeight=0,i._$offsetX=0,i._$offsetY=0,i.matrix=null,i.colorTransform=null,t.frameBuffer.releaseTexture(i),i=null);const l=r.filters.length;if(l){t._$offsetX=0,t._$offsetY=0;for(let i=0;it._$names.size&&t._$names.has(e)?t._$names.get(e):t[e]})}static toString(){return"[class DisplayObjectContainer]"}static get namespace(){return"next2d.display.DisplayObjectContainer"}toString(){return"[object DisplayObjectContainer]"}get namespace(){return"next2d.display.DisplayObjectContainer"}get mouseChildren(){return this._$mouseChildren}set mouseChildren(t){this._$mouseChildren=!!t}get numChildren(){return this._$needsChildren?this._$getChildren().length:this._$children.length}addChild(t){if(!(t instanceof b))throw new TypeError("TypeError: addChild: not DisplayObject.");t._$parent&&t._$parent._$remove(t,!(t._$parent._$instanceId===this._$instanceId));return this._$getChildren().push(t),t._$name&&this._$names.set(t._$name,t),this._$addChild(t)}addChildAt(t,e){if(!(t instanceof b))throw new TypeError("TypeError: addChildAt: not DisplayObject.");t._$parent&&t._$parent._$remove(t,!(t._$parent._$instanceId===this._$instanceId));const i=this._$getChildren(),s=i.length;if(0>e||e>s)throw new RangeError(`RangeError: addChildAt: index error: ${e}`);if(s&&s>e){i.splice(e,0,t);for(let t=0;tt||t>i)throw new RangeError(`RangeError: getChildAt: index error: ${t}`);return t in e?e[t]:null}getChildByName(t){if(!t)return null;const e=this._$getChildren(),i=e.length;for(let s=0;st;--n)this._$remove(i[n])}}setChildIndex(t,e){if(!(t instanceof b))throw new TypeError("TypeError: removeChild: not DisplayObject.");const i=this.getChildIndex(t);if(i===e)return;const s=this._$getChildren();s.splice(i,1),s.splice(e,0,t),this._$doChanged()}swapChildren(t,e){if(!(t instanceof b&&e instanceof b))throw new TypeError("TypeError: removeChild: not DisplayObject.");const i=this._$getChildren(),s=this.getChildIndex(t),r=this.getChildIndex(e);i[s]=e,i[r]=t,this._$doChanged()}swapChildrenAt(t,e){this.swapChildren(this.getChildAt(t),this.getChildAt(e))}_$getBounds(t=null){let e=s.$MATRIX_ARRAY_IDENTITY;if(t){e=t;const i=this._$transform._$rawMatrix();i!==s.$MATRIX_ARRAY_IDENTITY&&(e=s.$multiplicationMatrix(t,i))}const i=this._$graphics&&this._$graphics._$getBounds(),r=this._$needsChildren?this._$getChildren():this._$children,n=r.length;if(!n&&!i){const i=s.$getBoundsObject(e[4],-e[4],e[5],-e[5]);return t&&e!==t&&s.$poolFloat32Array6(e),i}const a=s.$MAX_VALUE;let o=a,h=-a,l=a,$=-a;if(i){const t=s.$boundsMatrix(this._$graphics._$getBounds(),e);o=t.xMin,h=t.xMax,l=t.yMin,$=t.yMax,s.$poolBoundsObject(t)}for(let t=0;tt){if(i._$filters=null,i._$blendMode=null,-1===i._$id){h.push(i),i._$name&&this._$names.set(i._$name,i);continue}const t=e[o];if(i._$id===t){i._$placeId=o,h.push(i),i._$name&&this._$names.set(i._$name,i),n.has(t)&&n.delete(t),r.set(t,!0),o++;continue}n.set(i._$id,i)}else i.willTrigger(a.REMOVED)&&i.dispatchEvent(new a(a.REMOVED,!0)),i.willTrigger(a.REMOVED_FROM_STAGE)&&i.dispatchEvent(new a(a.REMOVED_FROM_STAGE,!0)),i._$added=!1,i._$addedStage=!1,i._$active=!1,i._$updated=!0,i._$filters=null,i._$blendMode=null,i._$isNext=!0,i instanceof v&&(i._$executeRemovedFromStage(),i._$removeParentAndStage())}if(e)for(let t=0;t-1;--e)t[e]._$prepareActions();this._$executeAddedEvent()}_$nextFrame(){let t=!1;const e=this._$needsChildren?this._$getChildren():this._$children;for(let i=e.length-1;i>-1;--i){const s=e[i];s._$isNext&&(t?s._$nextFrame():t=s._$nextFrame())}return this._$executeAddedEvent(),this._$isNext=t,this._$isNext}_$clip(t,e){let i=e;const r=this._$transform._$rawMatrix();r!==s.$MATRIX_ARRAY_IDENTITY&&(i=s.$multiplicationMatrix(e,r)),this._$graphics&&this._$graphics._$getBounds()&&this._$graphics._$clip(t,i);const n=this._$getChildren(),a=n.length;for(let e=0;ec||i._$clipDepth>0)&&(t.restore(),_&&(t._$leaveClip(),u.length&&(s.$poolFloat32Array6(l),l=u.pop())),c=g.length?g.pop():null,_=f.pop()),!_)continue;if(i._$clipDepth>0){if(t.save(),c&&g.push(c),f.push(_),c=i._$clipDepth,_=i._$shouldClip(l),_){const e=i._$startClip(t,l);if(!1===e){_=!1;continue}e&&(u.push(l),l=e)}continue}const n=i._$mask;if(n){let e;if(n._$updated=!1,this===n._$parent)e=l;else{e=s.$MATRIX_ARRAY_IDENTITY;let i=n._$parent;for(;i;)e=s.$multiplicationMatrix(i._$transform._$rawMatrix(),e),i=i._$parent;const r=this.stage._$player,a=r._$scale*r._$ratio/20,o=s.$getFloat32Array6(a,0,0,a,0,0);if(e=s.$multiplicationMatrix(o,e),t._$isLayer){const i=t._$getCurrentPosition();e[4]-=i.xMin,e[5]-=i.yMin}t._$cacheCurrentBuffer&&(e[4]-=t._$cacheCurrentBounds.x,e[5]-=t._$cacheCurrentBounds.y)}if(!n._$shouldClip(e))continue;let i=n._$startClip(t,e);if(t.save(),!1===i){t.restore();continue}if(i){if(d.push(l),this!==n._$parent){const e=this._$transform._$rawMatrix();i[0]=s.$abs(l[0])*s.$sign(e[0]),i[1]=s.$abs(l[1])*s.$sign(e[1]),i[2]=s.$abs(l[2])*s.$sign(e[2]),i[3]=s.$abs(l[3])*s.$sign(e[3]),i[4]=l[4]-t._$cacheCurrentBounds.x,i[5]=l[5]-t._$cacheCurrentBounds.y}l=i}}i._$draw(t,l,$),i._$updated=!1,n&&(t.restore(),t._$leaveClip(),d.length&&(s.$poolFloat32Array6(l),l=d.pop()))}if(c&&(t.restore(),f.pop()&&t._$leaveClip()),s.$poolArray(u),s.$poolArray(d),s.$poolArray(g),s.$poolArray(f),h.isFilter)return this._$postDraw(t,e,r,h);s.$poolFloat32Array6(l),s.$poolPreObject(h)}_$mouseHit(t,e,i,r=!0){let n=e;const a=this._$transform._$rawMatrix();a!==s.$MATRIX_ARRAY_IDENTITY&&(n=s.$multiplicationMatrix(e,a));const o=this._$getChildren(),h=s.$getArray(),l=s.$getArray(),$=s.$getMap();let _=o.length,c=null,u=null;for(let t=0;t<_;++t){const e=o[t];(e._$visible||e._$hitObject)&&(e._$clipDepth?(u=h.length,c=e._$clipDepth,h.push(e)):(c&&e._$placeId>c&&(u=null,c=null),null!==u&&$.set(e._$instanceId,u),l.push(e)))}const d=s.$min(this._$mouseChildren,r);let g=!1;const f=this._$root===this;_=l.length;for(let e=0;e<_;++e){const e=l.pop();if(e._$isMask)continue;if(f&&!(e instanceof T))continue;if($.has(e._$instanceId)){if(!h[$.get(e._$instanceId)]._$hit(t,n,i,!0))continue}const r=e._$mask;if(r)if(this===r._$parent){if(!r._$hit(t,n,i,!0))continue}else{let e=s.$MATRIX_ARRAY_IDENTITY,n=r._$parent;for(;n;)e=s.$multiplicationMatrix(n._$transform._$rawMatrix(),e),n=n._$parent;if(!r._$hit(t,e,i,!0))continue}if(e._$mouseHit(t,n,i,d)||e._$hitArea&&e._$hitArea._$mouseHit(t,n,i,d)){if(e._$root===e)return!0;if(!d)return!0;if(g=!0,e instanceof T){if(!e._$mouseEnabled&&!e._$hitObject)continue;if(!s.$isTouch&&!i.pointer)switch(!0){case e instanceof st:e._$type===rt.INPUT&&(i.pointer="text");break;case e.buttonMode&&e.useHandCursor:i.pointer="pointer"}return i.hit||(i.hit=!e._$mouseEnabled&&e._$hitObject?e._$hitObject:e),!0}}}return s.$poolArray(h),s.$poolArray(l),s.$poolMap($),!g&&this._$graphics&&(g=this._$graphics._$hit(t,n,i)),n!==e&&s.$poolFloat32Array6(n),g}_$hit(t,e,i,r=!1){let n=e;const a=this._$transform._$rawMatrix();a!==s.$MATRIX_ARRAY_IDENTITY&&(n=s.$multiplicationMatrix(e,a));const o=this._$getChildren();for(let e=o.length-1;e>-1;--e){const s=o[e];if(!s._$isMask&&s._$hit(t,n,i,r))return!0}let h=!1;return this._$graphics&&(h=this._$graphics._$hit(t,n,i)),n!==e&&s.$poolFloat32Array6(n),h}_$createInstance(t){const e=this._$dictionary[t],i=this._$loaderInfo._$data.characters[e.characterId];i.class||(i.class=i.symbol&&s.$getClass(i.symbol)||s.$getClass(i.extends)),s.$currentLoaderInfo=null;const r=new i.class;return r._$build(e,this),r._$id=t,r}_$outCheck(t,e){let i=s.$MATRIX_ARRAY_IDENTITY,r=this._$parent;for(;r;)i=s.$multiplicationMatrix(r._$transform._$rawMatrix(),i),r=r._$parent;return s.$hitContext.setTransform(1,0,0,1,0,0),s.$hitContext.beginPath(),this._$mouseHit(s.$hitContext,i,{x:t,y:e})}}class y extends v{constructor(){super(),this._$buttonMode=!1,this._$hitArea=null,this._$soundTransform=null,this._$useHandCursor=!0,this._$graphics=null}static toString(){return"[class Sprite]"}static get namespace(){return"next2d.display.Sprite"}toString(){return"[object Sprite]"}get namespace(){return"next2d.display.Sprite"}get buttonMode(){return this._$buttonMode}set buttonMode(t){this._$buttonMode=!!t}get dropTarget(){return s.$dropTarget}get graphics(){return this._$graphics||(this._$graphics=new O,this._$graphics._$displayObject=this),this._$graphics}get hitArea(){return this._$hitArea}set hitArea(t){this._$hitArea&&(this._$hitArea._$hitObject=null),this._$hitArea=null,t instanceof y&&(this._$hitArea=t,t._$hitObject=this)}get soundTransform(){return this._$soundTransform||(this._$soundTransform=new lt),this._$soundTransform}set soundTransform(t){t instanceof lt&&(this._$soundTransform=t)}get useHandCursor(){return this._$useHandCursor}set useHandCursor(t){this._$useHandCursor=!!t}startDrag(t=!1,e=null){let i=0,r=0;if(!t){const t=this._$dragMousePoint();i=this.x-t.x,r=this.y-t.y}s.$dropTarget=this,s.$dragRules.lock=t,s.$dragRules.position.x=i,s.$dragRules.position.y=r,s.$dragRules.bounds=e}stopDrag(){s.$dropTarget=null,s.$dragRules.lock=!1,s.$dragRules.position.x=0,s.$dragRules.position.y=0,s.$dragRules.bounds=null}_$sync(){const t=super._$sync();return t&&(this._$controller=t.controller,this._$dictionary=t.dictionary,this._$placeMap=t.placeMap,this._$placeObjects=t.placeObjects),t}_$build(t,e){const i=super._$build(t,e);return this._$controller=i.controller,this._$dictionary=i.dictionary,this._$placeMap=i.placeMap,this._$placeObjects=i.placeObjects,i}_$dragMousePoint(){return this._$parent?this._$parent.globalToLocal(s.$currentMousePoint()):this.globalToLocal(s.$currentMousePoint())}}class E extends y{constructor(){super(),this._$stopFlag=!1,this._$canAction=!0,this._$childRemove=!1,this._$canSound=!0,this._$actionProcess=!1,this._$actions=s.$getMap(),this._$frameCache=s.$getMap(),this._$labels=null,this._$sounds=s.$getMap(),this._$channels=s.$getMap(),this._$actionOffset=0,this._$actionLimit=0,this._$currentFrame=1,this._$totalFrames=1,this._$isPlaying=!1}static toString(){return"[class MovieClip]"}static get namespace(){return"next2d.display.MovieClip"}toString(){return"[object MovieClip]"}get namespace(){return"next2d.display.MovieClip"}get currentFrame(){return this._$currentFrame}get currentFrameLabel(){if(!this._$labels)return null;const t=this._$currentFrame;return this._$labels.has(t)?this._$labels.get(t):null}get currentLabels(){return this._$labels?s.$Array.from(this._$labels.values()):null}get isPlaying(){return this._$isPlaying}get totalFrames(){return this._$totalFrames}gotoAndPlay(t){this.play(),this._$goToFrame(t)}gotoAndStop(t){this.stop(),this._$goToFrame(t)}nextFrame(){this.stop(),this._$totalFrames>this._$currentFrame&&this._$goToFrame(this._$currentFrame+1)}play(){this._$stopFlag=!1,this._$isPlaying=!0,this._$updateState()}prevFrame(){const t=this._$currentFrame-1;t&&(this.stop(),this._$goToFrame(t))}stop(){this._$stopFlag=!0,this._$isPlaying=!1}addFrameLabel(t){this._$labels||(this._$labels=s.$getMap()),t instanceof R&&this._$labels.set(t.frame,t)}addFrameScript(){const t=arguments.length;for(let e=0;e=t&&this._$addAction(t,i),t===this._$currentFrame){const t=s.$currentPlayer();if(t._$actionOffset=t._$actions.length,this._$canAction=!0,this._$setAction(),t._$actionOffset!==t._$actions.length){const e=t._$actions.splice(0,t._$actionOffset);t._$actions.push.apply(t._$actions,e),t._$actionOffset=0}}}}_$getFrameForLabel(t){for(let[e,i]of this._$labels)if(i.name===t)return 0|e;return 0}_$addAction(t,e){(t|=0)&&(this._$actions.has(t)||this._$actions.set(t,s.$getArray()),this._$actions.get(t).push(e))}_$setAction(){if(this._$executeAddedEvent(),this._$canAction){const t=this._$currentFrame;if(this._$labels&&this._$labels.has(t)){const e=this._$labels.get(t);e.willTrigger(a.FRAME_LABEL)&&e.dispatchEvent(new a(a.FRAME_LABEL))}if(this._$actions.size&&this._$actions.has(t)){const t=s.$currentPlayer();if(t){-1===t._$actions.indexOf(this)&&t._$actions.push(this)}}}}_$goToFrame(t){if(s.$isNaN(+t)&&(t=this._$getFrameForLabel(t)),t<1&&(t=1),t>this._$totalFrames)return this._$currentFrame=this._$totalFrames,this._$clearChildren(),this._$canAction=!1,void(this._$wait=!1);const e=s.$currentPlayer();switch(!0){case t!==this._$currentFrame:{this._$wait=!1;const i=this._$currentFrame;this._$actionProcess&&(this._$frameCache.set("nextFrame",t),this._$frameCache.set("stopFlag",this._$stopFlag),this._$frameCache.set("isPlaying",this._$isPlaying)),this._$currentFrame=t,this._$clearChildren(),e._$actionOffset=e._$actions.length;const r=e._$actionOffset?e._$actions.indexOf(this):-1;if(this._$canAction=!0,this._$prepareActions(),e._$actionOffset&&e._$actionOffset!==e._$actions.length){const t=e._$actions.splice(0,e._$actionOffset);e._$actions.push.apply(e._$actions,t),e._$actionOffset=0}if(!this._$actionProcess&&(r>-1||!e._$actionOffset))for(;e._$actions.length&&e._$actions.length!==r;){const t=e._$actions.pop();t._$canAction=!1,t._$actionOffset=0,t._$actionLimit=0,t._$actionProcess&&t._$frameCache.size&&(t._$currentFrame=t._$frameCache.get("nextFrame"),t._$clearChildren(),t._$stopFlag=t._$frameCache.get("stopFlag"),t._$isPlaying=t._$frameCache.get("isPlaying"),t._$frameCache.clear());const i=t._$currentFrame;if(!t._$actions.has(i))continue;const r=t._$actions.get(i),n=r.length;for(let e=0;e-1:{if(!this._$actionLimit)break;this._$wait=!1;const t=e._$actions.splice(this._$actionOffset,this._$actionLimit);for(;t.length;){const e=t.pop();e._$canAction=!1,e._$actionOffset=0,e._$actionLimit=0;const i=e._$currentFrame;if(!e._$actions.has(i))continue;const r=e._$actions.get(i),n=r.length;for(let t=0;t-1;--e)t[e]._$prepareActions();this._$setAction()}_$draw(t,e,i){super._$draw(t,e,i);const r=s.$currentPlayer();this._$canSound&&this._$sounds.size&&this._$sounds.has(this._$currentFrame)&&!r._$sounds.has(this._$instanceId)&&r._$sounds.set(this._$instanceId,this)}_$nextFrame(){let t=this._$needsChildren;switch(!0){case this._$wait:t=!0,this._$wait=!1;break;case this._$stopFlag:case 1===this._$totalFrames:break;default:t=!0,this._$canAction=!0,this._$canSound=!0,++this._$currentFrame,this._$currentFrame>this._$totalFrames&&(this._$currentFrame=1),this._$clearChildren()}const e=this._$needsChildren?this._$getChildren():this._$children;for(let i=e.length-1;i>-1;--i){const s=e[i];s._$isNext&&(t?s._$nextFrame():t=s._$nextFrame())}return this._$setAction(),this._$isNext=t,this._$isNext}_$buildCharacter(t){for(let e=0;e6)switch(this._$recode||(this._$recode=s.$getArray()),this._$fills[2]===this._$fills[this._$fills.length-2]&&this._$fills[3]===this._$fills[this._$fills.length-1]||this._$fills.push(O.LINE_TO,this._$fills[2],this._$fills[3]),this._$recode.push.apply(this._$recode,this._$fills),this._$fillType){case O.FILL_STYLE:this._$recode.push(this._$fillType,this._$fillStyleR,this._$fillStyleG,this._$fillStyleB,this._$fillStyleA,O.END_FILL);break;case O.GRADIENT_FILL:this._$recode.push(this._$fillType),this._$recode.push.apply(this._$recode,this._$fillGradient.toArray());break;case O.BITMAP_FILL:this._$recode.push(this._$fillType),this._$recode.push.apply(this._$recode,this._$fillBitmap.toArray())}return this._$fills&&(s.$poolArray(this._$fills),this._$fills=null),this._$fillType=0,this._$fillGradient=null,this._$fillBitmap=null,this._$fillStyleR=0,this._$fillStyleG=0,this._$fillStyleB=0,this._$fillStyleA=0,this._$doFill=!1,this._$restart(),this}endLine(){if(this._$doLine)switch(this._$recode||(this._$recode=s.$getArray()),this._$recode.push.apply(this._$recode,this._$lines),s.$poolArray(this._$lines),this._$lines=null,this._$lineType){case O.STROKE_STYLE:this._$recode.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,this._$lineStyleR,this._$lineStyleG,this._$lineStyleB,this._$lineStyleA,O.END_STROKE);break;case O.GRADIENT_STROKE:this._$recode.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit),this._$recode.push.apply(this._$recode,this._$lineGradient.toArray());break;case O.BITMAP_STROKE:this._$recode.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit),this._$recode.push.apply(this._$recode,this._$fillBitmap.toArray())}return this._$lineType=0,this._$lineWidth=0,this._$lineGradient=null,this._$lineStyleR=0,this._$lineStyleG=0,this._$lineStyleB=0,this._$lineStyleA=0,this._$caps=S.NONE,this._$joints=L.ROUND,this._$miterLimit=0,this._$doLine=!1,this._$restart(),this}lineBitmapStyle(t,e=null,i=!0,r=!1){return this._$doLine&&this.endLine(),this._$lines||(this._$lines=s.$getArray()),this._$maxAlpha=1,this._$doLine=!0,this._$canDraw=!0,this._$lines.push(O.BEGIN_PATH),this._$lineType=O.BITMAP_STROKE,this._$fillBitmap=new I(t,e,i,r),this}lineGradientStyle(t,e,i,r,n=null,a=U.PAD,o=F.RGB,h=0){if(!this._$doLine)return this;this._$lines||(this._$lines=s.$getArray());const l=i.length;for(let t=0;tu+x||0>g+b){if(!(n&&n.length&&o._$canApply(n)))return;{let t=new p(0,0,x,b);for(let e=0;et.x+t.width||0>t.y+t.height)return}}const y=t.frameBuffer.currentAttachment;if(u>y.width||g>y.height)return;const E=t._$textureScale(x,b);E<1&&(x*=E,b*=E);const A=s.$cacheStore().generateKeys(o._$instanceId,[T,v],i);let M=s.$cacheStore().get(A);if(!M){const r=t.frameBuffer.createCacheAttachment(x,b,!0);switch(t._$bind(r),s.$resetContext(t),i[3]=1,!0){case 1!==l[0]:case 0!==l[1]:case 0!==l[2]:case 1!==l[3]:{const r=Math.atan2(e[1],e[0]);let n=0,a=0;if(r){const t=new f;t.translate(-x/2,-b/2),t.rotate(r),t.translate(x/2,b/2);const e=t.transformPoint(new m(0,0)),i=t.transformPoint(new m(x,0)),o=t.transformPoint(new m(0,b)),h=t.transformPoint(new m(x,b));n=s.$min(e.x,i.x,o.x,h.x),a=s.$min(e.y,i.y,o.y,h.y)}s.$resetContext(t),t.setTransform(e[0],e[1],e[2],e[3],-n,-a),t.beginPath(),this._$runTransformCommand(t,l,i)}break;default:t.setTransform(h[0],h[1],h[2],h[3],h[4]-u,h[5]-g),this._$doDraw(t,i)}M=t.frameBuffer.getTextureFromCurrentAttachment(),s.$cacheStore().set(A,M),t.frameBuffer.releaseAttachment(r,!1),t._$bind(y)}let S=!1,R=0,w=0;if(n&&n.length){o._$canApply(n)&&(S=!0,M=this._$drawFilter(t,M,e,i,n,x,b),R=M._$offsetX,w=M._$offsetY)}s.$resetContext(t),t._$globalAlpha=a,t._$imageSmoothingEnabled=!0,t._$globalCompositeOperation=r,t.setTransform(1,0,0,1,0,0),S?t.drawImage(M,u-R,g-w,M.width,M.height,i):t.drawImage(M,u,g,x,b,i),s.$poolArray(A),s.$poolBoundsObject($)}_$draw(t,e,i,r=C.NORMAL,n=null){if(!this._$maxAlpha)return;const a=s.$clamp(i[3]+i[7]/255,0,1),o=this._$displayObject;let h=null!==o._$scale9Grid,l=null;h&&(l=o._$transform._$rawMatrix(),h=h&&s.$abs(l[1])<.001&&s.$abs(l[2])<1e-4);const $=this._$getBounds(),_=s.$boundsMatrix($,e),c=_.xMax,u=_.xMin,d=_.yMax,g=_.yMin;s.$poolBoundsObject(_);let f=s.$ceil(s.$abs(c-u)),m=s.$ceil(s.$abs(d-g));switch(!0){case 0===f:case 0===m:case f===-s.$Infinity:case m===-s.$Infinity:case f===s.$Infinity:case m===s.$Infinity:return}const x=Math.sqrt(e[0]*e[0]+e[1]*e[1]),b=Math.sqrt(e[2]*e[2]+e[3]*e[3]);if(0>u+f||0>g+m){if(!(n&&n.length&&o._$canApply(n)))return;{let t=new p(0,0,f,m);for(let e=0;et.x+t.width||0>t.y+t.height)return}}const T=t.frameBuffer.currentAttachment;if(u>T.width||g>T.height)return;const v=t._$textureScale(f,m);v<1&&(f*=v,m*=v);const y=s.$cacheStore().generateKeys(o._$instanceId,[x,b],i);let E=s.$cacheStore().get(y);if(!E){const r=t.frameBuffer.createCacheAttachment(f,m,!0);if(t._$bind(r),s.$resetContext(t),t.setTransform(e[0],e[1],e[2],e[3],e[4]-u,e[5]-g),h){const i=s.$currentPlayer(),r=i._$scale*i._$ratio,n=s.$getFloat32Array6(r,0,0,r,0,0),a=s.$multiplicationMatrix(n,l);s.$poolFloat32Array6(n);const h=o._$parent._$transform._$calculateConcatenatedMatrix()._$matrix,_=s.$getFloat32Array6(h[0],h[1],h[2],h[3],h[4]*r-u,h[5]*r-g),c=s.$multiplicationMatrix(_,a),d=c[4]-(e[4]-u),f=c[5]-(e[5]-g);s.$poolFloat32Array6(c);const m=s.$boundsMatrix($,a),p=+m.xMax,x=+m.xMin,b=+m.yMax,T=+m.yMin,v=s.$ceil(s.$abs(p-x)),y=s.$ceil(s.$abs(b-T));s.$poolBoundsObject(m),t.grid.enable(x,T,v,y,$,o._$scale9Grid,a[0],a[1],a[2],a[3],a[4],a[5],_[0],_[1],_[2],_[3],_[4]-d,_[5]-f),s.$poolFloat32Array6(a),s.$poolFloat32Array6(_)}i[3]=1,this._$doDraw(t,i,!1),h&&t.grid.disable(),E=t.frameBuffer.getTextureFromCurrentAttachment(),s.$cacheStore().set(y,E),t.frameBuffer.releaseAttachment(r,!1),t._$bind(T)}let A=!1,M=0,S=0;if(n&&n.length){o._$canApply(n)&&(A=!0,E=this._$drawFilter(t,E,e,i,n,f,m),M=E._$offsetX,S=E._$offsetY)}s.$resetContext(t),t._$globalAlpha=a,t._$imageSmoothingEnabled=!0,t._$globalCompositeOperation=r,t.setTransform(1,0,0,1,0,0),A?t.drawImage(E,u-M,g-S,E.width,E.height,i):t.drawImage(E,u,g,f,m,i),s.$poolArray(y),l&&s.$poolMatrix(l),s.$poolBoundsObject($)}_$doDraw(t,e,i=!1){s.$resetContext(t),t.beginPath(),this._$runCommand(t,e,i)}_$hit(t,e,i,s=!1){return t.beginPath(),t.setTransform(e[0],e[1],e[2],e[3],e[4],e[5]),this._$runCommand(t,null,s,i)}_$getBounds(){const t=this._$displayObject;return t&&t._$bounds?s.$getBoundsObject(t._$bounds.xMin,t._$bounds.xMax,t._$bounds.yMin,t._$bounds.yMax):s.$getBoundsObject(this._$xMin,this._$xMax,this._$yMin,this._$yMax)}_$restart(){this._$displayObject&&!this._$displayObject._$isUpdated()&&(this._$displayObject._$doChanged(),s.$isUpdated=!0,s.$cacheStore().removeCache(this._$displayObject._$instanceId))}_$setBounds(t=0,e=0){this._$setFillBounds(t,e),this._$doLine&&this._$setLineBounds(t,e)}_$setFillBounds(t,e){this._$xMin=s.$min(this._$xMin,t),this._$xMax=s.$max(this._$xMax,t),this._$yMin=s.$min(this._$yMin,e),this._$yMax=s.$max(this._$yMax,e)}_$setLineBounds(t,e){this._$xMin=s.$min(this._$xMin,s.$min(t,this._$pointerX)),this._$xMax=s.$max(this._$xMax,s.$max(t,this._$pointerX)),this._$yMin=s.$min(this._$yMin,s.$min(e,this._$pointerY)),this._$yMax=s.$max(this._$yMax,s.$max(e,this._$pointerY));const i=this._$lineWidth/2,r=.5*s.$PI,n=s.$atan2(e-this._$pointerY,t-this._$pointerX),a=s.$atan2(this._$pointerY-e,this._$pointerX-t),o=n+r,h=n-r,l=a+r,$=a-r;let _=t+i,c=-i+t,u=this._$pointerX+i,d=-i+this._$pointerX,g=e+i,f=-i+e,m=this._$pointerY+i,p=-i+this._$pointerY;this._$xMin=s.$min(this._$xMin,s.$min(_,s.$min(c,s.$min(u,d)))),this._$xMax=s.$max(this._$xMax,s.$max(_,s.$max(c,s.$max(u,d)))),this._$yMin=s.$min(this._$yMin,s.$min(g,s.$min(f,s.$min(m,p)))),this._$yMax=s.$max(this._$yMax,s.$max(g,s.$max(f,s.$max(m,p)))),s.$abs(o)%r!=0&&(_=t+s.$cos(o)*i),s.$abs(h)%r!=0&&(c=t+s.$cos(h)*i),s.$abs(l)%r!=0&&(u=this._$pointerX+s.$cos(l)*i),s.$abs($)%r!=0&&(d=this._$pointerX+s.$cos($)*i),o&&s.$abs(o)%s.$PI!=0&&(g=e+s.$sin(o)*i),h&&s.$abs(h)%s.$PI!=0&&(f=e+s.$sin(h)*i),l&&s.$abs(l)%s.$PI!=0&&(m=this._$pointerY+s.$sin(l)*i),$&&s.$abs($)%s.$PI!=0&&(p=this._$pointerY+s.$sin($)*i),this._$xMin=s.$min(this._$xMin,s.$min(_,s.$min(c,s.$min(u,d)))),this._$xMax=s.$max(this._$xMax,s.$max(_,s.$max(c,s.$max(u,d)))),this._$yMin=s.$min(this._$yMin,s.$min(g,s.$min(f,s.$min(m,p)))),this._$yMax=s.$max(this._$yMax,s.$max(g,s.$max(f,s.$max(m,p))));let x=0,b=0,T=0,v=0,y=0,E=0,A=0,M=0;switch(this._$caps){case S.ROUND:s.$abs(n)%r!=0&&(x=t+s.$cos(n)*i),n&&s.$abs(n)%s.$PI!=0&&(b=e+s.$sin(n)*i),s.$abs(a)%r!=0&&(T=this._$pointerX+s.$cos(a)*i),a&&s.$abs(a)%s.$PI!=0&&(v=this._$pointerY+s.$sin(a)*i),this._$xMin=s.$min(this._$xMin,s.$min(x,T)),this._$xMax=s.$max(this._$xMax,s.$max(x,T)),this._$yMin=s.$min(this._$yMin,s.$min(b,v)),this._$yMax=s.$max(this._$yMax,s.$max(b,v));break;case S.SQUARE:if(s.$abs(n)%r!=0){const t=s.$cos(n)*i;x=_+t,T=c+t}if(s.$abs(a)%r!=0){const t=s.$cos(a)*i;y=u+t,A=d+t}if(n&&s.$abs(n)%s.$PI!=0){const t=s.$sin(n)*i;b=g+t,v=f+t}if(a&&s.$abs(a)%s.$PI!=0){const t=s.$sin(a)*i;E=m+t,M=p+t}this._$xMin=s.$min(this._$xMin,s.$min(x,s.$min(T,s.$min(y,A)))),this._$xMax=s.$max(this._$xMax,s.$max(x,s.$max(T,s.$max(y,A)))),this._$yMin=s.$min(this._$yMin,s.$min(b,s.$min(v,s.$min(E,M)))),this._$yMax=s.$max(this._$yMax,s.$max(b,s.$max(v,s.$max(E,M))))}}_$margePath(t){this._$doFill&&this._$fills.push.apply(this._$fills,t),this._$doLine&&this._$lines.push.apply(this._$lines,t),s.$poolArray(t)}_$runTransformCommand(t,e,i=null){if(this._$doLine&&this.endLine(),this._$doFill&&this.endFill(),!this._$recode)return!1;let r=Number.MAX_VALUE,n=-Number.MAX_VALUE,a=Number.MAX_VALUE,o=-Number.MAX_VALUE;const h=this._$recode,l=h.length;for(let $=0;$t.target.status)switch(e.format){case _t.JSON:{const e=JSON.parse(t.target.responseText);if("zlib"===e.type){if(s.$unzipWorkerActive)return void s.$unzipQueues.push({json:e,scope:this});s.$unzipWorkerActive=!0,s.$unzipWorker||(s.$unzipWorker=new Worker(s.$unzipURL));const t=new Uint8Array(e.buffer);s.$unzipWorker.onmessage=s.$unzipHandler.bind(this),s.$unzipWorker.postMessage(t,[t.buffer])}else this._$build(e)}break;case _t.ARRAY_BUFFER:this._$imageDecode(new Uint8Array(t.target.response))}else e.willTrigger(_.IO_ERROR)&&e.dispatchEvent(new _(_.IO_ERROR,!1,!1,t.target.statusText))}.bind(this)}})}loadImage(t){t.responseDataFormat=_t.ARRAY_BUFFER,this.load(t)}_$imageDecode(t){const e={image:new s.$Image,scope:this};e.image.decoding="async",e.image.src=s.$URL.createObjectURL(new s.$Blob([t],{type:`image/${s.$getImageType(t)}`})),s.$imageWorkerActive?s.$imageQueues.push(e):(s.$imageWorkerActive=!0,e.image.decode().then(s.$decodeImage.bind(e)).catch((()=>{throw new Error("image encoding error")})))}_$build(t){const e=this.contentLoaderInfo;let i=null;const r=s.$getMap();if(t.symbols.length)for(let e=0;e=this._$blurX?1:this._$blurX*n,o=0>=this._$blurY?1:this._$blurY*n;switch(!0){case"number"==typeof e:case"number"==typeof i:a*=e,o*=i;break;default:a=s.$round(a),o=s.$round(o)}return r.x-=a,r.width+=2*a,r.y-=o,r.height+=2*o,r}_$isSame(t){return this._$quality===t._$quality&&(this._$blurX===t._$blurX&&this._$blurY===t._$blurY)}_$canApply(){return!(!this._$quality||!this._$blurX&&!this._$blurY)}_$applyFilter(t,e,i=!0){this._$doChanged(!1);const r=t.frameBuffer.currentAttachment,n=t.frameBuffer.getTextureFromCurrentAttachment();if(!this._$canApply())return i?n:t.frameBuffer.createTextureFromCurrentAttachment();const a=s.$sqrt(e[0]*e[0]+e[1]*e[1]),o=s.$sqrt(e[2]*e[2]+e[3]*e[3]),h=new p(0,0,n.width,n.height),l=this._$generateFilterRect(h,a,o),$=0|s.$ceil(l.width),_=0|s.$ceil(l.height),c=s.$ceil(s.$abs(l.x)+.5*s.$abs($-l.width)),u=s.$ceil(s.$abs(l.y)+.5*s.$abs(_-l.height));t._$offsetX=+(c+t._$offsetX),t._$offsetY=+(u+t._$offsetY);const d=this._$blurX*a,g=this._$blurY*o;let f=1,m=1;d>128?f=.0625:d>64?f=.125:d>32?f=.25:d>16&&(f=.5),g>128?m=.0625:g>64?m=.125:g>32?m=.25:g>16&&(m=.5);const x=d*f,b=g*m;let T=s.$ceil($*f),v=s.$ceil(_*m);const y=t.frameBuffer.createTextureAttachment(T,v),E=[y,t.frameBuffer.createTextureAttachment(T,v)];let A=0;t._$bind(y),s.$resetContext(t),t.setTransform(f,0,0,m,0,0),t.drawImage(n,c,u,n.width,n.height),t.blend.toOneZero();let M=t.frameBuffer.getTextureFromCurrentAttachment();for(let e=0;e0){A=(A+1)%2;const e=E[A];t._$bind(e),t._$applyBlurFilter(M,!0,x),M=t.frameBuffer.getTextureFromCurrentAttachment()}if(this._$blurY>0){A=(A+1)%2;const e=E[A];t._$bind(e),t._$applyBlurFilter(M,!1,b),M=t.frameBuffer.getTextureFromCurrentAttachment()}}if(t.blend.reset(),1!==f||1!==m){const e=t.frameBuffer.createTextureAttachment($,_);t._$bind(e),s.$resetContext(t),t.imageSmoothingEnabled=!0,t.setTransform(1/f,0,0,1/m,0,0),t.drawImage(M,0,0,T,v),M=t.frameBuffer.getTextureFromCurrentAttachment(),s.$resetContext(t),t.setTransform(1,0,0,1,0,0),t.frameBuffer.releaseAttachment(E[0],!0),t.frameBuffer.releaseAttachment(E[1],!0),i?t.frameBuffer.releaseAttachment(r,!0):t.frameBuffer.releaseAttachment(e,!1)}else t.frameBuffer.releaseAttachment(E[(A+1)%2],!0),i?t.frameBuffer.releaseAttachment(r,!0):t.frameBuffer.releaseAttachment(E[A],!1);return M}}class V extends X{constructor(t=4,e=45,i=16777215,s=1,r=0,n=1,a=4,o=4,h=1,l=1,$="inner",_=!1){super(),this._$blurFilter=new z(a,o,l),this._$distance=4,this._$angle=45,this._$highlightColor=16777215,this._$highlightAlpha=1,this._$shadowColor=0,this._$shadowAlpha=1,this._$strength=1,this._$type=H.INNER,this._$knockout=!1,this.distance=t,this.angle=e,this.highlightColor=i,this.highlightAlpha=s,this.shadowColor=r,this.shadowAlpha=n,this.strength=h,this.type=$,this.knockout=!!_}static toString(){return"[class BevelFilter]"}static get namespace(){return"next2d.filters.BevelFilter"}toString(){return"[object BevelFilter]"}get namespace(){return"next2d.filters.BevelFilter"}get angle(){return this._$angle}set angle(t){(t%=360)!==this._$angle&&this._$doChanged(!0),this._$angle=s.$clamp(t,-360,360,45)}get blurX(){return this._$blurFilter._$blurX}set blurX(t){this._$blurFilter.blurX=t}get blurY(){return this._$blurFilter._$blurY}set blurY(t){this._$blurFilter.blurY=t}get distance(){return this._$distance}set distance(t){(t=s.$clamp(+t,-255,255,4))!==this._$distance&&this._$doChanged(!0),this._$distance=t}get highlightAlpha(){return this._$highlightAlpha}set highlightAlpha(t){(t=s.$clamp(+t,0,1,0))!==this._$highlightAlpha&&this._$doChanged(!0),this._$highlightAlpha=t}get highlightColor(){return this._$highlightColor}set highlightColor(t){(t=s.$clamp(s.$toColorInt(t),0,16777215,16777215))!==this._$highlightColor&&this._$doChanged(!0),this._$highlightColor=t}get knockout(){return this._$knockout}set knockout(t){(t=!!t)!==this._$knockout&&this._$doChanged(!0),this._$knockout=t}get quality(){return this._$blurFilter._$quality}set quality(t){this._$blurFilter.quality=t}get shadowAlpha(){return this._$shadowAlpha}set shadowAlpha(t){(t=s.$clamp(+t,0,1,0))!==this._$shadowAlpha&&this._$doChanged(!0),this._$shadowAlpha=t}get shadowColor(){return this._$shadowColor}set shadowColor(t){(t=s.$clamp(s.$toColorInt(t),0,16777215,0))!==this._$shadowColor&&this._$doChanged(!0),this._$shadowColor=t}get strength(){return this._$strength}set strength(t){(t=s.$clamp(0|t,0,255,0))!==this._$strength&&this._$doChanged(!0),this._$strength=t}get type(){return this._$type}set type(t){switch((t+="")!==this._$type&&this._$doChanged(!0),t){case H.OUTER:case H.INNER:this._$type=t;break;default:this._$type=H.FULL}}clone(){return new V(this._$distance,this._$angle,this._$highlightColor,this._$highlightAlpha,this._$shadowColor,this._$shadowAlpha,this._$blurFilter._$blurX,this._$blurFilter._$blurY,this._$strength,this._$blurFilter._$quality,this._$type,this._$knockout)}_$isUpdated(){return this._$updated||this._$blurFilter._$isUpdated()}_$generateFilterRect(t,e=null,i=null){let r=t.clone();if(!this._$canApply())return r;r=this._$blurFilter._$generateFilterRect(r,e,i);const n=+this.angle*s.$PI/180,a=s.$cos(n)*this.distance,o=s.$sin(n)*this.distance;let h=0|s.$abs(a),l=0|s.$abs(o);return 0>a&&h++,0>o&&l++,0===h&&0>o&&(h=1),0===l&&0>a&&(l=1),r.x-=h,r.width+=2*h,r.y-=l,r.height+=2*l,r}_$isSame(t){return this._$distance===t._$distance&&(this._$angle===t._$angle&&(this._$highlightColor===t._$highlightColor&&(this._$highlightAlpha===t._$highlightAlpha&&(this._$shadowColor===t._$shadowColor&&(this._$shadowAlpha===t._$shadowAlpha&&(this._$strength===t._$strength&&(this._$type===t._$type&&(this._$knockout===t._$knockout&&this._$blurFilter._$isSame(t._$blurFilter)))))))))}_$canApply(){return!(!this._$strength||!this._$distance)}_$applyFilter(t,e){this._$doChanged(!1);const i=t.frameBuffer.currentAttachment;t.setTransform(1,0,0,1,0,0);const r=t.frameBuffer.getTextureFromCurrentAttachment();if(!this._$canApply())return r;const n=i.width,a=i.height,o=t._$offsetX,h=t._$offsetY,l=s.$sqrt(e[0]*e[0]+e[1]*e[1]),$=s.$sqrt(e[2]*e[2]+e[3]*e[3]),_=+this._$angle*s.$Deg2Rad,c=+s.$cos(_)*this._$distance*l,u=+s.$sin(_)*this._$distance*$;let d=t.frameBuffer.createTextureAttachment(n,a);t._$bind(d),s.$resetContext(t),t.drawImage(r,0,0,n,a),t.globalCompositeOperation=C.ERASE,t.drawImage(r,2*c,2*u,n,a);const g=this._$blurFilter._$applyFilter(t,e,!1),f=g.width,m=g.height,p=s.$ceil(f+2*s.$abs(c)),x=s.$ceil(m+2*s.$abs(u)),b=this._$type===H.INNER,T=b?n:p,v=b?a:x,y=s.$abs(c),E=s.$abs(u),A=(f-n)/2,M=(m-a)/2;let S,R,w,O;return b?(S=0,R=0,w=-A-c,O=-M-u):(S=y+A,R=E+M,w=y-c,O=E-u),t._$bind(i),t._$applyBitmapFilter(g,T,v,n,a,S,R,f,m,w,O,!1,this._$type,this._$knockout,this._$strength,null,null,null,s.$intToR(this._$highlightColor,this._$highlightAlpha,!0),s.$intToG(this._$highlightColor,this._$highlightAlpha,!0),s.$intToB(this._$highlightColor,this._$highlightAlpha,!0),this._$highlightAlpha,s.$intToR(this._$shadowColor,this._$shadowAlpha,!0),s.$intToG(this._$shadowColor,this._$shadowAlpha,!0),s.$intToB(this._$shadowColor,this._$shadowAlpha,!0),this._$shadowAlpha),t._$offsetX=o+S,t._$offsetY=h+R,t.frameBuffer.releaseTexture(g),t.frameBuffer.getTextureFromCurrentAttachment()}}class W extends X{constructor(t=null){super(),this._$matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this._$doApply=!1,this.matrix=t}static toString(){return"[class ColorMatrixFilter]"}static get namespace(){return"next2d.filters.ColorMatrixFilter"}toString(){return"[object ColorMatrixFilter]"}get namespace(){return"next2d.filters.ColorMatrixFilter"}get matrix(){return this._$matrix}set matrix(t){if(s.$isArray(t)&&20===t.length){if(this._$matrix){const e=t.length;for(let i=0;i0?s.$max(0,f-u):0)+v,C=(m>0?s.$max(0,m-d):0)+y),this._$inner?(S=H.INNER,R=this._$knockout||this._$hideObject):!this._$knockout&&this._$hideObject?(S=H.FULL,R=!0):(S=H.OUTER,R=this._$knockout),t._$bind(i),t._$applyBitmapFilter(h,b,T,r,n,E,A,l,$,M,C,!0,S,R,this._$strength,null,null,null,s.$intToR(this._$color,this._$alpha,!0),s.$intToG(this._$color,this._$alpha,!0),s.$intToB(this._$color,this._$alpha,!0),this._$alpha,0,0,0,0),t._$offsetX=a+E,t._$offsetY=o+A,t.frameBuffer.releaseTexture(h),t.frameBuffer.getTextureFromCurrentAttachment()}}class J extends X{constructor(t=0,e=1,i=4,s=4,r=1,n=1,a=!1,o=!1){super(),this._$blurFilter=new z(i,s,n),this._$color=0,this._$alpha=1,this._$strength=1,this._$inner=!1,this._$knockout=!1,this.color=t,this.alpha=e,this.strength=r,this.inner=a,this.knockout=o}static toString(){return"[class GlowFilter]"}static get namespace(){return"next2d.filters.GlowFilter"}toString(){return"[object GlowFilter]"}get namespace(){return"next2d.filters.GlowFilter"}get alpha(){return this._$alpha}set alpha(t){(t=s.$clamp(+t,0,1,0))!==this._$alpha&&this._$doChanged(!0),this._$alpha=t}get blurX(){return this._$blurFilter._$blurX}set blurX(t){this._$blurFilter.blurX=t}get blurY(){return this._$blurFilter._$blurY}set blurY(t){this._$blurFilter.blurY=t}get color(){return this._$color}set color(t){(t=s.$clamp(s.$toColorInt(t),0,16777215,4))!==this._$color&&this._$doChanged(!0),this._$color=t}get inner(){return this._$inner}set inner(t){(t=!!t)!==this._$inner&&this._$doChanged(!0),this._$inner=t}get knockout(){return this._$knockout}set knockout(t){(t=!!t)!==this._$knockout&&this._$doChanged(!0),this._$knockout=t}get quality(){return this._$blurFilter._$quality}set quality(t){this._$blurFilter.quality=t}get strength(){return this._$strength}set strength(t){(t=s.$clamp(0|t,0,255,0))!==this._$strength&&this._$doChanged(!0),this._$strength=t}clone(){return new J(this._$color,this._$alpha,this._$blurFilter._$blurX,this._$blurFilter._$blurY,this._$strength,this._$blurFilter._$quality,this._$inner,this._$knockout)}_$isUpdated(){return this._$updated||this._$blurFilter._$isUpdated()}_$generateFilterRect(t,e=null,i=null){const s=t.clone();return this._$canApply()?this._$blurFilter._$generateFilterRect(s,e,i):s}_$isSame(t){return this._$color===t._$color&&(this._$alpha===t._$alpha&&(this._$strength===t._$strength&&(this._$inner===t._$inner&&(this._$knockout===t._$knockout&&this._$blurFilter._$isSame(t._$blurFilter)))))}_$canApply(){return!(!this._$alpha||!this._$strength)&&this._$blurFilter._$canApply()}_$applyFilter(t,e){this._$doChanged(!1);const i=t.frameBuffer.currentAttachment;if(t.setTransform(1,0,0,1,0,0),!this._$canApply())return t.frameBuffer.getTextureFromCurrentAttachment();const r=i.width,n=i.height,a=t._$offsetX,o=t._$offsetY,h=this._$blurFilter._$applyFilter(t,e,!1),l=h.width,$=h.height,_=t._$offsetX,c=t._$offsetY,u=this._$inner?r:l,d=this._$inner?n:$;let g,f,m,p;this._$inner?(g=0,f=0,m=-_,p=-c):(g=_-a,f=c-o,m=0,p=0);const x=this._$inner?H.INNER:H.OUTER;return t._$bind(i),t._$applyBitmapFilter(h,u,d,r,n,g,f,l,$,m,p,!0,x,this._$knockout,this._$strength,null,null,null,s.$intToR(this._$color,this._$alpha,!0),s.$intToG(this._$color,this._$alpha,!0),s.$intToB(this._$color,this._$alpha,!0),this._$alpha,0,0,0,0),t._$offsetX=a+g,t._$offsetY=o+f,t.frameBuffer.releaseTexture(h),t.frameBuffer.getTextureFromCurrentAttachment()}}class Z extends X{constructor(t=4,e=45,i=null,s=null,r=null,n=4,a=4,o=1,h=1,l="inner",$=!1){super(),this._$blurFilter=new z(n,a,h),this._$distance=4,this._$angle=45,this._$colors=null,this._$alphas=null,this._$ratios=null,this._$strength=1,this._$type=H.INNER,this._$knockout=!1,this.distance=t,this.angle=e,this.colors=i,this.alphas=s,this.ratios=r,this.strength=o,this.type=l,this.knockout=$}static toString(){return"[class GradientBevelFilter]"}static get namespace(){return"next2d.filters.GradientBevelFilter"}toString(){return"[object GradientBevelFilter]"}get namespace(){return"next2d.filters.GradientBevelFilter"}get alphas(){return this._$colors&&this._$ratios?this._$alphas:null}set alphas(t){if(this._$alphas=null,s.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;i16777215&&(e%=16777216),t[i]=s.$toColorInt(s.$abs(e))}this._$colors=t.slice(0)}}get distance(){return this._$distance}set distance(t){(t=s.$clamp(+t,-255,255,4))!==this._$distance&&this._$doChanged(!0),this._$distance=t}get knockout(){return this._$knockout}set knockout(t){(t=!!t)!==this._$knockout&&this._$doChanged(!0),this._$knockout=t}get quality(){return this._$blurFilter._$quality}set quality(t){this._$blurFilter.quality=t}get ratios(){return this._$alphas&&this._$colors?this._$ratios:null}set ratios(t){if(this._$ratios=null,s.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;ir&&a++,0>n&&o++,0===a&&0>n&&(a=1),0===o&&0>r&&(o=1),e.x-=a,e.width+=2*a,e.y-=o,e.height+=2*o,e}_$isSame(t){if(this._$distance!==t._$distance)return!1;if(this._$angle!==t._$angle)return!1;for(let e=0;e16777215&&(e%=16777216),t[i]=s.$toColorInt(s.$abs(e))}this._$colors=t.slice(0)}}get distance(){return this._$distance}set distance(t){(t=s.$clamp(+t,-255,255,4))!==this._$distance&&this._$doChanged(!0),this._$distance=t}get knockout(){return this._$knockout}set knockout(t){(t=!!t)!==this._$knockout&&this._$doChanged(!0),this._$knockout=t}get quality(){return this._$blurFilter._$quality}set quality(t){this._$blurFilter.quality=t}get ratios(){return this._$alphas&&this._$colors?this._$ratios:null}set ratios(t){if(this._$ratios=null,s.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;i0?s.$max(0,p-u):0)+A,w=(x>0?s.$max(0,x-d):0)+M),t._$bind(i),t._$applyBitmapFilter(h,y,E,r,n,C,S,l,$,R,w,!0,this.type,this.knockout,this._$strength,this.ratios,this.colors,this.alphas,0,0,0,0,0,0,0,0),t._$offsetX=a+C,t._$offsetY=o+S,t.frameBuffer.releaseTexture(h),t.frameBuffer.getTextureFromCurrentAttachment()}}class et{static toString(){return"[class TextFormatAlign]"}static get namespace(){return"next2d.text.TextFormatAlign"}toString(){return"[object TextFormatAlign]"}get namespace(){return"next2d.text.TextFormatAlign"}static get CENTER(){return"center"}static get LEFT(){return"left"}static get RIGHT(){return"right"}}class it{static toString(){return"[class TextFieldAutoSize]"}static get namespace(){return"next2d.text.TextFieldAutoSize"}toString(){return"[object TextFieldAutoSize]"}get namespace(){return"next2d.text.TextFieldAutoSize"}static get CENTER(){return"center"}static get LEFT(){return"left"}static get NONE(){return"none"}static get RIGHT(){return"right"}}class st extends T{constructor(){super(),this._$background=!1,this._$backgroundColor=16777215,this._$border=!1,this._$borderColor=0,this._$htmlText="",this._$multiline=!1,this._$text="",this._$wordWrap=!1,this._$scrollH=0,this._$scrollV=1,this._$maxScrollV=null,this._$maxScrollH=null,this._$maxChars=0;const t=new nt;t._$setDefault(this),this._$defaultTextFormat=t,this._$decisionTextFormat=t,this._$rawHtmlText="",this._$bounds={xMin:0,xMax:100,yMin:0,yMax:100},this._$originBounds={xMin:0,xMax:100,yMin:0,yMax:100},this._$restrict=null,this._$isHTML=!1,this._$textData=null,this._$renew=!0,this._$textHeight=null,this._$textWidth=null,this._$widthTable=null,this._$textarea=null,this._$autoSize=it.NONE,this._$autoFontSize=!1,this._$textAppending=!1,this._$heightTable=null,this._$textFormatTable=[],this._$textAreaActive=!1,this._$totalWidth=null,this._$objectTable=null,this._$imageData=null,this._$scroll=!1,this._$type=rt.STATIC,this._$textHeightTable=null,this._$focus=!1,this._$isComposing=!1,this._$thickness=0,this._$thicknessColor=0,this._$verticalAlign=at.TOP}static toString(){return"[class TextField]"}static get namespace(){return"next2d.text.TextField"}toString(){return"[object TextField]"}get namespace(){return"next2d.text.TextField"}static get TEXT(){return"text"}static get BREAK(){return"break"}static get WRAP(){return"wrap"}static get IMAGE(){return"image"}get autoFontSize(){return this._$autoFontSize}set autoFontSize(t){this._$autoFontSize=!!t}get autoSize(){return this._$autoSize}set autoSize(t){switch(t){case it.CENTER:case it.LEFT:case it.RIGHT:this._$autoSize=t;break;default:this._$autoSize=it.NONE}this._$reload()}get background(){return this._$background}set background(t){this._$background=!!t,this._$reset()}get backgroundColor(){return this._$backgroundColor}set backgroundColor(t){this._$backgroundColor=s.$clamp(s.$toColorInt(t),0,16777215,16777215),this._$reset()}get border(){return this._$border}set border(t){this._$border=!!t,this._$reset()}get borderColor(){return this._$borderColor}set borderColor(t){this._$borderColor=s.$clamp(s.$toColorInt(t),0,16777215,0),this._$reset()}get defaultTextFormat(){return this._$defaultTextFormat}set defaultTextFormat(t){t instanceof nt&&(t._$merge(this._$defaultTextFormat),t._$textField=this,this._$defaultTextFormat=t)}get focus(){return this._$focus}set focus(t){if(this._$focus!==!!t)if(this._$focus=!!t,this._$focus){if(this._$type===rt.INPUT){const t=s.$currentPlayer(),e=s.$document.getElementById(t.contentElementId);if(!e)return;this._$createTextAreaElement(t._$scale);const i=this._$textarea,r=this._$transform.concatenatedMatrix,n=this._$getBounds(null),a=s.$intToRGBA(this._$defaultTextFormat._$color,100);i.style.color=`rgb(${a.R},${a.G},${a.B})`,i.style.left=(r.tx+n.xMin+t._$tx/t._$scale/s.$devicePixelRatio)*t._$scale+"px",i.style.top=(r.ty+n.yMin+t._$ty/t._$scale/s.$devicePixelRatio)*t._$scale+"px",i.style.width=`${s.$ceil((this.width-1)*t._$scale)}px`,i.style.height=`${s.$ceil((this.height-1)*t._$scale)}px`,i.value=this.text,e.appendChild(i);(0,s.$requestAnimationFrame)((()=>{i.focus()})),this._$textAreaActive=!0,this.willTrigger(l.FOCUS_IN)&&this.dispatchEvent(new l(l.FOCUS_IN)),this._$doChanged(),s.$isUpdated=!0}}else this._$textarea&&(this._$textarea.dispatchEvent(new s.$window.Event(`${s.$PREFIX}_blur`)),this.willTrigger(l.FOCUS_OUT)&&this.dispatchEvent(new l(l.FOCUS_OUT)),this._$doChanged(),s.$isUpdated=!0,this._$textarea.remove())}get htmlText(){return this._$htmlText}set htmlText(t){this._$htmlText!==t&&(this._$htmlText=`${t}`,this._$rawHtmlText="",this._$text="",this._$isHTML=!0,this._$textFormatTable=[],this._$reload())}get length(){return this.text.length}get maxChars(){return this._$maxChars}set maxChars(t){this._$maxChars=0|t}get maxScrollH(){return null===this._$maxScrollH&&(this._$maxScrollH=0),this._$maxScrollH}get maxScrollV(){if(null===this._$maxScrollV){this._$maxScrollV=1,this._$getTextData();const t=this._$textHeightTable.length,e=this.height;if(e>this.textHeight)return this._$maxScrollV;let i=0,s=0;for(;t>s&&(i+=this._$textHeightTable[s],!(i>e));)this._$maxScrollV++}return this._$maxScrollV}get multiline(){return this._$multiline}set multiline(t){this._$multiline=!!t,this._$reset()}get numLines(){return null===this._$textData&&this._$getTextData(),this._$objectTable.length}get restrict(){return this._$restrict}set restrict(t){this._$restrict=`${t}`}get scroll(){return this._$scroll}set scroll(t){this._$scroll=!!t}get scrollH(){return this._$scrollH}set scrollH(t){t=s.$clamp(0|t,0,this.maxScrollH),this._$scrollH!==t&&(this._$scrollH=t,this._$reset(),this.willTrigger(a.SCROLL)&&this.dispatchEvent(new a(a.SCROLL,!0)))}get scrollV(){return this._$scrollV}set scrollV(t){t=s.$clamp(0|t,1,this.maxScrollV),this._$scrollV!==t&&(this._$scrollV=t,this._$reset(),this.willTrigger(a.SCROLL)&&this.dispatchEvent(new a(a.SCROLL,!0)))}get text(){if(!this._$isHTML)return this._$text;if(this._$rawHtmlText)return this._$rawHtmlText;let t="";const e=this._$getTextData(),i=0|e.length;for(let s=1;s-1){const e=this._$getBounds(null),i=s.$abs(e.xMin);this._$originBounds.xMax=t+i,this._$originBounds.xMin=i,this._$bounds.xMax=this._$originBounds.xMax,this._$bounds.xMin=this._$originBounds.xMin,super.width=t,this._$reload()}}get height(){return super.height}set height(t){if(t=+t,!s.$isNaN(t)&&t>-1){const e=this._$getBounds(null),i=s.$abs(e.yMin);this._$originBounds.yMax=t+i,this._$bounds.yMax=this._$originBounds.yMax,this._$bounds.yMin=this._$originBounds.yMin,super.height=t,this._$reload()}}get x(){const t=this._$transform.matrix,e=this._$getBounds(null);return t._$matrix[4]+e.xMin}set x(t){const e=this._$getBounds(null);super.x=t-e.xMin}get y(){const t=this._$transform.matrix,e=this._$getBounds(null);return t._$matrix[5]+e.yMin}set y(t){const e=this._$getBounds(null);super.y=t-e.yMin}appendText(t){const e=this.text;this._$textAppending=!0,this.text=e+`${t}`,this._$textAppending=!1}getTextFormat(t=-1,e=-1){t|=0,e|=0;const i=this._$getTextData(),s=e>-1?e:i.length;let r=!1,n=new nt,a=t>-1?t:0;for(;at)break;r.yIndex===t&&(r.mode===st.TEXT&&(e+=r.text))}return e}replaceText(t,e,i){if(e|=0,(t|=0)>-1&&e>-1&&e>=t){const s=this.text;t>=s.length?e>=s.length&&e>=t&&(this.text=s+`${i}`):this.text=s.substr(0,t)+`${i}`+s.substr(e,s.length)}}setTextFormat(t,e=-1,i=-1){e|=0,i|=0;const s=this._$getTextData();switch(this._$reset(),!0){case-1===e&&-1===i:{const e=s.length;for(let i=0;i-1&&-1===i:{let i=e+1,r=s[i];r.mode===st.WRAP&&(r=s[++i]),this._$textFormatTable[i]=t._$clone()}break;case e>-1&&i>-1&&i>e:{let r=0;for(let n=e;n|<>)/g);i>-1&&(e=e.slice(0,i)),e=e.replace(/\r\n/g,"\r\r"),s.$P_TAG.innerHTML!==e&&(s.$P_TAG.textContent="",s.$P_TAG.insertAdjacentHTML("afterbegin",e));let r=this._$decisionTextFormat;if(this._$textData.length in this._$textFormatTable){const t=this._$textFormatTable[this._$textData.length]._$clone();t._$merge(r),r=t}this._$totalWidth=0,this._$heightTable[0]=0,this._$textHeightTable[0]=this._$getTextHeight(r),this._$widthTable[0]=0;const n={mode:st.BREAK,x:0,yIndex:0,textFormat:r._$clone()};this._$objectTable[0]=n,this._$textData[0]=n,this._$parseTag(s.$P_TAG,r._$clone(),t)}else{const e=this._$multiline?this._$text.split("\n"):[this._$text.replace("\n","")],i=e.length;for(let s=0;s0){const t=this._$imageData[this._$imageData.length-1],i=t.y+t.height+2*t.vspace;e.y=s.$max(l,i)}this._$loadImage(e),s.$loadedImages.set(t,e)}this._$textData[this._$textData.length]=e,this._$imageData[this._$imageData.length]=e}break;default:this._$parseTag(a,n,i)}else i=this._$parseText(a.nodeValue,n)}}_$loadImage(t){t.scope=this,t.image=new s.$Image,t.image.crossOrigin="anonymous",t.image.addEventListener("load",function(){this.loaded=!0,this.width||(this.width=0|this.image.width),this.height||(this.height=0|this.image.height);const t=this.scope;this.scope=null,s.$loadedImages.set(this.src,this),t._$reload()}.bind(t),!1),t.image.src=t.src}_$parseText(t,e,i){let r=this._$heightTable.length-1|0,n=e._$clone();const a=this._$transform.concatenatedMatrix._$matrix,o=(this._$originBounds.xMax-this._$originBounds.xMin)*(a[0]/a[3]);s.$poolFloat32Array6(a);const h=o-n._$widthMargin()-4;for(let a=0;ah){this._$widthTable[++r]=0,o.yIndex=r,this._$heightTable[r]=this._$heightTable[r-1],this._$textHeightTable[r]=this._$textHeightTable[r-1],this._$totalWidth=this._$getImageOffsetX(),n=n._$clone(),n._$indent=0;d={mode:l?st.BREAK:st.WRAP,x:0,yIndex:r,textFormat:n},this._$objectTable[r]=d,l||--i;let t=o.text,e=0,a=!0;const h=/[0-9a-zA-Z?!;:.,?!。、;:〜]/g;for(;t.match(h);){++e;const i=this._$textData[this._$textData.length-e];if(i.mode!==st.TEXT){a=!1;break}t=i.text}if(e>1&&this._$textData[this._$textData.length-e+1].text.match(/[0-9a-zA-Z]/g)&&--e,e>0&&a){const t=this._$textData.length-e;this._$textData.splice(t,0,d);let i=1,n=this._$textData[t-i];for(this._$widthTable[r-1]=0,this._$heightTable[r-1]=0,this._$textHeightTable[r-1]=0;n.mode===st.TEXT;)c=this._$getTextHeight(n.textFormat),u=c+$,this._$widthTable[r-1]+=n.width,this._$heightTable[r-1]=s.$max(this._$heightTable[r-1],c),this._$textHeightTable[r-1]=s.$max(this._$textHeightTable[r-1],u),++i,n=this._$textData[t-i];for(i=1;this._$textData.length>t+i;)n=this._$textData[t+i],++i,c=this._$getTextHeight(n.textFormat),u=c+$,this._$heightTable[r]=s.$max(this._$heightTable[r],c),this._$textHeightTable[r]=s.$max(this._$textHeightTable[r],u),n.x=this._$totalWidth,n.yIndex=r,this._$totalWidth+=n.width}else this._$textData[this._$textData.length]=d}l||(o.width=_,o.x=this._$totalWidth,this._$totalWidth+=_,this._$widthTable[r]=s.$max(this._$widthTable[r],this._$totalWidth),this._$heightTable[r]=s.$max(this._$heightTable[r],c),this._$textHeightTable[r]=s.$max(this._$textHeightTable[r],u),this._$textData[this._$textData.length]=o)}return i}_$getTextHeight(t){if(!s.$DIV){const t=s.$document.createElement("div");t.innerHTML="a",t.style.display="block",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.padding="0",t.style.margin="0",t.style.padding="0",t.style.border="0",t.style.outline="0",t.style.verticalAlign="bottom",t.style.lineHeight="100%",s.$DIV=t,s.$document.body.appendChild(s.$DIV)}const e=t._$size,i=t._$font,r=t._$bold?"bold":"normal",n=`${e}_${i}_${r}`;if(this._$heightCache.has(n))return this._$heightCache.get(n);const a=s.$DIV.style,o=`${e}px`;a.fontSize!==o&&(a.fontSize=o),a.fontFamily!==i&&(a.fontFamily=i),a.fontWeight!==r&&(a.fontWeight=r);const h=10>e?s.$DIV.clientHeight*e*.1:s.$DIV.clientHeight;return this._$heightCache.set(n,h),h}_$getImageOffsetX(){if(!this._$imageData.length)return 0;let t=0;for(let e=0;ethis.width)for(;this.textWidth>this.width;){if(this.defaultTextFormat.size--,1>this.defaultTextFormat.size){this.defaultTextFormat.size=1;break}this._$reset(),this._$getTextData()}if(this.height&&this.textHeight&&this.textHeight>this.height)for(;this.textHeight>this.height;){if(this.defaultTextFormat.size--,1>this.defaultTextFormat.size){this.defaultTextFormat.size=1;break}this._$reset(),this._$getTextData()}this.defaultTextFormat.size=t}this._$resize()}_$resize(){if(this._$autoSize!==it.NONE){const t=this._$defaultTextFormat,e=this.textWidth+4+t._$leftMargin+t._$rightMargin;if(this._$wordWrap)this._$bounds.xMax=this._$originBounds.xMax,this._$bounds.xMin=this._$originBounds.xMin;else switch(this._$autoSize){case it.LEFT:case it.CENTER:this._$bounds.xMax=e+this._$bounds.xMin;break;case it.RIGHT:this._$bounds.xMax=this._$originBounds.xMax-(this._$originBounds.xMax-this._$originBounds.xMin-(e-this._$originBounds.xMin))}this._$bounds.yMax=this.textHeight+4+this._$originBounds.yMin}}_$getAlignOffset(t,e){const i=this._$widthTable[t.yIndex],r=t.textFormat,n=r._$blockIndent+r._$leftMargin>0?r._$blockIndent+r._$leftMargin:0;switch(!0){case!1===this._$wordWrap&&i>e:return s.$max(0,n);case r._$align===et.CENTER:case this._$autoSize===it.CENTER:return s.$max(0,e/2-n-r._$rightMargin-i/2);case r._$align===et.RIGHT:case this._$autoSize===it.RIGHT:return s.$max(0,e-n-i-r._$rightMargin-2);default:return s.$max(0,n+2)}}_$getBounds(t=null){if(t){const e=s.$multiplicationMatrix(t,this._$correctMatrix(this._$transform._$rawMatrix()));return s.$boundsMatrix(this._$bounds,e)}return s.$boundsMatrix(this._$bounds,this._$correctMatrix(s.$MATRIX_ARRAY_IDENTITY))}_$correctMatrix(t){switch(this._$autoSize){case it.CENTER:{const e=this.textWidth+4,i=(this._$originBounds.xMax-this._$originBounds.xMin)/2-e/2;return s.$getFloat32Array6(t[0],t[1],t[2],t[3],t[4]+i,t[5])}case it.RIGHT:{const e=this.textWidth+4,i=this._$originBounds.xMax-this._$originBounds.xMin-(e-this._$originBounds.xMin);return s.$getFloat32Array6(t[0],t[1],t[2],t[3],t[4]+i,t[5])}default:return t}}_$buildCharacter(t){const e=this.defaultTextFormat;switch(e.font=t.font,e.size=0|t.size,e.align=t.align,e.color=0|t.color,e.leading=t.leading,e.letterSpacing=t.letterSpacing,e.leftMargin=t.leftMargin,e.rightMargin=t.rightMargin,t.fontType){case 1:e.bold=!0;break;case 2:e.italic=!0;break;case 3:e.bold=!0,e.italic=!0}switch(this._$type=t.inputType,this._$multiline=!!t.multiline,this._$wordWrap=!!t.wordWrap,this._$border=!!t.border,this._$scroll=!!t.scroll,this._$thickness=0|t.thickness,this._$thicknessColor=0|t.thicknessColor,this._$bounds.xMin=t.originBounds.xMin,this._$bounds.xMax=t.originBounds.xMax,this._$bounds.yMin=t.originBounds.yMin,this._$bounds.yMax=t.originBounds.yMax,this._$originBounds.xMin=t.originBounds.xMin,this._$originBounds.xMax=t.originBounds.xMax,this._$originBounds.yMin=t.originBounds.yMin,this._$originBounds.yMax=t.originBounds.yMax,t.autoSize){case 1:this.autoSize=t.align;break;case 2:this.autoFontSize=!0}this.text=t.text}_$sync(){const t=super._$sync();return t&&this._$buildCharacter(t),t}_$build(t,e){const i=super._$build(t,e);return this._$buildCharacter(i),i}_$clip(t,e){const i=this._$getBounds(),r=i.xMax,n=i.xMin,a=i.yMax,o=i.yMin;s.$poolBoundsObject(i);let h=s.$ceil(s.$abs(r-n)),l=s.$ceil(s.$abs(a-o));if(!h||!l)return;let $=e;const _=this._$transform._$rawMatrix();_!==s.$MATRIX_ARRAY_IDENTITY&&($=s.$multiplicationMatrix(e,_)),s.$resetContext(t),t.setTransform($[0],$[1],$[2],$[3],$[4],$[5]),t.beginPath(),t.moveTo(0,0),t.lineTo(h,0),t.lineTo(h,l),t.lineTo(0,l),t.lineTo(0,0),t.clip(!0),$!==e&&s.$poolFloat32Array6($)}_$draw(t,e,i){if(!this._$visible||this._$textAreaActive)return;if(!this._$background&&!this._$border&&!this.text)return;let r=i;const n=this._$transform._$rawColorTransform();n!==s.$COLOR_ARRAY_IDENTITY&&(r=s.$multiplicationColor(i,n));const a=s.$clamp(r[3]+r[7]/255,0,1);if(!a)return;let o=e;const h=this._$transform._$rawMatrix();h!==s.$MATRIX_ARRAY_IDENTITY&&(o=s.$multiplicationMatrix(e,h));const l=this._$getBounds(null);l.xMin-=this._$thickness,l.xMax+=this._$thickness,l.yMin-=this._$thickness,l.yMax+=this._$thickness;const $=s.$boundsMatrix(l,o),_=+$.xMax,c=+$.xMin,u=+$.yMax,d=+$.yMin;s.$poolBoundsObject($),s.$poolBoundsObject(l);let g=s.$ceil(s.$abs(_-c)),f=s.$ceil(s.$abs(u-d));if(!g||!f)return;if(0>c+g||0>d+f)return;const m=t.frameBuffer.currentAttachment;if(c>m.width||d>m.height)return;const p=+s.$sqrt(o[0]*o[0]+o[1]*o[1]),x=+s.$sqrt(o[2]*o[2]+o[3]*o[3]),b=s.$getArray();b[0]=p,b[1]=x;const T=s.$cacheStore(),v=T.generateKeys(this._$instanceId,b,r);let y=T.get(v);if(y&&(this._$renew||this._$isUpdated())&&(T.set(v,null),T.destroy(y),y=null),g+=4*s.$devicePixelRatio,f+=4*s.$devicePixelRatio,!y){this._$renew=!1,r[3]=1;const i=T.getCanvas();i.width=g,i.height=f;const n=i.getContext("2d");if(this._$background||this._$border){if(n.beginPath(),n.rotate(s.$atan2(e[1],e[0])),n.moveTo(0,0),n.lineTo(g,0),n.lineTo(g,f),n.lineTo(0,f),n.lineTo(0,0),this._$background){const t=s.$generateColorTransform(s.$intToRGBA(this._$backgroundColor),r);n.fillStyle=`rgba(${t.R},${t.G},${t.B},${t.A})`,n.fill()}if(this._$border){const t=s.$generateColorTransform(s.$intToRGBA(this._$borderColor),r);n.lineWidth=1,n.strokeStyle=`rgba(${t.R},${t.G},${t.B},${t.A})`,n.stroke()}}n.save(),n.beginPath();const a=s.$atan2(e[1],e[0]);a&&n.rotate(a),n.moveTo(2,2),n.lineTo(g-2,2),n.lineTo(g-2,f-2),n.lineTo(2,f-2),n.lineTo(2,2),n.clip(),n.beginPath(),n.setTransform(e[0],e[1],e[2],e[3],0,0),this._$doDraw(n,e,r,!1,g/e[0]),n.restore(),y=t.frameBuffer.createTextureFromCanvas(n.canvas),T.set(v,y),T.destroy(n)}s.$poolArray(v),s.$poolArray(b);let E=!1,A=0,M=0;const C=this._$filters||this.filters;if(C&&C.length){const r=this._$canApply(C);if(r){E=!0;const n=[this._$instanceId,"f"];let a=s.$cacheStore().get(n);const o=this._$isFilterUpdated(g,f,e,i,C,r);a&&!o||(a&&(s.$cacheStore().set(n,null),a.layerWidth=0,a.layerHeight=0,a._$offsetX=0,a._$offsetY=0,a.matrix=null,a.colorTransform=null,t.frameBuffer.releaseTexture(a),a=null),y=this._$getFilterTexture(t,C,y,e,i),s.$cacheStore().set(n,y)),a&&(y=a),s.$poolArray(n),A=y._$offsetX,M=y._$offsetY}}s.$resetContext(t),t._$globalAlpha=a,t._$globalCompositeOperation=this._$blendMode||this.blendMode,t.setTransform(1,0,0,1,0,0),E?t.drawImage(y,c-A,d-M,y.width,y.height,r):t.drawImage(y,c,d,g,f,r)}_$doDraw(t,e,i,r,n){const a=this._$getTextData(),o=r?0:this.width,h=r?0:this.height;let l=0,$=0,_=0,c=0;if(this._$verticalAlign!==at.TOP&&this.height>this.textHeight)switch(this._$verticalAlign){case at.MIDDLE:c=(this.height-this.textHeight+2)/2;break;case at.BOTTOM:c=this.height-this.textHeight+2}const u=a.length;for(let d=0;dh||g>o))continue;let f=u.textFormat;if(!r){const e=s.$generateColorTransform(s.$intToRGBA(u.textFormat._$color),i);if(t.fillStyle=`rgba(${e.R},${e.G},${e.B},${e.A})`,this._$thickness){const e=s.$generateColorTransform(s.$intToRGBA(this._$thicknessColor),i);t.lineWidth=this._$thickness,t.strokeStyle=`rgba(${e.R},${e.G},${e.B},${e.A})`}}const m=0|u.yIndex;switch(u.mode){case st.BREAK:case st.WRAP:if(_++,this.scrollV>_)continue;if($+=this._$textHeightTable[m],l=this._$getAlignOffset(this._$objectTable[m],n),f._$underline){const r=u.textFormat._$size/12,n=s.$generateColorTransform(s.$intToRGBA(f._$color),i);t.lineWidth=s.$max(1,1/s.$min(e[0],e[3])),t.strokeStyle=`rgba(${n.R},${n.G},${n.B},${n.A})`,t.beginPath(),t.moveTo(l,c+$-r),t.lineTo(l+this._$widthTable[m],c+$-r),t.stroke()}break;case st.TEXT:{if(this.scrollV>_)continue;let e=$-this._$heightTable[0];s.$isSafari||(e+=u.textFormat._$size/12*2),t.beginPath(),t.textBaseline="top",t.font=f._$generateFontStyle(),this._$thickness&&t.strokeText(u.text,g,c+e),t.fillText(u.text,g,c+e)}break;case st.IMAGE:if(!u.loaded)continue;t.beginPath(),t.drawImage(u.image,u.hspace,c+u.y,u.width,u.height)}}}_$mouseHit(t,e,i){return!!this._$visible&&this._$hit(t,e,i)}_$hit(t,e,i){let r=e;const n=this._$transform._$rawMatrix();n!==s.$MATRIX_ARRAY_IDENTITY&&(r=s.$multiplicationMatrix(e,n));const a=this._$getBounds(null),o=s.$boundsMatrix(a,r),h=+o.xMax,l=+o.xMin,$=+o.yMax,_=+o.yMin;s.$poolBoundsObject(o),s.$poolBoundsObject(a);const c=s.$ceil(s.$abs(h-l)),u=s.$ceil(s.$abs($-_));return t.setTransform(1,0,0,1,l,_),t.beginPath(),t.moveTo(0,0),t.lineTo(c,0),t.lineTo(c,u),t.lineTo(0,u),t.lineTo(0,0),r!==e&&s.$poolFloat32Array6(r),t.isPointInPath(i.x,i.y)}_$createTextAreaElement(t){if(!this._$textarea){this._$textarea=s.$document.createElement("textarea"),this._$textarea.value=this.text,this._$textarea.id=`${s.$PREFIX}_TextField_${this._$instanceId}`,this._$wordWrap||(this._$textarea.wrap="off");const t=this.defaultTextFormat;if(this._$textarea.style.position="absolute",this._$textarea.style.outline="0",this._$textarea.style.padding=`2px 2px 2px ${s.$max(3,0|t.leftMargin)}px`,this._$textarea.style.margin="0",this._$textarea.style.appearance="none",this._$textarea.style.resize="none",this._$textarea.style.border=this._$border?`solid 1px #${this.borderColor.toString(16)}`:"none",this._$textarea.style.overflow="hidden",this._$textarea.style.zIndex=2147483647,this._$textarea.style.verticalAlign="top",this._$textarea.style.backgroundColor=this._$border||this._$background?`#${this.backgroundColor.toString(16)}`:"transparent",this._$textarea.addEventListener(`${s.$PREFIX}_blur`,function(t){let e=t.target.value?t.target.value:"";if(e&&this._$restrict){let t=this._$restrict;"["!==t[0]&&(t="["+t),"]"!==t[t.length-1]&&(t+="]");const i=e.match(new s.$RegExp(t,"gm"));e=i?i.join(""):""}this.text=e;if(s.$document.getElementById(s.$currentPlayer().contentElementId)){const t=s.$document.getElementById(`${s.$PREFIX}_TextField_${this._$instanceId}`);t&&(t.remove(),this._$focus=!1,this._$textAreaActive=!1,s.$isUpdated=!0,this._$doChanged())}}.bind(this)),this._$textarea.addEventListener("input",function(t){let e=t.target.value?t.target.value:"";if(this._$restrict&&!this._$isComposing&&e){let t=this._$restrict;"["!==t[0]&&(t="["+t),"]"!==t[t.length-1]&&(t+="]");const i=e.match(new s.$RegExp(t,"gm"));e=i?i.join(""):""}if(!this._$isComposing&&this.text!==e){this.text=e,t.target.value=e,this.willTrigger(a.CHANGE)&&this.dispatchEvent(new a(a.CHANGE,!0));const i=s.$currentPlayer(),r=this._$textarea,n=this._$transform.concatenatedMatrix,o=this._$getBounds(null);r.style.left=`${s.$floor((n.tx+o.xMin+i._$tx/i._$scale/s.$devicePixelRatio)*i._$scale)}px`,r.style.top=`${s.$floor((n.ty+o.yMin+i._$ty/i._$scale/s.$devicePixelRatio)*i._$scale)}px`,r.style.width=`${s.$ceil((this.width-1)*i._$scale)}px`,r.style.height=`${s.$ceil((this.height-1)*i._$scale)}px`}}.bind(this)),this._$textarea.addEventListener("compositionstart",function(){this._$isComposing=!0}.bind(this)),this._$textarea.addEventListener("compositionend",function(t){this._$isComposing=!1;let e=t.target.value?t.target.value:"";if(!this._$restrict||!e)return;let i=this._$restrict;"["!==i[0]&&(i="["+i),"]"!==i[i.length-1]&&(i+="]");const r=e.match(new s.$RegExp(i,"gm"));e=r?r.join(""):"",this.text=e,t.target.value=e}.bind(this)),this._$textarea.addEventListener("click",function(){this.willTrigger(c.CLICK)&&this.dispatchEvent(new c(c.CLICK))}.bind(this)),this._$textarea.addEventListener(s.$MOUSE_WHEEL,function(t){this.scrollV+=t.deltaY}.bind(this)),this._$textarea.addEventListener(s.$SCROLL,function(){if(this._$scrollEventLock)return void(this._$scrollEventLock=!1);const t=parseFloat(this._$textarea.style.height);this.scrollV=this._$textarea.scrollTop/(this._$textarea.scrollHeight-t)*this.maxScrollV+1}.bind(this)),!0===s.$isTouch)this._$textarea.addEventListener(s.$TOUCH_START,(function(){const t=s.$currentPlayer();t&&(t._$state="down")})),this._$textarea.addEventListener(s.$TOUCH_END,(function(){const t=s.$currentPlayer();t&&(t._$state="up")}));else this._$textarea.addEventListener(s.$MOUSE_DOWN,(function(){const t=s.$currentPlayer();t&&(t._$state="down")})),this._$textarea.addEventListener(s.$MOUSE_UP,(function(){const t=s.$currentPlayer();t&&(t._$state="up")}))}const e=this.defaultTextFormat,i=s.$ceil(e.size*t*this._$transform.concatenatedMatrix.d);this._$textarea.style.fontSize=`${i}px`,this._$textarea.style.fontFamily=e.font,this._$textarea.style.lineHeight=(i+s.$max(0,0|e.leading))/i+"em",this._$autoSize!==it.NONE?this._$textarea.style.textAlign=it.CENTER:this._$textarea.style.textAlign=e.align,this._$textarea.onkeydown||(this._$textarea.onkeydown=function(t){let e=t.target.value?t.target.value:"";if(this._$restrict&&!this._$isComposing&&e){let t=this._$restrict;"["!==t[0]&&(t="["+t),"]"!==t[t.length-1]&&(t+="]");const i=e.match(new s.$RegExp(t,"gm"));e=i?i.join(""):""}if(this._$isComposing||(this.text=e,t.target.value=e),13===t.keyCode&&!this._$multiline)return!1}.bind(this)),this._$textarea.maxLength=2147483647,this._$maxChars&&(this._$textarea.maxLength=this._$maxChars)}}class rt{static toString(){return"[class TextFieldType]"}static get namespace(){return"next2d.text.TextFieldType"}toString(){return"[object TextFieldType]"}get namespace(){return"next2d.text.TextFieldType"}static get INPUT(){return"input"}static get STATIC(){return"static"}}class nt{constructor(t=null,e=null,i=null,r=null,n=null,a=null,o=null,h=null,l=null,$=null,_=null,c=null){this._$font=t,this._$size=e,this._$color=null===i?null:s.$clamp(s.$toColorInt(i),0,16777215,16777215),this._$bold=r,this._$italic=n,this._$underline=a,this._$align=o,this._$leftMargin=h,this._$rightMargin=l,this._$indent=$,this._$leading=_,this._$blockIndent=c,this._$letterSpacing=0,this._$textField=null}static toString(){return"[class TextFormat]"}static get namespace(){return"next2d.text.TextFormat"}toString(){return"[object TextFormat]"}get namespace(){return"next2d.text.TextFormat"}get align(){return this._$align}set align(t){switch(t){case et.CENTER:case et.RIGHT:case et.LEFT:this._$align=t;break;default:this._$align=null}this._$textField&&(this._$textField._$renew=!0)}get blockIndent(){return this._$blockIndent}set blockIndent(t){this._$blockIndent=t,this._$textField&&(this._$textField._$renew=!0)}get bold(){return this._$bold}set bold(t){this._$bold=!!t,this._$textField&&(this._$textField._$renew=!0)}get color(){return this._$color}set color(t){this._$color=s.$clamp(s.$toColorInt(t),0,16777215,0),this._$textField&&(this._$textField._$renew=!0)}get font(){return this._$font}set font(t){this._$font=`${t}`,this._$textField&&(this._$textField._$renew=!0)}get indent(){return this._$indent}set indent(t){this._$indent=t,this._$textField&&(this._$textField._$renew=!0)}get italic(){return this._$italic}set italic(t){this._$italic=!!t,this._$textField&&(this._$textField._$renew=!0)}get leading(){return this._$leading}set leading(t){this._$leading=t,this._$textField&&(this._$textField._$renew=!0)}get leftMargin(){return this._$leftMargin}set leftMargin(t){this._$leftMargin=t,this._$textField&&(this._$textField._$renew=!0)}get letterSpacing(){return this._$letterSpacing}set letterSpacing(t){this._$letterSpacing=t,this._$textField&&(this._$textField._$renew=!0)}get rightMargin(){return this._$rightMargin}set rightMargin(t){this._$rightMargin=t,this._$textField&&(this._$textField._$renew=!0)}get size(){return this._$size}set size(t){this._$size=0|t,this._$textField&&(this._$textField._$renew=!0)}get underline(){return this._$underline}set underline(t){this._$underline=!!t,this._$textField&&(this._$textField._$renew=!0)}_$clone(){const t=new nt(this._$font,this._$size,this._$color,this._$bold,this._$italic,this._$underline,this._$align,this._$leftMargin,this._$rightMargin,this._$indent,this._$leading,this._$blockIndent);return t._$letterSpacing=this._$letterSpacing,t._$textField=this._$textField,t}_$setDefault(t=null){this._$align=et.LEFT,this._$blockIndent=0,this._$bold=!1,this._$color=0,this._$font="Times New Roman",this._$indent=0,this._$italic=!1,this._$leading=0,this._$leftMargin=0,this._$letterSpacing=0,this._$rightMargin=0,this._$size=12,this._$underline=!1,this._$textField=t}_$merge(t){null===this._$align&&(this._$align=t._$align),null===this._$blockIndent&&(this._$blockIndent=t._$blockIndent),null===this._$bold&&(this._$bold=t._$bold),null===this._$color&&(this._$color=t.color),null===this._$font&&(this._$font=t._$font),null===this._$indent&&(this._$indent=t._$indent),null===this._$italic&&(this._$italic=t._$italic),null===this._$leading&&(this._$leading=t._$leading),null===this._$leftMargin&&(this._$leftMargin=t._$leftMargin),null===this._$letterSpacing&&(this._$letterSpacing=t._$letterSpacing),null===this._$rightMargin&&(this._$rightMargin=t._$rightMargin),null===this._$size&&(this._$size=t._$size),null===this._$underline&&(this._$underline=t._$underline)}_$widthMargin(){return this._$indent+this._$leftMargin+this._$rightMargin}_$generateFontStyle(){let t="";return this._$italic&&(t="italic "),this._$bold&&(t+="bold "),`${t}${this._$size}px '${this._$font}','sans-serif'`}}class at{static toString(){return"[class TextFormatVerticalAlign]"}static get namespace(){return"next2d.text.TextFormatVerticalAlign"}toString(){return"[object TextFormatVerticalAlign]"}get namespace(){return"next2d.text.TextFormatVerticalAlign"}static get TOP(){return"top"}static get MIDDLE(){return"middle"}static get BOTTOM(){return"bottom"}}class ot extends o{constructor(){super(),this._$bytesLoaded=0,this._$bytesTotal=0,this._$buffer=null,this._$audioBuffer=null,this._$character=null,this._$sources=s.$getArray(),this._$volume=1,this._$loop=!1,this._$stopFlag=!0}static toString(){return"[class Sound]"}static get namespace(){return"next2d.media.Sound"}toString(){return"[object Sound]"}get namespace(){return"next2d.media.Sound"}get bytesLoaded(){return this._$bytesLoaded}get bytesTotal(){return this._$bytesTotal}get loop(){return this._$loop}set loop(t){this._$loop=t}get volume(){return this._$volume}set volume(t){this._$volume=s.$min(ht.volume,s.$clamp(t,0,1,1));const e=this._$sources.length;if(e&&s.$audioContext)for(let t=0;tt.target.status?(this._$buffer=new Uint8Array(t.target.response),s.$audioContext?s.$decodeAudioData(this):s.$audios.push(this),s.$currentPlayer()._$loaders.push(this)):this.willTrigger(_.IO_ERROR)&&this.dispatchEvent(new _(_.IO_ERROR,!1,!1,t.target.statusText,t.target.status))}.bind(this)}})}play(t=0){const e=this._$character?this._$character.audioBuffer:this._$audioBuffer;if(s.$audioContext&&e)this._$createBufferSource(t);else{const e=function(t,i=0){if(null!==(this._$character?this._$character.audioBuffer:this._$audioBuffer)&&null!==s.$audioContext){const e=(s.$performance.now()-t)/1e3;return void this._$createBufferSource(i,e)}(0,s.$requestAnimationFrame)(e)}.bind(this,s.$performance.now(),t);(0,s.$requestAnimationFrame)(e)}}stop(){this._$stopFlag=!0;const t=this._$sources.length;if(t){const e=s.$currentPlayer();if(s.$audioContext)for(let e=0;e=this._$duration&&(this.removeEventListener(a.ENTER_FRAME,this._$update),this.hasEventListener(a.COMPLETE)&&this.dispatchEvent(new a(a.COMPLETE))))}updateProperty(t,e,i,s){for(let r=0;rthis._$currentTime?t[a]=this._$ease(this._$currentTime,h,i[a]-h,this._$duration):t[a]=i[a]}}}class mt{static toString(){return"[class Tween]"}static get namespace(){return"next2d.ui.Tween"}toString(){return"[object Tween]"}get namespace(){return"next2d.ui.Tween"}static add(t,e,i,s=0,r=1,n=null){return new ft(t,e,i,s,r,n)}}class pt{constructor(){this._$pool=s.$getArray(),this._$poolBitmapData=s.$getArray(),this._$store=s.$getMap(),this._$lifeCount=2,this._$delayLifeCheck=this.lifeCheck.bind(this);(0,s.$setTimeout)(this._$delayLifeCheck,5e3)}reset(){const t=this._$store.values();for(const e of t){const t=e.values();for(const e of t)this.destroy(e);s.$poolMap(e)}this._$store.clear()}destroy(t){if(t)switch(t.constructor){case s.$WebGLTexture:{const e=s.$currentPlayer();if(e._$context){const i=e._$context,s=t._$bitmapData;s&&(s._$getPixelsAsync(0,0,s.width,s.height,"RGBA"),this._$poolBitmapData.push(s),t._$bitmapData=!1),i.frameBuffer.releaseTexture(t)}}break;case s.$CanvasRenderingContext2D:{const e=t.canvas,i=e.width,s=e.height;t.clearRect(0,0,i+1,s+1),e.width=e.height=1,this._$pool.push(e)}}}getCanvas(){return this._$pool.pop()||s.$document.createElement("canvas")}removeCache(t){if(t=`${t}`,this._$store.has(t)){const e=this._$store.get(t),i=e.values();for(const t of i)this.destroy(t);s.$poolMap(e),this._$store.delete(t)}}generateLifeKey(t,e){return`${t}:${e}`}get(t){const e=`${t[0]}`,i=`${t[1]}`;if(this._$store.has(e)){const t=this._$store.get(e);if(t.has(i)){const e=`life_${i}`;return 1===t.has(e)&&t.set(e,this._$lifeCount),t.get(i)}}return null}set(t,e){const i=`${t[0]}`,r=`${t[1]}`;this._$store.has(i)||this._$store.set(i,s.$getMap());const n=this._$store.get(i);if(!e)return n.delete(r),n.delete(`life_${r}`),void(n.size||(s.$poolMap(n),this._$store.delete(i)));const a=n.get(r);a&&a!==e&&this.destroy(a),n.set(r,e),n.set(`life_${r}`,this._$lifeCount)}generateShapeKeys(t,e,i=null){let r="";switch(!0){case 1!==e[0]:case 0!==e[1]:case 0!==e[2]:case 1!==e[3]:r=`${e[0]}_${e[1]}_${e[2]}_${e[3]}`}i&&(r+=this.colorToString(i));const n=s.$getArray();return n[0]=`${t}`,n[1]=r?this.generateHash(r):"_0",n}generateKeys(t,e=null,i=null){let r="";e&&(r+=`${e[0]}_${e[1]}`),i&&(r+=this.colorToString(i));const n=s.$getArray();return n[1]=r?this.generateHash(r):"_0",n[0]=`${t}`,n}colorToString(t=null){switch(!0){case 1!==t[0]:case 1!==t[1]:case 1!==t[2]:case 0!==t[4]:case 0!==t[5]:case 0!==t[6]:case 0!==t[7]:return`_${t[0]}_${t[1]}_${t[2]}_${t[4]}_${t[5]}_${t[6]}_${t[7]}`;default:return""}}generateHash(t){let e=0;const i=t.length;for(let s=0;s 0.0) {\n ${t.fragColor()} = vec4(min(alpha, 1.0));\n } else {\n discard;\n } \n}\n\n`}}class Tt{static FILL_COLOR(t){return`${t.version()}\nprecision mediump float;\n\nuniform vec4 u_mediump;\n\n${t.outColor()}\n\nvoid main() {\n ${t.fragColor()} = u_mediump;\n}\n\n`}static COPY_SRC_TEX(t){return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\n\n${t.varyingIn()} vec2 v_src_tex_coord;\n${t.outColor()}\n\nvoid main() {\n ${t.fragColor()} = ${t.texture2D()}(u_src_tex, v_src_tex_coord);\n}\n\n`}static COPY_CHANNEL(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\nuniform vec4 u_mediump[2];\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.varyingIn()} vec2 v_dst_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 src_ch = u_mediump[0];\n vec4 dst_ch = u_mediump[1];\n\n vec4 src_color = ${e.texture2D()}(u_textures[0], v_src_tex_coord);\n vec4 dst_color = ${e.texture2D()}(u_textures[1], v_dst_tex_coord);\n\n src_color = vec4(src_color.rgb/max(0.0001, src_color.a), src_color.a);\n dst_color = vec4(dst_color.rgb/max(0.0001, dst_color.a), dst_color.a);\n\n // src_color から必要なチャンネルのスカラー値を取り出したもの\n float src_value = dot(src_color, src_ch);\n\n // コピー先の他のチャンネルと合成\n vec4 mixed = mix(dst_color, vec4(src_value), dst_ch);\n\n#if ${t}\n ${e.fragColor()} = vec4(mixed.rgb * mixed.a, mixed.a);\n#else\n ${e.fragColor()} = vec4(mixed.rgb, 1.0);\n#endif\n}\n\n`}static MERGE(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\nuniform vec4 u_mediump;\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.varyingIn()} vec2 v_dst_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 src_color = ${e.texture2D()}(u_textures[0], v_src_tex_coord);\n vec4 dst_color = ${e.texture2D()}(u_textures[1], v_dst_tex_coord);\n\n src_color = vec4(src_color.rgb/max(0.0001, src_color.a), src_color.a);\n dst_color = vec4(dst_color.rgb/max(0.0001, dst_color.a), dst_color.a);\n\n vec4 merged = mix(dst_color, src_color, u_mediump);\n\n#if ${t}\n ${e.fragColor()} = vec4(merged.rgb * merged.a, merged.a);\n#else\n ${e.fragColor()} = vec4(merged.rgb, 1.0);\n#endif\n}\n\n`}static COPY_PIXELS_WITH_ALPHA_BITMAP_DATA(t){return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\n\n${t.varyingIn()} vec2 v_src_tex_coord;\n${t.varyingIn()} vec2 v_alpha_tex_coord;\n${t.outColor()}\n\nvoid main() {\n vec4 src_color = ${t.texture2D()}(u_textures[0], v_src_tex_coord);\n float alpha = ${t.texture2D()}(u_textures[1], v_alpha_tex_coord).a;\n\n src_color = vec4(src_color.rgb/max(0.0001, src_color.a), src_color.a);\n alpha *= src_color.a;\n\n ${t.fragColor()} = vec4(src_color.rgb * alpha, alpha);\n}\n\n`}static PALETTE_MAP(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 src_color = ${e.texture2D()}(u_textures[0], v_src_tex_coord);\n src_color = vec4(src_color.rgb/max(0.0001, src_color.a), src_color.a);\n\n // ↓ 256*4のテクスチャの画素の中心をサンプリング\n vec4 map_r = ${e.texture2D()}(u_textures[1], vec2((0.5+src_color.r*255.0)/256.0, 0.125));\n vec4 map_g = ${e.texture2D()}(u_textures[1], vec2((0.5+src_color.g*255.0)/256.0, 0.375));\n vec4 map_b = ${e.texture2D()}(u_textures[1], vec2((0.5+src_color.b*255.0)/256.0, 0.625));\n vec4 map_a = ${e.texture2D()}(u_textures[1], vec2((0.5+src_color.a*255.0)/256.0, 0.875));\n\n // u_plt_tex(u_textures[1]) のパレットデータは BGRA で格納されているので、これを取り出すには .bgra\n // TODO プラットフォームのバイトオーダーがビッグエンディアンの場合は ARGB で格納されるので、これを取り出すには .gbar\n vec4 color = (map_r + map_g + map_b + map_a).bgra;\n\n // fract は 1.0, 2.0, ... のときに 0.0 を返すが 1.0 が欲しい\n vec4 color_fract = fract(color);\n color = color_fract + sign(color) - sign(color_fract);\n\n#if ${t}\n ${e.fragColor()} = vec4(color.rgb * color.a, color.a);\n#else\n ${e.fragColor()} = vec4(color.rgb, 1.0);\n#endif\n}\n\n`}static PIXEL_DISSOLVE_TEXTURE(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 src_color = ${e.texture2D()}(u_src_tex, v_src_tex_coord);\n\n#if ${t}\n ${e.fragColor()} = src_color;\n#else\n ${e.fragColor()} = vec4(src_color.rgb, 1.0);\n#endif\n}\n\n`}static COLOR_TRANSFORM(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\nuniform vec4 u_mediump[2];\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 ct_mul = u_mediump[0];\n vec4 ct_add = u_mediump[1];\n\n vec4 src_color = ${e.texture2D()}(u_src_tex, v_src_tex_coord);\n src_color = vec4(src_color.rgb/max(0.0001, src_color.a), src_color.a);\n\n vec4 color = clamp(ct_mul * src_color + ct_add, 0.0, 1.0);\n\n color = vec4(color.rgb * color.a, color.a);\n\n#if !${t}\n color.a = 1.0;\n#endif\n\n ${e.fragColor()} = color * sign(src_color.a); // 元の色が無色透明の場合、結果も常に無色透明になる。\n}\n\n`}static bitwiseAnd(){return"\n#if __VERSION__ < 130\n// 8bitまでの整数どうしのビット積\nint bitwiseAnd(int a, int b) {\n //ivec4 c1 = ivec4(1,2,4,8);\n //ivec4 c2 = ivec4(16,32,64,128);\n\n //ivec4 a1 = ivec4(a) / c1;\n //ivec4 a2 = ivec4(a) / c2;\n //ivec4 b1 = ivec4(b) / c1;\n //ivec4 b2 = ivec4(b) / c2;\n\n //ivec4 r = (a1-a1/2*2) * (b1-b1/2*2) * c1\n // + (a2-a2/2*2) * (b2-b2/2*2) * c2;\n\n //return r.x + r.y + r.z + r.w;\n\n // ↑ intのままで計算した場合(rakusanの開発環境ではintの方が遅かった)\n // ↓ floatに変換してから計算した場合\n\n vec4 a0 = vec4(float(a));\n vec4 b0 = vec4(float(b));\n vec4 a1 = floor(a0 * vec4(1.0, 0.5, 0.25, 0.125));\n vec4 a2 = floor(a0 * vec4(0.0625, 0.03125, 0.015625, 0.0078125));\n vec4 b1 = floor(b0 * vec4(1.0, 0.5, 0.25, 0.125));\n vec4 b2 = floor(b0 * vec4(0.0625, 0.03125, 0.015625, 0.0078125));\n\n return int(dot((a1-floor(a1*0.5)*2.0)*(b1-floor(b1*0.5)*2.0), vec4(1.0,2.0,4.0,8.0))\n + dot((a2-floor(a2*0.5)*2.0)*(b2-floor(b2*0.5)*2.0), vec4(16.0,32.0,64.0,128.0)));\n}\n\nivec4 bitwiseAnd(ivec4 a, ivec4 b) {\n return ivec4(bitwiseAnd(a.r, b.r),\n bitwiseAnd(a.g, b.g),\n bitwiseAnd(a.b, b.b),\n bitwiseAnd(a.a, b.a));\n}\n#else\n#define bitwiseAnd(a, b) ((a)&(b))\n#endif\n"}static THRESHOLD(t,e,i,s){return e|=0,i|=0,`${s.version()}\n#if __VERSION__ < 130\n#extension GL_EXT_draw_buffers : require\n#endif\n\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\nuniform vec4 u_mediump[2]; // u_threshold(u_mediump[0]) はJS側でマスク済み\nuniform ivec4 u_integer;\n\n${s.varyingIn()} vec2 v_src_tex_coord;\n\n#if __VERSION__ < 130\n#define outColor0 gl_FragData[0]\n#define outColor1 gl_FragData[1]\n#else\nlayout (location = 0) out vec4 outColor0;\nlayout (location = 1) out vec4 outColor1;\n#endif\n\n${Tt.bitwiseAnd()}\n\nbool less(vec4 x) {\n return dot(sign(x - u_mediump[0]), vec4(4.0, 2.0, 1.0, 8.0)) < 0.0;\n}\n\nbool greater(vec4 x) {\n return dot(sign(x - u_mediump[0]), vec4(4.0, 2.0, 1.0, 8.0)) > 0.0;\n}\n\nbool lessEqual(vec4 x) {\n return !greater(x);\n}\n\nbool greaterEqual(vec4 x) {\n return !less(x);\n}\n\n// 組込関数に equal があるので thresholdEqual にしている。\nbool thresholdEqual(vec4 x) {\n return all(equal(x, u_mediump[0]));\n}\n\n// 組込関数に notEqual があるので thresholdNotEqual にしている。\nbool thresholdNotEqual(vec4 x) {\n return any(notEqual(x, u_mediump[0]));\n}\n\nvoid main() {\n // 乗算済みのままで比較するとFlash Playerと一致する。\n\n vec4 src_color = ${s.texture2D()}(u_src_tex, v_src_tex_coord);\n ivec4 masked = bitwiseAnd(ivec4(src_color * 255.0), u_integer);\n\n if (${t}(vec4(masked))) {\n outColor0 = u_mediump[1];\n outColor1 = vec4(1.0);\n } else {\n#if ${e}\n #if ${i}\n outColor0 = src_color;\n #else\n outColor0 = vec4(src_color.rgb, 1.0);\n #endif\n outColor1 = vec4(0.0);\n#else\n discard;\n#endif\n }\n}\n\n`}static THRESHOLD_SUBTOTAL(t){return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\nuniform vec4 u_mediump;\n\n${t.varyingIn()} vec2 v_src_tex_coord;\n${t.outColor()}\n\nvoid main() {\n vec2 src_tex_step = u_mediump.xy;\n float subtotal_loop = u_mediump.z;\n\n float subtotal = 0.0;\n\n#if __VERSION__ < 130\n float j = 0.0;\n for (float i = 0.0; i < 4095.0; ++i) { // この 4095.0 というマジックナンバーについては\n if (j++ >= subtotal_loop) { // BitmapData.prototype.threshold のコメントを見てください。\n break;\n }\n#else\n for (float i = 0.0; i < subtotal_loop; ++i) {\n#endif\n subtotal += ${t.texture2D()}(u_src_tex, v_src_tex_coord + src_tex_step * i).a;\n }\n\n vec4 v1 = floor(subtotal * vec4(1.0, 0.00390625, 0.0000152587890625, 5.960464477539063e-8)); // vec4(1.0, 1.0/256.0, 1.0/65536.0, 1.0/16777216.0)\n vec4 v2 = vec4(v1.yzw, 0.0);\n ${t.fragColor()} = (v1 - v2*256.0) * 0.00392156862745098; // 1.0/255.0\n}\n\n`}static GET_COLOR_BOUNDS_RECT(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\nuniform vec4 u_mediump;\nuniform ivec4 u_integer[2];\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\n${Tt.bitwiseAnd()}\n\nvoid main() {\n vec2 src_tex_step = u_mediump.xy;\n float scan_loop = u_mediump.z;\n ivec4 mask = u_integer[0];\n ivec4 color = u_integer[1];\n\n float found = 0.0;\n\n#if __VERSION__ < 130\n float j = 0.0;\n for (float i = 0.0; i < 8191.0; ++i) { // BitmapData の幅または高さの最大サイズは 8191 ピクセル\n if (j++ >= scan_loop) {\n break;\n }\n#else\n for (float i = 0.0; i < scan_loop; ++i) {\n#endif\n vec4 src_color = ${e.texture2D()}(u_src_tex, v_src_tex_coord + src_tex_step * i);\n ivec4 masked = bitwiseAnd(ivec4(src_color * 255.0), mask);\n\n#if ${t}\n if (all(equal(masked, color))) {\n#else\n if (any(notEqual(masked, color))) {\n#endif\n found = 1.0;\n break;\n }\n }\n\n ${e.fragColor()} = vec4(found);\n}\n\n`}static NOISE(t){return`${t.version()}\nprecision mediump float;\n\nuniform vec4 u_mediump[3];\n\n${t.outColor()}\n\n// https://stackoverflow.com/a/28095165\n//\n// Gold Noise ©2015 dcerisano@standard3d.com\n// - based on the Golden Ratio\n// - uniform normalized distribution\n// - fastest static noise generator function (also runs at low precision)\n\nfloat PHI = 1.61803398874989484820459; // Φ = Golden Ratio\n\nvec4 gold_noise(vec2 xy, vec4 seed) {\n return fract(tan(distance(xy*PHI, xy)*seed)*xy.x);\n}\n\nvoid main() {\n vec4 seed = u_mediump[0];\n vec4 amp = u_mediump[1];\n vec4 low = u_mediump[2];\n\n vec4 noise = gold_noise(gl_FragCoord.xy, seed);\n vec4 color = noise * amp + low;\n ${t.fragColor()} = vec4(color.rgb * color.a, color.a);\n}\n\n`}static GET_PIXELS(t,e){switch(t){case"RGBA":t=1;break;case"BGRA":t=2;break;default:t=0}return`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 color = ${e.texture2D()}(u_src_tex, v_src_tex_coord);\n\n#if ${t} == 1 // RGBA\n ${e.fragColor()} = vec4(color.rgb / max(0.0001, color.a), color.a);\n#elif ${t} == 2 // BGRA\n ${e.fragColor()} = vec4(color.bgr / max(0.0001, color.a), color.a);\n#else // ARGB\n ${e.fragColor()} = vec4(color.a, color.rgb / max(0.0001, color.a));\n#endif\n}\n\n`}static SET_PIXELS(t,e){switch(t){case"RGBA":t=1;break;case"BGRA":t=2;break;default:t=0}return`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 color = ${e.texture2D()}(u_src_tex, v_src_tex_coord);\n\n#if ${t} == 1 // RGBA\n ${e.fragColor()} = vec4(color.rgb * color.a, color.a);\n#elif ${t} == 2 // BGRA\n ${e.fragColor()} = vec4(color.bgr * color.a, color.a);\n#else // ARGB\n ${e.fragColor()} = vec4(color.gba * color.r, color.r);\n#endif\n}\n\n`}static SET_PIXEL_QUEUE(t){return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_dst_tex;\n\n${t.varyingIn()} vec2 v_dst_tex_coord;\n${t.varyingIn()} vec4 v_color;\n${t.outColor()}\n\nvoid main() {\n float da = ${t.texture2D()}(u_dst_tex, v_dst_tex_coord).a;\n float a = v_color.a;\n\n ${t.fragColor()} = max( a, 0.0) * v_color\n + max(-a, 0.0) * vec4(v_color.rgb * da, da);\n}\n\n`}}class vt{static TEMPLATE(t,e){const i=e?"uniform vec4 u_mediump[2];":"",s=e?xt.STATEMENT_COLOR_TRANSFORM_ON(0):"";return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_texture;\n${i}\n\n${t.varyingIn()} vec2 v_coord;\n${t.outColor()}\n\nvoid main() {\n vec4 src = ${t.texture2D()}(u_texture, v_coord);\n ${s}\n ${t.fragColor()} = src;\n}\n\n`}}class yt{constructor(t,e,i){this._$context=t,this._$gl=e,this._$keyword=i,this._$collection=new Map}getBitmapShader(){return this._$collection.has("b")||this._$collection.set("b",new qt(this._$gl,this._$context,wt.TEXTURE(this._$keyword),vt.TEMPLATE(this._$keyword,0,0,!1))),this._$collection.get("b")}setBitmapUniform(){}setGetPixelsUniform(t,e,i,s,r){const n=t.highp;n[0]=1,n[1]=0,n[2]=0,n[4]=0,n[5]=1,n[6]=0,n[8]=0,n[9]=0,n[10]=1,n[12]=e,n[13]=0,n[14]=0,n[16]=0,n[17]=i,n[18]=0,n[3]=s,n[7]=r,n[11]=1}setSetPixelsUniform(t,e,i,s,r,n,a,o,h){const l=t.highp;l[0]=e,l[1]=0,l[2]=0,l[4]=0,l[5]=i,l[6]=0,l[8]=s,l[9]=r,l[10]=1,l[12]=n,l[13]=0,l[14]=0,l[16]=0,l[17]=a,l[18]=0,l[3]=o,l[7]=h,l[11]=1}setColorTransformUniform(t,e){const i=t.mediump;i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4]/255,i[5]=e[5]/255,i[6]=e[6]/255,i[7]=e[7]/255}setManipulatePixelsUniform(t,e,i,s,r,n){const a=t.highp;a[0]=e[0],a[1]=e[1],a[2]=e[2],a[4]=e[3],a[5]=e[4],a[6]=e[5],a[8]=e[6],a[9]=e[7],a[10]=e[8],r?(a[12]=s[0],a[13]=s[1],a[14]=s[2],a[16]=s[3],a[17]=s[4],a[18]=s[5],a[20]=s[6],a[21]=s[7],a[22]=s[8],a[24]=n[0],a[25]=n[1],a[26]=n[2],a[3]=n[3],a[7]=n[4],a[11]=n[5],a[15]=n[6],a[19]=n[7],a[23]=n[8]):i&&(a[12]=s[0],a[13]=s[1],a[14]=s[2],a[16]=s[3],a[17]=s[4],a[18]=s[5],a[3]=s[6],a[7]=s[7],a[11]=s[8])}setCopyChannelUniform(t,e,i){const s=t.textures;s[0]=0,s[1]=1;const r=t.mediump;r[0]=1&e,r[1]=e>>1&1,r[2]=e>>2&1,r[3]=e>>3&1,r[4]=1&i,r[5]=i>>1&1,r[6]=i>>2&1,r[7]=i>>3&1}setCopyPixelsUniform(t,e){if(e){const e=t.textures;e[0]=0,e[1]=1}}setFillRectUniform(t,e,i,s,r){const n=t.mediump;n[0]=e,n[1]=i,n[2]=s,n[3]=r}setGetColorBoundsRectUniform(t,e,i,s,r,n){const a=t.highp;a[0]=1,a[1]=0,a[2]=0,a[4]=0,a[5]=1,a[6]=0,a[8]=0,a[9]=0,a[10]=1,a[12]=e[0],a[13]=e[1],a[14]=e[2],a[16]=e[3],a[17]=e[4],a[18]=e[5],a[3]=e[6],a[7]=e[7],a[11]=e[8];const o=t.mediump;o[0]=i[0],o[1]=i[1],o[2]=s;const h=t.integer;h[0]=r[0],h[1]=r[1],h[2]=r[2],h[3]=r[3],h[4]=n[0],h[5]=n[1],h[6]=n[2],h[7]=n[3]}setMergeUniform(t,e,i,s,r){const n=t.textures;n[0]=0,n[1]=1;const a=t.mediump;a[0]=e,a[1]=i,a[2]=s,a[3]=r}setNoiseUniform(t,e,i,s,r,n,a,o,h,l,$,_,c){const u=t.mediump;u[0]=e,u[1]=i,u[2]=s,u[3]=r,u[4]=n,u[5]=a,u[6]=o,u[7]=h,u[8]=l,u[9]=$,u[10]=_,u[11]=c}setPaletteMapUniform(t){const e=t.textures;e[0]=0,e[1]=2}setPixelDissolveUniform(t,e,i,s,r){const n=t.mediump;n[0]=e,n[1]=i,n[2]=s,n[3]=r}setFlushSetPixelQueueUniform(t){const e=t.highp;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=-1,e[5]=0,e[6]=0,e[7]=1,e[8]=1}setThresholdUniform(t,e,i,s,r,n,a,o,h,l,$,_,c){const u=t.mediump;u[0]=e,u[1]=i,u[2]=s,u[3]=r,u[4]=n,u[5]=a,u[6]=o,u[7]=h;const d=t.integer;d[0]=l,d[1]=$,d[2]=_,d[3]=c}}class Et{constructor(t,e,i){this._$context=t,this._$gl=e,this._$keyword=i,this._$collection=new Map}getNormalBlendShader(t){const e="n"+(t?"y":"n");return this._$collection.has(e)||this._$collection.set(e,new qt(this._$gl,this._$context,wt.BLEND(this._$keyword),vt.TEMPLATE(this._$keyword,t))),this._$collection.get(e)}getClipShader(){return this._$collection.has("c")||this._$collection.set("c",new qt(this._$gl,this._$context,wt.BLEND_CLIP(this._$keyword),vt.TEMPLATE(this._$keyword,!1))),this._$collection.get("c")}getBlendShader(t,e){const i=`${t}${e?"y":"n"}`;return this._$collection.has(i)||this._$collection.set(i,new qt(this._$gl,this._$context,wt.BLEND(this._$keyword),class{static TEMPLATE(t,e,i){let s;switch(e){case C.SUBTRACT:s=this.FUNCTION_SUBTRACT();break;case C.MULTIPLY:s=this.FUNCTION_MULTIPLY();break;case C.LIGHTEN:s=this.FUNCTION_LIGHTEN();break;case C.DARKEN:s=this.FUNCTION_DARKEN();break;case C.OVERLAY:s=this.FUNCTION_OVERLAY();break;case C.HARDLIGHT:s=this.FUNCTION_HARDLIGHT();break;case C.DIFFERENCE:s=this.FUNCTION_DIFFERENCE();break;case C.INVERT:s=this.FUNCTION_INVERT();break;default:s=this.FUNCTION_NORMAL()}const r=i?"uniform vec4 u_mediump[2];":"",n=i?xt.STATEMENT_COLOR_TRANSFORM_ON(0):"";return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\n${r}\n\n${t.varyingIn()} vec2 v_coord;\n${t.outColor()}\n\n${s}\n\nvoid main() {\n vec4 dst = ${t.texture2D()}(u_textures[0], v_coord);\n vec4 src = ${t.texture2D()}(u_textures[1], v_coord);\n ${n}\n ${t.fragColor()} = blend(src, dst);\n}\n\n`}static FUNCTION_NORMAL(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n return src + dst - dst * src.a;\n}\n\n"}static FUNCTION_SUBTRACT(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(dst.rgb - src.rgb, src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_MULTIPLY(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n vec4 c = src * dst;\n\n return a + b + c;\n}\n\n"}static FUNCTION_LIGHTEN(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(mix(src.rgb, dst.rgb, step(src.rgb, dst.rgb)), src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_DARKEN(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(mix(src.rgb, dst.rgb, step(dst.rgb, src.rgb)), src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_OVERLAY(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 mul = src * dst;\n vec3 c1 = 2.0 * mul.rgb;\n vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0;\n vec4 c = vec4(mix(c1, c2, step(vec3(0.5), dst.rgb)), mul.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_HARDLIGHT(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 mul = src * dst;\n vec3 c1 = 2.0 * mul.rgb;\n vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0;\n vec4 c = vec4(mix(c1, c2, step(vec3(0.5), src.rgb)), mul.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_DIFFERENCE(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(abs(src.rgb - dst.rgb), src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_INVERT(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 b = dst - dst * src.a;\n vec4 c = vec4(src.a - dst.rgb * src.a, src.a);\n\n return b + c;\n}\n\n"}}.TEMPLATE(this._$keyword,t,e))),this._$collection.get(i)}setNormalBlendUniform(t,e,i,s,r,n,a,o,h,l,$,_,c,u,d,g,f){const m=t.highp;if(m[0]=e,m[1]=i,m[2]=s,m[3]=r,m[4]=n[0],m[5]=n[1],m[6]=n[2],m[8]=n[3],m[9]=n[4],m[10]=n[5],m[12]=n[6],m[13]=n[7],m[14]=n[8],m[7]=a,m[11]=o,h){const e=t.mediump;e[0]=l,e[1]=$,e[2]=_,e[3]=c,e[4]=u,e[5]=d,e[6]=g,e[7]=f}}setClipUniform(t,e,i,s,r,n,a,o){const h=t.highp;h[0]=e,h[1]=i,h[2]=s,h[3]=r,h[4]=n[0],h[5]=n[1],h[6]=n[2],h[8]=n[3],h[9]=n[4],h[10]=n[5],h[12]=n[6],h[13]=n[7],h[14]=n[8],h[7]=a,h[11]=o}setBlendUniform(t,e,i,s,r,n,a,o,h,l,$,_,c,u,d,g,f){const m=t.textures;m[0]=0,m[1]=1;const p=t.highp;if(p[0]=e,p[1]=i,p[2]=s,p[3]=r,p[4]=n[0],p[5]=n[1],p[6]=n[2],p[8]=n[3],p[9]=n[4],p[10]=n[5],p[12]=n[6],p[13]=n[7],p[14]=n[8],p[7]=a,p[11]=o,h){const e=t.mediump;e[0]=l,e[1]=$,e[2]=_,e[3]=c,e[4]=u,e[5]=d,e[6]=g,e[7]=f}}}class At{constructor(t,e,i){this._$context=t,this._$gl=e,this._$keyword=i,this._$collection=new Map}getBlurFilterShader(t){const e=`b${t}`;return this._$collection.has(e)||this._$collection.set(e,new qt(this._$gl,this._$context,wt.TEXTURE(this._$keyword),class{static TEMPLATE(t,e){const i=e.toFixed(1);return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_texture;\nuniform vec4 u_mediump;\n\n${t.varyingIn()} vec2 v_coord;\n${t.outColor()}\n\nvoid main() {\n vec2 offset = u_mediump.xy;\n float fraction = u_mediump.z;\n float samples = u_mediump.w;\n \n vec4 color = ${t.texture2D()}(u_texture, v_coord);\n\n for (float i = 1.0; i < ${i}; i += 1.0) {\n color += ${t.texture2D()}(u_texture, v_coord + offset * i);\n color += ${t.texture2D()}(u_texture, v_coord - offset * i);\n }\n color += ${t.texture2D()}(u_texture, v_coord + offset * ${i}) * fraction;\n color += ${t.texture2D()}(u_texture, v_coord - offset * ${i}) * fraction;\n color /= samples;\n\n ${t.fragColor()} = color;\n}\n\n`}}.TEMPLATE(this._$keyword,t))),this._$collection.get(e)}getBitmapFilterShader(t,e,i,r,n,a,o){const h=`f${t?"y":"n"}${e?"y":"n"}${i?"y":"n"}${r}${n?"y":"n"}${a?"y":"n"}`;if(!this._$collection.has(h)){let l=1;t&&l++,o&&l++;let $=(t?4:0)+(e?4:0)+(a?1:0);o||($+=i?4:8),$=s.$ceil($/4),this._$collection.set(h,new qt(this._$gl,this._$context,wt.TEXTURE(this._$keyword),class{static TEMPLATE(t,e,i,s,r,n,a,o,h,l){let $=0;const _=s?this.STATEMENT_BASE_TEXTURE_TRANSFORM(t,$++):"",c=r?this.STATEMENT_BLUR_TEXTURE_TRANSFORM(t,$++):this.STATEMENT_BLUR_TEXTURE(t),u=a===H.INNER,d=$;let g,f,m=4*$;switch(l?g=n?this.STATEMENT_GLOW(t,!1,s,h,l,d,m):this.STATEMENT_BEVEL(t,s,r,h,l,d,m):n?(m+=4,g=this.STATEMENT_GLOW(t,u,s,h,l,d,m)):(m+=8,g=this.STATEMENT_BEVEL(t,s,r,h,l,d,m)),a){case H.OUTER:f=o?"blur - blur * base.a":"base + blur - blur * base.a";break;case H.FULL:f=o?"blur":"base - base * blur.a + blur";break;default:f="blur"}return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[${e}];\nuniform vec4 u_mediump[${i}];\n\n${t.varyingIn()} vec2 v_coord;\n${t.outColor()}\n\n${xt.FUNCTION_IS_INSIDE()}\n\nvoid main() {\n ${_}\n ${c}\n ${g}\n ${t.fragColor()} = ${f};\n}\n\n`}static STATEMENT_BASE_TEXTURE_TRANSFORM(t,e){return`\n vec2 base_scale = u_mediump[${e}].xy;\n vec2 base_offset = u_mediump[${e}].zw;\n\n vec2 uv = v_coord * base_scale - base_offset;\n vec4 base = mix(vec4(0.0), ${t.texture2D()}(u_textures[1], uv), isInside(uv));\n`}static STATEMENT_BLUR_TEXTURE(t){return`\n vec4 blur = ${t.texture2D()}(u_textures[0], v_coord);\n`}static STATEMENT_BLUR_TEXTURE_TRANSFORM(t,e){return`\n vec2 blur_scale = u_mediump[${e}].xy;\n vec2 blur_offset = u_mediump[${e}].zw;\n\n vec2 st = v_coord * blur_scale - blur_offset;\n vec4 blur = mix(vec4(0.0), ${t.texture2D()}(u_textures[0], st), isInside(st));\n`}static STATEMENT_GLOW(t,e,i,s,r,n,a){return`\n ${e?"blur.a = 1.0 - blur.a;":""}\n ${s?this.STATEMENT_GLOW_STRENGTH(a):""}\n ${r?this.STATEMENT_GLOW_GRADIENT_COLOR(t,i):this.STATEMENT_GLOW_SOLID_COLOR(n)}\n`}static STATEMENT_GLOW_STRENGTH(t){return`\n float strength = u_mediump[${s.$floor(t/4)}][${t%4}];\n blur.a = clamp(blur.a * strength, 0.0, 1.0);\n`}static STATEMENT_GLOW_SOLID_COLOR(t){return`\n vec4 color = u_mediump[${t}];\n blur = color * blur.a;\n`}static STATEMENT_GLOW_GRADIENT_COLOR(t,e){const i=e?2:1;return`\n blur = ${t.texture2D()}(u_textures[${i}], vec2(blur.a, 0.5));\n`}static STATEMENT_BEVEL(t,e,i,s,r,n,a){return`\n ${i?this.STATEMENT_BLUR_TEXTURE_TRANSFORM_2(t):this.STATEMENT_BLUR_TEXTURE_2(t)}\n float highlight_alpha = blur.a - blur2.a;\n float shadow_alpha = blur2.a - blur.a;\n ${s?this.STATEMENT_BEVEL_STRENGTH(a):""}\n highlight_alpha = clamp(highlight_alpha, 0.0, 1.0);\n shadow_alpha = clamp(shadow_alpha, 0.0, 1.0);\n ${r?this.STATEMENT_BEVEL_GRADIENT_COLOR(t,e):this.STATEMENT_BEVEL_SOLID_COLOR(n)}\n`}static STATEMENT_BLUR_TEXTURE_2(t){return`\n vec4 blur2 = ${t.texture2D()}(u_textures[0], 1.0 - v_coord);\n`}static STATEMENT_BLUR_TEXTURE_TRANSFORM_2(t){return`\n vec2 pq = (1.0 - v_coord) * blur_scale - blur_offset;\n vec4 blur2 = mix(vec4(0.0), ${t.texture2D()}(u_textures[0], pq), isInside(pq));\n`}static STATEMENT_BEVEL_STRENGTH(t){return`\n float strength = u_mediump[${s.$floor(t/4)}][${t%4}];\n highlight_alpha *= strength;\n shadow_alpha *= strength;\n`}static STATEMENT_BEVEL_SOLID_COLOR(t){return`\n vec4 highlight_color = u_mediump[${t}];\n vec4 shadow_color = u_mediump[${t+1}];\n blur = highlight_color * highlight_alpha + shadow_color * shadow_alpha;\n`}static STATEMENT_BEVEL_GRADIENT_COLOR(t,e){const i=e?2:1;return`\n blur = ${t.texture2D()}(u_textures[${i}], vec2(\n 0.5019607843137255 - 0.5019607843137255 * shadow_alpha + 0.4980392156862745 * highlight_alpha,\n 0.5\n ));\n`}}.TEMPLATE(this._$keyword,l,$,t,e,i,r,n,a,o)))}return this._$collection.get(h)}getColorMatrixFilterShader(){return this._$collection.has("m")||this._$collection.set("m",new qt(this._$gl,this._$context,wt.TEXTURE(this._$keyword),class{static TEMPLATE(t){return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_texture;\nuniform vec4 u_mediump[5];\n\n${t.varyingIn()} vec2 v_coord;\n${t.outColor()}\n\nvoid main() {\n mat4 mul = mat4(u_mediump[0], u_mediump[1], u_mediump[2], u_mediump[3]);\n vec4 add = u_mediump[4];\n \n vec4 color = ${t.texture2D()}(u_texture, v_coord);\n\n color.rgb /= max(0.0001, color.a);\n color = clamp(color * mul + add, 0.0, 1.0);\n color.rgb *= color.a;\n\n ${t.fragColor()} = color;\n}\n\n`}}.TEMPLATE(this._$keyword))),this._$collection.get("m")}getConvolutionFilterShader(t,e,i,r){const n=`c${("0"+t).slice(-2)}${("0"+e).slice(-2)}${i?"y":"n"}${r?"y":"n"}`;if(!this._$collection.has(n)){const a=(r?1:2)+s.$ceil(t*e/4);this._$collection.set(n,new qt(this._$gl,this._$context,wt.TEXTURE(this._$keyword),class{static TEMPLATE(t,e,i,r,n,a){const o=s.$floor(.5*i),h=s.$floor(.5*r),l=i*r;let $="";const _=a?1:2;for(let t=0;t>16)/255,o[a++]=(e>>8&255)/255,o[a++]=(255&e)/255,o[a++]=s[t]}for(let t=r;t= 30.0) { // ラウンド結合\n float face = u_highp[${n}][1];\n float rad = face * (a_type - 30.0) * 0.3488888889; /* 0.3488888889 = PI / 9.0 */\n offset = mat2(cos(rad), sin(rad), -sin(rad), cos(rad)) * vec2(1.0, 0.0);\n }\n \n offset *= half_width;\n position += offset;\n ${o}\n\n position /= viewport;\n position = position * 2.0 - 1.0;\n gl_Position = vec4(position.x, -position.y, 0.0, 1.0);\n}\n\n`}static VARYING_UV_ON(t){return`\n${t.varyingOut()} vec2 v_uv;\n`}static STATEMENT_UV_ON(){return"\n mat3 uv_matrix = mat3(\n u_highp[0].xyz,\n u_highp[1].xyz,\n u_highp[2].xyz\n );\n mat3 inverse_matrix = mat3(\n u_highp[3].xyz,\n u_highp[4].xyz,\n vec3(u_highp[2].w, u_highp[3].w, u_highp[4].w)\n );\n\n v_uv = (uv_matrix * vec3(a_vertex, 1.0)).xy;\n v_uv += offset;\n v_uv = (inverse_matrix * vec3(v_uv, 1.0)).xy;\n"}}class Ft{constructor(){this._$rgb=F.RGB,this._$mode=U.PAD,this._$focalPointRatio=0,this._$points=s.$getFloat32Array6(),this._$stops=s.$getArray(),this._$type=null}linear(t,e,i,s,r=F.RGB,n=U.PAD){return this._$type=w.LINEAR,this._$points[0]=t,this._$points[1]=e,this._$points[2]=i,this._$points[3]=s,this._$rgb=r,this._$mode=n,this._$stops.length&&(this._$stops.length=0),this}radial(t,e,i,r,n,a,o=F.RGB,h=U.PAD,l=0){return this._$type=w.RADIAL,this._$points[0]=t,this._$points[1]=e,this._$points[2]=i,this._$points[3]=r,this._$points[4]=n,this._$points[5]=a,this._$rgb=o,this._$mode=h,this._$focalPointRatio=s.$clamp(l,-.975,.975,0),this._$stops.length&&(this._$stops.length=0),this}addColorStop(t,e){this._$stops.push([t,e]),this._$stops.sort((function(t,e){switch(!0){case t[0]>e[0]:return 1;case e[0]>t[0]:return-1;default:return 0}}))}}class Lt{constructor(t=null,e=null,i=null){this._$initialization(t,e,i)}_$initialization(t=null,e=null,i=null){return this._$texture=t,this._$repeat=e,this._$color_transform=i,this}get texture(){return this._$texture}get repeat(){return this._$repeat}get colorTransform(){return this._$color_transform}}class Pt{constructor(t,e){this._$gl=t;const i=e?s.$min(s.$currentPlayer().getSamples(),t.getParameter(t.MAX_SAMPLES)):0;this._$isWebGL2Context=e,this._$maxTextureSize=s.$min(8192,t.getParameter(t.MAX_TEXTURE_SIZE))-2,this._$contextStyle=new Gt,this._$style=this._$contextStyle,this._$fillBuffer=null,this._$strokeBuffer=null,this._$cacheCurrentBounds={x:0,y:0,w:0,h:0},this._$cacheCurrentBuffer=null,this._$stack=[],this._$globalAlpha=1,this._$imageSmoothingEnabled=!1,this._$globalCompositeOperation=C.NORMAL,this._$matrix=s.$getFloat32Array9(1,0,0,0,1,0,0,0,1),this._$clearColorR=1,this._$clearColorG=1,this._$clearColorB=1,this._$clearColorA=1,this._$viewportWidth=0,this._$viewportHeight=0,this._$frameBufferManager=new Yt(t,e,i),this._$path=new kt,this._$grid=new Nt,this._$offsetX=0,this._$offsetY=0,this._$blends=[],this._$positions=[],this._$isLayer=!1,this._$shaderList=new Kt(this,t),this._$gradientLUT=new Qt(this,t),this._$vao=new Wt(t,e),this._$pbo=new jt(t,e),this._$mask=new Ut(this,t),this._$blend=new Dt(this,t),this._$canvasPatternToWebGL=new Lt,this._$canvasGradientToWebGL=new Ft}get canvas(){return this._$gl.canvas}get fillStyle(){return this._$style._$fillStyle}set fillStyle(t){this._$style._$fillStyle.constructor===Float32Array&&s.$poolFloat32Array4(this._$style._$fillStyle),this._$style._$fillStyle=t}get strokeStyle(){return this._$style._$strokeStyle}set strokeStyle(t){this._$style._$strokeStyle.constructor===Float32Array&&s.$poolFloat32Array4(this._$style._$strokeStyle),this._$style._$strokeStyle=t}get lineWidth(){return this._$style._$lineWidth}set lineWidth(t){this._$style._$lineWidth=t}get lineCap(){return this._$style._$lineCap}set lineCap(t){switch(t){case S.NONE:case S.SQUARE:this._$style._$lineCap=t;break;default:this._$style._$lineCap=S.ROUND}}get lineJoin(){return this._$style._$lineJoin}set lineJoin(t){switch(t){case L.BEVEL:case L.MITER:this._$style._$lineJoin=t;break;default:this._$style._$lineJoin=L.ROUND}}get miterLimit(){return this._$style._$miterLimit}set miterLimit(t){this._$style._$miterLimit=t}get globalAlpha(){return this._$globalAlpha}set globalAlpha(t){this._$globalAlpha=s.$clamp(t,0,1,1)}get imageSmoothingEnabled(){return this._$imageSmoothingEnabled}set imageSmoothingEnabled(t){this._$imageSmoothingEnabled=s.$toBoolean(t)}get globalCompositeOperation(){return this._$globalCompositeOperation}set globalCompositeOperation(t){this._$globalCompositeOperation=t}get frameBuffer(){return this._$frameBufferManager}get path(){return this._$path}get grid(){return this._$grid}get vao(){return this._$vao}get pbo(){return this._$pbo}get blend(){return this._$blend}_$bind(t){if(!t)return;this._$frameBufferManager.bind(t);const e=t.color,i=t.stencil,s=t.width,r=t.height;this._$viewportWidth===s&&this._$viewportHeight===r||(this._$viewportWidth=s,this._$viewportHeight=r,this._$gl.viewport(0,0,s,r)),(e.dirty||i&&i.dirty)&&(e.dirty=!1,i&&(i.dirty=!1),this._$gl.clearColor(0,0,0,0),this.clearRect(0,0,this._$viewportWidth,this._$viewportHeight),this._$gl.clearColor(this._$clearColorR,this._$clearColorG,this._$clearColorB,this._$clearColorA),this._$mask._$onClear(t.mask)),this._$mask._$onBind(t.mask)}fillRect(t,e,i,r){if(!i||!r)return;this._$viewportWidth=i,this._$viewportHeight=r;let n=!1;if(!this._$fillBuffer){n=!0;const a=this._$path.createRectVertices(t,e,i,r);this._$fillBuffer=this._$vao.createFill(a),s.$poolArray(a.pop()),s.$poolArray(a)}const a=this._$grid.enabled,o=this._$shaderList.shapeShaderVariants,h=o.getSolidColorShapeShader(!1,a),l=h.uniform;o.setSolidColorShapeUniform(l,!1,0,0,0,a,this._$matrix,this._$viewportWidth,this._$viewportHeight,this._$grid,this.fillStyle,this._$globalAlpha),h._$fill(this._$fillBuffer),n&&(this._$vao.release(this._$fillBuffer),s.$poolArray(this._$fillBuffer.indexRanges)),this.beginPath()}setTransform(t,e,i,s,r,n){this._$matrix[0]=t,this._$matrix[1]=e,this._$matrix[3]=i,this._$matrix[4]=s,this._$matrix[6]=r,this._$matrix[7]=n}transform(t,e,i,s,r,n){const a=this._$matrix[0],o=this._$matrix[1],h=this._$matrix[3],l=this._$matrix[4],$=this._$matrix[6],_=this._$matrix[7];this._$matrix[0]=t*a+e*h,this._$matrix[1]=t*o+e*l,this._$matrix[3]=i*a+s*h,this._$matrix[4]=i*o+s*l,this._$matrix[6]=r*a+n*h+$,this._$matrix[7]=r*o+n*l+_}drawImage(t,e,i,s,r,n=null){let a=1,o=1,h=1,l=this._$globalAlpha,$=0,_=0,c=0;n&&(a=n[0],o=n[1],h=n[2],$=n[4]/255,_=n[5]/255,c=n[6]/255),this._$blend.drawImage(t,e,i,s,r,a,o,h,l,$,_,c,0,this._$globalCompositeOperation,this._$viewportWidth,this._$viewportHeight,this._$matrix,this._$imageSmoothingEnabled)}_$setColor(t=0,e=0,i=0,s=0){this._$clearColorR=t,this._$clearColorG=e,this._$clearColorB=i,this._$clearColorA=s,this._$gl.clearColor(t,e,i,s)}clearRect(t,e,i,s){this._$mask._$onClearRect(),this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(t,e,i,s),this._$gl.clear(this._$gl.COLOR_BUFFER_BIT|this._$gl.STENCIL_BUFFER_BIT),this._$gl.disable(this._$gl.SCISSOR_TEST)}_$clearRectStencil(t,e,i,s){this._$mask._$onClearRect(),this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(t,e,i,s),this._$gl.clear(this._$gl.STENCIL_BUFFER_BIT),this._$gl.disable(this._$gl.SCISSOR_TEST)}_$startClip(t,e){return this._$mask._$startClip(t,e)}moveTo(t,e){this._$path.moveTo(t,e)}lineTo(t,e){this._$path.lineTo(t,e)}beginPath(){this._$path.begin(),this._$isGraphics&&(this._$fillBuffer&&(this.vao.release(this._$fillBuffer),this.vao.release(this._$fillBuffer.boundObject),s.$poolArray(this._$fillBuffer.indexRanges),s.$poolArray(this._$fillBuffer.boundObject.indexRanges)),this._$strokeBuffer&&this.vao.release(this._$strokeBuffer)),this._$isGraphics=!1,this._$fillBuffer=null,this._$strokeBuffer=null}quadraticCurveTo(t,e,i,s){this._$path.quadTo(t,e,i,s)}bezierCurveTo(t,e,i,s,r,n){this._$path.cubicTo(t,e,i,s,r,n)}_$getVertices(){return this._$path.vertices}fill(){let t,e,i,r=this._$matrix;switch(!0){case this.fillStyle.constructor===Ft:if(this.fillStyle._$type===w.LINEAR);else r=this._$stack[this._$stack.length-1];break;case this.fillStyle.constructor===Lt:r=this._$stack[this._$stack.length-1]}const n=this._$grid.enabled;switch(!0){case this.fillStyle.constructor===Ft:{const a=this.fillStyle,o=a._$stops,h="linearRGB"===a._$rgb;if(t=this._$gradientLUT.generateForShape(o,h),this._$frameBufferManager._$textureManager.bind0(t,!0),e=this._$shaderList.gradientShapeShaderVariants,a._$type===w.LINEAR)i=e.getGradientShapeShader(!1,n,!1,!1,a._$mode),e.setGradientShapeUniform(i.uniform,!1,0,0,0,n,r,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!1,a._$points,0);else{const t=0!==a._$focalPointRatio;i=e.getGradientShapeShader(!1,n,!0,t,a._$mode),e.setGradientShapeUniform(i.uniform,!1,0,0,0,n,r,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!0,a._$points,a._$focalPointRatio)}}break;case this.fillStyle.constructor===Lt:{const a=this.fillStyle,o=a.colorTransform;t=a.texture,this._$frameBufferManager._$textureManager.bind0(t,this._$imageSmoothingEnabled),e=this._$shaderList.shapeShaderVariants,i=e.getBitmapShapeShader(!1,""!==a.repeat,n),o?e.setBitmapShapeUniform(i.uniform,!1,0,0,0,n,r,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,t.width,t.height,o[0],o[1],o[2],this._$globalAlpha,o[4]/255,o[5]/255,o[6]/255,0):e.setBitmapShapeUniform(i.uniform,!1,0,0,0,n,r,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,t.width,t.height,1,1,1,this._$globalAlpha,0,0,0,0)}break;default:e=this._$shaderList.shapeShaderVariants,i=e.getSolidColorShapeShader(!1,this._$grid.enabled),e.setSolidColorShapeUniform(i.uniform,!1,0,0,0,n,r,this._$viewportWidth,this._$viewportHeight,this._$grid,this.fillStyle,this._$globalAlpha)}const a=this._$shaderList.shapeShaderVariants,o=a.getMaskShapeShader(!1,n);if(a.setMaskShapeUniform(o.uniform,n,r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],this._$viewportWidth,this._$viewportHeight,this._$grid),!this._$fillBuffer){const t=this._$getVertices();if(!t.length)return;const e=s.$getArray();for(let i=0;is.length||e.push(s)}if(!e.length)return;this._$isGraphics=!0,this._$fillBuffer=this._$vao.createFill(e);const i=this._$path.getBoundsVertices();this._$fillBuffer.boundObject=this._$vao.createFill(i),s.$poolArray(i.pop()),s.$poolArray(i)}this._$gl.enable(this._$gl.STENCIL_TEST),this._$gl.stencilMask(255),this._$gl.enable(this._$gl.SAMPLE_ALPHA_TO_COVERAGE),this._$gl.stencilFunc(this._$gl.ALWAYS,0,255),this._$gl.stencilOp(this._$gl.KEEP,this._$gl.INVERT,this._$gl.INVERT),this._$gl.colorMask(!1,!1,!1,!1),o._$fill(this._$fillBuffer),this._$gl.disable(this._$gl.SAMPLE_ALPHA_TO_COVERAGE),this._$gl.stencilFunc(this._$gl.NOTEQUAL,0,255),this._$gl.stencilOp(this._$gl.KEEP,this._$gl.ZERO,this._$gl.ZERO),this._$gl.colorMask(!0,!0,!0,!0),i._$fill(this._$fillBuffer.boundObject),this._$gl.disable(this._$gl.STENCIL_TEST)}_$enterClip(){this._$mask._$enterClip()}_$beginClipDef(){this._$mask._$beginClipDef()}_$endClipDef(){this._$mask._$endClipDef()}_$leaveClip(){this._$mask._$leaveClip()}_$drawContainerClip(){this._$mask._$drawContainerClip()}_$unionStencilMask(t,e,i){this._$mask._$unionStencilMask(t,e,i)}closePath(){this._$path.close()}stroke(){if(!this._$strokeBuffer){const t=this._$getVertices();if(!t.length)return;const e=s.$getArray();for(let i=0;is.length||e.push(s)}if(!e.length)return;this._$isGraphics=!0,this._$strokeBuffer=this._$vao.createStroke(t,this.lineCap,this.lineJoin)}let t=this._$matrix;switch(!0){case this.strokeStyle.constructor===Ft:if(this.strokeStyle._$type===w.LINEAR);else t=this._$stack[this._$stack.length-1];break;case this.strokeStyle.constructor===Lt:t=this._$stack[this._$stack.length-1]}let e=s.$sign(t[0]*t[4]);e>0&&0!==t[1]&&0!==t[3]&&(e=-s.$sign(t[1]*t[3]));let i,r,n=.5*this.lineWidth;this._$grid.enabled?(n*=s.$getSameScaleBase(),i=s.$abs(this._$grid.ancestorMatrixA+this._$grid.ancestorMatrixD),r=s.$abs(this._$grid.ancestorMatrixB+this._$grid.ancestorMatrixE)):(i=s.$abs(t[0]+t[3]),r=s.$abs(t[1]+t[4]));const a=s.$min(i,r),o=s.$max(i,r);let h,l,$;n*=o*(1-.3*s.$cos(.5*s.$PI*(a/o))),n=s.$max(1,n);const _=this._$grid.enabled;switch(!0){case this.strokeStyle.constructor===Ft:{const i=this.strokeStyle,r=i._$stops,a="linearRGB"===i._$rgb;if(h=this._$gradientLUT.generateForShape(r,a),this._$frameBufferManager._$textureManager.bind0(h,!0),l=this._$shaderList.gradientShapeShaderVariants,i._$type===w.LINEAR)$=l.getGradientShapeShader(!0,_,!1,!1,i._$mode),l.setGradientShapeUniform($.uniform,!0,n,e,this.miterLimit,_,t,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!1,i._$points,0);else{const r=0!==i._$focalPointRatio;$=l.getGradientShapeShader(!0,_,!0,r,i._$mode),l.setGradientShapeUniform($.uniform,!0,n,e,this.miterLimit,_,t,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!0,i._$points,i._$focalPointRatio)}}break;case this.strokeStyle.constructor===Lt:{const i=this.strokeStyle,r=i.colorTransform;h=i.texture,this._$frameBufferManager._$textureManager.bind0(h),l=this._$shaderList.shapeShaderVariants,$=l.getBitmapShapeShader(!0,""!==i.repeat,this._$grid.enabled),r?l.setBitmapShapeUniform($.uniform,!0,n,e,this.miterLimit,_,t,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,h.width,h.height,r[0],r[1],r[2],this._$globalAlpha,r[4]/255,r[5]/255,r[6]/255,0):l.setBitmapShapeUniform($.uniform,!0,n,e,this.miterLimit,_,t,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,h.width,h.height,1,1,1,this._$globalAlpha,0,0,0,0)}break;default:l=this._$shaderList.shapeShaderVariants,$=l.getSolidColorShapeShader(!0,this._$grid.enabled),l.setSolidColorShapeUniform($.uniform,!0,n,e,this.miterLimit,_,t,this._$viewportWidth,this._$viewportHeight,this._$grid,this.strokeStyle,this._$globalAlpha)}$._$stroke(this._$strokeBuffer)}arc(t,e,i){this._$path.drawCircle(t,e,i)}clip(t=!1){const e=this._$shaderList.shapeShaderVariants,i=e.getMaskShapeShader(!1,!1),r=i.uniform;if(e.setMaskShapeUniform(r,!1,this._$matrix[0],this._$matrix[1],this._$matrix[2],this._$matrix[3],this._$matrix[4],this._$matrix[5],this._$matrix[6],this._$matrix[7],this._$matrix[8],this._$viewportWidth,this._$viewportHeight,null),!this._$fillBuffer){this._$fillBuffer=this._$vao.createFill(this._$getVertices());const t=this._$path.getBoundsVertices();this._$fillBuffer.boundObject=this._$vao.createFill(t),s.$poolArray(t.pop()),s.$poolArray(t)}this._$mask._$onClip(this._$matrix,this._$viewportWidth,this._$viewportHeight)||(i._$fill(this._$fillBuffer),t&&(this._$vao.release(this._$fillBuffer),this._$vao.release(this._$fillBuffer.boundObject),s.$poolArray(this._$fillBuffer.indexRanges),s.$poolArray(this._$fillBuffer.boundObject.indexRanges),this._$fillBuffer=null),this.beginPath())}save(){const t=this._$matrix;this._$stack.push(s.$getFloat32Array9(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])),this._$mask._$onSave()}restore(){this._$stack.length&&(s.$poolFloat32Array9(this._$matrix),this._$matrix=this._$stack.pop()),this._$mask._$onRestore()}createPattern(t,e,i){return this._$canvasPatternToWebGL._$initialization(t,e,i)}createLinearGradient(t,e,i,s,r=F.RGB,n=U.PAD){return this._$canvasGradientToWebGL.linear(t,e,i,s,r,n)}createRadialGradient(t,e,i,s,r,n,a=F.RGB,o=U.PAD,h=0){return this._$canvasGradientToWebGL.radial(t,e,i,s,r,n,a,o,h)}_$applyBlurFilter(t,e,i){const r=this._$frameBufferManager.currentAttachment,n=r.width,a=r.height;this._$frameBufferManager._$textureManager.bind0(t,!0);const o=s.$ceil(.5*i),h=1-(o-.5*i),l=1+i,$=this._$shaderList.filterShaderVariants,_=$.getBlurFilterShader(o);$.setBlurFilterUniform(_.uniform,n,a,e,h,l),_._$drawImage()}_$applyBitmapFilter(t,e,i,s,r,n,a,o,h,l,$,_,c,u,d,g,f,m,p,x,b,T,v,y,E,A){const M=c===H.INNER,C=this._$frameBufferManager.currentAttachment,S=this._$frameBufferManager.getTextureFromCurrentAttachment();let R;const w=null!==g;let O;w&&(R=this._$gradientLUT.generateForFilter(g,f,m)),M?w?this._$frameBufferManager._$textureManager.bind02(t,R,!0):this._$frameBufferManager._$textureManager.bind0(t):(O=this._$frameBufferManager.createTextureAttachment(e,i),this._$bind(O),w?this._$frameBufferManager._$textureManager.bind012(t,S,R,!0):this._$frameBufferManager._$textureManager.bind01(t,S));const I=!(M||c===H.FULL&&u),B=!(e===o&&i===h&&0===l&&0===$),F=!(1===d),L=this._$shaderList.filterShaderVariants,P=L.getBitmapFilterShader(I,B,_,c,u,F,w);L.setBitmapFilterUniform(P.uniform,e,i,s,r,n,a,o,h,l,$,_,d,p,x,b,T,v,y,E,A,I,B,F,w),M?u?this.blend.toSourceIn():this.blend.toSourceAtop():this.blend.toOneZero(),P._$drawImage(),M||this._$frameBufferManager.releaseAttachment(C,!0)}_$applyColorMatrixFilter(t,e){this._$frameBufferManager._$textureManager.bind0(t,!0);const i=this._$shaderList.filterShaderVariants,s=i.getColorMatrixFilterShader();i.setColorMatrixFilterUniform(s.uniform,e),this.blend.reset(),s._$drawImage()}_$applyConvolutionFilter(t,e,i,s,r,n,a,o,h,l,$,_){const c=t.width,u=t.height,d=this._$frameBufferManager.createTextureAttachment(c,u);this._$bind(d),this._$frameBufferManager._$textureManager.bind0(t,!0);const g=this._$shaderList.filterShaderVariants,f=g.getConvolutionFilterShader(e,i,a,o);g.setConvolutionFilterUniform(f.uniform,c,u,s,r,n,o,h,l,$,_),this.blend.reset(),f._$drawImage()}_$applyDisplacementMapFilter(t,e,i,s,r,n,a,o,h,l,$,_,c,u){const d=t.width,g=t.height,f=this._$frameBufferManager.createTextureAttachment(d,g);this._$bind(f),r||(r={x:0,y:0}),this._$frameBufferManager._$textureManager.bind01(t,e);const m=this._$shaderList.filterShaderVariants,p=m.getDisplacementMapFilterShader(n,a,l);m.setDisplacementMapFilterUniform(p.uniform,e.width,e.height,i,s,r.x,r.y,o,h,l,$,_,c,u),this.blend.reset(),p._$drawImage()}getImageData(t,e,i,r){const n=i*r*4,a=s.$getUint8Array(n);this._$gl.readPixels(t,r-(r-e),i,r,this._$gl.RGBA,this._$gl.UNSIGNED_BYTE,a);for(let t=0;tthis._$maxTextureSize?this._$maxTextureSize/i:1}changeSamples(t=4){if(this._$isWebGL2Context){t=s.$min(t,this._$gl.getParameter(this._$gl.MAX_SAMPLES));const e=this._$frameBufferManager;e._$objectPool=[],e._$colorBufferPool._$objectPool=[],e._$stencilBufferPool._$objectPool=[],e._$colorBufferPool._$samples=t}}}class Dt{constructor(t,e){this._$context=t,this._$gl=e,this._$enabled=!1,this._$funcCode=600,this.enable()}enable(){this._$enabled||(this._$enabled=!0,this._$gl.enable(this._$gl.BLEND)),this.reset()}disable(){this._$enabled&&(this._$enabled=!1,this._$gl.disable(this._$gl.BLEND))}reset(){613!==this._$funcCode&&(this._$funcCode=613,this._$gl.blendFunc(this._$gl.ONE,this._$gl.ONE_MINUS_SRC_ALPHA))}toOneZero(){610!==this._$funcCode&&(this._$funcCode=610,this._$gl.blendFunc(this._$gl.ONE,this._$gl.ZERO))}toZeroOne(){601!==this._$funcCode&&(this._$funcCode=601,this._$gl.blendFuncSeparate(this._$gl.ZERO,this._$gl.ONE,this._$gl.ONE,this._$gl.ZERO))}toAdd(){611!==this._$funcCode&&(this._$funcCode=611,this._$gl.blendFunc(this._$gl.ONE,this._$gl.ONE))}toScreen(){641!==this._$funcCode&&(this._$funcCode=641,this._$gl.blendFunc(this._$gl.ONE_MINUS_DST_COLOR,this._$gl.ONE))}toAlpha(){606!==this._$funcCode&&(this._$funcCode=606,this._$gl.blendFunc(this._$gl.ZERO,this._$gl.SRC_ALPHA))}toErase(){603!==this._$funcCode&&(this._$funcCode=603,this._$gl.blendFunc(this._$gl.ZERO,this._$gl.ONE_MINUS_SRC_ALPHA))}toSourceAtop(){673!==this._$funcCode&&(this._$funcCode=673,this._$gl.blendFunc(this._$gl.DST_ALPHA,this._$gl.ONE_MINUS_SRC_ALPHA))}toSourceIn(){670!==this._$funcCode&&(this._$funcCode=670,this._$gl.blendFunc(this._$gl.DST_ALPHA,this._$gl.ZERO))}toOperation(t){switch(t){case C.ADD:this.toAdd();break;case C.SCREEN:this.toScreen();break;case C.ALPHA:this.toAlpha();break;case C.ERASE:this.toErase();break;case"copy":this.toOneZero();break;default:this.reset()}}drawImage(t,e,i,r,n,a,o,h,l,$,_,c,u,d,g,f,m,p){const x=this._$context._$frameBufferManager.currentAttachment,b=1!==a||1!==o||1!==h||1!==l||0!==$||0!==_||0!==c||0!==u,T=this._$context._$shaderList.blendShaderVariants;switch(d){case C.NORMAL:case C.LAYER:case C.ADD:case C.SCREEN:case C.ALPHA:case C.ERASE:case"copy":{this._$context._$frameBufferManager._$textureManager.bind0(t,p);const x=T.getNormalBlendShader(b);T.setNormalBlendUniform(x.uniform,e,i,r,n,m,g,f,b,a,o,h,l,$,_,c,u);const v=m[0],y=m[1],E=m[3],A=m[4],M=m[6],C=m[7];if(1!==v||0!==y||0!==E||1!==A){const t=e+r,a=i+n,o=+(t*v+a*E+M),h=+(t*v+i*E+M),l=+(e*v+a*E+M),$=+(e*v+i*E+M),_=+(t*y+a*A+C),c=+(t*y+i*A+C),u=+(e*y+a*A+C),d=+(e*y+i*A+C),m=s.$MAX_VALUE,p=+s.$min(s.$min(s.$min(s.$min(m,o),h),l),$),x=+s.$max(s.$max(s.$max(s.$max(-m,o),h),l),$),b=+s.$min(s.$min(s.$min(s.$min(m,_),c),u),d),T=+s.$max(s.$max(s.$max(s.$max(-m,_),c),u),d),S=s.$max(0,0|p),R=s.$max(0,0|b),w=s.$min(s.$max(0,g-S),s.$ceil(s.$abs(x-p))),O=s.$min(s.$max(0,f-R),s.$ceil(s.$abs(T-b)));if(!w||!O)return;this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(S,s.$max(0,f-(R+O)),w+1,O+1)}else{const t=s.$max(0,e+M|0),a=s.$max(0,i+C|0),o=s.$min(s.$max(0,g-t),r),h=s.$min(s.$max(0,f-a),n);if(!o||!h)return;this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(t,s.$max(0,f-(a+h)),o+1,h+1)}this.toOperation(d),x._$drawImage(),this._$gl.disable(this._$gl.SCISSOR_TEST)}break;default:{const v=s.$max(0,e+m[6]|0),y=s.$max(0,i+m[7]|0),E=s.$min(s.$max(0,g-v),r),A=s.$min(s.$max(0,f-y),n);if(!E||!A)return;const M=this._$context._$frameBufferManager.getTextureFromCurrentAttachment(),C=this._$context._$frameBufferManager.createTextureAttachment(r,n);this._$context._$bind(C),this._$context._$frameBufferManager._$textureManager.bind0(M);const S=T.getClipShader(),R=S.uniform;T.setClipUniform(R,e,i,r,n,s.$inverseMatrix(m),g,f),this.reset(),S._$drawImage();const w=this._$context._$frameBufferManager.getTextureFromCurrentAttachment();this._$context._$bind(x),this._$context._$frameBufferManager._$textureManager.bind01(w,t,p);const O=T.getBlendShader(d,b);T.setBlendUniform(O.uniform,e,i,r,n,m,g,f,b,a,o,h,l,$,_,c,u),this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(v,s.$max(0,f-(y+A)),E,A),this.toOneZero(),O._$drawImage(),this._$gl.disable(this._$gl.SCISSOR_TEST),this._$context._$frameBufferManager.releaseAttachment(C,!0)}}}}class Nt{constructor(){this.enabled=!1,this.parentMatrixA=1,this.parentMatrixB=0,this.parentMatrixC=0,this.parentMatrixD=0,this.parentMatrixE=1,this.parentMatrixF=0,this.parentMatrixG=0,this.parentMatrixH=0,this.parentMatrixI=1,this.ancestorMatrixA=1,this.ancestorMatrixB=0,this.ancestorMatrixC=0,this.ancestorMatrixD=0,this.ancestorMatrixE=1,this.ancestorMatrixF=0,this.ancestorMatrixG=0,this.ancestorMatrixH=0,this.ancestorMatrixI=1,this.parentViewportX=0,this.parentViewportY=0,this.parentViewportW=0,this.parentViewportH=0,this.minXST=1e-5,this.minYST=1e-5,this.minXPQ=1e-5,this.minYPQ=1e-5,this.maxXST=.99999,this.maxYST=.99999,this.maxXPQ=.99999,this.maxYPQ=.99999}disable(){this.enabled=!1}}class Ut{constructor(t,e){this._$context=t,this._$gl=e,this._$clips=[],this._$clipStatus=!1,this._$containerClip=!1,this._$poolClip=[],this._$currentClip=!1}_$onClear(t){t&&(this._$gl.enable(this._$gl.STENCIL_TEST),this._$currentClip=!0)}_$onBind(t){!t&&this._$currentClip?(this._$gl.disable(this._$gl.STENCIL_TEST),this._$currentClip=!1):t&&!this._$currentClip&&(this._$gl.enable(this._$gl.STENCIL_TEST),this._$currentClip=!0,this._$endClipDef())}_$onClearRect(){this._$gl.disable(this._$gl.STENCIL_TEST),this._$currentClip=!1}_$endClip(){const t=this._$context._$frameBufferManager,e=t.getTextureFromCurrentAttachment(),i=t.currentAttachment;this._$context._$bind(this._$context._$cacheCurrentBuffer),this._$context._$cacheCurrentBuffer=null,this._$context._$blend.disable();const r=this._$context._$cacheCurrentBounds.x,n=this._$context._$cacheCurrentBounds.y,a=this._$context._$cacheCurrentBounds.w,o=this._$context._$cacheCurrentBounds.h;s.$resetContext(this._$context),this._$context.setTransform(1,0,0,1,0,0),this._$context.drawImage(e,r,n,a,o),this._$context._$blend.enable(),t.releaseAttachment(i,!0)}_$startClip(t,e){const i=s.$multiplicationMatrix(e,t._$transform._$rawMatrix()),r=t._$getBounds(null),n=s.$boundsMatrix(r,i);s.$poolFloat32Array9(i),s.$poolBoundsObject(r);let a=n.xMin,o=n.yMin,h=s.$abs(n.xMax-n.xMin),l=s.$abs(n.yMax-n.yMin);s.$poolBoundsObject(n);const $=this._$context._$frameBufferManager,_=$.currentAttachment;if(h+a>_.texture.width&&(h-=h-_.texture.width+a),l+o>_.texture.height&&(l-=l-_.texture.height+o),0>a&&(h+=a,a=0),0>o&&(l+=o,o=0),0>=h||0>=l)return null;h=s.$ceil(h),l=s.$ceil(l),this._$context._$cacheCurrentBounds.x=a,this._$context._$cacheCurrentBounds.y=o,this._$context._$cacheCurrentBounds.w=h,this._$context._$cacheCurrentBounds.h=l;const c=$.getTextureFromCurrentAttachment();this._$context._$cacheCurrentBuffer=_;const u=s.$currentPlayer(),d=!this._$context._$isWebGL2Context||u._$quality!==G.LOW&&u._$quality!==G.MIDDLE?0:s.$min(s.$HIGH_SAMPLES,this._$gl.getParameter(this._$gl.MAX_SAMPLES)),g=$.createCacheAttachment(h,l,!0,d);return this._$context._$bind(g),s.$resetContext(this._$context),this._$context.setTransform(1,0,0,1,0,0),this._$context.drawImage(c,-a,-o,c.width,c.height),s.$getFloat32Array9(e[0],e[1],e[2],e[3],e[4]-a,e[5]-o)}_$enterClip(){this._$currentClip||(this._$gl.enable(this._$gl.STENCIL_TEST),this._$currentClip=!0);const t=this._$context._$frameBufferManager.currentAttachment;t.mask=!0,++t.clipLevel}_$beginClipDef(){const t=this._$context._$frameBufferManager.currentAttachment;this._$gl.enable(this._$gl.SAMPLE_ALPHA_TO_COVERAGE),this._$gl.stencilFunc(this._$gl.ALWAYS,0,255),this._$gl.stencilOp(this._$gl.KEEP,this._$gl.INVERT,this._$gl.INVERT),this._$gl.stencilMask(1<7&&(this._$context._$unionStencilMask(e,o,h),a=e)}a>e+1&&this._$context._$unionStencilMask(e,o,h)}_$unionStencilMask(t,e,i){const r=this._$context._$path.createRectVertices(0,0,e,i),n=this._$context._$vao.createFill(r);s.$poolArray(r.pop()),s.$poolArray(r);const a=this._$context._$shaderList.shapeShaderVariants,o=a.getMaskShapeShader(!1,!1),h=o.uniform;a.setMaskShapeUniformIdentity(h,e,i);const l=n.indexRanges[0];this._$gl.stencilFunc(this._$gl.LEQUAL,1<1;){const r=s.$floor((i+e)/2);t<=this._$objectPool[r].area?i=r:e=r}return i}}const Ht={vertices:null};Ht.subhulls=new Array(512),Ht.subhullsIndex=0,Ht.extremePoints=new Array(32),Ht.extremePointsIndex=0,Ht.t=0,Ht.hulls=[new Array(16),new Array(64),new Array(256)],Ht.hullsIndex=0;class Yt{constructor(t,e,i){this._$gl=t,this._$isWebGL2Context=e,this._$objectPool=[],this._$frameBuffer=t.createFramebuffer(),this._$frameBufferTexture=null,this._$currentAttachment=null,this._$isBinding=!1,this._$textureManager=new Vt(t,e),this._$colorBufferPool=null,this._$stencilBufferPool=new zt(t),e&&(this._$frameBufferTexture=t.createFramebuffer(),this._$colorBufferPool=new Xt(t,i),t.bindFramebuffer(t.READ_FRAMEBUFFER,this._$frameBuffer))}get currentAttachment(){return this._$currentAttachment}createCacheAttachment(t,e,i=!1,s=0){const r=this._$objectPool.length?this._$objectPool.pop():{},n=this._$textureManager.create(t,e);return r.width=t,r.height=e,this._$isWebGL2Context&&i?(r.color=this._$colorBufferPool.create(t,e,s),r.texture=n,r.msaa=!0,r.stencil=r.color.stencil):(r.color=n,r.texture=n,r.msaa=!1,r.stencil=this._$stencilBufferPool.create(n.width,n.height)),r.mask=!1,r.clipLevel=0,r.isActive=!0,r}createTextureAttachment(t,e){const i=this._$objectPool.length?this._$objectPool.pop():{},s=this._$textureManager.create(t,e);return i.width=t,i.height=e,i.color=s,i.texture=s,i.msaa=!1,i.stencil=null,i.mask=!1,i.clipLevel=0,i.isActive=!0,i}createTextureAttachmentFrom(t){const e=this._$objectPool.length?this._$objectPool.pop():{};return e.width=t.width,e.height=t.height,e.color=t,e.texture=t,e.msaa=!1,e.stencil=null,e.mask=!1,e.clipLevel=0,e.isActive=!0,e}releaseAttachment(t,e=!1){t.isActive&&(t.msaa?this._$colorBufferPool.release(t.color):t.stencil&&this._$stencilBufferPool.release(t.stencil),e&&this._$textureManager.release(t.texture),t.color=null,t.texture=null,t.stencil=null,t.isActive=!1,this._$objectPool.push(t))}bind(t){this._$currentAttachment=t,this._$isBinding||(this._$isBinding=!0,this._$gl.bindFramebuffer(this._$gl.FRAMEBUFFER,this._$frameBuffer)),t.msaa?(this._$gl.bindRenderbuffer(this._$gl.RENDERBUFFER,t.color),this._$gl.framebufferRenderbuffer(this._$gl.FRAMEBUFFER,this._$gl.COLOR_ATTACHMENT0,this._$gl.RENDERBUFFER,t.color)):(this._$textureManager.bind0(t.color),this._$gl.framebufferTexture2D(this._$gl.FRAMEBUFFER,this._$gl.COLOR_ATTACHMENT0,this._$gl.TEXTURE_2D,t.color,0)),this._$gl.bindRenderbuffer(this._$gl.RENDERBUFFER,t.stencil),this._$gl.framebufferRenderbuffer(this._$gl.FRAMEBUFFER,this._$gl.STENCIL_ATTACHMENT,this._$gl.RENDERBUFFER,t.stencil)}unbind(){this._$currentAttachment=null,this._$isBinding&&(this._$isBinding=!1,this._$gl.bindFramebuffer(this._$gl.FRAMEBUFFER,null))}getTextureFromCurrentAttachment(){if(!this._$currentAttachment.msaa)return this._$currentAttachment.texture;const t=this._$currentAttachment.width,e=this._$currentAttachment.height,i=this._$currentAttachment.texture;return i.dirty=!1,this._$gl.bindFramebuffer(this._$gl.DRAW_FRAMEBUFFER,this._$frameBufferTexture),this._$textureManager.bind0(i),this._$gl.framebufferTexture2D(this._$gl.FRAMEBUFFER,this._$gl.COLOR_ATTACHMENT0,this._$gl.TEXTURE_2D,i,0),this._$gl.blitFramebuffer(0,0,t,e,0,0,t,e,this._$gl.COLOR_BUFFER_BIT,this._$gl.NEAREST),this._$gl.bindFramebuffer(this._$gl.FRAMEBUFFER,this._$frameBuffer),i}createTextureFromPixels(t,e,i=null,s=!1,r=!0){return this._$textureManager.create(t,e,i,s,r)}createTextureFromCanvas(t){return this._$textureManager.createFromCanvas(t)}createTextureFromImage(t){return this._$textureManager.createFromImage(t)}createAlphaTextureFromPixels(t,e,i){return this._$textureManager.createAlpha(t,e,i)}createTextureFromVideo(t,e=!1,i=null){return this._$textureManager.createFromVideo(t,e,i)}createTextureFromCurrentAttachment(){const t=this._$currentAttachment.width,e=this._$currentAttachment.height,i=this._$textureManager.create(t,e);return this._$textureManager.bind0(i),this._$gl.copyTexSubImage2D(this._$gl.TEXTURE_2D,0,0,0,0,0,t,e),i}releaseTexture(t){this._$textureManager.release(t)}}class jt{constructor(t,e){this._$gl=t,this._$isWebGL2Context=e,this._$objectPool=[],this._$maxWidth=0,this._$maxHeight=0,this._$cacheSize=0}_$getPixelBufferObject(t){if(!this._$objectPool.length){const t=this._$gl.createBuffer();return t.size=0,t}for(let e=0;ethis._$maxWidth*this._$maxHeight*4)this._$gl.deleteBuffer(t);else if(this._$objectPool.push(t),this._$cacheSize+=t.size/4,this._$cacheSize>this._$maxWidth*this._$maxHeight*10){const t=this._$objectPool.shift();this._$cacheSize-=t.size/4,this._$gl.deleteBuffer(t)}}}class zt{constructor(t){this._$gl=t,this._$objectPool=[],this._$objectPoolArea=0,this._$maxWidth=0,this._$maxHeight=0}_$createStencilBuffer(){const t=this._$gl.createRenderbuffer();return t.width=0,t.height=0,t.area=0,t.dirty=!0,t}_$getStencilBuffer(t,e){const i=this._$objectPool.length;for(let s=0;s100){const t=this._$objectPool.shift();return this._$objectPoolArea-=t.area,t}return this._$createStencilBuffer()}create(t,e){const i=this._$getStencilBuffer(t,e);return i.width===t&&i.height===e||(i.width=t,i.height=e,i.area=t*e,i.dirty=!1,this._$gl.bindRenderbuffer(this._$gl.RENDERBUFFER,i),this._$gl.renderbufferStorage(this._$gl.RENDERBUFFER,this._$gl.STENCIL_INDEX8,t,e)),i}release(t){if(t.area>this._$maxWidth*this._$maxHeight*2|0)this._$gl.deleteRenderbuffer(t);else if(t.dirty=!0,this._$objectPool.push(t),this._$objectPoolArea+=t.area,this._$objectPoolArea>this._$maxWidth*this._$maxHeight*10){const t=this._$objectPool.shift();this._$objectPoolArea-=t.area,this._$gl.deleteRenderbuffer(t)}}}class Vt{constructor(t,e){this._$gl=t,this._$isWebGL2Context=e,this._$objectPool=[],this._$objectPoolArea=0,this._$activeTexture=-1,this._$boundTextures=[null,null,null],this._$maxWidth=0,this._$maxHeight=0,this._$gl.pixelStorei(this._$gl.UNPACK_ALIGNMENT,1),this._$gl.pixelStorei(this._$gl.UNPACK_FLIP_Y_WEBGL,!0)}_$createTexture(e,i){const s=this._$gl.createTexture();return s.width=0,s.height=0,s.area=0,s.dirty=!0,s.smoothing=!0,s._$offsetX=0,s._$offsetY=0,this.bind0(s,!1),this._$gl.texParameteri(this._$gl.TEXTURE_2D,this._$gl.TEXTURE_WRAP_S,this._$gl.CLAMP_TO_EDGE),this._$gl.texParameteri(this._$gl.TEXTURE_2D,this._$gl.TEXTURE_WRAP_T,this._$gl.CLAMP_TO_EDGE),this._$isWebGL2Context&&(s.width=e,s.height=i,s.area=e*i,s.dirty=!1,this._$gl.texStorage2D(this._$gl.TEXTURE_2D,1,this._$gl.RGBA8,e,i),t.glstats&&glstats.ontex(s.area)),s}_$getTexture(t,e){for(let i=0;ithis._$maxWidth*this._$maxHeight*2|0)this._$gl.deleteTexture(t);else if(t.dirty=!0,this._$objectPool.push(t),this._$objectPoolArea+=t.area,this._$objectPoolArea>this._$maxWidth*this._$maxHeight*10){const t=this._$objectPool.shift();this._$objectPoolArea-=t.area,this._$gl.deleteTexture(t)}}bind0(t,e=null){this._$bindTexture(2,this._$gl.TEXTURE2,null,null),this._$bindTexture(1,this._$gl.TEXTURE1,null,null),this._$bindTexture(0,this._$gl.TEXTURE0,t,e)}bind01(t,e,i=null){this._$bindTexture(2,this._$gl.TEXTURE2,null,null),this._$bindTexture(1,this._$gl.TEXTURE1,e,i),this._$bindTexture(0,this._$gl.TEXTURE0,t,i)}bind012(t,e,i,s=null){this._$bindTexture(2,this._$gl.TEXTURE2,i,s),this._$bindTexture(1,this._$gl.TEXTURE1,e,null),this._$bindTexture(0,this._$gl.TEXTURE0,t,null)}bind02(t,e,i=null){this._$bindTexture(2,this._$gl.TEXTURE2,e,i),this._$bindTexture(1,this._$gl.TEXTURE1,null,null),this._$bindTexture(0,this._$gl.TEXTURE0,t,null)}_$bindTexture(t,e,i,r){const n=i!==this._$boundTextures[t],a=null!==r&&r!==i.smoothing;if((n||a||e===this._$gl.TEXTURE0)&&e!==this._$activeTexture&&(this._$activeTexture=e,this._$gl.activeTexture(e)),n&&(this._$boundTextures[t]=i,this._$gl.bindTexture(this._$gl.TEXTURE_2D,i)),a){i.smoothing=r;const t=r&&s.$currentPlayer()._$quality!==G.LOW?this._$gl.LINEAR:this._$gl.NEAREST;this._$gl.texParameteri(this._$gl.TEXTURE_2D,this._$gl.TEXTURE_MIN_FILTER,t),this._$gl.texParameteri(this._$gl.TEXTURE_2D,this._$gl.TEXTURE_MAG_FILTER,t)}}}class Wt{constructor(t,e){this._$gl=t,this._$isWebGL2Context=e,this._$fillVertexArrayPool=[],this._$strokeVertexArrayPool=[],this._$boundVertexArray=null,this._$extension=e?null:t.getExtension("OES_vertex_array_object"),this._$fillAttrib_vertex=0,this._$fillAttrib_bezier=1,this._$strokeAttrib_vertex=0,this._$strokeAttrib_option1=1,this._$strokeAttrib_option2=2,this._$strokeAttrib_type=3,this._$vertexBufferData=new s.$window.Float32Array([0,0,0,1,1,0,1,1]),this._$commonVertexArray=this._$getVertexArray(0,1)}_$createVertexArray(){return this._$isWebGL2Context?this._$gl.createVertexArray():this._$extension.createVertexArrayOES()}_$getVertexArray(t,e){const i=this._$createVertexArray();this.bind(i);const s=this._$gl.createBuffer();return this._$gl.bindBuffer(this._$gl.ARRAY_BUFFER,s),this._$vertexBufferData[0]=t,this._$vertexBufferData[2]=t,this._$vertexBufferData[4]=e,this._$vertexBufferData[6]=e,this._$gl.bufferData(this._$gl.ARRAY_BUFFER,this._$vertexBufferData,this._$gl.STATIC_DRAW),this._$gl.enableVertexAttribArray(0),this._$gl.vertexAttribPointer(0,2,this._$gl.FLOAT,!1,0,0),i}_$getFillVertexArray(){if(this._$fillVertexArrayPool.length)return this._$fillVertexArrayPool.pop();const t=this._$createVertexArray();this.bind(t);const e=this._$gl.createBuffer();return t.vertexBuffer=e,t.vertexLength=0,this._$gl.bindBuffer(this._$gl.ARRAY_BUFFER,e),this._$gl.enableVertexAttribArray(0),this._$gl.enableVertexAttribArray(1),this._$gl.vertexAttribPointer(this._$fillAttrib_vertex,2,this._$gl.FLOAT,!1,16,0),this._$gl.vertexAttribPointer(this._$fillAttrib_bezier,2,this._$gl.FLOAT,!1,16,8),t}_$getStrokeVertexArray(){if(this._$strokeVertexArrayPool.length)return this._$strokeVertexArrayPool.pop();const t=this._$createVertexArray();this.bind(t);const e=this._$gl.createBuffer();t.vertexBuffer=e,t.vertexLength=0,this._$gl.bindBuffer(this._$gl.ARRAY_BUFFER,e);const i=this._$gl.createBuffer();return t.indexBuffer=i,t.indexLength=0,this._$gl.bindBuffer(this._$gl.ELEMENT_ARRAY_BUFFER,i),this._$gl.enableVertexAttribArray(0),this._$gl.enableVertexAttribArray(1),this._$gl.enableVertexAttribArray(2),this._$gl.enableVertexAttribArray(3),this._$gl.vertexAttribPointer(this._$strokeAttrib_vertex,2,this._$gl.FLOAT,!1,28,0),this._$gl.vertexAttribPointer(this._$strokeAttrib_option1,2,this._$gl.FLOAT,!1,28,8),this._$gl.vertexAttribPointer(this._$strokeAttrib_option2,2,this._$gl.FLOAT,!1,28,16),this._$gl.vertexAttribPointer(this._$strokeAttrib_type,1,this._$gl.FLOAT,!1,28,24),t}createFill(t){const e=class{static generate(t){let e=0;for(let i=0;ithis._$vertexBufferData.length){const t=new s.$Float32Array(2*this._$vertexBufferData.length);t.set(this._$vertexBufferData),this._$vertexBufferData=t}}static _$expandIndexBufferIfNeeded(t){if(this._$indexBufferPos+t>this._$indexBufferData.length){const t=new s.$Int16Array(2*this._$indexBufferData.length);t.set(this._$indexBufferData),this._$indexBufferData=t}}static _$generateLineSegment(t){const e=t.length-5;for(let i=0;i0&&(t.assign--,t.method(t.array))}}}class ee{constructor(){this._$stage=new k,this._$stage._$player=this,this._$cacheStore=new pt,this._$mode="loader",this._$actionOffset=0,this._$actions=s.$getArray(),this._$loaders=s.$getArray(),this._$sounds=s.$getMap(),this._$hitObject={x:0,y:0,pointer:"",hit:null},this._$rollOverObject=null,this._$mouseOverTarget=null,this._$mouseWheelEvent=null,this._$ratio=s.$devicePixelRatio,this._$stopFlag=!0,this._$startTime=0,this._$fps=60,this._$isLoad=!1,this._$loadStatus=0,this._$width=0,this._$height=0,this._$baseWidth=0,this._$baseHeight=0,this._$scale=1,this._$matrix=new s.$window.Float32Array([1,0,0,1,0,0]),this._$tx=0,this._$ty=0,this._$backgroundColor=null,this._$state="up",this._$hitTestStart=!1,this._$stageX=-1,this._$stageY=-1,this._$broadcastEvents=s.$getMap(),this._$context=null,this._$canvas=null,this._$buffer=null,this._$optionWidth=0,this._$optionHeight=0,this._$tagId=null,this._$bgColor=null,this._$base="",this._$fullScreen=!1,this._$quality=G.HIGH,this._$sources=s.$getArray(),this._$videos=s.$getArray(),this._$textField=null,this._$bindRun=this._$run.bind(this),this._$timerId=-1,this._$loadId=-1}static get LOAD_START(){return 1}static get LOAD_END(){return 2}get broadcastEvents(){return this._$broadcastEvents}get base(){return this._$base}set base(t){if("string"==typeof t)if(-1===t.indexOf("//")){const e=t.split("/");""!==e[0]&&"."!==e[0]||e.shift(),e.pop(),this._$base=`${s.$location.origin}/`,e.length&&(this._$base+=`${e.join("/")}/`)}else if(-1===t.indexOf("?"))this._$base="/"===t.slice(-1)?t:`${t}/`;else{const e=t.split("?")[0];this._$base="/"===e.slice(-1)?e:`${e}/`}}get stage(){return this._$stage}get x(){return this._$tx}get y(){return this._$ty}get scaleX(){return this._$matrix[0]}get scaleY(){return this._$matrix[3]}get contentElementId(){return`${s.$PREFIX}`}get width(){return this._$baseWidth}set width(t){this._$baseWidth=0|t}get height(){return this._$baseHeight}set height(t){this._$baseHeight=0|t}play(){if(this._$stopFlag){if(this._$stopFlag=!1,this._$timerId>-1){(0,s.$cancelAnimationFrame)(this._$timerId)}this._$startTime=s.$performance.now(),this._$fps=1e3/this._$stage._$frameRate;const t=s.$requestAnimationFrame;this._$timerId=t(this._$bindRun)}}stop(){(0,s.$cancelAnimationFrame)(this._$timerId),this._$stopFlag=!0,this._$timerId=-1,ht.stopAll(),s.$cacheStore().reset()}setOptions(t=null){t&&(this._$optionWidth=t.width||this._$optionWidth,this._$optionHeight=t.height||this._$optionHeight,this._$tagId=t.tagId||this._$tagId,this.base=t.base||this._$base,this._$fullScreen=!!t.fullScreen,"bgColor"in t&&(this._$bgColor=t.bgColor)),this._$initialize()}_$updateLoadStatus(){if(this._$loadStatus===ee.LOAD_END)return void this._$loaded();const t=s.$requestAnimationFrame;this._$loadId=t(this._$updateLoadStatus.bind(this))}_$loaded(){const t=s.$document.getElementById(this.contentElementId);if(t){null!==this._$bgColor&&(this._$backgroundColor=this._$bgColor),this._$context&&(this._$backgroundColor&&"transparent"!==this._$backgroundColor?this._$context._$setColor(this._$backgroundColor[0],this._$backgroundColor[1],this._$backgroundColor[2],this._$backgroundColor[3]):this._$context._$setColor(0,0,0,0)),this._$deleteNode(),t.appendChild(this._$canvas),this.play(),this._$stage._$prepareActions(),this._$broadcastEvents.has(a.FRAME_CONSTRUCTED)&&this._$dispatchEvent(new a(a.FRAME_CONSTRUCTED)),this._$doAction(),this._$broadcastEvents.has(a.EXIT_FRAME)&&this._$dispatchEvent(new a(a.EXIT_FRAME));const e=0|this._$loaders.length;for(let t=0;t`);else{const i=t.getElementById(this._$tagId);if(!i)return void alert("Not Found Tag ID:"+this._$tagId);if(t.getElementById(e))this._$deleteNode();else{const s=t.createElement("div");s.id=e,s.tabIndex=-1,i.appendChild(s)}}this._$canvas||this._$initializeCanvas();const i=t.getElementById(e),r=i.parentNode;if(r){this._$initStyle(i),this._$buildWait();const t=this._$optionWidth?this._$optionWidth:"BODY"===r.tagName?s.$window.innerWidth:r.offsetWidth,e=this._$optionHeight?this._$optionHeight:"BODY"===r.tagName?s.$window.innerHeight:r.offsetHeight;"loader"===this._$mode&&t&&e&&(this._$baseWidth=t,this._$baseHeight=e,this._$resize())}"loader"===this._$mode?(this._$loadStatus=ee.LOAD_START,this._$updateLoadStatus()):(this._$resize(),this._$loaded())}_$initStyle(e){const i=e.style;i.position="relative",i.top="0",i.left="0",i.backgroundColor="transparent",i.overflow="hidden",i.padding="0",i.margin="0",i.userSelect="none",i.outline="none";const s=this._$optionWidth,r=this._$optionHeight,n=e.parentNode;if("BODY"===n.tagName)return i.width=s?`${s}px`:`${t.innerWidth}px`,void(i.height=r?`${r}px`:`${t.innerHeight}px`);i.width=s?`${s}px`:`${n.offsetWidth}px`,i.height=r?`${r}px`:`${n.offsetHeight}px`}_$buildWait(){const t=s.$document.getElementById(this.contentElementId);if(t){const e=`${this.contentElementId}_loading`;t.innerHTML=``;const i=s.$document.createElement("div");i.id=e,t.appendChild(i)}}_$deleteNode(){const t=s.$document.getElementById(this.contentElementId);if(t)for(;t.childNodes.length;)t.removeChild(t.childNodes[0])}_$initializeCanvas(){const e=s.$document.createElement("canvas");e.width=1,e.height=1,this._$canvas=e;const i={stencil:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,preserveDrawingBuffer:!0};let r=!0,n=e.getContext("webgl2",i);if(n||(n=e.getContext("webgl",i)||e.getContext("experimental-webgl",i),r=!1),n?this._$context=new Pt(n,r):alert("WebGL setting is off. Please turn the setting on."),t.glstats&&glstats.init(n,r,s.$isChrome,s.$isFireFox),s.$isTouch){const t=function(e){e.target.removeEventListener(s.$TOUCH_END,t),s.$loadAudioData()};e.addEventListener(s.$TOUCH_END,t),e.addEventListener(s.$TOUCH_START,function(t){s.$event=t,s.$eventType=s.$TOUCH_START,this._$hitTest()}.bind(this)),e.addEventListener(s.$TOUCH_MOVE,function(t){s.$event=t,s.$eventType=s.$TOUCH_MOVE,this._$hitTest()}.bind(this)),e.addEventListener(s.$TOUCH_END,function(t){s.$event=t,s.$eventType=s.$TOUCH_END,this._$hitTest()}.bind(this))}else{const t=function(e){e.target.removeEventListener(s.$MOUSE_DOWN,t),s.$loadAudioData()};e.addEventListener(s.$MOUSE_DOWN,t),e.addEventListener(s.$MOUSE_DOWN,function(t){s.$event=t,s.$eventType=s.$MOUSE_DOWN,t.button||this._$hitTest()}.bind(this)),e.addEventListener(s.$DOUBLE_CLICK,function(t){s.$event=t,s.$eventType=s.$DOUBLE_CLICK,t.button||this._$hitTest()}.bind(this)),e.addEventListener(s.$MOUSE_LEAVE,function(t){s.$event=t,s.$eventType=s.$MOUSE_LEAVE,this._$hitTest(),s.$event=null,this._$stageX=-1,this._$stageY=-1}.bind(this)),e.addEventListener(s.$MOUSE_UP,function(t){s.$event=t,s.$eventType=s.$MOUSE_UP,t.button||this._$hitTest()}.bind(this)),e.addEventListener(s.$MOUSE_MOVE,function(t){s.$event=t,s.$eventType=s.$MOUSE_MOVE,this._$hitTest()}.bind(this)),e.addEventListener(s.$MOUSE_WHEEL,function(t){this._$mouseWheelEvent=t}.bind(this))}const a=e.style;a.position="absolute",a.top="0",a.left="0",a.webkitTapHighlightColor="rgba(0,0,0,0)",a.backfaceVisibility="hidden",a.transformOrigin="0 0",1!==s.$devicePixelRatio&&(a.transform=`scale(${1/s.$devicePixelRatio})`)}_$resize(){const t=s.$document.getElementById(this.contentElementId);if(t){const e=t.parentNode,i=this._$optionWidth?this._$optionWidth:"BODY"===e.tagName?s.$window.innerWidth:e.offsetWidth?e.offsetWidth:s.$parseFloat(e.style.width),r=this._$optionHeight?this._$optionHeight:"BODY"===e.tagName?s.$window.innerHeight:e.offsetHeight?e.offsetHeight:s.$parseFloat(e.style.height),n="BODY"===e.tagName?s.$window.innerWidth:e.offsetWidth,a=s.$min(i/this._$baseWidth,r/this._$baseHeight);let o=this._$fullScreen?i:this._$baseWidth*a|0,h=this._$fullScreen?r:this._$baseHeight*a|0;const l=t.style;if(l.width=`${o}px`,l.height=`${h}px`,l.top="0",l.left=this._$fullScreen?"0":n/2-o/2+"px",o*=s.$devicePixelRatio,h*=s.$devicePixelRatio,this._$scale=a,this._$width=o,this._$height=h,this._$canvas.width=o,this._$canvas.height=h,this._$canvas.style.transform=1===this._$ratio&&1===s.$devicePixelRatio?"":`scale(${1/this._$ratio})`,this._$context){this._$context._$gl.viewport(0,0,o,h);const t=this._$context._$frameBufferManager;this._$buffer&&(t.unbind(),t.releaseAttachment(this._$buffer,!0)),this._$buffer=t.createCacheAttachment(o,h,!1),t._$stencilBufferPool._$maxWidth=o,t._$stencilBufferPool._$maxHeight=h,t._$textureManager._$maxWidth=o,t._$textureManager._$maxHeight=h,this._$context._$pbo._$maxWidth=o,this._$context._$pbo._$maxHeight=h}const $=this._$scale*this._$ratio;this._$matrix[0]=$,this._$matrix[3]=$,this._$fullScreen&&(this._$tx=(o-this._$baseWidth*a*s.$devicePixelRatio)/2,this._$ty=(h-this._$baseHeight*a*s.$devicePixelRatio)/2,this._$matrix[4]=this._$tx,this._$matrix[5]=this._$ty),t.children.length>1&&t.children[1].dispatchEvent(new s.$window.Event(`${s.$PREFIX}_blur`)),this._$stage._$doChanged(),this._$cacheStore.reset()}}getSamples(){switch(this._$quality){case G.HIGH:return s.$HIGH_SAMPLES;case G.MEDIUM:return s.$MEDIUM_SAMPLES;default:return s.$LOW_SAMPLES}}_$dispatchEvent(t){if(this._$broadcastEvents.size&&this._$broadcastEvents.has(t.type)){const e=this._$broadcastEvents.get(t.type).slice(0);t._$eventPhase=h.AT_TARGET;const i=e.length;for(let r=0;rthis._$fps&&(this._$startTime=e-i%this._$fps,this._$action(),this._$draw(0),!this._$hitTestStart&&"up"===this._$state&&s.$event&&this._$stageX>-1&&this._$stageY>-1&&this._$pointerCheck()),t.stats&&stats.end(),t.glstats&&glstats.end();const r=s.$requestAnimationFrame;this._$timerId=r(this._$bindRun)}_$pointerCheck(){const t=this._$stageX,e=this._$stageY;this._$hitObject.x=t,this._$hitObject.y=e,this._$hitObject.pointer="",this._$hitObject.hit=null,s.$hitContext.setTransform(1,0,0,1,0,0),s.$hitContext.beginPath(),s.$MATRIX_HIT_ARRAY_IDENTITY[4]=this._$tx/this._$scale/s.$devicePixelRatio,s.$MATRIX_HIT_ARRAY_IDENTITY[5]=this._$ty/this._$scale/s.$devicePixelRatio,this._$stage._$mouseHit(s.$hitContext,s.$MATRIX_HIT_ARRAY_IDENTITY,this._$hitObject,!0);let i=null,r=null,n=!1,a=!1;if(this._$hitObject.hit){if(i=this._$hitObject.hit,this._$mouseOverTarget&&this._$mouseOverTarget!==i){const t=this._$mouseOverTarget;t.willTrigger(c.MOUSE_OUT)&&t.dispatchEvent(new c(c.MOUSE_OUT,!0,!1,t.mouseX,t.mouseY))}if(this._$rollOverObject!==i){let s=null;if(this._$rollOverObject)for(r=this._$rollOverObject,r.willTrigger(c.ROLL_OUT)&&r.dispatchEvent(new c(c.ROLL_OUT,!1,!1,r.mouseX,r.mouseY)),s=r._$parent;s&&s._$root!==s&&s!==i;){if(s._$mouseEnabled&&s._$outCheck(t,e)){let t=!1,e=i;for(;e&&e._$root!==e;){if(e===s){t=!0;break}e=e._$parent}if(!t&&s._$parent===i._$parent&&s._$index>i._$index&&(t=!0),t)break}s.willTrigger(c.ROLL_OUT)&&s.dispatchEvent(new c(c.ROLL_OUT,!1,!1,s.mouseX,s.mouseY)),s=s._$parent}for(r=i;r.willTrigger(c.ROLL_OVER)&&r.dispatchEvent(new c(c.ROLL_OVER,!1,!1,r.mouseX,r.mouseY)),r=r._$parent,r&&r!==s&&r.stage!==r;);}switch(this._$rollOverObject=i,!0){case null===this._$mouseOverTarget:case this._$mouseOverTarget!==i:i.willTrigger(c.MOUSE_OVER)&&i.dispatchEvent(new c(c.MOUSE_OVER,!0,!1,i.mouseX,i.mouseY)),this._$mouseOverTarget=i}if("up"===this._$state&&(this._$clickTarget=null),!s.$isTouch&&"up"===this._$state)for(r=i;r&&r.root!==r;){switch(!0){case r instanceof st:r._$type===rt.INPUT&&(n=!0);break;case r.buttonMode:a=!0}if(n||a)break;r=r._$parent}}else{if(this._$mouseOverTarget&&(i=this._$mouseOverTarget,i.willTrigger(c.MOUSE_OUT)&&i.dispatchEvent(new c(c.MOUSE_OUT,!0,!1,i.mouseX,i.mouseY))),this._$rollOverObject)for(r=this._$rollOverObject;r&&r.root!==r;)r.willTrigger(c.ROLL_OUT)&&r.dispatchEvent(new c(c.ROLL_OUT,!1,!1,r.mouseX,r.mouseY)),r=r._$parent;this._$rollOverObject=null,this._$mouseOverTarget=null}switch(!0){case n:this._$canvas.style.cursor="text";break;case a:this._$canvas.style.cursor="pointer";break;case!s.$isTouch&&"up"===this._$state:this._$canvas.style.cursor="auto"}this._$actions.length>1&&this._$doAction()}_$action(){if(this._$stopFlag)return;let t=null;const e=this._$loaders.length;if(e){t=this._$loaders.slice(0),this._$loaders.length=0;for(let i=0;i0&&i>0){if(r._$bind(this._$buffer),s.$resetContext(r),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e,i),r.beginPath(),this._$stage._$draw(r,this._$matrix,s.$COLOR_ARRAY_IDENTITY),this._$stage._$updated=!1,this._$sounds.size){const t=this._$sounds.values();for(let e of t)e._$soundPlay();this._$sounds.clear()}const t=r.frameBuffer.getTextureFromCurrentAttachment();r.frameBuffer.unbind(),s.$resetContext(r),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e,i),r.drawImage(t,0,0,e,i),r._$bind(this._$buffer)}}_$doAction(){for(;this._$actions.length;){s.$actionProcess=!0;const t=this._$actions.pop();t._$canAction=!1,t._$actionOffset=0,t._$actionLimit=0;const e=t._$currentFrame;if(!t._$actions.has(e))continue;t._$actionProcess=!0;const i=t._$actions.get(e),r=i.length;for(let e=0;ee._$index&&(i=!0),i)break}t.willTrigger(c.ROLL_OUT)&&t.dispatchEvent(new c(c.ROLL_OUT,!1,!1,t.mouseX,t.mouseY)),t=t._$parent}for(i=e;i.willTrigger(c.ROLL_OVER)&&i.dispatchEvent(new c(c.ROLL_OVER,!1,!1,i.mouseX,i.mouseY)),i=i._$parent,i&&i!==t&&i.stage!==i;);}switch(this._$rollOverObject=e,!0){case null===this._$mouseOverTarget:case this._$mouseOverTarget!==e:e.willTrigger(c.MOUSE_OVER)&&e.dispatchEvent(new c(c.MOUSE_OVER,!0,!1,e.mouseX,e.mouseY)),this._$mouseOverTarget=e}"up"===this._$state&&(this._$clickTarget=null);break;case s.$TOUCH_START:case s.$MOUSE_DOWN:e!==this._$textField&&this._$textField instanceof st&&(this._$textField.focus=!1,this._$textField=null),e instanceof st&&(e.focus=!0,this._$textField=e),e.willTrigger(c.MOUSE_DOWN)&&e.dispatchEvent(new c(c.MOUSE_DOWN,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget=e;break;case s.$TOUCH_END:case s.$MOUSE_UP:e!==this._$textField&&this._$textField instanceof st&&(this._$textField.focus=!1,this._$textField=null),e.willTrigger(c.MOUSE_UP)&&e.dispatchEvent(new c(c.MOUSE_UP,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget===e&&e.willTrigger(c.CLICK)&&e.dispatchEvent(new c(c.CLICK,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget=null;break;case s.$MOUSE_WHEEL:e.willTrigger(c.MOUSE_WHEEL)&&e.dispatchEvent(new c(c.MOUSE_WHEEL)),e instanceof st&&(e.scrollV+=t.deltaY);break;case s.$DOUBLE_CLICK:e.willTrigger(c.DOUBLE_CLICK)&&e.dispatchEvent(new c(c.DOUBLE_CLICK))}if(!$&&!s.$isTouch&&"up"===this._$state)for(i=e;i&&i.root!==i;){if(i instanceof st){if(i._$type===rt.INPUT){l=!0;break}}else if(i._$buttonMode){_=!0;break}i=i._$parent}}switch(!0){case l:this._$canvas.style.cursor="text";break;case _:this._$canvas.style.cursor="pointer";break;case!s.$isTouch&&"up"===this._$state:this._$canvas.style.cursor="auto"}!s.$actionProcess&&this._$actions.length>1&&this._$doAction(),s.$isUpdated&&(t.preventDefault(),this._$stage._$prepareActions(),s.$actionProcess||this._$doAction()),this._$hitTestStart=!1}}s.$window.next2d=new class{constructor(){this._$player=new ee}load(t,e=null){if("develop"===t){const e=s.$location.search.substr(1).split("&")[0];if(!e)return;t=`${s.$location.origin}/${e}`}if(!t)return;"/"===t.charAt(1)&&(t=t.slice(1)),e&&"base"in e||!(t.indexOf("//")>-1)||(this._$player.base=t),this._$player.setOptions(e);const i=new P,r=i.contentLoaderInfo;r.addEventListener(_.IO_ERROR,(function(t){t.target.removeEventListener(_.IO_ERROR,t.listener),alert("Error: "+t.message)})),r.addEventListener(a.COMPLETE,(function(t){const e=t.target;e.removeEventListener(a.COMPLETE,t.listener);const i=s.$currentPlayer(),r=i.stage,n=e._$data.stage;if(i.width=n.width,i.height=n.height,i.stage.frameRate=n.fps,null===i._$bgColor){const t=s.$intToRGBA(0|`0x${n.bgColor.substr(1)}`);i._$context._$setColor(t.R/255,t.G/255,t.B/255,1),i._$backgroundColor=[t.R/255,t.G/255,t.B/255,1]}r.addChild(e.content),i._$resize()})),i.load(new ct(t))}createRootMovieClip(t=240,e=240,i=24,s=null){const r=this._$player;return r._$loadStatus=ee.LOAD_END,r._$mode="create",r._$stage.frameRate=0|i,r.width=0|t,r.height=0|e,r.setOptions(s),r._$stage.addChild(new y)}},s.$packages(s.$window.next2d),console.log("%c Next2D Player %c 1.4.14 %c https://next2d.app","color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")}(window); \ No newline at end of file +"next2d"in window||function(t){"use strict";let e=0,i=0;const s={$PREFIX:"__next2d__"};s.$MAX_VALUE=t.Number.MAX_VALUE,s.$MIN_VALUE=t.Number.MIN_VALUE,s.$HIGH_SAMPLES=4,s.$MEDIUM_SAMPLES=2,s.$LOW_SAMPLES=0,s.$LOAD_START="loadstart",s.$PROGRESS="progress",s.$LOADEND="loadend",s.$TOUCH_START="touchstart",s.$TOUCH_MOVE="touchmove",s.$TOUCH_END="touchend",s.$MOUSE_DOWN="mousedown",s.$MOUSE_MOVE="mousemove",s.$MOUSE_UP="mouseup",s.$MOUSE_WHEEL="wheel",s.$DOUBLE_CLICK="dblclick",s.$MOUSE_LEAVE="mouseleave",s.$KEY_DOWN="keydown",s.$KEY_UP="keyup",s.$SCROLL="scroll",s.$P_TAG=t.document.createElement("p"),s.$COLOR_ARRAY_IDENTITY=new Float32Array([1,1,1,1,0,0,0,0]),s.$COLOR_MATRIX_FILTER=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],s.$soundMixerVolume=1,s.$bezierConverterBuffer=new Array(32),s.$window=t,s.$document=t.document,s.$navigator=t.navigator,s.$userAgent=t.navigator.userAgent,s.$location=t.location,s.$RegExp=t.RegExp,s.$isNaN=t.isNaN,s.$min=Math.min,s.$max=Math.max,s.$sin=Math.sin,s.$cos=Math.cos,s.$tan=Math.tan,s.$sqrt=Math.sqrt,s.$pow=Math.pow,s.$abs=Math.abs,s.$sign=Math.sign,s.$ceil=Math.ceil,s.$atan2=Math.atan2,s.$floor=Math.floor,s.$round=Math.round,s.$SQRT2=Math.SQRT2,s.$PI=Math.PI,s.$Deg2Rad=s.$PI/180,s.$Rad2Deg=180/s.$PI,s.$Array=t.Array,s.$Map=t.Map,s.$Image=t.Image,s.$URL=t.URL,s.$Blob=t.Blob,s.$parseFloat=t.parseFloat,s.$setTimeout=t.setTimeout,s.$encodeURIComponent=t.encodeURIComponent,s.$Infinity=t.Infinity,s.$WebGLTexture=t.WebGLTexture,s.$clearTimeout=t.clearTimeout,s.$setTimeout=t.setTimeout,s.$audioContext=null,s.$CanvasRenderingContext2D=t.CanvasRenderingContext2D,s.$requestAnimationFrame=t.requestAnimationFrame,s.$cancelAnimationFrame=t.cancelAnimationFrame,s.$performance=t.performance,s.$Float32Array=t.Float32Array,s.$Int16Array=t.Int16Array,s.$variables=new Map,s.$loadedImages=new Map,s.$isUpdated=!1,s.$event=null,s.$dropTarget=null,s.$dragRules={lock:!1,position:{x:0,y:0},bounds:null},s.$rgbToLinearTable=new s.$Float32Array(256),s.$rgbIdentityTable=new s.$Float32Array(256);for(let t=0;t<256;++t)s.$rgbToLinearTable[t]=s.$pow(t/255,2.23333333),s.$rgbIdentityTable[t]=t/255;s.$SHORT_INT_MIN=-32768,s.$SHORT_INT_MAX=32767,s.$devicePixelRatio=s.$min(2,t.devicePixelRatio),s.$MATRIX_HIT_ARRAY_IDENTITY=new Float32Array([1,0,0,1,0,0]),s.$MATRIX_ARRAY_IDENTITY=new Float32Array([1,0,0,1,0,0]),s.$MATRIX_ARRAY_RATIO_0_0_RATIO_0_0=new Float32Array([s.$devicePixelRatio,0,0,s.$devicePixelRatio,0,0]),s.$bounds=[],s.$arrays=[],s.$audios=[],s.$maps=[],s.$preObjects=[],s.$matrices=[],s.$colors=[],s.$float32Array4=[],s.$float32Array6=[],s.$float32Array8=[],s.$float32Array9=[],s.$isAndroid=s.$userAgent.indexOf("Android")>-1,s.isiOS=s.$userAgent.indexOf("iPhone")>-1||s.$userAgent.indexOf("iPod")>-1,s.$isTouch=s.$isAndroid||s.isiOS,s.$isChrome=s.$userAgent.indexOf("Chrome")>-1,s.$isFireFox=s.$userAgent.indexOf("Firefox")>-1,s.$isSafari=-1===s.$userAgent.indexOf("Chrome")&&s.$userAgent.indexOf("Safari")>-1,s.$isEdge=s.$userAgent.indexOf("Edge")>-1,s.$isMac=s.$userAgent.indexOf("Mac")>-1,s.$isWindows=!1===s.$isMac,s.$currentLoaderInfo=null;const r=t.document.createElement("canvas");r.width=1,r.height=1,s.$hitContext=r.getContext("2d"),s.$hitContext.globalAlpha=0,s.$hitContext.imageSmoothingEnabled=!1;const n=t.document.createElement("canvas");n.width=1,n.height=1,s.$textContext=n.getContext("2d"),s.$hitContext.globalAlpha=0,s.$hitContext.imageSmoothingEnabled=!1,s.$DIV=null,s.$isArray=t=>s.$Array.isArray(t),s.$getArray=(...t)=>{const e=s.$arrays.pop()||[];return t.length&&e.push.apply(e,t),e},s.$poolArray=t=>{t.length&&(t.length=0),s.$arrays.push(t)},s.$clamp=(t,e,i,r=null)=>{const n=+t;return s.$isNaN(n)&&null!==r?r:s.$min(s.$max(e,s.$isNaN(n)?0:n),i)},s.$multiplicationColor=(t,e)=>s.$getFloat32Array8(t[0]*e[0],t[1]*e[1],t[2]*e[2],t[3]*e[3],t[0]*e[4]+t[4],t[1]*e[5]+t[5],t[2]*e[6]+t[6],t[3]*e[7]+t[7]),s.$multiplicationMatrix=(t,e)=>s.$getFloat32Array6(t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]),s.$getBoundsObject=(t=0,e=0,i=0,r=0)=>{const n=s.$bounds.pop()||{xMin:0,xMax:0,yMin:0,yMax:0};return n.xMin=t,n.xMax=e,n.yMin=i,n.yMax=r,n},s.$poolBoundsObject=t=>{s.$bounds.push(t)},s.$poolMap=t=>{t.size&&t.clear(),s.$maps.push(t)},s.$getMap=()=>s.$maps.pop()||new s.$Map,s.$getFloat32Array4=(t=0,e=0,i=0,r=0)=>{const n=s.$float32Array4.pop()||new s.$window.Float32Array(4);return n[0]=t,n[1]=e,n[2]=i,n[3]=r,n},s.$poolFloat32Array4=t=>{s.$float32Array4.push(t)},s.$getFloat32Array6=(t=0,e=0,i=0,r=0,n=0,a=0)=>{const o=s.$float32Array6.pop()||new s.$window.Float32Array(6);return o[0]=t,o[1]=e,o[2]=i,o[3]=r,o[4]=n,o[5]=a,o},s.$poolFloat32Array6=t=>{s.$float32Array6.push(t)},s.$getFloat32Array8=(t=1,e=1,i=1,r=1,n=0,a=0,o=0,h=0)=>{const l=s.$float32Array8.pop()||new s.$window.Float32Array(8);return l[0]=t,l[1]=e,l[2]=i,l[3]=r,l[4]=n,l[5]=a,l[6]=o,l[7]=h,l},s.$poolFloat32Array8=t=>{s.$float32Array8.push(t)},s.$getFloat32Array9=(t=0,e=0,i=0,r=0,n=0,a=0,o=0,h=0,l=0)=>{const $=s.$float32Array9.pop()||new s.$window.Float32Array(9);return $[0]=t,$[1]=e,$[2]=i,$[3]=r,$[4]=n,$[5]=a,$[6]=o,$[7]=h,$[8]=l,$},s.$poolFloat32Array9=t=>{s.$float32Array9.push(t)},s.$currentPlayer=()=>t.next2d._$player,s.$currentMousePoint=()=>{const t=s.$currentPlayer();let e=s.$window.pageXOffset,i=s.$window.pageYOffset;const r=s.$document.getElementById(t.contentElementId);if(r){const t=r.getBoundingClientRect();e+=t.left,i+=t.top}let n=s.$event.pageX,a=s.$event.pageY;if(s.$isTouch){const t=s.$event.changedTouches[0];n=t.pageX,a=t.pageY}const o=(n-e)/t._$scale|0,h=(a-i)/t._$scale|0;return new m(o,h)},s.$boundsMatrix=(t,e)=>{const i=t.xMax*e[0]+t.yMax*e[2]+e[4],r=t.xMax*e[0]+t.yMin*e[2]+e[4],n=t.xMin*e[0]+t.yMax*e[2]+e[4],a=t.xMin*e[0]+t.yMin*e[2]+e[4],o=t.xMax*e[1]+t.yMax*e[3]+e[5],h=t.xMax*e[1]+t.yMin*e[3]+e[5],l=t.xMin*e[1]+t.yMax*e[3]+e[5],$=t.xMin*e[1]+t.yMin*e[3]+e[5],_=s.$min(s.$MAX_VALUE,i,r,n,a),c=s.$max(-s.$MAX_VALUE,i,r,n,a),u=s.$min(s.$MAX_VALUE,o,h,l,$),d=s.$max(-s.$MAX_VALUE,o,h,l,$);return s.$getBoundsObject(_,c,u,d)},s.$upperPowerOfTwo=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t),s.$getMatrix=(t=1,e=0,i=0,r=1,n=0,a=0)=>{if(!s.$matrices.length)return new f(t,e,i,r,n,a);const o=s.$matrices.pop();return o._$matrix=s.$getFloat32Array6(t,e,i,r,n,a),o},s.$poolMatrix=t=>{s.$poolFloat32Array6(t._$matrix),t._$matrix=null,s.$matrices.push(t)},s.$toBoolean=(t=!1)=>{switch(typeof t){case"boolean":return t;case"function":return!0;case"object":case"string":case"number":return!!t;default:return!1}},s.$getColorTransform=(t=1,e=1,i=1,r=1,n=0,a=0,o=0,h=0)=>{if(!s.$colors.length)return new g(t,e,i,r,n,a,o,h);const l=s.$colors.pop();return l._$colorTransform=s.$getFloat32Array8(t,e,i,r,n,a,o,h),l},s.$poolColorTransform=t=>{s.$poolFloat32Array8(t._$colorTransform),t._$colorTransform=null,s.$colors.push(t)},s.$toColorInt=t=>s.$isNaN(+t)?s.$colorStringToInt(t):+t,s.$colorStringToInt=t=>{s.$hitContext.fillStyle=t;const e=s.$hitContext.fillStyle.substr(1);return s.$hitContext.fillStyle="rgba(0, 0, 0, 1)",0|`0x${e}`},s.$intToR=(t,e,i)=>(t>>16)*(i?e:1)/255,s.$intToG=(t,e,i)=>(t>>8&255)*(i?e:1)/255,s.$intToB=(t,e,i)=>(255&t)*(i?e:1)/255,s.$uintToRGBA=t=>({A:t>>>24,R:(16711680&t)>>16,G:(65280&t)>>8,B:255&t}),s.$intToRGBA=(t,e=1)=>({R:(16711680&t)>>16,G:(65280&t)>>8,B:255&t,A:255*e}),s.$generateColorTransform=(t,e)=>({R:s.$max(0,s.$min(t.R*e[0]+e[4],255)),G:s.$max(0,s.$min(t.G*e[1]+e[5],255)),B:s.$max(0,s.$min(t.B*e[2]+e[6],255)),A:s.$max(0,s.$min(255*t.A*e[3]+e[7],255))/255}),s.$cacheStore=()=>s.$currentPlayer()._$cacheStore,s.$inverseMatrix=t=>{const e=1/(t[0]*t[4]-t[3]*t[1]),i=t[3]*t[7]-t[4]*t[6],r=t[1]*t[6]-t[0]*t[7];return s.$getFloat32Array9(t[4]*e,-t[1]*e,0,-t[3]*e,t[0]*e,0,i*e,r*e,1)},s.$decodeAudioFailed=function(){const t=this._$character?this._$character.buffer:this._$buffer;let e=0;for(;e=t.indexOf(255,e),-1!==e&&224!=(224&t[e+1]);)++e;e>-1&&s.$audioContext.decodeAudioData(t.buffer.subarray(e),s.$decodeAudioSuccess.bind(this))},s.$decodeAudioSuccess=function(t){this._$character?(this._$character.buffer=null,this._$character.audioBuffer=t):(this._$buffer=null,this._$audioBuffer=t)},s.$decodeAudioData=t=>{const e=t._$character?t._$character.buffer:t._$buffer;e&&s.$audioContext.decodeAudioData(e.buffer,s.$decodeAudioSuccess.bind(t),s.$decodeAudioFailed.bind(t))},s.$loadAudioData=()=>{if(s.$audioContext||(s.$audioContext=new s.$window.AudioContext,s.$audioContext.resume()),s.$audioContext){const t=s.$audios.length;for(let e=0;e255===t[0]&&216===t[1]?"jpeg":71===t[0]&&73===t[1]&&70===t[2]?"gif":137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]&&13===t[4]&&10===t[5]&&26===t[6]&&10===t[7]?"png":66===t[0]&&77===t[1]?"bmp":null,s.$resizeTimerId=0,s.$resize=()=>{(0,s.$clearTimeout)(s.$resizeTimerId);const t=s.$setTimeout;s.$resizeTimerId=t(s.$resizeExecute,300)},s.$resizeExecute=()=>{const t=s.$currentPlayer();if(t._$loadStatus===ee.LOAD_END){t._$resize();const e=t._$stage;e.willTrigger(a.RESIZE)&&e.dispatchEvent(new a(a.RESIZE))}},s.$window.addEventListener("resize",s.$resize),s.$resetContext=t=>{const e=t._$contextStyle;switch(e._$fillStyle.constructor){case Ft:case Lt:e._$fillStyle=s.$getFloat32Array4(1,1,1,1);break;default:e._$fillStyle[0]=1,e._$fillStyle[1]=1,e._$fillStyle[2]=1,e._$fillStyle[3]=1}switch(e._$strokeStyle.constructor){case Ft:case Lt:e._$strokeStyle=s.$getFloat32Array4(1,1,1,1);break;default:e._$strokeStyle[0]=1,e._$strokeStyle[1]=1,e._$strokeStyle[2]=1,e._$strokeStyle[3]=1}t._$style=e,t._$globalAlpha=1,t._$globalCompositeOperation=C.NORMAL,t._$imageSmoothingEnabled=!1},s.$getPreObject=()=>s.$preObjects.pop()||{isFilter:!1,isUpdated:null,canApply:null,matrix:null,color:null,basePosition:{x:0,y:0},position:{dx:0,dy:0},baseMatrix:null,baseColor:null,currentAttachment:null,currentMaskBuffer:null,currentMaskBounds:null,cacheCurrentBounds:null,blendMode:null,filters:null,layerWidth:null,layerHeight:null},s.$poolPreObject=t=>{t.isFilter=!1,t.isUpdated=null,t.canApply=null,t.matrix=null,t.color=null,t.baseMatrix=null,t.baseColor=null,t.currentAttachment=null,t.currentMaskBuffer=null,t.currentMaskBounds=null,t.cacheCurrentBounds=null,t.blendMode=null,t.filters=null,t.layerWidth=null,t.layerHeight=null,s.$preObjects.push(t)},s.$cross=(t,e,i,s)=>t*s-i*e,s.$linearGradientXY=t=>{const e=-819.2*t[0]-819.2*t[2]+t[4],i=819.2*t[0]-819.2*t[2]+t[4],r=-819.2*t[0]+819.2*t[2]+t[4],n=-819.2*t[1]-819.2*t[3]+t[5],a=819.2*t[1]-819.2*t[3]+t[5];let o=r-e,h=-819.2*t[1]+819.2*t[3]+t[5]-n;const l=s.$sqrt(o*o+h*h);l?(o/=l,h/=l):(o=0,h=0);const $=(i-e)*o+(a-n)*h;return s.$getArray(e+$*o,n+$*h,i,a)},s.$ajax=(t=null)=>{t||(t={method:"GET"}),"method"in t||(t.method="GET");let e=null;switch(t.method.toUpperCase()){case $t.GET:if(t.data){const e=t.url.split("?");e[1]=1===e.length?t.data.toString():e[1]+"&"+t.data.toString(),t.url=e.join("?")}break;case $t.PUT:case $t.POST:e=t.data?t.data.toString():null}const i=new XMLHttpRequest;if(i.open(t.method,t.url,!0),t.withCredentials&&(i.withCredentials=!0),t.event){const e=Object.keys(t.event),r=e.length;for(let s=0;s{const e=s.$getArray();if(t){const i=t.trim().split("\n"),s=i.length;for(let t=0;t{const e=t.split(".");let i=s.$window;for(let t=0;t{throw new Error("image encoding error")}))}else s.$imageWorkerActive=!1},s.$unzipURL=URL.createObjectURL(new Blob(['/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function(){"use strict";var t=void 0,r=this;function i(i,e){var s,h=i.split("."),n=r;!(h[0]in n)&&n.execScript&&n.execScript("var "+h[0]);for(;h.length&&(s=h.shift());)h.length||e===t?n=n[s]?n[s]:n[s]={}:n[s]=e}var e="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;function s(t){var r,i,s,h,n,a,o,f,l,u,c=t.length,b=0,y=Number.POSITIVE_INFINITY;for(f=0;fb&&(b=t[f]),t[f]>=1;for(u=s<<16|f,l=a;l>>=1){case 0:var i=this.input,h=this.a,o=this.c,f=this.b,l=i.length,u=t,b=o.length,y=t;if(this.d=this.f=0,h+1>=l)throw Error("invalid uncompressed block header: LEN");if(u=i[h++]|i[h++]<<8,h+1>=l)throw Error("invalid uncompressed block header: NLEN");if(u===~(i[h++]|i[h++]<<8))throw Error("invalid uncompressed block header: length verify");if(h+u>i.length)throw Error("input buffer is broken");switch(this.i){case n:for(;f+u>o.length;){if(u-=y=b-f,e)o.set(i.subarray(h,h+y),f),f+=y,h+=y;else for(;y--;)o[f++]=i[h++];this.b=f,o=this.e(),f=this.b}break;case a:for(;f+u>o.length;)o=this.e({p:2});break;default:throw Error("invalid inflate mode")}if(e)o.set(i.subarray(h,h+u),f),f+=u,h+=u;else for(;u--;)o[f++]=i[h++];this.a=h,this.b=f,this.c=o;break;case 1:this.j(E,z);break;case 2:var p,d,g,v,w=S(this,5)+257,A=S(this,5)+1,k=S(this,4)+4,U=new(e?Uint8Array:Array)(c.length),m=t,I=t,x=t,N=t,j=t;for(j=0;j=f?8:255>=f?9:279>=f?7:8;var U,m,E=s(k),I=new(e?Uint8Array:Array)(30);for(U=0,m=I.length;U=a)throw Error("input buffer is broken");e|=h[n++]<>>r,t.d=s-r,t.a=n,i}function T(t,r){for(var i,e,s=t.f,h=t.d,n=t.input,a=t.a,o=n.length,f=r[0],l=r[1];h=o);)s|=n[a++]<>>16)>h)throw Error("invalid code length: "+e);return t.f=s>>e,t.d=h-e,t.a=a,65535&i}function x(t,r){var i,e;if(this.input=t,this.a=0,!r&&(r={})||(r.index&&(this.a=r.index),r.verify&&(this.A=r.verify)),i=t[this.a++],e=t[this.a++],(15&i)!==N)throw Error("unsupported compression method");if(this.method=N,0!=((i<<8)+e)%31)throw Error("invalid fcheck flag:"+((i<<8)+e)%31);if(32&e)throw Error("fdict flag is not supported");this.q=new h(t,{index:this.a,bufferSize:r.bufferSize,bufferType:r.bufferType,resize:r.resize})}h.prototype.j=function(t,r){var i=this.c,e=this.b;this.o=t;for(var s,h,n,a,o=i.length-258;256!==(s=T(this,t));)if(256>s)e>=o&&(this.b=e,i=this.e(),e=this.b),i[e++]=s;else for(a=y[h=s-257],0=o&&(this.b=e,i=this.e(),e=this.b);a--;)i[e]=i[e++-n];for(;8<=this.d;)this.d-=8,this.a--;this.b=e},h.prototype.w=function(t,r){var i=this.c,e=this.b;this.o=t;for(var s,h,n,a,o=i.length;256!==(s=T(this,t));)if(256>s)e>=o&&(o=(i=this.e()).length),i[e++]=s;else for(a=y[h=s-257],0o&&(o=(i=this.e()).length);a--;)i[e]=i[e++-n];for(;8<=this.d;)this.d-=8,this.a--;this.b=e},h.prototype.e=function(){var t,r,i=new(e?Uint8Array:Array)(this.b-32768),s=this.b-32768,h=this.c;if(e)i.set(h.subarray(32768,i.length));else for(t=0,r=i.length;tt;++t)h[t]=h[s+t];return this.b=32768,h},h.prototype.z=function(t){var r,i,s,h=this.input.length/this.a+1|0,n=this.input,a=this.c;return t&&("number"==typeof t.p&&(h=t.p),"number"==typeof t.u&&(h+=t.u)),2>h?i=(s=(n.length-this.a)/this.o[2]/2*258|0)r&&(this.c.length=r),t=this.c),this.buffer=t},x.prototype.k=function(){var t,r,i=this.input;if(t=this.q.k(),this.a=this.q.a,this.A){r=(i[this.a++]<<24|i[this.a++]<<16|i[this.a++]<<8|i[this.a++])>>>0;var e=t;if("string"==typeof e){var s,h,n=e.split("");for(s=0,h=n.length;s>>0;e=n}for(var a,o=1,f=0,l=e.length,u=0;0>>0)throw Error("invalid adler-32 checksum")}return t};var N=8;i("Zlib.Inflate",x),i("Zlib.Inflate.prototype.decompress",x.prototype.k);var j,C,O,L,Z={ADAPTIVE:o.s,BLOCK:o.t};if(Object.keys)j=Object.keys(Z);else for(C in j=[],O=0,Z)j[O++]=C;for(O=0,L=j.length;O{t.display={BitmapData:A,BitmapDataChannel:M,BlendMode:C,CapsStyle:S,DisplayObject:b,DisplayObjectContainer:v,FrameLabel:R,GradientType:w,Graphics:O,GraphicsGradientFill:B,InteractiveObject:T,InterpolationMethod:F,JointStyle:L,Loader:P,LoaderInfo:D,MovieClip:E,Shape:N,SpreadMethod:U,Sprite:y,Stage:k},t.events={Event:a,EventDispatcher:o,EventPhase:h,FocusEvent:l,HTTPStatusEvent:$,IOErrorEvent:_,MouseEvent:c,ProgressEvent:u,VideoEvent:d},t.filters={BevelFilter:V,BitmapFilterQuality:Y,BitmapFilterType:H,BlurFilter:z,ColorMatrixFilter:W,ConvolutionFilter:q,DisplacementMapFilter:K,DisplacementMapFilterMode:j,DropShadowFilter:Q,GlowFilter:J,GradientBevelFilter:Z,GradientGlowFilter:tt},t.geom={ColorTransform:g,Matrix:f,Point:m,Rectangle:p,Transform:x},t.media={Sound:_t,SoundMixer:ct,SoundTransform:ut,Video:dt},t.net={URLLoaderDataFormat:ot,URLRequest:ht,URLRequestHeader:lt,URLRequestMethod:$t},t.text={TextField:st,TextFieldAutoSize:it,TextFieldType:rt,TextFormat:nt,TextFormatAlign:et,TextFormatVerticalAlign:at},t.ui={Easing:gt,Job:ft,Tween:mt}};class a{constructor(t,e=!1,i=!1){this._$type=`${t}`,this._$bubbles=!!e,this._$cancelable=!!i,this._$target=null,this._$currentTarget=null,this._$eventPhase=h.AT_TARGET,this._$listener=null,this._$stopImmediatePropagation=!1,this._$stopPropagation=!1,this._$preventDefault=!1}static toString(){return"[class Event]"}static get namespace(){return"next2d.events.Event"}toString(){return this.formatToString("Event","type","bubbles","cancelable","eventPhase")}get namespace(){return"next2d.events.Event"}static get ACTIVATE(){return"activate"}static get ADDED(){return"added"}static get ADDED_TO_STAGE(){return"addedToStage"}static get CHANGE(){return"change"}static get COMPLETE(){return"complete"}static get DEACTIVATE(){return"deactivate"}static get ENTER_FRAME(){return"enterFrame"}static get EXIT_FRAME(){return"exitFrame"}static get FRAME_CONSTRUCTED(){return"frameConstructed"}static get FRAME_LABEL(){return"frameLabel"}static get INIT(){return"init"}static get MOUSE_LEAVE(){return"mouseLeave"}static get REMOVED(){return"removed"}static get REMOVED_FROM_STAGE(){return"removedFromStage"}static get RENDER(){return"render"}static get RESIZE(){return"resize"}static get SCROLL(){return"scroll"}static get STOP(){return"stop"}static get SOUND_COMPLETE(){return"soundComplete"}static get UPDATE(){return"update"}get bubbles(){return this._$bubbles}get cancelable(){return this._$cancelable}get currentTarget(){return this._$currentTarget}get eventPhase(){return this._$eventPhase}get listener(){return this._$listener}get target(){return this._$target?this._$target:this._$currentTarget}get type(){return this._$type}formatToString(){let t=`[${arguments[0]}`;for(let e=1;ee.priority:return-1;case t.prioritye.priority:return-1;case t.prioritye.priority:return-1;case t.priorityt&&this.bottom>e}containsPoint(t){return this.x<=t.x&&this.y<=t.y&&this.right>t.x&&this.bottom>t.y}containsRect(t){return this.x<=t.x&&this.y<=t.y&&this.right>=t.right&&this.bottom>=t.bottom}copyFrom(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}inflate(t,e){this.x=this.x-+t,this.width=this.width+2*+t,this.y=this.y-+e,this.height=this.height+2*+e}inflatePoint(t){this.x=this.x-t.x,this.width=this.width+2*t.x,this.y=this.y-t.y,this.height=this.height+2*t.y}intersection(t){const e=s.$max(this.x,t.x),i=s.$max(this.y,t.y),r=s.$min(this.right,t.right)-e,n=s.$min(this.bottom,t.bottom)-i;return r>0&&n>0?new p(e,i,r,n):new p(0,0,0,0)}intersects(t){const e=s.$max(this.x,t.x),i=s.$max(this.y,t.y),r=s.$min(this.right,t.right),n=s.$min(this.bottom,t.bottom);return r-e>0&&n-i>0}isEmpty(){return this.width<=0||this.height<=0}offset(t,e){this.x+=t,this.y+=e}offsetPoint(t){this.x+=t.x,this.y+=t.y}setEmpty(){this._$x=0,this._$y=0,this._$width=0,this._$height=0}setTo(t,e,i,s){this.x=t,this.y=e,this.width=i,this.height=s}union(t){return this.isEmpty()?t.clone():t.isEmpty()?this.clone():new p(s.$min(this.x,t.x),s.$min(this.y,t.y),s.$max(this.right-t.left,t.right-this.left),s.$max(this.bottom-t.top,t.bottom-this.top))}}class x{constructor(t){if(!(t instanceof b))throw new Error("Transform params is DisplayObject only.");this._$displayObject=t,this._$matrix=null,this._$colorTransform=null,this._$blendMode=null,this._$filters=null}static toString(){return"[class Transform]"}static get namespace(){return"next2d.geom.Transform"}toString(){return"[object Transform]"}get namespace(){return"next2d.geom.Transform"}get colorTransform(){if(this._$colorTransform)return this._$colorTransform._$clone();const t=this._$displayObject._$getPlaceObject();if(t){const e=t.colorTransform,i=new g;return i._$colorTransform=s.$getFloat32Array8(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]),i}return this._$transform(),this._$colorTransform._$clone()}set colorTransform(t){t instanceof g&&this._$transform(null,t._$colorTransform)}get concatenatedColorTransform(){let t=this._$rawColorTransform(),e=this._$displayObject._$parent;for(;e;)t=s.$multiplicationColor(e._$transform._$rawColorTransform(),t),e=e._$parent;return s.$getColorTransform(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7])}get matrix(){if(this._$matrix)return this._$matrix._$clone();const t=this._$displayObject._$getPlaceObject();if(t){const e=t.matrix;return s.$getMatrix(e[0],e[1],e[2],e[3],e[4],e[5])}return this._$transform(),this._$matrix._$clone()}set matrix(t){t instanceof f&&this._$transform(t._$matrix,null)}get concatenatedMatrix(){let t=this._$rawMatrix(),e=this._$displayObject._$parent;for(;e;)t=s.$multiplicationMatrix(e._$transform._$rawMatrix(),t),e=e._$parent;return s.$getMatrix(t[0],t[1],t[2],t[3],t[4],t[5])}pixelBounds(){const t=new p(0,0,0,0);if(!this._$displayObject)return t;const e=this._$displayObject._$getBounds(null);return t._$x=e.xMin,t._$y=e.yMin,t._$width=+s.$abs(e.xMax-e.xMin),t._$height=+s.$abs(e.yMax-e.yMin),s.$poolBoundsObject(e),t}_$rawMatrix(){if(null!==this._$matrix)return this._$matrix._$matrix;const t=this._$displayObject._$getPlaceObject();return t?t.matrix:s.$MATRIX_ARRAY_IDENTITY}_$rawColorTransform(){if(null!==this._$colorTransform)return this._$colorTransform._$colorTransform;const t=this._$displayObject._$getPlaceObject();return t?t.colorTransform:s.$COLOR_ARRAY_IDENTITY}_$transform(t=null,e=null,i=null,s=""){const r=this._$displayObject._$getPlaceObject();this._$setMatrix(t,r),this._$setColorTransform(e,r),this._$setFilters(i,r),this._$setBlendMode(s,r)}_$setMatrix(t=null,e=null){if((t||e)&&(this._$displayObject._$doChanged(),s.$isUpdated=!0),this._$matrix||(this._$matrix=s.$getMatrix(1,0,0,1,0,0),!t&&e&&(t=e.matrix)),t){const e=this._$matrix._$matrix;e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]}}_$setColorTransform(t=null,e=null){if((t||e)&&(this._$displayObject._$doChanged(),s.$isUpdated=!0),this._$colorTransform||(this._$colorTransform=s.$getColorTransform(1,1,1,1,0,0,0,0),!t&&e&&(t=e.colorTransform)),t){const e=this._$colorTransform._$colorTransform;e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7]}}_$setFilters(t=null,e=null){if(s.$isArray(t))return this._$filters&&s.$poolArray(this._$filters),this._$filters=t.slice(0),this._$displayObject._$doChanged(),void(s.$isUpdated=!0);if(!this._$filters)if(e){if(e.filters)this._$filters=e.filters.slice(0);else if(e.surfaceFilterList){const t=s.$getArray(),i=e.surfaceFilterList.length;for(let s=0;s-1){const e=this.rotation?s.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()):this._$getBounds(null),i=s.$abs(e.yMax-e.yMin);switch(s.$poolBoundsObject(e),i){case 0:case s.$Infinity:case-s.$Infinity:this.scaleY=0;break;default:this.scaleY=t/i}}}get loaderInfo(){return this._$loaderInfo}get mask(){return this._$mask}set mask(t){t!==this._$mask&&(this._$mask&&(this._$mask._$isMask=!1,this._$mask=null),t instanceof b&&(t._$isMask=!0,this._$mask=t),this._$doChanged())}get mouseX(){return s.$event?this.globalToLocal(s.$currentMousePoint()).x:0}get mouseY(){return s.$event?this.globalToLocal(s.$currentMousePoint()).y:0}get name(){return this._$name?this._$name:`instance${this._$instanceId}`}set name(t){this._$name=`${t}`;const e=this._$parent;if(e&&e._$names){e._$names.clear();const t=e._$getChildren(),i=t.length;for(let s=0;st[0]?-1*e:e}set scaleX(t){const e=this._$transform,i=e.matrix;if(0===i.b||s.$isNaN(i.b))i.a=t;else{const e=s.$atan2(i.b,i.a);i.b=t*s.$sin(e),i.a=1===i.b||-1===i.b?0:t*s.$cos(e)}e.matrix=i,s.$poolMatrix(i)}get scaleY(){const t=this._$transform._$rawMatrix(),e=s.$sqrt(t[2]*t[2]+t[3]*t[3]);return 0>t[3]?-1*e:e}set scaleY(t){const e=this._$transform,i=e.matrix;if(0===i.c||s.$isNaN(i.c))i.d=t;else{const e=s.$atan2(-i.c,i.d);i.c=-t*s.$sin(e),i.d=1===i.c||-1===i.c?0:t*s.$cos(e)}e.matrix=i,s.$poolMatrix(i)}get stage(){if(this._$stage)return this._$stage;const t=this._$parent;return t?t instanceof k?t:t._$stage:null}get transform(){return this._$transform}set transform(t){t instanceof x&&(this._$transform=t)}get visible(){return this._$visible}set visible(t){t=!!t,this._$visible!==t&&(this._$doChanged(),s.$isUpdated=!0),this._$visible=!!t}get width(){const t=s.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()),e=s.$abs(t.xMax-t.xMin);switch(s.$poolBoundsObject(t),!0){case 0===e:case e===s.$Infinity:case e===-s.$Infinity:return 0;default:return e}}set width(t){if(t=+t,!s.$isNaN(t)&&t>-1){const e=this.rotation?s.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()):this._$getBounds(null),i=s.$abs(e.xMax-e.xMin);switch(s.$poolBoundsObject(e),!0){case 0===i:case i===s.$Infinity:case i===-s.$Infinity:this.scaleX=0;break;default:this.scaleX=t/i}}}get x(){return this._$transform._$rawMatrix()[4]}set x(t){const e=this._$transform,i=this._$transform.matrix;i.tx=t,e.matrix=i,s.$poolMatrix(i)}get y(){return this._$transform._$rawMatrix()[5]}set y(t){const e=this._$transform,i=e.matrix;i.ty=t,e.matrix=i,s.$poolMatrix(i)}getBounds(t=null){const e=this._$getBounds(null),i=this._$transform.concatenatedMatrix,r=s.$boundsMatrix(e,i._$matrix);s.$poolMatrix(i),s.$poolBoundsObject(e);const n=s.$getBoundsObject(r.xMin,r.xMax,r.yMin,r.yMax);s.$poolBoundsObject(r),t||(t=this);const a=t._$transform.concatenatedMatrix;a.invert();const o=s.$boundsMatrix(n,a._$matrix),h=o.xMin,l=o.yMin,$=o.xMax,_=o.yMax;return s.$poolBoundsObject(n),s.$poolBoundsObject(o),s.$poolMatrix(a),new p(h,l,s.$abs($-h),s.$abs(_-l))}globalToLocal(t){const e=this._$transform.concatenatedMatrix;e.invert();const i=new m(t.x*e.a+t.y*e.c+e.tx,t.x*e.b+t.y*e.d+e.ty);return s.$poolMatrix(e),i}hitTestObject(t){const e=this._$getBounds(null),i=this._$transform.concatenatedMatrix,r=s.$boundsMatrix(e,i._$matrix);s.$poolMatrix(i),s.$poolBoundsObject(e);const n=t._$getBounds(null),a=t._$transform.concatenatedMatrix,o=s.$boundsMatrix(n,a._$matrix);s.$poolMatrix(a),s.$poolBoundsObject(n);const h=s.$max(r.xMin,o.xMin),l=s.$max(r.yMin,o.yMin),$=s.$min(r.xMax,o.xMax),_=s.$min(r.yMax,o.yMax);return s.$poolBoundsObject(r),s.$poolBoundsObject(o),$-h>=0&&_-l>=0}hitTestPoint(t,e,i=!1){if(i){let i=s.$MATRIX_ARRAY_IDENTITY,r=this._$parent;for(;r;)i=s.$multiplicationMatrix(r._$transform._$rawMatrix(),i),r=r._$parent;s.$hitContext.setTransform(1,0,0,1,0,0),s.$hitContext.beginPath();const n=this._$hit(s.$hitContext,i,{x:t,y:e},!0);return s.$poolFloat32Array6(i),n}const r=this._$getBounds(null),n=s.$boundsMatrix(r,this._$transform._$rawMatrix()),a=n.xMin,o=n.yMin,h=n.xMax-n.xMin,l=n.yMax-n.yMin,$=this._$parent?this._$parent.globalToLocal(new m(t,e)):new m(t,e);return s.$poolBoundsObject(n),s.$poolBoundsObject(r),new p(a,o,h,l).containsPoint($)}localToGlobal(t){const e=this._$transform.concatenatedMatrix,i=new m(t.x*e.a+t.y*e.c+e.tx,t.x*e.b+t.y*e.d+e.ty);return s.$poolMatrix(e),i}getLocalVariable(t){return this._$variables?this._$variables.has(t)?this._$variables.get(t):void 0:null}setLocalVariable(t,e){this._$variables||(this._$variables=s.$getMap()),this._$variables.set(t,e)}hasLocalVariable(t){return!!this._$variables&&this._$variables.has(t)}deleteLocalVariable(t){this._$variables&&this._$variables.has(t)&&(this._$variables.delete(t),this._$variables.size||(s.$poolMap(this._$variables),this._$variables=null))}getGlobalVariable(t){return s.$variables.has(t)?s.$variables.get(t):null}setGlobalVariable(t,e){s.$variables.set(t,e)}hasGlobalVariable(t){return s.$variables.has(t)}deleteGlobalVariable(t){s.$variables.has(t)&&s.$variables.delete(t)}clearGlobalVariable(){return s.$variables.clear()}_$getPlaceObject(){if(!this._$placeObject){const t=this._$placeId;if(null===t)return null;const e=this._$parent;if(!e)return null;const i=e._$placeMap;if(!i||!i.length)return null;const s=i[e._$currentFrame||1];if(!s)return null;this._$placeObject=e._$placeObjects[s[t]]}return this._$placeObject}_$sync(){const t=this.contentName;let e=null;if(next2d.fw.response.has(t)&&(e=next2d.fw.response.get(t)._$loaderInfo),!e&&next2d.fw.cache.has(t)&&(e=next2d.fw.cache.get(t)._$loaderInfo),e||(e=this._$loaderInfo||s.$currentLoaderInfo),!e)return null;const i=e._$data.symbols.get(this.namespace),r=e._$data.characters[i];return this._$characterId=i,this._$loaderInfo=e,r}_$build(t,e){const i=e._$loaderInfo;return this._$parent=e,this._$root=e._$root,this._$stage=e._$stage,this._$loaderInfo=i,this._$characterId=0|t.characterId,this._$clipDepth=0|t.clipDepth,this._$startFrame=0|t.startFrame,this._$endFrame=0|t.endFrame,this._$name=t.name||"",i._$data.characters[t.characterId]}_$isUpdated(){return this._$updated}_$updateState(){this._$isNext=!0;let t=this._$parent;t&&t._$updateState()}_$doChanged(){this._$isNext=!0,this._$updated=!0;let t=this._$parent;t&&t._$doChanged()}_$getLayerBounds(t=null){const e=this._$getBounds(t);if(!t)return e;const i=this._$filters||this.filters,r=i.length;if(!r)return e;let n=new p(e.xMin,e.yMin,e.xMax-e.xMin,e.yMax-e.yMin);s.$poolBoundsObject(e);for(let t=0;t0||h!==C.NORMAL){const e=this._$getBounds(null),l=s.$boundsMatrix(e,n),$=+l.xMax,_=+l.xMin,c=+l.yMax,u=+l.yMin;s.$poolBoundsObject(e),s.$poolBoundsObject(l);const d=s.$abs($-_),g=s.$abs(c-u);if(0>=d||0>=g)return!1;if(0>_+d||0>u+g)return!1;const f=t.frameBuffer.currentAttachment;if(_>f.width||u>f.height)return!1;a.basePosition.x=r[4],a.basePosition.y=r[5];let m=this._$getLayerBounds(null);const p=s.$boundsMatrix(m,n);let x=s.$abs(p.xMax-p.xMin),b=s.$abs(p.yMax-p.yMin);s.$poolBoundsObject(p),x===d&&b===g&&(s.$poolBoundsObject(m),m=null);let T=n[4]-s.$floor(_),v=n[5]-s.$floor(u),y=null;if(m){const t=s.$getFloat32Array6(n[0],n[1],n[2],n[3],0,0);y=s.$boundsMatrix(m,t),s.$poolBoundsObject(m),s.$poolFloat32Array6(t),T+=-s.$floor(y.xMin)-T,v+=-s.$floor(y.yMin)-v}let E=s.$floor(_),A=s.$floor(u),M=_,C=u;if(y&&(E-=-s.$floor(y.xMin)-(n[4]-E),A-=-s.$floor(y.yMin)-(n[5]-A),M-=-y.xMin-(n[4]-M),C-=-y.yMin-(n[5]-C),s.$poolBoundsObject(y)),a.position.dx=E>0?E:0,a.position.dy=A>0?A:0,x+M>f.texture.width&&(x-=x-f.texture.width+M),b+C>f.texture.height&&(b-=b-f.texture.height+C),0>E&&(T+=E,x+=M),0>A&&(v+=A,b+=C),0>=x||0>=b||!x||!b)return s.$poolPreObject(a),!1;t._$startLayer(s.$getBoundsObject(M,0,C,0)),a.canApply=this._$canApply(o);let S=this._$isFilterUpdated(x,b,n,i,o,a.canApply,a.basePosition.x,a.basePosition.y);const R=t._$cacheCurrentBuffer;t._$cacheCurrentBuffer=null;const w=t._$cacheCurrentBounds,O=s.$getBoundsObject(w.x,w.w,w.y,w.h);S&&(this._$buffer=t.frameBuffer.createCacheAttachment(s.$ceil(x),s.$ceil(b),!1),t._$bind(this._$buffer)),a.isFilter=!0,a.isUpdated=S,a.color=s.$getFloat32Array8(),a.baseMatrix=n,a.baseColor=i,a.currentAttachment=f,a.currentMaskBuffer=R,a.currentMaskBounds=O,a.filters=o,a.blendMode=h,a.layerWidth=x,a.layerHeight=b,a.matrix=s.$getFloat32Array6(n[0],n[1],n[2],n[3],T,v)}return a}_$postDraw(t,e,i,r){const n=[this._$instanceId,"f"];let a=null;if(this._$buffer){a=t.frameBuffer.getTextureFromCurrentAttachment();const e=s.$cacheStore().get(n);e&&(s.$cacheStore().set(n,null),t.frameBuffer.releaseTexture(e))}else a=s.$cacheStore().get(n);r.canApply||(a._$offsetX=0,a._$offsetY=0);let o=a._$offsetX,h=a._$offsetY;if(r.isUpdated&&r.canApply){let i=s.$cacheStore().get(n);i&&(s.$cacheStore().set(n,null),i.layerWidth=0,i.layerHeight=0,i._$offsetX=0,i._$offsetY=0,i.matrix=null,i.colorTransform=null,t.frameBuffer.releaseTexture(i),i=null);const l=r.filters.length;if(l){t._$offsetX=0,t._$offsetY=0;for(let i=0;it._$names.size&&t._$names.has(e)?t._$names.get(e):t[e]})}static toString(){return"[class DisplayObjectContainer]"}static get namespace(){return"next2d.display.DisplayObjectContainer"}toString(){return"[object DisplayObjectContainer]"}get namespace(){return"next2d.display.DisplayObjectContainer"}get mouseChildren(){return this._$mouseChildren}set mouseChildren(t){this._$mouseChildren=!!t}get numChildren(){return this._$needsChildren?this._$getChildren().length:this._$children.length}addChild(t){if(!(t instanceof b))throw new TypeError("TypeError: addChild: not DisplayObject.");t._$parent&&t._$parent._$remove(t,!(t._$parent._$instanceId===this._$instanceId));return this._$getChildren().push(t),t._$name&&this._$names.set(t._$name,t),this._$addChild(t)}addChildAt(t,e){if(!(t instanceof b))throw new TypeError("TypeError: addChildAt: not DisplayObject.");t._$parent&&t._$parent._$remove(t,!(t._$parent._$instanceId===this._$instanceId));const i=this._$getChildren(),s=i.length;if(0>e||e>s)throw new RangeError(`RangeError: addChildAt: index error: ${e}`);if(s&&s>e){i.splice(e,0,t);for(let t=0;tt||t>i)throw new RangeError(`RangeError: getChildAt: index error: ${t}`);return t in e?e[t]:null}getChildByName(t){if(!t)return null;const e=this._$getChildren(),i=e.length;for(let s=0;st;--n)this._$remove(i[n])}}setChildIndex(t,e){if(!(t instanceof b))throw new TypeError("TypeError: removeChild: not DisplayObject.");const i=this.getChildIndex(t);if(i===e)return;const s=this._$getChildren();s.splice(i,1),s.splice(e,0,t),this._$doChanged()}swapChildren(t,e){if(!(t instanceof b&&e instanceof b))throw new TypeError("TypeError: removeChild: not DisplayObject.");const i=this._$getChildren(),s=this.getChildIndex(t),r=this.getChildIndex(e);i[s]=e,i[r]=t,this._$doChanged()}swapChildrenAt(t,e){this.swapChildren(this.getChildAt(t),this.getChildAt(e))}_$getBounds(t=null){let e=s.$MATRIX_ARRAY_IDENTITY;if(t){e=t;const i=this._$transform._$rawMatrix();i!==s.$MATRIX_ARRAY_IDENTITY&&(e=s.$multiplicationMatrix(t,i))}const i=this._$graphics&&this._$graphics._$getBounds(),r=this._$needsChildren?this._$getChildren():this._$children,n=r.length;if(!n&&!i){const i=s.$getBoundsObject(e[4],-e[4],e[5],-e[5]);return t&&e!==t&&s.$poolFloat32Array6(e),i}const a=s.$MAX_VALUE;let o=a,h=-a,l=a,$=-a;if(i){const t=s.$boundsMatrix(this._$graphics._$getBounds(),e);o=t.xMin,h=t.xMax,l=t.yMin,$=t.yMax,s.$poolBoundsObject(t)}for(let t=0;tt){if(i._$filters=null,i._$blendMode=null,-1===i._$id){h.push(i),i._$name&&this._$names.set(i._$name,i);continue}const t=e[o];if(i._$id===t){i._$placeId=o,h.push(i),i._$name&&this._$names.set(i._$name,i),n.has(t)&&n.delete(t),r.set(t,!0),o++;continue}n.set(i._$id,i)}else i.willTrigger(a.REMOVED)&&i.dispatchEvent(new a(a.REMOVED,!0)),i.willTrigger(a.REMOVED_FROM_STAGE)&&i.dispatchEvent(new a(a.REMOVED_FROM_STAGE,!0)),i._$added=!1,i._$addedStage=!1,i._$active=!1,i._$updated=!0,i._$filters=null,i._$blendMode=null,i._$isNext=!0,i instanceof v&&(i._$executeRemovedFromStage(),i._$removeParentAndStage())}if(e)for(let t=0;t-1;--e)t[e]._$prepareActions();this._$executeAddedEvent()}_$nextFrame(){let t=!1;const e=this._$needsChildren?this._$getChildren():this._$children;for(let i=e.length-1;i>-1;--i){const s=e[i];s._$isNext&&(t?s._$nextFrame():t=s._$nextFrame())}return this._$executeAddedEvent(),this._$isNext=t,this._$isNext}_$clip(t,e){let i=e;const r=this._$transform._$rawMatrix();r!==s.$MATRIX_ARRAY_IDENTITY&&(i=s.$multiplicationMatrix(e,r)),this._$graphics&&this._$graphics._$getBounds()&&this._$graphics._$clip(t,i);const n=this._$getChildren(),a=n.length;for(let e=0;ec||i._$clipDepth>0)&&(t.restore(),_&&(t._$leaveClip(),u.length&&(s.$poolFloat32Array6(l),l=u.pop())),c=g.length?g.pop():null,_=f.pop()),!_)continue;if(i._$clipDepth>0){if(t.save(),c&&g.push(c),f.push(_),c=i._$clipDepth,_=i._$shouldClip(l),_){const e=i._$startClip(t,l);if(!1===e){_=!1;continue}e&&(u.push(l),l=e)}continue}const n=i._$mask;if(n){let e;if(n._$updated=!1,this===n._$parent)e=l;else{e=s.$MATRIX_ARRAY_IDENTITY;let i=n._$parent;for(;i;)e=s.$multiplicationMatrix(i._$transform._$rawMatrix(),e),i=i._$parent;const r=this.stage._$player,a=r._$scale*r._$ratio/20,o=s.$getFloat32Array6(a,0,0,a,0,0);if(e=s.$multiplicationMatrix(o,e),t._$isLayer){const i=t._$getCurrentPosition();e[4]-=i.xMin,e[5]-=i.yMin}t._$cacheCurrentBuffer&&(e[4]-=t._$cacheCurrentBounds.x,e[5]-=t._$cacheCurrentBounds.y)}if(!n._$shouldClip(e))continue;let i=n._$startClip(t,e);if(t.save(),!1===i){t.restore();continue}if(i){if(d.push(l),this!==n._$parent){const e=this._$transform._$rawMatrix();i[0]=s.$abs(l[0])*s.$sign(e[0]),i[1]=s.$abs(l[1])*s.$sign(e[1]),i[2]=s.$abs(l[2])*s.$sign(e[2]),i[3]=s.$abs(l[3])*s.$sign(e[3]),i[4]=l[4]-t._$cacheCurrentBounds.x,i[5]=l[5]-t._$cacheCurrentBounds.y}l=i}}i._$draw(t,l,$),i._$updated=!1,n&&(t.restore(),t._$leaveClip(),d.length&&(s.$poolFloat32Array6(l),l=d.pop()))}if(c&&(t.restore(),f.pop()&&t._$leaveClip()),s.$poolArray(u),s.$poolArray(d),s.$poolArray(g),s.$poolArray(f),h.isFilter)return this._$postDraw(t,e,r,h);s.$poolFloat32Array6(l),s.$poolPreObject(h)}_$mouseHit(t,e,i,r=!0){let n=e;const a=this._$transform._$rawMatrix();a!==s.$MATRIX_ARRAY_IDENTITY&&(n=s.$multiplicationMatrix(e,a));const o=this._$getChildren(),h=s.$getArray(),l=s.$getArray(),$=s.$getMap();let _=o.length,c=null,u=null;for(let t=0;t<_;++t){const e=o[t];(e._$visible||e._$hitObject)&&(e._$clipDepth?(u=h.length,c=e._$clipDepth,h.push(e)):(c&&e._$placeId>c&&(u=null,c=null),null!==u&&$.set(e._$instanceId,u),l.push(e)))}const d=s.$min(this._$mouseChildren,r);let g=!1;const f=this._$root===this;_=l.length;for(let e=0;e<_;++e){const e=l.pop();if(e._$isMask)continue;if(f&&!(e instanceof T))continue;if($.has(e._$instanceId)){if(!h[$.get(e._$instanceId)]._$hit(t,n,i,!0))continue}const r=e._$mask;if(r)if(this===r._$parent){if(!r._$hit(t,n,i,!0))continue}else{let e=s.$MATRIX_ARRAY_IDENTITY,n=r._$parent;for(;n;)e=s.$multiplicationMatrix(n._$transform._$rawMatrix(),e),n=n._$parent;if(!r._$hit(t,e,i,!0))continue}if(e._$mouseHit(t,n,i,d)||e._$hitArea&&e._$hitArea._$mouseHit(t,n,i,d)){if(e._$root===e)return!0;if(!d)return!0;if(g=!0,e instanceof T){if(!e._$mouseEnabled&&!e._$hitObject)continue;if(!s.$isTouch&&!i.pointer)switch(!0){case e instanceof st:e._$type===rt.INPUT&&(i.pointer="text");break;case e.buttonMode&&e.useHandCursor:i.pointer="pointer"}return i.hit||(i.hit=!e._$mouseEnabled&&e._$hitObject?e._$hitObject:e),!0}}}return s.$poolArray(h),s.$poolArray(l),s.$poolMap($),!g&&this._$graphics&&(g=this._$graphics._$hit(t,n,i)),n!==e&&s.$poolFloat32Array6(n),g}_$hit(t,e,i,r=!1){let n=e;const a=this._$transform._$rawMatrix();a!==s.$MATRIX_ARRAY_IDENTITY&&(n=s.$multiplicationMatrix(e,a));const o=this._$getChildren();for(let e=o.length-1;e>-1;--e){const s=o[e];if(!s._$isMask&&s._$hit(t,n,i,r))return!0}let h=!1;return this._$graphics&&(h=this._$graphics._$hit(t,n,i)),n!==e&&s.$poolFloat32Array6(n),h}_$createInstance(t){const e=this._$dictionary[t],i=this._$loaderInfo._$data.characters[e.characterId];i.class||(i.class=i.symbol&&s.$getClass(i.symbol)||s.$getClass(i.extends)),s.$currentLoaderInfo=null;const r=new i.class;return r._$build(e,this),r._$id=t,r}_$outCheck(t,e){let i=s.$MATRIX_ARRAY_IDENTITY,r=this._$parent;for(;r;)i=s.$multiplicationMatrix(r._$transform._$rawMatrix(),i),r=r._$parent;return s.$hitContext.setTransform(1,0,0,1,0,0),s.$hitContext.beginPath(),this._$mouseHit(s.$hitContext,i,{x:t,y:e})}}class y extends v{constructor(){super(),this._$buttonMode=!1,this._$hitArea=null,this._$soundTransform=null,this._$useHandCursor=!0,this._$graphics=null}static toString(){return"[class Sprite]"}static get namespace(){return"next2d.display.Sprite"}toString(){return"[object Sprite]"}get namespace(){return"next2d.display.Sprite"}get buttonMode(){return this._$buttonMode}set buttonMode(t){this._$buttonMode=!!t}get dropTarget(){return s.$dropTarget}get graphics(){return this._$graphics||(this._$graphics=new O,this._$graphics._$displayObject=this),this._$graphics}get hitArea(){return this._$hitArea}set hitArea(t){this._$hitArea&&(this._$hitArea._$hitObject=null),this._$hitArea=null,t instanceof y&&(this._$hitArea=t,t._$hitObject=this)}get soundTransform(){return this._$soundTransform||(this._$soundTransform=new ut),this._$soundTransform}set soundTransform(t){t instanceof ut&&(this._$soundTransform=t)}get useHandCursor(){return this._$useHandCursor}set useHandCursor(t){this._$useHandCursor=!!t}startDrag(t=!1,e=null){let i=0,r=0;if(!t){const t=this._$dragMousePoint();i=this.x-t.x,r=this.y-t.y}s.$dropTarget=this,s.$dragRules.lock=t,s.$dragRules.position.x=i,s.$dragRules.position.y=r,s.$dragRules.bounds=e}stopDrag(){s.$dropTarget=null,s.$dragRules.lock=!1,s.$dragRules.position.x=0,s.$dragRules.position.y=0,s.$dragRules.bounds=null}_$sync(){const t=super._$sync();return t&&(this._$controller=t.controller,this._$dictionary=t.dictionary,this._$placeMap=t.placeMap,this._$placeObjects=t.placeObjects),t}_$build(t,e){const i=super._$build(t,e);return this._$controller=i.controller,this._$dictionary=i.dictionary,this._$placeMap=i.placeMap,this._$placeObjects=i.placeObjects,i}_$dragMousePoint(){return this._$parent?this._$parent.globalToLocal(s.$currentMousePoint()):this.globalToLocal(s.$currentMousePoint())}}class E extends y{constructor(){super(),this._$stopFlag=!1,this._$canAction=!0,this._$childRemove=!1,this._$canSound=!0,this._$actionProcess=!1,this._$actions=s.$getMap(),this._$frameCache=s.$getMap(),this._$labels=null,this._$sounds=s.$getMap(),this._$channels=s.$getMap(),this._$actionOffset=0,this._$actionLimit=0,this._$currentFrame=1,this._$totalFrames=1,this._$isPlaying=!1}static toString(){return"[class MovieClip]"}static get namespace(){return"next2d.display.MovieClip"}toString(){return"[object MovieClip]"}get namespace(){return"next2d.display.MovieClip"}get currentFrame(){return this._$currentFrame}get currentFrameLabel(){if(!this._$labels)return null;const t=this._$currentFrame;return this._$labels.has(t)?this._$labels.get(t):null}get currentLabels(){return this._$labels?s.$Array.from(this._$labels.values()):null}get isPlaying(){return this._$isPlaying}get totalFrames(){return this._$totalFrames}gotoAndPlay(t){this.play(),this._$goToFrame(t)}gotoAndStop(t){this.stop(),this._$goToFrame(t)}nextFrame(){this.stop(),this._$totalFrames>this._$currentFrame&&this._$goToFrame(this._$currentFrame+1)}play(){this._$stopFlag=!1,this._$isPlaying=!0,this._$updateState()}prevFrame(){const t=this._$currentFrame-1;t&&(this.stop(),this._$goToFrame(t))}stop(){this._$stopFlag=!0,this._$isPlaying=!1}addFrameLabel(t){this._$labels||(this._$labels=s.$getMap()),t instanceof R&&this._$labels.set(t.frame,t)}addFrameScript(){const t=arguments.length;for(let e=0;e=t&&this._$addAction(t,i),t===this._$currentFrame){const t=s.$currentPlayer();if(t._$actionOffset=t._$actions.length,this._$canAction=!0,this._$setAction(),t._$actionOffset!==t._$actions.length){const e=t._$actions.splice(0,t._$actionOffset);t._$actions.push.apply(t._$actions,e),t._$actionOffset=0}}}}_$getFrameForLabel(t){for(let[e,i]of this._$labels)if(i.name===t)return 0|e;return 0}_$addAction(t,e){(t|=0)&&(this._$actions.has(t)||this._$actions.set(t,s.$getArray()),this._$actions.get(t).push(e))}_$setAction(){if(this._$executeAddedEvent(),this._$canAction){const t=this._$currentFrame;if(this._$labels&&this._$labels.has(t)){const e=this._$labels.get(t);e.willTrigger(a.FRAME_LABEL)&&e.dispatchEvent(new a(a.FRAME_LABEL))}if(this._$actions.size&&this._$actions.has(t)){const t=s.$currentPlayer();if(t){-1===t._$actions.indexOf(this)&&t._$actions.push(this)}}}}_$goToFrame(t){if(s.$isNaN(+t)&&(t=this._$getFrameForLabel(t)),t<1&&(t=1),t>this._$totalFrames)return this._$currentFrame=this._$totalFrames,this._$clearChildren(),this._$canAction=!1,void(this._$wait=!1);const e=s.$currentPlayer();switch(!0){case t!==this._$currentFrame:{this._$wait=!1;const i=this._$currentFrame;this._$actionProcess&&(this._$frameCache.set("nextFrame",t),this._$frameCache.set("stopFlag",this._$stopFlag),this._$frameCache.set("isPlaying",this._$isPlaying)),this._$currentFrame=t,this._$clearChildren(),e._$actionOffset=e._$actions.length;const r=e._$actionOffset?e._$actions.indexOf(this):-1;if(this._$canAction=!0,this._$prepareActions(),e._$actionOffset&&e._$actionOffset!==e._$actions.length){const t=e._$actions.splice(0,e._$actionOffset);e._$actions.push.apply(e._$actions,t),e._$actionOffset=0}if(!this._$actionProcess&&(r>-1||!e._$actionOffset))for(;e._$actions.length&&e._$actions.length!==r;){const t=e._$actions.pop();t._$canAction=!1,t._$actionOffset=0,t._$actionLimit=0,t._$actionProcess&&t._$frameCache.size&&(t._$currentFrame=t._$frameCache.get("nextFrame"),t._$clearChildren(),t._$stopFlag=t._$frameCache.get("stopFlag"),t._$isPlaying=t._$frameCache.get("isPlaying"),t._$frameCache.clear());const i=t._$currentFrame;if(!t._$actions.has(i))continue;const r=t._$actions.get(i),n=r.length;for(let e=0;e-1:{if(!this._$actionLimit)break;this._$wait=!1;const t=e._$actions.splice(this._$actionOffset,this._$actionLimit);for(;t.length;){const e=t.pop();e._$canAction=!1,e._$actionOffset=0,e._$actionLimit=0;const i=e._$currentFrame;if(!e._$actions.has(i))continue;const r=e._$actions.get(i),n=r.length;for(let t=0;t-1;--e)t[e]._$prepareActions();this._$setAction()}_$draw(t,e,i){super._$draw(t,e,i);const r=s.$currentPlayer();this._$canSound&&this._$sounds.size&&this._$sounds.has(this._$currentFrame)&&!r._$sounds.has(this._$instanceId)&&r._$sounds.set(this._$instanceId,this)}_$nextFrame(){let t=this._$needsChildren;switch(!0){case this._$wait:t=!0,this._$wait=!1;break;case this._$stopFlag:case 1===this._$totalFrames:break;default:t=!0,this._$canAction=!0,this._$canSound=!0,++this._$currentFrame,this._$currentFrame>this._$totalFrames&&(this._$currentFrame=1),this._$clearChildren()}const e=this._$needsChildren?this._$getChildren():this._$children;for(let i=e.length-1;i>-1;--i){const s=e[i];s._$isNext&&(t?s._$nextFrame():t=s._$nextFrame())}return this._$setAction(),this._$isNext=t,this._$isNext}_$buildCharacter(t){for(let e=0;e6)switch(this._$recode||(this._$recode=s.$getArray()),this._$fills[2]===this._$fills[this._$fills.length-2]&&this._$fills[3]===this._$fills[this._$fills.length-1]||this._$fills.push(O.LINE_TO,this._$fills[2],this._$fills[3]),this._$recode.push.apply(this._$recode,this._$fills),this._$fillType){case O.FILL_STYLE:this._$recode.push(this._$fillType,this._$fillStyleR,this._$fillStyleG,this._$fillStyleB,this._$fillStyleA,O.END_FILL);break;case O.GRADIENT_FILL:this._$recode.push(this._$fillType),this._$recode.push.apply(this._$recode,this._$fillGradient.toArray());break;case O.BITMAP_FILL:this._$recode.push(this._$fillType),this._$recode.push.apply(this._$recode,this._$fillBitmap.toArray())}return this._$fills&&(s.$poolArray(this._$fills),this._$fills=null),this._$fillType=0,this._$fillGradient=null,this._$fillBitmap=null,this._$fillStyleR=0,this._$fillStyleG=0,this._$fillStyleB=0,this._$fillStyleA=0,this._$doFill=!1,this._$restart(),this}endLine(){if(this._$doLine)switch(this._$recode||(this._$recode=s.$getArray()),this._$recode.push.apply(this._$recode,this._$lines),s.$poolArray(this._$lines),this._$lines=null,this._$lineType){case O.STROKE_STYLE:this._$recode.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,this._$lineStyleR,this._$lineStyleG,this._$lineStyleB,this._$lineStyleA,O.END_STROKE);break;case O.GRADIENT_STROKE:this._$recode.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit),this._$recode.push.apply(this._$recode,this._$lineGradient.toArray());break;case O.BITMAP_STROKE:this._$recode.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit),this._$recode.push.apply(this._$recode,this._$fillBitmap.toArray())}return this._$lineType=0,this._$lineWidth=0,this._$lineGradient=null,this._$lineStyleR=0,this._$lineStyleG=0,this._$lineStyleB=0,this._$lineStyleA=0,this._$caps=S.NONE,this._$joints=L.ROUND,this._$miterLimit=0,this._$doLine=!1,this._$restart(),this}lineBitmapStyle(t,e=null,i=!0,r=!1){return this._$doLine&&this.endLine(),this._$lines||(this._$lines=s.$getArray()),this._$maxAlpha=1,this._$doLine=!0,this._$canDraw=!0,this._$lines.push(O.BEGIN_PATH),this._$lineType=O.BITMAP_STROKE,this._$fillBitmap=new I(t,e,i,r),this}lineGradientStyle(t,e,i,r,n=null,a=U.PAD,o=F.RGB,h=0){if(!this._$doLine)return this;this._$lines||(this._$lines=s.$getArray());const l=i.length;for(let t=0;tu+x||0>g+b){if(!(n&&n.length&&o._$canApply(n)))return;{let t=new p(0,0,x,b);for(let e=0;et.x+t.width||0>t.y+t.height)return}}const y=t.frameBuffer.currentAttachment;if(u>y.width||g>y.height)return;const E=t._$textureScale(x,b);E<1&&(x*=E,b*=E);const A=s.$cacheStore().generateKeys(o._$instanceId,[T,v],i);let M=s.$cacheStore().get(A);if(!M){const r=t.frameBuffer.createCacheAttachment(x,b,!0);switch(t._$bind(r),s.$resetContext(t),i[3]=1,!0){case 1!==l[0]:case 0!==l[1]:case 0!==l[2]:case 1!==l[3]:{const r=Math.atan2(e[1],e[0]);let n=0,a=0;if(r){const t=new f;t.translate(-x/2,-b/2),t.rotate(r),t.translate(x/2,b/2);const e=t.transformPoint(new m(0,0)),i=t.transformPoint(new m(x,0)),o=t.transformPoint(new m(0,b)),h=t.transformPoint(new m(x,b));n=s.$min(e.x,i.x,o.x,h.x),a=s.$min(e.y,i.y,o.y,h.y)}s.$resetContext(t),t.setTransform(e[0],e[1],e[2],e[3],-n,-a),t.beginPath(),this._$runTransformCommand(t,l,i)}break;default:t.setTransform(h[0],h[1],h[2],h[3],h[4]-u,h[5]-g),this._$doDraw(t,i)}M=t.frameBuffer.getTextureFromCurrentAttachment(),s.$cacheStore().set(A,M),t.frameBuffer.releaseAttachment(r,!1),t._$bind(y)}let S=!1,R=0,w=0;if(n&&n.length){o._$canApply(n)&&(S=!0,M=this._$drawFilter(t,M,e,i,n,x,b),R=M._$offsetX,w=M._$offsetY)}s.$resetContext(t),t._$globalAlpha=a,t._$imageSmoothingEnabled=!0,t._$globalCompositeOperation=r,t.setTransform(1,0,0,1,0,0),S?t.drawImage(M,u-R,g-w,M.width,M.height,i):t.drawImage(M,u,g,x,b,i),s.$poolArray(A),s.$poolBoundsObject($)}_$draw(t,e,i,r=C.NORMAL,n=null){if(!this._$maxAlpha)return;const a=s.$clamp(i[3]+i[7]/255,0,1),o=this._$displayObject;let h=null!==o._$scale9Grid,l=null;h&&(l=o._$transform._$rawMatrix(),h=h&&s.$abs(l[1])<.001&&s.$abs(l[2])<1e-4);const $=this._$getBounds(),_=s.$boundsMatrix($,e),c=_.xMax,u=_.xMin,d=_.yMax,g=_.yMin;s.$poolBoundsObject(_);let f=s.$ceil(s.$abs(c-u)),m=s.$ceil(s.$abs(d-g));switch(!0){case 0===f:case 0===m:case f===-s.$Infinity:case m===-s.$Infinity:case f===s.$Infinity:case m===s.$Infinity:return}const x=Math.sqrt(e[0]*e[0]+e[1]*e[1]),b=Math.sqrt(e[2]*e[2]+e[3]*e[3]);if(0>u+f||0>g+m){if(!(n&&n.length&&o._$canApply(n)))return;{let t=new p(0,0,f,m);for(let e=0;et.x+t.width||0>t.y+t.height)return}}const T=t.frameBuffer.currentAttachment;if(u>T.width||g>T.height)return;const v=t._$textureScale(f,m);v<1&&(f*=v,m*=v);const y=s.$cacheStore().generateKeys(o._$instanceId,[x,b],i);let E=s.$cacheStore().get(y);if(!E){const r=t.frameBuffer.createCacheAttachment(f,m,!0);if(t._$bind(r),s.$resetContext(t),t.setTransform(e[0],e[1],e[2],e[3],e[4]-u,e[5]-g),h){const i=s.$currentPlayer(),r=i._$scale*i._$ratio,n=s.$getFloat32Array6(r,0,0,r,0,0),a=s.$multiplicationMatrix(n,l);s.$poolFloat32Array6(n);const h=o._$parent._$transform._$calculateConcatenatedMatrix()._$matrix,_=s.$getFloat32Array6(h[0],h[1],h[2],h[3],h[4]*r-u,h[5]*r-g),c=s.$multiplicationMatrix(_,a),d=c[4]-(e[4]-u),f=c[5]-(e[5]-g);s.$poolFloat32Array6(c);const m=s.$boundsMatrix($,a),p=+m.xMax,x=+m.xMin,b=+m.yMax,T=+m.yMin,v=s.$ceil(s.$abs(p-x)),y=s.$ceil(s.$abs(b-T));s.$poolBoundsObject(m),t.grid.enable(x,T,v,y,$,o._$scale9Grid,a[0],a[1],a[2],a[3],a[4],a[5],_[0],_[1],_[2],_[3],_[4]-d,_[5]-f),s.$poolFloat32Array6(a),s.$poolFloat32Array6(_)}i[3]=1,this._$doDraw(t,i,!1),h&&t.grid.disable(),E=t.frameBuffer.getTextureFromCurrentAttachment(),s.$cacheStore().set(y,E),t.frameBuffer.releaseAttachment(r,!1),t._$bind(T)}let A=!1,M=0,S=0;if(n&&n.length){o._$canApply(n)&&(A=!0,E=this._$drawFilter(t,E,e,i,n,f,m),M=E._$offsetX,S=E._$offsetY)}s.$resetContext(t),t._$globalAlpha=a,t._$imageSmoothingEnabled=!0,t._$globalCompositeOperation=r,t.setTransform(1,0,0,1,0,0),A?t.drawImage(E,u-M,g-S,E.width,E.height,i):t.drawImage(E,u,g,f,m,i),s.$poolArray(y),l&&s.$poolMatrix(l),s.$poolBoundsObject($)}_$doDraw(t,e,i=!1){s.$resetContext(t),t.beginPath(),this._$runCommand(t,e,i)}_$hit(t,e,i,s=!1){return t.beginPath(),t.setTransform(e[0],e[1],e[2],e[3],e[4],e[5]),this._$runCommand(t,null,s,i)}_$getBounds(){const t=this._$displayObject;return t&&t._$bounds?s.$getBoundsObject(t._$bounds.xMin,t._$bounds.xMax,t._$bounds.yMin,t._$bounds.yMax):s.$getBoundsObject(this._$xMin,this._$xMax,this._$yMin,this._$yMax)}_$restart(){this._$displayObject&&!this._$displayObject._$isUpdated()&&(this._$displayObject._$doChanged(),s.$isUpdated=!0,s.$cacheStore().removeCache(this._$displayObject._$instanceId))}_$setBounds(t=0,e=0){this._$setFillBounds(t,e),this._$doLine&&this._$setLineBounds(t,e)}_$setFillBounds(t,e){this._$xMin=s.$min(this._$xMin,t),this._$xMax=s.$max(this._$xMax,t),this._$yMin=s.$min(this._$yMin,e),this._$yMax=s.$max(this._$yMax,e)}_$setLineBounds(t,e){this._$xMin=s.$min(this._$xMin,s.$min(t,this._$pointerX)),this._$xMax=s.$max(this._$xMax,s.$max(t,this._$pointerX)),this._$yMin=s.$min(this._$yMin,s.$min(e,this._$pointerY)),this._$yMax=s.$max(this._$yMax,s.$max(e,this._$pointerY));const i=this._$lineWidth/2,r=.5*s.$PI,n=s.$atan2(e-this._$pointerY,t-this._$pointerX),a=s.$atan2(this._$pointerY-e,this._$pointerX-t),o=n+r,h=n-r,l=a+r,$=a-r;let _=t+i,c=-i+t,u=this._$pointerX+i,d=-i+this._$pointerX,g=e+i,f=-i+e,m=this._$pointerY+i,p=-i+this._$pointerY;this._$xMin=s.$min(this._$xMin,s.$min(_,s.$min(c,s.$min(u,d)))),this._$xMax=s.$max(this._$xMax,s.$max(_,s.$max(c,s.$max(u,d)))),this._$yMin=s.$min(this._$yMin,s.$min(g,s.$min(f,s.$min(m,p)))),this._$yMax=s.$max(this._$yMax,s.$max(g,s.$max(f,s.$max(m,p)))),s.$abs(o)%r!=0&&(_=t+s.$cos(o)*i),s.$abs(h)%r!=0&&(c=t+s.$cos(h)*i),s.$abs(l)%r!=0&&(u=this._$pointerX+s.$cos(l)*i),s.$abs($)%r!=0&&(d=this._$pointerX+s.$cos($)*i),o&&s.$abs(o)%s.$PI!=0&&(g=e+s.$sin(o)*i),h&&s.$abs(h)%s.$PI!=0&&(f=e+s.$sin(h)*i),l&&s.$abs(l)%s.$PI!=0&&(m=this._$pointerY+s.$sin(l)*i),$&&s.$abs($)%s.$PI!=0&&(p=this._$pointerY+s.$sin($)*i),this._$xMin=s.$min(this._$xMin,s.$min(_,s.$min(c,s.$min(u,d)))),this._$xMax=s.$max(this._$xMax,s.$max(_,s.$max(c,s.$max(u,d)))),this._$yMin=s.$min(this._$yMin,s.$min(g,s.$min(f,s.$min(m,p)))),this._$yMax=s.$max(this._$yMax,s.$max(g,s.$max(f,s.$max(m,p))));let x=0,b=0,T=0,v=0,y=0,E=0,A=0,M=0;switch(this._$caps){case S.ROUND:s.$abs(n)%r!=0&&(x=t+s.$cos(n)*i),n&&s.$abs(n)%s.$PI!=0&&(b=e+s.$sin(n)*i),s.$abs(a)%r!=0&&(T=this._$pointerX+s.$cos(a)*i),a&&s.$abs(a)%s.$PI!=0&&(v=this._$pointerY+s.$sin(a)*i),this._$xMin=s.$min(this._$xMin,s.$min(x,T)),this._$xMax=s.$max(this._$xMax,s.$max(x,T)),this._$yMin=s.$min(this._$yMin,s.$min(b,v)),this._$yMax=s.$max(this._$yMax,s.$max(b,v));break;case S.SQUARE:if(s.$abs(n)%r!=0){const t=s.$cos(n)*i;x=_+t,T=c+t}if(s.$abs(a)%r!=0){const t=s.$cos(a)*i;y=u+t,A=d+t}if(n&&s.$abs(n)%s.$PI!=0){const t=s.$sin(n)*i;b=g+t,v=f+t}if(a&&s.$abs(a)%s.$PI!=0){const t=s.$sin(a)*i;E=m+t,M=p+t}this._$xMin=s.$min(this._$xMin,s.$min(x,s.$min(T,s.$min(y,A)))),this._$xMax=s.$max(this._$xMax,s.$max(x,s.$max(T,s.$max(y,A)))),this._$yMin=s.$min(this._$yMin,s.$min(b,s.$min(v,s.$min(E,M)))),this._$yMax=s.$max(this._$yMax,s.$max(b,s.$max(v,s.$max(E,M))))}}_$margePath(t){this._$doFill&&this._$fills.push.apply(this._$fills,t),this._$doLine&&this._$lines.push.apply(this._$lines,t),s.$poolArray(t)}_$runTransformCommand(t,e,i=null){if(this._$doLine&&this.endLine(),this._$doFill&&this.endFill(),!this._$recode)return!1;let r=Number.MAX_VALUE,n=-Number.MAX_VALUE,a=Number.MAX_VALUE,o=-Number.MAX_VALUE;const h=this._$recode,l=h.length;for(let $=0;$t.target.status)switch(e.format){case ot.JSON:{const e=JSON.parse(t.target.responseText);if("zlib"===e.type){if(s.$unzipWorkerActive)return void s.$unzipQueues.push({json:e,scope:this});s.$unzipWorkerActive=!0,s.$unzipWorker||(s.$unzipWorker=new Worker(s.$unzipURL));const t=new Uint8Array(e.buffer);s.$unzipWorker.onmessage=s.$unzipHandler.bind(this),s.$unzipWorker.postMessage(t,[t.buffer])}else this._$build(e)}break;case ot.ARRAY_BUFFER:this._$imageDecode(new Uint8Array(t.target.response))}else e.willTrigger(_.IO_ERROR)&&e.dispatchEvent(new _(_.IO_ERROR,!1,!1,t.target.statusText))}.bind(this)}})}loadImage(t){t.responseDataFormat=ot.ARRAY_BUFFER,this.load(t)}_$imageDecode(t){const e={image:new s.$Image,scope:this};e.image.decoding="async",e.image.src=s.$URL.createObjectURL(new s.$Blob([t],{type:`image/${s.$getImageType(t)}`})),s.$imageWorkerActive?s.$imageQueues.push(e):(s.$imageWorkerActive=!0,e.image.decode().then(s.$decodeImage.bind(e)).catch((()=>{throw new Error("image encoding error")})))}_$build(t){const e=this.contentLoaderInfo;let i=null;const r=s.$getMap();if(t.symbols.length)for(let e=0;e=this._$blurX?1:this._$blurX*n,o=0>=this._$blurY?1:this._$blurY*n;switch(!0){case"number"==typeof e:case"number"==typeof i:a*=e,o*=i;break;default:a=s.$round(a),o=s.$round(o)}return r.x-=a,r.width+=2*a,r.y-=o,r.height+=2*o,r}_$isSame(t){return this._$quality===t._$quality&&(this._$blurX===t._$blurX&&this._$blurY===t._$blurY)}_$canApply(){return!(!this._$quality||!this._$blurX&&!this._$blurY)}_$applyFilter(t,e,i=!0){this._$doChanged(!1);const r=t.frameBuffer.currentAttachment,n=t.frameBuffer.getTextureFromCurrentAttachment();if(!this._$canApply())return i?n:t.frameBuffer.createTextureFromCurrentAttachment();const a=s.$sqrt(e[0]*e[0]+e[1]*e[1]),o=s.$sqrt(e[2]*e[2]+e[3]*e[3]),h=new p(0,0,n.width,n.height),l=this._$generateFilterRect(h,a,o),$=0|s.$ceil(l.width),_=0|s.$ceil(l.height),c=s.$ceil(s.$abs(l.x)+.5*s.$abs($-l.width)),u=s.$ceil(s.$abs(l.y)+.5*s.$abs(_-l.height));t._$offsetX=+(c+t._$offsetX),t._$offsetY=+(u+t._$offsetY);const d=this._$blurX*a,g=this._$blurY*o;let f=1,m=1;d>128?f=.0625:d>64?f=.125:d>32?f=.25:d>16&&(f=.5),g>128?m=.0625:g>64?m=.125:g>32?m=.25:g>16&&(m=.5);const x=d*f,b=g*m;let T=s.$ceil($*f),v=s.$ceil(_*m);const y=t.frameBuffer.createTextureAttachment(T,v),E=[y,t.frameBuffer.createTextureAttachment(T,v)];let A=0;t._$bind(y),s.$resetContext(t),t.setTransform(f,0,0,m,0,0),t.drawImage(n,c,u,n.width,n.height),t.blend.toOneZero();let M=t.frameBuffer.getTextureFromCurrentAttachment();for(let e=0;e0){A=(A+1)%2;const e=E[A];t._$bind(e),t._$applyBlurFilter(M,!0,x),M=t.frameBuffer.getTextureFromCurrentAttachment()}if(this._$blurY>0){A=(A+1)%2;const e=E[A];t._$bind(e),t._$applyBlurFilter(M,!1,b),M=t.frameBuffer.getTextureFromCurrentAttachment()}}if(t.blend.reset(),1!==f||1!==m){const e=t.frameBuffer.createTextureAttachment($,_);t._$bind(e),s.$resetContext(t),t.imageSmoothingEnabled=!0,t.setTransform(1/f,0,0,1/m,0,0),t.drawImage(M,0,0,T,v),M=t.frameBuffer.getTextureFromCurrentAttachment(),s.$resetContext(t),t.setTransform(1,0,0,1,0,0),t.frameBuffer.releaseAttachment(E[0],!0),t.frameBuffer.releaseAttachment(E[1],!0),i?t.frameBuffer.releaseAttachment(r,!0):t.frameBuffer.releaseAttachment(e,!1)}else t.frameBuffer.releaseAttachment(E[(A+1)%2],!0),i?t.frameBuffer.releaseAttachment(r,!0):t.frameBuffer.releaseAttachment(E[A],!1);return M}}class V extends X{constructor(t=4,e=45,i=16777215,s=1,r=0,n=1,a=4,o=4,h=1,l=1,$="inner",_=!1){super(),this._$blurFilter=new z(a,o,l),this._$distance=4,this._$angle=45,this._$highlightColor=16777215,this._$highlightAlpha=1,this._$shadowColor=0,this._$shadowAlpha=1,this._$strength=1,this._$type=H.INNER,this._$knockout=!1,this.distance=t,this.angle=e,this.highlightColor=i,this.highlightAlpha=s,this.shadowColor=r,this.shadowAlpha=n,this.strength=h,this.type=$,this.knockout=!!_}static toString(){return"[class BevelFilter]"}static get namespace(){return"next2d.filters.BevelFilter"}toString(){return"[object BevelFilter]"}get namespace(){return"next2d.filters.BevelFilter"}get angle(){return this._$angle}set angle(t){(t%=360)!==this._$angle&&this._$doChanged(!0),this._$angle=s.$clamp(t,-360,360,45)}get blurX(){return this._$blurFilter._$blurX}set blurX(t){this._$blurFilter.blurX=t}get blurY(){return this._$blurFilter._$blurY}set blurY(t){this._$blurFilter.blurY=t}get distance(){return this._$distance}set distance(t){(t=s.$clamp(+t,-255,255,4))!==this._$distance&&this._$doChanged(!0),this._$distance=t}get highlightAlpha(){return this._$highlightAlpha}set highlightAlpha(t){(t=s.$clamp(+t,0,1,0))!==this._$highlightAlpha&&this._$doChanged(!0),this._$highlightAlpha=t}get highlightColor(){return this._$highlightColor}set highlightColor(t){(t=s.$clamp(s.$toColorInt(t),0,16777215,16777215))!==this._$highlightColor&&this._$doChanged(!0),this._$highlightColor=t}get knockout(){return this._$knockout}set knockout(t){(t=!!t)!==this._$knockout&&this._$doChanged(!0),this._$knockout=t}get quality(){return this._$blurFilter._$quality}set quality(t){this._$blurFilter.quality=t}get shadowAlpha(){return this._$shadowAlpha}set shadowAlpha(t){(t=s.$clamp(+t,0,1,0))!==this._$shadowAlpha&&this._$doChanged(!0),this._$shadowAlpha=t}get shadowColor(){return this._$shadowColor}set shadowColor(t){(t=s.$clamp(s.$toColorInt(t),0,16777215,0))!==this._$shadowColor&&this._$doChanged(!0),this._$shadowColor=t}get strength(){return this._$strength}set strength(t){(t=s.$clamp(0|t,0,255,0))!==this._$strength&&this._$doChanged(!0),this._$strength=t}get type(){return this._$type}set type(t){switch((t+="")!==this._$type&&this._$doChanged(!0),t){case H.OUTER:case H.INNER:this._$type=t;break;default:this._$type=H.FULL}}clone(){return new V(this._$distance,this._$angle,this._$highlightColor,this._$highlightAlpha,this._$shadowColor,this._$shadowAlpha,this._$blurFilter._$blurX,this._$blurFilter._$blurY,this._$strength,this._$blurFilter._$quality,this._$type,this._$knockout)}_$isUpdated(){return this._$updated||this._$blurFilter._$isUpdated()}_$generateFilterRect(t,e=null,i=null){let r=t.clone();if(!this._$canApply())return r;r=this._$blurFilter._$generateFilterRect(r,e,i);const n=+this.angle*s.$PI/180,a=s.$cos(n)*this.distance,o=s.$sin(n)*this.distance;let h=0|s.$abs(a),l=0|s.$abs(o);return 0>a&&h++,0>o&&l++,0===h&&0>o&&(h=1),0===l&&0>a&&(l=1),r.x-=h,r.width+=2*h,r.y-=l,r.height+=2*l,r}_$isSame(t){return this._$distance===t._$distance&&(this._$angle===t._$angle&&(this._$highlightColor===t._$highlightColor&&(this._$highlightAlpha===t._$highlightAlpha&&(this._$shadowColor===t._$shadowColor&&(this._$shadowAlpha===t._$shadowAlpha&&(this._$strength===t._$strength&&(this._$type===t._$type&&(this._$knockout===t._$knockout&&this._$blurFilter._$isSame(t._$blurFilter)))))))))}_$canApply(){return!(!this._$strength||!this._$distance)}_$applyFilter(t,e){this._$doChanged(!1);const i=t.frameBuffer.currentAttachment;t.setTransform(1,0,0,1,0,0);const r=t.frameBuffer.getTextureFromCurrentAttachment();if(!this._$canApply())return r;const n=i.width,a=i.height,o=t._$offsetX,h=t._$offsetY,l=s.$sqrt(e[0]*e[0]+e[1]*e[1]),$=s.$sqrt(e[2]*e[2]+e[3]*e[3]),_=+this._$angle*s.$Deg2Rad,c=+s.$cos(_)*this._$distance*l,u=+s.$sin(_)*this._$distance*$;let d=t.frameBuffer.createTextureAttachment(n,a);t._$bind(d),s.$resetContext(t),t.drawImage(r,0,0,n,a),t.globalCompositeOperation=C.ERASE,t.drawImage(r,2*c,2*u,n,a);const g=this._$blurFilter._$applyFilter(t,e,!1),f=g.width,m=g.height,p=s.$ceil(f+2*s.$abs(c)),x=s.$ceil(m+2*s.$abs(u)),b=this._$type===H.INNER,T=b?n:p,v=b?a:x,y=s.$abs(c),E=s.$abs(u),A=(f-n)/2,M=(m-a)/2;let S,R,w,O;return b?(S=0,R=0,w=-A-c,O=-M-u):(S=y+A,R=E+M,w=y-c,O=E-u),t._$bind(i),t._$applyBitmapFilter(g,T,v,n,a,S,R,f,m,w,O,!1,this._$type,this._$knockout,this._$strength,null,null,null,s.$intToR(this._$highlightColor,this._$highlightAlpha,!0),s.$intToG(this._$highlightColor,this._$highlightAlpha,!0),s.$intToB(this._$highlightColor,this._$highlightAlpha,!0),this._$highlightAlpha,s.$intToR(this._$shadowColor,this._$shadowAlpha,!0),s.$intToG(this._$shadowColor,this._$shadowAlpha,!0),s.$intToB(this._$shadowColor,this._$shadowAlpha,!0),this._$shadowAlpha),t._$offsetX=o+S,t._$offsetY=h+R,t.frameBuffer.releaseTexture(g),t.frameBuffer.getTextureFromCurrentAttachment()}}class W extends X{constructor(t=null){super(),this._$matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this._$doApply=!1,this.matrix=t}static toString(){return"[class ColorMatrixFilter]"}static get namespace(){return"next2d.filters.ColorMatrixFilter"}toString(){return"[object ColorMatrixFilter]"}get namespace(){return"next2d.filters.ColorMatrixFilter"}get matrix(){return this._$matrix}set matrix(t){if(s.$isArray(t)&&20===t.length){if(this._$matrix){const e=t.length;for(let i=0;i0?s.$max(0,f-u):0)+v,C=(m>0?s.$max(0,m-d):0)+y),this._$inner?(S=H.INNER,R=this._$knockout||this._$hideObject):!this._$knockout&&this._$hideObject?(S=H.FULL,R=!0):(S=H.OUTER,R=this._$knockout),t._$bind(i),t._$applyBitmapFilter(h,b,T,r,n,E,A,l,$,M,C,!0,S,R,this._$strength,null,null,null,s.$intToR(this._$color,this._$alpha,!0),s.$intToG(this._$color,this._$alpha,!0),s.$intToB(this._$color,this._$alpha,!0),this._$alpha,0,0,0,0),t._$offsetX=a+E,t._$offsetY=o+A,t.frameBuffer.releaseTexture(h),t.frameBuffer.getTextureFromCurrentAttachment()}}class J extends X{constructor(t=0,e=1,i=4,s=4,r=1,n=1,a=!1,o=!1){super(),this._$blurFilter=new z(i,s,n),this._$color=0,this._$alpha=1,this._$strength=1,this._$inner=!1,this._$knockout=!1,this.color=t,this.alpha=e,this.strength=r,this.inner=a,this.knockout=o}static toString(){return"[class GlowFilter]"}static get namespace(){return"next2d.filters.GlowFilter"}toString(){return"[object GlowFilter]"}get namespace(){return"next2d.filters.GlowFilter"}get alpha(){return this._$alpha}set alpha(t){(t=s.$clamp(+t,0,1,0))!==this._$alpha&&this._$doChanged(!0),this._$alpha=t}get blurX(){return this._$blurFilter._$blurX}set blurX(t){this._$blurFilter.blurX=t}get blurY(){return this._$blurFilter._$blurY}set blurY(t){this._$blurFilter.blurY=t}get color(){return this._$color}set color(t){(t=s.$clamp(s.$toColorInt(t),0,16777215,4))!==this._$color&&this._$doChanged(!0),this._$color=t}get inner(){return this._$inner}set inner(t){(t=!!t)!==this._$inner&&this._$doChanged(!0),this._$inner=t}get knockout(){return this._$knockout}set knockout(t){(t=!!t)!==this._$knockout&&this._$doChanged(!0),this._$knockout=t}get quality(){return this._$blurFilter._$quality}set quality(t){this._$blurFilter.quality=t}get strength(){return this._$strength}set strength(t){(t=s.$clamp(0|t,0,255,0))!==this._$strength&&this._$doChanged(!0),this._$strength=t}clone(){return new J(this._$color,this._$alpha,this._$blurFilter._$blurX,this._$blurFilter._$blurY,this._$strength,this._$blurFilter._$quality,this._$inner,this._$knockout)}_$isUpdated(){return this._$updated||this._$blurFilter._$isUpdated()}_$generateFilterRect(t,e=null,i=null){const s=t.clone();return this._$canApply()?this._$blurFilter._$generateFilterRect(s,e,i):s}_$isSame(t){return this._$color===t._$color&&(this._$alpha===t._$alpha&&(this._$strength===t._$strength&&(this._$inner===t._$inner&&(this._$knockout===t._$knockout&&this._$blurFilter._$isSame(t._$blurFilter)))))}_$canApply(){return!(!this._$alpha||!this._$strength)&&this._$blurFilter._$canApply()}_$applyFilter(t,e){this._$doChanged(!1);const i=t.frameBuffer.currentAttachment;if(t.setTransform(1,0,0,1,0,0),!this._$canApply())return t.frameBuffer.getTextureFromCurrentAttachment();const r=i.width,n=i.height,a=t._$offsetX,o=t._$offsetY,h=this._$blurFilter._$applyFilter(t,e,!1),l=h.width,$=h.height,_=t._$offsetX,c=t._$offsetY,u=this._$inner?r:l,d=this._$inner?n:$;let g,f,m,p;this._$inner?(g=0,f=0,m=-_,p=-c):(g=_-a,f=c-o,m=0,p=0);const x=this._$inner?H.INNER:H.OUTER;return t._$bind(i),t._$applyBitmapFilter(h,u,d,r,n,g,f,l,$,m,p,!0,x,this._$knockout,this._$strength,null,null,null,s.$intToR(this._$color,this._$alpha,!0),s.$intToG(this._$color,this._$alpha,!0),s.$intToB(this._$color,this._$alpha,!0),this._$alpha,0,0,0,0),t._$offsetX=a+g,t._$offsetY=o+f,t.frameBuffer.releaseTexture(h),t.frameBuffer.getTextureFromCurrentAttachment()}}class Z extends X{constructor(t=4,e=45,i=null,s=null,r=null,n=4,a=4,o=1,h=1,l="inner",$=!1){super(),this._$blurFilter=new z(n,a,h),this._$distance=4,this._$angle=45,this._$colors=null,this._$alphas=null,this._$ratios=null,this._$strength=1,this._$type=H.INNER,this._$knockout=!1,this.distance=t,this.angle=e,this.colors=i,this.alphas=s,this.ratios=r,this.strength=o,this.type=l,this.knockout=$}static toString(){return"[class GradientBevelFilter]"}static get namespace(){return"next2d.filters.GradientBevelFilter"}toString(){return"[object GradientBevelFilter]"}get namespace(){return"next2d.filters.GradientBevelFilter"}get alphas(){return this._$colors&&this._$ratios?this._$alphas:null}set alphas(t){if(this._$alphas=null,s.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;i16777215&&(e%=16777216),t[i]=s.$toColorInt(s.$abs(e))}this._$colors=t.slice(0)}}get distance(){return this._$distance}set distance(t){(t=s.$clamp(+t,-255,255,4))!==this._$distance&&this._$doChanged(!0),this._$distance=t}get knockout(){return this._$knockout}set knockout(t){(t=!!t)!==this._$knockout&&this._$doChanged(!0),this._$knockout=t}get quality(){return this._$blurFilter._$quality}set quality(t){this._$blurFilter.quality=t}get ratios(){return this._$alphas&&this._$colors?this._$ratios:null}set ratios(t){if(this._$ratios=null,s.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;ir&&a++,0>n&&o++,0===a&&0>n&&(a=1),0===o&&0>r&&(o=1),e.x-=a,e.width+=2*a,e.y-=o,e.height+=2*o,e}_$isSame(t){if(this._$distance!==t._$distance)return!1;if(this._$angle!==t._$angle)return!1;for(let e=0;e16777215&&(e%=16777216),t[i]=s.$toColorInt(s.$abs(e))}this._$colors=t.slice(0)}}get distance(){return this._$distance}set distance(t){(t=s.$clamp(+t,-255,255,4))!==this._$distance&&this._$doChanged(!0),this._$distance=t}get knockout(){return this._$knockout}set knockout(t){(t=!!t)!==this._$knockout&&this._$doChanged(!0),this._$knockout=t}get quality(){return this._$blurFilter._$quality}set quality(t){this._$blurFilter.quality=t}get ratios(){return this._$alphas&&this._$colors?this._$ratios:null}set ratios(t){if(this._$ratios=null,s.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;i0?s.$max(0,p-u):0)+A,w=(x>0?s.$max(0,x-d):0)+M),t._$bind(i),t._$applyBitmapFilter(h,y,E,r,n,C,S,l,$,R,w,!0,this.type,this.knockout,this._$strength,this.ratios,this.colors,this.alphas,0,0,0,0,0,0,0,0),t._$offsetX=a+C,t._$offsetY=o+S,t.frameBuffer.releaseTexture(h),t.frameBuffer.getTextureFromCurrentAttachment()}}class et{static toString(){return"[class TextFormatAlign]"}static get namespace(){return"next2d.text.TextFormatAlign"}toString(){return"[object TextFormatAlign]"}get namespace(){return"next2d.text.TextFormatAlign"}static get CENTER(){return"center"}static get LEFT(){return"left"}static get RIGHT(){return"right"}}class it{static toString(){return"[class TextFieldAutoSize]"}static get namespace(){return"next2d.text.TextFieldAutoSize"}toString(){return"[object TextFieldAutoSize]"}get namespace(){return"next2d.text.TextFieldAutoSize"}static get CENTER(){return"center"}static get LEFT(){return"left"}static get NONE(){return"none"}static get RIGHT(){return"right"}}class st extends T{constructor(){super(),this._$background=!1,this._$backgroundColor=16777215,this._$border=!1,this._$borderColor=0,this._$htmlText="",this._$multiline=!1,this._$text="",this._$wordWrap=!1,this._$scrollH=0,this._$scrollV=1,this._$maxScrollV=null,this._$maxScrollH=null,this._$maxChars=0;const t=new nt;t._$setDefault(this),this._$defaultTextFormat=t,this._$decisionTextFormat=t,this._$rawHtmlText="",this._$bounds={xMin:0,xMax:100,yMin:0,yMax:100},this._$originBounds={xMin:0,xMax:100,yMin:0,yMax:100},this._$restrict=null,this._$isHTML=!1,this._$textData=null,this._$renew=!0,this._$textHeight=null,this._$textWidth=null,this._$widthTable=null,this._$textarea=null,this._$autoSize=it.NONE,this._$autoFontSize=!1,this._$textAppending=!1,this._$heightTable=null,this._$textFormatTable=[],this._$textAreaActive=!1,this._$totalWidth=null,this._$objectTable=null,this._$imageData=null,this._$scroll=!1,this._$type=rt.STATIC,this._$textHeightTable=null,this._$focus=!1,this._$isComposing=!1,this._$thickness=0,this._$thicknessColor=0,this._$verticalAlign=at.TOP}static toString(){return"[class TextField]"}static get namespace(){return"next2d.text.TextField"}toString(){return"[object TextField]"}get namespace(){return"next2d.text.TextField"}static get TEXT(){return"text"}static get BREAK(){return"break"}static get WRAP(){return"wrap"}static get IMAGE(){return"image"}get autoFontSize(){return this._$autoFontSize}set autoFontSize(t){this._$autoFontSize=!!t}get autoSize(){return this._$autoSize}set autoSize(t){switch(t){case it.CENTER:case it.LEFT:case it.RIGHT:this._$autoSize=t;break;default:this._$autoSize=it.NONE}this._$reload()}get background(){return this._$background}set background(t){this._$background=!!t,this._$reset()}get backgroundColor(){return this._$backgroundColor}set backgroundColor(t){this._$backgroundColor=s.$clamp(s.$toColorInt(t),0,16777215,16777215),this._$reset()}get border(){return this._$border}set border(t){this._$border=!!t,this._$reset()}get borderColor(){return this._$borderColor}set borderColor(t){this._$borderColor=s.$clamp(s.$toColorInt(t),0,16777215,0),this._$reset()}get defaultTextFormat(){return this._$defaultTextFormat}set defaultTextFormat(t){t instanceof nt&&(t._$merge(this._$defaultTextFormat),t._$textField=this,this._$defaultTextFormat=t)}get focus(){return this._$focus}set focus(t){if(this._$focus!==!!t)if(this._$focus=!!t,this._$focus){if(this._$type===rt.INPUT){const t=s.$currentPlayer(),e=s.$document.getElementById(t.contentElementId);if(!e)return;this._$createTextAreaElement(t._$scale);const i=this._$textarea,r=this._$transform.concatenatedMatrix,n=this._$getBounds(null),a=s.$intToRGBA(this._$defaultTextFormat._$color,100);i.style.color=`rgb(${a.R},${a.G},${a.B})`,i.style.left=(r.tx+n.xMin+t._$tx/t._$scale/s.$devicePixelRatio)*t._$scale+"px",i.style.top=(r.ty+n.yMin+t._$ty/t._$scale/s.$devicePixelRatio)*t._$scale+"px",i.style.width=`${s.$ceil((this.width-1)*t._$scale)}px`,i.style.height=`${s.$ceil((this.height-1)*t._$scale)}px`,i.value=this.text,e.appendChild(i);(0,s.$requestAnimationFrame)((()=>{i.focus()})),this._$textAreaActive=!0,this.willTrigger(l.FOCUS_IN)&&this.dispatchEvent(new l(l.FOCUS_IN)),this._$doChanged(),s.$isUpdated=!0}}else this._$textarea&&(this._$textarea.dispatchEvent(new s.$window.Event(`${s.$PREFIX}_blur`)),this.willTrigger(l.FOCUS_OUT)&&this.dispatchEvent(new l(l.FOCUS_OUT)),this._$doChanged(),s.$isUpdated=!0,this._$textarea.remove())}get htmlText(){return this._$htmlText}set htmlText(t){this._$htmlText!==t&&(this._$htmlText=`${t}`,this._$rawHtmlText="",this._$text="",this._$isHTML=!0,this._$textFormatTable=[],this._$reload())}get length(){return this.text.length}get maxChars(){return this._$maxChars}set maxChars(t){this._$maxChars=0|t}get maxScrollH(){return null===this._$maxScrollH&&(this._$maxScrollH=0),this._$maxScrollH}get maxScrollV(){if(null===this._$maxScrollV){this._$maxScrollV=1,this._$getTextData();const t=this._$textHeightTable.length,e=this.height;if(e>this.textHeight)return this._$maxScrollV;let i=0,s=0;for(;t>s&&(i+=this._$textHeightTable[s],!(i>e));)this._$maxScrollV++}return this._$maxScrollV}get multiline(){return this._$multiline}set multiline(t){this._$multiline=!!t,this._$reset()}get numLines(){return null===this._$textData&&this._$getTextData(),this._$objectTable.length}get restrict(){return this._$restrict}set restrict(t){this._$restrict=`${t}`}get scroll(){return this._$scroll}set scroll(t){this._$scroll=!!t}get scrollH(){return this._$scrollH}set scrollH(t){t=s.$clamp(0|t,0,this.maxScrollH),this._$scrollH!==t&&(this._$scrollH=t,this._$reset(),this.willTrigger(a.SCROLL)&&this.dispatchEvent(new a(a.SCROLL,!0)))}get scrollV(){return this._$scrollV}set scrollV(t){t=s.$clamp(0|t,1,this.maxScrollV),this._$scrollV!==t&&(this._$scrollV=t,this._$reset(),this.willTrigger(a.SCROLL)&&this.dispatchEvent(new a(a.SCROLL,!0)))}get text(){if(!this._$isHTML)return this._$text;if(this._$rawHtmlText)return this._$rawHtmlText;let t="";const e=this._$getTextData(),i=0|e.length;for(let s=1;s-1){const e=this._$getBounds(null),i=s.$abs(e.xMin);this._$originBounds.xMax=t+i,this._$originBounds.xMin=i,this._$bounds.xMax=this._$originBounds.xMax,this._$bounds.xMin=this._$originBounds.xMin,super.width=t,this._$reload()}}get height(){return super.height}set height(t){if(t=+t,!s.$isNaN(t)&&t>-1){const e=this._$getBounds(null),i=s.$abs(e.yMin);this._$originBounds.yMax=t+i,this._$bounds.yMax=this._$originBounds.yMax,this._$bounds.yMin=this._$originBounds.yMin,super.height=t,this._$reload()}}get x(){const t=this._$transform.matrix,e=this._$getBounds(null);return t._$matrix[4]+e.xMin}set x(t){const e=this._$getBounds(null);super.x=t-e.xMin}get y(){const t=this._$transform.matrix,e=this._$getBounds(null);return t._$matrix[5]+e.yMin}set y(t){const e=this._$getBounds(null);super.y=t-e.yMin}appendText(t){const e=this.text;this._$textAppending=!0,this.text=e+`${t}`,this._$textAppending=!1}getTextFormat(t=-1,e=-1){t|=0,e|=0;const i=this._$getTextData(),s=e>-1?e:i.length;let r=!1,n=new nt,a=t>-1?t:0;for(;at)break;r.yIndex===t&&(r.mode===st.TEXT&&(e+=r.text))}return e}replaceText(t,e,i){if(e|=0,(t|=0)>-1&&e>-1&&e>=t){const s=this.text;t>=s.length?e>=s.length&&e>=t&&(this.text=s+`${i}`):this.text=s.substr(0,t)+`${i}`+s.substr(e,s.length)}}setTextFormat(t,e=-1,i=-1){e|=0,i|=0;const s=this._$getTextData();switch(this._$reset(),!0){case-1===e&&-1===i:{const e=s.length;for(let i=0;i-1&&-1===i:{let i=e+1,r=s[i];r.mode===st.WRAP&&(r=s[++i]),this._$textFormatTable[i]=t._$clone()}break;case e>-1&&i>-1&&i>e:{let r=0;for(let n=e;n|<>)/g);i>-1&&(e=e.slice(0,i)),e=e.replace(/\r\n/g,"\r\r"),s.$P_TAG.innerHTML!==e&&(s.$P_TAG.textContent="",s.$P_TAG.insertAdjacentHTML("afterbegin",e));let r=this._$decisionTextFormat;if(this._$textData.length in this._$textFormatTable){const t=this._$textFormatTable[this._$textData.length]._$clone();t._$merge(r),r=t}this._$totalWidth=0,this._$heightTable[0]=0,this._$textHeightTable[0]=this._$getTextHeight(r),this._$widthTable[0]=0;const n={mode:st.BREAK,x:0,yIndex:0,textFormat:r._$clone()};this._$objectTable[0]=n,this._$textData[0]=n,this._$parseTag(s.$P_TAG,r._$clone(),t)}else{const e=this._$multiline?this._$text.split("\n"):[this._$text.replace("\n","")],i=e.length;for(let s=0;s0){const t=this._$imageData[this._$imageData.length-1],i=t.y+t.height+2*t.vspace;e.y=s.$max(l,i)}this._$loadImage(e),s.$loadedImages.set(t,e)}this._$textData[this._$textData.length]=e,this._$imageData[this._$imageData.length]=e}break;default:this._$parseTag(a,n,i)}else i=this._$parseText(a.nodeValue,n)}}_$loadImage(t){t.scope=this,t.image=new s.$Image,t.image.crossOrigin="anonymous",t.image.addEventListener("load",function(){this.loaded=!0,this.width||(this.width=0|this.image.width),this.height||(this.height=0|this.image.height);const t=this.scope;this.scope=null,s.$loadedImages.set(this.src,this),t._$reload()}.bind(t),!1),t.image.src=t.src}_$parseText(t,e,i){let r=this._$heightTable.length-1|0,n=e._$clone();const a=this._$transform.concatenatedMatrix._$matrix,o=(this._$originBounds.xMax-this._$originBounds.xMin)*(a[0]/a[3]);s.$poolFloat32Array6(a);const h=o-n._$widthMargin()-4;for(let a=0;ah){this._$widthTable[++r]=0,o.yIndex=r,this._$heightTable[r]=this._$heightTable[r-1],this._$textHeightTable[r]=this._$textHeightTable[r-1],this._$totalWidth=this._$getImageOffsetX(),n=n._$clone(),n._$indent=0;d={mode:l?st.BREAK:st.WRAP,x:0,yIndex:r,textFormat:n},this._$objectTable[r]=d,l||--i;let t=o.text,e=0,a=!0;const h=/[0-9a-zA-Z?!;:.,?!。、;:〜]/g;for(;t.match(h);){++e;const i=this._$textData[this._$textData.length-e];if(i.mode!==st.TEXT){a=!1;break}t=i.text}if(e>1&&this._$textData[this._$textData.length-e+1].text.match(/[0-9a-zA-Z]/g)&&--e,e>0&&a){const t=this._$textData.length-e;this._$textData.splice(t,0,d);let i=1,n=this._$textData[t-i];for(this._$widthTable[r-1]=0,this._$heightTable[r-1]=0,this._$textHeightTable[r-1]=0;n.mode===st.TEXT;)c=this._$getTextHeight(n.textFormat),u=c+$,this._$widthTable[r-1]+=n.width,this._$heightTable[r-1]=s.$max(this._$heightTable[r-1],c),this._$textHeightTable[r-1]=s.$max(this._$textHeightTable[r-1],u),++i,n=this._$textData[t-i];for(i=1;this._$textData.length>t+i;)n=this._$textData[t+i],++i,c=this._$getTextHeight(n.textFormat),u=c+$,this._$heightTable[r]=s.$max(this._$heightTable[r],c),this._$textHeightTable[r]=s.$max(this._$textHeightTable[r],u),n.x=this._$totalWidth,n.yIndex=r,this._$totalWidth+=n.width}else this._$textData[this._$textData.length]=d}l||(o.width=_,o.x=this._$totalWidth,this._$totalWidth+=_,this._$widthTable[r]=s.$max(this._$widthTable[r],this._$totalWidth),this._$heightTable[r]=s.$max(this._$heightTable[r],c),this._$textHeightTable[r]=s.$max(this._$textHeightTable[r],u),this._$textData[this._$textData.length]=o)}return i}_$getTextHeight(t){if(!s.$DIV){const t=s.$document.createElement("div");t.innerHTML="a",t.style.display="block",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.padding="0",t.style.margin="0",t.style.padding="0",t.style.border="0",t.style.outline="0",t.style.verticalAlign="bottom",t.style.lineHeight="100%",s.$DIV=t,s.$document.body.appendChild(s.$DIV)}const e=t._$size,i=t._$font,r=t._$bold?"bold":"normal",n=`${e}_${i}_${r}`;if(this._$heightCache.has(n))return this._$heightCache.get(n);const a=s.$DIV.style,o=`${e}px`;a.fontSize!==o&&(a.fontSize=o),a.fontFamily!==i&&(a.fontFamily=i),a.fontWeight!==r&&(a.fontWeight=r);const h=10>e?s.$DIV.clientHeight*e*.1:s.$DIV.clientHeight;return this._$heightCache.set(n,h),h}_$getImageOffsetX(){if(!this._$imageData.length)return 0;let t=0;for(let e=0;ethis.width)for(;this.textWidth>this.width;){if(this.defaultTextFormat.size--,1>this.defaultTextFormat.size){this.defaultTextFormat.size=1;break}this._$reset(),this._$getTextData()}if(this.height&&this.textHeight&&this.textHeight>this.height)for(;this.textHeight>this.height;){if(this.defaultTextFormat.size--,1>this.defaultTextFormat.size){this.defaultTextFormat.size=1;break}this._$reset(),this._$getTextData()}this.defaultTextFormat.size=t}this._$resize()}_$resize(){if(this._$autoSize!==it.NONE){const t=this._$defaultTextFormat,e=this.textWidth+4+t._$leftMargin+t._$rightMargin;if(this._$wordWrap)this._$bounds.xMax=this._$originBounds.xMax,this._$bounds.xMin=this._$originBounds.xMin;else switch(this._$autoSize){case it.LEFT:case it.CENTER:this._$bounds.xMax=e+this._$bounds.xMin;break;case it.RIGHT:this._$bounds.xMax=this._$originBounds.xMax-(this._$originBounds.xMax-this._$originBounds.xMin-(e-this._$originBounds.xMin))}this._$bounds.yMax=this.textHeight+4+this._$originBounds.yMin}}_$getAlignOffset(t,e){const i=this._$widthTable[t.yIndex],r=t.textFormat,n=r._$blockIndent+r._$leftMargin>0?r._$blockIndent+r._$leftMargin:0;switch(!0){case!1===this._$wordWrap&&i>e:return s.$max(0,n);case r._$align===et.CENTER:case this._$autoSize===it.CENTER:return s.$max(0,e/2-n-r._$rightMargin-i/2);case r._$align===et.RIGHT:case this._$autoSize===it.RIGHT:return s.$max(0,e-n-i-r._$rightMargin-2);default:return s.$max(0,n+2)}}_$getBounds(t=null){if(t){const e=s.$multiplicationMatrix(t,this._$correctMatrix(this._$transform._$rawMatrix()));return s.$boundsMatrix(this._$bounds,e)}return s.$boundsMatrix(this._$bounds,this._$correctMatrix(s.$MATRIX_ARRAY_IDENTITY))}_$correctMatrix(t){switch(this._$autoSize){case it.CENTER:{const e=this.textWidth+4,i=(this._$originBounds.xMax-this._$originBounds.xMin)/2-e/2;return s.$getFloat32Array6(t[0],t[1],t[2],t[3],t[4]+i,t[5])}case it.RIGHT:{const e=this.textWidth+4,i=this._$originBounds.xMax-this._$originBounds.xMin-(e-this._$originBounds.xMin);return s.$getFloat32Array6(t[0],t[1],t[2],t[3],t[4]+i,t[5])}default:return t}}_$buildCharacter(t){const e=this.defaultTextFormat;switch(e.font=t.font,e.size=0|t.size,e.align=t.align,e.color=0|t.color,e.leading=t.leading,e.letterSpacing=t.letterSpacing,e.leftMargin=t.leftMargin,e.rightMargin=t.rightMargin,t.fontType){case 1:e.bold=!0;break;case 2:e.italic=!0;break;case 3:e.bold=!0,e.italic=!0}switch(this._$type=t.inputType,this._$multiline=!!t.multiline,this._$wordWrap=!!t.wordWrap,this._$border=!!t.border,this._$scroll=!!t.scroll,this._$thickness=0|t.thickness,this._$thicknessColor=0|t.thicknessColor,this._$bounds.xMin=t.originBounds.xMin,this._$bounds.xMax=t.originBounds.xMax,this._$bounds.yMin=t.originBounds.yMin,this._$bounds.yMax=t.originBounds.yMax,this._$originBounds.xMin=t.originBounds.xMin,this._$originBounds.xMax=t.originBounds.xMax,this._$originBounds.yMin=t.originBounds.yMin,this._$originBounds.yMax=t.originBounds.yMax,t.autoSize){case 1:this.autoSize=t.align;break;case 2:this.autoFontSize=!0}this.text=t.text}_$sync(){const t=super._$sync();return t&&this._$buildCharacter(t),t}_$build(t,e){const i=super._$build(t,e);return this._$buildCharacter(i),i}_$clip(t,e){const i=this._$getBounds(),r=i.xMax,n=i.xMin,a=i.yMax,o=i.yMin;s.$poolBoundsObject(i);let h=s.$ceil(s.$abs(r-n)),l=s.$ceil(s.$abs(a-o));if(!h||!l)return;let $=e;const _=this._$transform._$rawMatrix();_!==s.$MATRIX_ARRAY_IDENTITY&&($=s.$multiplicationMatrix(e,_)),s.$resetContext(t),t.setTransform($[0],$[1],$[2],$[3],$[4],$[5]),t.beginPath(),t.moveTo(0,0),t.lineTo(h,0),t.lineTo(h,l),t.lineTo(0,l),t.lineTo(0,0),t.clip(!0),$!==e&&s.$poolFloat32Array6($)}_$draw(t,e,i){if(!this._$visible||this._$textAreaActive)return;if(!this._$background&&!this._$border&&!this.text)return;let r=i;const n=this._$transform._$rawColorTransform();n!==s.$COLOR_ARRAY_IDENTITY&&(r=s.$multiplicationColor(i,n));const a=s.$clamp(r[3]+r[7]/255,0,1);if(!a)return;let o=e;const h=this._$transform._$rawMatrix();h!==s.$MATRIX_ARRAY_IDENTITY&&(o=s.$multiplicationMatrix(e,h));const l=this._$getBounds(null);l.xMin-=this._$thickness,l.xMax+=this._$thickness,l.yMin-=this._$thickness,l.yMax+=this._$thickness;const $=s.$boundsMatrix(l,o),_=+$.xMax,c=+$.xMin,u=+$.yMax,d=+$.yMin;s.$poolBoundsObject($),s.$poolBoundsObject(l);let g=s.$ceil(s.$abs(_-c)),f=s.$ceil(s.$abs(u-d));if(!g||!f)return;if(0>c+g||0>d+f)return;const m=t.frameBuffer.currentAttachment;if(c>m.width||d>m.height)return;const p=+s.$sqrt(o[0]*o[0]+o[1]*o[1]),x=+s.$sqrt(o[2]*o[2]+o[3]*o[3]),b=s.$getArray();b[0]=p,b[1]=x;const T=s.$cacheStore(),v=T.generateKeys(this._$instanceId,b,r);let y=T.get(v);if(y&&(this._$renew||this._$isUpdated())&&(T.set(v,null),T.destroy(y),y=null),g+=4*s.$devicePixelRatio,f+=4*s.$devicePixelRatio,!y){this._$renew=!1,r[3]=1;const i=T.getCanvas();i.width=g,i.height=f;const n=i.getContext("2d");if(this._$background||this._$border){if(n.beginPath(),n.rotate(s.$atan2(e[1],e[0])),n.moveTo(0,0),n.lineTo(g,0),n.lineTo(g,f),n.lineTo(0,f),n.lineTo(0,0),this._$background){const t=s.$generateColorTransform(s.$intToRGBA(this._$backgroundColor),r);n.fillStyle=`rgba(${t.R},${t.G},${t.B},${t.A})`,n.fill()}if(this._$border){const t=s.$generateColorTransform(s.$intToRGBA(this._$borderColor),r);n.lineWidth=1,n.strokeStyle=`rgba(${t.R},${t.G},${t.B},${t.A})`,n.stroke()}}n.save(),n.beginPath();const a=s.$atan2(e[1],e[0]);a&&n.rotate(a),n.moveTo(2,2),n.lineTo(g-2,2),n.lineTo(g-2,f-2),n.lineTo(2,f-2),n.lineTo(2,2),n.clip(),n.beginPath(),n.setTransform(e[0],e[1],e[2],e[3],0,0),this._$doDraw(n,e,r,!1,g/e[0]),n.restore(),y=t.frameBuffer.createTextureFromCanvas(n.canvas),T.set(v,y),T.destroy(n)}s.$poolArray(v),s.$poolArray(b);let E=!1,A=0,M=0;const C=this._$filters||this.filters;if(C&&C.length){const r=this._$canApply(C);if(r){E=!0;const n=[this._$instanceId,"f"];let a=s.$cacheStore().get(n);const o=this._$isFilterUpdated(g,f,e,i,C,r);a&&!o||(a&&(s.$cacheStore().set(n,null),a.layerWidth=0,a.layerHeight=0,a._$offsetX=0,a._$offsetY=0,a.matrix=null,a.colorTransform=null,t.frameBuffer.releaseTexture(a),a=null),y=this._$getFilterTexture(t,C,y,e,i),s.$cacheStore().set(n,y)),a&&(y=a),s.$poolArray(n),A=y._$offsetX,M=y._$offsetY}}s.$resetContext(t),t._$globalAlpha=a,t._$globalCompositeOperation=this._$blendMode||this.blendMode,t.setTransform(1,0,0,1,0,0),E?t.drawImage(y,c-A,d-M,y.width,y.height,r):t.drawImage(y,c,d,g,f,r)}_$doDraw(t,e,i,r,n){const a=this._$getTextData(),o=r?0:this.width,h=r?0:this.height;let l=0,$=0,_=0,c=0;if(this._$verticalAlign!==at.TOP&&this.height>this.textHeight)switch(this._$verticalAlign){case at.MIDDLE:c=(this.height-this.textHeight+2)/2;break;case at.BOTTOM:c=this.height-this.textHeight+2}const u=a.length;for(let d=0;dh||g>o))continue;let f=u.textFormat;if(!r){const e=s.$generateColorTransform(s.$intToRGBA(u.textFormat._$color),i);if(t.fillStyle=`rgba(${e.R},${e.G},${e.B},${e.A})`,this._$thickness){const e=s.$generateColorTransform(s.$intToRGBA(this._$thicknessColor),i);t.lineWidth=this._$thickness,t.strokeStyle=`rgba(${e.R},${e.G},${e.B},${e.A})`}}const m=0|u.yIndex;switch(u.mode){case st.BREAK:case st.WRAP:if(_++,this.scrollV>_)continue;if($+=this._$textHeightTable[m],l=this._$getAlignOffset(this._$objectTable[m],n),f._$underline){const r=u.textFormat._$size/12,n=s.$generateColorTransform(s.$intToRGBA(f._$color),i);t.lineWidth=s.$max(1,1/s.$min(e[0],e[3])),t.strokeStyle=`rgba(${n.R},${n.G},${n.B},${n.A})`,t.beginPath(),t.moveTo(l,c+$-r),t.lineTo(l+this._$widthTable[m],c+$-r),t.stroke()}break;case st.TEXT:{if(this.scrollV>_)continue;let e=$-this._$heightTable[0];s.$isSafari||(e+=u.textFormat._$size/12*2),t.beginPath(),t.textBaseline="top",t.font=f._$generateFontStyle(),this._$thickness&&t.strokeText(u.text,g,c+e),t.fillText(u.text,g,c+e)}break;case st.IMAGE:if(!u.loaded)continue;t.beginPath(),t.drawImage(u.image,u.hspace,c+u.y,u.width,u.height)}}}_$mouseHit(t,e,i){return!!this._$visible&&this._$hit(t,e,i)}_$hit(t,e,i){let r=e;const n=this._$transform._$rawMatrix();n!==s.$MATRIX_ARRAY_IDENTITY&&(r=s.$multiplicationMatrix(e,n));const a=this._$getBounds(null),o=s.$boundsMatrix(a,r),h=+o.xMax,l=+o.xMin,$=+o.yMax,_=+o.yMin;s.$poolBoundsObject(o),s.$poolBoundsObject(a);const c=s.$ceil(s.$abs(h-l)),u=s.$ceil(s.$abs($-_));return t.setTransform(1,0,0,1,l,_),t.beginPath(),t.moveTo(0,0),t.lineTo(c,0),t.lineTo(c,u),t.lineTo(0,u),t.lineTo(0,0),r!==e&&s.$poolFloat32Array6(r),t.isPointInPath(i.x,i.y)}_$createTextAreaElement(t){if(!this._$textarea){this._$textarea=s.$document.createElement("textarea"),this._$textarea.value=this.text,this._$textarea.id=`${s.$PREFIX}_TextField_${this._$instanceId}`,this._$wordWrap||(this._$textarea.wrap="off");const t=this.defaultTextFormat;if(this._$textarea.style.position="absolute",this._$textarea.style.outline="0",this._$textarea.style.padding=`2px 2px 2px ${s.$max(3,0|t.leftMargin)}px`,this._$textarea.style.margin="0",this._$textarea.style.appearance="none",this._$textarea.style.resize="none",this._$textarea.style.border=this._$border?`solid 1px #${this.borderColor.toString(16)}`:"none",this._$textarea.style.overflow="hidden",this._$textarea.style.zIndex=2147483647,this._$textarea.style.verticalAlign="top",this._$textarea.style.backgroundColor=this._$border||this._$background?`#${this.backgroundColor.toString(16)}`:"transparent",this._$textarea.addEventListener(`${s.$PREFIX}_blur`,function(t){let e=t.target.value?t.target.value:"";if(e&&this._$restrict){let t=this._$restrict;"["!==t[0]&&(t="["+t),"]"!==t[t.length-1]&&(t+="]");const i=e.match(new s.$RegExp(t,"gm"));e=i?i.join(""):""}this.text=e;if(s.$document.getElementById(s.$currentPlayer().contentElementId)){const t=s.$document.getElementById(`${s.$PREFIX}_TextField_${this._$instanceId}`);t&&(t.remove(),this._$focus=!1,this._$textAreaActive=!1,s.$isUpdated=!0,this._$doChanged())}}.bind(this)),this._$textarea.addEventListener("input",function(t){let e=t.target.value?t.target.value:"";if(this._$restrict&&!this._$isComposing&&e){let t=this._$restrict;"["!==t[0]&&(t="["+t),"]"!==t[t.length-1]&&(t+="]");const i=e.match(new s.$RegExp(t,"gm"));e=i?i.join(""):""}if(!this._$isComposing&&this.text!==e){this.text=e,t.target.value=e,this.willTrigger(a.CHANGE)&&this.dispatchEvent(new a(a.CHANGE,!0));const i=s.$currentPlayer(),r=this._$textarea,n=this._$transform.concatenatedMatrix,o=this._$getBounds(null);r.style.left=`${s.$floor((n.tx+o.xMin+i._$tx/i._$scale/s.$devicePixelRatio)*i._$scale)}px`,r.style.top=`${s.$floor((n.ty+o.yMin+i._$ty/i._$scale/s.$devicePixelRatio)*i._$scale)}px`,r.style.width=`${s.$ceil((this.width-1)*i._$scale)}px`,r.style.height=`${s.$ceil((this.height-1)*i._$scale)}px`}}.bind(this)),this._$textarea.addEventListener("compositionstart",function(){this._$isComposing=!0}.bind(this)),this._$textarea.addEventListener("compositionend",function(t){this._$isComposing=!1;let e=t.target.value?t.target.value:"";if(!this._$restrict||!e)return;let i=this._$restrict;"["!==i[0]&&(i="["+i),"]"!==i[i.length-1]&&(i+="]");const r=e.match(new s.$RegExp(i,"gm"));e=r?r.join(""):"",this.text=e,t.target.value=e}.bind(this)),this._$textarea.addEventListener("click",function(){this.willTrigger(c.CLICK)&&this.dispatchEvent(new c(c.CLICK))}.bind(this)),this._$textarea.addEventListener(s.$MOUSE_WHEEL,function(t){this.scrollV+=t.deltaY}.bind(this)),this._$textarea.addEventListener(s.$SCROLL,function(){if(this._$scrollEventLock)return void(this._$scrollEventLock=!1);const t=parseFloat(this._$textarea.style.height);this.scrollV=this._$textarea.scrollTop/(this._$textarea.scrollHeight-t)*this.maxScrollV+1}.bind(this)),!0===s.$isTouch)this._$textarea.addEventListener(s.$TOUCH_START,(function(){const t=s.$currentPlayer();t&&(t._$state="down")})),this._$textarea.addEventListener(s.$TOUCH_END,(function(){const t=s.$currentPlayer();t&&(t._$state="up")}));else this._$textarea.addEventListener(s.$MOUSE_DOWN,(function(){const t=s.$currentPlayer();t&&(t._$state="down")})),this._$textarea.addEventListener(s.$MOUSE_UP,(function(){const t=s.$currentPlayer();t&&(t._$state="up")}))}const e=this.defaultTextFormat,i=s.$ceil(e.size*t*this._$transform.concatenatedMatrix.d);this._$textarea.style.fontSize=`${i}px`,this._$textarea.style.fontFamily=e.font,this._$textarea.style.lineHeight=(i+s.$max(0,0|e.leading))/i+"em",this._$autoSize!==it.NONE?this._$textarea.style.textAlign=it.CENTER:this._$textarea.style.textAlign=e.align,this._$textarea.onkeydown||(this._$textarea.onkeydown=function(t){let e=t.target.value?t.target.value:"";if(this._$restrict&&!this._$isComposing&&e){let t=this._$restrict;"["!==t[0]&&(t="["+t),"]"!==t[t.length-1]&&(t+="]");const i=e.match(new s.$RegExp(t,"gm"));e=i?i.join(""):""}if(this._$isComposing||(this.text=e,t.target.value=e),13===t.keyCode&&!this._$multiline)return!1}.bind(this)),this._$textarea.maxLength=2147483647,this._$maxChars&&(this._$textarea.maxLength=this._$maxChars)}}class rt{static toString(){return"[class TextFieldType]"}static get namespace(){return"next2d.text.TextFieldType"}toString(){return"[object TextFieldType]"}get namespace(){return"next2d.text.TextFieldType"}static get INPUT(){return"input"}static get STATIC(){return"static"}}class nt{constructor(t=null,e=null,i=null,r=null,n=null,a=null,o=null,h=null,l=null,$=null,_=null,c=null){this._$font=t,this._$size=e,this._$color=null===i?null:s.$clamp(s.$toColorInt(i),0,16777215,16777215),this._$bold=r,this._$italic=n,this._$underline=a,this._$align=o,this._$leftMargin=h,this._$rightMargin=l,this._$indent=$,this._$leading=_,this._$blockIndent=c,this._$letterSpacing=0,this._$textField=null}static toString(){return"[class TextFormat]"}static get namespace(){return"next2d.text.TextFormat"}toString(){return"[object TextFormat]"}get namespace(){return"next2d.text.TextFormat"}get align(){return this._$align}set align(t){switch(t){case et.CENTER:case et.RIGHT:case et.LEFT:this._$align=t;break;default:this._$align=null}this._$textField&&(this._$textField._$renew=!0)}get blockIndent(){return this._$blockIndent}set blockIndent(t){this._$blockIndent=t,this._$textField&&(this._$textField._$renew=!0)}get bold(){return this._$bold}set bold(t){this._$bold=!!t,this._$textField&&(this._$textField._$renew=!0)}get color(){return this._$color}set color(t){this._$color=s.$clamp(s.$toColorInt(t),0,16777215,0),this._$textField&&(this._$textField._$renew=!0)}get font(){return this._$font}set font(t){this._$font=`${t}`,this._$textField&&(this._$textField._$renew=!0)}get indent(){return this._$indent}set indent(t){this._$indent=t,this._$textField&&(this._$textField._$renew=!0)}get italic(){return this._$italic}set italic(t){this._$italic=!!t,this._$textField&&(this._$textField._$renew=!0)}get leading(){return this._$leading}set leading(t){this._$leading=t,this._$textField&&(this._$textField._$renew=!0)}get leftMargin(){return this._$leftMargin}set leftMargin(t){this._$leftMargin=t,this._$textField&&(this._$textField._$renew=!0)}get letterSpacing(){return this._$letterSpacing}set letterSpacing(t){this._$letterSpacing=t,this._$textField&&(this._$textField._$renew=!0)}get rightMargin(){return this._$rightMargin}set rightMargin(t){this._$rightMargin=t,this._$textField&&(this._$textField._$renew=!0)}get size(){return this._$size}set size(t){this._$size=0|t,this._$textField&&(this._$textField._$renew=!0)}get underline(){return this._$underline}set underline(t){this._$underline=!!t,this._$textField&&(this._$textField._$renew=!0)}_$clone(){const t=new nt(this._$font,this._$size,this._$color,this._$bold,this._$italic,this._$underline,this._$align,this._$leftMargin,this._$rightMargin,this._$indent,this._$leading,this._$blockIndent);return t._$letterSpacing=this._$letterSpacing,t._$textField=this._$textField,t}_$setDefault(t=null){this._$align=et.LEFT,this._$blockIndent=0,this._$bold=!1,this._$color=0,this._$font="Times New Roman",this._$indent=0,this._$italic=!1,this._$leading=0,this._$leftMargin=0,this._$letterSpacing=0,this._$rightMargin=0,this._$size=12,this._$underline=!1,this._$textField=t}_$merge(t){null===this._$align&&(this._$align=t._$align),null===this._$blockIndent&&(this._$blockIndent=t._$blockIndent),null===this._$bold&&(this._$bold=t._$bold),null===this._$color&&(this._$color=t.color),null===this._$font&&(this._$font=t._$font),null===this._$indent&&(this._$indent=t._$indent),null===this._$italic&&(this._$italic=t._$italic),null===this._$leading&&(this._$leading=t._$leading),null===this._$leftMargin&&(this._$leftMargin=t._$leftMargin),null===this._$letterSpacing&&(this._$letterSpacing=t._$letterSpacing),null===this._$rightMargin&&(this._$rightMargin=t._$rightMargin),null===this._$size&&(this._$size=t._$size),null===this._$underline&&(this._$underline=t._$underline)}_$widthMargin(){return this._$indent+this._$leftMargin+this._$rightMargin}_$generateFontStyle(){let t="";return this._$italic&&(t="italic "),this._$bold&&(t+="bold "),`${t}${this._$size}px '${this._$font}','sans-serif'`}}class at{static toString(){return"[class TextFormatVerticalAlign]"}static get namespace(){return"next2d.text.TextFormatVerticalAlign"}toString(){return"[object TextFormatVerticalAlign]"}get namespace(){return"next2d.text.TextFormatVerticalAlign"}static get TOP(){return"top"}static get MIDDLE(){return"middle"}static get BOTTOM(){return"bottom"}}class ot{static toString(){return"[class URLLoaderDataFormat]"}static get namespace(){return"next2d.net.URLLoaderDataFormat"}toString(){return"[object URLLoaderDataFormat]"}get namespace(){return"next2d.net.URLLoaderDataFormat"}static get ARRAY_BUFFER(){return"arraybuffer"}static get JSON(){return"json"}}class ht{constructor(t=""){this._$url=t,this._$contentType="application/json",this._$data=null,this._$method=$t.GET,this._$requestHeaders=s.$getArray(),this._$userAgent=s.$navigator.userAgent,this._$responseDataFormat=ot.JSON,this._$withCredentials=!1}static toString(){return"[class URLRequest]"}static get namespace(){return"next2d.net.URLRequest"}toString(){return"[object URLRequest]"}get namespace(){return"next2d.net.URLRequest"}get contentType(){return this._$contentType}set contentType(t){this._$contentType=`${t}`}get data(){return this._$data}set data(t){this._$data=t}get method(){return this._$method}set method(t){switch((t+="").toUpperCase()){case $t.DELETE:case $t.HEAD:case $t.OPTIONS:case $t.POST:case $t.PUT:this._$method=t;break;default:this._$method=$t.GET}}get requestHeaders(){return this._$requestHeaders}set requestHeaders(t){s.$isArray(t)&&(this._$requestHeaders=t)}get url(){if(this._$url&&-1===this._$url.indexOf("//")){const t=this._$url.split("/");""!==t[0]&&"."!==t[0]||t.shift();const e=s.$currentPlayer();if(e)return`${e.base}${t.join("/")}`}return this._$url}set url(t){this._$url=`${t}`}get userAgent(){return this._$userAgent}get responseDataFormat(){return this._$responseDataFormat}set responseDataFormat(t){this._$responseDataFormat=`${t}`}get withCredentials(){return this._$withCredentials}get headers(){const t=s.$getMap();t.set("Content-Type",`${this._$contentType}`);const e=this._$requestHeaders.length;for(let i=0;it.target.status?(this._$buffer=new Uint8Array(t.target.response),s.$audioContext?s.$decodeAudioData(this):s.$audios.push(this),s.$currentPlayer()._$loaders.push(this)):this.willTrigger(_.IO_ERROR)&&this.dispatchEvent(new _(_.IO_ERROR,!1,!1,t.target.statusText,t.target.status))}.bind(this)}})}play(t=0){const e=this._$character?this._$character.audioBuffer:this._$audioBuffer;if(s.$audioContext&&e)this._$createBufferSource(t);else{const e=function(t,i=0){if(null!==(this._$character?this._$character.audioBuffer:this._$audioBuffer)&&null!==s.$audioContext){const e=(s.$performance.now()-t)/1e3;return void this._$createBufferSource(i,e)}(0,s.$requestAnimationFrame)(e)}.bind(this,s.$performance.now(),t);(0,s.$requestAnimationFrame)(e)}}stop(){this._$stopFlag=!0;const t=this._$sources.length;if(t){const e=s.$currentPlayer();if(s.$audioContext)for(let e=0;e=this._$duration&&(this.removeEventListener(a.ENTER_FRAME,this._$update),this.hasEventListener(a.COMPLETE)&&this.dispatchEvent(new a(a.COMPLETE))))}updateProperty(t,e,i,s){for(let r=0;rthis._$currentTime?t[a]=this._$ease(this._$currentTime,h,i[a]-h,this._$duration):t[a]=i[a]}}}class mt{static toString(){return"[class Tween]"}static get namespace(){return"next2d.ui.Tween"}toString(){return"[object Tween]"}get namespace(){return"next2d.ui.Tween"}static add(t,e,i,s=0,r=1,n=null){return new ft(t,e,i,s,r,n)}}class pt{constructor(){this._$pool=s.$getArray(),this._$poolBitmapData=s.$getArray(),this._$store=s.$getMap(),this._$lifeCount=2,this._$delayLifeCheck=this.lifeCheck.bind(this);(0,s.$setTimeout)(this._$delayLifeCheck,5e3)}reset(){const t=this._$store.values();for(const e of t){const t=e.values();for(const e of t)this.destroy(e);s.$poolMap(e)}this._$store.clear()}destroy(t){if(t)switch(t.constructor){case s.$WebGLTexture:{const e=s.$currentPlayer();if(e._$context){const i=e._$context,s=t._$bitmapData;s&&(s._$getPixelsAsync(0,0,s.width,s.height,"RGBA"),this._$poolBitmapData.push(s),t._$bitmapData=!1),i.frameBuffer.releaseTexture(t)}}break;case s.$CanvasRenderingContext2D:{const e=t.canvas,i=e.width,s=e.height;t.clearRect(0,0,i+1,s+1),e.width=e.height=1,this._$pool.push(e)}}}getCanvas(){return this._$pool.pop()||s.$document.createElement("canvas")}removeCache(t){if(t=`${t}`,this._$store.has(t)){const e=this._$store.get(t),i=e.values();for(const t of i)this.destroy(t);s.$poolMap(e),this._$store.delete(t)}}generateLifeKey(t,e){return`${t}:${e}`}get(t){const e=`${t[0]}`,i=`${t[1]}`;if(this._$store.has(e)){const t=this._$store.get(e);if(t.has(i)){const e=`life_${i}`;return 1===t.has(e)&&t.set(e,this._$lifeCount),t.get(i)}}return null}set(t,e){const i=`${t[0]}`,r=`${t[1]}`;this._$store.has(i)||this._$store.set(i,s.$getMap());const n=this._$store.get(i);if(!e)return n.delete(r),n.delete(`life_${r}`),void(n.size||(s.$poolMap(n),this._$store.delete(i)));const a=n.get(r);a&&a!==e&&this.destroy(a),n.set(r,e),n.set(`life_${r}`,this._$lifeCount)}generateShapeKeys(t,e,i=null){let r="";switch(!0){case 1!==e[0]:case 0!==e[1]:case 0!==e[2]:case 1!==e[3]:r=`${e[0]}_${e[1]}_${e[2]}_${e[3]}`}i&&(r+=this.colorToString(i));const n=s.$getArray();return n[0]=`${t}`,n[1]=r?this.generateHash(r):"_0",n}generateKeys(t,e=null,i=null){let r="";e&&(r+=`${e[0]}_${e[1]}`),i&&(r+=this.colorToString(i));const n=s.$getArray();return n[1]=r?this.generateHash(r):"_0",n[0]=`${t}`,n}colorToString(t=null){switch(!0){case 1!==t[0]:case 1!==t[1]:case 1!==t[2]:case 0!==t[4]:case 0!==t[5]:case 0!==t[6]:case 0!==t[7]:return`_${t[0]}_${t[1]}_${t[2]}_${t[4]}_${t[5]}_${t[6]}_${t[7]}`;default:return""}}generateHash(t){let e=0;const i=t.length;for(let s=0;s 0.0) {\n ${t.fragColor()} = vec4(min(alpha, 1.0));\n } else {\n discard;\n } \n}\n\n`}}class Tt{static FILL_COLOR(t){return`${t.version()}\nprecision mediump float;\n\nuniform vec4 u_mediump;\n\n${t.outColor()}\n\nvoid main() {\n ${t.fragColor()} = u_mediump;\n}\n\n`}static COPY_SRC_TEX(t){return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\n\n${t.varyingIn()} vec2 v_src_tex_coord;\n${t.outColor()}\n\nvoid main() {\n ${t.fragColor()} = ${t.texture2D()}(u_src_tex, v_src_tex_coord);\n}\n\n`}static COPY_CHANNEL(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\nuniform vec4 u_mediump[2];\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.varyingIn()} vec2 v_dst_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 src_ch = u_mediump[0];\n vec4 dst_ch = u_mediump[1];\n\n vec4 src_color = ${e.texture2D()}(u_textures[0], v_src_tex_coord);\n vec4 dst_color = ${e.texture2D()}(u_textures[1], v_dst_tex_coord);\n\n src_color = vec4(src_color.rgb/max(0.0001, src_color.a), src_color.a);\n dst_color = vec4(dst_color.rgb/max(0.0001, dst_color.a), dst_color.a);\n\n // src_color から必要なチャンネルのスカラー値を取り出したもの\n float src_value = dot(src_color, src_ch);\n\n // コピー先の他のチャンネルと合成\n vec4 mixed = mix(dst_color, vec4(src_value), dst_ch);\n\n#if ${t}\n ${e.fragColor()} = vec4(mixed.rgb * mixed.a, mixed.a);\n#else\n ${e.fragColor()} = vec4(mixed.rgb, 1.0);\n#endif\n}\n\n`}static MERGE(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\nuniform vec4 u_mediump;\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.varyingIn()} vec2 v_dst_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 src_color = ${e.texture2D()}(u_textures[0], v_src_tex_coord);\n vec4 dst_color = ${e.texture2D()}(u_textures[1], v_dst_tex_coord);\n\n src_color = vec4(src_color.rgb/max(0.0001, src_color.a), src_color.a);\n dst_color = vec4(dst_color.rgb/max(0.0001, dst_color.a), dst_color.a);\n\n vec4 merged = mix(dst_color, src_color, u_mediump);\n\n#if ${t}\n ${e.fragColor()} = vec4(merged.rgb * merged.a, merged.a);\n#else\n ${e.fragColor()} = vec4(merged.rgb, 1.0);\n#endif\n}\n\n`}static COPY_PIXELS_WITH_ALPHA_BITMAP_DATA(t){return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\n\n${t.varyingIn()} vec2 v_src_tex_coord;\n${t.varyingIn()} vec2 v_alpha_tex_coord;\n${t.outColor()}\n\nvoid main() {\n vec4 src_color = ${t.texture2D()}(u_textures[0], v_src_tex_coord);\n float alpha = ${t.texture2D()}(u_textures[1], v_alpha_tex_coord).a;\n\n src_color = vec4(src_color.rgb/max(0.0001, src_color.a), src_color.a);\n alpha *= src_color.a;\n\n ${t.fragColor()} = vec4(src_color.rgb * alpha, alpha);\n}\n\n`}static PALETTE_MAP(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 src_color = ${e.texture2D()}(u_textures[0], v_src_tex_coord);\n src_color = vec4(src_color.rgb/max(0.0001, src_color.a), src_color.a);\n\n // ↓ 256*4のテクスチャの画素の中心をサンプリング\n vec4 map_r = ${e.texture2D()}(u_textures[1], vec2((0.5+src_color.r*255.0)/256.0, 0.125));\n vec4 map_g = ${e.texture2D()}(u_textures[1], vec2((0.5+src_color.g*255.0)/256.0, 0.375));\n vec4 map_b = ${e.texture2D()}(u_textures[1], vec2((0.5+src_color.b*255.0)/256.0, 0.625));\n vec4 map_a = ${e.texture2D()}(u_textures[1], vec2((0.5+src_color.a*255.0)/256.0, 0.875));\n\n // u_plt_tex(u_textures[1]) のパレットデータは BGRA で格納されているので、これを取り出すには .bgra\n // TODO プラットフォームのバイトオーダーがビッグエンディアンの場合は ARGB で格納されるので、これを取り出すには .gbar\n vec4 color = (map_r + map_g + map_b + map_a).bgra;\n\n // fract は 1.0, 2.0, ... のときに 0.0 を返すが 1.0 が欲しい\n vec4 color_fract = fract(color);\n color = color_fract + sign(color) - sign(color_fract);\n\n#if ${t}\n ${e.fragColor()} = vec4(color.rgb * color.a, color.a);\n#else\n ${e.fragColor()} = vec4(color.rgb, 1.0);\n#endif\n}\n\n`}static PIXEL_DISSOLVE_TEXTURE(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 src_color = ${e.texture2D()}(u_src_tex, v_src_tex_coord);\n\n#if ${t}\n ${e.fragColor()} = src_color;\n#else\n ${e.fragColor()} = vec4(src_color.rgb, 1.0);\n#endif\n}\n\n`}static COLOR_TRANSFORM(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\nuniform vec4 u_mediump[2];\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 ct_mul = u_mediump[0];\n vec4 ct_add = u_mediump[1];\n\n vec4 src_color = ${e.texture2D()}(u_src_tex, v_src_tex_coord);\n src_color = vec4(src_color.rgb/max(0.0001, src_color.a), src_color.a);\n\n vec4 color = clamp(ct_mul * src_color + ct_add, 0.0, 1.0);\n\n color = vec4(color.rgb * color.a, color.a);\n\n#if !${t}\n color.a = 1.0;\n#endif\n\n ${e.fragColor()} = color * sign(src_color.a); // 元の色が無色透明の場合、結果も常に無色透明になる。\n}\n\n`}static bitwiseAnd(){return"\n#if __VERSION__ < 130\n// 8bitまでの整数どうしのビット積\nint bitwiseAnd(int a, int b) {\n //ivec4 c1 = ivec4(1,2,4,8);\n //ivec4 c2 = ivec4(16,32,64,128);\n\n //ivec4 a1 = ivec4(a) / c1;\n //ivec4 a2 = ivec4(a) / c2;\n //ivec4 b1 = ivec4(b) / c1;\n //ivec4 b2 = ivec4(b) / c2;\n\n //ivec4 r = (a1-a1/2*2) * (b1-b1/2*2) * c1\n // + (a2-a2/2*2) * (b2-b2/2*2) * c2;\n\n //return r.x + r.y + r.z + r.w;\n\n // ↑ intのままで計算した場合(rakusanの開発環境ではintの方が遅かった)\n // ↓ floatに変換してから計算した場合\n\n vec4 a0 = vec4(float(a));\n vec4 b0 = vec4(float(b));\n vec4 a1 = floor(a0 * vec4(1.0, 0.5, 0.25, 0.125));\n vec4 a2 = floor(a0 * vec4(0.0625, 0.03125, 0.015625, 0.0078125));\n vec4 b1 = floor(b0 * vec4(1.0, 0.5, 0.25, 0.125));\n vec4 b2 = floor(b0 * vec4(0.0625, 0.03125, 0.015625, 0.0078125));\n\n return int(dot((a1-floor(a1*0.5)*2.0)*(b1-floor(b1*0.5)*2.0), vec4(1.0,2.0,4.0,8.0))\n + dot((a2-floor(a2*0.5)*2.0)*(b2-floor(b2*0.5)*2.0), vec4(16.0,32.0,64.0,128.0)));\n}\n\nivec4 bitwiseAnd(ivec4 a, ivec4 b) {\n return ivec4(bitwiseAnd(a.r, b.r),\n bitwiseAnd(a.g, b.g),\n bitwiseAnd(a.b, b.b),\n bitwiseAnd(a.a, b.a));\n}\n#else\n#define bitwiseAnd(a, b) ((a)&(b))\n#endif\n"}static THRESHOLD(t,e,i,s){return e|=0,i|=0,`${s.version()}\n#if __VERSION__ < 130\n#extension GL_EXT_draw_buffers : require\n#endif\n\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\nuniform vec4 u_mediump[2]; // u_threshold(u_mediump[0]) はJS側でマスク済み\nuniform ivec4 u_integer;\n\n${s.varyingIn()} vec2 v_src_tex_coord;\n\n#if __VERSION__ < 130\n#define outColor0 gl_FragData[0]\n#define outColor1 gl_FragData[1]\n#else\nlayout (location = 0) out vec4 outColor0;\nlayout (location = 1) out vec4 outColor1;\n#endif\n\n${Tt.bitwiseAnd()}\n\nbool less(vec4 x) {\n return dot(sign(x - u_mediump[0]), vec4(4.0, 2.0, 1.0, 8.0)) < 0.0;\n}\n\nbool greater(vec4 x) {\n return dot(sign(x - u_mediump[0]), vec4(4.0, 2.0, 1.0, 8.0)) > 0.0;\n}\n\nbool lessEqual(vec4 x) {\n return !greater(x);\n}\n\nbool greaterEqual(vec4 x) {\n return !less(x);\n}\n\n// 組込関数に equal があるので thresholdEqual にしている。\nbool thresholdEqual(vec4 x) {\n return all(equal(x, u_mediump[0]));\n}\n\n// 組込関数に notEqual があるので thresholdNotEqual にしている。\nbool thresholdNotEqual(vec4 x) {\n return any(notEqual(x, u_mediump[0]));\n}\n\nvoid main() {\n // 乗算済みのままで比較するとFlash Playerと一致する。\n\n vec4 src_color = ${s.texture2D()}(u_src_tex, v_src_tex_coord);\n ivec4 masked = bitwiseAnd(ivec4(src_color * 255.0), u_integer);\n\n if (${t}(vec4(masked))) {\n outColor0 = u_mediump[1];\n outColor1 = vec4(1.0);\n } else {\n#if ${e}\n #if ${i}\n outColor0 = src_color;\n #else\n outColor0 = vec4(src_color.rgb, 1.0);\n #endif\n outColor1 = vec4(0.0);\n#else\n discard;\n#endif\n }\n}\n\n`}static THRESHOLD_SUBTOTAL(t){return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\nuniform vec4 u_mediump;\n\n${t.varyingIn()} vec2 v_src_tex_coord;\n${t.outColor()}\n\nvoid main() {\n vec2 src_tex_step = u_mediump.xy;\n float subtotal_loop = u_mediump.z;\n\n float subtotal = 0.0;\n\n#if __VERSION__ < 130\n float j = 0.0;\n for (float i = 0.0; i < 4095.0; ++i) { // この 4095.0 というマジックナンバーについては\n if (j++ >= subtotal_loop) { // BitmapData.prototype.threshold のコメントを見てください。\n break;\n }\n#else\n for (float i = 0.0; i < subtotal_loop; ++i) {\n#endif\n subtotal += ${t.texture2D()}(u_src_tex, v_src_tex_coord + src_tex_step * i).a;\n }\n\n vec4 v1 = floor(subtotal * vec4(1.0, 0.00390625, 0.0000152587890625, 5.960464477539063e-8)); // vec4(1.0, 1.0/256.0, 1.0/65536.0, 1.0/16777216.0)\n vec4 v2 = vec4(v1.yzw, 0.0);\n ${t.fragColor()} = (v1 - v2*256.0) * 0.00392156862745098; // 1.0/255.0\n}\n\n`}static GET_COLOR_BOUNDS_RECT(t,e){return t|=0,`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\nuniform vec4 u_mediump;\nuniform ivec4 u_integer[2];\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\n${Tt.bitwiseAnd()}\n\nvoid main() {\n vec2 src_tex_step = u_mediump.xy;\n float scan_loop = u_mediump.z;\n ivec4 mask = u_integer[0];\n ivec4 color = u_integer[1];\n\n float found = 0.0;\n\n#if __VERSION__ < 130\n float j = 0.0;\n for (float i = 0.0; i < 8191.0; ++i) { // BitmapData の幅または高さの最大サイズは 8191 ピクセル\n if (j++ >= scan_loop) {\n break;\n }\n#else\n for (float i = 0.0; i < scan_loop; ++i) {\n#endif\n vec4 src_color = ${e.texture2D()}(u_src_tex, v_src_tex_coord + src_tex_step * i);\n ivec4 masked = bitwiseAnd(ivec4(src_color * 255.0), mask);\n\n#if ${t}\n if (all(equal(masked, color))) {\n#else\n if (any(notEqual(masked, color))) {\n#endif\n found = 1.0;\n break;\n }\n }\n\n ${e.fragColor()} = vec4(found);\n}\n\n`}static NOISE(t){return`${t.version()}\nprecision mediump float;\n\nuniform vec4 u_mediump[3];\n\n${t.outColor()}\n\n// https://stackoverflow.com/a/28095165\n//\n// Gold Noise ©2015 dcerisano@standard3d.com\n// - based on the Golden Ratio\n// - uniform normalized distribution\n// - fastest static noise generator function (also runs at low precision)\n\nfloat PHI = 1.61803398874989484820459; // Φ = Golden Ratio\n\nvec4 gold_noise(vec2 xy, vec4 seed) {\n return fract(tan(distance(xy*PHI, xy)*seed)*xy.x);\n}\n\nvoid main() {\n vec4 seed = u_mediump[0];\n vec4 amp = u_mediump[1];\n vec4 low = u_mediump[2];\n\n vec4 noise = gold_noise(gl_FragCoord.xy, seed);\n vec4 color = noise * amp + low;\n ${t.fragColor()} = vec4(color.rgb * color.a, color.a);\n}\n\n`}static GET_PIXELS(t,e){switch(t){case"RGBA":t=1;break;case"BGRA":t=2;break;default:t=0}return`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 color = ${e.texture2D()}(u_src_tex, v_src_tex_coord);\n\n#if ${t} == 1 // RGBA\n ${e.fragColor()} = vec4(color.rgb / max(0.0001, color.a), color.a);\n#elif ${t} == 2 // BGRA\n ${e.fragColor()} = vec4(color.bgr / max(0.0001, color.a), color.a);\n#else // ARGB\n ${e.fragColor()} = vec4(color.a, color.rgb / max(0.0001, color.a));\n#endif\n}\n\n`}static SET_PIXELS(t,e){switch(t){case"RGBA":t=1;break;case"BGRA":t=2;break;default:t=0}return`${e.version()}\nprecision mediump float;\n\nuniform sampler2D u_src_tex;\n\n${e.varyingIn()} vec2 v_src_tex_coord;\n${e.outColor()}\n\nvoid main() {\n vec4 color = ${e.texture2D()}(u_src_tex, v_src_tex_coord);\n\n#if ${t} == 1 // RGBA\n ${e.fragColor()} = vec4(color.rgb * color.a, color.a);\n#elif ${t} == 2 // BGRA\n ${e.fragColor()} = vec4(color.bgr * color.a, color.a);\n#else // ARGB\n ${e.fragColor()} = vec4(color.gba * color.r, color.r);\n#endif\n}\n\n`}static SET_PIXEL_QUEUE(t){return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_dst_tex;\n\n${t.varyingIn()} vec2 v_dst_tex_coord;\n${t.varyingIn()} vec4 v_color;\n${t.outColor()}\n\nvoid main() {\n float da = ${t.texture2D()}(u_dst_tex, v_dst_tex_coord).a;\n float a = v_color.a;\n\n ${t.fragColor()} = max( a, 0.0) * v_color\n + max(-a, 0.0) * vec4(v_color.rgb * da, da);\n}\n\n`}}class vt{static TEMPLATE(t,e){const i=e?"uniform vec4 u_mediump[2];":"",s=e?xt.STATEMENT_COLOR_TRANSFORM_ON(0):"";return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_texture;\n${i}\n\n${t.varyingIn()} vec2 v_coord;\n${t.outColor()}\n\nvoid main() {\n vec4 src = ${t.texture2D()}(u_texture, v_coord);\n ${s}\n ${t.fragColor()} = src;\n}\n\n`}}class yt{constructor(t,e,i){this._$context=t,this._$gl=e,this._$keyword=i,this._$collection=new Map}getBitmapShader(){return this._$collection.has("b")||this._$collection.set("b",new qt(this._$gl,this._$context,wt.TEXTURE(this._$keyword),vt.TEMPLATE(this._$keyword,0,0,!1))),this._$collection.get("b")}setBitmapUniform(){}setGetPixelsUniform(t,e,i,s,r){const n=t.highp;n[0]=1,n[1]=0,n[2]=0,n[4]=0,n[5]=1,n[6]=0,n[8]=0,n[9]=0,n[10]=1,n[12]=e,n[13]=0,n[14]=0,n[16]=0,n[17]=i,n[18]=0,n[3]=s,n[7]=r,n[11]=1}setSetPixelsUniform(t,e,i,s,r,n,a,o,h){const l=t.highp;l[0]=e,l[1]=0,l[2]=0,l[4]=0,l[5]=i,l[6]=0,l[8]=s,l[9]=r,l[10]=1,l[12]=n,l[13]=0,l[14]=0,l[16]=0,l[17]=a,l[18]=0,l[3]=o,l[7]=h,l[11]=1}setColorTransformUniform(t,e){const i=t.mediump;i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4]/255,i[5]=e[5]/255,i[6]=e[6]/255,i[7]=e[7]/255}setManipulatePixelsUniform(t,e,i,s,r,n){const a=t.highp;a[0]=e[0],a[1]=e[1],a[2]=e[2],a[4]=e[3],a[5]=e[4],a[6]=e[5],a[8]=e[6],a[9]=e[7],a[10]=e[8],r?(a[12]=s[0],a[13]=s[1],a[14]=s[2],a[16]=s[3],a[17]=s[4],a[18]=s[5],a[20]=s[6],a[21]=s[7],a[22]=s[8],a[24]=n[0],a[25]=n[1],a[26]=n[2],a[3]=n[3],a[7]=n[4],a[11]=n[5],a[15]=n[6],a[19]=n[7],a[23]=n[8]):i&&(a[12]=s[0],a[13]=s[1],a[14]=s[2],a[16]=s[3],a[17]=s[4],a[18]=s[5],a[3]=s[6],a[7]=s[7],a[11]=s[8])}setCopyChannelUniform(t,e,i){const s=t.textures;s[0]=0,s[1]=1;const r=t.mediump;r[0]=1&e,r[1]=e>>1&1,r[2]=e>>2&1,r[3]=e>>3&1,r[4]=1&i,r[5]=i>>1&1,r[6]=i>>2&1,r[7]=i>>3&1}setCopyPixelsUniform(t,e){if(e){const e=t.textures;e[0]=0,e[1]=1}}setFillRectUniform(t,e,i,s,r){const n=t.mediump;n[0]=e,n[1]=i,n[2]=s,n[3]=r}setGetColorBoundsRectUniform(t,e,i,s,r,n){const a=t.highp;a[0]=1,a[1]=0,a[2]=0,a[4]=0,a[5]=1,a[6]=0,a[8]=0,a[9]=0,a[10]=1,a[12]=e[0],a[13]=e[1],a[14]=e[2],a[16]=e[3],a[17]=e[4],a[18]=e[5],a[3]=e[6],a[7]=e[7],a[11]=e[8];const o=t.mediump;o[0]=i[0],o[1]=i[1],o[2]=s;const h=t.integer;h[0]=r[0],h[1]=r[1],h[2]=r[2],h[3]=r[3],h[4]=n[0],h[5]=n[1],h[6]=n[2],h[7]=n[3]}setMergeUniform(t,e,i,s,r){const n=t.textures;n[0]=0,n[1]=1;const a=t.mediump;a[0]=e,a[1]=i,a[2]=s,a[3]=r}setNoiseUniform(t,e,i,s,r,n,a,o,h,l,$,_,c){const u=t.mediump;u[0]=e,u[1]=i,u[2]=s,u[3]=r,u[4]=n,u[5]=a,u[6]=o,u[7]=h,u[8]=l,u[9]=$,u[10]=_,u[11]=c}setPaletteMapUniform(t){const e=t.textures;e[0]=0,e[1]=2}setPixelDissolveUniform(t,e,i,s,r){const n=t.mediump;n[0]=e,n[1]=i,n[2]=s,n[3]=r}setFlushSetPixelQueueUniform(t){const e=t.highp;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=-1,e[5]=0,e[6]=0,e[7]=1,e[8]=1}setThresholdUniform(t,e,i,s,r,n,a,o,h,l,$,_,c){const u=t.mediump;u[0]=e,u[1]=i,u[2]=s,u[3]=r,u[4]=n,u[5]=a,u[6]=o,u[7]=h;const d=t.integer;d[0]=l,d[1]=$,d[2]=_,d[3]=c}}class Et{constructor(t,e,i){this._$context=t,this._$gl=e,this._$keyword=i,this._$collection=new Map}getNormalBlendShader(t){const e="n"+(t?"y":"n");return this._$collection.has(e)||this._$collection.set(e,new qt(this._$gl,this._$context,wt.BLEND(this._$keyword),vt.TEMPLATE(this._$keyword,t))),this._$collection.get(e)}getClipShader(){return this._$collection.has("c")||this._$collection.set("c",new qt(this._$gl,this._$context,wt.BLEND_CLIP(this._$keyword),vt.TEMPLATE(this._$keyword,!1))),this._$collection.get("c")}getBlendShader(t,e){const i=`${t}${e?"y":"n"}`;return this._$collection.has(i)||this._$collection.set(i,new qt(this._$gl,this._$context,wt.BLEND(this._$keyword),class{static TEMPLATE(t,e,i){let s;switch(e){case C.SUBTRACT:s=this.FUNCTION_SUBTRACT();break;case C.MULTIPLY:s=this.FUNCTION_MULTIPLY();break;case C.LIGHTEN:s=this.FUNCTION_LIGHTEN();break;case C.DARKEN:s=this.FUNCTION_DARKEN();break;case C.OVERLAY:s=this.FUNCTION_OVERLAY();break;case C.HARDLIGHT:s=this.FUNCTION_HARDLIGHT();break;case C.DIFFERENCE:s=this.FUNCTION_DIFFERENCE();break;case C.INVERT:s=this.FUNCTION_INVERT();break;default:s=this.FUNCTION_NORMAL()}const r=i?"uniform vec4 u_mediump[2];":"",n=i?xt.STATEMENT_COLOR_TRANSFORM_ON(0):"";return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\n${r}\n\n${t.varyingIn()} vec2 v_coord;\n${t.outColor()}\n\n${s}\n\nvoid main() {\n vec4 dst = ${t.texture2D()}(u_textures[0], v_coord);\n vec4 src = ${t.texture2D()}(u_textures[1], v_coord);\n ${n}\n ${t.fragColor()} = blend(src, dst);\n}\n\n`}static FUNCTION_NORMAL(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n return src + dst - dst * src.a;\n}\n\n"}static FUNCTION_SUBTRACT(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(dst.rgb - src.rgb, src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_MULTIPLY(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n vec4 c = src * dst;\n\n return a + b + c;\n}\n\n"}static FUNCTION_LIGHTEN(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(mix(src.rgb, dst.rgb, step(src.rgb, dst.rgb)), src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_DARKEN(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(mix(src.rgb, dst.rgb, step(dst.rgb, src.rgb)), src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_OVERLAY(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 mul = src * dst;\n vec3 c1 = 2.0 * mul.rgb;\n vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0;\n vec4 c = vec4(mix(c1, c2, step(vec3(0.5), dst.rgb)), mul.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_HARDLIGHT(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 mul = src * dst;\n vec3 c1 = 2.0 * mul.rgb;\n vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0;\n vec4 c = vec4(mix(c1, c2, step(vec3(0.5), src.rgb)), mul.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_DIFFERENCE(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(abs(src.rgb - dst.rgb), src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}\n\n"}static FUNCTION_INVERT(){return"\n\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 b = dst - dst * src.a;\n vec4 c = vec4(src.a - dst.rgb * src.a, src.a);\n\n return b + c;\n}\n\n"}}.TEMPLATE(this._$keyword,t,e))),this._$collection.get(i)}setNormalBlendUniform(t,e,i,s,r,n,a,o,h,l,$,_,c,u,d,g,f){const m=t.highp;if(m[0]=e,m[1]=i,m[2]=s,m[3]=r,m[4]=n[0],m[5]=n[1],m[6]=n[2],m[8]=n[3],m[9]=n[4],m[10]=n[5],m[12]=n[6],m[13]=n[7],m[14]=n[8],m[7]=a,m[11]=o,h){const e=t.mediump;e[0]=l,e[1]=$,e[2]=_,e[3]=c,e[4]=u,e[5]=d,e[6]=g,e[7]=f}}setClipUniform(t,e,i,s,r,n,a,o){const h=t.highp;h[0]=e,h[1]=i,h[2]=s,h[3]=r,h[4]=n[0],h[5]=n[1],h[6]=n[2],h[8]=n[3],h[9]=n[4],h[10]=n[5],h[12]=n[6],h[13]=n[7],h[14]=n[8],h[7]=a,h[11]=o}setBlendUniform(t,e,i,s,r,n,a,o,h,l,$,_,c,u,d,g,f){const m=t.textures;m[0]=0,m[1]=1;const p=t.highp;if(p[0]=e,p[1]=i,p[2]=s,p[3]=r,p[4]=n[0],p[5]=n[1],p[6]=n[2],p[8]=n[3],p[9]=n[4],p[10]=n[5],p[12]=n[6],p[13]=n[7],p[14]=n[8],p[7]=a,p[11]=o,h){const e=t.mediump;e[0]=l,e[1]=$,e[2]=_,e[3]=c,e[4]=u,e[5]=d,e[6]=g,e[7]=f}}}class At{constructor(t,e,i){this._$context=t,this._$gl=e,this._$keyword=i,this._$collection=new Map}getBlurFilterShader(t){const e=`b${t}`;return this._$collection.has(e)||this._$collection.set(e,new qt(this._$gl,this._$context,wt.TEXTURE(this._$keyword),class{static TEMPLATE(t,e){const i=e.toFixed(1);return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_texture;\nuniform vec4 u_mediump;\n\n${t.varyingIn()} vec2 v_coord;\n${t.outColor()}\n\nvoid main() {\n vec2 offset = u_mediump.xy;\n float fraction = u_mediump.z;\n float samples = u_mediump.w;\n \n vec4 color = ${t.texture2D()}(u_texture, v_coord);\n\n for (float i = 1.0; i < ${i}; i += 1.0) {\n color += ${t.texture2D()}(u_texture, v_coord + offset * i);\n color += ${t.texture2D()}(u_texture, v_coord - offset * i);\n }\n color += ${t.texture2D()}(u_texture, v_coord + offset * ${i}) * fraction;\n color += ${t.texture2D()}(u_texture, v_coord - offset * ${i}) * fraction;\n color /= samples;\n\n ${t.fragColor()} = color;\n}\n\n`}}.TEMPLATE(this._$keyword,t))),this._$collection.get(e)}getBitmapFilterShader(t,e,i,r,n,a,o){const h=`f${t?"y":"n"}${e?"y":"n"}${i?"y":"n"}${r}${n?"y":"n"}${a?"y":"n"}`;if(!this._$collection.has(h)){let l=1;t&&l++,o&&l++;let $=(t?4:0)+(e?4:0)+(a?1:0);o||($+=i?4:8),$=s.$ceil($/4),this._$collection.set(h,new qt(this._$gl,this._$context,wt.TEXTURE(this._$keyword),class{static TEMPLATE(t,e,i,s,r,n,a,o,h,l){let $=0;const _=s?this.STATEMENT_BASE_TEXTURE_TRANSFORM(t,$++):"",c=r?this.STATEMENT_BLUR_TEXTURE_TRANSFORM(t,$++):this.STATEMENT_BLUR_TEXTURE(t),u=a===H.INNER,d=$;let g,f,m=4*$;switch(l?g=n?this.STATEMENT_GLOW(t,!1,s,h,l,d,m):this.STATEMENT_BEVEL(t,s,r,h,l,d,m):n?(m+=4,g=this.STATEMENT_GLOW(t,u,s,h,l,d,m)):(m+=8,g=this.STATEMENT_BEVEL(t,s,r,h,l,d,m)),a){case H.OUTER:f=o?"blur - blur * base.a":"base + blur - blur * base.a";break;case H.FULL:f=o?"blur":"base - base * blur.a + blur";break;default:f="blur"}return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_textures[${e}];\nuniform vec4 u_mediump[${i}];\n\n${t.varyingIn()} vec2 v_coord;\n${t.outColor()}\n\n${xt.FUNCTION_IS_INSIDE()}\n\nvoid main() {\n ${_}\n ${c}\n ${g}\n ${t.fragColor()} = ${f};\n}\n\n`}static STATEMENT_BASE_TEXTURE_TRANSFORM(t,e){return`\n vec2 base_scale = u_mediump[${e}].xy;\n vec2 base_offset = u_mediump[${e}].zw;\n\n vec2 uv = v_coord * base_scale - base_offset;\n vec4 base = mix(vec4(0.0), ${t.texture2D()}(u_textures[1], uv), isInside(uv));\n`}static STATEMENT_BLUR_TEXTURE(t){return`\n vec4 blur = ${t.texture2D()}(u_textures[0], v_coord);\n`}static STATEMENT_BLUR_TEXTURE_TRANSFORM(t,e){return`\n vec2 blur_scale = u_mediump[${e}].xy;\n vec2 blur_offset = u_mediump[${e}].zw;\n\n vec2 st = v_coord * blur_scale - blur_offset;\n vec4 blur = mix(vec4(0.0), ${t.texture2D()}(u_textures[0], st), isInside(st));\n`}static STATEMENT_GLOW(t,e,i,s,r,n,a){return`\n ${e?"blur.a = 1.0 - blur.a;":""}\n ${s?this.STATEMENT_GLOW_STRENGTH(a):""}\n ${r?this.STATEMENT_GLOW_GRADIENT_COLOR(t,i):this.STATEMENT_GLOW_SOLID_COLOR(n)}\n`}static STATEMENT_GLOW_STRENGTH(t){return`\n float strength = u_mediump[${s.$floor(t/4)}][${t%4}];\n blur.a = clamp(blur.a * strength, 0.0, 1.0);\n`}static STATEMENT_GLOW_SOLID_COLOR(t){return`\n vec4 color = u_mediump[${t}];\n blur = color * blur.a;\n`}static STATEMENT_GLOW_GRADIENT_COLOR(t,e){const i=e?2:1;return`\n blur = ${t.texture2D()}(u_textures[${i}], vec2(blur.a, 0.5));\n`}static STATEMENT_BEVEL(t,e,i,s,r,n,a){return`\n ${i?this.STATEMENT_BLUR_TEXTURE_TRANSFORM_2(t):this.STATEMENT_BLUR_TEXTURE_2(t)}\n float highlight_alpha = blur.a - blur2.a;\n float shadow_alpha = blur2.a - blur.a;\n ${s?this.STATEMENT_BEVEL_STRENGTH(a):""}\n highlight_alpha = clamp(highlight_alpha, 0.0, 1.0);\n shadow_alpha = clamp(shadow_alpha, 0.0, 1.0);\n ${r?this.STATEMENT_BEVEL_GRADIENT_COLOR(t,e):this.STATEMENT_BEVEL_SOLID_COLOR(n)}\n`}static STATEMENT_BLUR_TEXTURE_2(t){return`\n vec4 blur2 = ${t.texture2D()}(u_textures[0], 1.0 - v_coord);\n`}static STATEMENT_BLUR_TEXTURE_TRANSFORM_2(t){return`\n vec2 pq = (1.0 - v_coord) * blur_scale - blur_offset;\n vec4 blur2 = mix(vec4(0.0), ${t.texture2D()}(u_textures[0], pq), isInside(pq));\n`}static STATEMENT_BEVEL_STRENGTH(t){return`\n float strength = u_mediump[${s.$floor(t/4)}][${t%4}];\n highlight_alpha *= strength;\n shadow_alpha *= strength;\n`}static STATEMENT_BEVEL_SOLID_COLOR(t){return`\n vec4 highlight_color = u_mediump[${t}];\n vec4 shadow_color = u_mediump[${t+1}];\n blur = highlight_color * highlight_alpha + shadow_color * shadow_alpha;\n`}static STATEMENT_BEVEL_GRADIENT_COLOR(t,e){const i=e?2:1;return`\n blur = ${t.texture2D()}(u_textures[${i}], vec2(\n 0.5019607843137255 - 0.5019607843137255 * shadow_alpha + 0.4980392156862745 * highlight_alpha,\n 0.5\n ));\n`}}.TEMPLATE(this._$keyword,l,$,t,e,i,r,n,a,o)))}return this._$collection.get(h)}getColorMatrixFilterShader(){return this._$collection.has("m")||this._$collection.set("m",new qt(this._$gl,this._$context,wt.TEXTURE(this._$keyword),class{static TEMPLATE(t){return`${t.version()}\nprecision mediump float;\n\nuniform sampler2D u_texture;\nuniform vec4 u_mediump[5];\n\n${t.varyingIn()} vec2 v_coord;\n${t.outColor()}\n\nvoid main() {\n mat4 mul = mat4(u_mediump[0], u_mediump[1], u_mediump[2], u_mediump[3]);\n vec4 add = u_mediump[4];\n \n vec4 color = ${t.texture2D()}(u_texture, v_coord);\n\n color.rgb /= max(0.0001, color.a);\n color = clamp(color * mul + add, 0.0, 1.0);\n color.rgb *= color.a;\n\n ${t.fragColor()} = color;\n}\n\n`}}.TEMPLATE(this._$keyword))),this._$collection.get("m")}getConvolutionFilterShader(t,e,i,r){const n=`c${("0"+t).slice(-2)}${("0"+e).slice(-2)}${i?"y":"n"}${r?"y":"n"}`;if(!this._$collection.has(n)){const a=(r?1:2)+s.$ceil(t*e/4);this._$collection.set(n,new qt(this._$gl,this._$context,wt.TEXTURE(this._$keyword),class{static TEMPLATE(t,e,i,r,n,a){const o=s.$floor(.5*i),h=s.$floor(.5*r),l=i*r;let $="";const _=a?1:2;for(let t=0;t>16)/255,o[a++]=(e>>8&255)/255,o[a++]=(255&e)/255,o[a++]=s[t]}for(let t=r;t= 30.0) { // ラウンド結合\n float face = u_highp[${n}][1];\n float rad = face * (a_type - 30.0) * 0.3488888889; /* 0.3488888889 = PI / 9.0 */\n offset = mat2(cos(rad), sin(rad), -sin(rad), cos(rad)) * vec2(1.0, 0.0);\n }\n \n offset *= half_width;\n position += offset;\n ${o}\n\n position /= viewport;\n position = position * 2.0 - 1.0;\n gl_Position = vec4(position.x, -position.y, 0.0, 1.0);\n}\n\n`}static VARYING_UV_ON(t){return`\n${t.varyingOut()} vec2 v_uv;\n`}static STATEMENT_UV_ON(){return"\n mat3 uv_matrix = mat3(\n u_highp[0].xyz,\n u_highp[1].xyz,\n u_highp[2].xyz\n );\n mat3 inverse_matrix = mat3(\n u_highp[3].xyz,\n u_highp[4].xyz,\n vec3(u_highp[2].w, u_highp[3].w, u_highp[4].w)\n );\n\n v_uv = (uv_matrix * vec3(a_vertex, 1.0)).xy;\n v_uv += offset;\n v_uv = (inverse_matrix * vec3(v_uv, 1.0)).xy;\n"}}class Ft{constructor(){this._$rgb=F.RGB,this._$mode=U.PAD,this._$focalPointRatio=0,this._$points=s.$getFloat32Array6(),this._$stops=s.$getArray(),this._$type=null}linear(t,e,i,s,r=F.RGB,n=U.PAD){return this._$type=w.LINEAR,this._$points[0]=t,this._$points[1]=e,this._$points[2]=i,this._$points[3]=s,this._$rgb=r,this._$mode=n,this._$stops.length&&(this._$stops.length=0),this}radial(t,e,i,r,n,a,o=F.RGB,h=U.PAD,l=0){return this._$type=w.RADIAL,this._$points[0]=t,this._$points[1]=e,this._$points[2]=i,this._$points[3]=r,this._$points[4]=n,this._$points[5]=a,this._$rgb=o,this._$mode=h,this._$focalPointRatio=s.$clamp(l,-.975,.975,0),this._$stops.length&&(this._$stops.length=0),this}addColorStop(t,e){this._$stops.push([t,e]),this._$stops.sort((function(t,e){switch(!0){case t[0]>e[0]:return 1;case e[0]>t[0]:return-1;default:return 0}}))}}class Lt{constructor(t=null,e=null,i=null){this._$initialization(t,e,i)}_$initialization(t=null,e=null,i=null){return this._$texture=t,this._$repeat=e,this._$color_transform=i,this}get texture(){return this._$texture}get repeat(){return this._$repeat}get colorTransform(){return this._$color_transform}}class Pt{constructor(t,e){this._$gl=t;const i=e?s.$min(s.$currentPlayer().getSamples(),t.getParameter(t.MAX_SAMPLES)):0;this._$isWebGL2Context=e,this._$maxTextureSize=s.$min(8192,t.getParameter(t.MAX_TEXTURE_SIZE))-2,this._$contextStyle=new Gt,this._$style=this._$contextStyle,this._$fillBuffer=null,this._$strokeBuffer=null,this._$cacheCurrentBounds={x:0,y:0,w:0,h:0},this._$cacheCurrentBuffer=null,this._$stack=[],this._$globalAlpha=1,this._$imageSmoothingEnabled=!1,this._$globalCompositeOperation=C.NORMAL,this._$matrix=s.$getFloat32Array9(1,0,0,0,1,0,0,0,1),this._$clearColorR=1,this._$clearColorG=1,this._$clearColorB=1,this._$clearColorA=1,this._$viewportWidth=0,this._$viewportHeight=0,this._$frameBufferManager=new Yt(t,e,i),this._$path=new kt,this._$grid=new Nt,this._$offsetX=0,this._$offsetY=0,this._$blends=[],this._$positions=[],this._$isLayer=!1,this._$shaderList=new Kt(this,t),this._$gradientLUT=new Qt(this,t),this._$vao=new Wt(t,e),this._$pbo=new jt(t,e),this._$mask=new Ut(this,t),this._$blend=new Dt(this,t),this._$canvasPatternToWebGL=new Lt,this._$canvasGradientToWebGL=new Ft}get canvas(){return this._$gl.canvas}get fillStyle(){return this._$style._$fillStyle}set fillStyle(t){this._$style._$fillStyle.constructor===Float32Array&&s.$poolFloat32Array4(this._$style._$fillStyle),this._$style._$fillStyle=t}get strokeStyle(){return this._$style._$strokeStyle}set strokeStyle(t){this._$style._$strokeStyle.constructor===Float32Array&&s.$poolFloat32Array4(this._$style._$strokeStyle),this._$style._$strokeStyle=t}get lineWidth(){return this._$style._$lineWidth}set lineWidth(t){this._$style._$lineWidth=t}get lineCap(){return this._$style._$lineCap}set lineCap(t){switch(t){case S.NONE:case S.SQUARE:this._$style._$lineCap=t;break;default:this._$style._$lineCap=S.ROUND}}get lineJoin(){return this._$style._$lineJoin}set lineJoin(t){switch(t){case L.BEVEL:case L.MITER:this._$style._$lineJoin=t;break;default:this._$style._$lineJoin=L.ROUND}}get miterLimit(){return this._$style._$miterLimit}set miterLimit(t){this._$style._$miterLimit=t}get globalAlpha(){return this._$globalAlpha}set globalAlpha(t){this._$globalAlpha=s.$clamp(t,0,1,1)}get imageSmoothingEnabled(){return this._$imageSmoothingEnabled}set imageSmoothingEnabled(t){this._$imageSmoothingEnabled=s.$toBoolean(t)}get globalCompositeOperation(){return this._$globalCompositeOperation}set globalCompositeOperation(t){this._$globalCompositeOperation=t}get frameBuffer(){return this._$frameBufferManager}get path(){return this._$path}get grid(){return this._$grid}get vao(){return this._$vao}get pbo(){return this._$pbo}get blend(){return this._$blend}_$bind(t){if(!t)return;this._$frameBufferManager.bind(t);const e=t.color,i=t.stencil,s=t.width,r=t.height;this._$viewportWidth===s&&this._$viewportHeight===r||(this._$viewportWidth=s,this._$viewportHeight=r,this._$gl.viewport(0,0,s,r)),(e.dirty||i&&i.dirty)&&(e.dirty=!1,i&&(i.dirty=!1),this._$gl.clearColor(0,0,0,0),this.clearRect(0,0,this._$viewportWidth,this._$viewportHeight),this._$gl.clearColor(this._$clearColorR,this._$clearColorG,this._$clearColorB,this._$clearColorA),this._$mask._$onClear(t.mask)),this._$mask._$onBind(t.mask)}fillRect(t,e,i,r){if(!i||!r)return;this._$viewportWidth=i,this._$viewportHeight=r;let n=!1;if(!this._$fillBuffer){n=!0;const a=this._$path.createRectVertices(t,e,i,r);this._$fillBuffer=this._$vao.createFill(a),s.$poolArray(a.pop()),s.$poolArray(a)}const a=this._$grid.enabled,o=this._$shaderList.shapeShaderVariants,h=o.getSolidColorShapeShader(!1,a),l=h.uniform;o.setSolidColorShapeUniform(l,!1,0,0,0,a,this._$matrix,this._$viewportWidth,this._$viewportHeight,this._$grid,this.fillStyle,this._$globalAlpha),h._$fill(this._$fillBuffer),n&&(this._$vao.release(this._$fillBuffer),s.$poolArray(this._$fillBuffer.indexRanges)),this.beginPath()}setTransform(t,e,i,s,r,n){this._$matrix[0]=t,this._$matrix[1]=e,this._$matrix[3]=i,this._$matrix[4]=s,this._$matrix[6]=r,this._$matrix[7]=n}transform(t,e,i,s,r,n){const a=this._$matrix[0],o=this._$matrix[1],h=this._$matrix[3],l=this._$matrix[4],$=this._$matrix[6],_=this._$matrix[7];this._$matrix[0]=t*a+e*h,this._$matrix[1]=t*o+e*l,this._$matrix[3]=i*a+s*h,this._$matrix[4]=i*o+s*l,this._$matrix[6]=r*a+n*h+$,this._$matrix[7]=r*o+n*l+_}drawImage(t,e,i,s,r,n=null){let a=1,o=1,h=1,l=this._$globalAlpha,$=0,_=0,c=0;n&&(a=n[0],o=n[1],h=n[2],$=n[4]/255,_=n[5]/255,c=n[6]/255),this._$blend.drawImage(t,e,i,s,r,a,o,h,l,$,_,c,0,this._$globalCompositeOperation,this._$viewportWidth,this._$viewportHeight,this._$matrix,this._$imageSmoothingEnabled)}_$setColor(t=0,e=0,i=0,s=0){this._$clearColorR=t,this._$clearColorG=e,this._$clearColorB=i,this._$clearColorA=s,this._$gl.clearColor(t,e,i,s)}clearRect(t,e,i,s){this._$mask._$onClearRect(),this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(t,e,i,s),this._$gl.clear(this._$gl.COLOR_BUFFER_BIT|this._$gl.STENCIL_BUFFER_BIT),this._$gl.disable(this._$gl.SCISSOR_TEST)}_$clearRectStencil(t,e,i,s){this._$mask._$onClearRect(),this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(t,e,i,s),this._$gl.clear(this._$gl.STENCIL_BUFFER_BIT),this._$gl.disable(this._$gl.SCISSOR_TEST)}_$startClip(t,e){return this._$mask._$startClip(t,e)}moveTo(t,e){this._$path.moveTo(t,e)}lineTo(t,e){this._$path.lineTo(t,e)}beginPath(){this._$path.begin(),this._$isGraphics&&(this._$fillBuffer&&(this.vao.release(this._$fillBuffer),this.vao.release(this._$fillBuffer.boundObject),s.$poolArray(this._$fillBuffer.indexRanges),s.$poolArray(this._$fillBuffer.boundObject.indexRanges)),this._$strokeBuffer&&this.vao.release(this._$strokeBuffer)),this._$isGraphics=!1,this._$fillBuffer=null,this._$strokeBuffer=null}quadraticCurveTo(t,e,i,s){this._$path.quadTo(t,e,i,s)}bezierCurveTo(t,e,i,s,r,n){this._$path.cubicTo(t,e,i,s,r,n)}_$getVertices(){return this._$path.vertices}fill(){let t,e,i,r=this._$matrix;switch(!0){case this.fillStyle.constructor===Ft:if(this.fillStyle._$type===w.LINEAR);else r=this._$stack[this._$stack.length-1];break;case this.fillStyle.constructor===Lt:r=this._$stack[this._$stack.length-1]}const n=this._$grid.enabled;switch(!0){case this.fillStyle.constructor===Ft:{const a=this.fillStyle,o=a._$stops,h="linearRGB"===a._$rgb;if(t=this._$gradientLUT.generateForShape(o,h),this._$frameBufferManager._$textureManager.bind0(t,!0),e=this._$shaderList.gradientShapeShaderVariants,a._$type===w.LINEAR)i=e.getGradientShapeShader(!1,n,!1,!1,a._$mode),e.setGradientShapeUniform(i.uniform,!1,0,0,0,n,r,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!1,a._$points,0);else{const t=0!==a._$focalPointRatio;i=e.getGradientShapeShader(!1,n,!0,t,a._$mode),e.setGradientShapeUniform(i.uniform,!1,0,0,0,n,r,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!0,a._$points,a._$focalPointRatio)}}break;case this.fillStyle.constructor===Lt:{const a=this.fillStyle,o=a.colorTransform;t=a.texture,this._$frameBufferManager._$textureManager.bind0(t,this._$imageSmoothingEnabled),e=this._$shaderList.shapeShaderVariants,i=e.getBitmapShapeShader(!1,""!==a.repeat,n),o?e.setBitmapShapeUniform(i.uniform,!1,0,0,0,n,r,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,t.width,t.height,o[0],o[1],o[2],this._$globalAlpha,o[4]/255,o[5]/255,o[6]/255,0):e.setBitmapShapeUniform(i.uniform,!1,0,0,0,n,r,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,t.width,t.height,1,1,1,this._$globalAlpha,0,0,0,0)}break;default:e=this._$shaderList.shapeShaderVariants,i=e.getSolidColorShapeShader(!1,this._$grid.enabled),e.setSolidColorShapeUniform(i.uniform,!1,0,0,0,n,r,this._$viewportWidth,this._$viewportHeight,this._$grid,this.fillStyle,this._$globalAlpha)}const a=this._$shaderList.shapeShaderVariants,o=a.getMaskShapeShader(!1,n);if(a.setMaskShapeUniform(o.uniform,n,r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],this._$viewportWidth,this._$viewportHeight,this._$grid),!this._$fillBuffer){const t=this._$getVertices();if(!t.length)return;const e=s.$getArray();for(let i=0;is.length||e.push(s)}if(!e.length)return;this._$isGraphics=!0,this._$fillBuffer=this._$vao.createFill(e);const i=this._$path.getBoundsVertices();this._$fillBuffer.boundObject=this._$vao.createFill(i),s.$poolArray(i.pop()),s.$poolArray(i)}this._$gl.enable(this._$gl.STENCIL_TEST),this._$gl.stencilMask(255),this._$gl.enable(this._$gl.SAMPLE_ALPHA_TO_COVERAGE),this._$gl.stencilFunc(this._$gl.ALWAYS,0,255),this._$gl.stencilOp(this._$gl.KEEP,this._$gl.INVERT,this._$gl.INVERT),this._$gl.colorMask(!1,!1,!1,!1),o._$fill(this._$fillBuffer),this._$gl.disable(this._$gl.SAMPLE_ALPHA_TO_COVERAGE),this._$gl.stencilFunc(this._$gl.NOTEQUAL,0,255),this._$gl.stencilOp(this._$gl.KEEP,this._$gl.ZERO,this._$gl.ZERO),this._$gl.colorMask(!0,!0,!0,!0),i._$fill(this._$fillBuffer.boundObject),this._$gl.disable(this._$gl.STENCIL_TEST)}_$enterClip(){this._$mask._$enterClip()}_$beginClipDef(){this._$mask._$beginClipDef()}_$endClipDef(){this._$mask._$endClipDef()}_$leaveClip(){this._$mask._$leaveClip()}_$drawContainerClip(){this._$mask._$drawContainerClip()}_$unionStencilMask(t,e,i){this._$mask._$unionStencilMask(t,e,i)}closePath(){this._$path.close()}stroke(){if(!this._$strokeBuffer){const t=this._$getVertices();if(!t.length)return;const e=s.$getArray();for(let i=0;is.length||e.push(s)}if(!e.length)return;this._$isGraphics=!0,this._$strokeBuffer=this._$vao.createStroke(t,this.lineCap,this.lineJoin)}let t=this._$matrix;switch(!0){case this.strokeStyle.constructor===Ft:if(this.strokeStyle._$type===w.LINEAR);else t=this._$stack[this._$stack.length-1];break;case this.strokeStyle.constructor===Lt:t=this._$stack[this._$stack.length-1]}let e=s.$sign(t[0]*t[4]);e>0&&0!==t[1]&&0!==t[3]&&(e=-s.$sign(t[1]*t[3]));let i,r,n=.5*this.lineWidth;this._$grid.enabled?(n*=s.$getSameScaleBase(),i=s.$abs(this._$grid.ancestorMatrixA+this._$grid.ancestorMatrixD),r=s.$abs(this._$grid.ancestorMatrixB+this._$grid.ancestorMatrixE)):(i=s.$abs(t[0]+t[3]),r=s.$abs(t[1]+t[4]));const a=s.$min(i,r),o=s.$max(i,r);let h,l,$;n*=o*(1-.3*s.$cos(.5*s.$PI*(a/o))),n=s.$max(1,n);const _=this._$grid.enabled;switch(!0){case this.strokeStyle.constructor===Ft:{const i=this.strokeStyle,r=i._$stops,a="linearRGB"===i._$rgb;if(h=this._$gradientLUT.generateForShape(r,a),this._$frameBufferManager._$textureManager.bind0(h,!0),l=this._$shaderList.gradientShapeShaderVariants,i._$type===w.LINEAR)$=l.getGradientShapeShader(!0,_,!1,!1,i._$mode),l.setGradientShapeUniform($.uniform,!0,n,e,this.miterLimit,_,t,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!1,i._$points,0);else{const r=0!==i._$focalPointRatio;$=l.getGradientShapeShader(!0,_,!0,r,i._$mode),l.setGradientShapeUniform($.uniform,!0,n,e,this.miterLimit,_,t,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!0,i._$points,i._$focalPointRatio)}}break;case this.strokeStyle.constructor===Lt:{const i=this.strokeStyle,r=i.colorTransform;h=i.texture,this._$frameBufferManager._$textureManager.bind0(h),l=this._$shaderList.shapeShaderVariants,$=l.getBitmapShapeShader(!0,""!==i.repeat,this._$grid.enabled),r?l.setBitmapShapeUniform($.uniform,!0,n,e,this.miterLimit,_,t,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,h.width,h.height,r[0],r[1],r[2],this._$globalAlpha,r[4]/255,r[5]/255,r[6]/255,0):l.setBitmapShapeUniform($.uniform,!0,n,e,this.miterLimit,_,t,s.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,h.width,h.height,1,1,1,this._$globalAlpha,0,0,0,0)}break;default:l=this._$shaderList.shapeShaderVariants,$=l.getSolidColorShapeShader(!0,this._$grid.enabled),l.setSolidColorShapeUniform($.uniform,!0,n,e,this.miterLimit,_,t,this._$viewportWidth,this._$viewportHeight,this._$grid,this.strokeStyle,this._$globalAlpha)}$._$stroke(this._$strokeBuffer)}arc(t,e,i){this._$path.drawCircle(t,e,i)}clip(t=!1){const e=this._$shaderList.shapeShaderVariants,i=e.getMaskShapeShader(!1,!1),r=i.uniform;if(e.setMaskShapeUniform(r,!1,this._$matrix[0],this._$matrix[1],this._$matrix[2],this._$matrix[3],this._$matrix[4],this._$matrix[5],this._$matrix[6],this._$matrix[7],this._$matrix[8],this._$viewportWidth,this._$viewportHeight,null),!this._$fillBuffer){this._$fillBuffer=this._$vao.createFill(this._$getVertices());const t=this._$path.getBoundsVertices();this._$fillBuffer.boundObject=this._$vao.createFill(t),s.$poolArray(t.pop()),s.$poolArray(t)}this._$mask._$onClip(this._$matrix,this._$viewportWidth,this._$viewportHeight)||(i._$fill(this._$fillBuffer),t&&(this._$vao.release(this._$fillBuffer),this._$vao.release(this._$fillBuffer.boundObject),s.$poolArray(this._$fillBuffer.indexRanges),s.$poolArray(this._$fillBuffer.boundObject.indexRanges),this._$fillBuffer=null),this.beginPath())}save(){const t=this._$matrix;this._$stack.push(s.$getFloat32Array9(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])),this._$mask._$onSave()}restore(){this._$stack.length&&(s.$poolFloat32Array9(this._$matrix),this._$matrix=this._$stack.pop()),this._$mask._$onRestore()}createPattern(t,e,i){return this._$canvasPatternToWebGL._$initialization(t,e,i)}createLinearGradient(t,e,i,s,r=F.RGB,n=U.PAD){return this._$canvasGradientToWebGL.linear(t,e,i,s,r,n)}createRadialGradient(t,e,i,s,r,n,a=F.RGB,o=U.PAD,h=0){return this._$canvasGradientToWebGL.radial(t,e,i,s,r,n,a,o,h)}_$applyBlurFilter(t,e,i){const r=this._$frameBufferManager.currentAttachment,n=r.width,a=r.height;this._$frameBufferManager._$textureManager.bind0(t,!0);const o=s.$ceil(.5*i),h=1-(o-.5*i),l=1+i,$=this._$shaderList.filterShaderVariants,_=$.getBlurFilterShader(o);$.setBlurFilterUniform(_.uniform,n,a,e,h,l),_._$drawImage()}_$applyBitmapFilter(t,e,i,s,r,n,a,o,h,l,$,_,c,u,d,g,f,m,p,x,b,T,v,y,E,A){const M=c===H.INNER,C=this._$frameBufferManager.currentAttachment,S=this._$frameBufferManager.getTextureFromCurrentAttachment();let R;const w=null!==g;let O;w&&(R=this._$gradientLUT.generateForFilter(g,f,m)),M?w?this._$frameBufferManager._$textureManager.bind02(t,R,!0):this._$frameBufferManager._$textureManager.bind0(t):(O=this._$frameBufferManager.createTextureAttachment(e,i),this._$bind(O),w?this._$frameBufferManager._$textureManager.bind012(t,S,R,!0):this._$frameBufferManager._$textureManager.bind01(t,S));const I=!(M||c===H.FULL&&u),B=!(e===o&&i===h&&0===l&&0===$),F=!(1===d),L=this._$shaderList.filterShaderVariants,P=L.getBitmapFilterShader(I,B,_,c,u,F,w);L.setBitmapFilterUniform(P.uniform,e,i,s,r,n,a,o,h,l,$,_,d,p,x,b,T,v,y,E,A,I,B,F,w),M?u?this.blend.toSourceIn():this.blend.toSourceAtop():this.blend.toOneZero(),P._$drawImage(),M||this._$frameBufferManager.releaseAttachment(C,!0)}_$applyColorMatrixFilter(t,e){this._$frameBufferManager._$textureManager.bind0(t,!0);const i=this._$shaderList.filterShaderVariants,s=i.getColorMatrixFilterShader();i.setColorMatrixFilterUniform(s.uniform,e),this.blend.reset(),s._$drawImage()}_$applyConvolutionFilter(t,e,i,s,r,n,a,o,h,l,$,_){const c=t.width,u=t.height,d=this._$frameBufferManager.createTextureAttachment(c,u);this._$bind(d),this._$frameBufferManager._$textureManager.bind0(t,!0);const g=this._$shaderList.filterShaderVariants,f=g.getConvolutionFilterShader(e,i,a,o);g.setConvolutionFilterUniform(f.uniform,c,u,s,r,n,o,h,l,$,_),this.blend.reset(),f._$drawImage()}_$applyDisplacementMapFilter(t,e,i,s,r,n,a,o,h,l,$,_,c,u){const d=t.width,g=t.height,f=this._$frameBufferManager.createTextureAttachment(d,g);this._$bind(f),r||(r={x:0,y:0}),this._$frameBufferManager._$textureManager.bind01(t,e);const m=this._$shaderList.filterShaderVariants,p=m.getDisplacementMapFilterShader(n,a,l);m.setDisplacementMapFilterUniform(p.uniform,e.width,e.height,i,s,r.x,r.y,o,h,l,$,_,c,u),this.blend.reset(),p._$drawImage()}getImageData(t,e,i,r){const n=i*r*4,a=s.$getUint8Array(n);this._$gl.readPixels(t,r-(r-e),i,r,this._$gl.RGBA,this._$gl.UNSIGNED_BYTE,a);for(let t=0;tthis._$maxTextureSize?this._$maxTextureSize/i:1}changeSamples(t=4){if(this._$isWebGL2Context){t=s.$min(t,this._$gl.getParameter(this._$gl.MAX_SAMPLES));const e=this._$frameBufferManager;e._$objectPool=[],e._$colorBufferPool._$objectPool=[],e._$stencilBufferPool._$objectPool=[],e._$colorBufferPool._$samples=t}}}class Dt{constructor(t,e){this._$context=t,this._$gl=e,this._$enabled=!1,this._$funcCode=600,this.enable()}enable(){this._$enabled||(this._$enabled=!0,this._$gl.enable(this._$gl.BLEND)),this.reset()}disable(){this._$enabled&&(this._$enabled=!1,this._$gl.disable(this._$gl.BLEND))}reset(){613!==this._$funcCode&&(this._$funcCode=613,this._$gl.blendFunc(this._$gl.ONE,this._$gl.ONE_MINUS_SRC_ALPHA))}toOneZero(){610!==this._$funcCode&&(this._$funcCode=610,this._$gl.blendFunc(this._$gl.ONE,this._$gl.ZERO))}toZeroOne(){601!==this._$funcCode&&(this._$funcCode=601,this._$gl.blendFuncSeparate(this._$gl.ZERO,this._$gl.ONE,this._$gl.ONE,this._$gl.ZERO))}toAdd(){611!==this._$funcCode&&(this._$funcCode=611,this._$gl.blendFunc(this._$gl.ONE,this._$gl.ONE))}toScreen(){641!==this._$funcCode&&(this._$funcCode=641,this._$gl.blendFunc(this._$gl.ONE_MINUS_DST_COLOR,this._$gl.ONE))}toAlpha(){606!==this._$funcCode&&(this._$funcCode=606,this._$gl.blendFunc(this._$gl.ZERO,this._$gl.SRC_ALPHA))}toErase(){603!==this._$funcCode&&(this._$funcCode=603,this._$gl.blendFunc(this._$gl.ZERO,this._$gl.ONE_MINUS_SRC_ALPHA))}toSourceAtop(){673!==this._$funcCode&&(this._$funcCode=673,this._$gl.blendFunc(this._$gl.DST_ALPHA,this._$gl.ONE_MINUS_SRC_ALPHA))}toSourceIn(){670!==this._$funcCode&&(this._$funcCode=670,this._$gl.blendFunc(this._$gl.DST_ALPHA,this._$gl.ZERO))}toOperation(t){switch(t){case C.ADD:this.toAdd();break;case C.SCREEN:this.toScreen();break;case C.ALPHA:this.toAlpha();break;case C.ERASE:this.toErase();break;case"copy":this.toOneZero();break;default:this.reset()}}drawImage(t,e,i,r,n,a,o,h,l,$,_,c,u,d,g,f,m,p){const x=this._$context._$frameBufferManager.currentAttachment,b=1!==a||1!==o||1!==h||1!==l||0!==$||0!==_||0!==c||0!==u,T=this._$context._$shaderList.blendShaderVariants;switch(d){case C.NORMAL:case C.LAYER:case C.ADD:case C.SCREEN:case C.ALPHA:case C.ERASE:case"copy":{this._$context._$frameBufferManager._$textureManager.bind0(t,p);const x=T.getNormalBlendShader(b);T.setNormalBlendUniform(x.uniform,e,i,r,n,m,g,f,b,a,o,h,l,$,_,c,u);const v=m[0],y=m[1],E=m[3],A=m[4],M=m[6],C=m[7];if(1!==v||0!==y||0!==E||1!==A){const t=e+r,a=i+n,o=+(t*v+a*E+M),h=+(t*v+i*E+M),l=+(e*v+a*E+M),$=+(e*v+i*E+M),_=+(t*y+a*A+C),c=+(t*y+i*A+C),u=+(e*y+a*A+C),d=+(e*y+i*A+C),m=s.$MAX_VALUE,p=+s.$min(s.$min(s.$min(s.$min(m,o),h),l),$),x=+s.$max(s.$max(s.$max(s.$max(-m,o),h),l),$),b=+s.$min(s.$min(s.$min(s.$min(m,_),c),u),d),T=+s.$max(s.$max(s.$max(s.$max(-m,_),c),u),d),S=s.$max(0,0|p),R=s.$max(0,0|b),w=s.$min(s.$max(0,g-S),s.$ceil(s.$abs(x-p))),O=s.$min(s.$max(0,f-R),s.$ceil(s.$abs(T-b)));if(!w||!O)return;this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(S,s.$max(0,f-(R+O)),w+1,O+1)}else{const t=s.$max(0,e+M|0),a=s.$max(0,i+C|0),o=s.$min(s.$max(0,g-t),r),h=s.$min(s.$max(0,f-a),n);if(!o||!h)return;this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(t,s.$max(0,f-(a+h)),o+1,h+1)}this.toOperation(d),x._$drawImage(),this._$gl.disable(this._$gl.SCISSOR_TEST)}break;default:{const v=s.$max(0,e+m[6]|0),y=s.$max(0,i+m[7]|0),E=s.$min(s.$max(0,g-v),r),A=s.$min(s.$max(0,f-y),n);if(!E||!A)return;const M=this._$context._$frameBufferManager.getTextureFromCurrentAttachment(),C=this._$context._$frameBufferManager.createTextureAttachment(r,n);this._$context._$bind(C),this._$context._$frameBufferManager._$textureManager.bind0(M);const S=T.getClipShader(),R=S.uniform;T.setClipUniform(R,e,i,r,n,s.$inverseMatrix(m),g,f),this.reset(),S._$drawImage();const w=this._$context._$frameBufferManager.getTextureFromCurrentAttachment();this._$context._$bind(x),this._$context._$frameBufferManager._$textureManager.bind01(w,t,p);const O=T.getBlendShader(d,b);T.setBlendUniform(O.uniform,e,i,r,n,m,g,f,b,a,o,h,l,$,_,c,u),this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(v,s.$max(0,f-(y+A)),E,A),this.toOneZero(),O._$drawImage(),this._$gl.disable(this._$gl.SCISSOR_TEST),this._$context._$frameBufferManager.releaseAttachment(C,!0)}}}}class Nt{constructor(){this.enabled=!1,this.parentMatrixA=1,this.parentMatrixB=0,this.parentMatrixC=0,this.parentMatrixD=0,this.parentMatrixE=1,this.parentMatrixF=0,this.parentMatrixG=0,this.parentMatrixH=0,this.parentMatrixI=1,this.ancestorMatrixA=1,this.ancestorMatrixB=0,this.ancestorMatrixC=0,this.ancestorMatrixD=0,this.ancestorMatrixE=1,this.ancestorMatrixF=0,this.ancestorMatrixG=0,this.ancestorMatrixH=0,this.ancestorMatrixI=1,this.parentViewportX=0,this.parentViewportY=0,this.parentViewportW=0,this.parentViewportH=0,this.minXST=1e-5,this.minYST=1e-5,this.minXPQ=1e-5,this.minYPQ=1e-5,this.maxXST=.99999,this.maxYST=.99999,this.maxXPQ=.99999,this.maxYPQ=.99999}disable(){this.enabled=!1}}class Ut{constructor(t,e){this._$context=t,this._$gl=e,this._$clips=[],this._$clipStatus=!1,this._$containerClip=!1,this._$poolClip=[],this._$currentClip=!1}_$onClear(t){t&&(this._$gl.enable(this._$gl.STENCIL_TEST),this._$currentClip=!0)}_$onBind(t){!t&&this._$currentClip?(this._$gl.disable(this._$gl.STENCIL_TEST),this._$currentClip=!1):t&&!this._$currentClip&&(this._$gl.enable(this._$gl.STENCIL_TEST),this._$currentClip=!0,this._$endClipDef())}_$onClearRect(){this._$gl.disable(this._$gl.STENCIL_TEST),this._$currentClip=!1}_$endClip(){const t=this._$context._$frameBufferManager,e=t.getTextureFromCurrentAttachment(),i=t.currentAttachment;this._$context._$bind(this._$context._$cacheCurrentBuffer),this._$context._$cacheCurrentBuffer=null,this._$context._$blend.disable();const r=this._$context._$cacheCurrentBounds.x,n=this._$context._$cacheCurrentBounds.y,a=this._$context._$cacheCurrentBounds.w,o=this._$context._$cacheCurrentBounds.h;s.$resetContext(this._$context),this._$context.setTransform(1,0,0,1,0,0),this._$context.drawImage(e,r,n,a,o),this._$context._$blend.enable(),t.releaseAttachment(i,!0)}_$startClip(t,e){const i=s.$multiplicationMatrix(e,t._$transform._$rawMatrix()),r=t._$getBounds(null),n=s.$boundsMatrix(r,i);s.$poolFloat32Array9(i),s.$poolBoundsObject(r);let a=n.xMin,o=n.yMin,h=s.$abs(n.xMax-n.xMin),l=s.$abs(n.yMax-n.yMin);s.$poolBoundsObject(n);const $=this._$context._$frameBufferManager,_=$.currentAttachment;if(h+a>_.texture.width&&(h-=h-_.texture.width+a),l+o>_.texture.height&&(l-=l-_.texture.height+o),0>a&&(h+=a,a=0),0>o&&(l+=o,o=0),0>=h||0>=l)return null;h=s.$ceil(h),l=s.$ceil(l),this._$context._$cacheCurrentBounds.x=a,this._$context._$cacheCurrentBounds.y=o,this._$context._$cacheCurrentBounds.w=h,this._$context._$cacheCurrentBounds.h=l;const c=$.getTextureFromCurrentAttachment();this._$context._$cacheCurrentBuffer=_;const u=s.$currentPlayer(),d=!this._$context._$isWebGL2Context||u._$quality!==G.LOW&&u._$quality!==G.MIDDLE?0:s.$min(s.$HIGH_SAMPLES,this._$gl.getParameter(this._$gl.MAX_SAMPLES)),g=$.createCacheAttachment(h,l,!0,d);return this._$context._$bind(g),s.$resetContext(this._$context),this._$context.setTransform(1,0,0,1,0,0),this._$context.drawImage(c,-a,-o,c.width,c.height),s.$getFloat32Array9(e[0],e[1],e[2],e[3],e[4]-a,e[5]-o)}_$enterClip(){this._$currentClip||(this._$gl.enable(this._$gl.STENCIL_TEST),this._$currentClip=!0);const t=this._$context._$frameBufferManager.currentAttachment;t.mask=!0,++t.clipLevel}_$beginClipDef(){const t=this._$context._$frameBufferManager.currentAttachment;this._$gl.enable(this._$gl.SAMPLE_ALPHA_TO_COVERAGE),this._$gl.stencilFunc(this._$gl.ALWAYS,0,255),this._$gl.stencilOp(this._$gl.KEEP,this._$gl.INVERT,this._$gl.INVERT),this._$gl.stencilMask(1<7&&(this._$context._$unionStencilMask(e,o,h),a=e)}a>e+1&&this._$context._$unionStencilMask(e,o,h)}_$unionStencilMask(t,e,i){const r=this._$context._$path.createRectVertices(0,0,e,i),n=this._$context._$vao.createFill(r);s.$poolArray(r.pop()),s.$poolArray(r);const a=this._$context._$shaderList.shapeShaderVariants,o=a.getMaskShapeShader(!1,!1),h=o.uniform;a.setMaskShapeUniformIdentity(h,e,i);const l=n.indexRanges[0];this._$gl.stencilFunc(this._$gl.LEQUAL,1<1;){const r=s.$floor((i+e)/2);t<=this._$objectPool[r].area?i=r:e=r}return i}}const Ht={vertices:null};Ht.subhulls=new Array(512),Ht.subhullsIndex=0,Ht.extremePoints=new Array(32),Ht.extremePointsIndex=0,Ht.t=0,Ht.hulls=[new Array(16),new Array(64),new Array(256)],Ht.hullsIndex=0;class Yt{constructor(t,e,i){this._$gl=t,this._$isWebGL2Context=e,this._$objectPool=[],this._$frameBuffer=t.createFramebuffer(),this._$frameBufferTexture=null,this._$currentAttachment=null,this._$isBinding=!1,this._$textureManager=new Vt(t,e),this._$colorBufferPool=null,this._$stencilBufferPool=new zt(t),e&&(this._$frameBufferTexture=t.createFramebuffer(),this._$colorBufferPool=new Xt(t,i),t.bindFramebuffer(t.READ_FRAMEBUFFER,this._$frameBuffer))}get currentAttachment(){return this._$currentAttachment}createCacheAttachment(t,e,i=!1,s=0){const r=this._$objectPool.length?this._$objectPool.pop():{},n=this._$textureManager.create(t,e);return r.width=t,r.height=e,this._$isWebGL2Context&&i?(r.color=this._$colorBufferPool.create(t,e,s),r.texture=n,r.msaa=!0,r.stencil=r.color.stencil):(r.color=n,r.texture=n,r.msaa=!1,r.stencil=this._$stencilBufferPool.create(n.width,n.height)),r.mask=!1,r.clipLevel=0,r.isActive=!0,r}createTextureAttachment(t,e){const i=this._$objectPool.length?this._$objectPool.pop():{},s=this._$textureManager.create(t,e);return i.width=t,i.height=e,i.color=s,i.texture=s,i.msaa=!1,i.stencil=null,i.mask=!1,i.clipLevel=0,i.isActive=!0,i}createTextureAttachmentFrom(t){const e=this._$objectPool.length?this._$objectPool.pop():{};return e.width=t.width,e.height=t.height,e.color=t,e.texture=t,e.msaa=!1,e.stencil=null,e.mask=!1,e.clipLevel=0,e.isActive=!0,e}releaseAttachment(t,e=!1){t.isActive&&(t.msaa?this._$colorBufferPool.release(t.color):t.stencil&&this._$stencilBufferPool.release(t.stencil),e&&this._$textureManager.release(t.texture),t.color=null,t.texture=null,t.stencil=null,t.isActive=!1,this._$objectPool.push(t))}bind(t){this._$currentAttachment=t,this._$isBinding||(this._$isBinding=!0,this._$gl.bindFramebuffer(this._$gl.FRAMEBUFFER,this._$frameBuffer)),t.msaa?(this._$gl.bindRenderbuffer(this._$gl.RENDERBUFFER,t.color),this._$gl.framebufferRenderbuffer(this._$gl.FRAMEBUFFER,this._$gl.COLOR_ATTACHMENT0,this._$gl.RENDERBUFFER,t.color)):(this._$textureManager.bind0(t.color),this._$gl.framebufferTexture2D(this._$gl.FRAMEBUFFER,this._$gl.COLOR_ATTACHMENT0,this._$gl.TEXTURE_2D,t.color,0)),this._$gl.bindRenderbuffer(this._$gl.RENDERBUFFER,t.stencil),this._$gl.framebufferRenderbuffer(this._$gl.FRAMEBUFFER,this._$gl.STENCIL_ATTACHMENT,this._$gl.RENDERBUFFER,t.stencil)}unbind(){this._$currentAttachment=null,this._$isBinding&&(this._$isBinding=!1,this._$gl.bindFramebuffer(this._$gl.FRAMEBUFFER,null))}getTextureFromCurrentAttachment(){if(!this._$currentAttachment.msaa)return this._$currentAttachment.texture;const t=this._$currentAttachment.width,e=this._$currentAttachment.height,i=this._$currentAttachment.texture;return i.dirty=!1,this._$gl.bindFramebuffer(this._$gl.DRAW_FRAMEBUFFER,this._$frameBufferTexture),this._$textureManager.bind0(i),this._$gl.framebufferTexture2D(this._$gl.FRAMEBUFFER,this._$gl.COLOR_ATTACHMENT0,this._$gl.TEXTURE_2D,i,0),this._$gl.blitFramebuffer(0,0,t,e,0,0,t,e,this._$gl.COLOR_BUFFER_BIT,this._$gl.NEAREST),this._$gl.bindFramebuffer(this._$gl.FRAMEBUFFER,this._$frameBuffer),i}createTextureFromPixels(t,e,i=null,s=!1,r=!0){return this._$textureManager.create(t,e,i,s,r)}createTextureFromCanvas(t){return this._$textureManager.createFromCanvas(t)}createTextureFromImage(t){return this._$textureManager.createFromImage(t)}createAlphaTextureFromPixels(t,e,i){return this._$textureManager.createAlpha(t,e,i)}createTextureFromVideo(t,e=!1,i=null){return this._$textureManager.createFromVideo(t,e,i)}createTextureFromCurrentAttachment(){const t=this._$currentAttachment.width,e=this._$currentAttachment.height,i=this._$textureManager.create(t,e);return this._$textureManager.bind0(i),this._$gl.copyTexSubImage2D(this._$gl.TEXTURE_2D,0,0,0,0,0,t,e),i}releaseTexture(t){this._$textureManager.release(t)}}class jt{constructor(t,e){this._$gl=t,this._$isWebGL2Context=e,this._$objectPool=[],this._$maxWidth=0,this._$maxHeight=0,this._$cacheSize=0}_$getPixelBufferObject(t){if(!this._$objectPool.length){const t=this._$gl.createBuffer();return t.size=0,t}for(let e=0;ethis._$maxWidth*this._$maxHeight*4)this._$gl.deleteBuffer(t);else if(this._$objectPool.push(t),this._$cacheSize+=t.size/4,this._$cacheSize>this._$maxWidth*this._$maxHeight*10){const t=this._$objectPool.shift();this._$cacheSize-=t.size/4,this._$gl.deleteBuffer(t)}}}class zt{constructor(t){this._$gl=t,this._$objectPool=[],this._$objectPoolArea=0,this._$maxWidth=0,this._$maxHeight=0}_$createStencilBuffer(){const t=this._$gl.createRenderbuffer();return t.width=0,t.height=0,t.area=0,t.dirty=!0,t}_$getStencilBuffer(t,e){const i=this._$objectPool.length;for(let s=0;s100){const t=this._$objectPool.shift();return this._$objectPoolArea-=t.area,t}return this._$createStencilBuffer()}create(t,e){const i=this._$getStencilBuffer(t,e);return i.width===t&&i.height===e||(i.width=t,i.height=e,i.area=t*e,i.dirty=!1,this._$gl.bindRenderbuffer(this._$gl.RENDERBUFFER,i),this._$gl.renderbufferStorage(this._$gl.RENDERBUFFER,this._$gl.STENCIL_INDEX8,t,e)),i}release(t){if(t.area>this._$maxWidth*this._$maxHeight*2|0)this._$gl.deleteRenderbuffer(t);else if(t.dirty=!0,this._$objectPool.push(t),this._$objectPoolArea+=t.area,this._$objectPoolArea>this._$maxWidth*this._$maxHeight*10){const t=this._$objectPool.shift();this._$objectPoolArea-=t.area,this._$gl.deleteRenderbuffer(t)}}}class Vt{constructor(t,e){this._$gl=t,this._$isWebGL2Context=e,this._$objectPool=[],this._$objectPoolArea=0,this._$activeTexture=-1,this._$boundTextures=[null,null,null],this._$maxWidth=0,this._$maxHeight=0,this._$gl.pixelStorei(this._$gl.UNPACK_ALIGNMENT,1),this._$gl.pixelStorei(this._$gl.UNPACK_FLIP_Y_WEBGL,!0)}_$createTexture(e,i){const s=this._$gl.createTexture();return s.width=0,s.height=0,s.area=0,s.dirty=!0,s.smoothing=!0,s._$offsetX=0,s._$offsetY=0,this.bind0(s,!1),this._$gl.texParameteri(this._$gl.TEXTURE_2D,this._$gl.TEXTURE_WRAP_S,this._$gl.CLAMP_TO_EDGE),this._$gl.texParameteri(this._$gl.TEXTURE_2D,this._$gl.TEXTURE_WRAP_T,this._$gl.CLAMP_TO_EDGE),this._$isWebGL2Context&&(s.width=e,s.height=i,s.area=e*i,s.dirty=!1,this._$gl.texStorage2D(this._$gl.TEXTURE_2D,1,this._$gl.RGBA8,e,i),t.glstats&&glstats.ontex(s.area)),s}_$getTexture(t,e){for(let i=0;ithis._$maxWidth*this._$maxHeight*2|0)this._$gl.deleteTexture(t);else if(t.dirty=!0,this._$objectPool.push(t),this._$objectPoolArea+=t.area,this._$objectPoolArea>this._$maxWidth*this._$maxHeight*10){const t=this._$objectPool.shift();this._$objectPoolArea-=t.area,this._$gl.deleteTexture(t)}}bind0(t,e=null){this._$bindTexture(2,this._$gl.TEXTURE2,null,null),this._$bindTexture(1,this._$gl.TEXTURE1,null,null),this._$bindTexture(0,this._$gl.TEXTURE0,t,e)}bind01(t,e,i=null){this._$bindTexture(2,this._$gl.TEXTURE2,null,null),this._$bindTexture(1,this._$gl.TEXTURE1,e,i),this._$bindTexture(0,this._$gl.TEXTURE0,t,i)}bind012(t,e,i,s=null){this._$bindTexture(2,this._$gl.TEXTURE2,i,s),this._$bindTexture(1,this._$gl.TEXTURE1,e,null),this._$bindTexture(0,this._$gl.TEXTURE0,t,null)}bind02(t,e,i=null){this._$bindTexture(2,this._$gl.TEXTURE2,e,i),this._$bindTexture(1,this._$gl.TEXTURE1,null,null),this._$bindTexture(0,this._$gl.TEXTURE0,t,null)}_$bindTexture(t,e,i,r){const n=i!==this._$boundTextures[t],a=null!==r&&r!==i.smoothing;if((n||a||e===this._$gl.TEXTURE0)&&e!==this._$activeTexture&&(this._$activeTexture=e,this._$gl.activeTexture(e)),n&&(this._$boundTextures[t]=i,this._$gl.bindTexture(this._$gl.TEXTURE_2D,i)),a){i.smoothing=r;const t=r&&s.$currentPlayer()._$quality!==G.LOW?this._$gl.LINEAR:this._$gl.NEAREST;this._$gl.texParameteri(this._$gl.TEXTURE_2D,this._$gl.TEXTURE_MIN_FILTER,t),this._$gl.texParameteri(this._$gl.TEXTURE_2D,this._$gl.TEXTURE_MAG_FILTER,t)}}}class Wt{constructor(t,e){this._$gl=t,this._$isWebGL2Context=e,this._$fillVertexArrayPool=[],this._$strokeVertexArrayPool=[],this._$boundVertexArray=null,this._$extension=e?null:t.getExtension("OES_vertex_array_object"),this._$fillAttrib_vertex=0,this._$fillAttrib_bezier=1,this._$strokeAttrib_vertex=0,this._$strokeAttrib_option1=1,this._$strokeAttrib_option2=2,this._$strokeAttrib_type=3,this._$vertexBufferData=new s.$window.Float32Array([0,0,0,1,1,0,1,1]),this._$commonVertexArray=this._$getVertexArray(0,1)}_$createVertexArray(){return this._$isWebGL2Context?this._$gl.createVertexArray():this._$extension.createVertexArrayOES()}_$getVertexArray(t,e){const i=this._$createVertexArray();this.bind(i);const s=this._$gl.createBuffer();return this._$gl.bindBuffer(this._$gl.ARRAY_BUFFER,s),this._$vertexBufferData[0]=t,this._$vertexBufferData[2]=t,this._$vertexBufferData[4]=e,this._$vertexBufferData[6]=e,this._$gl.bufferData(this._$gl.ARRAY_BUFFER,this._$vertexBufferData,this._$gl.STATIC_DRAW),this._$gl.enableVertexAttribArray(0),this._$gl.vertexAttribPointer(0,2,this._$gl.FLOAT,!1,0,0),i}_$getFillVertexArray(){if(this._$fillVertexArrayPool.length)return this._$fillVertexArrayPool.pop();const t=this._$createVertexArray();this.bind(t);const e=this._$gl.createBuffer();return t.vertexBuffer=e,t.vertexLength=0,this._$gl.bindBuffer(this._$gl.ARRAY_BUFFER,e),this._$gl.enableVertexAttribArray(0),this._$gl.enableVertexAttribArray(1),this._$gl.vertexAttribPointer(this._$fillAttrib_vertex,2,this._$gl.FLOAT,!1,16,0),this._$gl.vertexAttribPointer(this._$fillAttrib_bezier,2,this._$gl.FLOAT,!1,16,8),t}_$getStrokeVertexArray(){if(this._$strokeVertexArrayPool.length)return this._$strokeVertexArrayPool.pop();const t=this._$createVertexArray();this.bind(t);const e=this._$gl.createBuffer();t.vertexBuffer=e,t.vertexLength=0,this._$gl.bindBuffer(this._$gl.ARRAY_BUFFER,e);const i=this._$gl.createBuffer();return t.indexBuffer=i,t.indexLength=0,this._$gl.bindBuffer(this._$gl.ELEMENT_ARRAY_BUFFER,i),this._$gl.enableVertexAttribArray(0),this._$gl.enableVertexAttribArray(1),this._$gl.enableVertexAttribArray(2),this._$gl.enableVertexAttribArray(3),this._$gl.vertexAttribPointer(this._$strokeAttrib_vertex,2,this._$gl.FLOAT,!1,28,0),this._$gl.vertexAttribPointer(this._$strokeAttrib_option1,2,this._$gl.FLOAT,!1,28,8),this._$gl.vertexAttribPointer(this._$strokeAttrib_option2,2,this._$gl.FLOAT,!1,28,16),this._$gl.vertexAttribPointer(this._$strokeAttrib_type,1,this._$gl.FLOAT,!1,28,24),t}createFill(t){const e=class{static generate(t){let e=0;for(let i=0;ithis._$vertexBufferData.length){const t=new s.$Float32Array(2*this._$vertexBufferData.length);t.set(this._$vertexBufferData),this._$vertexBufferData=t}}static _$expandIndexBufferIfNeeded(t){if(this._$indexBufferPos+t>this._$indexBufferData.length){const t=new s.$Int16Array(2*this._$indexBufferData.length);t.set(this._$indexBufferData),this._$indexBufferData=t}}static _$generateLineSegment(t){const e=t.length-5;for(let i=0;i0&&(t.assign--,t.method(t.array))}}}class ee{constructor(){this._$stage=new k,this._$stage._$player=this,this._$cacheStore=new pt,this._$mode="loader",this._$actionOffset=0,this._$actions=s.$getArray(),this._$loaders=s.$getArray(),this._$sounds=s.$getMap(),this._$hitObject={x:0,y:0,pointer:"",hit:null},this._$rollOverObject=null,this._$mouseOverTarget=null,this._$mouseWheelEvent=null,this._$ratio=s.$devicePixelRatio,this._$stopFlag=!0,this._$startTime=0,this._$fps=60,this._$isLoad=!1,this._$loadStatus=0,this._$width=0,this._$height=0,this._$baseWidth=0,this._$baseHeight=0,this._$scale=1,this._$matrix=new s.$window.Float32Array([1,0,0,1,0,0]),this._$tx=0,this._$ty=0,this._$backgroundColor=null,this._$state="up",this._$hitTestStart=!1,this._$stageX=-1,this._$stageY=-1,this._$broadcastEvents=s.$getMap(),this._$context=null,this._$canvas=null,this._$buffer=null,this._$optionWidth=0,this._$optionHeight=0,this._$tagId=null,this._$bgColor=null,this._$base="",this._$fullScreen=!1,this._$quality=G.HIGH,this._$sources=s.$getArray(),this._$videos=s.$getArray(),this._$textField=null,this._$bindRun=this._$run.bind(this),this._$timerId=-1,this._$loadId=-1}static get LOAD_START(){return 1}static get LOAD_END(){return 2}get broadcastEvents(){return this._$broadcastEvents}get base(){return this._$base}set base(t){if("string"==typeof t)if(-1===t.indexOf("//")){const e=t.split("/");""!==e[0]&&"."!==e[0]||e.shift(),e.pop(),this._$base=`${s.$location.origin}/`,e.length&&(this._$base+=`${e.join("/")}/`)}else if(-1===t.indexOf("?"))this._$base="/"===t.slice(-1)?t:`${t}/`;else{const e=t.split("?")[0];this._$base="/"===e.slice(-1)?e:`${e}/`}}get stage(){return this._$stage}get x(){return this._$tx}get y(){return this._$ty}get scaleX(){return this._$matrix[0]}get scaleY(){return this._$matrix[3]}get contentElementId(){return`${s.$PREFIX}`}get width(){return this._$baseWidth}set width(t){this._$baseWidth=0|t}get height(){return this._$baseHeight}set height(t){this._$baseHeight=0|t}play(){if(this._$stopFlag){if(this._$stopFlag=!1,this._$timerId>-1){(0,s.$cancelAnimationFrame)(this._$timerId)}this._$startTime=s.$performance.now(),this._$fps=1e3/this._$stage._$frameRate;const t=s.$requestAnimationFrame;this._$timerId=t(this._$bindRun)}}stop(){(0,s.$cancelAnimationFrame)(this._$timerId),this._$stopFlag=!0,this._$timerId=-1,ct.stopAll(),s.$cacheStore().reset()}setOptions(t=null){t&&(this._$optionWidth=t.width||this._$optionWidth,this._$optionHeight=t.height||this._$optionHeight,this._$tagId=t.tagId||this._$tagId,this.base=t.base||this._$base,this._$fullScreen=!!t.fullScreen,"bgColor"in t&&(this._$bgColor=t.bgColor)),this._$initialize()}_$updateLoadStatus(){if(this._$loadStatus===ee.LOAD_END)return void this._$loaded();const t=s.$requestAnimationFrame;this._$loadId=t(this._$updateLoadStatus.bind(this))}_$loaded(){const t=s.$document.getElementById(this.contentElementId);if(t){null!==this._$bgColor&&(this._$backgroundColor=this._$bgColor),this._$context&&(this._$backgroundColor&&"transparent"!==this._$backgroundColor?this._$context._$setColor(this._$backgroundColor[0],this._$backgroundColor[1],this._$backgroundColor[2],this._$backgroundColor[3]):this._$context._$setColor(0,0,0,0)),this._$deleteNode(),t.appendChild(this._$canvas),this.play(),this._$stage._$prepareActions(),this._$broadcastEvents.has(a.FRAME_CONSTRUCTED)&&this._$dispatchEvent(new a(a.FRAME_CONSTRUCTED)),this._$doAction(),this._$broadcastEvents.has(a.EXIT_FRAME)&&this._$dispatchEvent(new a(a.EXIT_FRAME));const e=0|this._$loaders.length;for(let t=0;t`);else{const i=t.getElementById(this._$tagId);if(!i)return void alert("Not Found Tag ID:"+this._$tagId);if(t.getElementById(e))this._$deleteNode();else{const s=t.createElement("div");s.id=e,s.tabIndex=-1,i.appendChild(s)}}this._$canvas||this._$initializeCanvas();const i=t.getElementById(e),r=i.parentNode;if(r){this._$initStyle(i),this._$buildWait();const t=this._$optionWidth?this._$optionWidth:"BODY"===r.tagName?s.$window.innerWidth:r.offsetWidth,e=this._$optionHeight?this._$optionHeight:"BODY"===r.tagName?s.$window.innerHeight:r.offsetHeight;"loader"===this._$mode&&t&&e&&(this._$baseWidth=t,this._$baseHeight=e,this._$resize())}"loader"===this._$mode?(this._$loadStatus=ee.LOAD_START,this._$updateLoadStatus()):(this._$resize(),this._$loaded())}_$initStyle(e){const i=e.style;i.position="relative",i.top="0",i.left="0",i.backgroundColor="transparent",i.overflow="hidden",i.padding="0",i.margin="0",i.userSelect="none",i.outline="none";const s=this._$optionWidth,r=this._$optionHeight,n=e.parentNode;if("BODY"===n.tagName)return i.width=s?`${s}px`:`${t.innerWidth}px`,void(i.height=r?`${r}px`:`${t.innerHeight}px`);i.width=s?`${s}px`:`${n.offsetWidth}px`,i.height=r?`${r}px`:`${n.offsetHeight}px`}_$buildWait(){const t=s.$document.getElementById(this.contentElementId);if(t){const e=`${this.contentElementId}_loading`;t.innerHTML=``;const i=s.$document.createElement("div");i.id=e,t.appendChild(i)}}_$deleteNode(){const t=s.$document.getElementById(this.contentElementId);if(t)for(;t.childNodes.length;)t.removeChild(t.childNodes[0])}_$initializeCanvas(){const e=s.$document.createElement("canvas");e.width=1,e.height=1,this._$canvas=e;const i={stencil:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,preserveDrawingBuffer:!0};let r=!0,n=e.getContext("webgl2",i);if(n||(n=e.getContext("webgl",i)||e.getContext("experimental-webgl",i),r=!1),n?this._$context=new Pt(n,r):alert("WebGL setting is off. Please turn the setting on."),t.glstats&&glstats.init(n,r,s.$isChrome,s.$isFireFox),s.$isTouch){const t=function(e){e.target.removeEventListener(s.$TOUCH_END,t),s.$loadAudioData()};e.addEventListener(s.$TOUCH_END,t),e.addEventListener(s.$TOUCH_START,function(t){s.$event=t,s.$eventType=s.$TOUCH_START,this._$hitTest()}.bind(this)),e.addEventListener(s.$TOUCH_MOVE,function(t){s.$event=t,s.$eventType=s.$TOUCH_MOVE,this._$hitTest()}.bind(this)),e.addEventListener(s.$TOUCH_END,function(t){s.$event=t,s.$eventType=s.$TOUCH_END,this._$hitTest()}.bind(this))}else{const t=function(e){e.target.removeEventListener(s.$MOUSE_DOWN,t),s.$loadAudioData()};e.addEventListener(s.$MOUSE_DOWN,t),e.addEventListener(s.$MOUSE_DOWN,function(t){s.$event=t,s.$eventType=s.$MOUSE_DOWN,t.button||this._$hitTest()}.bind(this)),e.addEventListener(s.$DOUBLE_CLICK,function(t){s.$event=t,s.$eventType=s.$DOUBLE_CLICK,t.button||this._$hitTest()}.bind(this)),e.addEventListener(s.$MOUSE_LEAVE,function(t){s.$event=t,s.$eventType=s.$MOUSE_LEAVE,this._$hitTest(),s.$event=null,this._$stageX=-1,this._$stageY=-1}.bind(this)),e.addEventListener(s.$MOUSE_UP,function(t){s.$event=t,s.$eventType=s.$MOUSE_UP,t.button||this._$hitTest()}.bind(this)),e.addEventListener(s.$MOUSE_MOVE,function(t){s.$event=t,s.$eventType=s.$MOUSE_MOVE,this._$hitTest()}.bind(this)),e.addEventListener(s.$MOUSE_WHEEL,function(t){this._$mouseWheelEvent=t}.bind(this))}const a=e.style;a.position="absolute",a.top="0",a.left="0",a.webkitTapHighlightColor="rgba(0,0,0,0)",a.backfaceVisibility="hidden",a.transformOrigin="0 0",1!==s.$devicePixelRatio&&(a.transform=`scale(${1/s.$devicePixelRatio})`)}_$resize(){const t=s.$document.getElementById(this.contentElementId);if(t){const e=t.parentNode,i=this._$optionWidth?this._$optionWidth:"BODY"===e.tagName?s.$window.innerWidth:e.offsetWidth?e.offsetWidth:s.$parseFloat(e.style.width),r=this._$optionHeight?this._$optionHeight:"BODY"===e.tagName?s.$window.innerHeight:e.offsetHeight?e.offsetHeight:s.$parseFloat(e.style.height),n="BODY"===e.tagName?s.$window.innerWidth:e.offsetWidth,a=s.$min(i/this._$baseWidth,r/this._$baseHeight);let o=this._$fullScreen?i:this._$baseWidth*a|0,h=this._$fullScreen?r:this._$baseHeight*a|0;const l=t.style;if(l.width=`${o}px`,l.height=`${h}px`,l.top="0",l.left=this._$fullScreen?"0":n/2-o/2+"px",o*=s.$devicePixelRatio,h*=s.$devicePixelRatio,this._$scale=a,this._$width=o,this._$height=h,this._$canvas.width=o,this._$canvas.height=h,this._$canvas.style.transform=1===this._$ratio&&1===s.$devicePixelRatio?"":`scale(${1/this._$ratio})`,this._$context){this._$context._$gl.viewport(0,0,o,h);const t=this._$context._$frameBufferManager;this._$buffer&&(t.unbind(),t.releaseAttachment(this._$buffer,!0)),this._$buffer=t.createCacheAttachment(o,h,!1),t._$stencilBufferPool._$maxWidth=o,t._$stencilBufferPool._$maxHeight=h,t._$textureManager._$maxWidth=o,t._$textureManager._$maxHeight=h,this._$context._$pbo._$maxWidth=o,this._$context._$pbo._$maxHeight=h}const $=this._$scale*this._$ratio;this._$matrix[0]=$,this._$matrix[3]=$,this._$fullScreen&&(this._$tx=(o-this._$baseWidth*a*s.$devicePixelRatio)/2,this._$ty=(h-this._$baseHeight*a*s.$devicePixelRatio)/2,this._$matrix[4]=this._$tx,this._$matrix[5]=this._$ty),t.children.length>1&&t.children[1].dispatchEvent(new s.$window.Event(`${s.$PREFIX}_blur`)),this._$stage._$doChanged(),this._$cacheStore.reset()}}getSamples(){switch(this._$quality){case G.HIGH:return s.$HIGH_SAMPLES;case G.MEDIUM:return s.$MEDIUM_SAMPLES;default:return s.$LOW_SAMPLES}}_$dispatchEvent(t){if(this._$broadcastEvents.size&&this._$broadcastEvents.has(t.type)){const e=this._$broadcastEvents.get(t.type).slice(0);t._$eventPhase=h.AT_TARGET;const i=e.length;for(let r=0;rthis._$fps&&(this._$startTime=e-i%this._$fps,this._$action(),this._$draw(0),!this._$hitTestStart&&"up"===this._$state&&s.$event&&this._$stageX>-1&&this._$stageY>-1&&this._$pointerCheck()),t.stats&&stats.end(),t.glstats&&glstats.end();const r=s.$requestAnimationFrame;this._$timerId=r(this._$bindRun)}_$pointerCheck(){const t=this._$stageX,e=this._$stageY;this._$hitObject.x=t,this._$hitObject.y=e,this._$hitObject.pointer="",this._$hitObject.hit=null,s.$hitContext.setTransform(1,0,0,1,0,0),s.$hitContext.beginPath(),s.$MATRIX_HIT_ARRAY_IDENTITY[4]=this._$tx/this._$scale/s.$devicePixelRatio,s.$MATRIX_HIT_ARRAY_IDENTITY[5]=this._$ty/this._$scale/s.$devicePixelRatio,this._$stage._$mouseHit(s.$hitContext,s.$MATRIX_HIT_ARRAY_IDENTITY,this._$hitObject,!0);let i=null,r=null,n=!1,a=!1;if(this._$hitObject.hit){if(i=this._$hitObject.hit,this._$mouseOverTarget&&this._$mouseOverTarget!==i){const t=this._$mouseOverTarget;t.willTrigger(c.MOUSE_OUT)&&t.dispatchEvent(new c(c.MOUSE_OUT,!0,!1,t.mouseX,t.mouseY))}if(this._$rollOverObject!==i){let s=null;if(this._$rollOverObject)for(r=this._$rollOverObject,r.willTrigger(c.ROLL_OUT)&&r.dispatchEvent(new c(c.ROLL_OUT,!1,!1,r.mouseX,r.mouseY)),s=r._$parent;s&&s._$root!==s&&s!==i;){if(s._$mouseEnabled&&s._$outCheck(t,e)){let t=!1,e=i;for(;e&&e._$root!==e;){if(e===s){t=!0;break}e=e._$parent}if(!t&&s._$parent===i._$parent&&s._$index>i._$index&&(t=!0),t)break}s.willTrigger(c.ROLL_OUT)&&s.dispatchEvent(new c(c.ROLL_OUT,!1,!1,s.mouseX,s.mouseY)),s=s._$parent}for(r=i;r.willTrigger(c.ROLL_OVER)&&r.dispatchEvent(new c(c.ROLL_OVER,!1,!1,r.mouseX,r.mouseY)),r=r._$parent,r&&r!==s&&r.stage!==r;);}switch(this._$rollOverObject=i,!0){case null===this._$mouseOverTarget:case this._$mouseOverTarget!==i:i.willTrigger(c.MOUSE_OVER)&&i.dispatchEvent(new c(c.MOUSE_OVER,!0,!1,i.mouseX,i.mouseY)),this._$mouseOverTarget=i}if("up"===this._$state&&(this._$clickTarget=null),!s.$isTouch&&"up"===this._$state)for(r=i;r&&r.root!==r;){switch(!0){case r instanceof st:r._$type===rt.INPUT&&(n=!0);break;case r.buttonMode:a=!0}if(n||a)break;r=r._$parent}}else{if(this._$mouseOverTarget&&(i=this._$mouseOverTarget,i.willTrigger(c.MOUSE_OUT)&&i.dispatchEvent(new c(c.MOUSE_OUT,!0,!1,i.mouseX,i.mouseY))),this._$rollOverObject)for(r=this._$rollOverObject;r&&r.root!==r;)r.willTrigger(c.ROLL_OUT)&&r.dispatchEvent(new c(c.ROLL_OUT,!1,!1,r.mouseX,r.mouseY)),r=r._$parent;this._$rollOverObject=null,this._$mouseOverTarget=null}switch(!0){case n:this._$canvas.style.cursor="text";break;case a:this._$canvas.style.cursor="pointer";break;case!s.$isTouch&&"up"===this._$state:this._$canvas.style.cursor="auto"}this._$actions.length>1&&this._$doAction()}_$action(){if(this._$stopFlag)return;let t=null;const e=this._$loaders.length;if(e){t=this._$loaders.slice(0),this._$loaders.length=0;for(let i=0;i0&&i>0){if(r._$bind(this._$buffer),s.$resetContext(r),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e,i),r.beginPath(),this._$stage._$draw(r,this._$matrix,s.$COLOR_ARRAY_IDENTITY),this._$stage._$updated=!1,this._$sounds.size){const t=this._$sounds.values();for(let e of t)e._$soundPlay();this._$sounds.clear()}const t=r.frameBuffer.getTextureFromCurrentAttachment();r.frameBuffer.unbind(),s.$resetContext(r),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e,i),r.drawImage(t,0,0,e,i),r._$bind(this._$buffer)}}_$doAction(){for(;this._$actions.length;){s.$actionProcess=!0;const t=this._$actions.pop();t._$canAction=!1,t._$actionOffset=0,t._$actionLimit=0;const e=t._$currentFrame;if(!t._$actions.has(e))continue;t._$actionProcess=!0;const i=t._$actions.get(e),r=i.length;for(let e=0;ee._$index&&(i=!0),i)break}t.willTrigger(c.ROLL_OUT)&&t.dispatchEvent(new c(c.ROLL_OUT,!1,!1,t.mouseX,t.mouseY)),t=t._$parent}for(i=e;i.willTrigger(c.ROLL_OVER)&&i.dispatchEvent(new c(c.ROLL_OVER,!1,!1,i.mouseX,i.mouseY)),i=i._$parent,i&&i!==t&&i.stage!==i;);}switch(this._$rollOverObject=e,!0){case null===this._$mouseOverTarget:case this._$mouseOverTarget!==e:e.willTrigger(c.MOUSE_OVER)&&e.dispatchEvent(new c(c.MOUSE_OVER,!0,!1,e.mouseX,e.mouseY)),this._$mouseOverTarget=e}"up"===this._$state&&(this._$clickTarget=null);break;case s.$TOUCH_START:case s.$MOUSE_DOWN:e!==this._$textField&&this._$textField instanceof st&&(this._$textField.focus=!1,this._$textField=null),e instanceof st&&(e.focus=!0,this._$textField=e),e.willTrigger(c.MOUSE_DOWN)&&e.dispatchEvent(new c(c.MOUSE_DOWN,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget=e;break;case s.$TOUCH_END:case s.$MOUSE_UP:e!==this._$textField&&this._$textField instanceof st&&(this._$textField.focus=!1,this._$textField=null),e.willTrigger(c.MOUSE_UP)&&e.dispatchEvent(new c(c.MOUSE_UP,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget===e&&e.willTrigger(c.CLICK)&&e.dispatchEvent(new c(c.CLICK,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget=null;break;case s.$MOUSE_WHEEL:e.willTrigger(c.MOUSE_WHEEL)&&e.dispatchEvent(new c(c.MOUSE_WHEEL)),e instanceof st&&(e.scrollV+=t.deltaY);break;case s.$DOUBLE_CLICK:e.willTrigger(c.DOUBLE_CLICK)&&e.dispatchEvent(new c(c.DOUBLE_CLICK))}if(!$&&!s.$isTouch&&"up"===this._$state)for(i=e;i&&i.root!==i;){if(i instanceof st){if(i._$type===rt.INPUT){l=!0;break}}else if(i._$buttonMode){_=!0;break}i=i._$parent}}switch(!0){case l:this._$canvas.style.cursor="text";break;case _:this._$canvas.style.cursor="pointer";break;case!s.$isTouch&&"up"===this._$state:this._$canvas.style.cursor="auto"}!s.$actionProcess&&this._$actions.length>1&&this._$doAction(),s.$isUpdated&&(this._$stage._$prepareActions(),s.$actionProcess||this._$doAction()),this._$hitTestStart=!1}}s.$window.next2d=new class{constructor(){this._$player=new ee}load(t,e=null){if("develop"===t){const e=s.$location.search.substr(1).split("&")[0];if(!e)return;t=`${s.$location.origin}/${e}`}if(!t)return;"/"===t.charAt(1)&&(t=t.slice(1)),e&&"base"in e||!(t.indexOf("//")>-1)||(this._$player.base=t),this._$player.setOptions(e);const i=new P,r=i.contentLoaderInfo;r.addEventListener(_.IO_ERROR,(function(t){t.target.removeEventListener(_.IO_ERROR,t.listener),alert("Error: "+t.message)})),r.addEventListener(a.COMPLETE,(function(t){const e=t.target;e.removeEventListener(a.COMPLETE,t.listener);const i=s.$currentPlayer(),r=i.stage,n=e._$data.stage;if(i.width=n.width,i.height=n.height,i.stage.frameRate=n.fps,null===i._$bgColor){const t=s.$intToRGBA(0|`0x${n.bgColor.substr(1)}`);i._$context._$setColor(t.R/255,t.G/255,t.B/255,1),i._$backgroundColor=[t.R/255,t.G/255,t.B/255,1]}r.addChild(e.content),i._$resize()})),i.load(new ht(t))}createRootMovieClip(t=240,e=240,i=24,s=null){const r=this._$player;return r._$loadStatus=ee.LOAD_END,r._$mode="create",r._$stage.frameRate=0|i,r.width=0|t,r.height=0|e,r.setOptions(s),r._$stage.addChild(new y)}},s.$packages(s.$window.next2d),console.log("%c Next2D Player %c 1.4.15 %c https://next2d.app","color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")}(window); \ No newline at end of file diff --git a/package.json b/package.json index f62dbf0d..00d0e39b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@next2d/player", - "version": "1.4.14", + "version": "1.4.15", "description": "Next2D Player. Aims to provide a fast 2D player.", "author": "Toshiyuki Ienaga", "license": "MIT",