From 799c016f23a76614b1a76ddb6ce8e2a25471678d Mon Sep 17 00:00:00 2001 From: ienaga Date: Sun, 23 Jan 2022 23:02:21 +0900 Subject: [PATCH] update 1.6.0 --- next2d.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/next2d.js b/next2d.js index ae48d491..3d5301da 100644 --- a/next2d.js +++ b/next2d.js @@ -1,7 +1,7 @@ /*! * licenses: MIT Licenses. - * version: 1.5.3 + * version: 1.6.0 * author: Toshiyuki Ienaga * copyright: (c) 2013-2022 Toshiyuki Ienaga. */ -"next2d"in window||(t=>{"use strict";let e=0,i=0;const s=t.Math,r=t.Number,n={$PREFIX:"__next2d__"};n.$MAX_VALUE=t.Number.MAX_VALUE,n.$MIN_VALUE=t.Number.MIN_VALUE,n.$HIGH_SAMPLES=4,n.$MEDIUM_SAMPLES=2,n.$LOW_SAMPLES=0,n.$LOAD_START="loadstart",n.$PROGRESS="progress",n.$LOADEND="loadend",n.$TOUCH_START="touchstart",n.$TOUCH_MOVE="touchmove",n.$TOUCH_END="touchend",n.$MOUSE_DOWN="mousedown",n.$MOUSE_MOVE="mousemove",n.$MOUSE_UP="mouseup",n.$MOUSE_WHEEL="wheel",n.$DOUBLE_CLICK="dblclick",n.$MOUSE_LEAVE="mouseleave",n.$KEY_DOWN="keydown",n.$KEY_UP="keyup",n.$SCROLL="scroll",n.$P_TAG=t.document.createElement("p"),n.$COLOR_ARRAY_IDENTITY=new Float32Array([1,1,1,1,0,0,0,0]),n.$COLOR_MATRIX_FILTER=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],n.$soundMixerVolume=1,n.$bezierConverterBuffer=new Array(32),n.$window=t,n.$document=t.document,n.$navigator=t.navigator,n.$userAgent=t.navigator.userAgent,n.$location=t.location,n.$RegExp=t.RegExp,n.$isNaN=t.isNaN,n.$Deg2Rad=s.PI/180,n.$Rad2Deg=180/s.PI,n.$Array=t.Array,n.$Map=t.Map,n.$Image=t.Image,n.$URL=t.URL,n.$Blob=t.Blob,n.$parseFloat=t.parseFloat,n.$setTimeout=t.setTimeout,n.$encodeURIComponent=t.encodeURIComponent,n.$Infinity=t.Infinity,n.$WebGLTexture=t.WebGLTexture,n.$clearTimeout=t.clearTimeout,n.$setTimeout=t.setTimeout,n.$audioContext=null,n.$CanvasRenderingContext2D=t.CanvasRenderingContext2D,n.$requestAnimationFrame=t.requestAnimationFrame,n.$cancelAnimationFrame=t.cancelAnimationFrame,n.$performance=t.performance,n.$Float32Array=t.Float32Array,n.$Int16Array=t.Int16Array,n.$variables=new Map,n.$loadedImages=new Map,n.$isUpdated=!1,n.$event=null,n.$dropTarget=null,n.$dragRules={lock:!1,position:{x:0,y:0},bounds:null},n.$rgbToLinearTable=new n.$Float32Array(256),n.$rgbIdentityTable=new n.$Float32Array(256);for(let t=0;t<256;++t)n.$rgbToLinearTable[t]=s.pow(t/255,2.23333333),n.$rgbIdentityTable[t]=t/255;n.$SHORT_INT_MIN=-32768,n.$SHORT_INT_MAX=32767,n.$devicePixelRatio=s.min(2,t.devicePixelRatio),n.$MATRIX_HIT_ARRAY_IDENTITY=new Float32Array([1,0,0,1,0,0]),n.$MATRIX_ARRAY_IDENTITY=new Float32Array([1,0,0,1,0,0]),n.$MATRIX_ARRAY_RATIO_0_0_RATIO_0_0=new Float32Array([n.$devicePixelRatio,0,0,n.$devicePixelRatio,0,0]),n.$bounds=[],n.$arrays=[],n.$audios=[],n.$maps=[],n.$preObjects=[],n.$matrices=[],n.$colors=[],n.$float32Array4=[],n.$float32Array6=[],n.$float32Array8=[],n.$float32Array9=[],n.$isAndroid=n.$userAgent.indexOf("Android")>-1,n.isiOS=n.$userAgent.indexOf("iPhone")>-1||n.$userAgent.indexOf("iPod")>-1,n.$isTouch=n.$isAndroid||n.isiOS,n.$isChrome=n.$userAgent.indexOf("Chrome")>-1,n.$isFireFox=n.$userAgent.indexOf("Firefox")>-1,n.$isSafari=-1===n.$userAgent.indexOf("Chrome")&&n.$userAgent.indexOf("Safari")>-1,n.$isEdge=n.$userAgent.indexOf("Edge")>-1,n.$isMac=n.$userAgent.indexOf("Mac")>-1,n.$isWindows=!1===n.$isMac,n.$currentLoaderInfo=null;const a=t.document.createElement("canvas");a.width=1,a.height=1,n.$hitContext=a.getContext("2d"),n.$hitContext.globalAlpha=0,n.$hitContext.imageSmoothingEnabled=!1;const o=t.document.createElement("canvas");o.width=1,o.height=1,n.$textContext=o.getContext("2d"),n.$hitContext.globalAlpha=0,n.$hitContext.imageSmoothingEnabled=!1,n.$DIV=null,n.$isArray=t=>n.$Array.isArray(t),n.$getArray=(...t)=>{const e=n.$arrays.pop()||[];return t.length&&e.push.apply(e,t),e},n.$poolArray=t=>{t.length&&(t.length=0),n.$arrays.push(t)},n.$clamp=(t,e,i,r=null)=>{const a=+t;return n.$isNaN(a)&&null!==r?r:s.min(s.max(e,n.$isNaN(a)?0:a),i)},n.$multiplicationColor=(t,e)=>n.$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]),n.$multiplicationMatrix=(t,e)=>n.$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]),n.$getBoundsObject=(t=0,e=0,i=0,s=0)=>{const r=n.$bounds.pop()||{xMin:0,xMax:0,yMin:0,yMax:0};return r.xMin=t,r.xMax=e,r.yMin=i,r.yMax=s,r},n.$poolBoundsObject=t=>{n.$bounds.push(t)},n.$poolMap=t=>{t.size&&t.clear(),n.$maps.push(t)},n.$getMap=()=>n.$maps.pop()||new n.$Map,n.$getFloat32Array4=(t=0,e=0,i=0,s=0)=>{const r=n.$float32Array4.pop()||new n.$window.Float32Array(4);return r[0]=t,r[1]=e,r[2]=i,r[3]=s,r},n.$poolFloat32Array4=t=>{n.$float32Array4.push(t)},n.$getFloat32Array6=(t=0,e=0,i=0,s=0,r=0,a=0)=>{const o=n.$float32Array6.pop()||new n.$window.Float32Array(6);return o[0]=t,o[1]=e,o[2]=i,o[3]=s,o[4]=r,o[5]=a,o},n.$poolFloat32Array6=t=>{n.$float32Array6.push(t)},n.$getFloat32Array8=(t=1,e=1,i=1,s=1,r=0,a=0,o=0,h=0)=>{const l=n.$float32Array8.pop()||new n.$window.Float32Array(8);return l[0]=t,l[1]=e,l[2]=i,l[3]=s,l[4]=r,l[5]=a,l[6]=o,l[7]=h,l},n.$poolFloat32Array8=t=>{n.$float32Array8.push(t)},n.$getFloat32Array9=(t=0,e=0,i=0,s=0,r=0,a=0,o=0,h=0,l=0)=>{const _=n.$float32Array9.pop()||new n.$window.Float32Array(9);return _[0]=t,_[1]=e,_[2]=i,_[3]=s,_[4]=r,_[5]=a,_[6]=o,_[7]=h,_[8]=l,_},n.$poolFloat32Array9=t=>{n.$float32Array9.push(t)},n.$currentPlayer=()=>t.next2d._$player,n.$currentMousePoint=()=>{const t=n.$currentPlayer();let e=n.$window.pageXOffset,i=n.$window.pageYOffset;const s=n.$document.getElementById(t.contentElementId);if(s){const t=s.getBoundingClientRect();e+=t.left,i+=t.top}let r=n.$event.pageX,a=n.$event.pageY;if(n.$isTouch){const t=n.$event.changedTouches[0];r=t.pageX,a=t.pageY}const o=(r-e)/t._$scale|0,h=(a-i)/t._$scale|0;return new x(o,h)},n.$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],a=t.xMin*e[0]+t.yMax*e[2]+e[4],o=t.xMin*e[0]+t.yMin*e[2]+e[4],h=t.xMax*e[1]+t.yMax*e[3]+e[5],l=t.xMax*e[1]+t.yMin*e[3]+e[5],_=t.xMin*e[1]+t.yMax*e[3]+e[5],$=t.xMin*e[1]+t.yMin*e[3]+e[5],c=s.min(n.$MAX_VALUE,i,r,a,o),u=s.max(-n.$MAX_VALUE,i,r,a,o),d=s.min(n.$MAX_VALUE,h,l,_,$),g=s.max(-n.$MAX_VALUE,h,l,_,$);return n.$getBoundsObject(c,u,d,g)},n.$upperPowerOfTwo=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t),n.$getMatrix=(t=1,e=0,i=0,s=1,r=0,a=0)=>{if(!n.$matrices.length)return new p(t,e,i,s,r,a);const o=n.$matrices.pop();return o._$matrix=n.$getFloat32Array6(t,e,i,s,r,a),o},n.$poolMatrix=t=>{n.$poolFloat32Array6(t._$matrix),t._$matrix=null,n.$matrices.push(t)},n.$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}},n.$getColorTransform=(t=1,e=1,i=1,s=1,r=0,a=0,o=0,h=0)=>{if(!n.$colors.length)return new m(t,e,i,s,r,a,o,h);const l=n.$colors.pop();return l._$colorTransform=n.$getFloat32Array8(t,e,i,s,r,a,o,h),l},n.$poolColorTransform=t=>{n.$poolFloat32Array8(t._$colorTransform),t._$colorTransform=null,n.$colors.push(t)},n.$toColorInt=t=>n.$isNaN(+t)?n.$colorStringToInt(t):+t,n.$colorStringToInt=t=>{n.$hitContext.fillStyle=t;const e=n.$hitContext.fillStyle.substr(1);return n.$hitContext.fillStyle="rgba(0, 0, 0, 1)",0|`0x${e}`},n.$intToR=(t,e,i)=>(t>>16)*(i?e:1)/255,n.$intToG=(t,e,i)=>(t>>8&255)*(i?e:1)/255,n.$intToB=(t,e,i)=>(255&t)*(i?e:1)/255,n.$uintToRGBA=t=>({A:t>>>24,R:(16711680&t)>>16,G:(65280&t)>>8,B:255&t}),n.$intToRGBA=(t,e=1)=>({R:(16711680&t)>>16,G:(65280&t)>>8,B:255&t,A:255*e}),n.$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}),n.$cacheStore=()=>n.$currentPlayer()._$cacheStore,n.$inverseMatrix=t=>{const e=1/(t[0]*t[4]-t[3]*t[1]),i=t[3]*t[7]-t[4]*t[6],s=t[1]*t[6]-t[0]*t[7];return n.$getFloat32Array9(t[4]*e,-t[1]*e,0,-t[3]*e,t[0]*e,0,i*e,s*e,1)},n.$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&&n.$audioContext.decodeAudioData(t.buffer.subarray(e),n.$decodeAudioSuccess.bind(this))},n.$decodeAudioSuccess=function(t){this._$character?(this._$character.buffer=null,this._$character.audioBuffer=t):(this._$buffer=null,this._$audioBuffer=t)},n.$decodeAudioData=t=>{const e=t._$character?t._$character.buffer:t._$buffer;e&&n.$audioContext.decodeAudioData(e.buffer,n.$decodeAudioSuccess.bind(t),n.$decodeAudioFailed.bind(t))},n.$loadAudioData=()=>{if(n.$audioContext||(n.$audioContext=new n.$window.AudioContext,n.$audioContext.resume()),n.$audioContext){const t=n.$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,n.$resizeTimerId=0,n.$resize=()=>{(0,n.$clearTimeout)(n.$resizeTimerId);const t=n.$setTimeout;n.$resizeTimerId=t(n.$resizeExecute,300)},n.$resizeExecute=()=>{const t=n.$currentPlayer();if(t._$loadStatus===se.LOAD_END){t._$resize();const e=t._$stage;e.willTrigger(h.RESIZE)&&e.dispatchEvent(new h(h.RESIZE))}},n.$window.addEventListener("resize",n.$resize),n.$resetContext=t=>{const e=t._$contextStyle;switch(e._$fillStyle.constructor){case Pt:case Dt:e._$fillStyle=n.$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 Pt:case Dt:e._$strokeStyle=n.$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=R.NORMAL,t._$imageSmoothingEnabled=!1},n.$getPreObject=()=>n.$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},n.$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,n.$preObjects.push(t)},n.$cross=(t,e,i,s)=>t*s-i*e,n.$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],a=-819.2*t[1]-819.2*t[3]+t[5],o=819.2*t[1]-819.2*t[3]+t[5];let h=r-e,l=-819.2*t[1]+819.2*t[3]+t[5]-a;const _=s.sqrt(h*h+l*l);_?(h/=_,l/=_):(h=0,l=0);const $=(i-e)*h+(o-a)*l;return n.$getArray(e+$*h,a+$*l,i,o)},n.$ajax=(t=null)=>{t||(t={method:"GET"}),"method"in t||(t.method="GET");let e=null;switch(t.method.toUpperCase()){case ft.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 ft.PUT:case ft.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),s=e.length;for(let r=0;r{const e=n.$getArray();if(t){const i=t.trim().split("\n"),s=i.length;for(let t=0;t{const e=t.split(".");let i=n.$window;for(let t=0;t{throw new Error("image encoding error")}))}else n.$imageWorkerActive=!1},n.$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:C,BitmapDataChannel:S,BlendMode:R,CapsStyle:w,DisplayObject:v,DisplayObjectContainer:E,FrameLabel:O,GradientType:I,Graphics:B,GraphicsGradientFill:L,InteractiveObject:y,InterpolationMethod:P,JointStyle:D,Loader:N,LoaderInfo:U,MovieClip:M,Shape:k,SpreadMethod:G,Sprite:A,Stage:X},t.events={Event:h,EventDispatcher:l,EventPhase:_,FocusEvent:$,HTTPStatusEvent:c,IOErrorEvent:u,MouseEvent:d,ProgressEvent:g,VideoEvent:f},t.filters={BevelFilter:q,BitmapFilterQuality:z,BitmapFilterType:j,BlurFilter:W,ColorMatrixFilter:K,ConvolutionFilter:Q,DisplacementMapFilter:J,DisplacementMapFilterMode:V,DropShadowFilter:Z,GlowFilter:tt,GradientBevelFilter:et,GradientGlowFilter:it},t.geom={ColorTransform:m,Matrix:p,Point:x,Rectangle:b,Transform:T},t.media={Sound:lt,SoundMixer:_t,SoundTransform:$t,Video:ct},t.net={URLLoaderDataFormat:ut,URLRequest:dt,URLRequestHeader:gt,URLRequestMethod:ft},t.text={TextField:nt,TextFieldAutoSize:rt,TextFieldType:at,TextFormat:ot,TextFormatAlign:st,TextFormatVerticalAlign:ht},t.ui={Easing:mt,Job:pt,Tween:xt}};class h{constructor(t,e=!1,i=!1){this._$type=`${t}`,this._$bubbles=!!e,this._$cancelable=!!i,this._$target=null,this._$currentTarget=null,this._$eventPhase=_.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 b(e,i,r,n):new b(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 b(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 T{constructor(t){if(!(t instanceof v))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 m;return i._$colorTransform=n.$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 m&&this._$transform(null,t._$colorTransform)}get concatenatedColorTransform(){let t=this._$rawColorTransform(),e=this._$displayObject._$parent;for(;e;)t=n.$multiplicationColor(e._$transform._$rawColorTransform(),t),e=e._$parent;return n.$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 n.$getMatrix(e[0],e[1],e[2],e[3],e[4],e[5])}return this._$transform(),this._$matrix._$clone()}set matrix(t){t instanceof p&&this._$transform(t._$matrix,null)}get concatenatedMatrix(){let t=this._$rawMatrix(),e=this._$displayObject._$parent;for(;e;)t=n.$multiplicationMatrix(e._$transform._$rawMatrix(),t),e=e._$parent;return n.$getMatrix(t[0],t[1],t[2],t[3],t[4],t[5])}pixelBounds(){const t=new b(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),n.$poolBoundsObject(e),t}_$rawMatrix(){if(null!==this._$matrix)return this._$matrix._$matrix;const t=this._$displayObject._$getPlaceObject();return t?t.matrix:n.$MATRIX_ARRAY_IDENTITY}_$rawColorTransform(){if(null!==this._$colorTransform)return this._$colorTransform._$colorTransform;const t=this._$displayObject._$getPlaceObject();return t?t.colorTransform:n.$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(),n.$isUpdated=!0),this._$matrix||(this._$matrix=n.$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(),n.$isUpdated=!0),this._$colorTransform||(this._$colorTransform=n.$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(n.$isArray(t))return this._$filters&&n.$poolArray(this._$filters),this._$filters=t.slice(0),this._$displayObject._$doChanged(),void(n.$isUpdated=!0);if(!this._$filters)if(e){if(e.filters)this._$filters=e.filters.slice(0);else if(e.surfaceFilterList){const t=n.$getArray(),i=e.surfaceFilterList.length;for(let s=0;s-1){const e=this.rotation?n.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()):this._$getBounds(null),i=s.abs(e.yMax-e.yMin);switch(n.$poolBoundsObject(e),i){case 0:case n.$Infinity:case-n.$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 v&&(t._$isMask=!0,this._$mask=t),this._$doChanged())}get mouseX(){return n.$event?this.globalToLocal(n.$currentMousePoint()).x:0}get mouseY(){return n.$event?this.globalToLocal(n.$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||n.$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,n.$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||n.$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,n.$poolMatrix(i)}get stage(){if(this._$stage)return this._$stage;const t=this._$parent;return t?t instanceof X?t:t._$stage:null}get transform(){return this._$transform}set transform(t){t instanceof T&&(this._$transform=t)}get visible(){return this._$visible}set visible(t){t=!!t,this._$visible!==t&&(this._$doChanged(),n.$isUpdated=!0),this._$visible=!!t}get width(){const t=n.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()),e=s.abs(t.xMax-t.xMin);switch(n.$poolBoundsObject(t),!0){case 0===e:case e===n.$Infinity:case e===-n.$Infinity:return 0;default:return e}}set width(t){if(t=+t,!n.$isNaN(t)&&t>-1){const e=this.rotation?n.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()):this._$getBounds(null),i=s.abs(e.xMax-e.xMin);switch(n.$poolBoundsObject(e),!0){case 0===i:case i===n.$Infinity:case i===-n.$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,n.$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,n.$poolMatrix(i)}getBounds(t=null){const e=this._$getBounds(null),i=this._$transform.concatenatedMatrix,r=n.$boundsMatrix(e,i._$matrix);n.$poolMatrix(i),n.$poolBoundsObject(e);const a=n.$getBoundsObject(r.xMin,r.xMax,r.yMin,r.yMax);n.$poolBoundsObject(r),t||(t=this);const o=t._$transform.concatenatedMatrix;o.invert();const h=n.$boundsMatrix(a,o._$matrix),l=h.xMin,_=h.yMin,$=h.xMax,c=h.yMax;return n.$poolBoundsObject(a),n.$poolBoundsObject(h),n.$poolMatrix(o),new b(l,_,s.abs($-l),s.abs(c-_))}globalToLocal(t){const e=this._$transform.concatenatedMatrix;e.invert();const i=new x(t.x*e.a+t.y*e.c+e.tx,t.x*e.b+t.y*e.d+e.ty);return n.$poolMatrix(e),i}hitTestObject(t){const e=this._$getBounds(null),i=this._$transform.concatenatedMatrix,r=n.$boundsMatrix(e,i._$matrix);n.$poolMatrix(i),n.$poolBoundsObject(e);const a=t._$getBounds(null),o=t._$transform.concatenatedMatrix,h=n.$boundsMatrix(a,o._$matrix);n.$poolMatrix(o),n.$poolBoundsObject(a);const l=s.max(r.xMin,h.xMin),_=s.max(r.yMin,h.yMin),$=s.min(r.xMax,h.xMax),c=s.min(r.yMax,h.yMax);return n.$poolBoundsObject(r),n.$poolBoundsObject(h),$-l>=0&&c-_>=0}hitTestPoint(t,e,i=!1){if(i){let i=n.$MATRIX_ARRAY_IDENTITY,s=this._$parent;for(;s;)i=n.$multiplicationMatrix(s._$transform._$rawMatrix(),i),s=s._$parent;n.$hitContext.setTransform(1,0,0,1,0,0),n.$hitContext.beginPath();const r=this._$hit(n.$hitContext,i,{x:t,y:e},!0);return n.$poolFloat32Array6(i),r}const s=this._$getBounds(null),r=n.$boundsMatrix(s,this._$transform._$rawMatrix()),a=r.xMin,o=r.yMin,h=r.xMax-r.xMin,l=r.yMax-r.yMin,_=this._$parent?this._$parent.globalToLocal(new x(t,e)):new x(t,e);return n.$poolBoundsObject(r),n.$poolBoundsObject(s),new b(a,o,h,l).containsPoint(_)}localToGlobal(t){const e=this._$transform.concatenatedMatrix,i=new x(t.x*e.a+t.y*e.c+e.tx,t.x*e.b+t.y*e.d+e.ty);return n.$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=n.$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||(n.$poolMap(this._$variables),this._$variables=null))}getGlobalVariable(t){return n.$variables.has(t)?n.$variables.get(t):null}setGlobalVariable(t,e){n.$variables.set(t,e)}hasGlobalVariable(t){return n.$variables.has(t)}deleteGlobalVariable(t){n.$variables.has(t)&&n.$variables.delete(t)}clearGlobalVariable(){return n.$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||n.$currentLoaderInfo),!e)return null;const i=e._$data.symbols.get(this.namespace),s=e._$data.characters[i];return this._$characterId=i,this._$loaderInfo=e,s}_$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,s=i.length;if(!s)return e;let r=new b(e.xMin,e.yMin,e.xMax-e.xMin,e.yMax-e.yMin);n.$poolBoundsObject(e);for(let t=0;t0||l!==R.NORMAL){const e=this._$getBounds(null),_=n.$boundsMatrix(e,a),$=+_.xMax,c=+_.xMin,u=+_.yMax,d=+_.yMin;n.$poolBoundsObject(e),n.$poolBoundsObject(_);const g=s.abs($-c),f=s.abs(u-d);if(0>=g||0>=f)return!1;if(0>c+g||0>d+f)return!1;const m=t.frameBuffer.currentAttachment;if(c>m.width||d>m.height)return!1;o.basePosition.x=r[4],o.basePosition.y=r[5];let p=this._$getLayerBounds(null);const x=n.$boundsMatrix(p,a);let b=s.abs(x.xMax-x.xMin),T=s.abs(x.yMax-x.yMin);n.$poolBoundsObject(x),b===g&&T===f&&(n.$poolBoundsObject(p),p=null);let v=a[4]-s.floor(c),y=a[5]-s.floor(d),E=null;if(p){const t=n.$getFloat32Array6(a[0],a[1],a[2],a[3],0,0);E=n.$boundsMatrix(p,t),n.$poolBoundsObject(p),n.$poolFloat32Array6(t),v+=-s.floor(E.xMin)-v,y+=-s.floor(E.yMin)-y}let A=s.floor(c),M=s.floor(d),C=c,S=d;if(E&&(A-=-s.floor(E.xMin)-(a[4]-A),M-=-s.floor(E.yMin)-(a[5]-M),C-=-E.xMin-(a[4]-C),S-=-E.yMin-(a[5]-S),n.$poolBoundsObject(E)),o.position.dx=A>0?A:0,o.position.dy=M>0?M:0,b+C>m.texture.width&&(b-=b-m.texture.width+C),T+S>m.texture.height&&(T-=T-m.texture.height+S),0>A&&(v+=A,b+=C),0>M&&(y+=M,T+=S),0>=b||0>=T||!b||!T)return n.$poolPreObject(o),!1;t._$startLayer(n.$getBoundsObject(C,0,S,0)),o.canApply=this._$canApply(h);let R=this._$isFilterUpdated(b,T,a,i,h,o.canApply,o.basePosition.x,o.basePosition.y);const w=t._$cacheCurrentBuffer;t._$cacheCurrentBuffer=null;const O=t._$cacheCurrentBounds,I=n.$getBoundsObject(O.x,O.w,O.y,O.h);R&&(this._$buffer=t.frameBuffer.createCacheAttachment(s.ceil(b),s.ceil(T),!1),t._$bind(this._$buffer)),o.isFilter=!0,o.isUpdated=R,o.color=n.$getFloat32Array8(),o.baseMatrix=a,o.baseColor=i,o.currentAttachment=m,o.currentMaskBuffer=w,o.currentMaskBounds=I,o.filters=h,o.blendMode=l,o.layerWidth=b,o.layerHeight=T,o.matrix=n.$getFloat32Array6(a[0],a[1],a[2],a[3],v,y)}return o}_$postDraw(t,e,i,s){const r=[this._$instanceId,"f"];let a=null;if(this._$buffer){a=t.frameBuffer.getTextureFromCurrentAttachment();const e=n.$cacheStore().get(r);e&&(n.$cacheStore().set(r,null),t.frameBuffer.releaseTexture(e))}else a=n.$cacheStore().get(r);s.canApply||(a._$offsetX=0,a._$offsetY=0);let o=a._$offsetX,h=a._$offsetY;if(s.isUpdated&&s.canApply){let i=n.$cacheStore().get(r);i&&(n.$cacheStore().set(r,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=s.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 v))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 v))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 v))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 v&&e instanceof v))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=n.$MATRIX_ARRAY_IDENTITY;if(t){e=t;const i=this._$transform._$rawMatrix();i!==n.$MATRIX_ARRAY_IDENTITY&&(e=n.$multiplicationMatrix(t,i))}const i=this._$graphics&&this._$graphics._$getBounds(),r=this._$needsChildren?this._$getChildren():this._$children,a=r.length;if(!a&&!i){const i=n.$getBoundsObject(e[4],-e[4],e[5],-e[5]);return t&&e!==t&&n.$poolFloat32Array6(e),i}const o=n.$MAX_VALUE;let h=o,l=-o,_=o,$=-o;if(i){const t=n.$boundsMatrix(this._$graphics._$getBounds(),e);h=t.xMin,l=t.xMax,_=t.yMin,$=t.yMax,n.$poolBoundsObject(t)}for(let t=0;tt){if(i._$filters=null,i._$blendMode=null,-1===i._$id){o.push(i),i._$name&&this._$names.set(i._$name,i);continue}const t=e[a];if(i._$id===t){i._$placeId=a,o.push(i),i._$name&&this._$names.set(i._$name,i),r.has(t)&&r.delete(t),s.set(t,!0),a++;continue}r.set(i._$id,i)}else i.willTrigger(h.REMOVED)&&i.dispatchEvent(new h(h.REMOVED,!0)),i.willTrigger(h.REMOVED_FROM_STAGE)&&i.dispatchEvent(new h(h.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 E&&(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 s=this._$transform._$rawMatrix();s!==n.$MATRIX_ARRAY_IDENTITY&&(i=n.$multiplicationMatrix(e,s)),this._$graphics&&this._$graphics._$getBounds()&&this._$graphics._$clip(t,i);const r=this._$getChildren(),a=r.length;for(let e=0;eu||i._$clipDepth>0)&&(t.restore(),c&&(t._$leaveClip(),d.length&&(n.$poolFloat32Array6(_),_=d.pop())),u=f.length?f.pop():null,c=m.pop()),!c)continue;if(i._$clipDepth>0){if(t.save(),u&&f.push(u),m.push(c),u=i._$clipDepth,c=i._$shouldClip(_),c){const e=i._$startClip(t,_);if(!1===e){c=!1;continue}e&&(d.push(_),_=e)}continue}const a=i._$mask;if(a){let e;if(a._$updated=!1,this===a._$parent)e=_;else{e=n.$MATRIX_ARRAY_IDENTITY;let i=a._$parent;for(;i;)e=n.$multiplicationMatrix(i._$transform._$rawMatrix(),e),i=i._$parent;const s=this.stage._$player,r=s._$scale*s._$ratio/20,o=n.$getFloat32Array6(r,0,0,r,0,0);if(e=n.$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(!a._$shouldClip(e))continue;let i=a._$startClip(t,e);if(t.save(),!1===i){t.restore();continue}if(i){if(g.push(_),this!==a._$parent){const e=this._$transform._$rawMatrix();i[0]=s.abs(_[0])*s.sign(e[0]),i[1]=s.abs(_[1])*s.sign(e[1]),i[2]=s.abs(_[2])*s.sign(e[2]),i[3]=s.abs(_[3])*s.sign(e[3]),i[4]=_[4]-t._$cacheCurrentBounds.x,i[5]=_[5]-t._$cacheCurrentBounds.y}_=i}}i._$draw(t,_,$),i._$updated=!1,a&&(t.restore(),t._$leaveClip(),g.length&&(n.$poolFloat32Array6(_),_=g.pop()))}if(u&&(t.restore(),m.pop()&&t._$leaveClip()),n.$poolArray(d),n.$poolArray(g),n.$poolArray(f),n.$poolArray(m),l.isFilter)return this._$postDraw(t,e,r,l);n.$poolFloat32Array6(_),n.$poolPreObject(l)}_$mouseHit(t,e,i,r=!0){let a=e;const o=this._$transform._$rawMatrix();o!==n.$MATRIX_ARRAY_IDENTITY&&(a=n.$multiplicationMatrix(e,o));const h=this._$getChildren(),l=n.$getArray(),_=n.$getArray(),$=n.$getMap();let c=h.length,u=null,d=null;for(let t=0;tu&&(d=null,u=null),null!==d&&$.set(e._$instanceId,d),_.push(e)))}const g=s.min(this._$mouseChildren,r);let f=!1;const m=this._$root===this;c=_.length;for(let e=0;e-1;--e){const n=o[e];if(!n._$isMask&&n._$hit(t,r,i,s))return!0}let h=!1;return this._$graphics&&(h=this._$graphics._$hit(t,r,i)),r!==e&&n.$poolFloat32Array6(r),h}_$createInstance(t){const e=this._$dictionary[t],i=this._$loaderInfo._$data.characters[e.characterId];i.class||(i.class=i.symbol&&n.$getClass(i.symbol)||n.$getClass(i.extends)),n.$currentLoaderInfo=null;const s=new i.class;return s._$build(e,this),s._$id=t,s}_$outCheck(t,e){let i=n.$MATRIX_ARRAY_IDENTITY,s=this._$parent;for(;s;)i=n.$multiplicationMatrix(s._$transform._$rawMatrix(),i),s=s._$parent;return n.$hitContext.setTransform(1,0,0,1,0,0),n.$hitContext.beginPath(),this._$mouseHit(n.$hitContext,i,{x:t,y:e})}}class A extends E{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 n.$dropTarget}get graphics(){return this._$graphics||(this._$graphics=new B,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 A&&(this._$hitArea=t,t._$hitObject=this)}get soundTransform(){return this._$soundTransform||(this._$soundTransform=new $t),this._$soundTransform}set soundTransform(t){t instanceof $t&&(this._$soundTransform=t)}get useHandCursor(){return this._$useHandCursor}set useHandCursor(t){this._$useHandCursor=!!t}startDrag(t=!1,e=null){let i=0,s=0;if(!t){const t=this._$dragMousePoint();i=this.x-t.x,s=this.y-t.y}n.$dropTarget=this,n.$dragRules.lock=t,n.$dragRules.position.x=i,n.$dragRules.position.y=s,n.$dragRules.bounds=e}stopDrag(){n.$dropTarget=null,n.$dragRules.lock=!1,n.$dragRules.position.x=0,n.$dragRules.position.y=0,n.$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(n.$currentMousePoint()):this.globalToLocal(n.$currentMousePoint())}}class M extends A{constructor(){super(),this._$stopFlag=!1,this._$canAction=!0,this._$childRemove=!1,this._$canSound=!0,this._$actionProcess=!1,this._$actions=n.$getMap(),this._$frameCache=n.$getMap(),this._$labels=null,this._$sounds=n.$getMap(),this._$channels=n.$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?n.$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=n.$getMap()),t instanceof O&&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=n.$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,n.$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(h.FRAME_LABEL)&&e.dispatchEvent(new h(h.FRAME_LABEL))}if(this._$actions.size&&this._$actions.has(t)){const t=n.$currentPlayer();if(t){-1===t._$actions.indexOf(this)&&t._$actions.push(this)}}}}_$goToFrame(t){if(n.$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=n.$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 s=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&&(s>-1||!e._$actionOffset))for(;e._$actions.length&&e._$actions.length!==s;){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 s=t._$actions.get(i),r=s.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 s=e._$actions.get(i),r=s.length;for(let t=0;t-1;--e)t[e]._$prepareActions();this._$setAction()}_$draw(t,e,i){super._$draw(t,e,i);const s=n.$currentPlayer();this._$canSound&&this._$sounds.size&&this._$sounds.has(this._$currentFrame)&&!s._$sounds.has(this._$instanceId)&&s._$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=n.$getArray()),this._$fills[2]===this._$fills[this._$fills.length-2]&&this._$fills[3]===this._$fills[this._$fills.length-1]||this._$fills.push(B.LINE_TO,this._$fills[2],this._$fills[3]),this._$recode.push.apply(this._$recode,this._$fills),this._$fillType){case B.FILL_STYLE:this._$recode.push(this._$fillType,this._$fillStyleR,this._$fillStyleG,this._$fillStyleB,this._$fillStyleA,B.END_FILL);break;case B.GRADIENT_FILL:this._$recode.push(this._$fillType),this._$recode.push.apply(this._$recode,this._$fillGradient.toArray());break;case B.BITMAP_FILL:this._$recode.push(this._$fillType),this._$recode.push.apply(this._$recode,this._$fillBitmap.toArray())}return this._$fills&&(n.$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=n.$getArray()),this._$recode.push.apply(this._$recode,this._$lines),n.$poolArray(this._$lines),this._$lines=null,this._$lineType){case B.STROKE_STYLE:this._$recode.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,this._$lineStyleR,this._$lineStyleG,this._$lineStyleB,this._$lineStyleA,B.END_STROKE);break;case B.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 B.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=w.NONE,this._$joints=D.ROUND,this._$miterLimit=0,this._$doLine=!1,this._$restart(),this}lineBitmapStyle(t,e=null,i=!0,s=!1){return this._$doLine&&this.endLine(),this._$lines||(this._$lines=n.$getArray()),this._$maxAlpha=1,this._$doLine=!0,this._$canDraw=!0,this._$lines.push(B.BEGIN_PATH),this._$lineType=B.BITMAP_STROKE,this._$fillBitmap=new F(t,e,i,s),this}lineGradientStyle(t,e,i,r,a=null,o=G.PAD,h=P.RGB,l=0){if(!this._$doLine)return this;this._$lines||(this._$lines=n.$getArray());const _=i.length;for(let t=0;t<_;++t)this._$maxAlpha=s.max(this._$maxAlpha,i[t]);return this._$lines.push(B.BEGIN_PATH),this._$lineType=B.GRADIENT_STROKE,this._$lineGradient=new L(t,e,i,r,a,o,h,l),this}lineStyle(t=1,e=0,i=1,r=w.ROUND,a=D.ROUND,o=3){this._$doLine&&this.endLine(),this._$lines||(this._$lines=n.$getArray()),e=n.$clamp(n.$toColorInt(e),0,16777215,0),i=n.$clamp(+i,0,1,1),this._$maxAlpha=s.max(this._$maxAlpha,i),this._$doLine=!0,this._$canDraw=!0,this._$lines.push(B.BEGIN_PATH,B.MOVE_TO,this._$pointerX,this._$pointerY);const h=n.$intToRGBA(e,i);return this._$lineType=B.STROKE_STYLE,this._$lineStyleR=h.R,this._$lineStyleG=h.G,this._$lineStyleB=h.B,this._$lineStyleA=h.A,this._$lineWidth=t,this._$caps=`${r}`,this._$joints=`${a}`,this._$joints===D.MITER&&(this._$miterLimit=o),this}lineTo(t,e){return t=+t||0,e=+e||0,this._$pointerX===t&&this._$pointerY===e||(this._$setBounds(t,e),this._$margePath(n.$getArray(B.LINE_TO,t,e)),this._$pointerX=t,this._$pointerY=e,this._$restart()),this}moveTo(t,e){return t=+t||0,e=+e||0,this._$pointerX=t,this._$pointerY=e,this._$setBounds(t,e),this._$margePath(n.$getArray(B.MOVE_TO,t,e)),this._$restart(),this}_$clip(t,e){const i=this._$getBounds(),r=n.$boundsMatrix(i,e);let a=s.ceil(s.abs(r.xMax-r.xMin)),o=s.ceil(s.abs(r.yMax-r.yMin));switch(n.$poolBoundsObject(i),n.$poolBoundsObject(r),!0){case 0===a:case 0===o:case a===-n.$Infinity:case o===-n.$Infinity:case a===n.$Infinity:case o===n.$Infinity:return}n.$resetContext(t),t.setTransform(e[0],e[1],e[2],e[3],e[4],e[5]),this._$doDraw(t,n.$COLOR_ARRAY_IDENTITY,!0),t.clip()}_$drawFilter(t,e,i,s,r,a,o){const h=this._$displayObject,l=[h._$instanceId,"f"];let _=n.$cacheStore().get(l);const $=h._$isFilterUpdated(a,o,i,s,r,!0);return _&&!$||(_&&(n.$cacheStore().set(l,null),_.layerWidth=0,_.layerHeight=0,_._$offsetX=0,_._$offsetY=0,_.matrix=null,_.colorTransform=null,t.frameBuffer.releaseTexture(_),_=null),e=h._$getFilterTexture(t,r,e,i,s),n.$cacheStore().set(l,e)),_&&(e=_),n.$poolArray(l),e}_$drawBitmap(t,e,i,r=R.NORMAL,a=null){if(!this._$maxAlpha)return;const o=n.$clamp(i[3]+i[7]/255,0,1),h=this._$displayObject;let l=e;const _=h._$transform._$rawMatrix();_!==n.$MATRIX_ARRAY_IDENTITY&&(l=n.$multiplicationMatrix(e,_));const $=this._$getBounds(),c=n.$boundsMatrix($,l),u=c.xMax,d=c.xMin,g=c.yMax,f=c.yMin;n.$poolBoundsObject(c);let m=s.ceil(s.abs(u-d)),T=s.ceil(s.abs(g-f));switch(!0){case 0===m:case 0===T:case m===-n.$Infinity:case T===-n.$Infinity:case m===n.$Infinity:case T===n.$Infinity:return}const v=s.sqrt(l[0]*l[0]+l[1]*l[1]),y=s.sqrt(l[2]*l[2]+l[3]*l[3]);if(0>d+m||0>f+T){if(!(a&&a.length&&h._$canApply(a)))return;{let t=new b(0,0,m,T);for(let e=0;et.x+t.width||0>t.y+t.height)return}}const E=t.frameBuffer.currentAttachment;if(d>E.width||f>E.height)return;const A=t._$textureScale(m,T);A<1&&(m*=A,T*=A);const M=n.$cacheStore().generateKeys(h._$instanceId,[v,y],i);let C=n.$cacheStore().get(M);if(!C){const r=t.frameBuffer.createCacheAttachment(m,T,!0);switch(t._$bind(r),n.$resetContext(t),i[3]=1,!0){case 1!==_[0]:case 0!==_[1]:case 0!==_[2]:case 1!==_[3]:{const r=s.atan2(e[1],e[0]);let a=0,o=0;if(r){const t=new p;t.translate(-m/2,-T/2),t.rotate(r),t.translate(m/2,T/2);const e=t.transformPoint(new x(0,0)),i=t.transformPoint(new x(m,0)),n=t.transformPoint(new x(0,T)),h=t.transformPoint(new x(m,T));a=s.min(e.x,i.x,n.x,h.x),o=s.min(e.y,i.y,n.y,h.y)}n.$resetContext(t),t.setTransform(e[0],e[1],e[2],e[3],-a,-o),t.beginPath(),this._$runTransformCommand(t,_,i)}break;default:t.setTransform(l[0],l[1],l[2],l[3],l[4]-d,l[5]-f),this._$doDraw(t,i)}C=t.frameBuffer.getTextureFromCurrentAttachment(),n.$cacheStore().set(M,C),t.frameBuffer.releaseAttachment(r,!1),t._$bind(E)}let S=!1,w=0,O=0;if(a&&a.length){h._$canApply(a)&&(S=!0,C=this._$drawFilter(t,C,e,i,a,m,T),w=C._$offsetX,O=C._$offsetY)}n.$resetContext(t),t._$globalAlpha=o,t._$imageSmoothingEnabled=!0,t._$globalCompositeOperation=r,t.setTransform(1,0,0,1,0,0),S?t.drawImage(C,d-w,f-O,C.width,C.height,i):t.drawImage(C,d,f,m,T,i),n.$poolArray(M),n.$poolBoundsObject($)}_$draw(t,e,i,a=R.NORMAL,o=null){if(!this._$maxAlpha)return;const h=n.$clamp(i[3]+i[7]/255,0,1),l=this._$displayObject;let _=null!==l._$scale9Grid,$=null;_&&($=l._$transform._$rawMatrix(),_=_&&s.abs($[1])<.001&&s.abs($[2])<1e-4);const c=this._$getBounds(),u=n.$boundsMatrix(c,e),d=u.xMax,g=u.xMin,f=u.yMax,m=u.yMin;n.$poolBoundsObject(u);let p=s.ceil(s.abs(d-g)),x=s.ceil(s.abs(f-m));switch(!0){case 0===p:case 0===x:case p===-n.$Infinity:case x===-n.$Infinity:case p===n.$Infinity:case x===n.$Infinity:return}let T=+s.sqrt(e[0]*e[0]+e[1]*e[1]);if(!r.isInteger(T)){const t=T.toString(),e=t.indexOf("e");-1!==e&&(T=+t.slice(0,e)),T=+T.toFixed(4)}let v=+s.sqrt(e[2]*e[2]+e[3]*e[3]);if(!r.isInteger(v)){const t=v.toString(),e=t.indexOf("e");-1!==e&&(v=+t.slice(0,e)),v=+v.toFixed(4)}if(0>g+p||0>m+x){if(!(o&&o.length&&l._$canApply(o)))return;{let t=new b(0,0,p,x);for(let e=0;et.x+t.width||0>t.y+t.height)return}}const y=t.frameBuffer.currentAttachment;if(g>y.width||m>y.height)return;const E=n.$cacheStore(),A=E.generateKeys(l._$instanceId,[T,v],i);let M=E.get(A);if(!M){p=s.ceil(s.abs(c.xMax-c.xMin)*T),x=s.ceil(s.abs(c.yMax-c.yMin)*v);const r=t._$textureScale(p,x);r<1&&(p*=r,x*=r);const a=t.frameBuffer.createCacheAttachment(p,x,!0);if(t._$bind(a),n.$resetContext(t),t.setTransform(T,0,0,v,-c.xMin*T,-c.yMin*v),_){const i=n.$currentPlayer(),r=i._$scale*i._$ratio,a=n.$getFloat32Array6(r,0,0,r,0,0),o=n.$multiplicationMatrix(a,$);n.$poolFloat32Array6(a);const h=l._$parent._$transform._$calculateConcatenatedMatrix()._$matrix,_=n.$getFloat32Array6(h[0],h[1],h[2],h[3],h[4]*r-g,h[5]*r-m),u=n.$multiplicationMatrix(_,o),d=u[4]-(e[4]-g),f=u[5]-(e[5]-m);n.$poolFloat32Array6(u);const p=n.$boundsMatrix(c,o),x=+p.xMax,b=+p.xMin,T=+p.yMax,v=+p.yMin,y=s.ceil(s.abs(x-b)),E=s.ceil(s.abs(T-v));n.$poolBoundsObject(p),t.grid.enable(b,v,y,E,c,l._$scale9Grid,o[0],o[1],o[2],o[3],o[4],o[5],_[0],_[1],_[2],_[3],_[4]-d,_[5]-f),n.$poolFloat32Array6(o),n.$poolFloat32Array6(_)}i[3]=1,this._$doDraw(t,i,!1),_&&t.grid.disable(),M=t.frameBuffer.getTextureFromCurrentAttachment(),E.set(A,M),t.frameBuffer.releaseAttachment(a,!1),t._$bind(y)}let C=0,S=0;if(o&&o.length){l._$canApply(o)&&(M=this._$drawFilter(t,M,e,i,o,p,x),C=M._$offsetX,S=M._$offsetY)}n.$resetContext(t),t._$globalAlpha=h,t._$imageSmoothingEnabled=!0,t._$globalCompositeOperation=a;const w=s.atan2(e[1],e[0]),O=s.atan2(-e[2],e[3]);if(w||O){const i=n.$getBoundsObject(c.xMin*T*s.cos(w)-c.yMin*v*s.sin(O),c.xMax*T*s.cos(w)-c.yMax*v*s.sin(O),c.xMin*T*s.sin(w)+c.yMin*v*s.cos(O),c.xMax*T*s.sin(w)+c.yMax*v*s.cos(O));t.setTransform(s.cos(w),s.sin(w),-s.sin(O),s.cos(O),i.xMin+e[4]-C,i.yMin+e[5]-S),n.$poolBoundsObject(i)}else t.setTransform(1,0,0,1,g-C,m-S);t.drawImage(M,0,0,M.width,M.height,i),n.$poolArray(A),$&&n.$poolMatrix($),n.$poolBoundsObject(c)}_$doDraw(t,e,i=!1){n.$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?n.$getBoundsObject(t._$bounds.xMin,t._$bounds.xMax,t._$bounds.yMin,t._$bounds.yMax):n.$getBoundsObject(this._$xMin,this._$xMax,this._$yMin,this._$yMax)}_$restart(){this._$displayObject&&!this._$displayObject._$isUpdated()&&(this._$displayObject._$doChanged(),n.$isUpdated=!0,n.$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 w.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 w.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),n.$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 ut.JSON:{const e=JSON.parse(t.target.responseText);if("zlib"===e.type){if(n.$unzipWorkerActive)return void n.$unzipQueues.push({json:e,scope:this});n.$unzipWorkerActive=!0,n.$unzipWorker||(n.$unzipWorker=new Worker(n.$unzipURL));const t=new Uint8Array(e.buffer);n.$unzipWorker.onmessage=n.$unzipHandler.bind(this),n.$unzipWorker.postMessage(t,[t.buffer])}else this._$build(e)}break;case ut.ARRAY_BUFFER:this._$imageDecode(new Uint8Array(t.target.response))}else e.willTrigger(u.IO_ERROR)&&e.dispatchEvent(new u(u.IO_ERROR,!1,!1,t.target.statusText))}.bind(this)}})}loadImage(t){t.responseDataFormat=ut.ARRAY_BUFFER,this.load(t)}_$imageDecode(t){const e={image:new n.$Image,scope:this};e.image.decoding="async",e.image.src=n.$URL.createObjectURL(new n.$Blob([t],{type:`image/${n.$getImageType(t)}`})),n.$imageWorkerActive?n.$imageQueues.push(e):(n.$imageWorkerActive=!0,e.image.decode().then(n.$decodeImage.bind(e)).catch((()=>{throw new Error("image encoding error")})))}_$build(t){const e=this.contentLoaderInfo;let i=null;const s=n.$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,a=t.frameBuffer.getTextureFromCurrentAttachment();if(!this._$canApply())return i?a:t.frameBuffer.createTextureFromCurrentAttachment();const o=s.sqrt(e[0]*e[0]+e[1]*e[1]),h=s.sqrt(e[2]*e[2]+e[3]*e[3]),l=new b(0,0,a.width,a.height),_=this._$generateFilterRect(l,o,h),$=0|s.ceil(_.width),c=0|s.ceil(_.height),u=s.ceil(s.abs(_.x)+.5*s.abs($-_.width)),d=s.ceil(s.abs(_.y)+.5*s.abs(c-_.height));t._$offsetX=+(u+t._$offsetX),t._$offsetY=+(d+t._$offsetY);const g=this._$blurX*o,f=this._$blurY*h;let m=1,p=1;g>128?m=.0625:g>64?m=.125:g>32?m=.25:g>16&&(m=.5),f>128?p=.0625:f>64?p=.125:f>32?p=.25:f>16&&(p=.5);const x=g*m,T=f*p;let v=s.ceil($*m),y=s.ceil(c*p);const E=t.frameBuffer.createTextureAttachment(v,y),A=[E,t.frameBuffer.createTextureAttachment(v,y)];let M=0;t._$bind(E),n.$resetContext(t),t.setTransform(m,0,0,p,0,0),t.drawImage(a,u,d,a.width,a.height),t.blend.toOneZero();let C=t.frameBuffer.getTextureFromCurrentAttachment();for(let e=0;e0){M=(M+1)%2;const e=A[M];t._$bind(e),t._$applyBlurFilter(C,!0,x),C=t.frameBuffer.getTextureFromCurrentAttachment()}if(this._$blurY>0){M=(M+1)%2;const e=A[M];t._$bind(e),t._$applyBlurFilter(C,!1,T),C=t.frameBuffer.getTextureFromCurrentAttachment()}}if(t.blend.reset(),1!==m||1!==p){const e=t.frameBuffer.createTextureAttachment($,c);t._$bind(e),n.$resetContext(t),t.imageSmoothingEnabled=!0,t.setTransform(1/m,0,0,1/p,0,0),t.drawImage(C,0,0,v,y),C=t.frameBuffer.getTextureFromCurrentAttachment(),n.$resetContext(t),t.setTransform(1,0,0,1,0,0),t.frameBuffer.releaseAttachment(A[0],!0),t.frameBuffer.releaseAttachment(A[1],!0),i?t.frameBuffer.releaseAttachment(r,!0):t.frameBuffer.releaseAttachment(e,!1)}else t.frameBuffer.releaseAttachment(A[(M+1)%2],!0),i?t.frameBuffer.releaseAttachment(r,!0):t.frameBuffer.releaseAttachment(A[M],!1);return C}}class q extends Y{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 W(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=j.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=n.$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=n.$clamp(+t,-255,255,4))!==this._$distance&&this._$doChanged(!0),this._$distance=t}get highlightAlpha(){return this._$highlightAlpha}set highlightAlpha(t){(t=n.$clamp(+t,0,1,0))!==this._$highlightAlpha&&this._$doChanged(!0),this._$highlightAlpha=t}get highlightColor(){return this._$highlightColor}set highlightColor(t){(t=n.$clamp(n.$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=n.$clamp(+t,0,1,0))!==this._$shadowAlpha&&this._$doChanged(!0),this._$shadowAlpha=t}get shadowColor(){return this._$shadowColor}set shadowColor(t){(t=n.$clamp(n.$toColorInt(t),0,16777215,0))!==this._$shadowColor&&this._$doChanged(!0),this._$shadowColor=t}get strength(){return this._$strength}set strength(t){(t=n.$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 j.OUTER:case j.INNER:this._$type=t;break;default:this._$type=j.FULL}}clone(){return new q(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 a=i.width,o=i.height,h=t._$offsetX,l=t._$offsetY,_=s.sqrt(e[0]*e[0]+e[1]*e[1]),$=s.sqrt(e[2]*e[2]+e[3]*e[3]),c=+this._$angle*n.$Deg2Rad,u=+s.cos(c)*this._$distance*_,d=+s.sin(c)*this._$distance*$;let g=t.frameBuffer.createTextureAttachment(a,o);t._$bind(g),n.$resetContext(t),t.drawImage(r,0,0,a,o),t.globalCompositeOperation=R.ERASE,t.drawImage(r,2*u,2*d,a,o);const f=this._$blurFilter._$applyFilter(t,e,!1),m=f.width,p=f.height,x=s.ceil(m+2*s.abs(u)),b=s.ceil(p+2*s.abs(d)),T=this._$type===j.INNER,v=T?a:x,y=T?o:b,E=s.abs(u),A=s.abs(d),M=(m-a)/2,C=(p-o)/2;let S,w,O,I;return T?(S=0,w=0,O=-M-u,I=-C-d):(S=E+M,w=A+C,O=E-u,I=A-d),t._$bind(i),t._$applyBitmapFilter(f,v,y,a,o,S,w,m,p,O,I,!1,this._$type,this._$knockout,this._$strength,null,null,null,n.$intToR(this._$highlightColor,this._$highlightAlpha,!0),n.$intToG(this._$highlightColor,this._$highlightAlpha,!0),n.$intToB(this._$highlightColor,this._$highlightAlpha,!0),this._$highlightAlpha,n.$intToR(this._$shadowColor,this._$shadowAlpha,!0),n.$intToG(this._$shadowColor,this._$shadowAlpha,!0),n.$intToB(this._$shadowColor,this._$shadowAlpha,!0),this._$shadowAlpha),t._$offsetX=h+S,t._$offsetY=l+w,t.frameBuffer.releaseTexture(f),t.frameBuffer.getTextureFromCurrentAttachment()}}class K extends Y{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(n.$isArray(t)&&20===t.length){if(this._$matrix){const e=t.length;for(let i=0;i0?s.max(0,m-d):0)+y,S=(p>0?s.max(0,p-g):0)+E),this._$inner?(R=j.INNER,w=this._$knockout||this._$hideObject):!this._$knockout&&this._$hideObject?(R=j.FULL,w=!0):(R=j.OUTER,w=this._$knockout),t._$bind(i),t._$applyBitmapFilter(l,T,v,r,a,A,M,_,$,C,S,!0,R,w,this._$strength,null,null,null,n.$intToR(this._$color,this._$alpha,!0),n.$intToG(this._$color,this._$alpha,!0),n.$intToB(this._$color,this._$alpha,!0),this._$alpha,0,0,0,0),t._$offsetX=o+A,t._$offsetY=h+M,t.frameBuffer.releaseTexture(l),t.frameBuffer.getTextureFromCurrentAttachment()}}class tt extends Y{constructor(t=0,e=1,i=4,s=4,r=1,n=1,a=!1,o=!1){super(),this._$blurFilter=new W(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=n.$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=n.$clamp(n.$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=n.$clamp(0|t,0,255,0))!==this._$strength&&this._$doChanged(!0),this._$strength=t}clone(){return new tt(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 s=i.width,r=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?s:l,d=this._$inner?r:_;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?j.INNER:j.OUTER;return t._$bind(i),t._$applyBitmapFilter(h,u,d,s,r,g,f,l,_,m,p,!0,x,this._$knockout,this._$strength,null,null,null,n.$intToR(this._$color,this._$alpha,!0),n.$intToG(this._$color,this._$alpha,!0),n.$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 et extends Y{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 W(n,a,h),this._$distance=4,this._$angle=45,this._$colors=null,this._$alphas=null,this._$ratios=null,this._$strength=1,this._$type=j.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,n.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;i16777215&&(e%=16777216),t[i]=n.$toColorInt(s.abs(e))}this._$colors=t.slice(0)}}get distance(){return this._$distance}set distance(t){(t=n.$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,n.$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]=n.$toColorInt(s.abs(e))}this._$colors=t.slice(0)}}get distance(){return this._$distance}set distance(t){(t=n.$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,n.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;i0?s.max(0,x-d):0)+M,O=(b>0?s.max(0,b-g):0)+C),t._$bind(i),t._$applyBitmapFilter(l,E,A,r,a,S,R,_,$,w,O,!0,this.type,this.knockout,this._$strength,this.ratios,this.colors,this.alphas,0,0,0,0,0,0,0,0),t._$offsetX=o+S,t._$offsetY=h+R,t.frameBuffer.releaseTexture(l),t.frameBuffer.getTextureFromCurrentAttachment()}}class st{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 rt{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 nt extends y{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 ot;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=rt.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=at.STATIC,this._$textHeightTable=null,this._$focus=!1,this._$isComposing=!1,this._$thickness=0,this._$thicknessColor=0,this._$verticalAlign=ht.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 rt.CENTER:case rt.LEFT:case rt.RIGHT:this._$autoSize=t;break;default:this._$autoSize=rt.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=n.$clamp(n.$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=n.$clamp(n.$toColorInt(t),0,16777215,0),this._$reset()}get defaultTextFormat(){return this._$defaultTextFormat}set defaultTextFormat(t){t instanceof ot&&(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===at.INPUT){const t=n.$currentPlayer(),e=n.$document.getElementById(t.contentElementId);if(!e)return;this._$createTextAreaElement(t._$scale);const i=this._$textarea,r=this._$transform.concatenatedMatrix,a=this._$getBounds(null),o=n.$intToRGBA(this._$defaultTextFormat._$color,100);i.style.color=`rgb(${o.R},${o.G},${o.B})`,i.style.left=(r.tx+a.xMin+t._$tx/t._$scale/n.$devicePixelRatio)*t._$scale+"px",i.style.top=(r.ty+a.yMin+t._$ty/t._$scale/n.$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,n.$requestAnimationFrame)((()=>{i.focus()})),this._$textAreaActive=!0,this.willTrigger($.FOCUS_IN)&&this.dispatchEvent(new $($.FOCUS_IN)),this._$doChanged(),n.$isUpdated=!0}}else this._$textarea&&(this._$textarea.dispatchEvent(new n.$window.Event(`${n.$PREFIX}_blur`)),this.willTrigger($.FOCUS_OUT)&&this.dispatchEvent(new $($.FOCUS_OUT)),this._$doChanged(),n.$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=n.$clamp(0|t,0,this.maxScrollH),this._$scrollH!==t&&(this._$scrollH=t,this._$reset(),this.willTrigger(h.SCROLL)&&this.dispatchEvent(new h(h.SCROLL,!0)))}get scrollV(){return this._$scrollV}set scrollV(t){t=n.$clamp(0|t,1,this.maxScrollV),this._$scrollV!==t&&(this._$scrollV=t,this._$reset(),this.willTrigger(h.SCROLL)&&this.dispatchEvent(new h(h.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,!n.$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 ot,a=t>-1?t:0;for(;at)break;r.yIndex===t&&(r.mode===nt.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===nt.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"),n.$P_TAG.innerHTML!==e&&(n.$P_TAG.textContent="",n.$P_TAG.insertAdjacentHTML("afterbegin",e));let s=this._$decisionTextFormat;if(this._$textData.length in this._$textFormatTable){const t=this._$textFormatTable[this._$textData.length]._$clone();t._$merge(s),s=t}this._$totalWidth=0,this._$heightTable[0]=0,this._$textHeightTable[0]=this._$getTextHeight(s),this._$widthTable[0]=0;const r={mode:nt.BREAK,x:0,yIndex:0,textFormat:s._$clone()};this._$objectTable[0]=r,this._$textData[0]=r,this._$parseTag(n.$P_TAG,s._$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(_,i)}this._$loadImage(e),n.$loadedImages.set(t,e)}this._$textData[this._$textData.length]=e,this._$imageData[this._$imageData.length]=e}break;default:this._$parseTag(o,a,i)}else i=this._$parseText(o.nodeValue,a)}}_$loadImage(t){t.scope=this,t.image=new n.$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,n.$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,a=e._$clone();const o=this._$transform.concatenatedMatrix._$matrix,h=(this._$originBounds.xMax-this._$originBounds.xMin)*(o[0]/o[3]);n.$poolFloat32Array6(o);const l=h-a._$widthMargin()-4;for(let o=0;ol){this._$widthTable[++r]=0,h.yIndex=r,this._$heightTable[r]=this._$heightTable[r-1],this._$textHeightTable[r]=this._$textHeightTable[r-1],this._$totalWidth=this._$getImageOffsetX(),a=a._$clone(),a._$indent=0;g={mode:_?nt.BREAK:nt.WRAP,x:0,yIndex:r,textFormat:a},this._$objectTable[r]=g,_||--i;let t=h.text,e=0,n=!0;const o=/[0-9a-zA-Z?!;:.,?!。、;:〜]/g;for(;t.match(o);){++e;const i=this._$textData[this._$textData.length-e];if(i.mode!==nt.TEXT){n=!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&&n){const t=this._$textData.length-e;this._$textData.splice(t,0,g);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===nt.TEXT;)u=this._$getTextHeight(n.textFormat),d=u+$,this._$widthTable[r-1]+=n.width,this._$heightTable[r-1]=s.max(this._$heightTable[r-1],u),this._$textHeightTable[r-1]=s.max(this._$textHeightTable[r-1],d),++i,n=this._$textData[t-i];for(i=1;this._$textData.length>t+i;)n=this._$textData[t+i],++i,u=this._$getTextHeight(n.textFormat),d=u+$,this._$heightTable[r]=s.max(this._$heightTable[r],u),this._$textHeightTable[r]=s.max(this._$textHeightTable[r],d),n.x=this._$totalWidth,n.yIndex=r,this._$totalWidth+=n.width}else this._$textData[this._$textData.length]=g}_||(h.width=c,h.x=this._$totalWidth,this._$totalWidth+=c,this._$widthTable[r]=s.max(this._$widthTable[r],this._$totalWidth),this._$heightTable[r]=s.max(this._$heightTable[r],u),this._$textHeightTable[r]=s.max(this._$textHeightTable[r],d),this._$textData[this._$textData.length]=h)}return i}_$getTextHeight(t){if(!n.$DIV){const t=n.$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%",n.$DIV=t,n.$document.body.appendChild(n.$DIV)}const e=t._$size,i=t._$font,s=t._$bold?"bold":"normal",r=`${e}_${i}_${s}`;if(this._$heightCache.has(r))return this._$heightCache.get(r);const a=n.$DIV.style,o=`${e}px`;a.fontSize!==o&&(a.fontSize=o),a.fontFamily!==i&&(a.fontFamily=i),a.fontWeight!==s&&(a.fontWeight=s);const h=10>e?n.$DIV.clientHeight*e*.1:n.$DIV.clientHeight;return this._$heightCache.set(r,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!==rt.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 rt.LEFT:case rt.CENTER:this._$bounds.xMax=e+this._$bounds.xMin;break;case rt.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===st.CENTER:case this._$autoSize===rt.CENTER:return s.max(0,e/2-n-r._$rightMargin-i/2);case r._$align===st.RIGHT:case this._$autoSize===rt.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=n.$multiplicationMatrix(t,this._$correctMatrix(this._$transform._$rawMatrix()));return n.$boundsMatrix(this._$bounds,e)}return n.$boundsMatrix(this._$bounds,this._$correctMatrix(n.$MATRIX_ARRAY_IDENTITY))}_$correctMatrix(t){switch(this._$autoSize){case rt.CENTER:{const e=this.textWidth+4,i=(this._$originBounds.xMax-this._$originBounds.xMin)/2-e/2;return n.$getFloat32Array6(t[0],t[1],t[2],t[3],t[4]+i,t[5])}case rt.RIGHT:{const e=this.textWidth+4,i=this._$originBounds.xMax-this._$originBounds.xMin-(e-this._$originBounds.xMin);return n.$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,a=i.xMin,o=i.yMax,h=i.yMin;n.$poolBoundsObject(i);let l=s.ceil(s.abs(r-a)),_=s.ceil(s.abs(o-h));if(!l||!_)return;let $=e;const c=this._$transform._$rawMatrix();c!==n.$MATRIX_ARRAY_IDENTITY&&($=n.$multiplicationMatrix(e,c)),n.$resetContext(t),t.setTransform($[0],$[1],$[2],$[3],$[4],$[5]),t.beginPath(),t.moveTo(0,0),t.lineTo(l,0),t.lineTo(l,_),t.lineTo(0,_),t.lineTo(0,0),t.clip(!0),$!==e&&n.$poolFloat32Array6($)}_$draw(t,e,i){if(!this._$visible||this._$textAreaActive)return;if(!this._$background&&!this._$border&&!this.text)return;let a=i;const o=this._$transform._$rawColorTransform();o!==n.$COLOR_ARRAY_IDENTITY&&(a=n.$multiplicationColor(i,o));const h=n.$clamp(a[3]+a[7]/255,0,1);if(!h)return;let l=e;const _=this._$transform._$rawMatrix();_!==n.$MATRIX_ARRAY_IDENTITY&&(l=n.$multiplicationMatrix(e,_));const $=this._$getBounds(null);$.xMin-=this._$thickness,$.xMax+=this._$thickness,$.yMin-=this._$thickness,$.yMax+=this._$thickness;const c=$.xMin,u=$.xMax,d=$.yMin,g=$.yMax,f=n.$boundsMatrix($,l),m=+f.xMax,p=+f.xMin,x=+f.yMax,b=+f.yMin;n.$poolBoundsObject(f),n.$poolBoundsObject($);let T=s.ceil(s.abs(m-p)),v=s.ceil(s.abs(x-b));if(!T||!v)return;if(0>p+T||0>b+v)return;const y=t.frameBuffer.currentAttachment;if(p>y.width||b>y.height)return;let E=+s.sqrt(l[0]*l[0]+l[1]*l[1]);if(!r.isInteger(E)){const t=E.toString(),e=t.indexOf("e");-1!==e&&(E=+t.slice(0,e)),E=+E.toFixed(4)}let A=+s.sqrt(l[2]*l[2]+l[3]*l[3]);if(!r.isInteger(A)){const t=A.toString(),e=t.indexOf("e");-1!==e&&(A=+t.slice(0,e)),A=+A.toFixed(4)}const M=n.$getArray();M[0]=E,M[1]=A;const C=n.$cacheStore(),S=C.generateKeys(this._$instanceId,M,a);let R=C.get(S);if(R&&(this._$renew||this._$isUpdated())&&(C.set(S,null),C.destroy(R),R=null),T+=4*n.$devicePixelRatio,v+=4*n.$devicePixelRatio,!R){this._$renew=!1,a[3]=1;const i=C.getCanvas();i.width=T,i.height=v;const r=i.getContext("2d");if(this._$background||this._$border){if(r.beginPath(),r.rotate(s.atan2(e[1],e[0])),r.moveTo(0,0),r.lineTo(T,0),r.lineTo(T,v),r.lineTo(0,v),r.lineTo(0,0),this._$background){const t=n.$generateColorTransform(n.$intToRGBA(this._$backgroundColor),a);r.fillStyle=`rgba(${t.R},${t.G},${t.B},${t.A})`,r.fill()}if(this._$border){const t=n.$generateColorTransform(n.$intToRGBA(this._$borderColor),a);r.lineWidth=1,r.strokeStyle=`rgba(${t.R},${t.G},${t.B},${t.A})`,r.stroke()}}r.save(),r.beginPath(),r.moveTo(2,2),r.lineTo(T-2,2),r.lineTo(T-2,v-2),r.lineTo(2,v-2),r.lineTo(2,2),r.clip(),r.beginPath(),r.setTransform(E,0,0,A,0,0),this._$doDraw(r,e,a,!1,T/e[0]),r.restore(),R=t.frameBuffer.createTextureFromCanvas(r.canvas),C.set(S,R),C.destroy(r)}n.$poolArray(S),n.$poolArray(M);let w=0,O=0;const I=this._$filters||this.filters;if(I&&I.length){const s=this._$canApply(I);if(s){const r=[this._$instanceId,"f"];let a=n.$cacheStore().get(r);const o=this._$isFilterUpdated(T,v,e,i,I,s);a&&!o||(a&&(n.$cacheStore().set(r,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),R=this._$getFilterTexture(t,I,R,e,i),n.$cacheStore().set(r,R)),a&&(R=a),n.$poolArray(r),w=R._$offsetX,O=R._$offsetY}}n.$resetContext(t),t._$globalAlpha=h,t._$globalCompositeOperation=this._$blendMode||this.blendMode;const B=s.atan2(l[1],l[0]),F=s.atan2(-l[2],l[3]);if(B||F){const e=n.$getBoundsObject(c*E*s.cos(B)-d*A*s.sin(F),u*E*s.cos(B)-g*A*s.sin(F),c*E*s.sin(B)+d*A*s.cos(F),u*E*s.sin(B)+g*A*s.cos(F));t.setTransform(s.cos(B),s.sin(B),-s.sin(F),s.cos(F),e.xMin+l[4]-w,e.yMin+l[5]-O),n.$poolBoundsObject(e)}else t.setTransform(1,0,0,1,p-w,b-O);t.drawImage(R,0,0,R.width,R.height,i),l!==e&&n.$poolFloat32Array6(l)}_$doDraw(t,e,i,r,a){const o=this._$getTextData(),h=r?0:this.width,l=r?0:this.height;let _=0,$=0,c=0,u=0;if(this._$verticalAlign!==ht.TOP&&this.height>this.textHeight)switch(this._$verticalAlign){case ht.MIDDLE:u=(this.height-this.textHeight+2)/2;break;case ht.BOTTOM:u=this.height-this.textHeight+2}const d=o.length;for(let g=0;gl||f>h))continue;let m=d.textFormat;if(!r){const e=n.$intToRGBA(d.textFormat._$color),r=s.max(0,s.min(255*e.A*i[3]+i[7],255))/255;if(t.fillStyle=`rgba(${e.R},${e.G},${e.B},${r})`,this._$thickness){const e=n.$intToRGBA(this._$thicknessColor),r=s.max(0,s.min(255*e.A*i[3]+i[7],255))/255;t.lineWidth=this._$thickness,t.strokeStyle=`rgba(${e.R},${e.G},${e.B},${r})`}}const p=0|d.yIndex;switch(d.mode){case nt.BREAK:case nt.WRAP:if(c++,this.scrollV>c)continue;if($+=this._$textHeightTable[p],_=this._$getAlignOffset(this._$objectTable[p],a),m._$underline){const r=d.textFormat._$size/12,a=n.$intToRGBA(m._$color),o=s.max(0,s.min(255*a.A*i[3]+i[7],255))/255;t.lineWidth=s.max(1,1/s.min(e[0],e[3])),t.strokeStyle=`rgba(${a.R},${a.G},${a.B},${o})`,t.beginPath(),t.moveTo(_,u+$-r),t.lineTo(_+this._$widthTable[p],u+$-r),t.stroke()}break;case nt.TEXT:{if(this.scrollV>c)continue;let e=$-this._$heightTable[0];n.$isSafari||(e+=d.textFormat._$size/12*2),t.beginPath(),t.textBaseline="top",t.font=m._$generateFontStyle(),this._$thickness&&t.strokeText(d.text,f,u+e),t.fillText(d.text,f,u+e)}break;case nt.IMAGE:if(!d.loaded)continue;t.beginPath(),t.drawImage(d.image,d.hspace,u+d.y,d.width,d.height)}}}_$mouseHit(t,e,i){return!!this._$visible&&this._$hit(t,e,i)}_$hit(t,e,i){let r=e;const a=this._$transform._$rawMatrix();a!==n.$MATRIX_ARRAY_IDENTITY&&(r=n.$multiplicationMatrix(e,a));const o=this._$getBounds(null),h=n.$boundsMatrix(o,r),l=+h.xMax,_=+h.xMin,$=+h.yMax,c=+h.yMin;n.$poolBoundsObject(h),n.$poolBoundsObject(o);const u=s.ceil(s.abs(l-_)),d=s.ceil(s.abs($-c));return t.setTransform(1,0,0,1,_,c),t.beginPath(),t.moveTo(0,0),t.lineTo(u,0),t.lineTo(u,d),t.lineTo(0,d),t.lineTo(0,0),r!==e&&n.$poolFloat32Array6(r),t.isPointInPath(i.x,i.y)}_$createTextAreaElement(t){if(!this._$textarea){this._$textarea=n.$document.createElement("textarea"),this._$textarea.value=this.text,this._$textarea.id=`${n.$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(`${n.$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 n.$RegExp(t,"gm"));e=i?i.join(""):""}this.text=e;if(n.$document.getElementById(n.$currentPlayer().contentElementId)){const t=n.$document.getElementById(`${n.$PREFIX}_TextField_${this._$instanceId}`);t&&(t.remove(),this._$focus=!1,this._$textAreaActive=!1,n.$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 n.$RegExp(t,"gm"));e=i?i.join(""):""}if(!this._$isComposing&&this.text!==e){this.text=e,t.target.value=e,this.willTrigger(h.CHANGE)&&this.dispatchEvent(new h(h.CHANGE,!0));const i=n.$currentPlayer(),r=this._$textarea,a=this._$transform.concatenatedMatrix,o=this._$getBounds(null);r.style.left=`${s.floor((a.tx+o.xMin+i._$tx/i._$scale/n.$devicePixelRatio)*i._$scale)}px`,r.style.top=`${s.floor((a.ty+o.yMin+i._$ty/i._$scale/n.$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 s=e.match(new n.$RegExp(i,"gm"));e=s?s.join(""):"",this.text=e,t.target.value=e}.bind(this)),this._$textarea.addEventListener("click",function(){this.willTrigger(d.CLICK)&&this.dispatchEvent(new d(d.CLICK))}.bind(this)),this._$textarea.addEventListener(n.$MOUSE_WHEEL,function(t){this.scrollV+=t.deltaY}.bind(this)),this._$textarea.addEventListener(n.$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===n.$isTouch)this._$textarea.addEventListener(n.$TOUCH_START,(function(){const t=n.$currentPlayer();t&&(t._$state="down")})),this._$textarea.addEventListener(n.$TOUCH_END,(function(){const t=n.$currentPlayer();t&&(t._$state="up")}));else this._$textarea.addEventListener(n.$MOUSE_DOWN,(function(){const t=n.$currentPlayer();t&&(t._$state="down")})),this._$textarea.addEventListener(n.$MOUSE_UP,(function(){const t=n.$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!==rt.NONE?this._$textarea.style.textAlign=rt.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 n.$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 at{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 ot{constructor(t=null,e=null,i=null,s=null,r=null,a=null,o=null,h=null,l=null,_=null,$=null,c=null){this._$font=t,this._$size=e,this._$color=null===i?null:n.$clamp(n.$toColorInt(i),0,16777215,16777215),this._$bold=s,this._$italic=r,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 st.CENTER:case st.RIGHT:case st.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=n.$clamp(n.$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 ot(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=st.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 ht{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 lt extends l{constructor(){super(),this._$bytesLoaded=0,this._$bytesTotal=0,this._$buffer=null,this._$audioBuffer=null,this._$character=null,this._$sources=n.$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(_t.volume,n.$clamp(t,0,1,1));const e=this._$sources.length;if(e&&n.$audioContext)for(let t=0;tt.target.status?(this._$buffer=new Uint8Array(t.target.response),n.$audioContext?n.$decodeAudioData(this):n.$audios.push(this),n.$currentPlayer()._$loaders.push(this)):this.willTrigger(u.IO_ERROR)&&this.dispatchEvent(new u(u.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(n.$audioContext&&e)this._$createBufferSource(t);else{const e=function(t,i=0){if(null!==(this._$character?this._$character.audioBuffer:this._$audioBuffer)&&null!==n.$audioContext){const e=(n.$performance.now()-t)/1e3;return void this._$createBufferSource(i,e)}(0,n.$requestAnimationFrame)(e)}.bind(this,n.$performance.now(),t);(0,n.$requestAnimationFrame)(e)}}stop(){this._$stopFlag=!0;const t=this._$sources.length;if(t){const e=n.$currentPlayer();if(n.$audioContext)for(let e=0;e=this._$duration&&(this.removeEventListener(h.ENTER_FRAME,this._$update),this.hasEventListener(h.COMPLETE)&&this.dispatchEvent(new h(h.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 xt{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 pt(t,e,i,s,r,n)}}class bt{constructor(){this._$pool=n.$getArray(),this._$store=n.$getMap(),this._$lifeCount=2,this._$delayLifeCheck=this.lifeCheck.bind(this),this._$delayBitmapLifeCheck=this.bitmapLifeCheck.bind(this)}reset(){const t=this._$store.values();for(const e of t){const t=e.values();for(const e of t)this.destroy(e);n.$poolMap(e)}this._$store.clear()}destroy(t){if(t)switch(t.constructor){case n.$WebGLTexture:return new Promise((()=>{const e=n.$currentPlayer();if(e._$context){const i=e._$context,s=t._$bitmapData;if(s){s._$getPixelsAsync(0,0,s.width,s.height,"RGBA"),t._$bitmapData=!1;(0,n.$setTimeout)(this._$delayBitmapLifeCheck,2e3,s)}i.frameBuffer.releaseTexture(t)}}));case n.$CanvasRenderingContext2D:return new Promise((()=>{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()||n.$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);n.$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=null){const i=`${t[0]}`,s=`${t[1]}`;this._$store.has(i)||this._$store.set(i,n.$getMap());const r=this._$store.get(i);if(!e)return r.delete(s),r.delete(`life_${s}`),void(r.size||(n.$poolMap(r),this._$store.delete(i)));const a=r.get(s);a&&a!==e&&this.destroy(a),r.set(s,e),r.set(`life_${s}`,this._$lifeCount);(0,n.$setTimeout)(this._$delayLifeCheck,5e3,i,s)}bitmapLifeCheck(t){if(!t._$pixelBuffer)return;const e=n.$currentPlayer()._$context;t._$buffer=e.pbo.getBufferSubDataAsync(t._$pixelBuffer),t._$pixelBuffer=null}lifeCheck(t,e){if(!this._$store.has(t))return;const i=this._$store.get(t),s=`life_${e}`,r=i.get(s)-1;if(!r)return this.destroy(i.get(e)),i.delete(e),i.delete(s),void(i.size||(n.$poolMap(i),this._$store.delete(t)));i.set(s,r);(0,n.$setTimeout)(this._$delayLifeCheck,5e3,t,e)}generateKeys(t,e=null,i=null){let s="";e&&(s+=`${e[0]}_${e[1]}`),i&&(s+=this.colorToString(i));const r=n.$getArray();return r[1]=s?this.generateHash(s):"_0",r[0]=`${t}`,r}colorToString(t=null){return t&&0!==t[7]?`_${t[7]}`:""}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 yt{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${yt.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${yt.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 Et{static TEMPLATE(t,e){const i=e?"uniform vec4 u_mediump[2];":"",s=e?Tt.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 At{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,It.TEXTURE(this._$keyword),Et.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 Mt{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,It.BLEND(this._$keyword),Et.TEMPLATE(this._$keyword,t))),this._$collection.get(e)}getClipShader(){return this._$collection.has("c")||this._$collection.set("c",new Qt(this._$gl,this._$context,It.BLEND_CLIP(this._$keyword),Et.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,It.BLEND(this._$keyword),class{static TEMPLATE(t,e,i){let s;switch(e){case R.SUBTRACT:s=this.FUNCTION_SUBTRACT();break;case R.MULTIPLY:s=this.FUNCTION_MULTIPLY();break;case R.LIGHTEN:s=this.FUNCTION_LIGHTEN();break;case R.DARKEN:s=this.FUNCTION_DARKEN();break;case R.OVERLAY:s=this.FUNCTION_OVERLAY();break;case R.HARDLIGHT:s=this.FUNCTION_HARDLIGHT();break;case R.DIFFERENCE:s=this.FUNCTION_DIFFERENCE();break;case R.INVERT:s=this.FUNCTION_INVERT();break;default:s=this.FUNCTION_NORMAL()}const r=i?"uniform vec4 u_mediump[2];":"",n=i?Tt.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 Ct{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,It.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,It.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===j.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 j.OUTER:f=o?"blur - blur * base.a":"base + blur - blur * base.a";break;case j.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${Tt.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,It.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,It.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 Pt{constructor(){this._$rgb=P.RGB,this._$mode=G.PAD,this._$focalPointRatio=0,this._$points=n.$getFloat32Array6(),this._$stops=n.$getArray(),this._$type=null}linear(t,e,i,s,r=P.RGB,n=G.PAD){return this._$type=I.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,s,r,a,o=P.RGB,h=G.PAD,l=0){return this._$type=I.RADIAL,this._$points[0]=t,this._$points[1]=e,this._$points[2]=i,this._$points[3]=s,this._$points[4]=r,this._$points[5]=a,this._$rgb=o,this._$mode=h,this._$focalPointRatio=n.$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 Dt{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 Nt{constructor(t,e){this._$gl=t;const i=e?s.min(n.$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 Ht,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=R.NORMAL,this._$matrix=n.$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 zt(t,e,i),this._$path=new Xt,this._$grid=new kt,this._$offsetX=0,this._$offsetY=0,this._$blends=[],this._$positions=[],this._$isLayer=!1,this._$shaderList=new Jt(this,t),this._$gradientLUT=new Zt(this,t),this._$vao=new Kt(t,e),this._$pbo=new Vt(t,e),this._$mask=new Gt(this,t),this._$blend=new Ut(this,t),this._$canvasPatternToWebGL=new Dt,this._$canvasGradientToWebGL=new Pt}get canvas(){return this._$gl.canvas}get fillStyle(){return this._$style._$fillStyle}set fillStyle(t){this._$style._$fillStyle.constructor===Float32Array&&n.$poolFloat32Array4(this._$style._$fillStyle),this._$style._$fillStyle=t}get strokeStyle(){return this._$style._$strokeStyle}set strokeStyle(t){this._$style._$strokeStyle.constructor===Float32Array&&n.$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 w.NONE:case w.SQUARE:this._$style._$lineCap=t;break;default:this._$style._$lineCap=w.ROUND}}get lineJoin(){return this._$style._$lineJoin}set lineJoin(t){switch(t){case D.BEVEL:case D.MITER:this._$style._$lineJoin=t;break;default:this._$style._$lineJoin=D.ROUND}}get miterLimit(){return this._$style._$miterLimit}set miterLimit(t){this._$style._$miterLimit=t}get globalAlpha(){return this._$globalAlpha}set globalAlpha(t){this._$globalAlpha=n.$clamp(t,0,1,1)}get imageSmoothingEnabled(){return this._$imageSmoothingEnabled}set imageSmoothingEnabled(t){this._$imageSmoothingEnabled=n.$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,s){if(!i||!s)return;this._$viewportWidth=i,this._$viewportHeight=s;let r=!1;if(!this._$fillBuffer){r=!0;const a=this._$path.createRectVertices(t,e,i,s);this._$fillBuffer=this._$vao.createFill(a),n.$poolArray(a.pop()),n.$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),r&&(this._$vao.release(this._$fillBuffer),n.$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),n.$poolArray(this._$fillBuffer.indexRanges),n.$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,s=this._$matrix;switch(!0){case this.fillStyle.constructor===Pt:if(this.fillStyle._$type===I.LINEAR);else s=this._$stack[this._$stack.length-1];break;case this.fillStyle.constructor===Dt:s=this._$stack[this._$stack.length-1]}const r=this._$grid.enabled;switch(!0){case this.fillStyle.constructor===Pt:{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===I.LINEAR)i=e.getGradientShapeShader(!1,r,!1,!1,a._$mode),e.setGradientShapeUniform(i.uniform,!1,0,0,0,r,s,n.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!1,a._$points,0);else{const t=0!==a._$focalPointRatio;i=e.getGradientShapeShader(!1,r,!0,t,a._$mode),e.setGradientShapeUniform(i.uniform,!1,0,0,0,r,s,n.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!0,a._$points,a._$focalPointRatio)}}break;case this.fillStyle.constructor===Dt:{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,r),o?e.setBitmapShapeUniform(i.uniform,!1,0,0,0,r,s,n.$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,r,s,n.$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,r,s,this._$viewportWidth,this._$viewportHeight,this._$grid,this.fillStyle,this._$globalAlpha)}const a=this._$shaderList.shapeShaderVariants,o=a.getMaskShapeShader(!1,r);if(a.setMaskShapeUniform(o.uniform,r,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],this._$viewportWidth,this._$viewportHeight,this._$grid),!this._$fillBuffer){const t=this._$getVertices();if(!t.length)return;const e=n.$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),n.$poolArray(i.pop()),n.$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=n.$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===Pt:if(this.strokeStyle._$type===I.LINEAR);else t=this._$stack[this._$stack.length-1];break;case this.strokeStyle.constructor===Dt: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,a=.5*this.lineWidth;this._$grid.enabled?(a*=n.$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 o=s.min(i,r),h=s.max(i,r);let l,_,$;a*=h*(1-.3*s.cos(.5*s.PI*(o/h))),a=s.max(1,a);const c=this._$grid.enabled;switch(!0){case this.strokeStyle.constructor===Pt:{const i=this.strokeStyle,s=i._$stops,r="linearRGB"===i._$rgb;if(l=this._$gradientLUT.generateForShape(s,r),this._$frameBufferManager._$textureManager.bind0(l,!0),_=this._$shaderList.gradientShapeShaderVariants,i._$type===I.LINEAR)$=_.getGradientShapeShader(!0,c,!1,!1,i._$mode),_.setGradientShapeUniform($.uniform,!0,a,e,this.miterLimit,c,t,n.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!1,i._$points,0);else{const s=0!==i._$focalPointRatio;$=_.getGradientShapeShader(!0,c,!0,s,i._$mode),_.setGradientShapeUniform($.uniform,!0,a,e,this.miterLimit,c,t,n.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!0,i._$points,i._$focalPointRatio)}}break;case this.strokeStyle.constructor===Dt:{const i=this.strokeStyle,s=i.colorTransform;l=i.texture,this._$frameBufferManager._$textureManager.bind0(l),_=this._$shaderList.shapeShaderVariants,$=_.getBitmapShapeShader(!0,""!==i.repeat,this._$grid.enabled),s?_.setBitmapShapeUniform($.uniform,!0,a,e,this.miterLimit,c,t,n.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,l.width,l.height,s[0],s[1],s[2],this._$globalAlpha,s[4]/255,s[5]/255,s[6]/255,0):_.setBitmapShapeUniform($.uniform,!0,a,e,this.miterLimit,c,t,n.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,l.width,l.height,1,1,1,this._$globalAlpha,0,0,0,0)}break;default:_=this._$shaderList.shapeShaderVariants,$=_.getSolidColorShapeShader(!0,this._$grid.enabled),_.setSolidColorShapeUniform($.uniform,!0,a,e,this.miterLimit,c,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),s=i.uniform;if(e.setMaskShapeUniform(s,!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),n.$poolArray(t.pop()),n.$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),n.$poolArray(this._$fillBuffer.indexRanges),n.$poolArray(this._$fillBuffer.boundObject.indexRanges),this._$fillBuffer=null),this.beginPath())}save(){const t=this._$matrix;this._$stack.push(n.$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&&(n.$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=P.RGB,n=G.PAD){return this._$canvasGradientToWebGL.linear(t,e,i,s,r,n)}createRadialGradient(t,e,i,s,r,n,a=P.RGB,o=G.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===j.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===j.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 a=i*r*4,o=n.$getUint8Array(a);this._$gl.readPixels(t,r-(r-e),i,r,this._$gl.RGBA,this._$gl.UNSIGNED_BYTE,o);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 Ut{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 R.ADD:this.toAdd();break;case R.SCREEN:this.toScreen();break;case R.ALPHA:this.toAlpha();break;case R.ERASE:this.toErase();break;case"copy":this.toOneZero();break;default:this.reset()}}drawImage(t,e,i,r,a,o,h,l,_,$,c,u,d,g,f,m,p,x){const b=this._$context._$frameBufferManager.currentAttachment,T=1!==o||1!==h||1!==l||1!==_||0!==$||0!==c||0!==u||0!==d,v=this._$context._$shaderList.blendShaderVariants;switch(g){case R.NORMAL:case R.LAYER:case R.ADD:case R.SCREEN:case R.ALPHA:case R.ERASE:case"copy":{this._$context._$frameBufferManager._$textureManager.bind0(t,x);const b=v.getNormalBlendShader(T);v.setNormalBlendUniform(b.uniform,e,i,r,a,p,f,m,T,o,h,l,_,$,c,u,d);const y=p[0],E=p[1],A=p[3],M=p[4],C=p[6],S=p[7];if(1!==y||0!==E||0!==A||1!==M){const t=e+r,o=i+a,h=+(t*y+o*A+C),l=+(t*y+i*A+C),_=+(e*y+o*A+C),$=+(e*y+i*A+C),c=+(t*E+o*M+S),u=+(t*E+i*M+S),d=+(e*E+o*M+S),g=+(e*E+i*M+S),p=n.$MAX_VALUE,x=+s.min(s.min(s.min(s.min(p,h),l),_),$),b=+s.max(s.max(s.max(s.max(-p,h),l),_),$),T=+s.min(s.min(s.min(s.min(p,c),u),d),g),v=+s.max(s.max(s.max(s.max(-p,c),u),d),g),R=s.max(0,0|x),w=s.max(0,0|T),O=s.min(s.max(0,f-R),s.ceil(s.abs(b-x))),I=s.min(s.max(0,m-w),s.ceil(s.abs(v-T)));if(!O||!I)return;this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(R,s.max(0,m-(w+I)),O+1,I+1)}else{const t=s.max(0,e+C|0),n=s.max(0,i+S|0),o=s.min(s.max(0,f-t),r),h=s.min(s.max(0,m-n),a);if(!o||!h)return;this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(t,s.max(0,m-(n+h)),o+1,h+1)}this.toOperation(g),b._$drawImage(),this._$gl.disable(this._$gl.SCISSOR_TEST)}break;default:{const y=s.max(0,e+p[6]|0),E=s.max(0,i+p[7]|0),A=s.min(s.max(0,f-y),r),M=s.min(s.max(0,m-E),a);if(!A||!M)return;const C=this._$context._$frameBufferManager.getTextureFromCurrentAttachment(),S=this._$context._$frameBufferManager.createTextureAttachment(r,a);this._$context._$bind(S),this._$context._$frameBufferManager._$textureManager.bind0(C);const R=v.getClipShader(),w=R.uniform;v.setClipUniform(w,e,i,r,a,n.$inverseMatrix(p),f,m),this.reset(),R._$drawImage();const O=this._$context._$frameBufferManager.getTextureFromCurrentAttachment();this._$context._$bind(b),this._$context._$frameBufferManager._$textureManager.bind01(O,t,x);const I=v.getBlendShader(g,T);v.setBlendUniform(I.uniform,e,i,r,a,p,f,m,T,o,h,l,_,$,c,u,d),this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(y,s.max(0,m-(E+M)),A,M),this.toOneZero(),I._$drawImage(),this._$gl.disable(this._$gl.SCISSOR_TEST),this._$context._$frameBufferManager.releaseAttachment(S,!0)}}}}class kt{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 Gt{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 s=this._$context._$cacheCurrentBounds.x,r=this._$context._$cacheCurrentBounds.y,a=this._$context._$cacheCurrentBounds.w,o=this._$context._$cacheCurrentBounds.h;n.$resetContext(this._$context),this._$context.setTransform(1,0,0,1,0,0),this._$context.drawImage(e,s,r,a,o),this._$context._$blend.enable(),t.releaseAttachment(i,!0)}_$startClip(t,e){const i=n.$multiplicationMatrix(e,t._$transform._$rawMatrix()),r=t._$getBounds(null),a=n.$boundsMatrix(r,i);n.$poolFloat32Array9(i),n.$poolBoundsObject(r);let o=a.xMin,h=a.yMin,l=s.abs(a.xMax-a.xMin),_=s.abs(a.yMax-a.yMin);n.$poolBoundsObject(a);const $=this._$context._$frameBufferManager,c=$.currentAttachment;if(l+o>c.texture.width&&(l-=l-c.texture.width+o),_+h>c.texture.height&&(_-=_-c.texture.height+h),0>o&&(l+=o,o=0),0>h&&(_+=h,h=0),0>=l||0>=_)return null;l=s.ceil(l),_=s.ceil(_),this._$context._$cacheCurrentBounds.x=o,this._$context._$cacheCurrentBounds.y=h,this._$context._$cacheCurrentBounds.w=l,this._$context._$cacheCurrentBounds.h=_;const u=$.getTextureFromCurrentAttachment();this._$context._$cacheCurrentBuffer=c;const d=n.$currentPlayer(),g=!this._$context._$isWebGL2Context||d._$quality!==H.LOW&&d._$quality!==H.MIDDLE?0:s.min(n.$HIGH_SAMPLES,this._$gl.getParameter(this._$gl.MAX_SAMPLES)),f=$.createCacheAttachment(l,_,!0,g);return this._$context._$bind(f),n.$resetContext(this._$context),this._$context.setTransform(1,0,0,1,0,0),this._$context.drawImage(u,-o,-h,u.width,u.height),n.$getFloat32Array9(e[0],e[1],e[2],e[3],e[4]-o,e[5]-h)}_$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 s=this._$context._$path.createRectVertices(0,0,e,i),r=this._$context._$vao.createFill(s);n.$poolArray(s.pop()),n.$poolArray(s);const a=this._$context._$shaderList.shapeShaderVariants,o=a.getMaskShapeShader(!1,!1),h=o.uniform;a.setMaskShapeUniformIdentity(h,e,i);const l=r.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 jt={vertices:null};jt.subhulls=new Array(512),jt.subhullsIndex=0,jt.extremePoints=new Array(32),jt.extremePointsIndex=0,jt.t=0,jt.hulls=[new Array(16),new Array(64),new Array(256)],jt.hullsIndex=0;class zt{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 qt(t,e),this._$colorBufferPool=null,this._$stencilBufferPool=new Wt(t),e&&(this._$frameBufferTexture=t.createFramebuffer(),this._$colorBufferPool=new Yt(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 Vt{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 Wt{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 qt{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,s){const r=i!==this._$boundTextures[t],a=null!==s&&s!==i.smoothing;if((r||a||e===this._$gl.TEXTURE0)&&e!==this._$activeTexture&&(this._$activeTexture=e,this._$gl.activeTexture(e)),r&&(this._$boundTextures[t]=i,this._$gl.bindTexture(this._$gl.TEXTURE_2D,i)),a){i.smoothing=s;const t=s&&n.$currentPlayer()._$quality!==H.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 Kt{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 n.$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 n.$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 n.$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 se{constructor(){this._$stage=new X,this._$stage._$player=this,this._$cacheStore=new bt,this._$mode="loader",this._$actionOffset=0,this._$actions=n.$getArray(),this._$loaders=n.$getArray(),this._$sounds=n.$getMap(),this._$hitObject={x:0,y:0,pointer:"",hit:null},this._$rollOverObject=null,this._$mouseOverTarget=null,this._$mouseWheelEvent=null,this._$ratio=n.$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 n.$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=n.$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=H.HIGH,this._$sources=n.$getArray(),this._$videos=n.$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=`${n.$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`${n.$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,n.$cancelAnimationFrame)(this._$timerId)}this._$startTime=n.$performance.now(),this._$fps=1e3/this._$stage._$frameRate;const t=n.$requestAnimationFrame;this._$timerId=t(this._$bindRun)}}stop(){(0,n.$cancelAnimationFrame)(this._$timerId),this._$stopFlag=!0,this._$timerId=-1,_t.stopAll(),n.$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===se.LOAD_END)return void this._$loaded();const t=n.$requestAnimationFrame;this._$loadId=t(this._$updateLoadStatus.bind(this))}_$loaded(){const t=n.$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(h.FRAME_CONSTRUCTED)&&this._$dispatchEvent(new h(h.FRAME_CONSTRUCTED)),this._$doAction(),this._$broadcastEvents.has(h.EXIT_FRAME)&&this._$dispatchEvent(new h(h.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),s=i.parentNode;if(s){this._$initStyle(i),this._$buildWait();const t=this._$optionWidth?this._$optionWidth:"BODY"===s.tagName?n.$window.innerWidth:s.offsetWidth,e=this._$optionHeight?this._$optionHeight:"BODY"===s.tagName?n.$window.innerHeight:s.offsetHeight;"loader"===this._$mode&&t&&e&&(this._$baseWidth=t,this._$baseHeight=e,this._$resize())}"loader"===this._$mode?(this._$loadStatus=se.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=n.$document.getElementById(this.contentElementId);if(t){const e=`${this.contentElementId}_loading`;t.innerHTML=``;const i=n.$document.createElement("div");i.id=e,t.appendChild(i)}}_$deleteNode(){const t=n.$document.getElementById(this.contentElementId);if(t)for(;t.childNodes.length;)t.removeChild(t.childNodes[0])}_$initializeCanvas(){const e=n.$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 s=!0,r=e.getContext("webgl2",i);if(r||(r=e.getContext("webgl",i)||e.getContext("experimental-webgl",i),s=!1),r?this._$context=new Nt(r,s):alert("WebGL setting is off. Please turn the setting on."),t.glstats&&glstats.init(r,s,n.$isChrome,n.$isFireFox),n.$isTouch){const t=function(e){e.target.removeEventListener(n.$TOUCH_END,t),n.$loadAudioData()};e.addEventListener(n.$TOUCH_END,t),e.addEventListener(n.$TOUCH_START,function(t){n.$event=t,n.$eventType=n.$TOUCH_START,this._$hitTest()}.bind(this)),e.addEventListener(n.$TOUCH_MOVE,function(t){n.$event=t,n.$eventType=n.$TOUCH_MOVE,this._$hitTest()}.bind(this)),e.addEventListener(n.$TOUCH_END,function(t){n.$event=t,n.$eventType=n.$TOUCH_END,this._$hitTest()}.bind(this))}else{const t=function(e){e.target.removeEventListener(n.$MOUSE_DOWN,t),n.$loadAudioData()};e.addEventListener(n.$MOUSE_DOWN,t),e.addEventListener(n.$MOUSE_DOWN,function(t){n.$event=t,n.$eventType=n.$MOUSE_DOWN,t.button||this._$hitTest()}.bind(this)),e.addEventListener(n.$DOUBLE_CLICK,function(t){n.$event=t,n.$eventType=n.$DOUBLE_CLICK,t.button||this._$hitTest()}.bind(this)),e.addEventListener(n.$MOUSE_LEAVE,function(t){n.$event=t,n.$eventType=n.$MOUSE_LEAVE,this._$hitTest(),n.$event=null,this._$stageX=-1,this._$stageY=-1}.bind(this)),e.addEventListener(n.$MOUSE_UP,function(t){n.$event=t,n.$eventType=n.$MOUSE_UP,t.button||this._$hitTest()}.bind(this)),e.addEventListener(n.$MOUSE_MOVE,function(t){n.$event=t,n.$eventType=n.$MOUSE_MOVE,this._$hitTest()}.bind(this)),e.addEventListener(n.$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!==n.$devicePixelRatio&&(a.transform=`scale(${1/n.$devicePixelRatio})`)}_$resize(){const t=n.$document.getElementById(this.contentElementId);if(t){const e=t.parentNode,i=this._$optionWidth?this._$optionWidth:"BODY"===e.tagName?n.$window.innerWidth:e.offsetWidth?e.offsetWidth:n.$parseFloat(e.style.width),r=this._$optionHeight?this._$optionHeight:"BODY"===e.tagName?n.$window.innerHeight:e.offsetHeight?e.offsetHeight:n.$parseFloat(e.style.height),a="BODY"===e.tagName?n.$window.innerWidth:e.offsetWidth,o=s.min(i/this._$baseWidth,r/this._$baseHeight);let h=this._$fullScreen?i:this._$baseWidth*o|0,l=this._$fullScreen?r:this._$baseHeight*o|0;const _=t.style;if(_.width=`${h}px`,_.height=`${l}px`,_.top="0",_.left=this._$fullScreen?"0":a/2-h/2+"px",h*=n.$devicePixelRatio,l*=n.$devicePixelRatio,this._$scale=o,this._$width=h,this._$height=l,this._$canvas.width=h,this._$canvas.height=l,this._$canvas.style.transform=1===this._$ratio&&1===n.$devicePixelRatio?"":`scale(${1/this._$ratio})`,this._$context){this._$context._$gl.viewport(0,0,h,l);const t=this._$context._$frameBufferManager;this._$buffer&&(t.unbind(),t.releaseAttachment(this._$buffer,!0)),this._$buffer=t.createCacheAttachment(h,l,!1),t._$stencilBufferPool._$maxWidth=h,t._$stencilBufferPool._$maxHeight=l,t._$textureManager._$maxWidth=h,t._$textureManager._$maxHeight=l,this._$context._$pbo._$maxWidth=h,this._$context._$pbo._$maxHeight=l}const $=this._$scale*this._$ratio;this._$matrix[0]=$,this._$matrix[3]=$,this._$fullScreen&&(this._$tx=(h-this._$baseWidth*o*n.$devicePixelRatio)/2,this._$ty=(l-this._$baseHeight*o*n.$devicePixelRatio)/2,this._$matrix[4]=this._$tx,this._$matrix[5]=this._$ty),t.children.length>1&&t.children[1].dispatchEvent(new n.$window.Event(`${n.$PREFIX}_blur`)),this._$stage._$doChanged(),this._$cacheStore.reset()}}getSamples(){switch(this._$quality){case H.HIGH:return n.$HIGH_SAMPLES;case H.MEDIUM:return n.$MEDIUM_SAMPLES;default:return n.$LOW_SAMPLES}}_$dispatchEvent(t){if(this._$broadcastEvents.size&&this._$broadcastEvents.has(t.type)){const e=this._$broadcastEvents.get(t.type).slice(0);t._$eventPhase=_.AT_TARGET;const i=e.length;for(let s=0;sthis._$fps&&(this._$startTime=e-i%this._$fps,this._$action(),this._$draw(0),!this._$hitTestStart&&"up"===this._$state&&n.$event&&this._$stageX>-1&&this._$stageY>-1&&this._$pointerCheck()),t.stats&&stats.end(),t.glstats&&glstats.end();const s=n.$requestAnimationFrame;this._$timerId=s(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,n.$hitContext.setTransform(1,0,0,1,0,0),n.$hitContext.beginPath(),n.$MATRIX_HIT_ARRAY_IDENTITY[4]=this._$tx/this._$scale/n.$devicePixelRatio,n.$MATRIX_HIT_ARRAY_IDENTITY[5]=this._$ty/this._$scale/n.$devicePixelRatio,this._$stage._$mouseHit(n.$hitContext,n.$MATRIX_HIT_ARRAY_IDENTITY,this._$hitObject,!0);let i=null,s=null,r=!1,a=!1;if(this._$hitObject.hit){if(i=this._$hitObject.hit,this._$mouseOverTarget&&this._$mouseOverTarget!==i){const t=this._$mouseOverTarget;t.willTrigger(d.MOUSE_OUT)&&t.dispatchEvent(new d(d.MOUSE_OUT,!0,!1,t.mouseX,t.mouseY))}if(this._$rollOverObject!==i){let r=null;if(this._$rollOverObject)for(s=this._$rollOverObject,s.willTrigger(d.ROLL_OUT)&&s.dispatchEvent(new d(d.ROLL_OUT,!1,!1,s.mouseX,s.mouseY)),r=s._$parent;r&&r._$root!==r&&r!==i;){if(r._$mouseEnabled&&r._$outCheck(t,e)){let t=!1,e=i;for(;e&&e._$root!==e;){if(e===r){t=!0;break}e=e._$parent}if(!t&&r._$parent===i._$parent&&r._$index>i._$index&&(t=!0),t)break}r.willTrigger(d.ROLL_OUT)&&r.dispatchEvent(new d(d.ROLL_OUT,!1,!1,r.mouseX,r.mouseY)),r=r._$parent}for(s=i;s.willTrigger(d.ROLL_OVER)&&s.dispatchEvent(new d(d.ROLL_OVER,!1,!1,s.mouseX,s.mouseY)),s=s._$parent,s&&s!==r&&s.stage!==s;);}switch(this._$rollOverObject=i,!0){case null===this._$mouseOverTarget:case this._$mouseOverTarget!==i:i.willTrigger(d.MOUSE_OVER)&&i.dispatchEvent(new d(d.MOUSE_OVER,!0,!1,i.mouseX,i.mouseY)),this._$mouseOverTarget=i}if("up"===this._$state&&(this._$clickTarget=null),!n.$isTouch&&"up"===this._$state)for(s=i;s&&s.root!==s;){switch(!0){case s instanceof nt:s._$type===at.INPUT&&(r=!0);break;case s.buttonMode:a=!0}if(r||a)break;s=s._$parent}}else{if(this._$mouseOverTarget&&(i=this._$mouseOverTarget,i.willTrigger(d.MOUSE_OUT)&&i.dispatchEvent(new d(d.MOUSE_OUT,!0,!1,i.mouseX,i.mouseY))),this._$rollOverObject)for(s=this._$rollOverObject;s&&s.root!==s;)s.willTrigger(d.ROLL_OUT)&&s.dispatchEvent(new d(d.ROLL_OUT,!1,!1,s.mouseX,s.mouseY)),s=s._$parent;this._$rollOverObject=null,this._$mouseOverTarget=null}switch(!0){case r:this._$canvas.style.cursor="text";break;case a:this._$canvas.style.cursor="pointer";break;case!n.$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(s._$bind(this._$buffer),n.$resetContext(s),s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e,i),s.beginPath(),this._$stage._$draw(s,this._$matrix,n.$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=s.frameBuffer.getTextureFromCurrentAttachment();s.frameBuffer.unbind(),n.$resetContext(s),s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e,i),s.drawImage(t,0,0,e,i),s._$bind(this._$buffer)}}_$doAction(){for(;this._$actions.length;){n.$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),s=i.length;for(let e=0;ee._$index&&(i=!0),i)break}t.willTrigger(d.ROLL_OUT)&&t.dispatchEvent(new d(d.ROLL_OUT,!1,!1,t.mouseX,t.mouseY)),t=t._$parent}for(i=e;i.willTrigger(d.ROLL_OVER)&&i.dispatchEvent(new d(d.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(d.MOUSE_OVER)&&e.dispatchEvent(new d(d.MOUSE_OVER,!0,!1,e.mouseX,e.mouseY)),this._$mouseOverTarget=e}"up"===this._$state&&(this._$clickTarget=null);break;case n.$TOUCH_START:case n.$MOUSE_DOWN:e!==this._$textField&&this._$textField instanceof nt&&(this._$textField.focus=!1,this._$textField=null),e instanceof nt&&(e.focus=!0,this._$textField=e),e.willTrigger(d.MOUSE_DOWN)&&e.dispatchEvent(new d(d.MOUSE_DOWN,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget=e;break;case n.$TOUCH_END:case n.$MOUSE_UP:e!==this._$textField&&this._$textField instanceof nt&&(this._$textField.focus=!1,this._$textField=null),e.willTrigger(d.MOUSE_UP)&&e.dispatchEvent(new d(d.MOUSE_UP,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget===e&&e.willTrigger(d.CLICK)&&e.dispatchEvent(new d(d.CLICK,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget=null;break;case n.$MOUSE_WHEEL:e.willTrigger(d.MOUSE_WHEEL)&&e.dispatchEvent(new d(d.MOUSE_WHEEL)),e instanceof nt&&(e.scrollV+=t.deltaY);break;case n.$DOUBLE_CLICK:e.willTrigger(d.DOUBLE_CLICK)&&e.dispatchEvent(new d(d.DOUBLE_CLICK))}if(!_&&!n.$isTouch&&"up"===this._$state)for(i=e;i&&i.root!==i;){if(i instanceof nt){if(i._$type===at.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!n.$isTouch&&"up"===this._$state:this._$canvas.style.cursor="auto"}!n.$actionProcess&&this._$actions.length>1&&this._$doAction(),n.$isUpdated&&(this._$stage._$prepareActions(),n.$actionProcess||this._$doAction()),this._$hitTestStart=!1}}n.$window.next2d=new class{constructor(){this._$player=new se}load(t,e=null){if("develop"===t){const e=n.$location.search.substr(1).split("&")[0];if(!e)return;t=`${n.$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 N,s=i.contentLoaderInfo;s.addEventListener(u.IO_ERROR,(function(t){t.target.removeEventListener(u.IO_ERROR,t.listener),alert("Error: "+t.message)})),s.addEventListener(h.COMPLETE,(function(t){const e=t.target;e.removeEventListener(h.COMPLETE,t.listener);const i=n.$currentPlayer(),s=i.stage,r=e._$data.stage;if(i.width=r.width,i.height=r.height,i.stage.frameRate=r.fps,null===i._$bgColor){const t=n.$intToRGBA(0|`0x${r.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]}s.addChild(e.content),i._$resize()})),i.load(new dt(t))}createRootMovieClip(t=240,e=240,i=24,s=null){const r=this._$player;return r._$loadStatus=se.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 A)}},n.$packages(n.$window.next2d),console.log("%c Next2D Player %c 1.5.3 %c https://next2d.app","color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")})(window); \ No newline at end of file +"next2d"in window||(t=>{"use strict";let e=0,i=0;const s=t.Math,r=t.Number,n=t.RegExp,a=t.Float32Array,o=t.Int16Array,h={$PREFIX:"__next2d__",$HIGH_SAMPLES:4,$MEDIUM_SAMPLES:2,$LOW_SAMPLES:0,$LOAD_START:"loadstart",$PROGRESS:"progress",$LOADEND:"loadend",$TOUCH_START:"touchstart",$TOUCH_MOVE:"touchmove",$TOUCH_END:"touchend",$MOUSE_DOWN:"mousedown",$MOUSE_MOVE:"mousemove",$MOUSE_UP:"mouseup",$MOUSE_WHEEL:"wheel",$DOUBLE_CLICK:"dblclick",$MOUSE_LEAVE:"mouseleave",$KEY_DOWN:"keydown",$KEY_UP:"keyup",$SCROLL:"scroll"};h.$P_TAG=t.document.createElement("p"),h.$COLOR_ARRAY_IDENTITY=new a([1,1,1,1,0,0,0,0]),h.$COLOR_MATRIX_FILTER=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],h.$soundMixerVolume=1,h.$bezierConverterBuffer=new Array(32),h.$window=t,h.$document=t.document,h.$navigator=t.navigator,h.$userAgent=t.navigator.userAgent,h.$location=t.location,h.$isNaN=t.isNaN,h.$Deg2Rad=s.PI/180,h.$Rad2Deg=180/s.PI,h.$Array=t.Array,h.$Map=t.Map,h.$Image=t.Image,h.$URL=t.URL,h.$Blob=t.Blob,h.$parseFloat=t.parseFloat,h.$setTimeout=t.setTimeout,h.$encodeURIComponent=t.encodeURIComponent,h.$Infinity=t.Infinity,h.$WebGLTexture=t.WebGLTexture,h.$clearTimeout=t.clearTimeout,h.$setTimeout=t.setTimeout,h.$audioContext=null,h.$CanvasRenderingContext2D=t.CanvasRenderingContext2D,h.$requestAnimationFrame=t.requestAnimationFrame,h.$cancelAnimationFrame=t.cancelAnimationFrame,h.$performance=t.performance,h.$variables=new Map,h.$loadedImages=new Map,h.$isUpdated=!1,h.$event=null,h.$dropTarget=null,h.$dragRules={lock:!1,position:{x:0,y:0},bounds:null},h.$rgbToLinearTable=new a(256),h.$rgbIdentityTable=new a(256);for(let t=0;t<256;++t)h.$rgbToLinearTable[t]=s.pow(t/255,2.23333333),h.$rgbIdentityTable[t]=t/255;h.$SHORT_INT_MIN=-32768,h.$SHORT_INT_MAX=32767,h.$devicePixelRatio=s.min(2,t.devicePixelRatio),h.$MATRIX_HIT_ARRAY_IDENTITY=new a([1,0,0,1,0,0]),h.$MATRIX_ARRAY_IDENTITY=new a([1,0,0,1,0,0]),h.$MATRIX_ARRAY_RATIO_0_0_RATIO_0_0=new Float32Array([h.$devicePixelRatio,0,0,h.$devicePixelRatio,0,0]),h.$bounds=[],h.$arrays=[],h.$audios=[],h.$maps=[],h.$preObjects=[],h.$matrices=[],h.$colors=[],h.$float32Array4=[],h.$float32Array6=[],h.$float32Array8=[],h.$float32Array9=[],h.$isAndroid=h.$userAgent.indexOf("Android")>-1,h.isiOS=h.$userAgent.indexOf("iPhone")>-1||h.$userAgent.indexOf("iPod")>-1,h.$isTouch=h.$isAndroid||h.isiOS,h.$isChrome=h.$userAgent.indexOf("Chrome")>-1,h.$isFireFox=h.$userAgent.indexOf("Firefox")>-1,h.$isSafari=-1===h.$userAgent.indexOf("Chrome")&&h.$userAgent.indexOf("Safari")>-1,h.$isEdge=h.$userAgent.indexOf("Edge")>-1,h.$isMac=h.$userAgent.indexOf("Mac")>-1,h.$isWindows=!1===h.$isMac,h.$currentLoaderInfo=null;const l=t.document.createElement("canvas");l.width=1,l.height=1,h.$hitContext=l.getContext("2d"),h.$hitContext.globalAlpha=0,h.$hitContext.imageSmoothingEnabled=!1;const _=t.document.createElement("canvas");_.width=1,_.height=1,h.$textContext=_.getContext("2d"),h.$hitContext.globalAlpha=0,h.$hitContext.imageSmoothingEnabled=!1,h.$DIV=null,h.$isArray=t=>h.$Array.isArray(t),h.$getArray=(...t)=>{const e=h.$arrays.pop()||[];return t.length&&e.push.apply(e,t),e},h.$poolArray=t=>{t.length&&(t.length=0),h.$arrays.push(t)},h.$clamp=(t,e,i,r=null)=>{const n=+t;return h.$isNaN(n)&&null!==r?r:s.min(s.max(e,h.$isNaN(n)?0:n),i)},h.$multiplicationColor=(t,e)=>h.$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]),h.$multiplicationMatrix=(t,e)=>h.$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]),h.$getBoundsObject=(t=0,e=0,i=0,s=0)=>{const r=h.$bounds.pop()||{xMin:0,xMax:0,yMin:0,yMax:0};return r.xMin=t,r.xMax=e,r.yMin=i,r.yMax=s,r},h.$poolBoundsObject=t=>{h.$bounds.push(t)},h.$poolMap=t=>{t.size&&t.clear(),h.$maps.push(t)},h.$getMap=()=>h.$maps.pop()||new h.$Map,h.$getFloat32Array4=(t=0,e=0,i=0,s=0)=>{const r=h.$float32Array4.pop()||new a(4);return r[0]=t,r[1]=e,r[2]=i,r[3]=s,r},h.$poolFloat32Array4=t=>{h.$float32Array4.push(t)},h.$getFloat32Array6=(t=0,e=0,i=0,s=0,r=0,n=0)=>{const o=h.$float32Array6.pop()||new a(6);return o[0]=t,o[1]=e,o[2]=i,o[3]=s,o[4]=r,o[5]=n,o},h.$poolFloat32Array6=t=>{h.$float32Array6.push(t)},h.$getFloat32Array8=(t=1,e=1,i=1,s=1,r=0,n=0,o=0,l=0)=>{const _=h.$float32Array8.pop()||new a(8);return _[0]=t,_[1]=e,_[2]=i,_[3]=s,_[4]=r,_[5]=n,_[6]=o,_[7]=l,_},h.$poolFloat32Array8=t=>{h.$float32Array8.push(t)},h.$getFloat32Array9=(t=0,e=0,i=0,s=0,r=0,n=0,o=0,l=0,_=0)=>{const $=h.$float32Array9.pop()||new a(9);return $[0]=t,$[1]=e,$[2]=i,$[3]=s,$[4]=r,$[5]=n,$[6]=o,$[7]=l,$[8]=_,$},h.$poolFloat32Array9=t=>{h.$float32Array9.push(t)},h.$currentPlayer=()=>t.next2d._$player,h.$currentMousePoint=()=>{const t=h.$currentPlayer();let e=h.$window.pageXOffset,i=h.$window.pageYOffset;const s=h.$document.getElementById(t.contentElementId);if(s){const t=s.getBoundingClientRect();e+=t.left,i+=t.top}let r=h.$event.pageX,n=h.$event.pageY;if(h.$isTouch){const t=h.$event.changedTouches[0];r=t.pageX,n=t.pageY}const a=(r-e)/t._$scale|0,o=(n-i)/t._$scale|0;return new v(a,o)},h.$boundsMatrix=(t,e)=>{const i=t.xMax*e[0]+t.yMax*e[2]+e[4],n=t.xMax*e[0]+t.yMin*e[2]+e[4],a=t.xMin*e[0]+t.yMax*e[2]+e[4],o=t.xMin*e[0]+t.yMin*e[2]+e[4],l=t.xMax*e[1]+t.yMax*e[3]+e[5],_=t.xMax*e[1]+t.yMin*e[3]+e[5],$=t.xMin*e[1]+t.yMax*e[3]+e[5],c=t.xMin*e[1]+t.yMin*e[3]+e[5],u=s.min(r.MAX_VALUE,i,n,a,o),d=s.max(-r.MAX_VALUE,i,n,a,o),g=s.min(r.MAX_VALUE,l,_,$,c),f=s.max(-r.MAX_VALUE,l,_,$,c);return h.$getBoundsObject(u,d,g,f)},h.$upperPowerOfTwo=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t),h.$getMatrix=(t=1,e=0,i=0,s=1,r=0,n=0)=>{if(!h.$matrices.length)return new T(t,e,i,s,r,n);const a=h.$matrices.pop();return a._$matrix=h.$getFloat32Array6(t,e,i,s,r,n),a},h.$poolMatrix=t=>{h.$poolFloat32Array6(t._$matrix),t._$matrix=null,h.$matrices.push(t)},h.$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}},h.$getColorTransform=(t=1,e=1,i=1,s=1,r=0,n=0,a=0,o=0)=>{if(!h.$colors.length)return new b(t,e,i,s,r,n,a,o);const l=h.$colors.pop();return l._$colorTransform=h.$getFloat32Array8(t,e,i,s,r,n,a,o),l},h.$poolColorTransform=t=>{h.$poolFloat32Array8(t._$colorTransform),t._$colorTransform=null,h.$colors.push(t)},h.$toColorInt=t=>h.$isNaN(+t)?h.$colorStringToInt(t):+t,h.$colorStringToInt=t=>{h.$hitContext.fillStyle=t;const e=h.$hitContext.fillStyle.substr(1);return h.$hitContext.fillStyle="rgba(0, 0, 0, 1)",0|`0x${e}`},h.$intToR=(t,e,i)=>(t>>16)*(i?e:1)/255,h.$intToG=(t,e,i)=>(t>>8&255)*(i?e:1)/255,h.$intToB=(t,e,i)=>(255&t)*(i?e:1)/255,h.$uintToRGBA=t=>({A:t>>>24,R:(16711680&t)>>16,G:(65280&t)>>8,B:255&t}),h.$intToRGBA=(t,e=1)=>({R:(16711680&t)>>16,G:(65280&t)>>8,B:255&t,A:255*e}),h.$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}),h.$cacheStore=()=>h.$currentPlayer()._$cacheStore,h.$inverseMatrix=t=>{const e=1/(t[0]*t[4]-t[3]*t[1]),i=t[3]*t[7]-t[4]*t[6],s=t[1]*t[6]-t[0]*t[7];return h.$getFloat32Array9(t[4]*e,-t[1]*e,0,-t[3]*e,t[0]*e,0,i*e,s*e,1)},h.$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&&h.$audioContext.decodeAudioData(t.buffer.subarray(e),h.$decodeAudioSuccess.bind(this))},h.$decodeAudioSuccess=function(t){this._$character?(this._$character.buffer=null,this._$character.audioBuffer=t):(this._$buffer=null,this._$audioBuffer=t)},h.$decodeAudioData=t=>{const e=t._$character?t._$character.buffer:t._$buffer;e&&h.$audioContext.decodeAudioData(e.buffer,h.$decodeAudioSuccess.bind(t),h.$decodeAudioFailed.bind(t))},h.$loadAudioData=()=>{if(h.$audioContext||(h.$audioContext=new h.$window.AudioContext,h.$audioContext.resume()),h.$audioContext){const t=h.$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,h.$resizeTimerId=0,h.$resize=()=>{(0,h.$clearTimeout)(h.$resizeTimerId);const t=h.$setTimeout;h.$resizeTimerId=t(h.$resizeExecute,300)},h.$resizeExecute=()=>{const t=h.$currentPlayer();if(t._$loadStatus===ae.LOAD_END){t._$resize();const e=t._$stage;e.willTrigger($.RESIZE)&&e.dispatchEvent(new $($.RESIZE))}},h.$window.addEventListener("resize",h.$resize),h.$resetContext=t=>{const e=t._$contextStyle;switch(e._$fillStyle.constructor){case Ut:case kt:e._$fillStyle=h.$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 Ut:case kt:e._$strokeStyle=h.$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=I.NORMAL,t._$imageSmoothingEnabled=!1},h.$getPreObject=()=>h.$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},h.$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,h.$preObjects.push(t)},h.$cross=(t,e,i,s)=>t*s-i*e,h.$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,l=-819.2*t[1]+819.2*t[3]+t[5]-n;const _=s.sqrt(o*o+l*l);_?(o/=_,l/=_):(o=0,l=0);const $=(i-e)*o+(a-n)*l;return h.$getArray(e+$*o,n+$*l,i,a)},h.$ajax=(t=null)=>{t||(t={method:"GET"}),"method"in t||(t.method="GET");let e=null;switch(t.method.toUpperCase()){case xt.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 xt.PUT:case xt.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),s=e.length;for(let r=0;r{const e=h.$getArray();if(t){const i=t.trim().split("\n"),s=i.length;for(let t=0;t{const e=t.split(".");let i=h.$window;for(let t=0;t{throw new Error("image encoding error")}))}else h.$imageWorkerActive=!1},h.$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:w,BitmapDataChannel:O,BlendMode:I,CapsStyle:B,DisplayObject:A,DisplayObjectContainer:C,FrameLabel:F,GradientType:L,Graphics:P,GraphicsGradientFill:N,InteractiveObject:M,InterpolationMethod:U,JointStyle:k,Loader:G,LoaderInfo:X,MovieClip:R,Shape:H,SpreadMethod:Y,Sprite:S,Stage:j},t.events={Event:$,EventDispatcher:c,EventPhase:u,FocusEvent:d,HTTPStatusEvent:g,IOErrorEvent:f,MouseEvent:p,ProgressEvent:m,VideoEvent:x},t.filters={BevelFilter:J,BitmapFilterQuality:q,BitmapFilterType:W,BlurFilter:Q,ColorMatrixFilter:Z,ConvolutionFilter:tt,DisplacementMapFilter:et,DisplacementMapFilterMode:K,DropShadowFilter:it,GlowFilter:st,GradientBevelFilter:rt,GradientGlowFilter:nt},t.geom={ColorTransform:b,Matrix:T,Point:v,Rectangle:y,Transform:E},t.media={Sound:ct,SoundMixer:ut,SoundTransform:dt,Video:gt},t.net={URLLoaderDataFormat:ft,URLRequest:pt,URLRequestHeader:mt,URLRequestMethod:xt},t.text={TextField:ht,TextFieldAutoSize:ot,TextFieldType:lt,TextFormat:_t,TextFormatAlign:at,TextFormatVerticalAlign:$t},t.ui={Easing:bt,Job:Tt,Tween:vt}};class ${constructor(t,e=!1,i=!1){this._$type=`${t}`,this._$bubbles=!!e,this._$cancelable=!!i,this._$target=null,this._$currentTarget=null,this._$eventPhase=u.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 y(e,i,r,n):new y(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 y(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 E{constructor(t){if(!(t instanceof A))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 b;return i._$colorTransform=h.$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 b&&this._$transform(null,t._$colorTransform)}get concatenatedColorTransform(){let t=this._$rawColorTransform(),e=this._$displayObject._$parent;for(;e;)t=h.$multiplicationColor(e._$transform._$rawColorTransform(),t),e=e._$parent;return h.$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 h.$getMatrix(e[0],e[1],e[2],e[3],e[4],e[5])}return this._$transform(),this._$matrix._$clone()}set matrix(t){t instanceof T&&this._$transform(t._$matrix,null)}get concatenatedMatrix(){let t=this._$rawMatrix(),e=this._$displayObject._$parent;for(;e;)t=h.$multiplicationMatrix(e._$transform._$rawMatrix(),t),e=e._$parent;return h.$getMatrix(t[0],t[1],t[2],t[3],t[4],t[5])}pixelBounds(){const t=new y(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),h.$poolBoundsObject(e),t}_$rawMatrix(){if(null!==this._$matrix)return this._$matrix._$matrix;const t=this._$displayObject._$getPlaceObject();return t?t.matrix:h.$MATRIX_ARRAY_IDENTITY}_$rawColorTransform(){if(null!==this._$colorTransform)return this._$colorTransform._$colorTransform;const t=this._$displayObject._$getPlaceObject();return t?t.colorTransform:h.$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(),h.$isUpdated=!0),this._$matrix||(this._$matrix=h.$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(),h.$isUpdated=!0),this._$colorTransform||(this._$colorTransform=h.$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(h.$isArray(t))return this._$filters&&h.$poolArray(this._$filters),this._$filters=t.slice(0),this._$displayObject._$doChanged(),void(h.$isUpdated=!0);if(!this._$filters)if(e){if(e.filters)this._$filters=e.filters.slice(0);else if(e.surfaceFilterList){const t=h.$getArray(),i=e.surfaceFilterList.length;for(let s=0;s-1){const e=this.rotation?h.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()):this._$getBounds(null),i=s.abs(e.yMax-e.yMin);switch(h.$poolBoundsObject(e),i){case 0:case h.$Infinity:case-h.$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 A&&(t._$isMask=!0,this._$mask=t),this._$doChanged())}get mouseX(){return h.$event?this.globalToLocal(h.$currentMousePoint()).x:0}get mouseY(){return h.$event?this.globalToLocal(h.$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||h.$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,h.$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||h.$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,h.$poolMatrix(i)}get stage(){if(this._$stage)return this._$stage;const t=this._$parent;return t?t instanceof j?t:t._$stage:null}get transform(){return this._$transform}set transform(t){t instanceof E&&(this._$transform=t)}get visible(){return this._$visible}set visible(t){t=!!t,this._$visible!==t&&(this._$doChanged(),h.$isUpdated=!0),this._$visible=!!t}get width(){const t=h.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()),e=s.abs(t.xMax-t.xMin);switch(h.$poolBoundsObject(t),!0){case 0===e:case e===h.$Infinity:case e===-h.$Infinity:return 0;default:return e}}set width(t){if(t=+t,!h.$isNaN(t)&&t>-1){const e=this.rotation?h.$boundsMatrix(this._$getBounds(null),this._$transform._$rawMatrix()):this._$getBounds(null),i=s.abs(e.xMax-e.xMin);switch(h.$poolBoundsObject(e),!0){case 0===i:case i===h.$Infinity:case i===-h.$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,h.$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,h.$poolMatrix(i)}getBounds(t=null){const e=this._$getBounds(null),i=this._$transform.concatenatedMatrix,r=h.$boundsMatrix(e,i._$matrix);h.$poolMatrix(i),h.$poolBoundsObject(e);const n=h.$getBoundsObject(r.xMin,r.xMax,r.yMin,r.yMax);h.$poolBoundsObject(r),t||(t=this);const a=t._$transform.concatenatedMatrix;a.invert();const o=h.$boundsMatrix(n,a._$matrix),l=o.xMin,_=o.yMin,$=o.xMax,c=o.yMax;return h.$poolBoundsObject(n),h.$poolBoundsObject(o),h.$poolMatrix(a),new y(l,_,s.abs($-l),s.abs(c-_))}globalToLocal(t){const e=this._$transform.concatenatedMatrix;e.invert();const i=new v(t.x*e.a+t.y*e.c+e.tx,t.x*e.b+t.y*e.d+e.ty);return h.$poolMatrix(e),i}hitTestObject(t){const e=this._$getBounds(null),i=this._$transform.concatenatedMatrix,r=h.$boundsMatrix(e,i._$matrix);h.$poolMatrix(i),h.$poolBoundsObject(e);const n=t._$getBounds(null),a=t._$transform.concatenatedMatrix,o=h.$boundsMatrix(n,a._$matrix);h.$poolMatrix(a),h.$poolBoundsObject(n);const l=s.max(r.xMin,o.xMin),_=s.max(r.yMin,o.yMin),$=s.min(r.xMax,o.xMax),c=s.min(r.yMax,o.yMax);return h.$poolBoundsObject(r),h.$poolBoundsObject(o),$-l>=0&&c-_>=0}hitTestPoint(t,e,i=!1){if(i){let i=h.$MATRIX_ARRAY_IDENTITY,s=this._$parent;for(;s;)i=h.$multiplicationMatrix(s._$transform._$rawMatrix(),i),s=s._$parent;h.$hitContext.setTransform(1,0,0,1,0,0),h.$hitContext.beginPath();const r=this._$hit(h.$hitContext,i,{x:t,y:e},!0);return h.$poolFloat32Array6(i),r}const s=this._$getBounds(null),r=h.$boundsMatrix(s,this._$transform._$rawMatrix()),n=r.xMin,a=r.yMin,o=r.xMax-r.xMin,l=r.yMax-r.yMin,_=this._$parent?this._$parent.globalToLocal(new v(t,e)):new v(t,e);return h.$poolBoundsObject(r),h.$poolBoundsObject(s),new y(n,a,o,l).containsPoint(_)}localToGlobal(t){const e=this._$transform.concatenatedMatrix,i=new v(t.x*e.a+t.y*e.c+e.tx,t.x*e.b+t.y*e.d+e.ty);return h.$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=h.$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||(h.$poolMap(this._$variables),this._$variables=null))}getGlobalVariable(t){return h.$variables.has(t)?h.$variables.get(t):null}setGlobalVariable(t,e){h.$variables.set(t,e)}hasGlobalVariable(t){return h.$variables.has(t)}deleteGlobalVariable(t){h.$variables.has(t)&&h.$variables.delete(t)}clearGlobalVariable(){return h.$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||h.$currentLoaderInfo),!e)return null;const i=e._$data.symbols.get(this.namespace),s=e._$data.characters[i];return this._$characterId=i,this._$loaderInfo=e,s}_$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()}_$drawFilter(t,e,i,s,r,n){const a=[this._$instanceId,"f"];let o=h.$cacheStore().get(a);const l=this._$isFilterUpdated(r,n,i,s,!0);let _;return o&&!l||(o&&(h.$cacheStore().set(a,null),o.layerWidth=0,o.layerHeight=0,o._$offsetX=0,o._$offsetY=0,o.matrix=null,o.colorTransform=null,t.frameBuffer.releaseTexture(o),o=null),_=this._$applyFilter(t,s,e,i,r,n),h.$cacheStore().set(a,_)),o&&(_=o),_}_$getLayerBounds(t=null){const e=this._$getBounds(t);if(!t)return e;const i=this._$filters||this.filters,s=i.length;if(!s)return e;let r=new y(e.xMin,e.yMin,e.xMax-e.xMin,e.yMax-e.yMin);h.$poolBoundsObject(e);for(let t=0;t0||o!==I.NORMAL){const e=this._$getBounds(null),l=h.$boundsMatrix(e,r),_=+l.xMax,$=+l.xMin,c=+l.yMax,u=+l.yMin;h.$poolBoundsObject(e),h.$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;n.basePosition.x=i[4],n.basePosition.y=i[5];let p=this._$getLayerBounds(null);const m=h.$boundsMatrix(p,r);let x=s.abs(m.xMax-m.xMin),b=s.abs(m.yMax-m.yMin);h.$poolBoundsObject(m),x===d&&b===g&&(h.$poolBoundsObject(p),p=null);let T=r[4]-s.floor($),v=r[5]-s.floor(u),y=null;if(p){const t=h.$getFloat32Array6(r[0],r[1],r[2],r[3],0,0);y=h.$boundsMatrix(p,t),h.$poolBoundsObject(p),h.$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)-(r[4]-E),A-=-s.floor(y.yMin)-(r[5]-A),M-=-y.xMin-(r[4]-M),C-=-y.yMin-(r[5]-C),h.$poolBoundsObject(y)),n.position.dx=E>0?E:0,n.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 h.$poolPreObject(n),!1;t._$startLayer(h.$getBoundsObject(M,0,C,0)),n.canApply=this._$canApply(a);let S=this._$isFilterUpdated(x,b,r,a,n.canApply,n.basePosition.x,n.basePosition.y);const R=t._$cacheCurrentBuffer;t._$cacheCurrentBuffer=null;const w=t._$cacheCurrentBounds,O=h.$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)),n.isFilter=!0,n.isUpdated=S,n.color=h.$getFloat32Array8(),n.baseMatrix=r,n.currentAttachment=f,n.currentMaskBuffer=R,n.currentMaskBounds=O,n.filters=a,n.blendMode=o,n.layerWidth=x,n.layerHeight=b,n.matrix=h.$getFloat32Array6(r[0],r[1],r[2],r[3],T,v)}return n}_$postDraw(t,e,i,s){const r=[this._$instanceId,"f"];let n=null;if(this._$buffer){n=t.frameBuffer.getTextureFromCurrentAttachment();const e=h.$cacheStore().get(r);e&&(h.$cacheStore().set(r,null),t.frameBuffer.releaseTexture(e))}else n=h.$cacheStore().get(r);s.canApply||(n._$offsetX=0,n._$offsetY=0);let a=n._$offsetX,o=n._$offsetY;if(s.isUpdated&&s.canApply){let i=h.$cacheStore().get(r);i&&(h.$cacheStore().set(r,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=s.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 A))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 A))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 A))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 A&&e instanceof A))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=h.$MATRIX_ARRAY_IDENTITY;if(t){e=t;const i=this._$transform._$rawMatrix();i!==h.$MATRIX_ARRAY_IDENTITY&&(e=h.$multiplicationMatrix(t,i))}const i=this._$graphics&&this._$graphics._$getBounds(),n=this._$needsChildren?this._$getChildren():this._$children,a=n.length;if(!a&&!i){const i=h.$getBoundsObject(e[4],-e[4],e[5],-e[5]);return t&&e!==t&&h.$poolFloat32Array6(e),i}const o=r.MAX_VALUE;let l=o,_=-o,$=o,c=-o;if(i){const t=h.$boundsMatrix(this._$graphics._$getBounds(),e);l=t.xMin,_=t.xMax,$=t.yMin,c=t.yMax,h.$poolBoundsObject(t)}for(let t=0;tt){if(i._$filters=null,i._$blendMode=null,-1===i._$id){a.push(i),i._$name&&this._$names.set(i._$name,i);continue}const t=e[n];if(i._$id===t){i._$placeId=n,a.push(i),i._$name&&this._$names.set(i._$name,i),r.has(t)&&r.delete(t),s.set(t,!0),n++;continue}r.set(i._$id,i)}else i.willTrigger($.REMOVED)&&i.dispatchEvent(new $($.REMOVED,!0)),i.willTrigger($.REMOVED_FROM_STAGE)&&i.dispatchEvent(new $($.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 C&&(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 s=this._$transform._$rawMatrix();s!==h.$MATRIX_ARRAY_IDENTITY&&(i=h.$multiplicationMatrix(e,s)),this._$graphics&&this._$graphics._$getBounds()&&this._$graphics._$clip(t,i);const r=this._$getChildren(),n=r.length;for(let e=0;eu||i._$clipDepth>0)&&(t.restore(),c&&(t._$leaveClip(),d.length&&(h.$poolFloat32Array6(_),_=d.pop())),u=f.length?f.pop():null,c=p.pop()),!c)continue;if(i._$clipDepth>0){if(t.save(),u&&f.push(u),p.push(c),u=i._$clipDepth,c=i._$shouldClip(_),c){const e=i._$startClip(t,_);if(!1===e){c=!1;continue}e&&(d.push(_),_=e)}continue}const n=i._$mask;if(n){let e;if(n._$updated=!1,this===n._$parent)e=_;else{e=h.$MATRIX_ARRAY_IDENTITY;let i=n._$parent;for(;i;)e=h.$multiplicationMatrix(i._$transform._$rawMatrix(),e),i=i._$parent;const s=this.stage._$player,r=s._$scale*s._$ratio/20,a=h.$getFloat32Array6(r,0,0,r,0,0);if(e=h.$multiplicationMatrix(a,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(g.push(_),this!==n._$parent){const e=this._$transform._$rawMatrix();i[0]=s.abs(_[0])*s.sign(e[0]),i[1]=s.abs(_[1])*s.sign(e[1]),i[2]=s.abs(_[2])*s.sign(e[2]),i[3]=s.abs(_[3])*s.sign(e[3]),i[4]=_[4]-t._$cacheCurrentBounds.x,i[5]=_[5]-t._$cacheCurrentBounds.y}_=i}}i._$draw(t,_,$),i._$updated=!1,n&&(t.restore(),t._$leaveClip(),g.length&&(h.$poolFloat32Array6(_),_=g.pop()))}if(u&&(t.restore(),p.pop()&&t._$leaveClip()),h.$poolArray(d),h.$poolArray(g),h.$poolArray(f),h.$poolArray(p),l.isFilter)return this._$postDraw(t,e,r,l);h.$poolFloat32Array6(_),h.$poolPreObject(l)}_$mouseHit(t,e,i,r=!0){let n=e;const a=this._$transform._$rawMatrix();a!==h.$MATRIX_ARRAY_IDENTITY&&(n=h.$multiplicationMatrix(e,a));const o=this._$getChildren(),l=h.$getArray(),_=h.$getArray(),$=h.$getMap();let c=o.length,u=null,d=null;for(let t=0;tu&&(d=null,u=null),null!==d&&$.set(e._$instanceId,d),_.push(e)))}const g=s.min(this._$mouseChildren,r);let f=!1;const p=this._$root===this;c=_.length;for(let e=0;e-1;--e){const n=a[e];if(!n._$isMask&&n._$hit(t,r,i,s))return!0}let o=!1;return this._$graphics&&(o=this._$graphics._$hit(t,r,i)),r!==e&&h.$poolFloat32Array6(r),o}_$createInstance(t){const e=this._$dictionary[t],i=this._$loaderInfo._$data.characters[e.characterId];i.class||(i.class=i.symbol&&h.$getClass(i.symbol)||h.$getClass(i.extends)),h.$currentLoaderInfo=null;const s=new i.class;return s._$build(e,this),s._$id=t,s}_$outCheck(t,e){let i=h.$MATRIX_ARRAY_IDENTITY,s=this._$parent;for(;s;)i=h.$multiplicationMatrix(s._$transform._$rawMatrix(),i),s=s._$parent;return h.$hitContext.setTransform(1,0,0,1,0,0),h.$hitContext.beginPath(),this._$mouseHit(h.$hitContext,i,{x:t,y:e})}}class S extends C{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 h.$dropTarget}get graphics(){return this._$graphics||(this._$graphics=new P,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 S&&(this._$hitArea=t,t._$hitObject=this)}get soundTransform(){return this._$soundTransform||(this._$soundTransform=new dt),this._$soundTransform}set soundTransform(t){t instanceof dt&&(this._$soundTransform=t)}get useHandCursor(){return this._$useHandCursor}set useHandCursor(t){this._$useHandCursor=!!t}startDrag(t=!1,e=null){let i=0,s=0;if(!t){const t=this._$dragMousePoint();i=this.x-t.x,s=this.y-t.y}h.$dropTarget=this,h.$dragRules.lock=t,h.$dragRules.position.x=i,h.$dragRules.position.y=s,h.$dragRules.bounds=e}stopDrag(){h.$dropTarget=null,h.$dragRules.lock=!1,h.$dragRules.position.x=0,h.$dragRules.position.y=0,h.$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(h.$currentMousePoint()):this.globalToLocal(h.$currentMousePoint())}}class R extends S{constructor(){super(),this._$stopFlag=!1,this._$canAction=!0,this._$childRemove=!1,this._$canSound=!0,this._$actionProcess=!1,this._$actions=h.$getMap(),this._$frameCache=h.$getMap(),this._$labels=null,this._$sounds=h.$getMap(),this._$channels=h.$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?h.$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=h.$getMap()),t instanceof F&&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=h.$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,h.$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($.FRAME_LABEL)&&e.dispatchEvent(new $($.FRAME_LABEL))}if(this._$actions.size&&this._$actions.has(t)){const t=h.$currentPlayer();if(t){-1===t._$actions.indexOf(this)&&t._$actions.push(this)}}}}_$goToFrame(t){if(h.$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=h.$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 s=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&&(s>-1||!e._$actionOffset))for(;e._$actions.length&&e._$actions.length!==s;){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 s=t._$actions.get(i),r=s.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 s=e._$actions.get(i),r=s.length;for(let t=0;t-1;--e)t[e]._$prepareActions();this._$setAction()}_$draw(t,e,i){super._$draw(t,e,i);const s=h.$currentPlayer();this._$canSound&&this._$sounds.size&&this._$sounds.has(this._$currentFrame)&&!s._$sounds.has(this._$instanceId)&&s._$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=h.$getArray()),this._$fills[2]===this._$fills[this._$fills.length-2]&&this._$fills[3]===this._$fills[this._$fills.length-1]||this._$fills.push(P.LINE_TO,this._$fills[2],this._$fills[3]),this._$recode.push.apply(this._$recode,this._$fills),this._$fillType){case P.FILL_STYLE:this._$recode.push(this._$fillType,this._$fillStyleR,this._$fillStyleG,this._$fillStyleB,this._$fillStyleA,P.END_FILL);break;case P.GRADIENT_FILL:this._$recode.push(this._$fillType),this._$recode.push.apply(this._$recode,this._$fillGradient.toArray());break;case P.BITMAP_FILL:this._$recode.push(this._$fillType),this._$recode.push.apply(this._$recode,this._$fillBitmap.toArray())}return this._$fills&&(h.$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=h.$getArray()),this._$recode.push.apply(this._$recode,this._$lines),h.$poolArray(this._$lines),this._$lines=null,this._$lineType){case P.STROKE_STYLE:this._$recode.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,this._$lineStyleR,this._$lineStyleG,this._$lineStyleB,this._$lineStyleA,P.END_STROKE);break;case P.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 P.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=B.NONE,this._$joints=k.ROUND,this._$miterLimit=0,this._$doLine=!1,this._$restart(),this}lineBitmapStyle(t,e=null,i=!0,s=!1){return this._$doLine&&this.endLine(),this._$lines||(this._$lines=h.$getArray()),this._$maxAlpha=1,this._$doLine=!0,this._$canDraw=!0,this._$lines.push(P.BEGIN_PATH),this._$lineType=P.BITMAP_STROKE,this._$fillBitmap=new D(t,e,i,s),this}lineGradientStyle(t,e,i,r,n=null,a=Y.PAD,o=U.RGB,l=0){if(!this._$doLine)return this;this._$lines||(this._$lines=h.$getArray());const _=i.length;for(let t=0;t<_;++t)this._$maxAlpha=s.max(this._$maxAlpha,i[t]);return this._$lines.push(P.BEGIN_PATH),this._$lineType=P.GRADIENT_STROKE,this._$lineGradient=new N(t,e,i,r,n,a,o,l),this}lineStyle(t=1,e=0,i=1,r=B.ROUND,n=k.ROUND,a=3){this._$doLine&&this.endLine(),this._$lines||(this._$lines=h.$getArray()),e=h.$clamp(h.$toColorInt(e),0,16777215,0),i=h.$clamp(+i,0,1,1),this._$maxAlpha=s.max(this._$maxAlpha,i),this._$doLine=!0,this._$canDraw=!0,this._$lines.push(P.BEGIN_PATH,P.MOVE_TO,this._$pointerX,this._$pointerY);const o=h.$intToRGBA(e,i);return this._$lineType=P.STROKE_STYLE,this._$lineStyleR=o.R,this._$lineStyleG=o.G,this._$lineStyleB=o.B,this._$lineStyleA=o.A,this._$lineWidth=t,this._$caps=`${r}`,this._$joints=`${n}`,this._$joints===k.MITER&&(this._$miterLimit=a),this}lineTo(t,e){return t=+t||0,e=+e||0,this._$pointerX===t&&this._$pointerY===e||(this._$setBounds(t,e),this._$margePath(h.$getArray(P.LINE_TO,t,e)),this._$pointerX=t,this._$pointerY=e,this._$restart()),this}moveTo(t,e){return t=+t||0,e=+e||0,this._$pointerX=t,this._$pointerY=e,this._$setBounds(t,e),this._$margePath(h.$getArray(P.MOVE_TO,t,e)),this._$restart(),this}_$clip(t,e){const i=this._$getBounds(),r=h.$boundsMatrix(i,e);let n=s.ceil(s.abs(r.xMax-r.xMin)),a=s.ceil(s.abs(r.yMax-r.yMin));switch(h.$poolBoundsObject(i),h.$poolBoundsObject(r),!0){case 0===n:case 0===a:case n===-h.$Infinity:case a===-h.$Infinity:case n===h.$Infinity:case a===h.$Infinity:return}h.$resetContext(t),t.setTransform(e[0],e[1],e[2],e[3],e[4],e[5]),this._$doDraw(t,h.$COLOR_ARRAY_IDENTITY,!0),t.clip()}_$drawBitmap(t,e,i,r=I.NORMAL,n=null){if(!this._$maxAlpha)return;const a=h.$clamp(i[3]+i[7]/255,0,1),o=this._$displayObject;let l=e;const _=o._$transform._$rawMatrix();_!==h.$MATRIX_ARRAY_IDENTITY&&(l=h.$multiplicationMatrix(e,_));const $=this._$getBounds(),c=h.$boundsMatrix($,l),u=c.xMax,d=c.xMin,g=c.yMax,f=c.yMin;h.$poolBoundsObject(c),h.$poolBoundsObject($);let p=s.ceil(s.abs(u-d)),m=s.ceil(s.abs(g-f));switch(!0){case 0===p:case 0===m:case p===-h.$Infinity:case m===-h.$Infinity:case p===h.$Infinity:case m===h.$Infinity:return}const x=t.frameBuffer.currentAttachment;if(d>x.width||f>x.height)return;const b=s.sqrt(l[0]*l[0]+l[1]*l[1]),T=s.sqrt(l[2]*l[2]+l[3]*l[3]);if(0>d+p||0>f+m){if(!(n&&n.length&&o._$canApply(n)))return;{let t=new y(0,0,p,m);for(let e=0;et.x+t.width||0>t.y+t.height)return}}const v=h.$getArray(l[0],l[1],l[2],l[3]),E=h.$cacheStore().generateKeys(o._$instanceId,v,i);h.$poolArray(v);let A=h.$cacheStore().get(E);if(!A){const s=t._$textureScale(p,m);s<1&&(p*=s,m*=s);const r=t.frameBuffer.createCacheAttachment(p,m,!0);t._$bind(r),h.$resetContext(t),i[3]=1;const n=p/2,a=m/2,o=h.$devicePixelRatio,l=h.$getFloat32Array6(1/o,0,0,1/o),$=h.$getFloat32Array6(e[0],e[1],e[2],e[3],0,0),c=h.$multiplicationMatrix(l,$);h.$poolFloat32Array6(l),h.$poolFloat32Array6($);const u=h.$getFloat32Array6(1,0,0,1,-n,-a),d=h.$multiplicationMatrix(c,u);h.$poolFloat32Array6(c),h.$poolFloat32Array6(u),h.$resetContext(t),t.setTransform(e[0],e[1],e[2],e[3],d[4]+n,d[5]+a),h.$poolFloat32Array6(d),t.beginPath(),this._$runTransformCommand(t,_,i),A=t.frameBuffer.getTextureFromCurrentAttachment(),h.$cacheStore().set(E,A),t.frameBuffer.releaseAttachment(r,!1),t._$bind(x)}if(h.$poolArray(E),n&&n.length&&o._$canApply(n)){const s=o._$drawFilter(t,A,e,n,p,m);h.$resetContext(t),t._$globalAlpha=a,t._$imageSmoothingEnabled=!0,t._$globalCompositeOperation=r,t.setTransform(1,0,0,1,d-s._$offsetX,f-s._$offsetY),t.drawImage(s,0,0,s.width,s.height,i)}else h.$resetContext(t),t._$globalAlpha=a,t._$imageSmoothingEnabled=!0,t._$globalCompositeOperation=r,t.setTransform(1,0,0,1,0,0),t.drawImage(A,d,f,p,m,i);l!==e&&h.$poolFloat32Array6(l)}_$draw(t,e,i,n=I.NORMAL,a=null){if(!this._$maxAlpha)return;const o=h.$clamp(i[3]+i[7]/255,0,1),l=this._$displayObject;let _=null!==l._$scale9Grid,$=null;_&&($=l._$transform._$rawMatrix(),_=_&&s.abs($[1])<.001&&s.abs($[2])<1e-4);const c=this._$getBounds(),u=h.$boundsMatrix(c,e),d=u.xMax,g=u.xMin,f=u.yMax,p=u.yMin;h.$poolBoundsObject(u);let m=s.ceil(s.abs(d-g)),x=s.ceil(s.abs(f-p));switch(!0){case 0===m:case 0===x:case m===-h.$Infinity:case x===-h.$Infinity:case m===h.$Infinity:case x===h.$Infinity:return}const b=t.frameBuffer.currentAttachment;if(g>b.width||p>b.height)return;let T=+s.sqrt(e[0]*e[0]+e[1]*e[1]);if(!r.isInteger(T)){const t=T.toString(),e=t.indexOf("e");-1!==e&&(T=+t.slice(0,e)),T=+T.toFixed(4)}let v=+s.sqrt(e[2]*e[2]+e[3]*e[3]);if(!r.isInteger(v)){const t=v.toString(),e=t.indexOf("e");-1!==e&&(v=+t.slice(0,e)),v=+v.toFixed(4)}if(0>g+m||0>p+x){if(!(a&&a.length&&l._$canApply(a)))return;{let t=new y(0,0,m,x);for(let e=0;et.x+t.width||0>t.y+t.height)return}}const E=h.$getArray(T,v),A=h.$cacheStore(),M=A.generateKeys(l._$instanceId,E,i);h.$poolArray(E);let C=A.get(M);if(!C){let r=s.ceil(s.abs(c.xMax-c.xMin)*T),n=s.ceil(s.abs(c.yMax-c.yMin)*v);const a=t._$textureScale(r,n);a<1&&(r*=a,n*=a);const o=t.frameBuffer.createCacheAttachment(r,n,!0);if(t._$bind(o),h.$resetContext(t),t.setTransform(T,0,0,v,-c.xMin*T,-c.yMin*v),_){const i=h.$currentPlayer(),r=i._$scale*i._$ratio,n=h.$getFloat32Array6(r,0,0,r,0,0),a=h.$multiplicationMatrix(n,$);h.$poolFloat32Array6(n);const o=l._$parent._$transform.concatenatedMatrix._$matrix,_=h.$getFloat32Array6(o[0],o[1],o[2],o[3],o[4]*r-g,o[5]*r-p),u=h.$multiplicationMatrix(_,a),d=u[4]-(e[4]-g),f=u[5]-(e[5]-p);h.$poolFloat32Array6(u);const m=h.$boundsMatrix(c,a),x=+m.xMax,b=+m.xMin,T=+m.yMax,v=+m.yMin,y=s.ceil(s.abs(x-b)),E=s.ceil(s.abs(T-v));h.$poolBoundsObject(m),t.grid.enable(b,v,y,E,c,l._$scale9Grid,a[0],a[1],a[2],a[3],a[4],a[5],_[0],_[1],_[2],_[3],_[4]-d,_[5]-f),h.$poolFloat32Array6(a),h.$poolFloat32Array6(_)}i[3]=1,this._$doDraw(t,i,!1),_&&t.grid.disable(),C=t.frameBuffer.getTextureFromCurrentAttachment(),A.set(M,C),t.frameBuffer.releaseAttachment(o,!1),t._$bind(b)}if(h.$poolArray(M),$&&h.$poolMatrix($),h.$poolBoundsObject(c),a&&a.length){if(l._$canApply(a)){const s=l._$drawFilter(t,C,e,a,m,x);return h.$resetContext(t),t._$globalAlpha=o,t._$imageSmoothingEnabled=!0,t._$globalCompositeOperation=n,t.setTransform(1,0,0,1,g-s._$offsetX,p-s._$offsetY),void t.drawImage(s,0,0,s.width,s.height,i)}}h.$resetContext(t),t._$globalAlpha=o,t._$imageSmoothingEnabled=!0,t._$globalCompositeOperation=n;const S=s.atan2(e[1],e[0]),R=s.atan2(-e[2],e[3]);if(S||R){const i=c.xMin*T,r=c.yMin*v;t.setTransform(s.cos(S),s.sin(S),-s.sin(R),s.cos(R),i*s.cos(S)-r*s.sin(R)+e[4],i*s.sin(S)+r*s.cos(R)+e[5])}else t.setTransform(1,0,0,1,g,p);t.drawImage(C,0,0,C.width,C.height,i)}_$doDraw(t,e,i=!1){h.$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?h.$getBoundsObject(t._$bounds.xMin,t._$bounds.xMax,t._$bounds.yMin,t._$bounds.yMax):h.$getBoundsObject(this._$xMin,this._$xMax,this._$yMin,this._$yMax)}_$restart(){this._$displayObject&&!this._$displayObject._$isUpdated()&&(this._$displayObject._$doChanged(),h.$isUpdated=!0,h.$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,p=this._$pointerY+i,m=-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(p,m)))),this._$yMax=s.max(this._$yMax,s.max(g,s.max(f,s.max(p,m)))),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&&(p=this._$pointerY+s.sin(l)*i),_&&s.abs(_)%s.PI!=0&&(m=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(p,m)))),this._$yMax=s.max(this._$yMax,s.max(g,s.max(f,s.max(p,m))));let x=0,b=0,T=0,v=0,y=0,E=0,A=0,M=0;switch(this._$caps){case B.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 B.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=p+t,M=m+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),h.$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 ft.JSON:{const e=JSON.parse(t.target.responseText);if("zlib"===e.type){if(h.$unzipWorkerActive)return void h.$unzipQueues.push({json:e,scope:this});h.$unzipWorkerActive=!0,h.$unzipWorker||(h.$unzipWorker=new Worker(h.$unzipURL));const t=new Uint8Array(e.buffer);h.$unzipWorker.onmessage=h.$unzipHandler.bind(this),h.$unzipWorker.postMessage(t,[t.buffer])}else this._$build(e)}break;case ft.ARRAY_BUFFER:this._$imageDecode(new Uint8Array(t.target.response))}else e.willTrigger(f.IO_ERROR)&&e.dispatchEvent(new f(f.IO_ERROR,!1,!1,t.target.statusText))}.bind(this)}})}loadImage(t){t.responseDataFormat=ft.ARRAY_BUFFER,this.load(t)}_$imageDecode(t){const e={image:new h.$Image,scope:this};e.image.decoding="async",e.image.src=h.$URL.createObjectURL(new h.$Blob([t],{type:`image/${h.$getImageType(t)}`})),h.$imageWorkerActive?h.$imageQueues.push(e):(h.$imageWorkerActive=!0,e.image.decode().then(h.$decodeImage.bind(e)).catch((()=>{throw new Error("image encoding error")})))}_$build(t){const e=this.contentLoaderInfo;let i=null;const s=h.$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]),l=new y(0,0,n.width,n.height),_=this._$generateFilterRect(l,a,o),$=0|s.ceil(_.width),c=0|s.ceil(_.height),u=s.ceil(s.abs(_.x)+.5*s.abs($-_.width)),d=s.ceil(s.abs(_.y)+.5*s.abs(c-_.height));t._$offsetX=+(u+t._$offsetX),t._$offsetY=+(d+t._$offsetY);const g=this._$blurX*a,f=this._$blurY*o;let p=1,m=1;g>128?p=.0625:g>64?p=.125:g>32?p=.25:g>16&&(p=.5),f>128?m=.0625:f>64?m=.125:f>32?m=.25:f>16&&(m=.5);const x=g*p,b=f*m;let T=s.ceil($*p),v=s.ceil(c*m);const E=t.frameBuffer.createTextureAttachment(T,v),A=[E,t.frameBuffer.createTextureAttachment(T,v)];let M=0;t._$bind(E),h.$resetContext(t),t.setTransform(p,0,0,m,0,0),t.drawImage(n,u,d,n.width,n.height),t.blend.toOneZero();let C=t.frameBuffer.getTextureFromCurrentAttachment();for(let e=0;e0){M=(M+1)%2;const e=A[M];t._$bind(e),t._$applyBlurFilter(C,!0,x),C=t.frameBuffer.getTextureFromCurrentAttachment()}if(this._$blurY>0){M=(M+1)%2;const e=A[M];t._$bind(e),t._$applyBlurFilter(C,!1,b),C=t.frameBuffer.getTextureFromCurrentAttachment()}}if(t.blend.reset(),1!==p||1!==m){const e=t.frameBuffer.createTextureAttachment($,c);t._$bind(e),h.$resetContext(t),t.imageSmoothingEnabled=!0,t.setTransform(1/p,0,0,1/m,0,0),t.drawImage(C,0,0,T,v),C=t.frameBuffer.getTextureFromCurrentAttachment(),h.$resetContext(t),t.setTransform(1,0,0,1,0,0),t.frameBuffer.releaseAttachment(A[0],!0),t.frameBuffer.releaseAttachment(A[1],!0),i?t.frameBuffer.releaseAttachment(r,!0):t.frameBuffer.releaseAttachment(e,!1)}else t.frameBuffer.releaseAttachment(A[(M+1)%2],!0),i?t.frameBuffer.releaseAttachment(r,!0):t.frameBuffer.releaseAttachment(A[M],!1);return C}}class J extends V{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 Q(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=W.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=h.$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=h.$clamp(+t,-255,255,4))!==this._$distance&&this._$doChanged(!0),this._$distance=t}get highlightAlpha(){return this._$highlightAlpha}set highlightAlpha(t){(t=h.$clamp(+t,0,1,0))!==this._$highlightAlpha&&this._$doChanged(!0),this._$highlightAlpha=t}get highlightColor(){return this._$highlightColor}set highlightColor(t){(t=h.$clamp(h.$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=h.$clamp(+t,0,1,0))!==this._$shadowAlpha&&this._$doChanged(!0),this._$shadowAlpha=t}get shadowColor(){return this._$shadowColor}set shadowColor(t){(t=h.$clamp(h.$toColorInt(t),0,16777215,0))!==this._$shadowColor&&this._$doChanged(!0),this._$shadowColor=t}get strength(){return this._$strength}set strength(t){(t=h.$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 W.OUTER:case W.INNER:this._$type=t;break;default:this._$type=W.FULL}}clone(){return new J(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*h.$Deg2Rad,a=s.abs(s.cos(n)*this._$distance),o=s.abs(s.sin(n)*this._$distance);return r.x+=-a,r.width+=a,r.y+=-o,r.height+=2*o,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&&this._$blurFilter._$canApply()}_$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,l=t._$offsetY,_=s.sqrt(e[0]*e[0]+e[1]*e[1]),$=s.sqrt(e[2]*e[2]+e[3]*e[3]),c=+this._$angle*h.$Deg2Rad,u=+s.cos(c)*this._$distance*_,d=+s.sin(c)*this._$distance*$;let g=t.frameBuffer.createTextureAttachment(n,a);t._$bind(g),h.$resetContext(t),t.drawImage(r,0,0,n,a),t.globalCompositeOperation=I.ERASE,t.drawImage(r,2*u,2*d,n,a);const f=this._$blurFilter._$applyFilter(t,e,!1),p=f.width,m=f.height,x=s.ceil(p+2*s.abs(u)),b=s.ceil(m+2*s.abs(d)),T=this._$type===W.INNER,v=T?n:x,y=T?a:b,E=s.abs(u),A=s.abs(d),M=(p-n)/2,C=(m-a)/2;let S,R,w,O;return T?(S=0,R=0,w=-M-u,O=-C-d):(S=E+M,R=A+C,w=E-u,O=A-d),t._$bind(i),t._$applyBitmapFilter(f,v,y,n,a,S,R,p,m,w,O,!1,this._$type,this._$knockout,this._$strength,null,null,null,h.$intToR(this._$highlightColor,this._$highlightAlpha,!0),h.$intToG(this._$highlightColor,this._$highlightAlpha,!0),h.$intToB(this._$highlightColor,this._$highlightAlpha,!0),this._$highlightAlpha,h.$intToR(this._$shadowColor,this._$shadowAlpha,!0),h.$intToG(this._$shadowColor,this._$shadowAlpha,!0),h.$intToB(this._$shadowColor,this._$shadowAlpha,!0),this._$shadowAlpha),t._$offsetX=o+S,t._$offsetY=l+R,t.frameBuffer.releaseTexture(f),t.frameBuffer.getTextureFromCurrentAttachment()}}class Z extends V{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(h.$isArray(t)&&20===t.length){if(this._$matrix){const e=t.length;for(let i=0;i0?s.max(0,p-d):0)+y,S=(m>0?s.max(0,m-g):0)+E),this._$inner?(R=W.INNER,w=this._$knockout||this._$hideObject):!this._$knockout&&this._$hideObject?(R=W.FULL,w=!0):(R=W.OUTER,w=this._$knockout),t._$bind(i),t._$applyBitmapFilter(l,T,v,r,n,A,M,_,$,C,S,!0,R,w,this._$strength,null,null,null,h.$intToR(this._$color,this._$alpha,!0),h.$intToG(this._$color,this._$alpha,!0),h.$intToB(this._$color,this._$alpha,!0),this._$alpha,0,0,0,0),t._$offsetX=a+A,t._$offsetY=o+M,t.frameBuffer.releaseTexture(l),t.frameBuffer.getTextureFromCurrentAttachment()}}class st extends V{constructor(t=0,e=1,i=4,s=4,r=1,n=1,a=!1,o=!1){super(),this._$blurFilter=new Q(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=h.$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=h.$clamp(h.$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=h.$clamp(0|t,0,255,0))!==this._$strength&&this._$doChanged(!0),this._$strength=t}clone(){return new st(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 s=i.width,r=i.height,n=t._$offsetX,a=t._$offsetY,o=this._$blurFilter._$applyFilter(t,e,!1),l=o.width,_=o.height,$=t._$offsetX,c=t._$offsetY,u=this._$inner?s:l,d=this._$inner?r:_;let g,f,p,m;this._$inner?(g=0,f=0,p=-$,m=-c):(g=$-n,f=c-a,p=0,m=0);const x=this._$inner?W.INNER:W.OUTER;return t._$bind(i),t._$applyBitmapFilter(o,u,d,s,r,g,f,l,_,p,m,!0,x,this._$knockout,this._$strength,null,null,null,h.$intToR(this._$color,this._$alpha,!0),h.$intToG(this._$color,this._$alpha,!0),h.$intToB(this._$color,this._$alpha,!0),this._$alpha,0,0,0,0),t._$offsetX=n+g,t._$offsetY=a+f,t.frameBuffer.releaseTexture(o),t.frameBuffer.getTextureFromCurrentAttachment()}}class rt extends V{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 Q(n,a,h),this._$distance=4,this._$angle=45,this._$colors=null,this._$alphas=null,this._$ratios=null,this._$strength=1,this._$type=W.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,h.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;i16777215&&(e%=16777216),t[i]=h.$toColorInt(s.abs(e))}this._$colors=t.slice(0)}}get distance(){return this._$distance}set distance(t){(t=h.$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,h.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;i16777215&&(e%=16777216),t[i]=h.$toColorInt(s.abs(e))}this._$colors=t.slice(0)}}get distance(){return this._$distance}set distance(t){(t=h.$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,h.$isArray(t)){this._$doChanged(!0);const e=t.length;for(let i=0;i0?s.max(0,x-d):0)+M,O=(b>0?s.max(0,b-g):0)+C),t._$bind(i),t._$applyBitmapFilter(l,E,A,r,n,S,R,_,$,w,O,!0,this.type,this.knockout,this._$strength,this.ratios,this.colors,this.alphas,0,0,0,0,0,0,0,0),t._$offsetX=a+S,t._$offsetY=o+R,t.frameBuffer.releaseTexture(l),t.frameBuffer.getTextureFromCurrentAttachment()}}class at{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 ot{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 ht extends M{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 _t;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=ot.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=lt.STATIC,this._$textHeightTable=null,this._$focus=!1,this._$isComposing=!1,this._$thickness=0,this._$thicknessColor=0,this._$verticalAlign=$t.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 ot.CENTER:case ot.LEFT:case ot.RIGHT:this._$autoSize=t;break;default:this._$autoSize=ot.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=h.$clamp(h.$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=h.$clamp(h.$toColorInt(t),0,16777215,0),this._$reset()}get defaultTextFormat(){return this._$defaultTextFormat}set defaultTextFormat(t){t instanceof _t&&(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===lt.INPUT){const t=h.$currentPlayer(),e=h.$document.getElementById(t.contentElementId);if(!e)return;this._$createTextAreaElement(t._$scale);const i=this._$textarea,r=this._$transform.concatenatedMatrix,n=this._$getBounds(null),a=h.$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/h.$devicePixelRatio)*t._$scale+"px",i.style.top=(r.ty+n.yMin+t._$ty/t._$scale/h.$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,h.$requestAnimationFrame)((()=>{i.focus()})),this._$textAreaActive=!0,this.willTrigger(d.FOCUS_IN)&&this.dispatchEvent(new d(d.FOCUS_IN)),this._$doChanged(),h.$isUpdated=!0}}else this._$textarea&&(this._$textarea.dispatchEvent(new h.$window.Event(`${h.$PREFIX}_blur`)),this.willTrigger(d.FOCUS_OUT)&&this.dispatchEvent(new d(d.FOCUS_OUT)),this._$doChanged(),h.$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=h.$clamp(0|t,0,this.maxScrollH),this._$scrollH!==t&&(this._$scrollH=t,this._$reset(),this.willTrigger($.SCROLL)&&this.dispatchEvent(new $($.SCROLL,!0)))}get scrollV(){return this._$scrollV}set scrollV(t){t=h.$clamp(0|t,1,this.maxScrollV),this._$scrollV!==t&&(this._$scrollV=t,this._$reset(),this.willTrigger($.SCROLL)&&this.dispatchEvent(new $($.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,!h.$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 _t,a=t>-1?t:0;for(;at)break;r.yIndex===t&&(r.mode===ht.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===ht.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"),h.$P_TAG.innerHTML!==e&&(h.$P_TAG.textContent="",h.$P_TAG.insertAdjacentHTML("afterbegin",e));let s=this._$decisionTextFormat;if(this._$textData.length in this._$textFormatTable){const t=this._$textFormatTable[this._$textData.length]._$clone();t._$merge(s),s=t}this._$totalWidth=0,this._$heightTable[0]=0,this._$textHeightTable[0]=this._$getTextHeight(s),this._$widthTable[0]=0;const r={mode:ht.BREAK,x:0,yIndex:0,textFormat:s._$clone()};this._$objectTable[0]=r,this._$textData[0]=r,this._$parseTag(h.$P_TAG,s._$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(_,i)}this._$loadImage(e),h.$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 h.$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,h.$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]);h.$poolFloat32Array6(a);const l=o-n._$widthMargin()-4;for(let a=0;al){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;g={mode:_?ht.BREAK:ht.WRAP,x:0,yIndex:r,textFormat:n},this._$objectTable[r]=g,_||--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!==ht.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,g);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===ht.TEXT;)u=this._$getTextHeight(n.textFormat),d=u+$,this._$widthTable[r-1]+=n.width,this._$heightTable[r-1]=s.max(this._$heightTable[r-1],u),this._$textHeightTable[r-1]=s.max(this._$textHeightTable[r-1],d),++i,n=this._$textData[t-i];for(i=1;this._$textData.length>t+i;)n=this._$textData[t+i],++i,u=this._$getTextHeight(n.textFormat),d=u+$,this._$heightTable[r]=s.max(this._$heightTable[r],u),this._$textHeightTable[r]=s.max(this._$textHeightTable[r],d),n.x=this._$totalWidth,n.yIndex=r,this._$totalWidth+=n.width}else this._$textData[this._$textData.length]=g}_||(o.width=c,o.x=this._$totalWidth,this._$totalWidth+=c,this._$widthTable[r]=s.max(this._$widthTable[r],this._$totalWidth),this._$heightTable[r]=s.max(this._$heightTable[r],u),this._$textHeightTable[r]=s.max(this._$textHeightTable[r],d),this._$textData[this._$textData.length]=o)}return i}_$getTextHeight(t){if(!h.$DIV){const t=h.$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%",h.$DIV=t,h.$document.body.appendChild(h.$DIV)}const e=t._$size,i=t._$font,s=t._$bold?"bold":"normal",r=`${e}_${i}_${s}`;if(this._$heightCache.has(r))return this._$heightCache.get(r);const n=h.$DIV.style,a=`${e}px`;n.fontSize!==a&&(n.fontSize=a),n.fontFamily!==i&&(n.fontFamily=i),n.fontWeight!==s&&(n.fontWeight=s);const o=10>e?h.$DIV.clientHeight*e*.1:h.$DIV.clientHeight;return this._$heightCache.set(r,o),o}_$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!==ot.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 ot.LEFT:case ot.CENTER:this._$bounds.xMax=e+this._$bounds.xMin;break;case ot.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===at.CENTER:case this._$autoSize===ot.CENTER:return s.max(0,e/2-n-r._$rightMargin-i/2);case r._$align===at.RIGHT:case this._$autoSize===ot.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=h.$multiplicationMatrix(t,this._$correctMatrix(this._$transform._$rawMatrix()));return h.$boundsMatrix(this._$bounds,e)}return h.$boundsMatrix(this._$bounds,this._$correctMatrix(h.$MATRIX_ARRAY_IDENTITY))}_$correctMatrix(t){switch(this._$autoSize){case ot.CENTER:{const e=this.textWidth+4,i=(this._$originBounds.xMax-this._$originBounds.xMin)/2-e/2;return h.$getFloat32Array6(t[0],t[1],t[2],t[3],t[4]+i,t[5])}case ot.RIGHT:{const e=this.textWidth+4,i=this._$originBounds.xMax-this._$originBounds.xMin-(e-this._$originBounds.xMin);return h.$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;h.$poolBoundsObject(i);let l=s.ceil(s.abs(r-n)),_=s.ceil(s.abs(a-o));if(!l||!_)return;let $=e;const c=this._$transform._$rawMatrix();c!==h.$MATRIX_ARRAY_IDENTITY&&($=h.$multiplicationMatrix(e,c)),h.$resetContext(t),t.setTransform($[0],$[1],$[2],$[3],$[4],$[5]),t.beginPath(),t.moveTo(0,0),t.lineTo(l,0),t.lineTo(l,_),t.lineTo(0,_),t.lineTo(0,0),t.clip(!0),$!==e&&h.$poolFloat32Array6($)}_$draw(t,e,i){if(!this._$visible||this._$textAreaActive)return;if(!this._$background&&!this._$border&&!this.text)return;let n=i;const a=this._$transform._$rawColorTransform();a!==h.$COLOR_ARRAY_IDENTITY&&(n=h.$multiplicationColor(i,a));const o=h.$clamp(n[3]+n[7]/255,0,1);if(!o)return;let l=e;const _=this._$transform._$rawMatrix();_!==h.$MATRIX_ARRAY_IDENTITY&&(l=h.$multiplicationMatrix(e,_));const $=this._$getBounds(null);$.xMin-=this._$thickness,$.xMax+=this._$thickness,$.yMin-=this._$thickness,$.yMax+=this._$thickness;const c=$.xMin,u=$.yMin,d=h.$boundsMatrix($,l),g=+d.xMax,f=+d.xMin,p=+d.yMax,m=+d.yMin;h.$poolBoundsObject(d);let x=s.ceil(s.abs(g-f)),b=s.ceil(s.abs(p-m));switch(!0){case 0===x:case 0===b:case x===-h.$Infinity:case b===-h.$Infinity:case x===h.$Infinity:case b===h.$Infinity:return}if(0>f+x||0>m+b)return;const T=t.frameBuffer.currentAttachment;if(f>T.width||m>T.height)return;let v=+s.sqrt(l[0]*l[0]+l[1]*l[1]);if(!r.isInteger(v)){const t=v.toString(),e=t.indexOf("e");-1!==e&&(v=+t.slice(0,e)),v=+v.toFixed(4)}let E=+s.sqrt(l[2]*l[2]+l[3]*l[3]);if(!r.isInteger(E)){const t=E.toString(),e=t.indexOf("e");-1!==e&&(E=+t.slice(0,e)),E=+E.toFixed(4)}const A=this._$filters||this.filters;if(0>f+x||0>m+b){if(!(A&&A.length&&this._$canApply(A)))return;{let t=new y(0,0,x,b);for(let e=0;et.x+t.width||0>t.y+t.height)return}}const M=h.$getArray(v,E),C=h.$cacheStore(),S=C.generateKeys(this._$instanceId,M,n);let R=C.get(S);if(h.$poolArray(M),R&&(this._$renew||this._$isUpdated())&&(C.removeCache(this._$instanceId),R=null),!R){const i=s.ceil(s.abs($.xMax-$.xMin)*v),r=s.ceil(s.abs($.yMax-$.yMin)*E);this._$renew=!1,n[3]=1;const a=C.getCanvas();a.width=i,a.height=r;const o=a.getContext("2d");if(this._$background||this._$border){if(o.beginPath(),o.moveTo(0,0),o.lineTo(i,0),o.lineTo(i,r),o.lineTo(0,r),o.lineTo(0,0),this._$background){const t=h.$intToRGBA(this._$backgroundColor),e=s.max(0,s.min(255*t.A*n[3]+n[7],255))/255;o.fillStyle=`rgba(${t.R},${t.G},${t.B},${e})`,o.fill()}if(this._$border){const t=h.$intToRGBA(this._$borderColor),e=s.max(0,s.min(255*t.A*n[3]+n[7],255))/255;o.lineWidth=1,o.strokeStyle=`rgba(${t.R},${t.G},${t.B},${e})`,o.stroke()}}o.save(),o.beginPath(),o.moveTo(2,2),o.lineTo(i-2,2),o.lineTo(i-2,r-2),o.lineTo(2,r-2),o.lineTo(2,2),o.clip(),o.beginPath(),o.setTransform(v,0,0,E,0,0),this._$doDraw(o,e,n,i/e[0]),o.restore(),R=t.frameBuffer.createTextureFromCanvas(o.canvas),C.set(S,R),C.destroy(o)}h.$poolArray(S),h.$poolBoundsObject($);const w=this._$blendMode||this.blendMode;if(A&&A.length){if(this._$canApply(A)){const s=this._$drawFilter(t,R,l,A,x,b);return h.$resetContext(t),t._$globalAlpha=o,t._$globalCompositeOperation=w,t.setTransform(1,0,0,1,f-s._$offsetX,m-s._$offsetY),t.drawImage(s,0,0,s.width,s.height,n),l!==e&&h.$poolFloat32Array6(l),void(n!==i&&h.$poolFloat32Array8(n))}}h.$resetContext(t),t._$globalAlpha=o,t._$globalCompositeOperation=w;const O=s.atan2(l[1],l[0]),I=s.atan2(-l[2],l[3]);if(O||I){const e=c*v,i=u*E;t.setTransform(s.cos(O),s.sin(O),-s.sin(I),s.cos(I),e*s.cos(O)-i*s.sin(I)+l[4],e*s.sin(O)+i*s.cos(I)+l[5])}else t.setTransform(1,0,0,1,f,m);t.drawImage(R,0,0,R.width,R.height,n),l!==e&&h.$poolFloat32Array6(l),n!==i&&h.$poolFloat32Array8(n)}_$doDraw(t,e,i,r){const n=this._$getTextData(),a=this.width,o=this.height;let l=0,_=0,$=0,c=0;if(this._$verticalAlign!==$t.TOP&&this.height>this.textHeight)switch(this._$verticalAlign){case $t.MIDDLE:c=(this.height-this.textHeight+2)/2;break;case $t.BOTTOM:c=this.height-this.textHeight+2}const u=n.length;for(let d=0;do||g>a))continue;let f=u.textFormat;const p=h.$intToRGBA(u.textFormat._$color),m=s.max(0,s.min(255*p.A*i[3]+i[7],255))/255;if(t.fillStyle=`rgba(${p.R},${p.G},${p.B},${m})`,this._$thickness){const e=h.$intToRGBA(this._$thicknessColor),r=s.max(0,s.min(255*e.A*i[3]+i[7],255))/255;t.lineWidth=this._$thickness,t.strokeStyle=`rgba(${e.R},${e.G},${e.B},${r})`}const x=0|u.yIndex;switch(u.mode){case ht.BREAK:case ht.WRAP:if($++,this.scrollV>$)continue;if(_+=this._$textHeightTable[x],l=this._$getAlignOffset(this._$objectTable[x],r),f._$underline){const r=u.textFormat._$size/12,n=h.$intToRGBA(f._$color),a=s.max(0,s.min(255*n.A*i[3]+i[7],255))/255;t.lineWidth=s.max(1,1/s.min(e[0],e[3])),t.strokeStyle=`rgba(${n.R},${n.G},${n.B},${a})`,t.beginPath(),t.moveTo(l,c+_-r),t.lineTo(l+this._$widthTable[x],c+_-r),t.stroke()}break;case ht.TEXT:{if(this.scrollV>$)continue;let e=_-this._$heightTable[0];h.$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 ht.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!==h.$MATRIX_ARRAY_IDENTITY&&(r=h.$multiplicationMatrix(e,n));const a=this._$getBounds(null),o=h.$boundsMatrix(a,r),l=+o.xMax,_=+o.xMin,$=+o.yMax,c=+o.yMin;h.$poolBoundsObject(o),h.$poolBoundsObject(a);const u=s.ceil(s.abs(l-_)),d=s.ceil(s.abs($-c));return t.setTransform(1,0,0,1,_,c),t.beginPath(),t.moveTo(0,0),t.lineTo(u,0),t.lineTo(u,d),t.lineTo(0,d),t.lineTo(0,0),r!==e&&h.$poolFloat32Array6(r),t.isPointInPath(i.x,i.y)}_$createTextAreaElement(t){if(!this._$textarea){this._$textarea=h.$document.createElement("textarea"),this._$textarea.value=this.text,this._$textarea.id=`${h.$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(`${h.$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 n(t,"gm"));e=i?i.join(""):""}this.text=e;if(h.$document.getElementById(h.$currentPlayer().contentElementId)){const t=h.$document.getElementById(`${h.$PREFIX}_TextField_${this._$instanceId}`);t&&(t.remove(),this._$focus=!1,this._$textAreaActive=!1,h.$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 n(t,"gm"));e=i?i.join(""):""}if(!this._$isComposing&&this.text!==e){this.text=e,t.target.value=e,this.willTrigger($.CHANGE)&&this.dispatchEvent(new $($.CHANGE,!0));const i=h.$currentPlayer(),r=this._$textarea,n=this._$transform.concatenatedMatrix,a=this._$getBounds(null);r.style.left=`${s.floor((n.tx+a.xMin+i._$tx/i._$scale/h.$devicePixelRatio)*i._$scale)}px`,r.style.top=`${s.floor((n.ty+a.yMin+i._$ty/i._$scale/h.$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 s=e.match(new n(i,"gm"));e=s?s.join(""):"",this.text=e,t.target.value=e}.bind(this)),this._$textarea.addEventListener("click",function(){this.willTrigger(p.CLICK)&&this.dispatchEvent(new p(p.CLICK))}.bind(this)),this._$textarea.addEventListener(h.$MOUSE_WHEEL,function(t){this.scrollV+=t.deltaY}.bind(this)),this._$textarea.addEventListener(h.$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===h.$isTouch)this._$textarea.addEventListener(h.$TOUCH_START,(function(){const t=h.$currentPlayer();t&&(t._$state="down")})),this._$textarea.addEventListener(h.$TOUCH_END,(function(){const t=h.$currentPlayer();t&&(t._$state="up")}));else this._$textarea.addEventListener(h.$MOUSE_DOWN,(function(){const t=h.$currentPlayer();t&&(t._$state="down")})),this._$textarea.addEventListener(h.$MOUSE_UP,(function(){const t=h.$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!==ot.NONE?this._$textarea.style.textAlign=ot.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 n(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 lt{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 _t{constructor(t=null,e=null,i=null,s=null,r=null,n=null,a=null,o=null,l=null,_=null,$=null,c=null){this._$font=t,this._$size=e,this._$color=null===i?null:h.$clamp(h.$toColorInt(i),0,16777215,16777215),this._$bold=s,this._$italic=r,this._$underline=n,this._$align=a,this._$leftMargin=o,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 at.CENTER:case at.RIGHT:case at.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=h.$clamp(h.$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 _t(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=at.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 $t{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 ct extends c{constructor(){super(),this._$bytesLoaded=0,this._$bytesTotal=0,this._$buffer=null,this._$audioBuffer=null,this._$character=null,this._$sources=h.$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(ut.volume,h.$clamp(t,0,1,1));const e=this._$sources.length;if(e&&h.$audioContext)for(let t=0;tt.target.status?(this._$buffer=new Uint8Array(t.target.response),h.$audioContext?h.$decodeAudioData(this):h.$audios.push(this),h.$currentPlayer()._$loaders.push(this)):this.willTrigger(f.IO_ERROR)&&this.dispatchEvent(new f(f.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(h.$audioContext&&e)this._$createBufferSource(t);else{const e=function(t,i=0){if(null!==(this._$character?this._$character.audioBuffer:this._$audioBuffer)&&null!==h.$audioContext){const e=(h.$performance.now()-t)/1e3;return void this._$createBufferSource(i,e)}(0,h.$requestAnimationFrame)(e)}.bind(this,h.$performance.now(),t);(0,h.$requestAnimationFrame)(e)}}stop(){this._$stopFlag=!0;const t=this._$sources.length;if(t){const e=h.$currentPlayer();if(h.$audioContext)for(let e=0;ep.width||d>p.height)return;let m=+s.sqrt(o[0]*o[0]+o[1]*o[1]),b=+s.sqrt(o[2]*o[2]+o[3]*o[3]);const T=this._$filters||this.filters;if(0>c+g||0>d+f){if(!(T&&T.length&&this._$canApply(T)))return;{let t=new y(0,0,g,f);for(let e=0;et.x+t.width||0>t.y+t.height)return}}let v=this._$texture;const E=this._$blendMode||this.blendMode;if(T&&T.length&&this._$canApply(T)){let e=this._$texture;if(1!==m||1!==b){const i=t.frameBuffer.currentAttachment,s=t.frameBuffer.createCacheAttachment(e.width*m,e.height*b);t._$bind(s),h.$resetContext(t),t.setTransform(m,0,0,b,0,0),t.drawImage(this._$texture,0,0,this._$texture.width,this._$texture.height),e=t.frameBuffer.getTextureFromCurrentAttachment(),t._$bind(i),t.frameBuffer.releaseAttachment(s,!1)}v=this._$drawFilter(t,e,o,T,g,f),h.$resetContext(t),t._$globalAlpha=a,t._$imageSmoothingEnabled=this._$smoothing,t._$globalCompositeOperation=E;const i=h.$boundsMatrix(this._$bounds,o);t.setTransform(1,0,0,1,i.xMin-v._$offsetX,i.yMin-v._$offsetY),t.drawImage(v,0,0,v.width,v.height,r),h.$poolBoundsObject(i)}else h.$resetContext(t),t._$globalAlpha=a,t._$imageSmoothingEnabled=this._$smoothing,t._$globalCompositeOperation=E,t.setTransform(o[0],o[1],o[2],o[3],o[4],o[5]),t.drawImage(v,0,0,v.width,v.height,r);o!==e&&h.$poolFloat32Array6(o),r!==i&&h.$poolFloat32Array8(r)}_$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!==h.$MATRIX_ARRAY_IDENTITY&&(r=h.$multiplicationMatrix(e,n));const a=this._$getBounds(null),o=h.$boundsMatrix(a,r),l=+o.xMax,_=+o.xMin,$=+o.yMax,c=+o.yMin;h.$poolBoundsObject(o),h.$poolBoundsObject(a);const u=s.ceil(s.abs(l-_)),d=s.ceil(s.abs($-c));return t.setTransform(1,0,0,1,_,c),t.beginPath(),t.moveTo(0,0),t.lineTo(u,0),t.lineTo(u,d),t.lineTo(0,d),t.lineTo(0,0),r!==e&&h.$poolFloat32Array6(r),t.isPointInPath(i.x,i.y)}_$getBounds(t=null){if(t){let e=t;const i=this._$transform._$rawMatrix();i!==h.$MATRIX_ARRAY_IDENTITY&&(e=h.$multiplicationMatrix(t,i));const s=h.$boundsMatrix(this._$bounds,e);return e!==t&&h.$poolFloat32Array6(e),s}return h.$getBoundsObject(this._$bounds.xMin,this._$bounds.xMax,this._$bounds.yMin,this._$bounds.yMax)}}class ft{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 pt{constructor(t=""){this._$url=t,this._$contentType="application/json",this._$data=null,this._$method=xt.GET,this._$requestHeaders=h.$getArray(),this._$userAgent=h.$navigator.userAgent,this._$responseDataFormat=ft.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 xt.DELETE:case xt.HEAD:case xt.OPTIONS:case xt.POST:case xt.PUT:this._$method=t;break;default:this._$method=xt.GET}}get requestHeaders(){return this._$requestHeaders}set requestHeaders(t){h.$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=h.$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=h.$getMap();t.set("Content-Type",`${this._$contentType}`);const e=this._$requestHeaders.length;for(let i=0;i=this._$duration&&(this.removeEventListener($.ENTER_FRAME,this._$update),this.hasEventListener($.COMPLETE)&&this.dispatchEvent(new $($.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 vt{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 Tt(t,e,i,s,r,n)}}class yt{constructor(){this._$pool=h.$getArray(),this._$store=h.$getMap(),this._$lifeCount=2,this._$delayLifeCheck=this.lifeCheck.bind(this),this._$delayBitmapLifeCheck=this.bitmapLifeCheck.bind(this)}reset(){const t=this._$store.values();for(const e of t){const t=e.values();for(const e of t)this.destroy(e);h.$poolMap(e)}this._$store.clear()}destroy(t){if(t)switch(t.constructor){case h.$WebGLTexture:return new Promise((()=>{const e=h.$currentPlayer();if(e._$context){const i=e._$context,s=t._$bitmapData;if(s){s._$getPixelsAsync(0,0,s.width,s.height,"RGBA"),t._$bitmapData=!1;(0,h.$setTimeout)(this._$delayBitmapLifeCheck,2e3,s)}i.frameBuffer.releaseTexture(t)}}));case h.$CanvasRenderingContext2D:return new Promise((()=>{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()||h.$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);h.$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=null){const i=`${t[0]}`,s=`${t[1]}`;this._$store.has(i)||this._$store.set(i,h.$getMap());const r=this._$store.get(i);if(!e)return r.delete(s),r.delete(`life_${s}`),void(r.size||(h.$poolMap(r),this._$store.delete(i)));const n=r.get(s);n&&n!==e&&this.destroy(n),r.set(s,e),r.set(`life_${s}`,this._$lifeCount);(0,h.$setTimeout)(this._$delayLifeCheck,5e3,i,s)}bitmapLifeCheck(t){if(!t._$pixelBuffer)return;const e=h.$currentPlayer()._$context;t._$buffer=e.pbo.getBufferSubDataAsync(t._$pixelBuffer),t._$pixelBuffer=null}lifeCheck(t,e){if(!this._$store.has(t))return;const i=this._$store.get(t),s=`life_${e}`,r=i.get(s)-1;if(!r)return this.destroy(i.get(e)),i.delete(e),i.delete(s),void(i.size||(h.$poolMap(i),this._$store.delete(t)));i.set(s,r);(0,h.$setTimeout)(this._$delayLifeCheck,5e3,t,e)}generateKeys(t,e=null,i=null){let s="";e&&(s+=`${e.join("_")}`),i&&(s+=this.colorToString(i));const r=h.$getArray();return r[1]=s?this.generateHash(s):"_0",r[0]=`${t}`,r}colorToString(t=null){return t&&0!==t[7]?`_${t[7]}`:""}generateHash(t){let e=0;const i=t.length;for(let s=0;s>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 At{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 te(this._$gl,this._$context,Lt.BLEND(this._$keyword),Bt.TEMPLATE(this._$keyword,t))),this._$collection.get(e)}getClipShader(){return this._$collection.has("c")||this._$collection.set("c",new te(this._$gl,this._$context,Lt.BLEND_CLIP(this._$keyword),Bt.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 te(this._$gl,this._$context,Lt.BLEND(this._$keyword),class{static TEMPLATE(t,e,i){let s;switch(e){case I.SUBTRACT:s=this.FUNCTION_SUBTRACT();break;case I.MULTIPLY:s=this.FUNCTION_MULTIPLY();break;case I.LIGHTEN:s=this.FUNCTION_LIGHTEN();break;case I.DARKEN:s=this.FUNCTION_DARKEN();break;case I.OVERLAY:s=this.FUNCTION_OVERLAY();break;case I.HARDLIGHT:s=this.FUNCTION_HARDLIGHT();break;case I.DIFFERENCE:s=this.FUNCTION_DIFFERENCE();break;case I.INVERT:s=this.FUNCTION_INVERT();break;default:s=this.FUNCTION_NORMAL()}const r=i?"uniform vec4 u_mediump[2];":"",n=i?wt.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 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}}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 p=t.textures;p[0]=0,p[1]=1;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}}}class Mt{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 te(this._$gl,this._$context,Lt.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 te(this._$gl,this._$context,Lt.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===W.INNER,d=_;let g,f,p=4*_;switch(l?g=n?this.STATEMENT_GLOW(t,!1,s,h,l,d,p):this.STATEMENT_BEVEL(t,s,r,h,l,d,p):n?(p+=4,g=this.STATEMENT_GLOW(t,u,s,h,l,d,p)):(p+=8,g=this.STATEMENT_BEVEL(t,s,r,h,l,d,p)),a){case W.OUTER:f=o?"blur - blur * base.a":"base + blur - blur * base.a";break;case W.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${wt.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 te(this._$gl,this._$context,Lt.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 te(this._$gl,this._$context,Lt.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 0.0) {\n ${t.fragColor()} = vec4(min(alpha, 1.0));\n } else {\n discard;\n } \n}\n\n`}}class It{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${It.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${It.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 Bt{static TEMPLATE(t,e){const i=e?"uniform vec4 u_mediump[2];":"",s=e?wt.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 Ft{static FUNCTION_GRID_OFF(){return"\n\nvec2 applyMatrix(in vec2 vertex) {\n mat3 matrix = mat3(\n u_highp[0].xyz,\n u_highp[1].xyz,\n u_highp[2].xyz\n );\n\n vec2 position = (matrix * vec3(vertex, 1.0)).xy;\n\n return position;\n}\n\n"}static FUNCTION_GRID_ON(t){return`\n\nvec2 applyMatrix(in vec2 vertex) {\n mat3 parent_matrix = mat3(\n u_highp[${t}].xyz,\n u_highp[${t+1}].xyz,\n u_highp[${t+2}].xyz\n );\n mat3 ancestor_matrix = mat3(\n u_highp[${t+3}].xyz,\n u_highp[${t+4}].xyz,\n u_highp[${t+5}].xyz\n );\n vec2 parent_offset = vec2(u_highp[${t+2}].w, u_highp[${t+3}].w);\n vec2 parent_size = vec2(u_highp[${t+4}].w, u_highp[${t+5}].w);\n vec4 grid_min = u_highp[${t+6}];\n vec4 grid_max = u_highp[${t+7}];\n\n vec2 position = (parent_matrix * vec3(vertex, 1.0)).xy;\n position = (position - parent_offset) / parent_size;\n\n vec4 ga = grid_min;\n vec4 gb = grid_max - grid_min;\n vec4 gc = vec4(1.0) - grid_max;\n\n vec2 pa = position;\n vec2 pb = position - grid_min.st;\n vec2 pc = position - grid_max.st;\n\n position = (ga.pq / ga.st) * min(pa, ga.st)\n + (gb.pq / gb.st) * clamp(pb, vec2(0.0), gb.st)\n + (gc.pq / gc.st) * max(vec2(0.0), pc);\n\n position = position * parent_size + parent_offset;\n position = (ancestor_matrix * vec3(position, 1.0)).xy;\n\n return position;\n}\n\n`}}class Lt{static TEXTURE(t){return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n\n${t.varyingOut()} vec2 v_coord;\n\nvoid main() {\n v_coord = a_vertex;\n\n vec2 position = a_vertex * 2.0 - 1.0;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n\n`}static BLEND(t){return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n\nuniform vec4 u_highp[4];\n\n${t.varyingOut()} vec2 v_coord;\n\nvoid main() {\n v_coord = a_vertex;\n\n vec2 offset = u_highp[0].xy;\n vec2 size = u_highp[0].zw;\n mat3 matrix = mat3(u_highp[1].xyz, u_highp[2].xyz, u_highp[3].xyz);\n vec2 viewport = vec2(u_highp[1].w, u_highp[2].w);\n\n vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y);\n position = position * size + offset;\n position = (matrix * vec3(position, 1.0)).xy;\n position /= viewport;\n\n position = position * 2.0 - 1.0;\n gl_Position = vec4(position.x, -position.y, 0.0, 1.0);\n}\n\n`}static BLEND_CLIP(t){return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n\nuniform vec4 u_highp[4];\n\n${t.varyingOut()} vec2 v_coord;\n\nvoid main() {\n v_coord = a_vertex;\n\n vec2 offset = u_highp[0].xy;\n vec2 size = u_highp[0].zw;\n mat3 inv_matrix = mat3(u_highp[1].xyz, u_highp[2].xyz, u_highp[3].xyz);\n vec2 viewport = vec2(u_highp[1].w, u_highp[2].w);\n\n vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y);\n position *= viewport;\n position = (inv_matrix * vec3(position, 1.0)).xy;\n position = (position - offset) / size;\n\n position = position * 2.0 - 1.0;\n gl_Position = vec4(position.x, -position.y, 0.0, 1.0);\n}\n\n`}}class Pt{static POSITION_ONLY(t){return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n\nuniform vec4 u_highp[3];\n\nvoid main() {\n mat3 matrix = mat3(u_highp[0].xyz, u_highp[1].xyz, u_highp[2].xyz);\n\n vec2 position = (matrix * vec3(a_vertex, 1.0)).xy * 2.0 - 1.0;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n\n`}static SRC_AND_DST_TEX_COORD(t){return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n\nuniform vec4 u_highp[5];\n\n${t.varyingOut()} vec2 v_src_tex_coord;\n${t.varyingOut()} vec2 v_dst_tex_coord;\n\nvoid main() {\n mat3 matrix = mat3(u_highp[0].xyz, u_highp[1].xyz, u_highp[2].xyz);\n mat3 src_tex_matrix = mat3(\n u_highp[3].xyz,\n u_highp[4].xyz,\n vec3(u_highp[0].w, u_highp[1].w, u_highp[2].w)\n );\n\n v_src_tex_coord = (src_tex_matrix * vec3(a_vertex, 1.0)).xy;\n v_dst_tex_coord = vec2(a_vertex.x, 1.0 - a_vertex.y);\n\n vec2 position = (matrix * vec3(a_vertex, 1.0)).xy * 2.0 - 1.0;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n\n`}static SRC_TEX_COORD(t){return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n\nuniform vec4 u_highp[5];\n\n${t.varyingOut()} vec2 v_src_tex_coord;\n\nvoid main() {\n mat3 matrix = mat3(u_highp[0].xyz, u_highp[1].xyz, u_highp[2].xyz);\n mat3 src_tex_matrix = mat3(\n u_highp[3].xyz,\n u_highp[4].xyz,\n vec3(u_highp[0].w, u_highp[1].w, u_highp[2].w)\n );\n\n v_src_tex_coord = (src_tex_matrix * vec3(a_vertex, 1.0)).xy;\n\n vec2 position = (matrix * vec3(a_vertex, 1.0)).xy * 2.0 - 1.0;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n\n`}static SRC_AND_ALPHA_TEX_COORD(t){return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n\nuniform vec4 u_highp[7];\n\n${t.varyingOut()} vec2 v_src_tex_coord;\n${t.varyingOut()} vec2 v_alpha_tex_coord;\n\nvoid main() {\n mat3 matrix = mat3(u_highp[0].xyz, u_highp[1].xyz, u_highp[2].xyz);\n mat3 src_tex_matrix = mat3(u_highp[3].xyz, u_highp[4].xyz, u_highp[5].xyz);\n mat3 alpha_tex_matrix = mat3(\n u_highp[6].xyz,\n vec3(u_highp[0].w, u_highp[1].w, u_highp[2].w),\n vec3(u_highp[3].w, u_highp[4].w, u_highp[5].w)\n );\n\n v_src_tex_coord = (src_tex_matrix * vec3(a_vertex, 1.0)).xy;\n v_alpha_tex_coord = (alpha_tex_matrix * vec3(a_vertex, 1.0)).xy;\n\n vec2 position = (matrix * vec3(a_vertex, 1.0)).xy * 2.0 - 1.0;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n\n`}static PIXEL_DISSOLVE_COLOR(t){return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n\nuniform mat3 u_highp[3];\n\nvoid main() {\n mat3 matrix = mat3(u_highp[0].xyz, u_highp[1].xyz, u_highp[2].xyz);\n\n vec2 position = (matrix * vec3(a_vertex, 1.0)).xy * 2.0 - 1.0;\n gl_Position = vec4(position, 0.0, 1.0);\n\n gl_PointSize = 1.0;\n}\n\n`}static PIXEL_DISSOLVE_TEXTURE(t){return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n\nuniform mat3 u_highp[5];\n\n${t.varyingOut()} vec2 v_src_tex_coord;\n\nvoid main() {\n mat3 matrix = mat3(u_highp[0].xyz, u_highp[1].xyz, u_highp[2].xyz);\n mat3 src_tex_matrix = mat3(\n u_highp[3].xyz,\n u_highp[4].xyz,\n vec3(u_highp[0].w, u_highp[1].w, u_highp[2].w)\n );\n\n v_src_tex_coord = (u_src_tex_matrix * vec3(a_vertex, 1.0)).xy;\n\n vec2 position = (u_matrix * vec3(a_vertex, 1.0)).xy * 2.0 - 1.0;\n gl_Position = vec4(position, 0.0, 1.0);\n\n gl_PointSize = 1.0;\n}\n\n`}static SET_PIXEL_QUEUE(t){return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n${t.attribute(1)} vec4 a_color;\n\nuniform mat3 u_highp[3];\n\n${t.varyingOut()} vec2 v_dst_tex_coord;\n${t.varyingOut()} vec4 v_color;\n\nvoid main() {\n mat3 matrix = mat3(u_highp[0].xyz, u_highp[1].xyz, u_highp[2].xyz);\n\n v_dst_tex_coord = vec2(a_vertex.x, 1.0 - a_vertex.y);\n v_color = a_color;\n\n vec2 position = (matrix * vec3(a_vertex, 1.0)).xy * 2.0 - 1.0;\n gl_Position = vec4(position, 0.0, 1.0);\n}\n\n`}}class Dt{static TEMPLATE(t,e,i,s,r){const n=s?this.ATTRIBUTE_BEZIER_ON(t):"",a=s?this.VARYING_BEZIER_ON(t):i?this.VARYING_UV_ON(t):"",o=s?this.STATEMENT_BEZIER_ON():i?this.STATEMENT_UV_ON():"",h=r?Ft.FUNCTION_GRID_ON(i?5:0):Ft.FUNCTION_GRID_OFF();return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n${n}\n\nuniform vec4 u_highp[${e}];\n\n${a}\n\n${h}\n\nvoid main() {\n vec2 viewport = vec2(u_highp[0].w, u_highp[1].w);\n\n ${o}\n\n vec2 pos = applyMatrix(a_vertex) / viewport;\n pos = pos * 2.0 - 1.0;\n gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0);\n}\n\n`}static ATTRIBUTE_BEZIER_ON(t){return`\n${t.attribute(1)} vec2 a_bezier;\n`}static VARYING_UV_ON(t){return`\n${t.varyingOut()} vec2 v_uv;\n`}static VARYING_BEZIER_ON(t){return`\n${t.varyingOut()} vec2 v_bezier;\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 = (inverse_matrix * uv_matrix * vec3(a_vertex, 1.0)).xy;\n"}static STATEMENT_BEZIER_ON(){return"\n v_bezier = a_bezier;\n"}}class Nt{static TEMPLATE(t,e,i,s,r){const n=i-1,a=s?this.VARYING_UV_ON(t):"",o=s?this.STATEMENT_UV_ON():"",h=r?Ft.FUNCTION_GRID_ON(s?5:0):Ft.FUNCTION_GRID_OFF();return`${t.version()}\n\n${t.attribute(0)} vec2 a_vertex;\n${t.attribute(1)} vec2 a_option1;\n${t.attribute(2)} vec2 a_option2;\n${t.attribute(3)} float a_type;\n\nuniform vec4 u_highp[${e}];\n\n${a}\n\n${h}\n\nfloat crossVec2(in vec2 v1, in vec2 v2) {\n return v1.x * v2.y - v2.x * v1.y;\n}\n\nvec2 perpendicularVec2(in vec2 v1) {\n float face = u_highp[${n}][1];\n\n return face * vec2(v1.y, -v1.x);\n}\n\nvec2 calculateNormal(in vec2 direction) {\n vec2 normalized = normalize(direction);\n return perpendicularVec2(normalized);\n}\n\nvec2 calculateIntersection(in vec2 v1, in vec2 v2, in vec2 o1, in vec2 o2) {\n float t = crossVec2(o2 - o1, v2) / crossVec2(v1, v2);\n return (o1 + t * v1);\n}\n\nvec2 calculateAnchor(in vec2 position, in float convex, out vec2 v1, out vec2 v2, out vec2 o1, out vec2 o2) {\n float miter_limit = u_highp[${n}][2];\n\n vec2 a = applyMatrix(a_option1);\n vec2 b = applyMatrix(a_option2);\n\n v1 = convex * (position - a);\n v2 = convex * (b - position);\n o1 = calculateNormal(v1) + a;\n o2 = calculateNormal(v2) + position;\n\n vec2 anchor = calculateIntersection(v1, v2, o1, o2) - position;\n return normalize(anchor) * min(length(anchor), miter_limit);\n}\n\nvoid main() {\n vec2 viewport = vec2(u_highp[0].w, u_highp[1].w);\n float half_width = u_highp[${n}][0];\n\n vec2 position = applyMatrix(a_vertex);\n vec2 offset = vec2(0.0);\n vec2 v1, v2, o1, o2;\n\n if (a_type == 1.0 || a_type == 2.0) { // 線分\n offset = calculateNormal(a_option2 * (applyMatrix(a_option1) - position));\n } else if (a_type == 10.0) { // スクエア線端\n offset = normalize(position - applyMatrix(a_option1));\n offset += a_option2 * perpendicularVec2(offset);\n } else if (a_type == 21.0) { // マイター結合(線分Bの凸側)\n offset = calculateAnchor(position, 1.0, v1, v2, o1, o2);\n offset = calculateIntersection(v2, perpendicularVec2(offset), o2, position + offset) - position;\n } else if (a_type == 22.0) { // マイター結合(線分Aの凸側)\n offset = calculateAnchor(position, 1.0, v1, v2, o1, o2);\n offset = calculateIntersection(v1, perpendicularVec2(offset), o1, position + offset) - position;\n } else if (a_type == 23.0) { // マイター結合(線分Aの凹側)\n offset = calculateAnchor(position, -1.0, v1, v2, o1, o2);\n offset = calculateIntersection(v1, perpendicularVec2(offset), o1, position + offset) - position;\n } else if (a_type == 24.0) { // マイター結合(線分Bの凹側)\n offset = calculateAnchor(position, -1.0, v1, v2, o1, o2);\n offset = calculateIntersection(v2, perpendicularVec2(offset), o2, position + offset) - position;\n } else if (a_type >= 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 Ut{constructor(){this._$rgb=U.RGB,this._$mode=Y.PAD,this._$focalPointRatio=0,this._$points=h.$getFloat32Array6(),this._$stops=h.$getArray(),this._$type=null}linear(t,e,i,s,r=U.RGB,n=Y.PAD){return this._$type=L.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,s,r,n,a=U.RGB,o=Y.PAD,l=0){return this._$type=L.RADIAL,this._$points[0]=t,this._$points[1]=e,this._$points[2]=i,this._$points[3]=s,this._$points[4]=r,this._$points[5]=n,this._$rgb=a,this._$mode=o,this._$focalPointRatio=h.$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 kt{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 Gt{constructor(t,e){this._$gl=t;const i=e?s.min(h.$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 zt,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=I.NORMAL,this._$matrix=h.$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 qt(t,e,i),this._$path=new jt,this._$grid=new Ht,this._$offsetX=0,this._$offsetY=0,this._$blends=[],this._$positions=[],this._$isLayer=!1,this._$shaderList=new ee(this,t),this._$gradientLUT=new ie(this,t),this._$vao=new Zt(t,e),this._$pbo=new Kt(t,e),this._$mask=new Yt(this,t),this._$blend=new Xt(this,t),this._$canvasPatternToWebGL=new kt,this._$canvasGradientToWebGL=new Ut}get canvas(){return this._$gl.canvas}get fillStyle(){return this._$style._$fillStyle}set fillStyle(t){this._$style._$fillStyle.constructor===Float32Array&&h.$poolFloat32Array4(this._$style._$fillStyle),this._$style._$fillStyle=t}get strokeStyle(){return this._$style._$strokeStyle}set strokeStyle(t){this._$style._$strokeStyle.constructor===Float32Array&&h.$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 B.NONE:case B.SQUARE:this._$style._$lineCap=t;break;default:this._$style._$lineCap=B.ROUND}}get lineJoin(){return this._$style._$lineJoin}set lineJoin(t){switch(t){case k.BEVEL:case k.MITER:this._$style._$lineJoin=t;break;default:this._$style._$lineJoin=k.ROUND}}get miterLimit(){return this._$style._$miterLimit}set miterLimit(t){this._$style._$miterLimit=t}get globalAlpha(){return this._$globalAlpha}set globalAlpha(t){this._$globalAlpha=h.$clamp(t,0,1,1)}get imageSmoothingEnabled(){return this._$imageSmoothingEnabled}set imageSmoothingEnabled(t){this._$imageSmoothingEnabled=h.$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,s){if(!i||!s)return;this._$viewportWidth=i,this._$viewportHeight=s;let r=!1;if(!this._$fillBuffer){r=!0;const n=this._$path.createRectVertices(t,e,i,s);this._$fillBuffer=this._$vao.createFill(n),h.$poolArray(n.pop()),h.$poolArray(n)}const n=this._$grid.enabled,a=this._$shaderList.shapeShaderVariants,o=a.getSolidColorShapeShader(!1,n),l=o.uniform;a.setSolidColorShapeUniform(l,!1,0,0,0,n,this._$matrix,this._$viewportWidth,this._$viewportHeight,this._$grid,this.fillStyle,this._$globalAlpha),o._$fill(this._$fillBuffer),r&&(this._$vao.release(this._$fillBuffer),h.$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),h.$poolArray(this._$fillBuffer.indexRanges),h.$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,s=this._$matrix;switch(!0){case this.fillStyle.constructor===Ut:if(this.fillStyle._$type===L.LINEAR);else s=this._$stack[this._$stack.length-1];break;case this.fillStyle.constructor===kt:s=this._$stack[this._$stack.length-1]}const r=this._$grid.enabled;switch(!0){case this.fillStyle.constructor===Ut:{const n=this.fillStyle,a=n._$stops,o="linearRGB"===n._$rgb;if(t=this._$gradientLUT.generateForShape(a,o),this._$frameBufferManager._$textureManager.bind0(t,!0),e=this._$shaderList.gradientShapeShaderVariants,n._$type===L.LINEAR)i=e.getGradientShapeShader(!1,r,!1,!1,n._$mode),e.setGradientShapeUniform(i.uniform,!1,0,0,0,r,s,h.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!1,n._$points,0);else{const t=0!==n._$focalPointRatio;i=e.getGradientShapeShader(!1,r,!0,t,n._$mode),e.setGradientShapeUniform(i.uniform,!1,0,0,0,r,s,h.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!0,n._$points,n._$focalPointRatio)}}break;case this.fillStyle.constructor===kt:{const n=this.fillStyle,a=n.colorTransform;t=n.texture,this._$frameBufferManager._$textureManager.bind0(t,this._$imageSmoothingEnabled),e=this._$shaderList.shapeShaderVariants,i=e.getBitmapShapeShader(!1,""!==n.repeat,r),a?e.setBitmapShapeUniform(i.uniform,!1,0,0,0,r,s,h.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,t.width,t.height,a[0],a[1],a[2],this._$globalAlpha,a[4]/255,a[5]/255,a[6]/255,0):e.setBitmapShapeUniform(i.uniform,!1,0,0,0,r,s,h.$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,r,s,this._$viewportWidth,this._$viewportHeight,this._$grid,this.fillStyle,this._$globalAlpha)}const n=this._$shaderList.shapeShaderVariants,a=n.getMaskShapeShader(!1,r);if(n.setMaskShapeUniform(a.uniform,r,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],this._$viewportWidth,this._$viewportHeight,this._$grid),!this._$fillBuffer){const t=this._$getVertices();if(!t.length)return;const e=h.$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),h.$poolArray(i.pop()),h.$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),a._$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=h.$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===Ut:if(this.strokeStyle._$type===L.LINEAR);else t=this._$stack[this._$stack.length-1];break;case this.strokeStyle.constructor===kt: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*=h.$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 l,_,$;n*=o*(1-.3*s.cos(.5*s.PI*(a/o))),n=s.max(1,n);const c=this._$grid.enabled;switch(!0){case this.strokeStyle.constructor===Ut:{const i=this.strokeStyle,s=i._$stops,r="linearRGB"===i._$rgb;if(l=this._$gradientLUT.generateForShape(s,r),this._$frameBufferManager._$textureManager.bind0(l,!0),_=this._$shaderList.gradientShapeShaderVariants,i._$type===L.LINEAR)$=_.getGradientShapeShader(!0,c,!1,!1,i._$mode),_.setGradientShapeUniform($.uniform,!0,n,e,this.miterLimit,c,t,h.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!1,i._$points,0);else{const s=0!==i._$focalPointRatio;$=_.getGradientShapeShader(!0,c,!0,s,i._$mode),_.setGradientShapeUniform($.uniform,!0,n,e,this.miterLimit,c,t,h.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,!0,i._$points,i._$focalPointRatio)}}break;case this.strokeStyle.constructor===kt:{const i=this.strokeStyle,s=i.colorTransform;l=i.texture,this._$frameBufferManager._$textureManager.bind0(l),_=this._$shaderList.shapeShaderVariants,$=_.getBitmapShapeShader(!0,""!==i.repeat,this._$grid.enabled),s?_.setBitmapShapeUniform($.uniform,!0,n,e,this.miterLimit,c,t,h.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,l.width,l.height,s[0],s[1],s[2],this._$globalAlpha,s[4]/255,s[5]/255,s[6]/255,0):_.setBitmapShapeUniform($.uniform,!0,n,e,this.miterLimit,c,t,h.$inverseMatrix(this._$matrix),this._$viewportWidth,this._$viewportHeight,this._$grid,l.width,l.height,1,1,1,this._$globalAlpha,0,0,0,0)}break;default:_=this._$shaderList.shapeShaderVariants,$=_.getSolidColorShapeShader(!0,this._$grid.enabled),_.setSolidColorShapeUniform($.uniform,!0,n,e,this.miterLimit,c,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),s=i.uniform;if(e.setMaskShapeUniform(s,!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),h.$poolArray(t.pop()),h.$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),h.$poolArray(this._$fillBuffer.indexRanges),h.$poolArray(this._$fillBuffer.boundObject.indexRanges),this._$fillBuffer=null),this.beginPath())}save(){const t=this._$matrix;this._$stack.push(h.$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&&(h.$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=U.RGB,n=Y.PAD){return this._$canvasGradientToWebGL.linear(t,e,i,s,r,n)}createRadialGradient(t,e,i,s,r,n,a=U.RGB,o=Y.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,p,m,x,b,T,v,y,E,A){const M=c===W.INNER,C=this._$frameBufferManager.currentAttachment,S=this._$frameBufferManager.getTextureFromCurrentAttachment();let R;const w=null!==g;let O;w&&(R=this._$gradientLUT.generateForFilter(g,f,p)),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===W.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,m,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 p=this._$shaderList.filterShaderVariants,m=p.getDisplacementMapFilterShader(n,a,l);p.setDisplacementMapFilterUniform(m.uniform,e.width,e.height,i,s,r.x,r.y,o,h,l,_,$,c,u),this.blend.reset(),m._$drawImage()}getImageData(t,e,i,r){const n=i*r*4,a=h.$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 Xt{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 I.ADD:this.toAdd();break;case I.SCREEN:this.toScreen();break;case I.ALPHA:this.toAlpha();break;case I.ERASE:this.toErase();break;case"copy":this.toOneZero();break;default:this.reset()}}drawImage(t,e,i,n,a,o,l,_,$,c,u,d,g,f,p,m,x,b){const T=this._$context._$frameBufferManager.currentAttachment,v=1!==o||1!==l||1!==_||1!==$||0!==c||0!==u||0!==d||0!==g,y=this._$context._$shaderList.blendShaderVariants;switch(f){case I.NORMAL:case I.LAYER:case I.ADD:case I.SCREEN:case I.ALPHA:case I.ERASE:case"copy":{this._$context._$frameBufferManager._$textureManager.bind0(t,b);const h=y.getNormalBlendShader(v);y.setNormalBlendUniform(h.uniform,e,i,n,a,x,p,m,v,o,l,_,$,c,u,d,g);const T=x[0],E=x[1],A=x[3],M=x[4],C=x[6],S=x[7];if(1!==T||0!==E||0!==A||1!==M){const t=e+n,o=i+a,h=+(t*T+o*A+C),l=+(t*T+i*A+C),_=+(e*T+o*A+C),$=+(e*T+i*A+C),c=+(t*E+o*M+S),u=+(t*E+i*M+S),d=+(e*E+o*M+S),g=+(e*E+i*M+S),f=r.MAX_VALUE,x=+s.min(s.min(s.min(s.min(f,h),l),_),$),b=+s.max(s.max(s.max(s.max(-f,h),l),_),$),v=+s.min(s.min(s.min(s.min(f,c),u),d),g),y=+s.max(s.max(s.max(s.max(-f,c),u),d),g),R=s.max(0,0|x),w=s.max(0,0|v),O=s.min(s.max(0,p-R),s.ceil(s.abs(b-x))),I=s.min(s.max(0,m-w),s.ceil(s.abs(y-v)));if(!O||!I)return;this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(R,s.max(0,m-(w+I)),O+1,I+1)}else{const t=s.max(0,e+C|0),r=s.max(0,i+S|0),o=s.min(s.max(0,p-t),n),h=s.min(s.max(0,m-r),a);if(!o||!h)return;this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(t,s.max(0,m-(r+h)),o+1,h+1)}this.toOperation(f),h._$drawImage(),this._$gl.disable(this._$gl.SCISSOR_TEST)}break;default:{const r=s.max(0,e+x[6]|0),E=s.max(0,i+x[7]|0),A=s.min(s.max(0,p-r),n),M=s.min(s.max(0,m-E),a);if(!A||!M)return;const C=this._$context._$frameBufferManager.getTextureFromCurrentAttachment(),S=this._$context._$frameBufferManager.createTextureAttachment(n,a);this._$context._$bind(S),this._$context._$frameBufferManager._$textureManager.bind0(C);const R=y.getClipShader(),w=R.uniform;y.setClipUniform(w,e,i,n,a,h.$inverseMatrix(x),p,m),this.reset(),R._$drawImage();const O=this._$context._$frameBufferManager.getTextureFromCurrentAttachment();this._$context._$bind(T),this._$context._$frameBufferManager._$textureManager.bind01(O,t,b);const I=y.getBlendShader(f,v);y.setBlendUniform(I.uniform,e,i,n,a,x,p,m,v,o,l,_,$,c,u,d,g),this._$gl.enable(this._$gl.SCISSOR_TEST),this._$gl.scissor(r,s.max(0,m-(E+M)),A,M),this.toOneZero(),I._$drawImage(),this._$gl.disable(this._$gl.SCISSOR_TEST),this._$context._$frameBufferManager.releaseAttachment(S,!0)}}}}class Ht{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}enable(t,e,i,r,n,a,o,l,_,$,c,u,d,g,f,p,m,x){const b=n.xMax-n.xMin,T=n.yMax-n.yMin,v=a._$width,y=a._$height,E=h.$currentPlayer(),A=E._$scale*E._$ratio,M=s.abs(s.ceil(b*A)),C=s.abs(s.ceil(T*A)),S=v>0?(a._$x-n.xMin)/b:1e-5,R=y>0?(a._$y-n.yMin)/T:1e-5,w=v>0?(a._$x+a._$width-n.xMin)/b:.99999,O=y>0?(a._$y+a._$height-n.yMin)/T:.99999;let I=M*S/i,B=C*R/r,F=(i-M*(1-w))/i,L=(r-C*(1-O))/r;if(I>=F){const t=S/(S+(1-w));I=s.max(t-1e-5,0),F=s.min(t+1e-5,1)}if(B>=L){const t=R/(R+(1-O));B=s.max(t-1e-5,0),L=s.min(t+1e-5,1)}this.enabled=!0,this.parentMatrixA=o,this.parentMatrixB=l,this.parentMatrixD=_,this.parentMatrixE=$,this.parentMatrixG=c,this.parentMatrixH=u,this.ancestorMatrixA=d,this.ancestorMatrixB=g,this.ancestorMatrixD=f,this.ancestorMatrixE=p,this.ancestorMatrixG=m,this.ancestorMatrixH=x,this.parentViewportX=t,this.parentViewportY=e,this.parentViewportW=i,this.parentViewportH=r,this.minXST=S,this.minYST=R,this.minXPQ=I,this.minYPQ=B,this.maxXST=w,this.maxYST=O,this.maxXPQ=F,this.maxYPQ=L}disable(){this.enabled=!1}}class Yt{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 s=this._$context._$cacheCurrentBounds.x,r=this._$context._$cacheCurrentBounds.y,n=this._$context._$cacheCurrentBounds.w,a=this._$context._$cacheCurrentBounds.h;h.$resetContext(this._$context),this._$context.setTransform(1,0,0,1,0,0),this._$context.drawImage(e,s,r,n,a),this._$context._$blend.enable(),t.releaseAttachment(i,!0)}_$startClip(t,e){const i=h.$multiplicationMatrix(e,t._$transform._$rawMatrix()),r=t._$getBounds(null),n=h.$boundsMatrix(r,i);h.$poolFloat32Array9(i),h.$poolBoundsObject(r);let a=n.xMin,o=n.yMin,l=s.abs(n.xMax-n.xMin),_=s.abs(n.yMax-n.yMin);h.$poolBoundsObject(n);const $=this._$context._$frameBufferManager,c=$.currentAttachment;if(l+a>c.texture.width&&(l-=l-c.texture.width+a),_+o>c.texture.height&&(_-=_-c.texture.height+o),0>a&&(l+=a,a=0),0>o&&(_+=o,o=0),0>=l||0>=_)return null;l=s.ceil(l),_=s.ceil(_),this._$context._$cacheCurrentBounds.x=a,this._$context._$cacheCurrentBounds.y=o,this._$context._$cacheCurrentBounds.w=l,this._$context._$cacheCurrentBounds.h=_;const u=$.getTextureFromCurrentAttachment();this._$context._$cacheCurrentBuffer=c;const d=h.$currentPlayer(),g=!this._$context._$isWebGL2Context||d._$quality!==z.LOW&&d._$quality!==z.MIDDLE?0:s.min(h.$HIGH_SAMPLES,this._$gl.getParameter(this._$gl.MAX_SAMPLES)),f=$.createCacheAttachment(l,_,!0,g);return this._$context._$bind(f),h.$resetContext(this._$context),this._$context.setTransform(1,0,0,1,0,0),this._$context.drawImage(u,-a,-o,u.width,u.height),h.$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 s=this._$context._$path.createRectVertices(0,0,e,i),r=this._$context._$vao.createFill(s);h.$poolArray(s.pop()),h.$poolArray(s);const n=this._$context._$shaderList.shapeShaderVariants,a=n.getMaskShapeShader(!1,!1),o=a.uniform;n.setMaskShapeUniformIdentity(o,e,i);const l=r.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 Wt={vertices:null};Wt.subhulls=new Array(512),Wt.subhullsIndex=0,Wt.extremePoints=new Array(32),Wt.extremePointsIndex=0,Wt.t=0,Wt.hulls=[new Array(16),new Array(64),new Array(256)],Wt.hullsIndex=0;class qt{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 Jt(t,e),this._$colorBufferPool=null,this._$stencilBufferPool=new Qt(t),e&&(this._$frameBufferTexture=t.createFramebuffer(),this._$colorBufferPool=new Vt(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 Kt{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 Qt{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 Jt{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,s){const r=i!==this._$boundTextures[t],n=null!==s&&s!==i.smoothing;if((r||n||e===this._$gl.TEXTURE0)&&e!==this._$activeTexture&&(this._$activeTexture=e,this._$gl.activeTexture(e)),r&&(this._$boundTextures[t]=i,this._$gl.bindTexture(this._$gl.TEXTURE_2D,i)),n){i.smoothing=s;const t=s&&h.$currentPlayer()._$quality!==z.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 Zt{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 a([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 a(2*this._$vertexBufferData.length);t.set(this._$vertexBufferData),this._$vertexBufferData=t}}static _$expandIndexBufferIfNeeded(t){if(this._$indexBufferPos+t>this._$indexBufferData.length){const t=new o(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 ae{constructor(){this._$stage=new j,this._$stage._$player=this,this._$cacheStore=new yt,this._$mode="loader",this._$actionOffset=0,this._$actions=h.$getArray(),this._$loaders=h.$getArray(),this._$sounds=h.$getMap(),this._$hitObject={x:0,y:0,pointer:"",hit:null},this._$rollOverObject=null,this._$mouseOverTarget=null,this._$mouseWheelEvent=null,this._$ratio=h.$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 a([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=h.$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=z.HIGH,this._$sources=h.$getArray(),this._$videos=h.$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=`${h.$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`${h.$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,h.$cancelAnimationFrame)(this._$timerId)}this._$startTime=h.$performance.now(),this._$fps=1e3/this._$stage._$frameRate;const t=h.$requestAnimationFrame;this._$timerId=t(this._$bindRun)}}stop(){(0,h.$cancelAnimationFrame)(this._$timerId),this._$stopFlag=!0,this._$timerId=-1,ut.stopAll(),h.$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===ae.LOAD_END)return void this._$loaded();const t=h.$requestAnimationFrame;this._$loadId=t(this._$updateLoadStatus.bind(this))}_$loaded(){const t=h.$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($.FRAME_CONSTRUCTED)&&this._$dispatchEvent(new $($.FRAME_CONSTRUCTED)),this._$doAction(),this._$broadcastEvents.has($.EXIT_FRAME)&&this._$dispatchEvent(new $($.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),s=i.parentNode;if(s){this._$initStyle(i),this._$buildWait();const t=this._$optionWidth?this._$optionWidth:"BODY"===s.tagName?h.$window.innerWidth:s.offsetWidth,e=this._$optionHeight?this._$optionHeight:"BODY"===s.tagName?h.$window.innerHeight:s.offsetHeight;"loader"===this._$mode&&t&&e&&(this._$baseWidth=t,this._$baseHeight=e,this._$resize())}"loader"===this._$mode?(this._$loadStatus=ae.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=h.$document.getElementById(this.contentElementId);if(t){const e=`${this.contentElementId}_loading`;t.innerHTML=``;const i=h.$document.createElement("div");i.id=e,t.appendChild(i)}}_$deleteNode(){const t=h.$document.getElementById(this.contentElementId);if(t)for(;t.childNodes.length;)t.removeChild(t.childNodes[0])}_$initializeCanvas(){const e=h.$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 s=!0,r=e.getContext("webgl2",i);if(r||(r=e.getContext("webgl",i)||e.getContext("experimental-webgl",i),s=!1),r?this._$context=new Gt(r,s):alert("WebGL setting is off. Please turn the setting on."),t.glstats&&glstats.init(r,s,h.$isChrome,h.$isFireFox),h.$isTouch){const t=function(e){e.target.removeEventListener(h.$TOUCH_END,t),h.$loadAudioData()};e.addEventListener(h.$TOUCH_END,t),e.addEventListener(h.$TOUCH_START,function(t){h.$event=t,h.$eventType=h.$TOUCH_START,this._$hitTest()}.bind(this)),e.addEventListener(h.$TOUCH_MOVE,function(t){h.$event=t,h.$eventType=h.$TOUCH_MOVE,this._$hitTest()}.bind(this)),e.addEventListener(h.$TOUCH_END,function(t){h.$event=t,h.$eventType=h.$TOUCH_END,this._$hitTest()}.bind(this))}else{const t=function(e){e.target.removeEventListener(h.$MOUSE_DOWN,t),h.$loadAudioData()};e.addEventListener(h.$MOUSE_DOWN,t),e.addEventListener(h.$MOUSE_DOWN,function(t){h.$event=t,h.$eventType=h.$MOUSE_DOWN,t.button||this._$hitTest()}.bind(this)),e.addEventListener(h.$DOUBLE_CLICK,function(t){h.$event=t,h.$eventType=h.$DOUBLE_CLICK,t.button||this._$hitTest()}.bind(this)),e.addEventListener(h.$MOUSE_LEAVE,function(t){h.$event=t,h.$eventType=h.$MOUSE_LEAVE,this._$hitTest(),h.$event=null,this._$stageX=-1,this._$stageY=-1}.bind(this)),e.addEventListener(h.$MOUSE_UP,function(t){h.$event=t,h.$eventType=h.$MOUSE_UP,t.button||this._$hitTest()}.bind(this)),e.addEventListener(h.$MOUSE_MOVE,function(t){h.$event=t,h.$eventType=h.$MOUSE_MOVE,this._$hitTest()}.bind(this)),e.addEventListener(h.$MOUSE_WHEEL,function(t){this._$mouseWheelEvent=t}.bind(this))}const n=e.style;n.position="absolute",n.top="0",n.left="0",n.webkitTapHighlightColor="rgba(0,0,0,0)",n.backfaceVisibility="hidden",n.transformOrigin="0 0",1!==h.$devicePixelRatio&&(n.transform=`scale(${1/h.$devicePixelRatio})`)}_$resize(){const t=h.$document.getElementById(this.contentElementId);if(t){const e=t.parentNode,i=this._$optionWidth?this._$optionWidth:"BODY"===e.tagName?h.$window.innerWidth:e.offsetWidth?e.offsetWidth:h.$parseFloat(e.style.width),r=this._$optionHeight?this._$optionHeight:"BODY"===e.tagName?h.$window.innerHeight:e.offsetHeight?e.offsetHeight:h.$parseFloat(e.style.height),n="BODY"===e.tagName?h.$window.innerWidth:e.offsetWidth,a=s.min(i/this._$baseWidth,r/this._$baseHeight);let o=this._$fullScreen?i:this._$baseWidth*a|0,l=this._$fullScreen?r:this._$baseHeight*a|0;const _=t.style;if(_.width=`${o}px`,_.height=`${l}px`,_.top="0",_.left=this._$fullScreen?"0":n/2-o/2+"px",o*=h.$devicePixelRatio,l*=h.$devicePixelRatio,this._$scale=a,this._$width=o,this._$height=l,this._$canvas.width=o,this._$canvas.height=l,this._$canvas.style.transform=1===this._$ratio&&1===h.$devicePixelRatio?"":`scale(${1/this._$ratio})`,this._$context){this._$context._$gl.viewport(0,0,o,l);const t=this._$context._$frameBufferManager;this._$buffer&&(t.unbind(),t.releaseAttachment(this._$buffer,!0)),this._$buffer=t.createCacheAttachment(o,l,!1),t._$stencilBufferPool._$maxWidth=o,t._$stencilBufferPool._$maxHeight=l,t._$textureManager._$maxWidth=o,t._$textureManager._$maxHeight=l,this._$context._$pbo._$maxWidth=o,this._$context._$pbo._$maxHeight=l}const $=this._$scale*this._$ratio;this._$matrix[0]=$,this._$matrix[3]=$,this._$fullScreen&&(this._$tx=(o-this._$baseWidth*a*h.$devicePixelRatio)/2,this._$ty=(l-this._$baseHeight*a*h.$devicePixelRatio)/2,this._$matrix[4]=this._$tx,this._$matrix[5]=this._$ty),t.children.length>1&&t.children[1].dispatchEvent(new h.$window.Event(`${h.$PREFIX}_blur`)),this._$stage._$doChanged(),this._$cacheStore.reset()}}getSamples(){switch(this._$quality){case z.HIGH:return h.$HIGH_SAMPLES;case z.MEDIUM:return h.$MEDIUM_SAMPLES;default:return h.$LOW_SAMPLES}}_$dispatchEvent(t){if(this._$broadcastEvents.size&&this._$broadcastEvents.has(t.type)){const e=this._$broadcastEvents.get(t.type).slice(0);t._$eventPhase=u.AT_TARGET;const i=e.length;for(let s=0;sthis._$fps&&(this._$startTime=e-i%this._$fps,this._$action(),this._$draw(0),!this._$hitTestStart&&"up"===this._$state&&h.$event&&this._$stageX>-1&&this._$stageY>-1&&this._$pointerCheck()),t.stats&&stats.end(),t.glstats&&glstats.end();const s=h.$requestAnimationFrame;this._$timerId=s(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,h.$hitContext.setTransform(1,0,0,1,0,0),h.$hitContext.beginPath(),h.$MATRIX_HIT_ARRAY_IDENTITY[4]=this._$tx/this._$scale/h.$devicePixelRatio,h.$MATRIX_HIT_ARRAY_IDENTITY[5]=this._$ty/this._$scale/h.$devicePixelRatio,this._$stage._$mouseHit(h.$hitContext,h.$MATRIX_HIT_ARRAY_IDENTITY,this._$hitObject,!0);let i=null,s=null,r=!1,n=!1;if(this._$hitObject.hit){if(i=this._$hitObject.hit,this._$mouseOverTarget&&this._$mouseOverTarget!==i){const t=this._$mouseOverTarget;t.willTrigger(p.MOUSE_OUT)&&t.dispatchEvent(new p(p.MOUSE_OUT,!0,!1,t.mouseX,t.mouseY))}if(this._$rollOverObject!==i){let r=null;if(this._$rollOverObject)for(s=this._$rollOverObject,s.willTrigger(p.ROLL_OUT)&&s.dispatchEvent(new p(p.ROLL_OUT,!1,!1,s.mouseX,s.mouseY)),r=s._$parent;r&&r._$root!==r&&r!==i;){if(r._$mouseEnabled&&r._$outCheck(t,e)){let t=!1,e=i;for(;e&&e._$root!==e;){if(e===r){t=!0;break}e=e._$parent}if(!t&&r._$parent===i._$parent&&r._$index>i._$index&&(t=!0),t)break}r.willTrigger(p.ROLL_OUT)&&r.dispatchEvent(new p(p.ROLL_OUT,!1,!1,r.mouseX,r.mouseY)),r=r._$parent}for(s=i;s.willTrigger(p.ROLL_OVER)&&s.dispatchEvent(new p(p.ROLL_OVER,!1,!1,s.mouseX,s.mouseY)),s=s._$parent,s&&s!==r&&s.stage!==s;);}switch(this._$rollOverObject=i,!0){case null===this._$mouseOverTarget:case this._$mouseOverTarget!==i:i.willTrigger(p.MOUSE_OVER)&&i.dispatchEvent(new p(p.MOUSE_OVER,!0,!1,i.mouseX,i.mouseY)),this._$mouseOverTarget=i}if("up"===this._$state&&(this._$clickTarget=null),!h.$isTouch&&"up"===this._$state)for(s=i;s&&s.root!==s;){switch(!0){case s instanceof ht:s._$type===lt.INPUT&&(r=!0);break;case s.buttonMode:n=!0}if(r||n)break;s=s._$parent}}else{if(this._$mouseOverTarget&&(i=this._$mouseOverTarget,i.willTrigger(p.MOUSE_OUT)&&i.dispatchEvent(new p(p.MOUSE_OUT,!0,!1,i.mouseX,i.mouseY))),this._$rollOverObject)for(s=this._$rollOverObject;s&&s.root!==s;)s.willTrigger(p.ROLL_OUT)&&s.dispatchEvent(new p(p.ROLL_OUT,!1,!1,s.mouseX,s.mouseY)),s=s._$parent;this._$rollOverObject=null,this._$mouseOverTarget=null}switch(!0){case r:this._$canvas.style.cursor="text";break;case n:this._$canvas.style.cursor="pointer";break;case!h.$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(s._$bind(this._$buffer),h.$resetContext(s),s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e,i),s.beginPath(),this._$stage._$draw(s,this._$matrix,h.$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=s.frameBuffer.getTextureFromCurrentAttachment();s.frameBuffer.unbind(),h.$resetContext(s),s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e,i),s.drawImage(t,0,0,e,i),s._$bind(this._$buffer)}}_$doAction(){for(;this._$actions.length;){h.$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),s=i.length;for(let e=0;ee._$index&&(i=!0),i)break}t.willTrigger(p.ROLL_OUT)&&t.dispatchEvent(new p(p.ROLL_OUT,!1,!1,t.mouseX,t.mouseY)),t=t._$parent}for(i=e;i.willTrigger(p.ROLL_OVER)&&i.dispatchEvent(new p(p.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(p.MOUSE_OVER)&&e.dispatchEvent(new p(p.MOUSE_OVER,!0,!1,e.mouseX,e.mouseY)),this._$mouseOverTarget=e}"up"===this._$state&&(this._$clickTarget=null);break;case h.$TOUCH_START:case h.$MOUSE_DOWN:e!==this._$textField&&this._$textField instanceof ht&&(this._$textField.focus=!1,this._$textField=null),e instanceof ht&&(e.focus=!0,this._$textField=e),e.willTrigger(p.MOUSE_DOWN)&&e.dispatchEvent(new p(p.MOUSE_DOWN,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget=e;break;case h.$TOUCH_END:case h.$MOUSE_UP:e!==this._$textField&&this._$textField instanceof ht&&(this._$textField.focus=!1,this._$textField=null),e.willTrigger(p.MOUSE_UP)&&e.dispatchEvent(new p(p.MOUSE_UP,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget===e&&e.willTrigger(p.CLICK)&&e.dispatchEvent(new p(p.CLICK,!0,!1,e.mouseX,e.mouseY)),this._$clickTarget=null;break;case h.$MOUSE_WHEEL:e.willTrigger(p.MOUSE_WHEEL)&&e.dispatchEvent(new p(p.MOUSE_WHEEL)),e instanceof ht&&(e.scrollV+=t.deltaY);break;case h.$DOUBLE_CLICK:e.willTrigger(p.DOUBLE_CLICK)&&e.dispatchEvent(new p(p.DOUBLE_CLICK))}if(!_&&!h.$isTouch&&"up"===this._$state)for(i=e;i&&i.root!==i;){if(i instanceof ht){if(i._$type===lt.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!h.$isTouch&&"up"===this._$state:this._$canvas.style.cursor="auto"}!h.$actionProcess&&this._$actions.length>1&&this._$doAction(),h.$isUpdated&&(this._$stage._$prepareActions(),h.$actionProcess||this._$doAction()),this._$hitTestStart=!1}}h.$window.next2d=new class{constructor(){this._$player=new ae}load(t,e=null){if("develop"===t){const e=h.$location.search.substr(1).split("&")[0];if(!e)return;t=`${h.$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 G,s=i.contentLoaderInfo;s.addEventListener(f.IO_ERROR,(t=>{t.target.removeEventListener(f.IO_ERROR,t.listener),alert("Error: "+t.message)})),s.addEventListener($.COMPLETE,(t=>{const e=t.target;e.removeEventListener($.COMPLETE,t.listener);const i=h.$currentPlayer(),s=i.stage,r=e._$data.stage;if(i.width=r.width,i.height=r.height,i.stage.frameRate=r.fps,null===i._$bgColor){const t=h.$intToRGBA(0|`0x${r.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]}s.addChild(e.content),i._$resize()})),i.load(new pt(t))}createRootMovieClip(t=240,e=240,i=24,s=null){const r=this._$player;return r._$loadStatus=ae.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 S)}},h.$packages(h.$window.next2d),console.log("%c Next2D Player %c 1.6.0 %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 24ae022e..34d7ef7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@next2d/player", - "version": "1.5.3", + "version": "1.6.0", "description": "Experience the fast and beautiful anti-aliased rendering of WebGL. You can create rich, interactive graphics, cross-platform applications and games without worrying about browser or device compatibility.", "author": "Toshiyuki Ienaga", "license": "MIT",