tencentcloud-webar 2.0.3-dev.1 → 2.0.3-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ var self = wx;(self.webpackChunktencentcloud_webar=self.webpackChunktencentcloud_webar||[]).push([[790],{2790:(t,n,o)=>{o.r(n),o.d(n,{PhysicsController:()=>c,PhysicsModelParser:()=>i});var i=function(){function t(t){this.CANNON=t}return t.prototype.parse=function(t){var n,o,i=this,s=[],e=new Map;return t.traverse((function(t){if(t.name){var n=t.name.toLowerCase();if(console.log('解析节点: "'.concat(t.name,'", 类型: ').concat(t.type,", 位置:"),t.position),/_\d+$/.test(n))console.log(" -> 跳过拆分子节点: ".concat(t.name));else if(i.isAnchor(n))e.has("anchor")||e.set("anchor",[]),e.get("anchor").push(t);else if(i.isChain(n)){var o=i.extractChainIndex(n),s="chain-".concat(o);e.has(s)||e.set(s,[]),e.get(s).push(t)}else i.isPendant(n)&&(e.has("pendant")||e.set("pendant",[]),e.get("pendant").push(t))}})),n=this.selectBestCandidate(e.get("anchor")),o=this.selectBestCandidate(e.get("pendant")),Array.from(e.keys()).filter((function(t){return t.startsWith("chain-")})).sort((function(t,n){return parseInt(t.split("-")[1])-parseInt(n.split("-")[1])})).forEach((function(t){var n=i.selectBestCandidate(e.get(t));n&&s.push(n)})),o&&!s.includes(o)&&s.push(o),console.log("解析结果:",{anchor:null==n?void 0:n.name,chains:s.map((function(t){return t.name})),pendant:null==o?void 0:o.name}),{anchorMesh:n,chainMeshes:s,pendantMesh:o}},t.prototype.selectBestCandidate=function(t){if(!t||0===t.length)return null;var n=t.filter((function(t){return"Group"===t.type}));if(n.length>0)return console.log(" -> 选择 Group: ".concat(n[0].name)),n[0];var o=t.filter((function(t){return"Mesh"===t.type}));return o.length>0?(console.log(" -> 选择 Mesh: ".concat(o[0].name)),o[0]):(console.log(" -> 选择默认: ".concat(t[0].name)),t[0])},t.prototype.isAnchor=function(t){return t.startsWith("anchor")},t.prototype.isChain=function(t){return t.startsWith("chain")},t.prototype.isPendant=function(t){return t.startsWith("pendant")},t.prototype.extractChainIndex=function(t){var n=t.match(/chain-(\d+)/);return n?parseInt(n[1])-1:0},t}(),s=function(){return s=Object.assign||function(t){for(var n,o=1,i=arguments.length;o<i;o++)for(var s in n=arguments[o])Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s]);return t},s.apply(this,arguments)},e=function(t,n,o,i){return new(o||(o=Promise))((function(s,e){function r(t){try{a(i.next(t))}catch(t){e(t)}}function h(t){try{a(i.throw(t))}catch(t){e(t)}}function a(t){var n;t.done?s(t.value):(n=t.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,h)}a((i=i.apply(t,n||[])).next())}))},r=function(t,n){var o,i,s,e,r={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return e={next:h(0),throw:h(1),return:h(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function h(e){return function(h){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;r;)try{if(o=1,i&&(s=2&e[0]?i.return:e[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,e[1])).done)return s;switch(i=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return r.label++,{value:e[1],done:!1};case 5:r.label++,i=e[1],e=[0];continue;case 7:e=r.ops.pop(),r.trys.pop();continue;default:if(!(s=r.trys,(s=s.length>0&&s[s.length-1])||6!==e[0]&&2!==e[0])){r=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){r.label=e[1];break}if(6===e[0]&&r.label<s[1]){r.label=s[1],s=e;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(e);break}s[2]&&r.ops.pop(),r.trys.pop();continue}e=n.call(t,r)}catch(t){e=[6,t],i=0}finally{o=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,h])}}},h=function(t,n){var o="function"==typeof Symbol&&t[Symbol.iterator];if(!o)return t;var i,s,e=o.call(t),r=[];try{for(;(void 0===n||n-- >0)&&!(i=e.next()).done;)r.push(i.value)}catch(t){s={error:t}}finally{try{i&&!i.done&&(o=e.return)&&o.call(e)}finally{if(s)throw s.error}}return r},a=function(t,n,o){if(o||2===arguments.length)for(var i,s=0,e=n.length;s<e;s++)!i&&s in n||(i||(i=Array.prototype.slice.call(n,0,s)),i[s]=n[s]);return t.concat(i||Array.prototype.slice.call(n))},c=function(){function t(t,n){void 0===t&&(t={}),this.chainBodies=[],this.meshes=[],this.constraints=[],this.originalTransforms=[],this.spacing=1.2,this.ANCHOR_SWING_ANGLE=15,this.initialized=!1,this.groupScale=1,this.lastAnchorPosition={x:0,y:0,z:0},this.smoothedAnchorPosition={x:0,y:0,z:0},this.GRAVITY_SCALE=14.3,this.config=s({gravity:-9.8,damping:.8,mass:.05,swingAngle:5},t),this.anchorPoint=n||""}return t.prototype.init=function(t){var n;return e(this,void 0,Promise,(function(){var s,e,c,l,d,p,u,y,f,g,N,A,v,w,m;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),s=this,[4,o.e(541).then(o.bind(o,2415))];case 1:return s.CANNON=r.sent(),e=(null!==(n=this.config.gravity)&&void 0!==n?n:-9.8)*this.GRAVITY_SCALE,this.world=new this.CANNON.World({gravity:new this.CANNON.Vec3(0,e,0)}),this.world.solver.iterations=20,console.log("PhysicsController: cannon-es 加载成功"),c=new i(this.CANNON),l=c.parse(t),d=l.anchorMesh,p=l.chainMeshes,u=l.pendantMesh,d&&0!==p.length?(p.length>=1&&(y=d.position,f=p[0].position,console.log("=== 间距计算详情 ==="),console.log('锚点 "'.concat(d.name||"anchor",'" 位置:'),{x:y.x.toFixed(6),y:y.y.toFixed(6),z:y.z.toFixed(6)}),console.log('第一个链节 "'.concat(p[0].name||"chain_1",'" 位置:'),{x:f.x.toFixed(6),y:f.y.toFixed(6),z:f.z.toFixed(6)}),g=f.x-y.x,N=f.y-y.y,A=f.z-y.z,console.log("位置差值:",{deltaX:g.toFixed(6),deltaY:N.toFixed(6),deltaZ:A.toFixed(6)}),this.spacing=Math.sqrt(g*g+N*N+A*A),console.log("计算过程:"),console.log(" √(".concat(g.toFixed(6),"² + ").concat(N.toFixed(6),"² + ").concat(A.toFixed(6),"²)")),console.log(" = √(".concat((g*g).toFixed(6)," + ").concat((N*N).toFixed(6)," + ").concat((A*A).toFixed(6),")")),console.log(" = √".concat((g*g+N*N+A*A).toFixed(6))),console.log(" = ".concat(this.spacing.toFixed(6))),console.log("=== 所有链节间距离 ==="),v=y,w=d.name||"anchor",p.forEach((function(t,n){var o=t.position,i=t.name||"chain_".concat(n+1),s=Math.sqrt(Math.pow(o.x-v.x,2)+Math.pow(o.y-v.y,2)+Math.pow(o.z-v.z,2));console.log("".concat(w," → ").concat(i,": ").concat(s.toFixed(6))),v=o,w=i}))),console.log("PhysicsController: 模型间距 =",this.spacing,"m"),this.meshes=a([d],h(p),!1),u&&!p.includes(u)&&this.meshes.push(u),this.originalTransforms=this.meshes.map((function(t){return{position:{x:t.position.x,y:t.position.y,z:t.position.z},quaternion:{x:t.quaternion.x,y:t.quaternion.y,z:t.quaternion.z,w:t.quaternion.w}}})),this.createPhysicsBodies(),this.initialized=!0,console.log("PhysicsController: 初始化完成,".concat(this.chainBodies.length," 个链节")),[3,3]):(console.warn("PhysicsController: 未找到锚点或链节"),[2]);case 2:throw m=r.sent(),console.error("PhysicsController: 初始化失败",m),m;case 3:return[2]}}))}))},t.prototype.createPhysicsBodies=function(){var t,n,o,i,s,e,r=.3*this.spacing;this.hiddenAnchor=new this.CANNON.Body({mass:0,type:this.CANNON.Body.KINEMATIC,position:new this.CANNON.Vec3(0,0,0),shape:new this.CANNON.Sphere(.5*r)}),this.world.addBody(this.hiddenAnchor);var h=this.meshes[0];this.anchorBody=new this.CANNON.Body({mass:.5*(null!==(t=this.config.mass)&&void 0!==t?t:.05),position:new this.CANNON.Vec3((null==h?void 0:h.position.x)||0,(null==h?void 0:h.position.y)||0,(null==h?void 0:h.position.z)||0),shape:new this.CANNON.Sphere(r),linearDamping:.8,angularDamping:.8}),this.world.addBody(this.anchorBody);var a=new this.CANNON.DistanceConstraint(this.hiddenAnchor,this.anchorBody,0);this.world.addConstraint(a),this.constraints.push(a);var c=this.ANCHOR_SWING_ANGLE*Math.PI/180,l=new this.CANNON.ConeTwistConstraint(this.hiddenAnchor,this.anchorBody,{pivotA:new this.CANNON.Vec3(0,0,0),pivotB:new this.CANNON.Vec3(0,0,0),axisA:new this.CANNON.Vec3(0,1,0),axisB:new this.CANNON.Vec3(0,1,0),angle:c,twistAngle:.5*c});this.world.addConstraint(l),this.constraints.push(l);for(var d=this.meshes.slice(1),p=this.anchorBody,u=0;u<d.length;u++){var y=d[u],f=u===d.length-1,g=f?3*(null!==(n=this.config.mass)&&void 0!==n?n:.05):(null!==(o=this.config.mass)&&void 0!==o?o:.05)*(1+.1*u),N=new this.CANNON.Body({mass:g,position:new this.CANNON.Vec3(y.position.x,y.position.y,y.position.z),shape:new this.CANNON.Sphere(f?1.5*r:r),linearDamping:null!==(i=this.config.damping)&&void 0!==i?i:.5,angularDamping:.5*(null!==(s=this.config.damping)&&void 0!==s?s:.5)});this.world.addBody(N),this.chainBodies.push(N);var A=0===u?this.meshes[0]:d[u-1],v=y,w=A.position,m=v.position,x=Math.sqrt(Math.pow(m.x-w.x,2)+Math.pow(m.y-w.y,2)+Math.pow(m.z-w.z,2));console.log("约束距离 ".concat(A.name||"prev"," → ").concat(v.name||"current",": ").concat(x.toFixed(6)));var C=new this.CANNON.DistanceConstraint(p,N,x);this.world.addConstraint(C),this.constraints.push(C);var z=(null!==(e=this.config.swingAngle)&&void 0!==e?e:45)*Math.PI/180,B=new this.CANNON.ConeTwistConstraint(p,N,{pivotA:new this.CANNON.Vec3(0,-x/2,0),pivotB:new this.CANNON.Vec3(0,x/2,0),axisA:new this.CANNON.Vec3(0,1,0),axisB:new this.CANNON.Vec3(0,1,0),angle:z,twistAngle:0});this.world.addConstraint(B),this.constraints.push(B),p=N}},t.prototype.setGroupScale=function(t){t>0&&(this.groupScale=t)},t.prototype.update=function(t,n){var o=this;if(this.world&&this.initialized&&n){var i=this.groupScale||1,s=n.x/i,e=n.y/i,r=n.z/i;this.smoothedAnchorPosition.x+=.3*(s-this.smoothedAnchorPosition.x),this.smoothedAnchorPosition.y+=.3*(e-this.smoothedAnchorPosition.y),this.smoothedAnchorPosition.z+=.3*(r-this.smoothedAnchorPosition.z);var h=this.smoothedAnchorPosition.x-this.lastAnchorPosition.x,a=this.smoothedAnchorPosition.y-this.lastAnchorPosition.y,c=this.smoothedAnchorPosition.z-this.lastAnchorPosition.z;this.hiddenAnchor.position.x+=h,this.hiddenAnchor.position.y+=a,this.hiddenAnchor.position.z+=c,this.lastAnchorPosition.x=this.smoothedAnchorPosition.x,this.lastAnchorPosition.y=this.smoothedAnchorPosition.y,this.lastAnchorPosition.z=this.smoothedAnchorPosition.z,this.world.step(1/60,t,3);var l=this.meshes[0];l&&(l.position.x=this.anchorBody.position.x-this.hiddenAnchor.position.x,l.position.y=this.anchorBody.position.y-this.hiddenAnchor.position.y,l.position.z=this.anchorBody.position.z-this.hiddenAnchor.position.z),this.chainBodies.forEach((function(t,n){var i=o.meshes[n+1];i&&(i.position.x=t.position.x-o.hiddenAnchor.position.x,i.position.y=t.position.y-o.hiddenAnchor.position.y,i.position.z=t.position.z-o.hiddenAnchor.position.z,i.quaternion.set(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w))}))}},t.prototype.setConfig=function(t){if(this.config=s(s({},this.config),t),void 0!==t.gravity&&this.world){var n=t.gravity*this.GRAVITY_SCALE;this.world.gravity.set(0,n,0)}void 0!==t.damping&&this.chainBodies.forEach((function(n){var o;n.linearDamping=t.damping,n.angularDamping=.5*(null!==(o=t.damping)&&void 0!==o?o:.5)}))},t.prototype.destroy=function(){var t,n,o=this;this.meshes.forEach((function(t,n){var i=o.originalTransforms[n];t&&i&&(t.position.x=i.position.x,t.position.y=i.position.y,t.position.z=i.position.z,t.quaternion.x=i.quaternion.x,t.quaternion.y=i.quaternion.y,t.quaternion.z=i.quaternion.z,t.quaternion.w=i.quaternion.w)})),this.originalTransforms=[],this.constraints.forEach((function(t){var n;return null===(n=o.world)||void 0===n?void 0:n.removeConstraint(t)})),this.constraints=[],this.hiddenAnchor&&(null===(t=this.world)||void 0===t||t.removeBody(this.hiddenAnchor),this.hiddenAnchor=null),this.anchorBody&&(null===(n=this.world)||void 0===n||n.removeBody(this.anchorBody),this.anchorBody=null),this.chainBodies.forEach((function(t){var n;return null===(n=o.world)||void 0===n?void 0:n.removeBody(t)})),this.chainBodies=[],this.meshes=[],this.world=null,this.CANNON=null,this.initialized=!1},t}()}}]);
@@ -1 +1 @@
1
- var self = wx;(self.webpackChunktencentcloud_webar=self.webpackChunktencentcloud_webar||[]).push([[321],{8019:(e,t,i)=>{i.d(t,{g:()=>ge,b:()=>_e});var n,r=i(3044),s=i(9124),o=i(1206),a=i(3125),c=i(9560),u=i(401),h=i(1347),p=i(1084),l=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},f=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},d=function(){function e(e,t,i,n,r,s,a,c){this._container=new o.W2,this._name=e,this._src=t,this._target=n,this._config=i,this._jsonIntensity=i.intensity,this._landmarks=r,this._options=s,this._key=a,this._angles=c}return Object.defineProperty(e.prototype,"parentIntensity",{get:function(){return this._parentIntensity},set:function(e){this._parentIntensity=e,this._sticker&&(this._sticker.alpha=this._jsonIntensity*e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceLandMarks",{set:function(e){this._landmarks=e,this._sticker&&this.setStickerProps()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angles",{set:function(e){this._angles=e,this._sticker&&this.setStickerProps()},enumerable:!1,configurable:!0}),e.prototype.getCircle=function(e){void 0===e&&(e=5);var t=new o.TC;return t.beginFill(16711680),t.drawCircle(0,0,e),t.endFill(),t},e.prototype.getCircle2=function(e){void 0===e&&(e=5);var t=new o.TC;return t.beginFill(255),t.drawCircle(0,0,e),t.endFill(),t},e.prototype.getDisplay=function(){return this._container},e.prototype.load=function(){var e,t=this;if(this.checkAnimated()){var i=[];this._src.forEach((function(e){var n;n=e.indexOf(".json")>-1?e:"".concat(t._key,"|").concat(JSON.parse(e).meta.image);var s=r.iV[n].textures,o=Object.keys(s).map((function(e){return s[e]}));i=i.concat(o)})),(e=new c.Kg(i)).animationSpeed=(this._config.fps||30)/60,e.play()}else{var n=this._src[0],s=o.P6.kN[n];e=new c.jy(s)}this._config.blend&&(e.blendMode_1=this._config.blend);this._config.wxAnchorOffset;e.width=this._config.width,e.height=this._config.height;var a=[.5,.5];this._config.anchor&&(a=this._config.anchor),e.anchor.set(a[0],a[1]),e.alpha=this._jsonIntensity*this.parentIntensity,this._sticker=e,this._container.addChild(this._sticker),this._container.convertTo3d(),this.setStickerProps()},e.prototype.setStickerProps=function(){var e=this._config,t=this._landmarks,i=u.Jp.map((function(e){return t[e]})),n=(0,h.Sp)(i[0],i[1]),r=e.wxAnchorArea,s=(e.wxAnchorOffset,e.wxWeights),o=n/u.jw,a=r.map((function(e){var i=t[e];return{x:i.x,y:i.y,z:0}}));this._container.scale.set(o);var c={x:a[0].x*s[0]+a[1].x*s[1]+a[2].x*s[2],y:a[0].y*s[0]+a[1].y*s[1]+a[2].y*s[2]};this._container.position.x=c.x,this._container.position.y=c.y,this._angles&&(this._container.euler.z=this._angles.roll,this._container.euler.y=this._angles.yaw,this._container.euler.x=this._angles.pitch)},e.prototype.checkAnimated=function(){if(this._src instanceof Array&&this._src.length>1)return!0;try{return JSON.parse(this._src[0]),!0}catch(e){return"json"===this._src[0].split(".").pop()}},e.prototype.tick=function(){},e.prototype.apply=function(){},e.prototype.remove=function(){},e.prototype.destroy=function(){this._sticker.destroy(),this._container.destroy(),this._sticker=null,this._target=null},l([(0,p.M)("StickerLayer"),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",Boolean)],e.prototype,"checkAnimated",null),l([(0,p.M)("StickerLayer"),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",void 0)],e.prototype,"destroy",null),e}(),y=function(){function e(e,t,i,n,r,s,o){void 0===o&&(o=1);var c=this;this._stickers=[],this._visible=!0,this._parentIntensity=1,this._target=i,this._options=r,this._landmarks=n;var u=new a.LE;u.setPlanes(400,10,1e4,!0),this._camera=u,this._stickers=t.map((function(t){var o=new d(t.name,t.src,t,i,n,r,e,s);return o.parentIntensity=c.parentIntensity,o.load(),c._camera.addChild(o.getDisplay()),o}))}return Object.defineProperty(e.prototype,"parentIntensity",{get:function(){return this._parentIntensity},set:function(e){this._stickers.forEach((function(t){t.parentIntensity=e})),this._parentIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceLandMarks",{set:function(e){this._stickers.forEach((function(t){t.faceLandMarks=e}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angles",{set:function(e){this._stickers.forEach((function(t){t.angles=e}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){this._target&&e!==this._visible&&(this._visible=e,e?this.apply():this.remove())},enumerable:!1,configurable:!0}),e.prototype.tick=function(){this._stickers.forEach((function(e){return e.tick()}))},e.prototype.apply=function(){this._target.addChild(this._camera)},e.prototype.remove=function(){this._target.removeChild(this._camera)},e.prototype.destroy=function(){this.remove(),this._stickers.forEach((function(e){return e.destroy()})),this._camera.destroy(),this._stickers=[]},e}(),_=i(6109),g=i(201),m=i(617),b=i(3849),v=(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),k=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},x=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},w=(0,_.jl)("merged-makeup-layer");var M=function(){function e(e,t,i,n,r){this._destroyed=!1,this.type="makeup",this._parentIntensity=1,this._jsonIntensity=1,this.textures=[],this.files=[],this._options=e,this._container=t,this._lipMaskTexture=r,this.renderer=i,this.type=n||"makeup"}return e.prototype.setParentIntensityAt=function(e,t){if(this.shader&&this.files.length)for(var i=0;i<this.files.length;i++){if(this.files[i].parentKey===e)this.files[i].parentIntensity=t,this.shader.uniforms["parentIntensity".concat(i)]=t}},Object.defineProperty(e.prototype,"lipMask",{set:function(e){null===e||(this._lipMaskTexture=e.texture,this.shader&&(this.shader.uniforms.uSamplerLipMask=this._lipMaskTexture))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visible",{set:function(e){this.shader&&(this.shader.uniforms.enable=e?1:0)},enumerable:!1,configurable:!0}),e.prototype.updateGeometry=function(e){this._destroyed},e.prototype.renderMesh=function(){},e.prototype.resize=function(e,t){this._options.width=e,this._options.height=t,this.shader&&(this.shader.uniforms.size=[e,t])},e.prototype.drawMeshBatch=function(e,t){var i=this;if(!this._destroyed){this.files=e;var n=Array.from(e.reduce((function(e,t){return e.add(t.blend),e}),new Set));this.irisRenderTexture&&!n.includes(this.irisBlendMode)&&n.push(this.irisBlendMode);var r="\n precision mediump float;\n varying vec2 vUvs;\n varying vec2 bUvs;\n uniform sampler2D uSamplerLipMask;\n \n\n ".concat(e.map((function(e,t){return"uniform sampler2D uSamplerMakeup".concat(t,";")})).join("\n"),"\n ").concat(e.map((function(e,t){return"uniform float intensity".concat(t,";")})).join("\n"),"\n ").concat(e.map((function(e,t){return"uniform float parentIntensity".concat(t,";")})).join("\n"),"\n uniform int enable;\n uniform sampler2D baseImage;\n \n uniform sampler2D uSamplerIris;\n\n uniform int mirror;\n uniform vec2 imageOffset;\n \n ").concat(n.map((function(e){return c.Lc[e].shader})).join("\n"),"\n \n void main() {\n if (enable == 0) {\n gl_FragColor = vec4(0.0,0.0,0.0,0.0);\n return;\n }\n\n // todo:适配镜像与非镜像\n vec2 baseCoord = bUvs;\n baseCoord += imageOffset;\n\n if (mirror == 1) {\n baseCoord = vec2(1.0 - bUvs.x, bUvs.y);\n }\n \n vec4 baseColor = texture2D(baseImage, baseCoord);\n\n vec4 makeupColor = vec4(0.0);\n float alphaFromMask = 1.0 - texture2D(uSamplerLipMask, bUvs).a; \n\n ").concat(e.map((function(e,t){return"\n \n vec4 color".concat(t," = texture2D(uSamplerMakeup").concat(t,", vUvs);\n float a").concat(t," = color").concat(t,".a;\n float realIntensity").concat(t," = intensity").concat(t," * parentIntensity").concat(t,";\n\n makeupColor = texture2D(uSamplerMakeup").concat(t,", vUvs) * realIntensity").concat(t," * alphaFromMask;\n \n if (makeupColor.a > 0.) {\n \n\n // 混合\n baseColor.rgb = blend").concat(c.Lc[e.blend].key,"(baseColor.rgb, makeupColor.rgb/makeupColor.a , makeupColor.a);\n \n }\n \n \n \n\n ")})).join("\n"),"\n\n ").concat(this.irisRenderTexture?"\n // 混合美瞳\n vec4 irisColor = texture2D(uSamplerIris, bUvs);\n if (irisColor.a > 0.) {\n baseColor.rgb = blend".concat(c.Lc[this.irisBlendMode].key,"(baseColor.rgb, irisColor.rgb/irisColor.a , irisColor.a);\n }\n "):"","\n \n \n // 输出\n gl_FragColor = baseColor;\n // gl_FragColor = makeupColor;\n }"),s={enable:1},a=this._options,u=a.width,h=a.height;s.baseImage=_e.baseTexture,s.size=[u*h/_e.baseTexture.height,h];var p=_e.baseTexture.width*h/_e.baseTexture.height;s.imageOffset=[(p-u)/2/p,0],e.forEach((function(e,t){var n=e.src,r=o.P6.kN[n];s["uSamplerMakeup".concat(t)]=r,s["intensity".concat(t)]=e.intensity,s["parentIntensity".concat(t)]=null==e.parentIntensity?1:e.parentIntensity,s.mirror=b.t.instance.options.mirror?1:0,i.textures.push(r)})),this.irisRenderTexture&&(s.uSamplerIris=this.irisRenderTexture,s.mirror=b.t.instance.options.mirror?1:0),s.uSamplerLipMask=this._lipMaskTexture;var l=o.ex.from("\n precision mediump float;\n attribute vec2 aVertexPosition;\n attribute vec2 aUvs;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n uniform vec2 size;\n varying vec2 vUvs;\n varying vec2 bUvs;\n\n \n void main() {\n vUvs = aUvs;\n bUvs = aVertexPosition.xy /size;\n // lipUvs = lipAuvs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n }",r,s);this.shader=l,this.mirrorChangeHandler=function(e){i.shader&&(i.shader.uniforms.mirror=(null==e?void 0:e.mirror)?1:0)},b.t.instance.on("mirrorChange",this.mirrorChangeHandler);var f=new o.Kj(t,l);return this._mesh=f,this._container.addChild(f),f}},e.prototype.destroy=function(){var e;w.info("MakeupLayer destroy"),this._destroyed=!0,this._mesh&&(this._mesh.destroy({children:!0,texture:!1,baseTexture:!1}),this._mesh.mask=null,this._mesh=null),this._maskRenderTexure&&this._maskRenderTexure.destroy(!1),this.shader&&(null===(e=this.shader)||void 0===e||e.destroy(),this.shader=null),this.mirrorChangeHandler&&b.t.instance.off("mirrorChange",this.mirrorChangeHandler)},k([(0,p.M)("MakeupLayer"),x("design:type",Function),x("design:paramtypes",[Array]),x("design:returntype",void 0)],e.prototype,"updateGeometry",null),k([(0,p.M)("MakeupLayer"),x("design:type",Function),x("design:paramtypes",[]),x("design:returntype",void 0)],e.prototype,"destroy",null),e}(),T=function(e){function t(t,i,n,r,s,a,c,u){var h=e.call(this,t,a)||this;return h._maskGraphics=new o.TC,h.maxLConSize=.42,h.maxRConSize=.42,h._parentIntensity=1,h.parentKey=c,h.jsonIntensity=r,h._parentIntensity=u||1,h.getTexture(i,n),h._config=s,h.renderTexture=o.TI.create({width:t.width,height:t.height}),h}var i,n;return v(t,e),Object.defineProperty(t.prototype,"parentIntensity",{get:function(){return this._parentIntensity},set:function(e){this._container&&(this._container.alpha=this.jsonIntensity*e),this._parentIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visible",{set:function(e){this._container.visible=e},enumerable:!1,configurable:!0}),t.prototype.getTexture=function(e,t){var i=e,n=o.P6.kN[i];if(n){var r=new o.jy(n),s=new o.jy(n.clone());r.anchor.set(.5),s.anchor.set(.5),this._leftIris=r,this._rightIris=s;var a=new o.W2;this._maskGraphics||(this._maskGraphics=new o.TC),a.addChild(this._maskGraphics),a.addChild(r),a.addChild(s),a.alpha=this.parentIntensity*this.jsonIntensity,a.mask=this._maskGraphics,this._container=a}},t.prototype.setIrisProps=function(e,t){if(!this._destroyed&&e.length)try{var i=this._config.getConfigByKeys(["POINTS_MAP","LEFT_IRIS","RIGHT_IRIS","LEFT_EYE_ORDER","RIGHT_EYE_ORDER"]),n=i.POINTS_MAP,r=(i.LEFT_IRIS,i.RIGHT_IRIS,i.LEFT_EYE_ORDER),s=i.RIGHT_EYE_ORDER,o=(n.left_eye_center,n.right_eye_center,void 0),a=void 0,c=void 0,u=void 0,p=void 0,l=void 0;if(e.length>=163){var f=e.slice(123,143),d=e.slice(143,163);a=o=this._getXRange(f),u=c=this._getXRange(d),p=e[123],l=e[143]}else{var y=(0,h.Sp)(e[52],e[55]),_=(0,h.Sp)(e[58],e[61]);a=o=y*this.maxLConSize,u=c=_*this.maxLConSize,p=(0,h.qg)(e[74],e[104]),l=(0,h.qg)(e[77],e[105])}var g=o,m=a,b=c,v=u,k=p,x=l,w=_e.baseTexture.width*this._options.height/_e.baseTexture.height;k.x-=(w-this._options.width)/2,x.x-=(w-this._options.width)/2;var M=this._leftIris,T=this._rightIris;M.width=g*(this._options.irisScale||1),M.height=m*(this._options.irisScale||1),M.x=k.x,M.y=k.y,T.width=b*(this._options.irisScale||1),T.height=v*(this._options.irisScale||1),T.x=x.x,T.y=x.y,this._maskGraphics.clear(),this._drawMaskGraphics(r,e),this._drawMaskGraphics(s,e),t.render(this._container,{renderTexture:this.renderTexture})}catch(e){}},t.prototype._drawMaskGraphics=function(e,t){var i=this._maskGraphics;i.beginFill(16724736),i.lineStyle(1,16767232,1);var n,r,s=t[e[0]];i.moveTo(s.x,s.y),s=t[e[1]],i.lineTo(s.x,s.y),n=t[e[2]],r=t[e[3]],i.quadraticCurveTo(n.x,n.y+(n.y-(0,h.qg)(s,r).y),r.x,r.y),s=t[e[4]],i.lineTo(s.x,s.y),s=t[e[5]],i.lineTo(s.x,s.y),n=t[e[6]],r=t[e[7]],i.quadraticCurveTo(n.x,n.y-((0,h.qg)(s,r).y-n.y),r.x,r.y),i.closePath(),i.endFill()},t.prototype._getPixelPosition=function(e,t){return{x:e,y:t}},t.prototype._getXRange=function(e){if(0===e.length)return 0;var t=e.reduce((function(e,t){return{min:Math.min(e.min,t.x),max:Math.max(e.max,t.x)}}),{min:e[0].x,max:e[0].x}),i=t.min;return t.max-i},t.prototype.resize=function(t,i){var n;e.prototype.resize.call(this,t,i),null===(n=this.renderTexture)||void 0===n||n.resize(t,i)},t.prototype.destroy=function(){w.info("irisLayer destroy"),this._destroyed=!0,this._leftIris&&this._leftIris.destroy({children:!0,texture:!1,baseTexture:!1}),this._rightIris&&this._rightIris.destroy({children:!0,texture:!1,baseTexture:!1}),this._maskGraphics&&this._maskGraphics.destroy({children:!0,texture:!1,baseTexture:!1})},k([(0,p.M)("IrisLayer"),x("design:type",Function),x("design:paramtypes",["function"==typeof(i="undefined"!=typeof Array&&Array)?i:Object,"function"==typeof(n=void 0!==o.Th&&o.Th)?n:Object]),x("design:returntype",void 0)],t.prototype,"setIrisProps",null),t}(M),C=i(3120),S=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},E=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},I=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},P=function(e,t){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},R=function(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],n=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},j=(0,_.jl)("makeup-mer"),O=function(){function e(e,t,i){e&&(this._options=e),t&&(this._lipVertex=t),i&&(this.renderer=i)}return e.prototype.destroy=function(){var e=this._lipMask;this._lipMask=null;try{e.destroy(!0)}catch(e){}try{this._lipMaskMesh.destroy(!0),this._lipMaskMesh=null}catch(e){}try{this._maskRenderTexture.destroy(!0),this._maskRenderTexture=null}catch(e){}this._config=null;try{this._maskSprite.destroy(!0),this._maskSprite=null}catch(e){}},e.prototype.load=function(){return I(this,void 0,void 0,(function(){var e,t,i,n;return P(this,(function(r){switch(r.label){case 0:return this._config?[3,2]:(this._config=new m.M,[4,this._config.load()]);case 1:r.sent(),r.label=2;case 2:return this._lipMask?[3,4]:[4,this._getMask()];case 3:r.sent(),r.label=4;case 4:return this._maskSprite&&!this._maskSprite.destroyed||(e=this._options,t=e.width,i=e.height,this._maskRenderTexture=o.TI.create({width:t,height:i}),n=new o.jy(this._maskRenderTexture),this._maskSprite=n),[2,{maskSprite:this._maskSprite,lipmask:this._lipMask,lipmaskmesh:this._lipMaskMesh}]}}))}))},e.prototype.update=function(e){if(this._lipMaskMesh){this._lipMaskMesh.geometry.getBuffer("aVertexPosition").update(e);var t=this._lipMaskMesh.getBounds();this._lipMaskMesh.mask.clear(),this._lipMaskMesh.mask.drawRect(t.x,t.y,t.width,t.height),this.render()}},e.prototype.render=function(){this.renderer&&this._lipMask&&this.renderer.render(this._lipMask,{renderTexture:this._maskRenderTexture})},e.prototype.resize=function(e,t){var i;j.info("ReuseableLipMask resize",e,t,this._maskSprite),null===(i=this._maskRenderTexture)||void 0===i||i.resize(e,t)},e.prototype._getMask=function(){return I(this,void 0,void 0,(function(){var e,t,i,n,r,s,a;return P(this,(function(c){switch(c.label){case 0:return this._lipMask?[2,this._lipMask]:(e=this._lipVertex,t=this._config.getDataConfig(29),[4,this._loadLipImage()]);case 1:return i=c.sent(),n=(new o.wG).addAttribute("aVertexPosition",e).addAttribute("aUvs",t),"\n precision mediump float;\n attribute vec2 aVertexPosition;\n attribute vec2 aUvs;\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n varying vec2 vUvs;\n\n\n void main() {\n vUvs = aUvs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n }","\n precision mediump float;\n varying vec2 vUvs;\n uniform sampler2D uSamplerMakeup;\n\n \n void main() {\n gl_FragColor = texture2D(uSamplerMakeup, vUvs);\n }",r={uSamplerMakeup:i},s=o.ex.from("\n precision mediump float;\n attribute vec2 aVertexPosition;\n attribute vec2 aUvs;\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n varying vec2 vUvs;\n\n\n void main() {\n vUvs = aUvs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n }","\n precision mediump float;\n varying vec2 vUvs;\n uniform sampler2D uSamplerMakeup;\n\n \n void main() {\n gl_FragColor = texture2D(uSamplerMakeup, vUvs);\n }",r),(a=new o.Kj(n,s)).mask=new o.TC,this._lipMaskMesh=a,this._lipMask=a,[2,a]}}))}))},e.prototype._loadLipImage=function(){return I(this,void 0,Promise,(function(){var e=this;return P(this,(function(t){return[2,new Promise((function(t,i){return I(e,void 0,void 0,(function(){var e,i,n;return P(this,(function(r){switch(r.label){case 0:return[4,(e=new C.KI).init()];case 1:return i=r.sent(),[4,e.loadImage(i)];case 2:return n=r.sent(),t(n[C.X_]),[2]}}))}))}))]}))}))},S([(0,p.M)("ReuseableLipMask"),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",void 0)],e.prototype,"destroy",null),S([(0,p.o)("ReuseableLipMask"),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Promise)],e.prototype,"_getMask",null),e}(),F=function(){function e(e,t,i,n,r,s,a){this._container=new o.W2,this._makeupMeshes=[],this._visible=!0,this.mouthShut=!0,this._applyed=!1,this._key=e,this._data=t,this._options=i,this.mesh=n,this.lipmesh=s,this.faceLandMarks=r,this.renderer=a;var c=new o.jy(o.xE.WHITE);c.alpha=0,c.width=i.width,c.height=i.height,this._container.addChild(c)}var t;return Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){var t=this;this._target&&e!==this._visible&&(this._visible=e,this._makeupMeshes.forEach((function(i){e?t.apply(t._target):t.remove()})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mesh",{set:function(e){(this._meshVertex=e,this.geometry)&&(this.geometry.getBuffer("aVertexPosition").update(e),this._makeupMeshes.forEach((function(t){t.updateGeometry(e)})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lipmesh",{set:function(e){this._lipVertex=e,this._lipMaskIns&&this._lipMaskIns.update(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceLandMarks",{set:function(e){var t=this;e&&e.length&&(this._irises&&this._irises.setIrisProps(e,this.renderer),(0,h.Sp)(e[98],e[102])<.03*(0,h.Sp)(e[0],e[32])?this.mouthShut||(this._makeupMeshes.forEach((function(e){"lips"===e.type&&(e.lipMask=null)})),this.mouthShut=!0):this.mouthShut&&(this._makeupMeshes.forEach((function(e){"lips"===e.type&&t._lipMaskIns&&(e.lipMask=t._lipMaskIns._maskSprite)})),this.mouthShut=!1))},enumerable:!1,configurable:!0}),e.prototype.renderMesh=function(){this._lipMaskIns&&this._lipMaskIns.render(),this._makeupMeshes.forEach((function(e){e.renderMesh()}))},e.prototype.load=function(){return I(this,void 0,void 0,(function(){var e,t,i,n,r,s,o,a;return P(this,(function(c){switch(c.label){case 0:return this._config=new m.M,[4,this._config.load()];case 1:if(c.sent(),e=this._data,j.info("makeup info",this._data),t=[],e&&e.length){try{for(i=R(e),n=i.next();!n.done;n=i.next())"iris"===(r=n.value).type?(j.info("generate iris layer",r),this._irises=this._getIris(this.getFilename(r.src,r.parentKey),r.blend,r.intensity,r.parentKey,r.parentIntensity),this.irisBlendMode=r.blend):(r.blend+"",t.push({src:this.getFilename(r.src,r.parentKey),intensity:r.intensity,type:r.type,blend:r.blend,parentIntensity:r.parentIntensity,parentKey:r.parentKey}))}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=i.return)&&a.call(i)}finally{if(o)throw o.error}}j.info("makeupLayersByBlendMode",t),s=this._getMeshLayerByBlendMode(t),this._makeupMeshes.push(s)}return[4,this._initLipMask()];case 2:return c.sent(),[2]}}))}))},e.prototype.getFilename=function(e,t){return"default"===t?e:"".concat(t,"|").concat(e)},e.prototype.setParentIntensity=function(e,t){j.info("setParentIntensity",e,t),this._makeupMeshes.forEach((function(i){i.setParentIntensityAt(e,t)})),this._irises&&this._irises.parentKey===e&&(this._irises.parentIntensity=t)},e.prototype._getIris=function(e,t,i,n,r){return new T(this._options,e,t,i,this._config,this._container,n,r)},e.prototype._getMeshLayerByBlendMode=function(e){var t=e.some((function(e){return"lips"===e.type}))?"lips":"makeup",i=new M(this._options,this._container,this.renderer,t);this._irises&&(i.irisRenderTexture=this._irises.renderTexture.baseTexture,i.irisBlendMode=this.irisBlendMode);var n=this._config.getDataConfig(26);if(!this.geometry){var r=(new o.wG).addAttribute("aVertexPosition",this._meshVertex).addAttribute("aUvs",n);this.geometry=r}return i.drawMeshBatch(e,this.geometry),i},e.prototype.resize=function(e,t){var i,n;this._makeupMeshes.forEach((function(i){i.resize(e,t)})),null===(i=this._irises)||void 0===i||i.resize(e,t),null===(n=this._lipMaskIns)||void 0===n||n.resize(e,t)},e.prototype.apply=function(e){this._target=e,this._applyMakeup(e)},e.prototype.remove=function(){this._removeMakeup(this._target)},e.prototype._applyMakeup=function(e){if(!this._applyed){if(!e)return j.info("_applyMakeup failed: container is null");this._applyed=!0,e.filters||(e.filters=[]);try{e.addChild(this._container)}catch(e){j.info("_applyMakeup error",e)}}},e.prototype._removeMakeup=function(e){if(this._applyed){if(!e)return j.info("_removeMakeup failed: container is null");this._applyed=!1,e.filters&&e.removeChild(this._container)}},e.prototype._initLipMask=function(){return I(this,void 0,void 0,(function(){var e,t,i=this;return P(this,(function(n){switch(n.label){case 0:return(e=new O(this._options,this._lipVertex,this.renderer))._options=this._options,e._lipVertex=this._lipVertex,e.renderer=this.renderer,this._lipMaskIns=e,[4,e.load()];case 1:return t=n.sent().maskSprite,this._makeupMeshes.forEach((function(e){"lips"!==e.type||i.mouthShut||(e.lipMask=t)})),[2]}}))}))},e.prototype.destroy=function(){j.info("makeup destroy"),this.remove(),this._makeupMeshes.forEach((function(e){return e.destroy()})),this._makeupMeshes=[],this._irises&&this._irises.destroy(),this._irises=null,this._container.destroy(),this._target=null,this._lipMaskIns&&this._lipMaskIns.destroy()},S([(0,p.M)("Makeup"),E("design:type",Function),E("design:paramtypes",["function"==typeof(t=void 0!==o.W2&&o.W2)?t:Object]),E("design:returntype",void 0)],e.prototype,"_removeMakeup",null),S([(0,p.M)("Makeup"),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",void 0)],e.prototype,"destroy",null),e}(),L=i(7959),V=function(){return V=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},V.apply(this,arguments)},A=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},U=function(e,t){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},N=(0,_.jl)("makeup-merge-hub"),D=function(){function e(){this._visible=!0,this._makeupConfigs={},this._applied=!1,this._mesh=[],this._faceLandMarks=[],this._lipmesh=[]}return Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){this._visible=e,this.currentMakeupInstance&&(this.currentMakeupInstance.visible=e)},enumerable:!1,configurable:!0}),e.prototype.addMakeupConfig=function(e,t,i){this._makeupConfigs[e]={config:t,visible:!0,parentIntensity:i}},e.prototype.setMakeupConfigVisible=function(e,t){this._makeupConfigs[e]&&(this._makeupConfigs[e].visible=t)},e.prototype.MakeupConfigExist=function(e){return void 0!==this._makeupConfigs[e]},e.prototype.setMakeupConfigParentIntensity=function(e,t){var i;this._makeupConfigs[e]&&(N.info("setMakeupConfigParentIntensity",e,t),this._makeupConfigs[e].parentIntensity=t,null===(i=this.currentMakeupInstance)||void 0===i||i.setParentIntensity(e,t))},e.prototype.removeMakeupConfig=function(e){delete this._makeupConfigs[e]},e.prototype.generateFinalConfig=function(){var e=this,t=[],i=function(i){n._makeupConfigs[i].visible&&n._makeupConfigs[i].config.forEach((function(n){var r=V(V({},n),{parentIntensity:e._makeupConfigs[i].parentIntensity,parentKey:i});t.push(r)}))},n=this;for(var r in this._makeupConfigs)i(r);return t},e.prototype.generateMakeup=function(e,t,i,n){return A(this,void 0,void 0,(function(){var r,s;return U(this,(function(o){switch(o.label){case 0:return r=this.generateFinalConfig(),N.info("generateMakeup",r),L.s.checkEnabled("beautify")?r.length?[4,(s=new F("merged-".concat((new Date).getTime()),r,b.t.instance.options,e,t,i,n)).load()]:[2,null]:[2,null];case 1:return o.sent(),[2,s]}}))}))},e.prototype.updateMakeupFilter=function(e,t,i,n){return A(this,void 0,void 0,(function(){var r;return U(this,(function(s){switch(s.label){case 0:return console.log("updateMakeupFilter called"),L.s.checkEnabled("beautify")?[4,this.generateMakeup(e,t,i,n)]:[2];case 1:return(r=s.sent())?(this.mesh=e,this.faceLandMarks=t,this.lipmesh=i,[4,r.load()]):(this.currentMakeupInstance&&this.currentMakeupInstance.destroy(),this._applied=!1,[2]);case 2:return s.sent(),this.currentMakeupInstance&&this.currentMakeupInstance.destroy(),r&&(this.currentMakeupInstance=r),this._applied&&this.currentMakeupInstance.apply(this._target),[2]}}))}))},e.prototype.updateMakeupConfigShortcut=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,this.updateMakeupFilter(this.mesh,this.faceLandMarks,this.lipmesh,e)];case 1:return[2,t.sent()]}}))}))},e.prototype.resize=function(e,t){N.info("resize",e,t),this.currentMakeupInstance&&this.currentMakeupInstance.resize(e,t)},e.prototype.renderMesh=function(){this.currentMakeupInstance&&this.currentMakeupInstance.renderMesh()},e.prototype.applyIfNot=function(e){this._applied||this.currentMakeupInstance&&(this.currentMakeupInstance.apply(e),this._target=e,this._applied=!0)},Object.defineProperty(e.prototype,"mesh",{get:function(){return this._mesh},set:function(e){this.currentMakeupInstance&&(this.currentMakeupInstance.mesh=e),this._mesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lipmesh",{get:function(){return this._lipmesh},set:function(e){this.currentMakeupInstance&&(this.currentMakeupInstance.lipmesh=e),this._lipmesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceLandMarks",{get:function(){return this._faceLandMarks},set:function(e){this.currentMakeupInstance&&(this.currentMakeupInstance.faceLandMarks=e),this._faceLandMarks=e},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.currentMakeupInstance&&this.currentMakeupInstance.destroy(),this._applied=!1,this._makeupConfigs={}},e.instance=new e,e}();const B=function(){function e(){if(e.instance)throw new Error("TextureRefManager 已存在实例,请使用 getInstance() 获取");this.refCounts=new Map}return e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.addRef=function(e){var t=this.refCounts.get(e)||0;this.refCounts.set(e,t+1)},e.prototype.removeRef=function(e){var t=this.refCounts.get(e)||0;return t<=1?(this.refCounts.delete(e),!0):(this.refCounts.set(e,t-1),!1)},e.prototype.getRefCount=function(e){return this.refCounts.get(e)||0},e.prototype.clear=function(){this.refCounts.clear()},e}();var z=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),G=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},H=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},J=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},X=function(e,t){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},W=function(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],n=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},K=(0,_.jl)("Effect"),q=function(){function e(e,t,i,n,r,s,o,a,c,u,h){this.type="face",this._filters=[],this._destroyed=!1,this._visible=!0,this._intensity=1,this._filterIntensity=1,this.localSpriteSheets={},this._filtersActived=!0,this.makeupConfig=[],K.info("effect constructor",this._key,t),this._target=t,this._stickerTarget=i,this._url=e,this._key=e,this._options=r,this.mesh=s,this.lipmesh=a,this.faceLandMarks=o,c&&(this.angles=c),void 0!==u&&(this.intensity=u),this._app3d=n,this._canvas=h}var t;return Object.defineProperty(e.prototype,"isPureFilter",{get:function(){var e=this._config;return!!e&&((!e.makeup||!e.makeup.length)&&((!e.sticker||!e.sticker.length)&&((!e.sticker3d||!e.sticker3d.length)&&(!e.beautify||!Object.keys(e.beautify).find((function(t){return!!e.beautify[t]}))))))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"filterActived",{get:function(){return this._filtersActived},set:function(e){e!==this._filtersActived&&(this._filterTarget&&(e?this._applyFilter(this._filterTarget):this._removeFilter(this._filterTarget)),this._filtersActived=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"app3d",{get:function(){return this._app3d},set:function(e){this._app3d=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"intensity",{get:function(){return this._intensity},set:function(e){e>1&&(e=1),null!=e&&(D.instance.setMakeupConfigParentIntensity(this._key,e),this._sticker&&(this._sticker.parentIntensity=e),this._intensity=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"filterIntensity",{get:function(){return this._filterIntensity},set:function(e){null!=e&&(this._filters&&this._filters.forEach((function(t){t.uniforms.parentIntensity=e})),this._filterIntensity=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){this._destroyed||(this._visible=e,D.instance.visible=e,this._sticker&&(this._sticker.visible=e),this._app3d&&(this._app3d.visible=e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mesh",{set:function(e){this._destroyed||(this._meshVertex=e,D.instance.mesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lipmesh",{set:function(e){this._destroyed||(this._lipVertex=e,D.instance.lipmesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceLandMarks",{get:function(){return this._faceLandMarks},set:function(e){this._destroyed||(this._faceLandMarks=e,D.instance.faceLandMarks=e,this._sticker&&(this._sticker.faceLandMarks=e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angles",{set:function(e){this._angles=e,this._sticker&&(this._sticker.angles=e)},enumerable:!1,configurable:!0}),e.prototype.download=function(){return J(this,void 0,Promise,(function(){var e;return X(this,(function(t){switch(t.label){case 0:return[4,this._getLoader()];case 1:return[4,t.sent().preload(this._url)];case 2:return t.sent(),[4,this._getConfig()];case 3:return e=t.sent(),_.D4.info("download:",this._url,e),[2,e]}}))}))},e.prototype.load=function(e){return J(this,void 0,Promise,(function(){var t,i,n,r,s,o;return X(this,(function(a){switch(a.label){case 0:return[4,this.download()];case 1:return t=a.sent(),i=t.filter,n=t.makeup,r=t.beautify,s=t.sticker,o=t.sticker3d,e&&e(!!(null==o?void 0:o.length)),[4,this._loadImages(t)];case 2:return a.sent(),this.loadFilter(i),[4,this.setMakeup(n)];case 3:return a.sent(),s?[4,this.loadStickers(s)]:[3,5];case 4:a.sent(),a.label=5;case 5:return[4,this.load3d(o)];case 6:return a.sent(),this.sticker3d=o,[4,this._getLoader()];case 7:return a.sent().removeFromCache(this._url),[2,r]}}))}))},e.prototype._getLoader=function(){return J(this,void 0,void 0,(function(){return X(this,(function(e){switch(e.label){case 0:return this._loader?[3,2]:(this._loader=new r.pF,[4,this._loader.init()]);case 1:e.sent(),e.label=2;case 2:return[2,this._loader]}}))}))},e.prototype._getConfig=function(){return J(this,void 0,void 0,(function(){var e;return X(this,(function(t){switch(t.label){case 0:return this._config?[3,3]:[4,this._getLoader()];case 1:return[4,(e=t.sent()).preload(this._url)];case 2:t.sent(),this._config=e.readJSON("content.json",this._key),t.label=3;case 3:return[2,this._config]}}))}))},e.prototype.hasEyeMakeup=function(){return J(this,void 0,Promise,(function(){var e,t,i,n,r,s,o,a;return X(this,(function(c){switch(c.label){case 0:return[4,this._getConfig()];case 1:e=c.sent(),t=e.makeup,i=!1;try{for(n=W(t),r=n.next();!r.done;r=n.next())if("iris"===(s=r.value).type||"eyes"===s.type){i=!0;break}}catch(e){o={error:e}}finally{try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(o)throw o.error}}return[2,i]}}))}))},e.prototype.needDetection=function(){return J(this,void 0,Promise,(function(){var e,t,i,n;return X(this,(function(r){switch(r.label){case 0:return[4,this._getConfig()];case 1:return e=r.sent(),t=e.makeup,i=e.sticker,n=e.sticker3d,[2,t&&t.length||i&&i.length||n&&n.length]}}))}))},e.prototype.hasFilter=function(){return J(this,void 0,Promise,(function(){var e,t;return X(this,(function(i){switch(i.label){case 0:return[4,this._getConfig()];case 1:return e=i.sent(),[2,!(!(t=e.filter)||!t.length)]}}))}))},e.prototype.loadStickers=function(e){return J(this,void 0,Promise,(function(){var t;return X(this,(function(i){return e.length?((t=new y(this._key,e,this._stickerTarget,this.faceLandMarks,this._options,this._angles)).parentIntensity=this.intensity,this._sticker=t,[2]):[2,Promise.resolve()]}))}))},e.prototype.loadSticker3d=function(e){return void 0===e&&(e=[]),J(this,void 0,Promise,(function(){return X(this,(function(e){return[2]}))}))},e.prototype.load3d=function(e){return J(this,void 0,void 0,(function(){return X(this,(function(e){return[2]}))}))},e.prototype.initThreeApp=function(){return J(this,void 0,void 0,(function(){return X(this,(function(e){return[2]}))}))},e.prototype.apply3d=function(){},e.prototype.removeForConsole=function(){},e.prototype.destroyForConosle=function(){},e.prototype.setMakeup=function(e){if(!e.length)return Promise.resolve();D.instance.addMakeupConfig(this._key,e,this.intensity),this.makeupConfig=e},e.prototype.resize=function(e,t){D.instance.resize(e,t)},e.prototype.apply=function(e){var t=this;this._destroyed||this._applyed||(this.filterActived&&this._applyFilter(e.filterTarget),this._filters.length&&e.filterCallback&&e.filterCallback(),this._filterTarget=e.filterTarget,D.instance.MakeupConfigExist(this._key)||D.instance.addMakeupConfig(this._key,this.makeupConfig,this.intensity),D.instance.setMakeupConfigVisible(this._key,!0),D.instance.updateMakeupFilter(this._meshVertex,this.faceLandMarks,this._lipVertex,this.renderer).then((function(){K.info("merged makeup updated,start apply"),D.instance.applyIfNot(t._target)})),this._sticker&&this._sticker.apply(),this.apply3d(),this._applyed=!0)},e.prototype.getUrl=function(){return this._url},e.prototype.remove=function(e){void 0===e&&(e=!1),D.instance.removeMakeupConfig(this._key),e||D.instance.updateMakeupConfigShortcut(this.renderer),this._sticker&&this._sticker.remove(),this.removeForConsole(),this._removeFilter(this._filterTarget),this._applyed=!1},e.prototype.tick=function(){this._sticker&&this._sticker.tick()},e.prototype.tickMesh=function(){D.instance.renderMesh()},e.prototype.destroy=function(e){void 0===e&&(e=!1),this._destroyed=!0,this.remove(e),this._sticker&&(this._sticker.destroy(),this._sticker=null),this.destroyForConosle(),this._filters=[],this.clearTexture()},e.prototype.loadFilter=function(e){var t=this;this._destroyed||e&&e.length&&e.forEach((function(e){var i=t._createFilterSync(e.src,e.intensity,t.filterIntensity);t._filters.push(i)}))},e.prototype._applyFilter=function(e){e.filters||(e.filters=[]),e.filters=this._filters.concat(e.filters)},e.prototype._removeFilter=function(e){e&&e.filters&&e.filters.length&&this._filters.forEach((function(t){var i=e.filters.findIndex((function(e){return e===t}));i>-1&&e.filters.splice(i,1)}))},e.prototype._createFilterSync=function(e,t,i){var n="default"===this._key?e:"".concat(this._key,"|").concat(e),r=o.P6.kN[n];return r.baseTexture.scaleMode=o.aH.LINEAR,r.baseTexture.mipmap=o.KI.OFF,new s.f("lut",this._options,{uniforms:{lut:r,intensity:t,parentIntensity:i}})},e.prototype.clearTexture=function(){var e=B.getInstance();for(var t in o.P6.kN)if(t.indexOf(this._key)>-1){var i=o.P6.kN[t];e.removeRef(t)&&(o.xE.removeFromCache(i),i.destroy(!0),r.iV[t]&&r.iV[t]instanceof o.c2&&(r.iV[t].destroy(),delete r.iV[t]))}},e.prototype._loadImages=function(e){var t,i,n=this,s=(e.filter||[]).concat(e.makeup||[]).concat(e.sticker||[]),a=this._loader.getIndeLoader(),c={};this.localSpriteSheets=c;try{for(var u=W(s),h=u.next();!h.done;h=u.next()){var p=h.value;if(p.src instanceof Array)p.src.forEach((function(e,t){var i=n.checkSpriteSheetJSON(e);if(i){var r=i.meta.image,s="".concat(n._key,"|").concat(r);if(B.getInstance().addRef(s),o.P6.kN[s])return;if(0===r.indexOf("blob:")){var u=o.xE.from(r);o.xE.addToCache(u,s)}else a.add(s,r);i.meta.image="",c[s]=i}else{if(B.getInstance().addRef(e),o.P6.kN[e])return;if(a.resources[e])return;a.add(e,e)}}));else{var l="".concat(this._key,"|").concat(p.src);if(B.getInstance().addRef(l),o.P6.kN[l])continue;if(0===p.src.indexOf("blob:")){var f=o.xE.from(p.src);o.xE.addToCache(f,l)}else a.add(l,p.src)}}}catch(e){t={error:e}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(t)throw t.error}}return new Promise((function(e){a.load((function(t,i){return J(n,void 0,void 0,(function(){var t,n,s,a,u;return X(this,(function(h){switch(h.label){case 0:for(s in t=function(e){var t;return X(this,(function(i){switch(i.label){case 0:return r.iV[e]?[2,"continue"]:c[e]?(t=new o.c2(o.P6.kN[e],c[e],"@".concat((0,g.u)(),"x")),[4,new Promise((function(i){t.parse((function(){r.iV[e]=t,i()}))}))]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))},n=[],o.P6.kN)n.push(s);a=0,h.label=1;case 1:return a<n.length?(u=n[a],[5,t(u)]):[3,4];case 2:h.sent(),h.label=3;case 3:return a++,[3,1];case 4:for(u in i)r.iV[u]||c[u]||(r.iV[u]=i[u]);return e(),[2]}}))}))}))}))},e.prototype.checkSpriteSheetJSON=function(e){try{return JSON.parse(e)}catch(e){return null}},G([(0,p.M)("Effect"),H("design:type",Function),H("design:paramtypes",[Boolean]),H("design:returntype",void 0)],e.prototype,"remove",null),G([(0,p.M)("Effect"),H("design:type",Function),H("design:paramtypes",[Boolean]),H("design:returntype",void 0)],e.prototype,"destroy",null),G([(0,p.M)("Effect"),H("design:type",Function),H("design:paramtypes",["function"==typeof(t=void 0!==o.W2&&o.W2)?t:Object]),H("design:returntype",void 0)],e.prototype,"_removeFilter",null),e}(),Y=function(e){function t(t,i,n,r,s,o,a,c){var u=e.call(this,"default",i,n,r,s,o,a,c)||this;return u._json=t,u._app3d=r,u}return z(t,e),t.prototype.load=function(e){return J(this,void 0,Promise,(function(){var t,i,n,r,s,o;return X(this,(function(a){switch(a.label){case 0:return t=this._json,i=t.filter,n=t.makeup,r=t.beautify,s=t.sticker,o=t.sticker3d,e&&e(!!(null==o?void 0:o.length)),[4,this._loadImages(t)];case 1:return a.sent(),this.loadFilter(i),[4,this.setMakeup(n)];case 2:return a.sent(),s?[4,this.loadStickers(s)]:[3,4];case 3:a.sent(),a.label=4;case 4:return o?this._app3d?[3,6]:[4,this.initThreeApp()]:[3,8];case 5:a.sent(),a.label=6;case 6:return[4,this.loadSticker3d(o||[])];case 7:a.sent(),a.label=8;case 8:return[2,r]}}))}))},t.prototype.loadImage=function(){return J(this,void 0,void 0,(function(){return X(this,(function(e){return[2]}))}))},t.prototype._loadImages=function(e){var t,i,n=this,s=new o.aN,a=(e.filter||[]).concat(e.makeup||[]).concat(e.sticker||[]),c={},u=function(e){if(e.src instanceof Array)e.src.forEach((function(t,i){var r=n.checkSpriteSheetJSON(t);if(r){var a=r.meta.image,u="".concat(n._key,"|").concat(a);if(o.P6.kN[u])return void B.getInstance().addRef(u);if(e.objectSrc&&e.objectSrc.length){var h=o.xE.from(e.objectSrc[i]);o.xE.addToCache(h,u),B.getInstance().addRef(u)}else if(0===a.indexOf("blob:")){h=o.xE.from(a);o.xE.addToCache(h,u)}else s.add(u,a);r.meta.image="",c[u]=r}else{if(o.P6.kN[t])return;if(s.resources[t])return;if(e.objectSrc&&e.objectSrc.length){h=o.xE.from(e.objectSrc[i],{resolution:(0,g.u)()});o.xE.addToCache(h,t)}else s.add(t,t)}}));else{if(B.getInstance().addRef(e.src),o.P6.kN[e.src])return"continue";if(s.resources[e.src])return K.info("already loaded file",e.src),"continue";if(e.objectSrc){K.info("use imagebitmap to create texture");var t=o.xE.from(e.objectSrc);o.xE.addToCache(t,e.src),B.getInstance().addRef(e.src)}else if(0===e.src.indexOf("blob:")){t=o.xE.from(e.src);K.info("JSONEffect blob texture",t),o.xE.addToCache(t,e.src),B.getInstance().addRef(e.src)}else s.add(e.src)}};try{for(var h=W(a),p=h.next();!p.done;p=h.next()){u(p.value)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(t)throw t.error}}return new Promise((function(e){return J(n,void 0,void 0,(function(){var t=this;return X(this,(function(i){return s.load((function(i,n){return J(t,void 0,void 0,(function(){var t,i,s,a,u;return X(this,(function(h){switch(h.label){case 0:for(s in t=function(e){var t;return X(this,(function(i){switch(i.label){case 0:return r.iV[e]?[2,"continue"]:c[e]?(t=new o.c2(o.P6.kN[e],c[e],"@".concat((0,g.u)(),"x")),[4,new Promise((function(i){t.parse((function(){r.iV[e]=t,i()}))}))]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))},i=[],o.P6.kN)i.push(s);a=0,h.label=1;case 1:return a<i.length?(u=i[a],[5,t(u)]):[3,4];case 2:h.sent(),h.label=3;case 3:return a++,[3,1];case 4:for(u in n)r.iV[u]||c[u]||(r.iV[u]=n[u]);return e(),[2]}}))}))})),[2]}))}))}))},t.prototype.loadSticker3d=function(e){return J(this,void 0,Promise,(function(){return X(this,(function(e){return[2]}))}))},t}(q),Z=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),$=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},Q=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ee=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},te=function(e,t){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},ie=((0,_.jl)("Effect"),function(){function e(e,t,i,n){this.type="hand",this._destroyed=!1,this._visible=!0,this._intensity=1,this.localSpriteSheets={},this._url=e,this._key=e,this._app3d=t,this._canvas=n,this._options=i}return Object.defineProperty(e.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"app3d",{get:function(){return this._app3d},set:function(e){this._app3d=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"intensity",{get:function(){return this._intensity},set:function(e){this._intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){this._destroyed||(this._visible=e)},enumerable:!1,configurable:!0}),e.prototype.download=function(){return ee(this,void 0,Promise,(function(){var e;return te(this,(function(t){switch(t.label){case 0:return[4,this._getLoader()];case 1:return[4,t.sent().preload(this._url)];case 2:return t.sent(),[4,this._getConfig()];case 3:return e=t.sent(),_.D4.info("download:",this._url,e),[2,e]}}))}))},e.prototype.load=function(){return ee(this,void 0,Promise,(function(){var e,t;return te(this,(function(i){switch(i.label){case 0:return[4,this.download()];case 1:return e=i.sent(),t=e.hand,[4,this.load3d(t||[])];case 2:return i.sent(),[4,this._getLoader()];case 3:return i.sent().removeFromCache(this._url),[2,null]}}))}))},e.prototype._getLoader=function(){return ee(this,void 0,void 0,(function(){return te(this,(function(e){switch(e.label){case 0:return this._loader?[3,2]:(this._loader=new r.pF,[4,this._loader.init()]);case 1:e.sent(),e.label=2;case 2:return[2,this._loader]}}))}))},e.prototype._getConfig=function(){return ee(this,void 0,void 0,(function(){var e;return te(this,(function(t){switch(t.label){case 0:return this._config?[3,3]:[4,this._getLoader()];case 1:return[4,(e=t.sent()).preload(this._url)];case 2:t.sent(),this._config=e.readJSON("content.json",this._key),t.label=3;case 3:return[2,this._config]}}))}))},e.prototype.load3d=function(e){return ee(this,void 0,void 0,(function(){return te(this,(function(e){return[2]}))}))},e.prototype.initThreeApp=function(){return ee(this,void 0,void 0,(function(){return te(this,(function(e){return[2]}))}))},e.prototype.apply3d=function(){},e.prototype.removeForConsole=function(){},e.prototype.destroyForConosle=function(){},e.prototype.apply=function(){this._destroyed||this._applyed||(this.apply3d(),this._applyed=!0)},e.prototype.getUrl=function(){return this._url},e.prototype.remove=function(){this.removeForConsole(),this._applyed=!1},e.prototype.tick=function(){},e.prototype.tickMesh=function(){},e.prototype.destroy=function(){this._destroyed=!0,this.remove(),this.destroyForConosle(),this.clearTexture()},e.prototype.clearTexture=function(){var e=B.getInstance();for(var t in o.P6.kN)if(t.indexOf(this._key)>-1){var i=o.P6.kN[t];e.removeRef(t)&&(o.xE.removeFromCache(i),i.destroy(!0),r.iV[t]&&r.iV[t]instanceof o.c2&&(r.iV[t].destroy(),delete r.iV[t]))}},e.prototype.checkSpriteSheetJSON=function(e){try{return JSON.parse(e)}catch(e){return null}},$([(0,p.M)("Effect"),Q("design:type",Function),Q("design:paramtypes",[]),Q("design:returntype",void 0)],e.prototype,"remove",null),$([(0,p.M)("Effect"),Q("design:type",Function),Q("design:paramtypes",[]),Q("design:returntype",void 0)],e.prototype,"destroy",null),e}()),ne=function(e){function t(t,i,n,r){var s=e.call(this,"default",i,n,r)||this;return s._json=t,s._app3d=i,s}return Z(t,e),t.prototype.load=function(){return ee(this,void 0,Promise,(function(){var e,t;return te(this,(function(i){switch(i.label){case 0:return e=this._json,(t=e.hand)?this._app3d?[3,2]:[4,this.initThreeApp()]:[3,4];case 1:i.sent(),i.label=2;case 2:return[4,this.loadHand3d(t||[])];case 3:i.sent(),i.label=4;case 4:return[2,null]}}))}))},t.prototype.loadImage=function(){return ee(this,void 0,void 0,(function(){return te(this,(function(e){return[2]}))}))},t.prototype.loadSticker3d=function(e){return ee(this,void 0,Promise,(function(){return te(this,(function(e){return[2]}))}))},t.prototype.loadHand3d=function(e){return ee(this,void 0,Promise,(function(){return te(this,(function(e){return[2]}))}))},t}(ie),re=i(5156),se=i(6309),oe=i(5562),ae=(0,_.jl)("videoFrameTextureManager"),ce=function(){function e(e){this.id=(new Date).getTime().toString(),this.pixiTexture=null,this.glTexture=null,this._width=0,this._height=0,console.log("VideoFrameTextureManager constructor"),this.renderer=e}return e.prototype.check=function(){var e=this.renderer.gl.isTexture(this.glTexture);return ae.info("check",e),e},e.prototype.update=function(e,t){void 0===t&&(t=!1);var i=this.renderer.gl,n=e.displayWidth,r=e.displayHeight;if(!this.pixiTexture||this._width!==n||this._height!==r||t){ae.info("VideoFrameTextureManager update",this._width,this._height,n,r),this.destroy(),this._width=n,this._height=r,this.glTexture=i.createTexture(),i.bindTexture(i.TEXTURE_2D,this.glTexture),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this._width,this._height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);var s=new o.VL(null,{width:this._width,height:this._height,format:i.RGBA,type:i.UNSIGNED_BYTE}),a=this.renderer,c=a.CONTEXT_UID||0;s._glTextures[c]||(s._glTextures[c]=a.texture.initTexture(s));var u=s._glTextures[c];this.glTexture&&(u.texture=this.glTexture),this.pixiTexture=new o.xE(s),o.P6.kN["videoframe-".concat(this.id)]=this.pixiTexture,o.P6.V8["videoframe-".concat(this.id)]=this.pixiTexture.baseTexture}if(this.glTexture){try{i.bindTexture(i.TEXTURE_2D,this.glTexture)}catch(e){ae.error("gl.bindTexture error",e)}e.width=e.displayWidth,e.height=e.displayHeight,i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e),this.pixiTexture&&this.pixiTexture.baseTexture.update()}else if(console.error("WebGLTexture 未初始化!"),!this.pixiTexture)return o.xE.EMPTY;return this.pixiTexture},e.prototype.destroy=function(){ae.info("videoFrameTextureManager destroy"),this.pixiTexture&&(this.pixiTexture.destroy(!0),this.pixiTexture=null),delete o.P6.kN["videoframe-".concat(this.id)],delete o.P6.V8["videoframe-".concat(this.id)],this._width=0,this._height=0},e.prototype.getTexture=function(){return this.pixiTexture},e}(),ue=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),he=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},pe=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},le=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},fe=function(e,t){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},de=function(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],n=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ye=(0,_.jl)("Renderer"),_e=function(){};var ge=function(e){function t(t){var i=e.call(this,t)||this;return i._setup=!1,i._effects=[],i._debug=!0,i._destroyed=!1,i._isVR=!1,i._meshVertexTimer=0,i.lastCheckTime=0,i.need3dRefresh=!1,i.lib3dLoaded=!1,i.libHand3dLoaded=!1,ye.info("[@#$] AR Renderer Constructed",t),i._debug=!1,t.output?i._canvas=new wx.window.Canvas(t.output):i._canvas=new wx.window.Canvas(wx.createOffscreenCanvas({type:"webgl",width:t.width,height:t.height})),i._options=t,o.Xd.RESOLUTION=(0,g.u)(),o.Xd.FILTER_RESOLUTION=(0,g.u)(),i._renderer=new o.Th({view:i._canvas,width:t.width,height:t.height,useContextAlpha:!1,preserveDrawingBuffer:!1,antialias:!1,autoDensity:!0}),i.setRenderer(),i.initRenderContext(t),i.handleLoading(),i.setup(),i}return ue(t,e),Object.defineProperty(t.prototype,"mirror",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"backGroundVR",{set:function(e){if(e){this._backgroundVR=new o.jy(o.xE.from(e));var t=this._backgroundVR,i=t.width,n=t.height,r=Math.max(this._options.width/i,this._options.height/n);this._backgroundVR.width*=r,this._backgroundVR.height*=r}else this._backgroundVR=null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{set:function(e){var t=e.width,i=e.height;this._canvas.width=t,this._canvas.height=i,this._renderer&&this.resize(t,i),this._baseSprite&&(this._baseSprite.width=t,this._baseSprite.height=i,this._baseSprite.position.set(t/2,i/2),this._baseSprite.anchor.set(.5,.5)),this._makeupRenderTexture.resize(t,i),this._options=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"app3d",{get:function(){return this._app3d},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"avatar3d",{get:function(){return this._avatar3d},enumerable:!1,configurable:!0}),t.prototype.initRenderContext=function(e){this._makeupContainer=new o.W2,this._frontContainer=new o.W2,this._frontContainer.sortableChildren=!0,this._finalContainer=new o.W2,this._makeupRenderTexture=o.TI.create({width:e.width,height:e.height}),this._finalContainer.addChild(this._makeupContainer),this._finalContainer.addChild(this._frontContainer),this._target=this._finalContainer},t.prototype.loadLib3d=function(){return le(this,void 0,Promise,(function(){var e;return fe(this,(function(t){switch(t.label){case 0:return e=new se.e({}),ye.info("loader init"),[4,e.init()];case 1:return t.sent(),ye.info("loader init done"),this._options.plugin3d&&this._options.plugin3d(q,Y,e,wx.window),[2]}}))}))},t.prototype.loadHand3d=function(){return le(this,void 0,Promise,(function(){var e;return fe(this,(function(t){switch(t.label){case 0:return e=new se.e({}),ye.info("+++++loader init"),[4,e.init()];case 1:return t.sent(),ye.info("+++++loader init done"),this._options.plugin3d&&this._options.pluginHand(ie,ne,e,wx.window),[2]}}))}))},t.prototype.setup=function(){return le(this,void 0,void 0,(function(){return fe(this,(function(e){switch(e.label){case 0:return this._setup?[2]:(this._config=new m.M,[4,this._config.load()]);case 1:return e.sent(),this._setup=!0,[2]}}))}))},Object.defineProperty(t.prototype,"meshVertex",{get:function(){return this._meshVertex},set:function(e){this._meshVertex=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mirrorFilter",{get:function(){return this._mirrorFilter||(this._mirrorFilter=new s.f("mirror",{width:b.t.instance.options.width,height:b.t.instance.options.height})),this._mirrorFilter},enumerable:!1,configurable:!0}),t.prototype.switchMode=function(e){_.bH.info("switchMode",e),e!==this._mode3d&&("Sticker"===e&&this.setAvatar(null),this._mode3d=e)},t.prototype.logTime=function(e){var t=+new Date;ye.info("".concat(e," time:").concat(t-this.currentTime)),this.currentTime=t},t.prototype.tick=function(t,i){var n=t.landmarks,r=t.meshVertex,s=t.lipVertex,a=t.image,c=t.angles,u=(t.backgroundType,t.background,t.segmentation,t.blendshapes,t.isLivePusher);t.hair;if(!this._destroyed)if(this._renderer)if(this._setup){this.currentTime=+new Date;try{(this.need3dRefresh&&L.s.checkEnabled("beautify")&&"Sticker"===this._mode3d||L.s.checkEnabled("beautify")&&"AR"===this._mode3d||L.s.checkEnabled("handLandmark"))&&this._renderer.reset()}catch(e){}if(this._isVR)try{this._renderer.render(this._backgroundVR)}catch(e){}else{if(u)if(this._baseSprite)this._baseSprite.texture.update();else{d=o.xE.from(a);this._baseSprite=new o.jy(d),this._baseSprite.anchor.set(.5,.5),this._baseSprite.position.set(this._options.width/2,this._options.height/2),this._baseSprite.scale.set(1,-1),this._makeupContainer.addChild(this._baseSprite)}else{var h=a,p=h.width,l=h.height,f=h.data;if(this._baseSprite){if(this._baseSprite.texture.width===p&&this._baseSprite.texture.height===l)this._baseSprite.texture.baseTexture.resource.data=new Uint8Array(f),this._baseSprite.texture.update();else this._baseSprite.texture.destroy(!0),this._baseSprite.texture=o.xE.fromBuffer(new Uint8Array(f),p,l)}else{var d=o.xE.fromBuffer(new Uint8Array(f),p,l);this._baseSprite=new o.jy(d),this._baseSprite.anchor.set(.5,.5),this._baseSprite.position.set(this._options.width/2,this._options.height/2);var y=Math.max(this._options.width/p,this._options.height/l);this._baseSprite.scale.set(y*(0,g.u)()),this._makeupContainer.addChild(this._baseSprite)}}(L.s.checkEnabled("beautify")||L.s.checkEnabled("segmentation")||L.s.checkEnabled("hair"))&&(e.prototype.setMesh.call(this,r),e.prototype.setReshapeMarks.call(this,n),n&&n.length?(this._faceLandmarks=n,this._angles=c,this.meshVertex=r,this.lipVertex=s,this.detected=!0,this._effects.forEach((function(e){e.visible||(e.visible=!0),e.lipmesh=s,e.mesh=r,e.angles=c,e.faceLandMarks=n,e.tick()})),"Sticker"===this._mode3d&&this._app3d&&this._app3d.loaded&&(this._app3d.facelandmarks=n,this._app3d.angles=c)):(this.handleNoFace(),this.detected=!1)),this._render()}}else _.b_.info("_renderer waiting for setup");else _.b_.info("_renderer waiting for renderer")},t.prototype.getBackgroungInstance=function(e,t,i,n){var r;return"image"===e?r=new ImageBackground(this._options,t,i):"video"===e?r=new VideoBackground(this._options,t,i):"blur"===e?r=new BlurBackground(this._options,i,n,this._videoFrameTextureManager,this._renderer):"green"===e&&(r=new ColorBackground(this._options,i)),r},t.prototype.handleNoFace=function(){this._effects.forEach((function(e){return e.visible=!1})),this._effects.forEach((function(e){e.tickMesh()}));new Date;"AR"===this._mode3d||"Sticker"===this._mode3d&&this._app3d&&this._app3d.loaded&&(this._app3d.facelandmarks=[],this._app3d.angles={})},t.prototype._render=function(){this.renderLayers(),L.s.checkEnabled("beautify")&&"Sticker"===this._mode3d&&this._app3d&&this._app3d.loaded&&this._app3d.render(),L.s.checkEnabled("handLandmark")&&this._appHand3d&&this._appHand3d.render()},t.prototype.renderLayers=function(){e.prototype.renderDermabrasion.call(this),this._renderer.render(this._finalContainer)},t.prototype.preUploadBaseTexture=function(e,t){var i=this;if(this._baseSprite)if("undefined"!=typeof VideoFrame&&e instanceof VideoFrame){var n=this._videoFrameTextureManager.update(e),r=this._baseSprite.texture;this._baseSprite.texture=n,this._baseSprite.texture.update(),r!==this._baseSprite.texture&&(_e.baseTexture=this._baseSprite.texture,D.instance.updateMakeupConfigShortcut(this._renderer))}else if(e instanceof ImageData){var s=this._baseSprite.texture.baseTexture.resource;s.width!==e.width||s.height!==e.height?(this._baseSprite.texture=o.xE.fromBuffer(e.data,e.width,e.height),_e.baseTexture=this._baseSprite.texture,D.instance.updateMakeupConfigShortcut(this._renderer)):this._baseSprite.texture.baseTexture.resource.data=e.data}else{var a=this._baseSprite.texture.baseTexture.resource,c=a.source;if(c.width!==e.width||c.height!==e.height){r=this._baseSprite.texture;this._baseSprite.texture=o.xE.from(e),r!==this._baseSprite.texture&&(_e.baseTexture=this._baseSprite.texture,D.instance.updateMakeupConfigShortcut(this._renderer))}else a.source!==e&&(a.source=e)}else{var u=void 0;"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(this._videoFrameTextureManager||(this._videoFrameTextureManager=new ce(this._renderer)),u=this._videoFrameTextureManager.update(e)):u=e instanceof ImageData?o.xE.fromBuffer(e.data,e.width,e.height):o.xE.from(e),this._baseSprite=new o.jy(u),this._baseSprite.width=this._options.width,this._baseSprite.height=this._options.height,this._baseSprite.filters=b.t.instance.options.mirror?[this.mirrorFilter]:[],b.t.instance.on("mirrorChange",(function(e){var t=e.mirror;if(ye.info("renderer mirror change",t),t)i._baseSprite.filters.push(i.mirrorFilter);else{var n=i._baseSprite.filters.findIndex((function(e){return e===i.mirrorFilter}));n>-1&&i._baseSprite.filters.splice(n,1)}})),this._makeupContainer.addChild(this._baseSprite),_e.baseTexture=this._baseSprite.texture}if(this._baseSprite.texture.update(),t)return this._prerenderer||(this._prerenderer=new o.Th({width:this._options.width/2-this._options.width/2%2,height:this._options.height/2-this._options.height/2%2})),this._prerenderer.extract.pixels(this._baseSprite,t),t},t.prototype.getBaseTexture=function(){return this._baseSprite.texture},t.prototype.removeBackground=function(){this.background&&(this.background.remove(),this.background=null)},t.prototype.disableEdgeOptimization=function(){this.background&&this.background.disableEdgeOptimization()},t.prototype.enableEdgeOptimization=function(){this.background&&this.background.enableEdgeOptimization()},t.prototype.applyBackground=function(e){this.background},t.prototype.removeForeground=function(){this._frontContainer&&(this._frontContainer.children.forEach((function(e){e.destroy()})),this._frontContainer.removeChildren())},t.prototype.addForeground=function(e){var t=this;if(Array.isArray(e)){var i={};for(var n in this._frontContainer.children.forEach((function(e){i[e.id]=e})),e.forEach((function(e,n){var r=i[e.id];r?(r.zIndex=n,delete i[e.id]):t._addForeground(e,n)})),i)i[n].destroy(),this._frontContainer.removeChild(i[n]);this._frontContainer.sortChildren()}else this._addForeground(e)},t.prototype._addForeground=function(e,t){var i=e.image,n=e.type,r=e.id,s=b.t.instance.options,a=s.width,u=s.height,h="data"in i?o.xE.fromBuffer(new Uint8Array(i.data.buffer),i.width,i.height):o.xE.from(i),p=new c.jy(h);"video"===n&&(p.blendMode_1=6),p.width=a,p.height=u,p.id=r,t&&(p.zIndex=t),this._frontContainer.addChild(p)},t.prototype.debugDraw=function(e){if(null==e?void 0:e.length){if(!this.points){for(var t=[],i=0;2*i<e.length;i++){var n=this.getCircle(2);t.push(n),this._finalContainer.addChild(n)}this.points=t}for(i=0;2*i<e.length;i++)this.points[i].x=e[2*i],this.points[i].y=e[2*i+1]}},t.prototype.debugDraw2=function(e){if(null==e?void 0:e.length){if(!this.points){for(var t=[],i=0;i<e.length;i++){var n=this.getCircle(2);t.push(n),this._finalContainer.addChild(n)}this.points=t}for(i=0;i<e.length;i++)this.points[i].x=e[i].x*b.t.instance.options.width,this.points[i].y=e[i].y*b.t.instance.options.height}},t.prototype.getPixels=function(){var e=this._options,t=e.width,i=e.height,n=new Uint8Array(t*i*4),r=this._renderer.gl;return r.readPixels(0,0,t,i,r.RGBA,r.UNSIGNED_BYTE,n),{data:n,width:t,height:i}},t.prototype.setEffect=function(e,t,i,n){return le(this,void 0,Promise,(function(){var r,s=this;return fe(this,(function(o){return r=!0,this.latestEffectUrls&&this.latestEffectUrls.length===e.length&&e.every((function(e){return s.latestEffectUrls.indexOf(e)>-1}))&&(r=!1,this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)),this.latestEffectUrls=e,[2,new Promise((function(o,a){r?(s.debounceTimer&&(clearTimeout(s.debounceTimer),s.debounceTimer=null),s.debounceTimer=setTimeout((function(){return s._setEffect(e,t,i,n).then((function(e){clearTimeout(s.debounceTimer),s.debounceTimer=null,o(e)}))}),100)):s._setEffect(e,t,i).then((function(e){o(e)}))}))]}))}))},t.prototype._setEffect=function(e,t,i,n){return le(this,void 0,Promise,(function(){var s,o=this;return fe(this,(function(a){return _.b_.time("AI init duration"),L.s.checkEnabled("beautify")&&!this._meshVertex?[2,new Promise((function(r){clearTimeout(o._meshVertexTimer),o._meshVertexTimer=setInterval((function(){_.b_.info("waiting for AI init..."),o._meshVertex&&(_.b_.info("waiting for AI init...done"),clearTimeout(o._meshVertexTimer),o._setEffect(e,t,i,n).then((function(){r(o._effects)})))}),200)}))]:(_.b_.timeEnd("AI init duration"),s="uid_"+Math.floor(1e8*Math.random()),[2,new Promise((function(a,c){return le(o,void 0,void 0,(function(){var o,c,u,h,p,l,f,d,y,g,m,b,v,k,x,w,M,T=this;return fe(this,(function(C){switch(C.label){case 0:for(o=[].concat(this._effects),c=[],u=[],h=[],p=[],l=[],f=[],d=[],y=[],e.length||(this.filterActivedEffect=null),g=[],m=function(n){var s=o.findIndex((function(t){return t.url===e[n]}));if(s>-1)c.push(o[s]),o[s],u.push(t[n]),h.push(i[n]),o.splice(s,1);else{var a=e[n];y.push(function(e){return le(this,void 0,Promise,(function(){var t,i;return fe(this,(function(n){switch(n.label){case 0:return[4,(t=new r.pF).init()];case 1:return n.sent(),[4,t.preload(e)];case 2:return n.sent(),i=t.readJSON("content.json",e),_.D4.info("download:",e,i),[2,i]}}))}))}(a)),g.push(a),l.push(t[n]),f.push(i[n])}},b=0;b<e.length;b++)m(b);return[4,Promise.all(y)];case 1:for(v=C.sent(),!1,k=!1,x=0;x<v.length;x++)w=g[x],M=void 0,(M=new q(w,this._makeupContainer,this._finalContainer,this._app3d,this._options,this._meshVertex,this._faceLandmarks,this.lipVertex,this._angles,l[x],this._canvas)).filterIntensity=f[x],v[x].sticker3d&&v[x].sticker3d.length&&(k=!0),M.renderer=this._renderer,p.push(M);return _.b_.time("require 3d lib"),this.lib3dLoaded||!k?[3,3]:(_.b_.info("check useFace3d",n()),n&&!n()?[2]:(ye.info("require 3d lib"),[4,this.loadLib3d()]));case 2:C.sent(),this.lib3dLoaded=!0,C.label=3;case 3:return _.b_.timeEnd("require 3d lib"),p.forEach((function(e){d.push(e.load((function(e){e&&(T.need3dRefresh=!0)})).then((function(){return e.intensity=e.intensity,T._app3d||"face"!==e.type||(T._app3d=e.app3d),T._appHand3d||"hand"!==e.type||(T._appHand3d=e.app3d),e})).catch((function(e){ye.error("effect load error",e)})))})),_.b_.time("renderer parse effect"),Promise.all(d).then((function(e){_.b_.timeEnd("renderer parse effect"),_.b_.time("renderer apply effect");for(var t=!1,i=0;i<p.length;i++){var n=p[i];T.latestEffectUrls&&-1===T.latestEffectUrls.indexOf(n.getUrl())&&(n.destroy(!0),t=!0)}if(t)ye.info(s+"end");else{o.forEach((function(e){e.remove(!0)})),T._effects=c,c.forEach((function(e,t){e.intensity=u[t],e.filterIntensity=h[t]}));for(i=0;i<p.length;i++){n=p[i];T._effects.push(n),n.apply({filterTarget:T._makeupContainer,filterCallback:function(){}})}o.forEach((function(e){e.destroy(!0)})),_.b_.timeEnd("renderer apply effect"),(p.length||o.length)&&D.instance.updateMakeupConfigShortcut(T._renderer),a(T._effects)}})),[2]}}))}))}))])}))}))},t.prototype.setEffectJSON=function(e){return le(this,void 0,void 0,(function(){var t,i,n,r,s,o=this;return fe(this,(function(a){switch(a.label){case 0:return i=e.sticker3d,n=e.hand,i&&i.length&&!this.lib3dLoaded?(ye.info("require 3d lib"),[4,this.loadLib3d()]):[3,2];case 1:a.sent(),this.lib3dLoaded=!0,a.label=2;case 2:return n&&n.length&&!this.libHand3dLoaded?(ye.info("require 3d hand lib"),[4,this.loadHand3d()]):[3,4];case 3:a.sent(),this.libHand3dLoaded=!0,a.label=4;case 4:return r=!1,(s=function(){L.s.checkEnabled("beautify")&&o._meshVertex&&(t&&clearTimeout(t),r=!0,o.getJSONEffectForFace(e)),L.s.checkEnabled("handLandmark")&&n&&n.length&&(r=!0,o.getJSONEffectForHand(e)),r||(t=setTimeout(s,20))})(),[2]}}))}))},t.prototype.getJSONEffectForHand=function(e){var t=this,i=new ne(e,this._appHand3d,this._options,this._canvas);i.renderer=this._renderer,_.b_.info("getJSONEffectForHand"),i.load().then((function(){t._appHand3d||(t._appHand3d=i.app3d),i.apply()}))},t.prototype.getJSONEffectForFace=function(e){var t=this,i=new Y(e,this._makeupContainer,this._finalContainer,this._app3d,this._options,this._meshVertex,this._faceLandmarks,this.lipVertex);return i.renderer=this._renderer,i.load((function(e){e&&(t.need3dRefresh=!0)})).then((function(){t._app3d||(t._app3d=i.app3d);var e=[].concat(t._effects);t._effects=[i],i.apply({filterTarget:t._makeupContainer}),e.forEach((function(e){e.destroy()}))})),i},t.prototype.setExclusiveFilter=function(e,t){var i=this;return void 0===t&&(t=1),new Promise((function(n,r){!function(){if(i.exclusiveFilter&&i.exclusiveFilter.getUrl()===e)i.exclusiveFilter.intensity=t,i.exclusiveFilter.filterIntensity=t;else{var r=new q(e,i._makeupContainer,i._finalContainer,i._app3d,i._options,i._meshVertex,i._faceLandmarks,i.lipVertex,i._angles,t);r.filterIntensity=t,r.load((function(e){e&&(i.need3dRefresh=!0)})).then((function(){i.exclusiveFilter&&i.exclusiveFilter.destroy(),i.exclusiveFilter=r,r.renderer=i._renderer,r.apply({filterTarget:i._makeupContainer}),n()}))}}()}))},t.prototype.resize=function(t,i,n){if(void 0===n&&(n=!0),e.prototype.resize.call(this,t,i),ye.info("renderer resize",t,i,n),this._options.width=t,this._options.height=i,this._renderer.resize(t,i),this.background&&this.background.resize(t,i),this._app3d?this._app3d.resize(t,i):this._avatar3d&&this._avatar3d.resize(t,i),this._makeupRenderTexture&&this._makeupRenderTexture.resize(t,i),n&&this._baseSprite&&(this._baseSprite.width=t,this._baseSprite.height=i,this._baseSprite.position.set(t/2,i/2),this._baseSprite.anchor.set(.5,.5),this._baseSprite.scale.set(1)),this._backgroundVR){var r=this._backgroundVR,s=r.width,o=r.height,a=Math.max(t/s,i/o);this._backgroundVR.width*=a,this._backgroundVR.height*=a}this._effects.forEach((function(e){e.resize(t,i)}))},t.prototype.disableExclusiveFilter=function(){this.exclusiveFilter&&this.exclusiveFilter.remove()},t.prototype.enableExclusiveFilter=function(){this.exclusiveFilter&&this.exclusiveFilter.apply({filterTarget:this._makeupContainer,filterCallback:function(){}})},t.prototype.disableEffects=function(e){void 0===e&&(e=!1),this._effects.forEach((function(t){!e&&t.isPureFilter||"hand"===t.type||t.remove()}))},t.prototype.enableEffects=function(){var e=this;this._effects.forEach((function(t){t.apply({filterTarget:e._makeupContainer,filterCallback:function(){}})}))},t.prototype.removeExclusiveFilter=function(){this.exclusiveFilter&&(this.exclusiveFilter.destroy(),this.exclusiveFilter=null)},t.prototype.initAvatarApp=function(e,t){return le(this,void 0,void 0,(function(){return fe(this,(function(e){return[2]}))}))},t.prototype.setAvatar=function(e,t){return le(this,void 0,void 0,(function(){return fe(this,(function(e){return[2]}))}))},t.prototype.registerAvatar=function(e){},t.prototype.reCorrectAvatar=function(){return le(this,void 0,void 0,(function(){return fe(this,(function(e){return[2]}))}))},t.prototype.getCanvas=function(){return this._canvas},t.prototype.setOptions=function(e){},t.prototype.mount=function(e){this._canvas&&e.appendChild(this._canvas)},t.prototype.getCircle=function(e){void 0===e&&(e=5);var t=new o.TC;return t.beginFill(16711680),t.drawCircle(0,0,e),t.endFill(),t},t.preloadEffects=function(e){return le(this,void 0,Promise,(function(){var t,i,n,s,o,a,c;return fe(this,(function(u){switch(u.label){case 0:return e.length?[4,(t=new r.pF).init()]:[2];case 1:u.sent(),i=[];try{for(n=de(e),s=n.next();!s.done;s=n.next())(o=s.value)&&i.push(t.preload(o))}catch(e){a={error:e}}finally{try{s&&!s.done&&(c=n.return)&&c.call(n)}finally{if(a)throw a.error}}return[2,Promise.all(i).then((function(){return Promise.resolve()})).catch((function(e){return Promise.reject(e)}))]}}))}))},t.prototype.handleLoading=function(){var e=this._options,i=e.enableLoadingIcon,n=e.loadingIconOptions,r=void 0===n?{}:n;if(i){var s=t.loading=new re.Z(r);s.zIndex=20;var o=this._options,a=o.width,c=o.height;s.x=a/2,s.y=c/2,this._finalContainer.addChild(s)}},t.prototype.showLoading=function(){t.loading&&t.loading.show()},t.prototype.hideLoading=function(){t.loading&&t.loading.hide()},t.prototype.destroy=function(e){void 0===e&&(e=!0),this.hideLoading(),t.loading&&t.loading.destroy(),e&&_e.baseTexture&&(_e.baseTexture.destroy(!0),_e.baseTexture=null),D.instance.clear(),this._destroyed=!0,this._effects.forEach((function(e){e.destroy()})),this.exclusiveFilter&&this.exclusiveFilter.destroy(),this._stage&&this._stage.destroy(!0),this._renderer&&this._renderer.destroy(!0),this.background&&this.background.destroy(),this._app3d&&this._app3d.destroy(),this._appHand3d&&this._appHand3d.destroy(),this._meshVertexTimer&&clearTimeout(this._meshVertexTimer),this.destroyAvatar()},t.prototype.destroyAvatar=function(){this._avatar3d&&(this._avatar3d.destroy(),this._avatar3d=null)},he([(0,p.M)("ArRenderer"),pe("design:type",Function),pe("design:paramtypes",[Object]),pe("design:returntype",void 0)],t.prototype,"destroy",null),t}(oe.F)}}]);
1
+ var self = wx;(self.webpackChunktencentcloud_webar=self.webpackChunktencentcloud_webar||[]).push([[321],{8019:(e,t,i)=>{i.d(t,{g:()=>ge,b:()=>_e});var n,r=i(3044),s=i(9124),o=i(1206),a=i(3125),c=i(9560),u=i(401),h=i(1347),p=i(1084),l=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},f=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},d=function(){function e(e,t,i,n,r,s,a,c){this._container=new o.W2,this._name=e,this._src=t,this._target=n,this._config=i,this._jsonIntensity=i.intensity,this._landmarks=r,this._options=s,this._key=a,this._angles=c}return Object.defineProperty(e.prototype,"parentIntensity",{get:function(){return this._parentIntensity},set:function(e){this._parentIntensity=e,this._sticker&&(this._sticker.alpha=this._jsonIntensity*e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceLandMarks",{set:function(e){this._landmarks=e,this._sticker&&this.setStickerProps()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angles",{set:function(e){this._angles=e,this._sticker&&this.setStickerProps()},enumerable:!1,configurable:!0}),e.prototype.getCircle=function(e){void 0===e&&(e=5);var t=new o.TC;return t.beginFill(16711680),t.drawCircle(0,0,e),t.endFill(),t},e.prototype.getCircle2=function(e){void 0===e&&(e=5);var t=new o.TC;return t.beginFill(255),t.drawCircle(0,0,e),t.endFill(),t},e.prototype.getDisplay=function(){return this._container},e.prototype.load=function(){var e,t=this;if(this.checkAnimated()){var i=[];this._src.forEach((function(e){var n;n=e.indexOf(".json")>-1?e:"".concat(t._key,"|").concat(JSON.parse(e).meta.image);var s=r.iV[n].textures,o=Object.keys(s).map((function(e){return s[e]}));i=i.concat(o)})),(e=new c.Kg(i)).animationSpeed=(this._config.fps||30)/60,e.play()}else{var n=this._src[0],s=o.P6.kN[n];e=new c.jy(s)}this._config.blend&&(e.blendMode_1=this._config.blend);this._config.wxAnchorOffset;e.width=this._config.width,e.height=this._config.height;var a=[.5,.5];this._config.anchor&&(a=this._config.anchor),e.anchor.set(a[0],a[1]),e.alpha=this._jsonIntensity*this.parentIntensity,this._sticker=e,this._container.addChild(this._sticker),this._container.convertTo3d(),this.setStickerProps()},e.prototype.setStickerProps=function(){var e=this._config,t=this._landmarks,i=u.Jp.map((function(e){return t[e]})),n=(0,h.Sp)(i[0],i[1]),r=e.wxAnchorArea,s=(e.wxAnchorOffset,e.wxWeights),o=n/u.jw,a=r.map((function(e){var i=t[e];return{x:i.x,y:i.y,z:0}}));this._container.scale.set(o);var c={x:a[0].x*s[0]+a[1].x*s[1]+a[2].x*s[2],y:a[0].y*s[0]+a[1].y*s[1]+a[2].y*s[2]};this._container.position.x=c.x,this._container.position.y=c.y,this._angles&&(this._container.euler.z=this._angles.roll,this._container.euler.y=this._angles.yaw,this._container.euler.x=this._angles.pitch)},e.prototype.checkAnimated=function(){if(this._src instanceof Array&&this._src.length>1)return!0;try{return JSON.parse(this._src[0]),!0}catch(e){return"json"===this._src[0].split(".").pop()}},e.prototype.tick=function(){},e.prototype.apply=function(){},e.prototype.remove=function(){},e.prototype.destroy=function(){this._sticker.destroy(),this._container.destroy(),this._sticker=null,this._target=null},l([(0,p.M)("StickerLayer"),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",Boolean)],e.prototype,"checkAnimated",null),l([(0,p.M)("StickerLayer"),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",void 0)],e.prototype,"destroy",null),e}(),y=function(){function e(e,t,i,n,r,s,o){void 0===o&&(o=1);var c=this;this._stickers=[],this._visible=!0,this._parentIntensity=1,this._target=i,this._options=r,this._landmarks=n;var u=new a.LE;u.setPlanes(400,10,1e4,!0),this._camera=u,this._stickers=t.map((function(t){var o=new d(t.name,t.src,t,i,n,r,e,s);return o.parentIntensity=c.parentIntensity,o.load(),c._camera.addChild(o.getDisplay()),o}))}return Object.defineProperty(e.prototype,"parentIntensity",{get:function(){return this._parentIntensity},set:function(e){this._stickers.forEach((function(t){t.parentIntensity=e})),this._parentIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceLandMarks",{set:function(e){this._stickers.forEach((function(t){t.faceLandMarks=e}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angles",{set:function(e){this._stickers.forEach((function(t){t.angles=e}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){this._target&&e!==this._visible&&(this._visible=e,e?this.apply():this.remove())},enumerable:!1,configurable:!0}),e.prototype.tick=function(){this._stickers.forEach((function(e){return e.tick()}))},e.prototype.apply=function(){this._target.addChild(this._camera)},e.prototype.remove=function(){this._target.removeChild(this._camera)},e.prototype.destroy=function(){this.remove(),this._stickers.forEach((function(e){return e.destroy()})),this._camera.destroy(),this._stickers=[]},e}(),_=i(6109),g=i(201),m=i(617),b=i(3849),v=(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),k=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},x=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},w=(0,_.jl)("merged-makeup-layer");var M=function(){function e(e,t,i,n,r){this._destroyed=!1,this.type="makeup",this._parentIntensity=1,this._jsonIntensity=1,this.textures=[],this.files=[],this._options=e,this._container=t,this._lipMaskTexture=r,this.renderer=i,this.type=n||"makeup"}return e.prototype.setParentIntensityAt=function(e,t){if(this.shader&&this.files.length)for(var i=0;i<this.files.length;i++){if(this.files[i].parentKey===e)this.files[i].parentIntensity=t,this.shader.uniforms["parentIntensity".concat(i)]=t}},Object.defineProperty(e.prototype,"lipMask",{set:function(e){null===e||(this._lipMaskTexture=e.texture,this.shader&&(this.shader.uniforms.uSamplerLipMask=this._lipMaskTexture))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visible",{set:function(e){this.shader&&(this.shader.uniforms.enable=e?1:0)},enumerable:!1,configurable:!0}),e.prototype.updateGeometry=function(e){this._destroyed},e.prototype.renderMesh=function(){},e.prototype.resize=function(e,t){this._options.width=e,this._options.height=t,this.shader&&(this.shader.uniforms.size=[e,t])},e.prototype.drawMeshBatch=function(e,t){var i=this;if(!this._destroyed){this.files=e;var n=Array.from(e.reduce((function(e,t){return e.add(t.blend),e}),new Set));this.irisRenderTexture&&!n.includes(this.irisBlendMode)&&n.push(this.irisBlendMode);var r="\n precision mediump float;\n varying vec2 vUvs;\n varying vec2 bUvs;\n uniform sampler2D uSamplerLipMask;\n \n\n ".concat(e.map((function(e,t){return"uniform sampler2D uSamplerMakeup".concat(t,";")})).join("\n"),"\n ").concat(e.map((function(e,t){return"uniform float intensity".concat(t,";")})).join("\n"),"\n ").concat(e.map((function(e,t){return"uniform float parentIntensity".concat(t,";")})).join("\n"),"\n uniform int enable;\n uniform sampler2D baseImage;\n \n uniform sampler2D uSamplerIris;\n\n uniform int mirror;\n uniform vec2 imageOffset;\n \n ").concat(n.map((function(e){return c.Lc[e].shader})).join("\n"),"\n \n void main() {\n if (enable == 0) {\n gl_FragColor = vec4(0.0,0.0,0.0,0.0);\n return;\n }\n\n // todo:适配镜像与非镜像\n vec2 baseCoord = bUvs;\n baseCoord += imageOffset;\n\n if (mirror == 1) {\n baseCoord = vec2(1.0 - bUvs.x, bUvs.y);\n }\n \n vec4 baseColor = texture2D(baseImage, baseCoord);\n\n vec4 makeupColor = vec4(0.0);\n float alphaFromMask = 1.0 - texture2D(uSamplerLipMask, bUvs).a; \n\n ").concat(e.map((function(e,t){return"\n \n vec4 color".concat(t," = texture2D(uSamplerMakeup").concat(t,", vUvs);\n float a").concat(t," = color").concat(t,".a;\n float realIntensity").concat(t," = intensity").concat(t," * parentIntensity").concat(t,";\n\n makeupColor = texture2D(uSamplerMakeup").concat(t,", vUvs) * realIntensity").concat(t," * alphaFromMask;\n \n if (makeupColor.a > 0.) {\n \n\n // 混合\n baseColor.rgb = blend").concat(c.Lc[e.blend].key,"(baseColor.rgb, makeupColor.rgb/makeupColor.a , makeupColor.a);\n \n }\n \n \n \n\n ")})).join("\n"),"\n\n ").concat(this.irisRenderTexture?"\n // 混合美瞳\n vec4 irisColor = texture2D(uSamplerIris, bUvs);\n if (irisColor.a > 0.) {\n baseColor.rgb = blend".concat(c.Lc[this.irisBlendMode].key,"(baseColor.rgb, irisColor.rgb/irisColor.a , irisColor.a);\n }\n "):"","\n \n \n // 输出\n gl_FragColor = baseColor;\n // gl_FragColor = makeupColor;\n }"),s={enable:1},a=this._options,u=a.width,h=a.height;s.baseImage=_e.baseTexture,s.size=[u*h/_e.baseTexture.height,h];var p=_e.baseTexture.width*h/_e.baseTexture.height;s.imageOffset=[(p-u)/2/p,0],e.forEach((function(e,t){var n=e.src,r=o.P6.kN[n];s["uSamplerMakeup".concat(t)]=r,s["intensity".concat(t)]=e.intensity,s["parentIntensity".concat(t)]=null==e.parentIntensity?1:e.parentIntensity,s.mirror=b.t.instance.options.mirror?1:0,i.textures.push(r)})),this.irisRenderTexture&&(s.uSamplerIris=this.irisRenderTexture,s.mirror=b.t.instance.options.mirror?1:0),s.uSamplerLipMask=this._lipMaskTexture;var l=o.ex.from("\n precision mediump float;\n attribute vec2 aVertexPosition;\n attribute vec2 aUvs;\n\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n uniform vec2 size;\n varying vec2 vUvs;\n varying vec2 bUvs;\n\n \n void main() {\n vUvs = aUvs;\n bUvs = aVertexPosition.xy /size;\n // lipUvs = lipAuvs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n }",r,s);this.shader=l,this.mirrorChangeHandler=function(e){i.shader&&(i.shader.uniforms.mirror=(null==e?void 0:e.mirror)?1:0)},b.t.instance.on("mirrorChange",this.mirrorChangeHandler);var f=new o.Kj(t,l);return this._mesh=f,this._container.addChild(f),f}},e.prototype.destroy=function(){var e;w.info("MakeupLayer destroy"),this._destroyed=!0,this._mesh&&(this._mesh.destroy({children:!0,texture:!1,baseTexture:!1}),this._mesh.mask=null,this._mesh=null),this._maskRenderTexure&&this._maskRenderTexure.destroy(!1),this.shader&&(null===(e=this.shader)||void 0===e||e.destroy(),this.shader=null),this.mirrorChangeHandler&&b.t.instance.off("mirrorChange",this.mirrorChangeHandler)},k([(0,p.M)("MakeupLayer"),x("design:type",Function),x("design:paramtypes",[Array]),x("design:returntype",void 0)],e.prototype,"updateGeometry",null),k([(0,p.M)("MakeupLayer"),x("design:type",Function),x("design:paramtypes",[]),x("design:returntype",void 0)],e.prototype,"destroy",null),e}(),T=function(e){function t(t,i,n,r,s,a,c,u){var h=e.call(this,t,a)||this;return h._maskGraphics=new o.TC,h.maxLConSize=.42,h.maxRConSize=.42,h._parentIntensity=1,h.parentKey=c,h.jsonIntensity=r,h._parentIntensity=u||1,h.getTexture(i,n),h._config=s,h.renderTexture=o.TI.create({width:t.width,height:t.height}),h}var i,n;return v(t,e),Object.defineProperty(t.prototype,"parentIntensity",{get:function(){return this._parentIntensity},set:function(e){this._container&&(this._container.alpha=this.jsonIntensity*e),this._parentIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visible",{set:function(e){this._container.visible=e},enumerable:!1,configurable:!0}),t.prototype.getTexture=function(e,t){var i=e,n=o.P6.kN[i];if(n){var r=new o.jy(n),s=new o.jy(n.clone());r.anchor.set(.5),s.anchor.set(.5),this._leftIris=r,this._rightIris=s;var a=new o.W2;this._maskGraphics||(this._maskGraphics=new o.TC),a.addChild(this._maskGraphics),a.addChild(r),a.addChild(s),a.alpha=this.parentIntensity*this.jsonIntensity,a.mask=this._maskGraphics,this._container=a}},t.prototype.setIrisProps=function(e,t){if(!this._destroyed&&e.length)try{var i=this._config.getConfigByKeys(["POINTS_MAP","LEFT_IRIS","RIGHT_IRIS","LEFT_EYE_ORDER","RIGHT_EYE_ORDER"]),n=i.POINTS_MAP,r=(i.LEFT_IRIS,i.RIGHT_IRIS,i.LEFT_EYE_ORDER),s=i.RIGHT_EYE_ORDER,o=(n.left_eye_center,n.right_eye_center,void 0),a=void 0,c=void 0,u=void 0,p=void 0,l=void 0;if(e.length>=163){var f=e.slice(123,143),d=e.slice(143,163);a=o=this._getXRange(f),u=c=this._getXRange(d),p=e[123],l=e[143]}else{var y=(0,h.Sp)(e[52],e[55]),_=(0,h.Sp)(e[58],e[61]);a=o=y*this.maxLConSize,u=c=_*this.maxLConSize,p=(0,h.qg)(e[74],e[104]),l=(0,h.qg)(e[77],e[105])}var g=o,m=a,b=c,v=u,k=p,x=l,w=_e.baseTexture.width*this._options.height/_e.baseTexture.height;k.x-=(w-this._options.width)/2,x.x-=(w-this._options.width)/2;var M=this._leftIris,T=this._rightIris;M.width=g*(this._options.irisScale||1),M.height=m*(this._options.irisScale||1),M.x=k.x,M.y=k.y,T.width=b*(this._options.irisScale||1),T.height=v*(this._options.irisScale||1),T.x=x.x,T.y=x.y,this._maskGraphics.clear(),this._drawMaskGraphics(r,e),this._drawMaskGraphics(s,e),t.render(this._container,{renderTexture:this.renderTexture})}catch(e){}},t.prototype._drawMaskGraphics=function(e,t){var i=this._maskGraphics;i.beginFill(16724736),i.lineStyle(1,16767232,1);var n,r,s=t[e[0]];i.moveTo(s.x,s.y),s=t[e[1]],i.lineTo(s.x,s.y),n=t[e[2]],r=t[e[3]],i.quadraticCurveTo(n.x,n.y+(n.y-(0,h.qg)(s,r).y),r.x,r.y),s=t[e[4]],i.lineTo(s.x,s.y),s=t[e[5]],i.lineTo(s.x,s.y),n=t[e[6]],r=t[e[7]],i.quadraticCurveTo(n.x,n.y-((0,h.qg)(s,r).y-n.y),r.x,r.y),i.closePath(),i.endFill()},t.prototype._getPixelPosition=function(e,t){return{x:e,y:t}},t.prototype._getXRange=function(e){if(0===e.length)return 0;var t=e.reduce((function(e,t){return{min:Math.min(e.min,t.x),max:Math.max(e.max,t.x)}}),{min:e[0].x,max:e[0].x}),i=t.min;return t.max-i},t.prototype.resize=function(t,i){var n;e.prototype.resize.call(this,t,i),null===(n=this.renderTexture)||void 0===n||n.resize(t,i)},t.prototype.destroy=function(){w.info("irisLayer destroy"),this._destroyed=!0,this._leftIris&&this._leftIris.destroy({children:!0,texture:!1,baseTexture:!1}),this._rightIris&&this._rightIris.destroy({children:!0,texture:!1,baseTexture:!1}),this._maskGraphics&&this._maskGraphics.destroy({children:!0,texture:!1,baseTexture:!1})},k([(0,p.M)("IrisLayer"),x("design:type",Function),x("design:paramtypes",["function"==typeof(i="undefined"!=typeof Array&&Array)?i:Object,"function"==typeof(n=void 0!==o.Th&&o.Th)?n:Object]),x("design:returntype",void 0)],t.prototype,"setIrisProps",null),t}(M),C=i(3120),S=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},E=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},I=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},P=function(e,t){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},R=function(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],n=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},j=(0,_.jl)("makeup-mer"),O=function(){function e(e,t,i){e&&(this._options=e),t&&(this._lipVertex=t),i&&(this.renderer=i)}return e.prototype.destroy=function(){var e=this._lipMask;this._lipMask=null;try{e.destroy(!0)}catch(e){}try{this._lipMaskMesh.destroy(!0),this._lipMaskMesh=null}catch(e){}try{this._maskRenderTexture.destroy(!0),this._maskRenderTexture=null}catch(e){}this._config=null;try{this._maskSprite.destroy(!0),this._maskSprite=null}catch(e){}},e.prototype.load=function(){return I(this,void 0,void 0,(function(){var e,t,i,n;return P(this,(function(r){switch(r.label){case 0:return this._config?[3,2]:(this._config=new m.M,[4,this._config.load()]);case 1:r.sent(),r.label=2;case 2:return this._lipMask?[3,4]:[4,this._getMask()];case 3:r.sent(),r.label=4;case 4:return this._maskSprite&&!this._maskSprite.destroyed||(e=this._options,t=e.width,i=e.height,this._maskRenderTexture=o.TI.create({width:t,height:i}),n=new o.jy(this._maskRenderTexture),this._maskSprite=n),[2,{maskSprite:this._maskSprite,lipmask:this._lipMask,lipmaskmesh:this._lipMaskMesh}]}}))}))},e.prototype.update=function(e){if(this._lipMaskMesh){this._lipMaskMesh.geometry.getBuffer("aVertexPosition").update(e);var t=this._lipMaskMesh.getBounds();this._lipMaskMesh.mask.clear(),this._lipMaskMesh.mask.drawRect(t.x,t.y,t.width,t.height),this.render()}},e.prototype.render=function(){this.renderer&&this._lipMask&&this.renderer.render(this._lipMask,{renderTexture:this._maskRenderTexture})},e.prototype.resize=function(e,t){var i;j.info("ReuseableLipMask resize",e,t,this._maskSprite),null===(i=this._maskRenderTexture)||void 0===i||i.resize(e,t)},e.prototype._getMask=function(){return I(this,void 0,void 0,(function(){var e,t,i,n,r,s,a;return P(this,(function(c){switch(c.label){case 0:return this._lipMask?[2,this._lipMask]:(e=this._lipVertex,t=this._config.getDataConfig(29),[4,this._loadLipImage()]);case 1:return i=c.sent(),n=(new o.wG).addAttribute("aVertexPosition",e).addAttribute("aUvs",t),"\n precision mediump float;\n attribute vec2 aVertexPosition;\n attribute vec2 aUvs;\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n varying vec2 vUvs;\n\n\n void main() {\n vUvs = aUvs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n }","\n precision mediump float;\n varying vec2 vUvs;\n uniform sampler2D uSamplerMakeup;\n\n \n void main() {\n gl_FragColor = texture2D(uSamplerMakeup, vUvs);\n }",r={uSamplerMakeup:i},s=o.ex.from("\n precision mediump float;\n attribute vec2 aVertexPosition;\n attribute vec2 aUvs;\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n varying vec2 vUvs;\n\n\n void main() {\n vUvs = aUvs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n }","\n precision mediump float;\n varying vec2 vUvs;\n uniform sampler2D uSamplerMakeup;\n\n \n void main() {\n gl_FragColor = texture2D(uSamplerMakeup, vUvs);\n }",r),(a=new o.Kj(n,s)).mask=new o.TC,this._lipMaskMesh=a,this._lipMask=a,[2,a]}}))}))},e.prototype._loadLipImage=function(){return I(this,void 0,Promise,(function(){var e=this;return P(this,(function(t){return[2,new Promise((function(t,i){return I(e,void 0,void 0,(function(){var e,i,n;return P(this,(function(r){switch(r.label){case 0:return[4,(e=new C.KI).init()];case 1:return i=r.sent(),[4,e.loadImage(i)];case 2:return n=r.sent(),t(n[C.X_]),[2]}}))}))}))]}))}))},S([(0,p.M)("ReuseableLipMask"),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",void 0)],e.prototype,"destroy",null),S([(0,p.o)("ReuseableLipMask"),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Promise)],e.prototype,"_getMask",null),e}(),F=function(){function e(e,t,i,n,r,s,a){this._container=new o.W2,this._makeupMeshes=[],this._visible=!0,this.mouthShut=!0,this._applyed=!1,this._key=e,this._data=t,this._options=i,this.mesh=n,this.lipmesh=s,this.faceLandMarks=r,this.renderer=a;var c=new o.jy(o.xE.WHITE);c.alpha=0,c.width=i.width,c.height=i.height,this._container.addChild(c)}var t;return Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){var t=this;this._target&&e!==this._visible&&(this._visible=e,this._makeupMeshes.forEach((function(i){e?t.apply(t._target):t.remove()})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mesh",{set:function(e){(this._meshVertex=e,this.geometry)&&(this.geometry.getBuffer("aVertexPosition").update(e),this._makeupMeshes.forEach((function(t){t.updateGeometry(e)})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lipmesh",{set:function(e){this._lipVertex=e,this._lipMaskIns&&this._lipMaskIns.update(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceLandMarks",{set:function(e){var t=this;e&&e.length&&(this._irises&&this._irises.setIrisProps(e,this.renderer),(0,h.Sp)(e[98],e[102])<.03*(0,h.Sp)(e[0],e[32])?this.mouthShut||(this._makeupMeshes.forEach((function(e){"lips"===e.type&&(e.lipMask=null)})),this.mouthShut=!0):this.mouthShut&&(this._makeupMeshes.forEach((function(e){"lips"===e.type&&t._lipMaskIns&&(e.lipMask=t._lipMaskIns._maskSprite)})),this.mouthShut=!1))},enumerable:!1,configurable:!0}),e.prototype.renderMesh=function(){this._lipMaskIns&&this._lipMaskIns.render(),this._makeupMeshes.forEach((function(e){e.renderMesh()}))},e.prototype.load=function(){return I(this,void 0,void 0,(function(){var e,t,i,n,r,s,o,a;return P(this,(function(c){switch(c.label){case 0:return this._config=new m.M,[4,this._config.load()];case 1:if(c.sent(),e=this._data,j.info("makeup info",this._data),t=[],e&&e.length){try{for(i=R(e),n=i.next();!n.done;n=i.next())"iris"===(r=n.value).type?(j.info("generate iris layer",r),this._irises=this._getIris(this.getFilename(r.src,r.parentKey),r.blend,r.intensity,r.parentKey,r.parentIntensity),this.irisBlendMode=r.blend):(r.blend+"",t.push({src:this.getFilename(r.src,r.parentKey),intensity:r.intensity,type:r.type,blend:r.blend,parentIntensity:r.parentIntensity,parentKey:r.parentKey}))}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=i.return)&&a.call(i)}finally{if(o)throw o.error}}j.info("makeupLayersByBlendMode",t),s=this._getMeshLayerByBlendMode(t),this._makeupMeshes.push(s)}return[4,this._initLipMask()];case 2:return c.sent(),[2]}}))}))},e.prototype.getFilename=function(e,t){return"default"===t?e:"".concat(t,"|").concat(e)},e.prototype.setParentIntensity=function(e,t){j.info("setParentIntensity",e,t),this._makeupMeshes.forEach((function(i){i.setParentIntensityAt(e,t)})),this._irises&&this._irises.parentKey===e&&(this._irises.parentIntensity=t)},e.prototype._getIris=function(e,t,i,n,r){return new T(this._options,e,t,i,this._config,this._container,n,r)},e.prototype._getMeshLayerByBlendMode=function(e){var t=e.some((function(e){return"lips"===e.type}))?"lips":"makeup",i=new M(this._options,this._container,this.renderer,t);this._irises&&(i.irisRenderTexture=this._irises.renderTexture.baseTexture,i.irisBlendMode=this.irisBlendMode);var n=this._config.getDataConfig(26);if(!this.geometry){var r=(new o.wG).addAttribute("aVertexPosition",this._meshVertex).addAttribute("aUvs",n);this.geometry=r}return i.drawMeshBatch(e,this.geometry),i},e.prototype.resize=function(e,t){var i,n;this._makeupMeshes.forEach((function(i){i.resize(e,t)})),null===(i=this._irises)||void 0===i||i.resize(e,t),null===(n=this._lipMaskIns)||void 0===n||n.resize(e,t)},e.prototype.apply=function(e){this._target=e,this._applyMakeup(e)},e.prototype.remove=function(){this._removeMakeup(this._target)},e.prototype._applyMakeup=function(e){if(!this._applyed){if(!e)return j.info("_applyMakeup failed: container is null");this._applyed=!0,e.filters||(e.filters=[]);try{e.addChild(this._container)}catch(e){j.info("_applyMakeup error",e)}}},e.prototype._removeMakeup=function(e){if(this._applyed){if(!e)return j.info("_removeMakeup failed: container is null");this._applyed=!1,e.filters&&e.removeChild(this._container)}},e.prototype._initLipMask=function(){return I(this,void 0,void 0,(function(){var e,t,i=this;return P(this,(function(n){switch(n.label){case 0:return(e=new O(this._options,this._lipVertex,this.renderer))._options=this._options,e._lipVertex=this._lipVertex,e.renderer=this.renderer,this._lipMaskIns=e,[4,e.load()];case 1:return t=n.sent().maskSprite,this._makeupMeshes.forEach((function(e){"lips"!==e.type||i.mouthShut||(e.lipMask=t)})),[2]}}))}))},e.prototype.destroy=function(){j.info("makeup destroy"),this.remove(),this._makeupMeshes.forEach((function(e){return e.destroy()})),this._makeupMeshes=[],this._irises&&this._irises.destroy(),this._irises=null,this._container.destroy(),this._target=null,this._lipMaskIns&&this._lipMaskIns.destroy()},S([(0,p.M)("Makeup"),E("design:type",Function),E("design:paramtypes",["function"==typeof(t=void 0!==o.W2&&o.W2)?t:Object]),E("design:returntype",void 0)],e.prototype,"_removeMakeup",null),S([(0,p.M)("Makeup"),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",void 0)],e.prototype,"destroy",null),e}(),L=i(7959),V=function(){return V=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},V.apply(this,arguments)},A=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},U=function(e,t){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},N=(0,_.jl)("makeup-merge-hub"),D=function(){function e(){this._visible=!0,this._makeupConfigs={},this._applied=!1,this._mesh=[],this._faceLandMarks=[],this._lipmesh=[]}return Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){this._visible=e,this.currentMakeupInstance&&(this.currentMakeupInstance.visible=e)},enumerable:!1,configurable:!0}),e.prototype.addMakeupConfig=function(e,t,i){this._makeupConfigs[e]={config:t,visible:!0,parentIntensity:i}},e.prototype.setMakeupConfigVisible=function(e,t){this._makeupConfigs[e]&&(this._makeupConfigs[e].visible=t)},e.prototype.MakeupConfigExist=function(e){return void 0!==this._makeupConfigs[e]},e.prototype.setMakeupConfigParentIntensity=function(e,t){var i;this._makeupConfigs[e]&&(N.info("setMakeupConfigParentIntensity",e,t),this._makeupConfigs[e].parentIntensity=t,null===(i=this.currentMakeupInstance)||void 0===i||i.setParentIntensity(e,t))},e.prototype.removeMakeupConfig=function(e){delete this._makeupConfigs[e]},e.prototype.generateFinalConfig=function(){var e=this,t=[],i=function(i){n._makeupConfigs[i].visible&&n._makeupConfigs[i].config.forEach((function(n){var r=V(V({},n),{parentIntensity:e._makeupConfigs[i].parentIntensity,parentKey:i});t.push(r)}))},n=this;for(var r in this._makeupConfigs)i(r);return t},e.prototype.generateMakeup=function(e,t,i,n){return A(this,void 0,void 0,(function(){var r,s;return U(this,(function(o){switch(o.label){case 0:return r=this.generateFinalConfig(),N.info("generateMakeup",r),L.s.checkEnabled("beautify")?r.length?[4,(s=new F("merged-".concat((new Date).getTime()),r,b.t.instance.options,e,t,i,n)).load()]:[2,null]:[2,null];case 1:return o.sent(),[2,s]}}))}))},e.prototype.updateMakeupFilter=function(e,t,i,n){return A(this,void 0,void 0,(function(){var r;return U(this,(function(s){switch(s.label){case 0:return console.log("updateMakeupFilter called"),L.s.checkEnabled("beautify")?[4,this.generateMakeup(e,t,i,n)]:[2];case 1:return(r=s.sent())?(this.mesh=e,this.faceLandMarks=t,this.lipmesh=i,[4,r.load()]):(this.currentMakeupInstance&&this.currentMakeupInstance.destroy(),this._applied=!1,[2]);case 2:return s.sent(),this.currentMakeupInstance&&this.currentMakeupInstance.destroy(),r&&(this.currentMakeupInstance=r),this._applied&&this.currentMakeupInstance.apply(this._target),[2]}}))}))},e.prototype.updateMakeupConfigShortcut=function(e){return A(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,this.updateMakeupFilter(this.mesh,this.faceLandMarks,this.lipmesh,e)];case 1:return[2,t.sent()]}}))}))},e.prototype.resize=function(e,t){N.info("resize",e,t),this.currentMakeupInstance&&this.currentMakeupInstance.resize(e,t)},e.prototype.renderMesh=function(){this.currentMakeupInstance&&this.currentMakeupInstance.renderMesh()},e.prototype.applyIfNot=function(e){this._applied||this.currentMakeupInstance&&(this.currentMakeupInstance.apply(e),this._target=e,this._applied=!0)},Object.defineProperty(e.prototype,"mesh",{get:function(){return this._mesh},set:function(e){this.currentMakeupInstance&&(this.currentMakeupInstance.mesh=e),this._mesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lipmesh",{get:function(){return this._lipmesh},set:function(e){this.currentMakeupInstance&&(this.currentMakeupInstance.lipmesh=e),this._lipmesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceLandMarks",{get:function(){return this._faceLandMarks},set:function(e){this.currentMakeupInstance&&(this.currentMakeupInstance.faceLandMarks=e),this._faceLandMarks=e},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.currentMakeupInstance&&this.currentMakeupInstance.destroy(),this._applied=!1,this._makeupConfigs={}},e.instance=new e,e}();const B=function(){function e(){if(e.instance)throw new Error("TextureRefManager 已存在实例,请使用 getInstance() 获取");this.refCounts=new Map}return e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.addRef=function(e){var t=this.refCounts.get(e)||0;this.refCounts.set(e,t+1)},e.prototype.removeRef=function(e){var t=this.refCounts.get(e)||0;return t<=1?(this.refCounts.delete(e),!0):(this.refCounts.set(e,t-1),!1)},e.prototype.getRefCount=function(e){return this.refCounts.get(e)||0},e.prototype.clear=function(){this.refCounts.clear()},e}();var z=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),G=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},H=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},J=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},X=function(e,t){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},W=function(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],n=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},K=(0,_.jl)("Effect"),q=function(){function e(e,t,i,n,r,s,o,a,c,u,h){this.type="face",this._filters=[],this._destroyed=!1,this._visible=!0,this._intensity=1,this._filterIntensity=1,this.localSpriteSheets={},this._filtersActived=!0,this.makeupConfig=[],K.info("effect constructor",this._key,t),this._target=t,this._stickerTarget=i,this._url=e,this._key=e,this._options=r,this.mesh=s,this.lipmesh=a,this.faceLandMarks=o,c&&(this.angles=c),void 0!==u&&(this.intensity=u),this._app3d=n,this._canvas=h}var t;return Object.defineProperty(e.prototype,"isPureFilter",{get:function(){var e=this._config;return!!e&&((!e.makeup||!e.makeup.length)&&((!e.sticker||!e.sticker.length)&&((!e.sticker3d||!e.sticker3d.length)&&(!e.beautify||!Object.keys(e.beautify).find((function(t){return!!e.beautify[t]}))))))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"filterActived",{get:function(){return this._filtersActived},set:function(e){e!==this._filtersActived&&(this._filterTarget&&(e?this._applyFilter(this._filterTarget):this._removeFilter(this._filterTarget)),this._filtersActived=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"app3d",{get:function(){return this._app3d},set:function(e){this._app3d=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"intensity",{get:function(){return this._intensity},set:function(e){e>1&&(e=1),null!=e&&(D.instance.setMakeupConfigParentIntensity(this._key,e),this._sticker&&(this._sticker.parentIntensity=e),this._intensity=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"filterIntensity",{get:function(){return this._filterIntensity},set:function(e){null!=e&&(this._filters&&this._filters.forEach((function(t){t.uniforms.parentIntensity=e})),this._filterIntensity=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){this._destroyed||(this._visible=e,D.instance.visible=e,this._sticker&&(this._sticker.visible=e),this._app3d&&(this._app3d.visible=e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mesh",{set:function(e){this._destroyed||(this._meshVertex=e,D.instance.mesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lipmesh",{set:function(e){this._destroyed||(this._lipVertex=e,D.instance.lipmesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"faceLandMarks",{get:function(){return this._faceLandMarks},set:function(e){this._destroyed||(this._faceLandMarks=e,D.instance.faceLandMarks=e,this._sticker&&(this._sticker.faceLandMarks=e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"angles",{set:function(e){this._angles=e,this._sticker&&(this._sticker.angles=e)},enumerable:!1,configurable:!0}),e.prototype.download=function(){return J(this,void 0,Promise,(function(){var e;return X(this,(function(t){switch(t.label){case 0:return[4,this._getLoader()];case 1:return[4,t.sent().preload(this._url)];case 2:return t.sent(),[4,this._getConfig()];case 3:return e=t.sent(),_.D4.info("download:",this._url,e),[2,e]}}))}))},e.prototype.load=function(e){return J(this,void 0,Promise,(function(){var t,i,n,r,s,o;return X(this,(function(a){switch(a.label){case 0:return[4,this.download()];case 1:return t=a.sent(),i=t.filter,n=t.makeup,r=t.beautify,s=t.sticker,o=t.sticker3d,e&&e(!!(null==o?void 0:o.length)),[4,this._loadImages(t)];case 2:return a.sent(),this.loadFilter(i),[4,this.setMakeup(n)];case 3:return a.sent(),s?[4,this.loadStickers(s)]:[3,5];case 4:a.sent(),a.label=5;case 5:return[4,this.load3d(o)];case 6:return a.sent(),this.sticker3d=o,[4,this._getLoader()];case 7:return a.sent().removeFromCache(this._url),[2,r]}}))}))},e.prototype._getLoader=function(){return J(this,void 0,void 0,(function(){return X(this,(function(e){switch(e.label){case 0:return this._loader?[3,2]:(this._loader=new r.pF,[4,this._loader.init()]);case 1:e.sent(),e.label=2;case 2:return[2,this._loader]}}))}))},e.prototype._getConfig=function(){return J(this,void 0,void 0,(function(){var e;return X(this,(function(t){switch(t.label){case 0:return this._config?[3,3]:[4,this._getLoader()];case 1:return[4,(e=t.sent()).preload(this._url)];case 2:t.sent(),this._config=e.readJSON("content.json",this._key),t.label=3;case 3:return[2,this._config]}}))}))},e.prototype.hasEyeMakeup=function(){return J(this,void 0,Promise,(function(){var e,t,i,n,r,s,o,a;return X(this,(function(c){switch(c.label){case 0:return[4,this._getConfig()];case 1:e=c.sent(),t=e.makeup,i=!1;try{for(n=W(t),r=n.next();!r.done;r=n.next())if("iris"===(s=r.value).type||"eyes"===s.type){i=!0;break}}catch(e){o={error:e}}finally{try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(o)throw o.error}}return[2,i]}}))}))},e.prototype.needDetection=function(){return J(this,void 0,Promise,(function(){var e,t,i,n;return X(this,(function(r){switch(r.label){case 0:return[4,this._getConfig()];case 1:return e=r.sent(),t=e.makeup,i=e.sticker,n=e.sticker3d,[2,t&&t.length||i&&i.length||n&&n.length]}}))}))},e.prototype.hasFilter=function(){return J(this,void 0,Promise,(function(){var e,t;return X(this,(function(i){switch(i.label){case 0:return[4,this._getConfig()];case 1:return e=i.sent(),[2,!(!(t=e.filter)||!t.length)]}}))}))},e.prototype.loadStickers=function(e){return J(this,void 0,Promise,(function(){var t;return X(this,(function(i){return e.length?((t=new y(this._key,e,this._stickerTarget,this.faceLandMarks,this._options,this._angles)).parentIntensity=this.intensity,this._sticker=t,[2]):[2,Promise.resolve()]}))}))},e.prototype.loadSticker3d=function(e){return void 0===e&&(e=[]),J(this,void 0,Promise,(function(){return X(this,(function(e){return[2]}))}))},e.prototype.load3d=function(e){return J(this,void 0,void 0,(function(){return X(this,(function(e){return[2]}))}))},e.prototype.initThreeApp=function(){return J(this,void 0,void 0,(function(){return X(this,(function(e){return[2]}))}))},e.prototype.apply3d=function(){},e.prototype.removeForConsole=function(){},e.prototype.destroyForConosle=function(){},e.prototype.setMakeup=function(e){if(!(null==e?void 0:e.length))return Promise.resolve();D.instance.addMakeupConfig(this._key,e,this.intensity),this.makeupConfig=e},e.prototype.resize=function(e,t){D.instance.resize(e,t)},e.prototype.apply=function(e){var t=this;this._destroyed||this._applyed||(this.filterActived&&this._applyFilter(e.filterTarget),this._filters.length&&e.filterCallback&&e.filterCallback(),this._filterTarget=e.filterTarget,D.instance.MakeupConfigExist(this._key)||D.instance.addMakeupConfig(this._key,this.makeupConfig,this.intensity),D.instance.setMakeupConfigVisible(this._key,!0),D.instance.updateMakeupFilter(this._meshVertex,this.faceLandMarks,this._lipVertex,this.renderer).then((function(){K.info("merged makeup updated,start apply"),D.instance.applyIfNot(t._target)})),this._sticker&&this._sticker.apply(),this.apply3d(),this._applyed=!0)},e.prototype.getUrl=function(){return this._url},e.prototype.remove=function(e){void 0===e&&(e=!1),D.instance.removeMakeupConfig(this._key),e||D.instance.updateMakeupConfigShortcut(this.renderer),this._sticker&&this._sticker.remove(),this.removeForConsole(),this._removeFilter(this._filterTarget),this._applyed=!1},e.prototype.tick=function(){this._sticker&&this._sticker.tick()},e.prototype.tickMesh=function(){D.instance.renderMesh()},e.prototype.destroy=function(e){void 0===e&&(e=!1),this._destroyed=!0,this.remove(e),this._sticker&&(this._sticker.destroy(),this._sticker=null),this.destroyForConosle(),this._filters=[],this.clearTexture()},e.prototype.loadFilter=function(e){var t=this;this._destroyed||e&&e.length&&e.forEach((function(e){var i=t._createFilterSync(e.src,e.intensity,t.filterIntensity);t._filters.push(i)}))},e.prototype._applyFilter=function(e){e.filters||(e.filters=[]),e.filters=this._filters.concat(e.filters)},e.prototype._removeFilter=function(e){e&&e.filters&&e.filters.length&&this._filters.forEach((function(t){var i=e.filters.findIndex((function(e){return e===t}));i>-1&&e.filters.splice(i,1)}))},e.prototype._createFilterSync=function(e,t,i){var n="default"===this._key?e:"".concat(this._key,"|").concat(e),r=o.P6.kN[n];return r.baseTexture.scaleMode=o.aH.LINEAR,r.baseTexture.mipmap=o.KI.OFF,new s.f("lut",this._options,{uniforms:{lut:r,intensity:t,parentIntensity:i}})},e.prototype.clearTexture=function(){var e=B.getInstance();for(var t in o.P6.kN)if(t.indexOf(this._key)>-1){var i=o.P6.kN[t];e.removeRef(t)&&(o.xE.removeFromCache(i),i.destroy(!0),r.iV[t]&&r.iV[t]instanceof o.c2&&(r.iV[t].destroy(),delete r.iV[t]))}},e.prototype._loadImages=function(e){var t,i,n=this,s=(e.filter||[]).concat(e.makeup||[]).concat(e.sticker||[]),a=this._loader.getIndeLoader(),c={};this.localSpriteSheets=c;try{for(var u=W(s),h=u.next();!h.done;h=u.next()){var p=h.value;if(p.src instanceof Array)p.src.forEach((function(e,t){var i=n.checkSpriteSheetJSON(e);if(i){var r=i.meta.image,s="".concat(n._key,"|").concat(r);if(B.getInstance().addRef(s),o.P6.kN[s])return;if(0===r.indexOf("blob:")){var u=o.xE.from(r);o.xE.addToCache(u,s)}else a.add(s,r);i.meta.image="",c[s]=i}else{if(B.getInstance().addRef(e),o.P6.kN[e])return;if(a.resources[e])return;a.add(e,e)}}));else{var l="".concat(this._key,"|").concat(p.src);if(B.getInstance().addRef(l),o.P6.kN[l])continue;if(0===p.src.indexOf("blob:")){var f=o.xE.from(p.src);o.xE.addToCache(f,l)}else a.add(l,p.src)}}}catch(e){t={error:e}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(t)throw t.error}}return new Promise((function(e){a.load((function(t,i){return J(n,void 0,void 0,(function(){var t,n,s,a,u;return X(this,(function(h){switch(h.label){case 0:for(s in t=function(e){var t;return X(this,(function(i){switch(i.label){case 0:return r.iV[e]?[2,"continue"]:c[e]?(t=new o.c2(o.P6.kN[e],c[e],"@".concat((0,g.u)(),"x")),[4,new Promise((function(i){t.parse((function(){r.iV[e]=t,i()}))}))]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))},n=[],o.P6.kN)n.push(s);a=0,h.label=1;case 1:return a<n.length?(u=n[a],[5,t(u)]):[3,4];case 2:h.sent(),h.label=3;case 3:return a++,[3,1];case 4:for(u in i)r.iV[u]||c[u]||(r.iV[u]=i[u]);return e(),[2]}}))}))}))}))},e.prototype.checkSpriteSheetJSON=function(e){try{return JSON.parse(e)}catch(e){return null}},G([(0,p.M)("Effect"),H("design:type",Function),H("design:paramtypes",[Boolean]),H("design:returntype",void 0)],e.prototype,"remove",null),G([(0,p.M)("Effect"),H("design:type",Function),H("design:paramtypes",[Boolean]),H("design:returntype",void 0)],e.prototype,"destroy",null),G([(0,p.M)("Effect"),H("design:type",Function),H("design:paramtypes",["function"==typeof(t=void 0!==o.W2&&o.W2)?t:Object]),H("design:returntype",void 0)],e.prototype,"_removeFilter",null),e}(),Y=function(e){function t(t,i,n,r,s,o,a,c){var u=e.call(this,"default",i,n,r,s,o,a,c)||this;return u._json=t,u._app3d=r,u}return z(t,e),t.prototype.load=function(e){return J(this,void 0,Promise,(function(){var t,i,n,r,s,o;return X(this,(function(a){switch(a.label){case 0:return t=this._json,i=t.filter,n=t.makeup,r=t.beautify,s=t.sticker,o=t.sticker3d,e&&e(!!(null==o?void 0:o.length)),[4,this._loadImages(t)];case 1:return a.sent(),this.loadFilter(i),[4,this.setMakeup(n)];case 2:return a.sent(),s?[4,this.loadStickers(s)]:[3,4];case 3:a.sent(),a.label=4;case 4:return o?this._app3d?[3,6]:[4,this.initThreeApp()]:[3,8];case 5:a.sent(),a.label=6;case 6:return[4,this.loadSticker3d(o||[])];case 7:a.sent(),a.label=8;case 8:return[2,r]}}))}))},t.prototype.loadImage=function(){return J(this,void 0,void 0,(function(){return X(this,(function(e){return[2]}))}))},t.prototype._loadImages=function(e){var t,i,n=this,s=new o.aN,a=(e.filter||[]).concat(e.makeup||[]).concat(e.sticker||[]),c={},u=function(e){if(e.src instanceof Array)e.src.forEach((function(t,i){var r=n.checkSpriteSheetJSON(t);if(r){var a=r.meta.image,u="".concat(n._key,"|").concat(a);if(o.P6.kN[u])return void B.getInstance().addRef(u);if(e.objectSrc&&e.objectSrc.length){var h=o.xE.from(e.objectSrc[i]);o.xE.addToCache(h,u),B.getInstance().addRef(u)}else if(0===a.indexOf("blob:")){h=o.xE.from(a);o.xE.addToCache(h,u)}else s.add(u,a);r.meta.image="",c[u]=r}else{if(o.P6.kN[t])return;if(s.resources[t])return;if(e.objectSrc&&e.objectSrc.length){h=o.xE.from(e.objectSrc[i],{resolution:(0,g.u)()});o.xE.addToCache(h,t)}else s.add(t,t)}}));else{if(B.getInstance().addRef(e.src),o.P6.kN[e.src])return"continue";if(s.resources[e.src])return K.info("already loaded file",e.src),"continue";if(e.objectSrc){K.info("use imagebitmap to create texture");var t=o.xE.from(e.objectSrc);o.xE.addToCache(t,e.src),B.getInstance().addRef(e.src)}else if(0===e.src.indexOf("blob:")){t=o.xE.from(e.src);K.info("JSONEffect blob texture",t),o.xE.addToCache(t,e.src),B.getInstance().addRef(e.src)}else s.add(e.src)}};try{for(var h=W(a),p=h.next();!p.done;p=h.next()){u(p.value)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(t)throw t.error}}return new Promise((function(e){return J(n,void 0,void 0,(function(){var t=this;return X(this,(function(i){return s.load((function(i,n){return J(t,void 0,void 0,(function(){var t,i,s,a,u;return X(this,(function(h){switch(h.label){case 0:for(s in t=function(e){var t;return X(this,(function(i){switch(i.label){case 0:return r.iV[e]?[2,"continue"]:c[e]?(t=new o.c2(o.P6.kN[e],c[e],"@".concat((0,g.u)(),"x")),[4,new Promise((function(i){t.parse((function(){r.iV[e]=t,i()}))}))]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))},i=[],o.P6.kN)i.push(s);a=0,h.label=1;case 1:return a<i.length?(u=i[a],[5,t(u)]):[3,4];case 2:h.sent(),h.label=3;case 3:return a++,[3,1];case 4:for(u in n)r.iV[u]||c[u]||(r.iV[u]=n[u]);return e(),[2]}}))}))})),[2]}))}))}))},t.prototype.loadSticker3d=function(e){return J(this,void 0,Promise,(function(){return X(this,(function(e){return[2]}))}))},t}(q),Z=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),$=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},Q=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ee=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},te=function(e,t){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},ie=((0,_.jl)("Effect"),function(){function e(e,t,i,n){this.type="hand",this._destroyed=!1,this._visible=!0,this._intensity=1,this.localSpriteSheets={},this._url=e,this._key=e,this._app3d=t,this._canvas=n,this._options=i}return Object.defineProperty(e.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"app3d",{get:function(){return this._app3d},set:function(e){this._app3d=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"intensity",{get:function(){return this._intensity},set:function(e){this._intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){this._destroyed||(this._visible=e)},enumerable:!1,configurable:!0}),e.prototype.download=function(){return ee(this,void 0,Promise,(function(){var e;return te(this,(function(t){switch(t.label){case 0:return[4,this._getLoader()];case 1:return[4,t.sent().preload(this._url)];case 2:return t.sent(),[4,this._getConfig()];case 3:return e=t.sent(),_.D4.info("download:",this._url,e),[2,e]}}))}))},e.prototype.load=function(){return ee(this,void 0,Promise,(function(){var e,t;return te(this,(function(i){switch(i.label){case 0:return[4,this.download()];case 1:return e=i.sent(),t=e.hand,[4,this.load3d(t||[])];case 2:return i.sent(),[4,this._getLoader()];case 3:return i.sent().removeFromCache(this._url),[2,null]}}))}))},e.prototype._getLoader=function(){return ee(this,void 0,void 0,(function(){return te(this,(function(e){switch(e.label){case 0:return this._loader?[3,2]:(this._loader=new r.pF,[4,this._loader.init()]);case 1:e.sent(),e.label=2;case 2:return[2,this._loader]}}))}))},e.prototype._getConfig=function(){return ee(this,void 0,void 0,(function(){var e;return te(this,(function(t){switch(t.label){case 0:return this._config?[3,3]:[4,this._getLoader()];case 1:return[4,(e=t.sent()).preload(this._url)];case 2:t.sent(),this._config=e.readJSON("content.json",this._key),t.label=3;case 3:return[2,this._config]}}))}))},e.prototype.load3d=function(e){return ee(this,void 0,void 0,(function(){return te(this,(function(e){return[2]}))}))},e.prototype.initThreeApp=function(){return ee(this,void 0,void 0,(function(){return te(this,(function(e){return[2]}))}))},e.prototype.apply3d=function(){},e.prototype.removeForConsole=function(){},e.prototype.destroyForConosle=function(){},e.prototype.apply=function(){this._destroyed||this._applyed||(this.apply3d(),this._applyed=!0)},e.prototype.getUrl=function(){return this._url},e.prototype.remove=function(){this.removeForConsole(),this._applyed=!1},e.prototype.tick=function(){},e.prototype.tickMesh=function(){},e.prototype.destroy=function(){this._destroyed=!0,this.remove(),this.destroyForConosle(),this.clearTexture()},e.prototype.clearTexture=function(){var e=B.getInstance();for(var t in o.P6.kN)if(t.indexOf(this._key)>-1){var i=o.P6.kN[t];e.removeRef(t)&&(o.xE.removeFromCache(i),i.destroy(!0),r.iV[t]&&r.iV[t]instanceof o.c2&&(r.iV[t].destroy(),delete r.iV[t]))}},e.prototype.checkSpriteSheetJSON=function(e){try{return JSON.parse(e)}catch(e){return null}},$([(0,p.M)("Effect"),Q("design:type",Function),Q("design:paramtypes",[]),Q("design:returntype",void 0)],e.prototype,"remove",null),$([(0,p.M)("Effect"),Q("design:type",Function),Q("design:paramtypes",[]),Q("design:returntype",void 0)],e.prototype,"destroy",null),e}()),ne=function(e){function t(t,i,n,r){var s=e.call(this,"default",i,n,r)||this;return s._json=t,s._app3d=i,s}return Z(t,e),t.prototype.load=function(){return ee(this,void 0,Promise,(function(){var e,t;return te(this,(function(i){switch(i.label){case 0:return e=this._json,(t=e.hand)?this._app3d?[3,2]:[4,this.initThreeApp()]:[3,4];case 1:i.sent(),i.label=2;case 2:return[4,this.loadHand3d(t||[])];case 3:i.sent(),i.label=4;case 4:return[2,null]}}))}))},t.prototype.loadImage=function(){return ee(this,void 0,void 0,(function(){return te(this,(function(e){return[2]}))}))},t.prototype.loadSticker3d=function(e){return ee(this,void 0,Promise,(function(){return te(this,(function(e){return[2]}))}))},t.prototype.loadHand3d=function(e){return ee(this,void 0,Promise,(function(){return te(this,(function(e){return[2]}))}))},t}(ie),re=i(5156),se=i(6309),oe=i(5562),ae=(0,_.jl)("videoFrameTextureManager"),ce=function(){function e(e){this.id=(new Date).getTime().toString(),this.pixiTexture=null,this.glTexture=null,this._width=0,this._height=0,console.log("VideoFrameTextureManager constructor"),this.renderer=e}return e.prototype.check=function(){var e=this.renderer.gl.isTexture(this.glTexture);return ae.info("check",e),e},e.prototype.update=function(e,t){void 0===t&&(t=!1);var i=this.renderer.gl,n=e.displayWidth,r=e.displayHeight;if(!this.pixiTexture||this._width!==n||this._height!==r||t){ae.info("VideoFrameTextureManager update",this._width,this._height,n,r),this.destroy(),this._width=n,this._height=r,this.glTexture=i.createTexture(),i.bindTexture(i.TEXTURE_2D,this.glTexture),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this._width,this._height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);var s=new o.VL(null,{width:this._width,height:this._height,format:i.RGBA,type:i.UNSIGNED_BYTE}),a=this.renderer,c=a.CONTEXT_UID||0;s._glTextures[c]||(s._glTextures[c]=a.texture.initTexture(s));var u=s._glTextures[c];this.glTexture&&(u.texture=this.glTexture),this.pixiTexture=new o.xE(s),o.P6.kN["videoframe-".concat(this.id)]=this.pixiTexture,o.P6.V8["videoframe-".concat(this.id)]=this.pixiTexture.baseTexture}if(this.glTexture){try{i.bindTexture(i.TEXTURE_2D,this.glTexture)}catch(e){ae.error("gl.bindTexture error",e)}e.width=e.displayWidth,e.height=e.displayHeight,i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e),this.pixiTexture&&this.pixiTexture.baseTexture.update()}else if(console.error("WebGLTexture 未初始化!"),!this.pixiTexture)return o.xE.EMPTY;return this.pixiTexture},e.prototype.destroy=function(){ae.info("videoFrameTextureManager destroy"),this.pixiTexture&&(this.pixiTexture.destroy(!0),this.pixiTexture=null),delete o.P6.kN["videoframe-".concat(this.id)],delete o.P6.V8["videoframe-".concat(this.id)],this._width=0,this._height=0},e.prototype.getTexture=function(){return this.pixiTexture},e}(),ue=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),he=function(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},pe=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},le=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},fe=function(e,t){var i,n,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},de=function(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],n=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ye=(0,_.jl)("Renderer"),_e=function(){};var ge=function(e){function t(t){var i=e.call(this,t)||this;return i._setup=!1,i._effects=[],i._debug=!0,i._destroyed=!1,i._isVR=!1,i._meshVertexTimer=0,i.lastCheckTime=0,i.need3dRefresh=!1,i.lib3dLoaded=!1,i.libHand3dLoaded=!1,ye.info("[@#$] AR Renderer Constructed",t),i._debug=!1,t.output?i._canvas=new wx.window.Canvas(t.output):i._canvas=new wx.window.Canvas(wx.createOffscreenCanvas({type:"webgl",width:t.width,height:t.height})),i._options=t,o.Xd.RESOLUTION=(0,g.u)(),o.Xd.FILTER_RESOLUTION=(0,g.u)(),i._renderer=new o.Th({view:i._canvas,width:t.width,height:t.height,useContextAlpha:!1,preserveDrawingBuffer:!1,antialias:!1,autoDensity:!0}),i.setRenderer(),i.initRenderContext(t),i.handleLoading(),i.setup(),i}return ue(t,e),Object.defineProperty(t.prototype,"mirror",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"backGroundVR",{set:function(e){if(e){this._backgroundVR=new o.jy(o.xE.from(e));var t=this._backgroundVR,i=t.width,n=t.height,r=Math.max(this._options.width/i,this._options.height/n);this._backgroundVR.width*=r,this._backgroundVR.height*=r}else this._backgroundVR=null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{set:function(e){var t=e.width,i=e.height;this._canvas.width=t,this._canvas.height=i,this._renderer&&this.resize(t,i),this._baseSprite&&(this._baseSprite.width=t,this._baseSprite.height=i,this._baseSprite.position.set(t/2,i/2),this._baseSprite.anchor.set(.5,.5)),this._makeupRenderTexture.resize(t,i),this._options=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"app3d",{get:function(){return this._app3d},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"avatar3d",{get:function(){return this._avatar3d},enumerable:!1,configurable:!0}),t.prototype.initRenderContext=function(e){this._makeupContainer=new o.W2,this._frontContainer=new o.W2,this._frontContainer.sortableChildren=!0,this._finalContainer=new o.W2,this._makeupRenderTexture=o.TI.create({width:e.width,height:e.height}),this._finalContainer.addChild(this._makeupContainer),this._finalContainer.addChild(this._frontContainer),this._target=this._finalContainer},t.prototype.loadLib3d=function(){return le(this,void 0,Promise,(function(){var e;return fe(this,(function(t){switch(t.label){case 0:return e=new se.e({}),ye.info("loader init"),[4,e.init()];case 1:return t.sent(),ye.info("loader init done"),this._options.plugin3d&&this._options.plugin3d(q,Y,e,wx.window),[2]}}))}))},t.prototype.loadHand3d=function(){return le(this,void 0,Promise,(function(){var e;return fe(this,(function(t){switch(t.label){case 0:return e=new se.e({}),ye.info("+++++loader init"),[4,e.init()];case 1:return t.sent(),ye.info("+++++loader init done"),this._options.plugin3d&&this._options.pluginHand(ie,ne,e,wx.window),[2]}}))}))},t.prototype.setup=function(){return le(this,void 0,void 0,(function(){return fe(this,(function(e){switch(e.label){case 0:return this._setup?[2]:(this._config=new m.M,[4,this._config.load()]);case 1:return e.sent(),this._setup=!0,[2]}}))}))},Object.defineProperty(t.prototype,"meshVertex",{get:function(){return this._meshVertex},set:function(e){this._meshVertex=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mirrorFilter",{get:function(){return this._mirrorFilter||(this._mirrorFilter=new s.f("mirror",{width:b.t.instance.options.width,height:b.t.instance.options.height})),this._mirrorFilter},enumerable:!1,configurable:!0}),t.prototype.switchMode=function(e){_.bH.info("switchMode",e),e!==this._mode3d&&("Sticker"===e&&this.setAvatar(null),this._mode3d=e)},t.prototype.logTime=function(e){var t=+new Date;ye.info("".concat(e," time:").concat(t-this.currentTime)),this.currentTime=t},t.prototype.tick=function(t,i){var n=t.landmarks,r=t.meshVertex,s=t.lipVertex,a=t.image,c=t.angles,u=(t.backgroundType,t.background,t.segmentation,t.blendshapes,t.isLivePusher);t.hair;if(!this._destroyed)if(this._renderer)if(this._setup){this.currentTime=+new Date;try{(this.need3dRefresh&&L.s.checkEnabled("beautify")&&"Sticker"===this._mode3d||L.s.checkEnabled("beautify")&&"AR"===this._mode3d||L.s.checkEnabled("handLandmark"))&&this._renderer.reset()}catch(e){}if(this._isVR)try{this._renderer.render(this._backgroundVR)}catch(e){}else{if(u)if(this._baseSprite)this._baseSprite.texture.update();else{d=o.xE.from(a);this._baseSprite=new o.jy(d),this._baseSprite.anchor.set(.5,.5),this._baseSprite.position.set(this._options.width/2,this._options.height/2),this._baseSprite.scale.set(1,-1),this._makeupContainer.addChild(this._baseSprite)}else{var h=a,p=h.width,l=h.height,f=h.data;if(this._baseSprite){if(this._baseSprite.texture.width===p&&this._baseSprite.texture.height===l)this._baseSprite.texture.baseTexture.resource.data=new Uint8Array(f),this._baseSprite.texture.update();else this._baseSprite.texture.destroy(!0),this._baseSprite.texture=o.xE.fromBuffer(new Uint8Array(f),p,l)}else{var d=o.xE.fromBuffer(new Uint8Array(f),p,l);this._baseSprite=new o.jy(d),this._baseSprite.anchor.set(.5,.5),this._baseSprite.position.set(this._options.width/2,this._options.height/2);var y=Math.max(this._options.width/p,this._options.height/l);this._baseSprite.scale.set(y*(0,g.u)()),this._makeupContainer.addChild(this._baseSprite)}}(L.s.checkEnabled("beautify")||L.s.checkEnabled("segmentation")||L.s.checkEnabled("hair"))&&(e.prototype.setMesh.call(this,r),e.prototype.setReshapeMarks.call(this,n),n&&n.length?(this._faceLandmarks=n,this._angles=c,this.meshVertex=r,this.lipVertex=s,this.detected=!0,this._effects.forEach((function(e){e.visible||(e.visible=!0),e.lipmesh=s,e.mesh=r,e.angles=c,e.faceLandMarks=n,e.tick()})),"Sticker"===this._mode3d&&this._app3d&&this._app3d.loaded&&(this._app3d.facelandmarks=n,this._app3d.angles=c)):(this.handleNoFace(),this.detected=!1)),this._render()}}else _.b_.info("_renderer waiting for setup");else _.b_.info("_renderer waiting for renderer")},t.prototype.getBackgroungInstance=function(e,t,i,n){var r;return"image"===e?r=new ImageBackground(this._options,t,i):"video"===e?r=new VideoBackground(this._options,t,i):"blur"===e?r=new BlurBackground(this._options,i,n,this._videoFrameTextureManager,this._renderer):"green"===e&&(r=new ColorBackground(this._options,i)),r},t.prototype.handleNoFace=function(){this._effects.forEach((function(e){return e.visible=!1})),this._effects.forEach((function(e){e.tickMesh()}));new Date;"AR"===this._mode3d||"Sticker"===this._mode3d&&this._app3d&&this._app3d.loaded&&(this._app3d.facelandmarks=[],this._app3d.angles={})},t.prototype._render=function(){this.renderLayers(),L.s.checkEnabled("beautify")&&"Sticker"===this._mode3d&&this._app3d&&this._app3d.loaded&&this._app3d.render(),L.s.checkEnabled("handLandmark")&&this._appHand3d&&this._appHand3d.render()},t.prototype.renderLayers=function(){e.prototype.renderDermabrasion.call(this),this._renderer.render(this._finalContainer)},t.prototype.preUploadBaseTexture=function(e,t){var i=this;if(this._baseSprite)if("undefined"!=typeof VideoFrame&&e instanceof VideoFrame){var n=this._videoFrameTextureManager.update(e),r=this._baseSprite.texture;this._baseSprite.texture=n,this._baseSprite.texture.update(),r!==this._baseSprite.texture&&(_e.baseTexture=this._baseSprite.texture,D.instance.updateMakeupConfigShortcut(this._renderer))}else if(e instanceof ImageData){var s=this._baseSprite.texture.baseTexture.resource;s.width!==e.width||s.height!==e.height?(this._baseSprite.texture=o.xE.fromBuffer(e.data,e.width,e.height),_e.baseTexture=this._baseSprite.texture,D.instance.updateMakeupConfigShortcut(this._renderer)):this._baseSprite.texture.baseTexture.resource.data=e.data}else{var a=this._baseSprite.texture.baseTexture.resource,c=a.source;if(c.width!==e.width||c.height!==e.height){r=this._baseSprite.texture;this._baseSprite.texture=o.xE.from(e),r!==this._baseSprite.texture&&(_e.baseTexture=this._baseSprite.texture,D.instance.updateMakeupConfigShortcut(this._renderer))}else a.source!==e&&(a.source=e)}else{var u=void 0;"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(this._videoFrameTextureManager||(this._videoFrameTextureManager=new ce(this._renderer)),u=this._videoFrameTextureManager.update(e)):u=e instanceof ImageData?o.xE.fromBuffer(e.data,e.width,e.height):o.xE.from(e),this._baseSprite=new o.jy(u),this._baseSprite.width=this._options.width,this._baseSprite.height=this._options.height,this._baseSprite.filters=b.t.instance.options.mirror?[this.mirrorFilter]:[],b.t.instance.on("mirrorChange",(function(e){var t=e.mirror;if(ye.info("renderer mirror change",t),t)i._baseSprite.filters.push(i.mirrorFilter);else{var n=i._baseSprite.filters.findIndex((function(e){return e===i.mirrorFilter}));n>-1&&i._baseSprite.filters.splice(n,1)}})),this._makeupContainer.addChild(this._baseSprite),_e.baseTexture=this._baseSprite.texture}if(this._baseSprite.texture.update(),t)return this._prerenderer||(this._prerenderer=new o.Th({width:this._options.width/2-this._options.width/2%2,height:this._options.height/2-this._options.height/2%2})),this._prerenderer.extract.pixels(this._baseSprite,t),t},t.prototype.getBaseTexture=function(){return this._baseSprite.texture},t.prototype.removeBackground=function(){this.background&&(this.background.remove(),this.background=null)},t.prototype.disableEdgeOptimization=function(){this.background&&this.background.disableEdgeOptimization()},t.prototype.enableEdgeOptimization=function(){this.background&&this.background.enableEdgeOptimization()},t.prototype.applyBackground=function(e){this.background},t.prototype.removeForeground=function(){this._frontContainer&&(this._frontContainer.children.forEach((function(e){e.destroy()})),this._frontContainer.removeChildren())},t.prototype.addForeground=function(e){var t=this;if(Array.isArray(e)){var i={};for(var n in this._frontContainer.children.forEach((function(e){i[e.id]=e})),e.forEach((function(e,n){var r=i[e.id];r?(r.zIndex=n,delete i[e.id]):t._addForeground(e,n)})),i)i[n].destroy(),this._frontContainer.removeChild(i[n]);this._frontContainer.sortChildren()}else this._addForeground(e)},t.prototype._addForeground=function(e,t){var i=e.image,n=e.type,r=e.id,s=b.t.instance.options,a=s.width,u=s.height,h="data"in i?o.xE.fromBuffer(new Uint8Array(i.data.buffer),i.width,i.height):o.xE.from(i),p=new c.jy(h);"video"===n&&(p.blendMode_1=6),p.width=a,p.height=u,p.id=r,t&&(p.zIndex=t),this._frontContainer.addChild(p)},t.prototype.debugDraw=function(e){if(null==e?void 0:e.length){if(!this.points){for(var t=[],i=0;2*i<e.length;i++){var n=this.getCircle(2);t.push(n),this._finalContainer.addChild(n)}this.points=t}for(i=0;2*i<e.length;i++)this.points[i].x=e[2*i],this.points[i].y=e[2*i+1]}},t.prototype.debugDraw2=function(e){if(null==e?void 0:e.length){if(!this.points){for(var t=[],i=0;i<e.length;i++){var n=this.getCircle(2);t.push(n),this._finalContainer.addChild(n)}this.points=t}for(i=0;i<e.length;i++)this.points[i].x=e[i].x*b.t.instance.options.width,this.points[i].y=e[i].y*b.t.instance.options.height}},t.prototype.getPixels=function(){var e=this._options,t=e.width,i=e.height,n=new Uint8Array(t*i*4),r=this._renderer.gl;return r.readPixels(0,0,t,i,r.RGBA,r.UNSIGNED_BYTE,n),{data:n,width:t,height:i}},t.prototype.setEffect=function(e,t,i,n){return le(this,void 0,Promise,(function(){var r,s=this;return fe(this,(function(o){return r=!0,this.latestEffectUrls&&this.latestEffectUrls.length===e.length&&e.every((function(e){return s.latestEffectUrls.indexOf(e)>-1}))&&(r=!1,this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)),this.latestEffectUrls=e,[2,new Promise((function(o,a){r?(s.debounceTimer&&(clearTimeout(s.debounceTimer),s.debounceTimer=null),s.debounceTimer=setTimeout((function(){return s._setEffect(e,t,i,n).then((function(e){clearTimeout(s.debounceTimer),s.debounceTimer=null,o(e)}))}),100)):s._setEffect(e,t,i).then((function(e){o(e)}))}))]}))}))},t.prototype._setEffect=function(e,t,i,n){return le(this,void 0,Promise,(function(){var s,o=this;return fe(this,(function(a){return _.b_.time("AI init duration"),L.s.checkEnabled("beautify")&&!this._meshVertex?[2,new Promise((function(r){clearTimeout(o._meshVertexTimer),o._meshVertexTimer=setInterval((function(){_.b_.info("waiting for AI init..."),o._meshVertex&&(_.b_.info("waiting for AI init...done"),clearTimeout(o._meshVertexTimer),o._setEffect(e,t,i,n).then((function(){r(o._effects)})))}),200)}))]:(_.b_.timeEnd("AI init duration"),s="uid_"+Math.floor(1e8*Math.random()),[2,new Promise((function(a,c){return le(o,void 0,void 0,(function(){var o,c,u,h,p,l,f,d,y,g,m,b,v,k,x,w,M,T=this;return fe(this,(function(C){switch(C.label){case 0:for(o=[].concat(this._effects),c=[],u=[],h=[],p=[],l=[],f=[],d=[],y=[],e.length||(this.filterActivedEffect=null),g=[],m=function(n){var s=o.findIndex((function(t){return t.url===e[n]}));if(s>-1)c.push(o[s]),o[s],u.push(t[n]),h.push(i[n]),o.splice(s,1);else{var a=e[n];y.push(function(e){return le(this,void 0,Promise,(function(){var t,i;return fe(this,(function(n){switch(n.label){case 0:return[4,(t=new r.pF).init()];case 1:return n.sent(),[4,t.preload(e)];case 2:return n.sent(),i=t.readJSON("content.json",e),_.D4.info("download:",e,i),[2,i]}}))}))}(a)),g.push(a),l.push(t[n]),f.push(i[n])}},b=0;b<e.length;b++)m(b);return[4,Promise.all(y)];case 1:for(v=C.sent(),!1,k=!1,x=0;x<v.length;x++)w=g[x],M=void 0,(M=new q(w,this._makeupContainer,this._finalContainer,this._app3d,this._options,this._meshVertex,this._faceLandmarks,this.lipVertex,this._angles,l[x],this._canvas)).filterIntensity=f[x],v[x].sticker3d&&v[x].sticker3d.length&&(k=!0),M.renderer=this._renderer,p.push(M);return _.b_.time("require 3d lib"),this.lib3dLoaded||!k?[3,3]:(_.b_.info("check useFace3d",n()),n&&!n()?[2]:(ye.info("require 3d lib"),[4,this.loadLib3d()]));case 2:C.sent(),this.lib3dLoaded=!0,C.label=3;case 3:return _.b_.timeEnd("require 3d lib"),p.forEach((function(e){d.push(e.load((function(e){e&&(T.need3dRefresh=!0)})).then((function(){return e.intensity=e.intensity,T._app3d||"face"!==e.type||(T._app3d=e.app3d),T._appHand3d||"hand"!==e.type||(T._appHand3d=e.app3d),e})).catch((function(e){ye.error("effect load error",e)})))})),_.b_.time("renderer parse effect"),Promise.all(d).then((function(e){_.b_.timeEnd("renderer parse effect"),_.b_.time("renderer apply effect");for(var t=!1,i=0;i<p.length;i++){var n=p[i];T.latestEffectUrls&&-1===T.latestEffectUrls.indexOf(n.getUrl())&&(n.destroy(!0),t=!0)}if(t)ye.info(s+"end");else{o.forEach((function(e){e.remove(!0)})),T._effects=c,c.forEach((function(e,t){e.intensity=u[t],e.filterIntensity=h[t]}));for(i=0;i<p.length;i++){n=p[i];T._effects.push(n),n.apply({filterTarget:T._makeupContainer,filterCallback:function(){}})}o.forEach((function(e){e.destroy(!0)})),_.b_.timeEnd("renderer apply effect"),(p.length||o.length)&&D.instance.updateMakeupConfigShortcut(T._renderer),a(T._effects)}})),[2]}}))}))}))])}))}))},t.prototype.setEffectJSON=function(e){return le(this,void 0,void 0,(function(){var t,i,n,r,s,o=this;return fe(this,(function(a){switch(a.label){case 0:return i=e.sticker3d,n=e.hand,i&&i.length&&!this.lib3dLoaded?(ye.info("require 3d lib"),[4,this.loadLib3d()]):[3,2];case 1:a.sent(),this.lib3dLoaded=!0,a.label=2;case 2:return n&&n.length&&!this.libHand3dLoaded?(ye.info("require 3d hand lib"),[4,this.loadHand3d()]):[3,4];case 3:a.sent(),this.libHand3dLoaded=!0,a.label=4;case 4:return r=!1,(s=function(){L.s.checkEnabled("beautify")&&o._meshVertex&&(t&&clearTimeout(t),r=!0,o.getJSONEffectForFace(e)),L.s.checkEnabled("handLandmark")&&n&&n.length&&(r=!0,o.getJSONEffectForHand(e)),r||(t=setTimeout(s,20))})(),[2]}}))}))},t.prototype.getJSONEffectForHand=function(e){var t=this,i=new ne(e,this._appHand3d,this._options,this._canvas);i.renderer=this._renderer,_.b_.info("getJSONEffectForHand"),i.load().then((function(){t._appHand3d||(t._appHand3d=i.app3d),i.apply()}))},t.prototype.getJSONEffectForFace=function(e){var t=this,i=[].concat(this._effects);this._effects=[],i.forEach((function(e){e.destroy()}));var n=new Y(e,this._makeupContainer,this._finalContainer,this._app3d,this._options,this._meshVertex,this._faceLandmarks,this.lipVertex);return n.renderer=this._renderer,n.load((function(e){e&&(t.need3dRefresh=!0)})).then((function(){t._app3d||(t._app3d=n.app3d),t._effects=[n],n.apply({filterTarget:t._makeupContainer})})),n},t.prototype.setExclusiveFilter=function(e,t){var i=this;return void 0===t&&(t=1),new Promise((function(n,r){!function(){if(i.exclusiveFilter&&i.exclusiveFilter.getUrl()===e)i.exclusiveFilter.intensity=t,i.exclusiveFilter.filterIntensity=t;else{var r=new q(e,i._makeupContainer,i._finalContainer,i._app3d,i._options,i._meshVertex,i._faceLandmarks,i.lipVertex,i._angles,t);r.filterIntensity=t,r.load((function(e){e&&(i.need3dRefresh=!0)})).then((function(){i.exclusiveFilter&&i.exclusiveFilter.destroy(),i.exclusiveFilter=r,r.renderer=i._renderer,r.apply({filterTarget:i._makeupContainer}),n()}))}}()}))},t.prototype.resize=function(t,i,n){if(void 0===n&&(n=!0),e.prototype.resize.call(this,t,i),ye.info("renderer resize",t,i,n),this._options.width=t,this._options.height=i,this._renderer.resize(t,i),this.background&&this.background.resize(t,i),this._app3d?this._app3d.resize(t,i):this._avatar3d&&this._avatar3d.resize(t,i),this._makeupRenderTexture&&this._makeupRenderTexture.resize(t,i),n&&this._baseSprite&&(this._baseSprite.width=t,this._baseSprite.height=i,this._baseSprite.position.set(t/2,i/2),this._baseSprite.anchor.set(.5,.5),this._baseSprite.scale.set(1)),this._backgroundVR){var r=this._backgroundVR,s=r.width,o=r.height,a=Math.max(t/s,i/o);this._backgroundVR.width*=a,this._backgroundVR.height*=a}this._effects.forEach((function(e){e.resize(t,i)}))},t.prototype.disableExclusiveFilter=function(){this.exclusiveFilter&&this.exclusiveFilter.remove()},t.prototype.enableExclusiveFilter=function(){this.exclusiveFilter&&this.exclusiveFilter.apply({filterTarget:this._makeupContainer,filterCallback:function(){}})},t.prototype.disableEffects=function(e){void 0===e&&(e=!1),this._effects.forEach((function(t){!e&&t.isPureFilter||"hand"===t.type||t.remove()}))},t.prototype.enableEffects=function(){var e=this;this._effects.forEach((function(t){t.apply({filterTarget:e._makeupContainer,filterCallback:function(){}})}))},t.prototype.removeExclusiveFilter=function(){this.exclusiveFilter&&(this.exclusiveFilter.destroy(),this.exclusiveFilter=null)},t.prototype.initAvatarApp=function(e,t){return le(this,void 0,void 0,(function(){return fe(this,(function(e){return[2]}))}))},t.prototype.setAvatar=function(e,t){return le(this,void 0,void 0,(function(){return fe(this,(function(e){return[2]}))}))},t.prototype.registerAvatar=function(e){},t.prototype.reCorrectAvatar=function(){return le(this,void 0,void 0,(function(){return fe(this,(function(e){return[2]}))}))},t.prototype.getCanvas=function(){return this._canvas},t.prototype.setOptions=function(e){},t.prototype.mount=function(e){this._canvas&&e.appendChild(this._canvas)},t.prototype.getCircle=function(e){void 0===e&&(e=5);var t=new o.TC;return t.beginFill(16711680),t.drawCircle(0,0,e),t.endFill(),t},t.preloadEffects=function(e){return le(this,void 0,Promise,(function(){var t,i,n,s,o,a,c;return fe(this,(function(u){switch(u.label){case 0:return e.length?[4,(t=new r.pF).init()]:[2];case 1:u.sent(),i=[];try{for(n=de(e),s=n.next();!s.done;s=n.next())(o=s.value)&&i.push(t.preload(o))}catch(e){a={error:e}}finally{try{s&&!s.done&&(c=n.return)&&c.call(n)}finally{if(a)throw a.error}}return[2,Promise.all(i).then((function(){return Promise.resolve()})).catch((function(e){return Promise.reject(e)}))]}}))}))},t.prototype.handleLoading=function(){var e=this._options,i=e.enableLoadingIcon,n=e.loadingIconOptions,r=void 0===n?{}:n;if(i){var s=t.loading=new re.Z(r);s.zIndex=20;var o=this._options,a=o.width,c=o.height;s.x=a/2,s.y=c/2,this._finalContainer.addChild(s)}},t.prototype.showLoading=function(){t.loading&&t.loading.show()},t.prototype.hideLoading=function(){t.loading&&t.loading.hide()},t.prototype.destroy=function(e){void 0===e&&(e=!0),this.hideLoading(),t.loading&&t.loading.destroy(),e&&_e.baseTexture&&(_e.baseTexture.destroy(!0),_e.baseTexture=null),D.instance.clear(),this._destroyed=!0,this._effects.forEach((function(e){e.destroy()})),this.exclusiveFilter&&this.exclusiveFilter.destroy(),this._stage&&this._stage.destroy(!0),this._renderer&&this._renderer.destroy(!0),this._prerenderer&&(this._prerenderer.destroy(!0),this._prerenderer=null),this.background&&this.background.destroy(),this._app3d&&this._app3d.destroy(),this._appHand3d&&this._appHand3d.destroy(),this._meshVertexTimer&&clearTimeout(this._meshVertexTimer),this.destroyAvatar()},t.prototype.destroyAvatar=function(){this._avatar3d&&(this._avatar3d.destroy(),this._avatar3d=null)},he([(0,p.M)("ArRenderer"),pe("design:type",Function),pe("design:paramtypes",[Object]),pe("design:returntype",void 0)],t.prototype,"destroy",null),t}(oe.F)}}]);