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

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.
@@ -1 +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
+ var self = wx;(self.webpackChunktencentcloud_webar=self.webpackChunktencentcloud_webar||[]).push([[790],{2790:(t,i,n)=>{n.r(i),n.d(i,{PhysicsController:()=>c,PhysicsModelParser:()=>o});var o=function(){function t(t){this.CANNON=t}return t.prototype.parse=function(t){var i,n,o=this,s=[],e=new Map;return t.traverse((function(t){if(t.name){var i=t.name.toLowerCase();if(!/_\d+$/.test(i))if(o.isAnchor(i))e.has("anchor")||e.set("anchor",[]),e.get("anchor").push(t);else if(o.isChain(i)){var n=o.extractChainIndex(i),s="chain-".concat(n);e.has(s)||e.set(s,[]),e.get(s).push(t)}else o.isPendant(i)&&(e.has("pendant")||e.set("pendant",[]),e.get("pendant").push(t))}})),i=this.selectBestCandidate(e.get("anchor")),n=this.selectBestCandidate(e.get("pendant")),Array.from(e.keys()).filter((function(t){return t.startsWith("chain-")})).sort((function(t,i){return parseInt(t.split("-")[1])-parseInt(i.split("-")[1])})).forEach((function(t){var i=o.selectBestCandidate(e.get(t));i&&s.push(i)})),n&&!s.includes(n)&&s.push(n),{anchorMesh:i,chainMeshes:s,pendantMesh:n}},t.prototype.selectBestCandidate=function(t){if(!t||0===t.length)return null;var i=t.filter((function(t){return"Group"===t.type}));if(i.length>0)return i[0];var n=t.filter((function(t){return"Mesh"===t.type}));return n.length>0?n[0]: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 i=t.match(/chain-(\d+)/);return i?parseInt(i[1])-1:0},t}(),s=function(){return s=Object.assign||function(t){for(var i,n=1,o=arguments.length;n<o;n++)for(var s in i=arguments[n])Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s]);return t},s.apply(this,arguments)},e=function(t,i,n,o){return new(n||(n=Promise))((function(s,e){function r(t){try{a(o.next(t))}catch(t){e(t)}}function h(t){try{a(o.throw(t))}catch(t){e(t)}}function a(t){var i;t.done?s(t.value):(i=t.value,i instanceof n?i:new n((function(t){t(i)}))).then(r,h)}a((o=o.apply(t,i||[])).next())}))},r=function(t,i){var n,o,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(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=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++,o=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=i.call(t,r)}catch(t){e=[6,t],o=0}finally{n=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,h])}}},h=function(t,i){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,s,e=n.call(t),r=[];try{for(;(void 0===i||i-- >0)&&!(o=e.next()).done;)r.push(o.value)}catch(t){s={error:t}}finally{try{o&&!o.done&&(n=e.return)&&n.call(e)}finally{if(s)throw s.error}}return r},a=function(t,i,n){if(n||2===arguments.length)for(var o,s=0,e=i.length;s<e;s++)!o&&s in i||(o||(o=Array.prototype.slice.call(i,0,s)),o[s]=i[s]);return t.concat(o||Array.prototype.slice.call(i))},c=function(){function t(t,i){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=i||""}return t.prototype.init=function(t){var i;return e(this,void 0,Promise,(function(){var s,e,c,l,d,u,p,y,f,N,A,v;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),s=this,[4,n.e(541).then(n.bind(n,2415))];case 1:return s.CANNON=r.sent(),e=(null!==(i=this.config.gravity)&&void 0!==i?i:-9.8)*this.GRAVITY_SCALE,this.world=new this.CANNON.World({gravity:new this.CANNON.Vec3(0,e,0)}),this.world.solver.iterations=20,c=new o(this.CANNON),l=c.parse(t),d=l.anchorMesh,u=l.chainMeshes,p=l.pendantMesh,d&&0!==u.length?(u.length>=1&&(y=d.position,f=u[0].position,N=f.x-y.x,A=f.y-y.y,v=f.z-y.z,this.spacing=Math.sqrt(N*N+A*A+v*v)),this.meshes=a([d],h(u),!1),p&&!u.includes(p)&&this.meshes.push(p),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,[3,3]):[2];case 2:throw r.sent();case 3:return[2]}}))}))},t.prototype.createPhysicsBodies=function(){var t,i,n,o,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),u=this.anchorBody,p=0;p<d.length;p++){var y=d[p],f=p===d.length-1,N=f?3*(null!==(i=this.config.mass)&&void 0!==i?i:.05):(null!==(n=this.config.mass)&&void 0!==n?n:.05)*(1+.1*p),A=new this.CANNON.Body({mass:N,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!==(o=this.config.damping)&&void 0!==o?o:.5,angularDamping:.5*(null!==(s=this.config.damping)&&void 0!==s?s:.5)});this.world.addBody(A),this.chainBodies.push(A);var v=y,w=(0===p?this.meshes[0]:d[p-1]).position,g=v.position,m=Math.sqrt(Math.pow(g.x-w.x,2)+Math.pow(g.y-w.y,2)+Math.pow(g.z-w.z,2)),C=new this.CANNON.DistanceConstraint(u,A,m);this.world.addConstraint(C),this.constraints.push(C);var x=(null!==(e=this.config.swingAngle)&&void 0!==e?e:45)*Math.PI/180,B=new this.CANNON.ConeTwistConstraint(u,A,{pivotA:new this.CANNON.Vec3(0,-m/2,0),pivotB:new this.CANNON.Vec3(0,m/2,0),axisA:new this.CANNON.Vec3(0,1,0),axisB:new this.CANNON.Vec3(0,1,0),angle:x,twistAngle:0});this.world.addConstraint(B),this.constraints.push(B),u=A}},t.prototype.setGroupScale=function(t){t>0&&(this.groupScale=t)},t.prototype.update=function(t,i){var n=this;if(this.world&&this.initialized&&i){var o=this.groupScale||1,s=i.x/o,e=i.y/o,r=i.z/o;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,i){var o=n.meshes[i+1];o&&(o.position.x=t.position.x-n.hiddenAnchor.position.x,o.position.y=t.position.y-n.hiddenAnchor.position.y,o.position.z=t.position.z-n.hiddenAnchor.position.z,o.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 i=t.gravity*this.GRAVITY_SCALE;this.world.gravity.set(0,i,0)}void 0!==t.damping&&this.chainBodies.forEach((function(i){var n;i.linearDamping=t.damping,i.angularDamping=.5*(null!==(n=t.damping)&&void 0!==n?n:.5)}))},t.prototype.destroy=function(){var t,i,n=this;this.meshes.forEach((function(t,i){var o=n.originalTransforms[i];t&&o&&(t.position.x=o.position.x,t.position.y=o.position.y,t.position.z=o.position.z,t.quaternion.x=o.quaternion.x,t.quaternion.y=o.quaternion.y,t.quaternion.z=o.quaternion.z,t.quaternion.w=o.quaternion.w)})),this.originalTransforms=[],this.constraints.forEach((function(t){var i;return null===(i=n.world)||void 0===i?void 0:i.removeConstraint(t)})),this.constraints=[],this.hiddenAnchor&&(null===(t=this.world)||void 0===t||t.removeBody(this.hiddenAnchor),this.hiddenAnchor=null),this.anchorBody&&(null===(i=this.world)||void 0===i||i.removeBody(this.anchorBody),this.anchorBody=null),this.chainBodies.forEach((function(t){var i;return null===(i=n.world)||void 0===i?void 0:i.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(!(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)}}]);
1
+ var self = wx;(self.webpackChunktencentcloud_webar=self.webpackChunktencentcloud_webar||[]).push([[321],{2197:(e,t,i)=>{i.d(t,{g:()=>Ze,b:()=>$e});var n,r=i(3044),s=i(9124),o=i(1206),a=i(3125),h=i(9560),u=i(401),c=i(1347),l=i(1084),p=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,h){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=h}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 h.Kg(i)).animationSpeed=(this._config.fps||30)/60,e.play()}else{var n=this._src[0],s=o.P6.kN[n];e=new h.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,c.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 h={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=h.x,this._container.position.y=h.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},p([(0,l.M)("StickerLayer"),f("design:type",Function),f("design:paramtypes",[]),f("design:returntype",Boolean)],e.prototype,"checkAnimated",null),p([(0,l.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 h=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=h.parentIntensity,o.load(),h._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),m=i(201),g=i(617),v=i(3849),b=(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 S,M,T,C,E,R,L,I,P=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.shader&&(this.shader.uniforms.uUseLipMask=0):(this._lipMaskTexture=e.texture,this.shader&&(this.shader.uniforms.uSamplerLipMask=this._lipMaskTexture,this.shader.uniforms.uUseLipMask=1))},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.updateIrisFeather=function(){this.shader&&this.irisLayerRef&&(this.shader.uniforms.irisLeftCenter=this.irisLayerRef.irisLeftCenter,this.shader.uniforms.irisRightCenter=this.irisLayerRef.irisRightCenter,this.shader.uniforms.irisLeftRadius=this.irisLayerRef.irisLeftRadius,this.shader.uniforms.irisRightRadius=this.irisLayerRef.irisRightRadius)},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 uniform float uUseLipMask;\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 // 虹膜径向羽化参数\n uniform vec2 irisLeftCenter; // 左眼虹膜中心(归一化 0~1)\n uniform vec2 irisRightCenter; // 右眼虹膜中心(归一化 0~1)\n uniform vec2 irisLeftRadius; // 左眼虹膜半径 [rx, ry]\n uniform vec2 irisRightRadius; // 右眼虹膜半径 [rx, ry]\n\n // Catchlight 高光保留参数\n uniform float catchlightThreshold; // 高亮检测阈值(默认 0.55)\n\n uniform int mirror;\n uniform vec2 imageOffset;\n \n ").concat(n.map((function(e){return h.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(h.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 // 混合美瞳(带径向羽化 + Catchlight 高光保留)\n vec4 irisColor = texture2D(uSamplerIris, bUvs);\n if (irisColor.a > 0.) {\n // 计算当前像素到左右虹膜中心的椭圆归一化距离\n vec2 dL = (bUvs - irisLeftCenter) / max(irisLeftRadius, vec2(0.001));\n vec2 dR = (bUvs - irisRightCenter) / max(irisRightRadius, vec2(0.001));\n float distL = length(dL);\n float distR = length(dR);\n // 取最近的虹膜距离\n float dist = min(distL, distR);\n // 从 0.7 倍半径开始羽化,到 1.0 倍半径完全透明\n float feather = 1.0 - smoothstep(0.7, 1.0, dist);\n float finalAlpha = irisColor.a * feather;\n\n // === Catchlight 高光保留 ===\n // 混合前:检测原图中的高亮像素(眼球反光点)\n float sourceGray = dot(baseColor.rgb, vec3(0.299, 0.587, 0.114));\n float screenValue = 0.0;\n if (sourceGray > catchlightThreshold) {\n float diff = sourceGray - catchlightThreshold;\n // 高光强度:diff 乘以放大系数,让小面积亮点也能穿透美瞳\n // 系数 6.0 确保即使 diff 只有 0.1~0.2 也能产生可见效果\n float catchlightIntensity = 6.0;\n screenValue = min(catchlightIntensity * diff, 1.0) * finalAlpha;\n }\n\n if (finalAlpha > 0.) {\n // 正常混合美瞳\n baseColor.rgb = blend".concat(h.Lc[this.irisBlendMode].key,"(baseColor.rgb, irisColor.rgb/irisColor.a , finalAlpha);\n\n // 混合后:Screen blend 叠回高光,让眼睛保持神采\n if (screenValue > 0.0) {\n baseColor.rgb = 1.0 - (1.0 - baseColor.rgb) * (1.0 - screenValue);\n }\n }\n }\n "):"","\n \n \n // 输出\n gl_FragColor = baseColor;\n // gl_FragColor = makeupColor;\n }"),s={enable:1},a=this._options,u=a.width,c=a.height;s.baseImage=$e.baseTexture,s.size=[u*c/$e.baseTexture.height,c];var l=$e.baseTexture.width*c/$e.baseTexture.height;if(s.imageOffset=[(l-u)/2/l,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=v.t.instance.options.mirror?1:0,i.textures.push(r)})),this.irisRenderTexture){s.uSamplerIris=this.irisRenderTexture,s.mirror=v.t.instance.options.mirror?1:0;var p=this.irisLayerRef;s.irisLeftCenter=p?p.irisLeftCenter:[0,0],s.irisRightCenter=p?p.irisRightCenter:[0,0],s.irisLeftRadius=p?p.irisLeftRadius:[.1,.1],s.irisRightRadius=p?p.irisRightRadius:[.1,.1],s.catchlightThreshold=.55}s.uSamplerLipMask=this._lipMaskTexture;var f=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=f,this.mirrorChangeHandler=function(e){i.shader&&(i.shader.uniforms.mirror=(null==e?void 0:e.mirror)?1:0)},v.t.instance.on("mirrorChange",this.mirrorChangeHandler);var d=new o.Kj(t,f);return this._mesh=d,this._container.addChild(d),d}},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&&v.t.instance.off("mirrorChange",this.mirrorChangeHandler)},k([(0,l.M)("MakeupLayer"),x("design:type",Function),x("design:paramtypes",[Array]),x("design:returntype",void 0)],e.prototype,"updateGeometry",null),k([(0,l.M)("MakeupLayer"),x("design:type",Function),x("design:paramtypes",[]),x("design:returntype",void 0)],e.prototype,"destroy",null),e}(),O=function(e){function t(t,i,n,r,s,a,h,u){var c=e.call(this,t,a)||this;return c._maskGraphics=new o.TC,c.maxLConSize=.42,c.maxRConSize=.42,c.irisLeftCenter=[0,0],c.irisRightCenter=[0,0],c.irisLeftRadius=[0,0],c.irisRightRadius=[0,0],c._parentIntensity=1,c.parentKey=h,c.jsonIntensity=r,c._parentIntensity=u||1,c.getTexture(i,n),c._config=s,c.renderTexture=o.TI.create({width:t.width,height:t.height,resolution:2}),c}var i,n;return b(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,h=void 0,u=void 0,l=void 0,p=void 0;if(e.length>=163){var f=e.slice(123,143),d=e.slice(143,163);a=o=this._getXRange(f),u=h=this._getXRange(d),l=e[123],p=e[143]}else{var y=(0,c.Sp)(e[52],e[55]),_=(0,c.Sp)(e[58],e[61]);a=o=y*this.maxLConSize,u=h=_*this.maxLConSize,l=(0,c.qg)(e[74],e[104]),p=(0,c.qg)(e[77],e[105])}var m=o,g=a,v=h,b=u,k=l,x=p,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 S=this._leftIris,M=this._rightIris,T=function(e,t){var i=e.length;if(i<8)return 1;var n=Math.floor(i/2),r=t[e[0]],s=t[e[n]],o=Math.abs(s.x-r.x);if(o<.001)return 1;for(var a=0,h=0,u=1;u<n;u++){var c=t[e[u]].y,l=t[e[i-u]].y;a+=Math.abs(l-c),h++}return h>0?a/h/o:0},C=T(r,e),E=T(s,e),R=function(e){return Math.min(1,Math.max(0,(e-.08)/(.18-.08)))};S.alpha=R(C),M.alpha=R(E),S.width=m*(this._options.irisScale||1),S.height=g*(this._options.irisScale||1),S.x=k.x,S.y=k.y,M.width=v*(this._options.irisScale||1),M.height=b*(this._options.irisScale||1),M.x=x.x,M.y=x.y,this._maskGraphics.clear(),this._drawMaskGraphics(r,e),this._drawMaskGraphics(s,e);var L=this.renderTexture.width,I=this.renderTexture.height,P=this._options.irisScale||1;this.irisLeftCenter=[k.x/L,k.y/I],this.irisRightCenter=[x.x/L,x.y/I],this.irisLeftRadius=[m*P*.5/L,g*P*.5/I],this.irisRightRadius=[v*P*.5/L,b*P*.5/I],t.render(this._container,{renderTexture:this.renderTexture})}catch(e){}},t.prototype._drawMaskGraphics=function(e,t){var i=this._maskGraphics;i.beginFill(16724736);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,c.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,c.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,l.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}(P),F=i(3120),j=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},U=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},V=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{h(n.next(e))}catch(e){s(e)}}function a(e){try{h(n.throw(e))}catch(e){s(e)}}function h(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}h((n=n.apply(e,t||[])).next())}))},A=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])}}},G=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.")},N=function(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var n,r,s=i.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(e){r={error:e}}finally{try{n&&!n.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return o},D=function(e,t,i){if(i||2===arguments.length)for(var n,r=0,s=t.length;r<s;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))},z=(0,_.jl)("lip-makeup"),W=[[61,78,185],[78,191,185],[185,191,40],[191,80,40],[40,80,39],[80,81,39],[39,81,37],[81,82,37],[37,82,0],[82,13,0],[0,13,267],[13,312,267],[267,312,269],[312,311,269],[269,311,270],[311,310,270],[270,310,409],[310,415,409],[409,415,291],[415,308,291],[61,78,146],[78,95,146],[146,95,91],[95,88,91],[91,88,181],[88,178,181],[181,178,84],[178,87,84],[84,87,17],[87,14,17],[17,14,314],[14,317,314],[314,317,405],[317,402,405],[405,402,321],[402,318,321],[321,318,375],[318,324,375],[375,324,291],[324,308,291]],B={0:[.499977,.347466],13:[.500023,.307652],14:[.499977,.304722],17:[.499977,.262981],37:[.471751,.349596],39:[.439785,.342771],40:[.414617,.333459],61:[.381974,.305289],78:[.403629,.306047],80:[.431158,.307634],81:[.452182,.307634],82:[.475387,.307634],84:[.472329,.263774],87:[.473033,.304722],88:[.427942,.304722],91:[.418309,.279937],95:[.4132,.3046],146:[.3961,.289783],178:[.448662,.304722],181:[.444832,.269206],185:[.3924,.322297],191:[.413386,.307634],267:[.528249,.349596],269:[.560215,.342771],270:[.585384,.333459],291:[.618026,.305289],308:[.596371,.306047],310:[.568842,.307634],311:[.547818,.307634],312:[.524613,.307634],314:[.527671,.263774],317:[.526967,.304722],318:[.572058,.304722],321:[.581691,.279937],324:[.5868,.3046],375:[.6039,.289783],402:[.551338,.304722],405:[.555168,.269206],409:[.6076,.322297],415:[.586614,.307634]},H=new Set;try{for(var K=G(W),J=K.next();!J.done;J=K.next()){var X=J.value;try{for(var q=(T=void 0,G(X)),Y=q.next();!Y.done;Y=q.next()){var $=Y.value;H.add($)}}catch(e){T={error:e}}finally{try{Y&&!Y.done&&(C=q.return)&&C.call(q)}finally{if(T)throw T.error}}}}catch(e){S={error:e}}finally{try{J&&!J.done&&(M=K.return)&&M.call(K)}finally{if(S)throw S.error}}var Z=D([],N(H),!1).sort((function(e,t){return e-t})),Q=new Map;Z.forEach((function(e,t){return Q.set(e,t)}));var ee=[];try{for(var te=G(Z),ie=te.next();!ie.done;ie=te.next()){var ne=B[$=ie.value];ee.push(ne?ne[0]:0,ne?ne[1]:0)}}catch(e){E={error:e}}finally{try{ie&&!ie.done&&(R=te.return)&&R.call(te)}finally{if(E)throw E.error}}var re=[];try{for(var se=G(W),oe=se.next();!oe.done;oe=se.next()){X=oe.value;re.push(Q.get(X[0]),Q.get(X[1]),Q.get(X[2]))}}catch(e){L={error:e}}finally{try{oe&&!oe.done&&(I=se.return)&&I.call(se)}finally{if(L)throw L.error}}var ae=function(){function e(e,t,i){this._destroyed=!1,this._color=[234/255,21/255,32/255],this._intensity=.65,this._satinLevel=.3,this._shimmerLevel=0,this._glossLevel=.8,this._blendMode=19,this._parentIntensity=1,this.parentKey="",this._glossPingPong=0,this._glossStartSat=.35,this._glossMidSat=.18,this._glossEndSat=.05,this._glossReduce=.85,this._lastLipAnalyzeTime=0,this._options=e,this._container=t,this.renderer=i}return e.prototype.init=function(e){return V(this,void 0,Promise,(function(){return A(this,(function(t){return this._parseConfig(e),z.info("lip mesh:",Z.length,"unique vertices,",W.length,"triangles,","index range: 0-"+(Z.length-1)),this._createGeometry(),this._createShaderAndMesh(),this._createGlossPipeline(),[2]}))}))},e.prototype._parseConfig=function(e){e.color&&(this._color=this._hexToRgb(e.color)),void 0!==e.intensity&&(this._intensity=e.intensity),void 0!==e.satinLevel&&(this._satinLevel=e.satinLevel),void 0!==e.shimmerLevel&&(this._shimmerLevel=e.shimmerLevel),void 0!==e.glossLevel&&(this._glossLevel=e.glossLevel),void 0!==e.blend&&(this._blendMode=e.blend)},e.prototype._hexToRgb=function(e){var t=e.replace("#","");return[parseInt(t.substring(0,2),16)/255,parseInt(t.substring(2,4),16)/255,parseInt(t.substring(4,6),16)/255]},e.prototype._createGeometry=function(){var e=Z.length;this.geometry=(new o.wG).addAttribute("aVertexPosition",new Float32Array(2*e),2).addAttribute("aUvs",new Float32Array(ee),2).addIndex(new Uint16Array(re))},e.prototype._createShaderAndMesh=function(){var e=this,t=h.Lc[this._blendMode].shader,i=h.Lc[this._blendMode].key,n="\n precision mediump float;\n varying vec2 vUvs;\n varying vec2 bUvs;\n uniform sampler2D baseImage;\n uniform sampler2D uLipBase;\n uniform sampler2D uLipSatin;\n uniform sampler2D uLipShimmer;\n uniform sampler2D uLipGloss;\n uniform sampler2D uGlossAccum;\n uniform int enable;\n uniform int mirror;\n uniform vec2 imageOffset;\n uniform vec3 uColor;\n uniform float uIntensity;\n uniform float uSatinLevel;\n uniform float uShimmerLevel;\n uniform float uGlossLevel;\n uniform float uParentIntensity;\n\n ".concat(t,"\n\n void main() {\n if (enable == 0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n return;\n }\n // 纹理采样 UV(对 v 做 1-v 翻转,与 demo composite shader 一致)\n vec2 texUV = vec2(vUvs.x, 1.0 - vUvs.y);\n float mask = texture2D(uLipBase, texUV).a;\n if (mask < 0.003) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n return;\n }\n vec2 baseCoord = bUvs + imageOffset;\n if (mirror == 1) {\n baseCoord = vec2(1.0 - bUvs.x, bUvs.y);\n }\n vec4 baseColor = texture2D(baseImage, baseCoord);\n vec3 col = baseColor.rgb;\n float realIntensity = uIntensity * uParentIntensity;\n float lipMask = mask * realIntensity;\n\n // Layer 0: 口红着色\n col = blend").concat(i,"(col, uColor, lipMask);\n\n // Layer 1: Satin (Add)\n if (uSatinLevel > 0.0) {\n float satinA = texture2D(uLipSatin, texUV).a;\n col += vec3(satinA * uSatinLevel);\n }\n // Layer 1.5: Shimmer (Add, x1.5)\n if (uShimmerLevel > 0.0) {\n float shimmerA = texture2D(uLipShimmer, texUV).a;\n col += vec3(shimmerA * uShimmerLevel * 1.5);\n }\n\n // Layer 2: Gloss (动态饱和度 Screen blend,对齐 demo composite shader)\n if (uGlossLevel > 0.0) {\n float glossMask = texture2D(uLipGloss, texUV).a;\n // 从 temporal 平滑后的 RT 采样(face UV 空间)\n vec2 glossRG = texture2D(uGlossAccum, vUvs).rg;\n float weight = glossRG.r;\n float reduce = glossRG.g;\n // weight *= glossTexture.alpha * uGlossLevel\n weight *= glossMask * uGlossLevel;\n float cutoff = 0.12;\n float gamma = 2.0;\n float strength = 3.5;\n weight = max(0.0, (weight - cutoff)) / max(1e-6, (1.0 - cutoff));\n weight = pow(weight, gamma) * strength;\n weight = clamp(weight * reduce, 0.0, 1.0);\n // Screen blend\n col = col + (1.0 - col) * weight;\n }\n\n // 边缘柔化:对 mask 做 smoothstep 平滑过渡,避免三角形硬边产生锯齿\n // 上限从 0.35 → 0.15,让上唇内侧(低 mask alpha 区域)获得更充分的着色覆盖\n float edgeAlpha = smoothstep(0.01, 0.35, mask);\n\n // 输出 premultiplied alpha,让 pixi blend 时透明边缘平滑过渡\n gl_FragColor = vec4(clamp(col, 0.0, 1.0) * edgeAlpha, edgeAlpha);\n }"),r=this._options,s=r.width,a=r.height,u={enable:1,baseImage:$e.baseTexture,uLipBase:o.P6.kN[F.$i]||o.xE.WHITE,uLipSatin:o.P6.kN[F.pq]||o.xE.WHITE,uLipShimmer:o.P6.kN[F.pT]||o.xE.WHITE,uLipGloss:o.P6.kN[F.wW]||o.xE.WHITE,uGlossAccum:o.xE.WHITE,uColor:this._color,uIntensity:this._intensity,uSatinLevel:this._satinLevel,uShimmerLevel:this._shimmerLevel,uGlossLevel:this._glossLevel,uParentIntensity:this._parentIntensity,mirror:v.t.instance.options.mirror?1:0};u.size=[s*a/$e.baseTexture.height,a];var c=$e.baseTexture.width*a/$e.baseTexture.height;u.imageOffset=[(c-s)/2/c,0],this.shader=o.ex.from("\n precision mediump float;\n attribute vec2 aVertexPosition;\n attribute vec2 aUvs;\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n uniform vec2 size;\n varying vec2 vUvs;\n varying vec2 bUvs;\n void main() {\n vUvs = aUvs;\n bUvs = aVertexPosition.xy / size;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n }",n,u),this.mirrorChangeHandler=function(t){e.shader&&(e.shader.uniforms.mirror=(null==t?void 0:t.mirror)?1:0)},v.t.instance.on("mirrorChange",this.mirrorChangeHandler),this._mesh=new o.Kj(this.geometry,this.shader),this._container.addChild(this._mesh)},e.prototype._createGlossPipeline=function(){var e=256;this._lipSampleRT=o.TI.create({width:e,height:e,scaleMode:o.aH.NEAREST}),this._glossWeightRT=o.TI.create({width:e,height:e,scaleMode:o.aH.LINEAR}),this._temporalRT=[o.TI.create({width:e,height:e,scaleMode:o.aH.LINEAR}),o.TI.create({width:e,height:e,scaleMode:o.aH.LINEAR})],this._glossPingPong=0;var t="\n precision mediump float;\n attribute vec2 aVertexPosition;\n attribute vec2 aUvs;\n uniform mat3 translationMatrix;\n uniform mat3 projectionMatrix;\n uniform vec2 uScreenSize;\n varying vec2 vUvFace;\n varying vec2 vUvScreen;\n void main() {\n // 在 face UV 空间渲染 — aUvs 映射到 clip space\n gl_Position = vec4(aUvs * 2.0 - 1.0, 0.0, 1.0);\n vUvFace = aUvs;\n // screen UV from pixel position\n vUvScreen = aVertexPosition / uScreenSize;\n }";this._lipSampleGeom=this._createGlossGeometry();this._lipSampleShader=o.ex.from(t,"\n precision mediump float;\n varying vec2 vUvFace;\n varying vec2 vUvScreen;\n uniform sampler2D uVideoTex;\n uniform sampler2D uLipMask;\n\n vec3 rgb2hsv(vec3 c) {\n float cMax = max(c.r, max(c.g, c.b));\n float cMin = min(c.r, min(c.g, c.b));\n float d = cMax - cMin;\n float s = (cMax < 1e-5) ? 0.0 : d / cMax;\n return vec3(0.0, s, cMax);\n }\n\n void main() {\n vec2 texUV = vec2(vUvFace.x, 1.0 - vUvFace.y);\n float a = texture2D(uLipMask, texUV).a;\n if (a < 0.05) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n return;\n }\n vec3 col = texture2D(uVideoTex, vUvScreen).rgb;\n float s = rgb2hsv(col).y;\n gl_FragColor = vec4(s, 0.0, 0.0, a);\n }",{uVideoTex:$e.baseTexture,uLipMask:o.P6.kN[F.$i]||o.xE.WHITE,uScreenSize:[this._options.width,this._options.height]}),this._lipSampleMesh=new o.Kj(this._lipSampleGeom,this._lipSampleShader),this._glossWeightGeom=this._createGlossGeometry();this._glossWeightShader=o.ex.from(t,"\n precision mediump float;\n varying vec2 vUvFace;\n varying vec2 vUvScreen;\n uniform sampler2D uVideoTex;\n uniform sampler2D uLipMask;\n uniform float uGlossStartSat;\n uniform float uGlossMidSat;\n uniform float uGlossEndSat;\n uniform float uGlossReduce;\n\n vec3 rgb2hsv(vec3 c) {\n float cMax = max(c.r, max(c.g, c.b));\n float cMin = min(c.r, min(c.g, c.b));\n float d = cMax - cMin;\n float s = (cMax < 1e-5) ? 0.0 : d / cMax;\n return vec3(0.0, s, cMax);\n }\n\n void main() {\n vec2 texUV = vec2(vUvFace.x, 1.0 - vUvFace.y);\n float a = texture2D(uLipMask, texUV).a;\n if (a < 0.05) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n float s = rgb2hsv(texture2D(uVideoTex, vUvScreen).rgb).y;\n float sStart = uGlossStartSat;\n float sMid = uGlossMidSat;\n float sEnd = uGlossEndSat;\n float reduce = uGlossReduce;\n sStart = max(sStart, sMid + 1e-6);\n sMid = max(sMid, sEnd + 1e-6);\n float midLevel = 0.5;\n float gamma1 = 1.5;\n float t;\n if (s >= sStart) {\n t = 0.0;\n } else if (s > sMid) {\n float r = pow(clamp((sStart - s) / max(sStart - sMid, 1e-6), 0.0, 1.0), gamma1);\n t = r * midLevel;\n } else if (s > sEnd) {\n float r = clamp((sMid - s) / max(sMid - sEnd, 1e-6), 0.0, 1.0);\n t = mix(midLevel, 1.0, r);\n } else {\n t = 1.0;\n }\n float w = clamp(a * t, 0.0, 1.0);\n gl_FragColor = vec4(w, reduce, 0.0, 1.0);\n }",{uVideoTex:$e.baseTexture,uLipMask:o.P6.kN[F.$i]||o.xE.WHITE,uScreenSize:[this._options.width,this._options.height],uGlossStartSat:this._glossStartSat,uGlossMidSat:this._glossMidSat,uGlossEndSat:this._glossEndSat,uGlossReduce:this._glossReduce}),this._glossWeightMesh=new o.Kj(this._glossWeightGeom,this._glossWeightShader),this._temporalGeom=(new o.wG).addAttribute("aVertexPosition",new Float32Array([0,0,e,0,e,e,0,e]),2).addAttribute("aUvs",new Float32Array([0,0,1,0,1,1,0,1]),2).addIndex(new Uint16Array([0,1,2,0,2,3]));this._temporalShader=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 vUV;\n void main() {\n vUV = aUvs;\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n }","\n precision mediump float;\n varying vec2 vUV;\n uniform sampler2D uCurr;\n uniform sampler2D uPrev;\n void main() {\n float fadeInSpeed = 0.60;\n float fadeOutSpeed = 0.40;\n vec2 c = texture2D(uCurr, vUV).rg;\n vec2 p = texture2D(uPrev, vUV).rg;\n float kR = (c.r > p.r) ? fadeInSpeed : fadeOutSpeed;\n float kG = (c.g > p.g) ? fadeInSpeed : fadeOutSpeed;\n vec2 a = mix(p, c, vec2(kR, kG));\n gl_FragColor = vec4(a, 0.0, 1.0);\n }",{uCurr:this._glossWeightRT,uPrev:this._temporalRT[1]}),this._temporalMesh=new o.Kj(this._temporalGeom,this._temporalShader),this.shader&&(this.shader.uniforms.uGlossAccum=this._temporalRT[0])},e.prototype._createGlossGeometry=function(){var e=Z.length;return(new o.wG).addAttribute("aVertexPosition",new Float32Array(2*e),2).addAttribute("aUvs",new Float32Array(ee),2).addIndex(new Uint16Array(re))},e.prototype._runGlossPipeline=function(){if(!(this._destroyed||this._glossLevel<=0)&&this._glossWeightRT&&this._temporalRT){var e="undefined"!=typeof performance?performance.now():Date.now();e-this._lastLipAnalyzeTime>66&&(this._lastLipAnalyzeTime=e,this._passLipSample(),this._analyzeLipSaturation()),this._passGlossWeight(),this._passTemporal()}},e.prototype._passLipSample=function(){if(this._lipSampleShader&&this._lipSampleMesh&&this._lipSampleRT){var e=this._lipSampleShader.uniforms;e.uVideoTex=$e.baseTexture,e.uScreenSize=[this._options.width,this._options.height],this.renderer.render(this._lipSampleMesh,{renderTexture:this._lipSampleRT,clear:!0})}},e.prototype._passGlossWeight=function(){if(this._glossWeightShader&&this._glossWeightMesh){var e=this._glossWeightShader.uniforms;e.uVideoTex=$e.baseTexture,e.uScreenSize=[this._options.width,this._options.height],e.uGlossStartSat=this._glossStartSat,e.uGlossMidSat=this._glossMidSat,e.uGlossEndSat=this._glossEndSat,e.uGlossReduce=this._glossReduce,this.renderer.render(this._glossWeightMesh,{renderTexture:this._glossWeightRT,clear:!0})}},e.prototype._passTemporal=function(){if(this._temporalShader&&this._temporalMesh){var e=this._glossPingPong,t=1-e;this._temporalShader.uniforms.uCurr=this._glossWeightRT,this._temporalShader.uniforms.uPrev=this._temporalRT[t],this.renderer.render(this._temporalMesh,{renderTexture:this._temporalRT[e],clear:!0}),this.shader&&(this.shader.uniforms.uGlossAccum=this._temporalRT[e]),this._glossPingPong=1-this._glossPingPong}},e.prototype._analyzeLipSaturation=function(){if(this._currentLandmarks&&this._currentLandmarks.length&&this._lipSampleRT)try{var e=this.renderer.gl;if(!e)return;this.renderer.renderTexture.bind(this._lipSampleRT);var t=256,i=new Uint8Array(262144);e.readPixels(0,0,t,t,e.RGBA,e.UNSIGNED_BYTE,i),this.renderer.renderTexture.bind(null);for(var n=[],r=0;r<i.length;r+=4){var s=i[r]/255;i[r+3]/255<=.05||n.push(s)}if(0===n.length)return;n.sort((function(e,t){return e-t}));var o=function(e){return n[Math.max(0,Math.min(n.length-1,Math.floor(n.length*e)))]},a=o(.3),h=o(.1),u=o(.04),c=o(.9)-o(.03),l=void 0;if(c>=.2)l=1;else if(c<=.15)l=.45;else{l=.45+.55*((c-.15)/(.2-.15))}this._glossStartSat=a,this._glossMidSat=h,this._glossEndSat=u,this._glossReduce=l}catch(e){}},e.prototype.updateLandmarks=function(t){if(!this._destroyed&&this.geometry&&t&&t.length){this._currentLandmarks=t;var i=this._options,n=i.width,r=i.height,s=this.geometry.getBuffer("aVertexPosition"),o=new Float32Array(2*Z.length),a=t[13],h=t[14],u=0,c=0;if(a&&h){var l=h.y-a.y;u=Math.min(Math.max(l/e.OPEN_THRESHOLD,0),1),c=(a.y+h.y)/2}for(var p=e.UPPER_INNER_CONVERGE,f=u*e.LOWER_INNER_CONVERGE_MAX,d=0;d<Z.length;d++){var y=Z[d],_=e.LOWER_LIP_OUTER_MAP[y];if(_){var m=N(_,2),g=m[0],v=m[1],b=t[y],k=t[g];b&&k&&(o[2*d]=(b.x+(k.x-b.x)*v)*n,o[2*d+1]=(b.y+(k.y-b.y)*v)*r)}else if(e.UPPER_INNER_POINTS.has(y)){(x=t[y])&&(o[2*d]=x.x*n,o[2*d+1]=(x.y+(c-x.y)*p)*r)}else if(f>0&&e.LOWER_INNER_POINTS.has(y)){(x=t[y])&&(o[2*d]=x.x*n,o[2*d+1]=(x.y+(c-x.y)*f)*r)}else{var x;(x=t[y])&&(o[2*d]=x.x*n,o[2*d+1]=x.y*r)}}if(s.update(o),this._lipSampleGeom)this._lipSampleGeom.getBuffer("aVertexPosition").update(o);if(this._glossWeightGeom)this._glossWeightGeom.getBuffer("aVertexPosition").update(o);this._runGlossPipeline()}},e.prototype.updateMeshVertex=function(e){},e.prototype.updateParams=function(e){if(this.shader){var t=this.shader.uniforms;e.color&&(this._color=this._hexToRgb(e.color),t.uColor=this._color),void 0!==e.intensity&&(this._intensity=e.intensity,t.uIntensity=this._intensity),void 0!==e.satinLevel&&(this._satinLevel=e.satinLevel,t.uSatinLevel=this._satinLevel),void 0!==e.shimmerLevel&&(this._shimmerLevel=e.shimmerLevel,t.uShimmerLevel=this._shimmerLevel),void 0!==e.glossLevel&&(this._glossLevel=e.glossLevel,t.uGlossLevel=this._glossLevel)}},Object.defineProperty(e.prototype,"parentIntensity",{set:function(e){this._parentIntensity=e,this.shader&&(this.shader.uniforms.uParentIntensity=e)},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.resize=function(e,t){this._options.width=e,this._options.height=t,this.shader&&(this.shader.uniforms.size=[e,t],this._lipSampleShader&&(this._lipSampleShader.uniforms.uScreenSize=[e,t]),this._glossWeightShader&&(this._glossWeightShader.uniforms.uScreenSize=[e,t]))},e.prototype.destroy=function(){var e,t;z.info("LipMakeupLayer destroy"),this._destroyed=!0,this._mesh&&(this._mesh.destroy({children:!0,texture:!1,baseTexture:!1}),this._mesh=null),this.shader&&(this.shader.destroy(),this.shader=null),this.mirrorChangeHandler&&v.t.instance.off("mirrorChange",this.mirrorChangeHandler),this._lipSampleMesh&&(this._lipSampleMesh.destroy({children:!0,texture:!1,baseTexture:!1}),this._lipSampleMesh=null),this._lipSampleShader&&(this._lipSampleShader.destroy(),this._lipSampleShader=null),this._lipSampleRT&&(this._lipSampleRT.destroy(!0),this._lipSampleRT=null),this._glossWeightMesh&&(this._glossWeightMesh.destroy({children:!0,texture:!1,baseTexture:!1}),this._glossWeightMesh=null),this._glossWeightShader&&(this._glossWeightShader.destroy(),this._glossWeightShader=null),this._glossWeightRT&&(this._glossWeightRT.destroy(!0),this._glossWeightRT=null),this._temporalMesh&&(this._temporalMesh.destroy({children:!0,texture:!1,baseTexture:!1}),this._temporalMesh=null),this._temporalShader&&(this._temporalShader.destroy(),this._temporalShader=null),this._temporalRT&&(null===(e=this._temporalRT[0])||void 0===e||e.destroy(!0),null===(t=this._temporalRT[1])||void 0===t||t.destroy(!0),this._temporalRT=null)},e.LOWER_LIP_OUTER_MAP={61:[57,.1],146:[43,.2],91:[106,.2],181:[182,.2],84:[83,.2],17:[18,.2],314:[313,.2],405:[406,.2],321:[335,.2],375:[273,.2],291:[287,.1]},e.UPPER_INNER_POINTS=new Set([191,80,81,82,13,312,311,310,415]),e.LOWER_INNER_POINTS=new Set([95,88,178,87,14,317,402,318,324]),e.UPPER_INNER_CONVERGE=.35,e.LOWER_INNER_CONVERGE_MAX=.3,e.OPEN_THRESHOLD=.04,j([(0,l.M)("LipMakeupLayer"),U("design:type",Function),U("design:paramtypes",[]),U("design:returntype",void 0)],e.prototype,"destroy",null),e}(),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},ue=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ce=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{h(n.next(e))}catch(e){s(e)}}function a(e){try{h(n.throw(e))}catch(e){s(e)}}function h(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}h((n=n.apply(e,t||[])).next())}))},le=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])}}},pe=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.")},fe=(0,_.jl)("makeup-mer"),de=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 ce(this,void 0,void 0,(function(){var e,t,i,n;return le(this,(function(r){switch(r.label){case 0:return this._config?[3,2]:(this._config=new g.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;fe.info("ReuseableLipMask resize",e,t,this._maskSprite),null===(i=this._maskRenderTexture)||void 0===i||i.resize(e,t)},e.prototype._getMask=function(){return ce(this,void 0,void 0,(function(){var e,t,i,n,r,s,a;return le(this,(function(h){switch(h.label){case 0:return this._lipMask?[2,this._lipMask]:(e=this._lipVertex,t=this._config.getDataConfig(29),[4,this._loadLipImage()]);case 1:return i=h.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 ce(this,void 0,Promise,(function(){var e=this;return le(this,(function(t){return[2,new Promise((function(t,i){return ce(e,void 0,void 0,(function(){var e,i,n;return le(this,(function(r){switch(r.label){case 0:return[4,(e=new F.KI).init()];case 1:return i=r.sent(),[4,e.loadImage(i)];case 2:return n=r.sent(),t(n[F.X_]),[2]}}))}))}))]}))}))},he([(0,l.M)("ReuseableLipMask"),ue("design:type",Function),ue("design:paramtypes",[]),ue("design:returntype",void 0)],e.prototype,"destroy",null),he([(0,l.o)("ReuseableLipMask"),ue("design:type",Function),ue("design:paramtypes",[]),ue("design:returntype",Promise)],e.prototype,"_getMask",null),e}(),ye=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 h=new o.jy(o.xE.WHITE);h.alpha=0,h.width=i.width,h.height=i.height,this._container.addChild(h)}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)})));this._lipMakeupLayer&&this._lipMakeupLayer.updateMeshVertex(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),this._makeupMeshes.forEach((function(e){e.updateIrisFeather()}))),(0,c.Sp)(e[98],e[102])<.03*(0,c.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),this._lipMakeupLayer&&this._lipMakeupLayer.updateLandmarks(e))},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 ce(this,void 0,void 0,(function(){var e,t,i,n,r,s,o,a,h,u;return le(this,(function(c){switch(c.label){case 0:return this._config=new g.M,[4,this._config.load()];case 1:if(c.sent(),e=this._data,fe.info("makeup info",this._data),t=[],!e||!e.length)return[3,3];i=null;try{for(n=pe(e),r=n.next();!r.done;r=n.next())"iris"===(s=r.value).type?(fe.info("generate iris layer",s),this._irises=this._getIris(this.getFilename(s.src,s.parentKey),s.blend,s.intensity,s.parentKey,s.parentIntensity),this.irisBlendMode=s.blend):"lipstick"===s.type?i=s:(s.blend+"",t.push({src:this.getFilename(s.src,s.parentKey),intensity:s.intensity,type:s.type,blend:s.blend,parentIntensity:s.parentIntensity,parentKey:s.parentKey}))}catch(e){h={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(h)throw h.error}}return fe.info("makeupLayersByBlendMode",t),(t.length>0||this._irises)&&(o=this._getMeshLayerByBlendMode(t),this._makeupMeshes.push(o)),i?(fe.info("generate lipstick layer",i),(a=new ae(this._options,this._container,this.renderer)).parentKey=i.parentKey||"",a.parentIntensity=i.parentIntensity||1,[4,a.init(i)]):[3,3];case 2:c.sent(),this._lipMakeupLayer=a,c.label=3;case 3:return[4,this._initLipMask()];case 4:return c.sent(),[2]}}))}))},e.prototype.getFilename=function(e,t){return"default"===t?e:"".concat(t,"|").concat(e)},e.prototype.updateLipstickConfig=function(e){return!!this._lipMakeupLayer&&(this._lipMakeupLayer.updateParams({color:e.color,intensity:e.intensity,satinLevel:e.satinLevel,shimmerLevel:e.shimmerLevel,glossLevel:e.glossLevel}),!0)},e.prototype.setParentIntensity=function(e,t){fe.info("setParentIntensity",e,t),this._makeupMeshes.forEach((function(i){i.setParentIntensityAt(e,t)})),this._irises&&this._irises.parentKey===e&&(this._irises.parentIntensity=t),this._lipMakeupLayer&&this._lipMakeupLayer.parentKey===e&&(this._lipMakeupLayer.parentIntensity=t)},e.prototype._getIris=function(e,t,i,n,r){return new O(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 P(this._options,this._container,this.renderer,t);this._irises&&(i.irisRenderTexture=this._irises.renderTexture.baseTexture,i.irisBlendMode=this.irisBlendMode,i.irisLayerRef=this._irises);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,r;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),null===(r=this._lipMakeupLayer)||void 0===r||r.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 fe.info("_applyMakeup failed: container is null");this._applyed=!0,e.filters||(e.filters=[]);try{e.addChild(this._container)}catch(e){fe.info("_applyMakeup error",e)}}},e.prototype._removeMakeup=function(e){if(this._applyed){if(!e)return fe.info("_removeMakeup failed: container is null");this._applyed=!1,e.filters&&e.removeChild(this._container)}},e.prototype._initLipMask=function(){return ce(this,void 0,void 0,(function(){var e,t,i=this;return le(this,(function(n){switch(n.label){case 0:return(e=new de(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)})),this._lipMakeupLayer&&this.mouthShut,[2]}}))}))},e.prototype.destroy=function(){fe.info("makeup destroy"),this.remove(),this._makeupMeshes.forEach((function(e){return e.destroy()})),this._makeupMeshes=[],this._irises&&this._irises.destroy(),this._irises=null,this._lipMakeupLayer&&this._lipMakeupLayer.destroy(),this._lipMakeupLayer=null,this._container.destroy(),this._target=null,this._lipMaskIns&&this._lipMaskIns.destroy()},he([(0,l.M)("Makeup"),ue("design:type",Function),ue("design:paramtypes",["function"==typeof(t=void 0!==o.W2&&o.W2)?t:Object]),ue("design:returntype",void 0)],e.prototype,"_removeMakeup",null),he([(0,l.M)("Makeup"),ue("design:type",Function),ue("design:paramtypes",[]),ue("design:returntype",void 0)],e.prototype,"destroy",null),e}(),_e=i(7959),me=function(){return me=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},me.apply(this,arguments)},ge=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{h(n.next(e))}catch(e){s(e)}}function a(e){try{h(n.throw(e))}catch(e){s(e)}}function h(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}h((n=n.apply(e,t||[])).next())}))},ve=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])}}},be=(0,_.jl)("makeup-merge-hub"),ke=function(){function e(){this._visible=!0,this._makeupConfigs={},this._lastFinalConfigLength=0,this._lastNonLipstickConfig="",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]&&(be.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=me(me({},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._isOnlyLipstickChanged=function(e){var t=JSON.stringify(e.filter((function(e){return"lipstick"!==e.type})).map((function(e){return{type:e.type,src:e.src,blend:e.blend,intensity:e.intensity,parentKey:e.parentKey,parentIntensity:e.parentIntensity}})));if(""===this._lastNonLipstickConfig)return this._lastNonLipstickConfig=t,!1;var i=t===this._lastNonLipstickConfig;return this._lastNonLipstickConfig=t,i},e.prototype.generateMakeup=function(e,t,i,n){return ge(this,void 0,void 0,(function(){var r,s;return ve(this,(function(o){switch(o.label){case 0:return r=this.generateFinalConfig(),be.info("generateMakeup",r),_e.s.checkEnabled("beautify")?r.length?[4,(s=new ye("merged-".concat((new Date).getTime()),r,v.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 ge(this,void 0,void 0,(function(){var r,s,o;return ve(this,(function(a){switch(a.label){case 0:return _e.s.checkEnabled("beautify")?(r=this.generateFinalConfig(),s=r.filter((function(e){return"lipstick"===e.type})),this.currentMakeupInstance&&1===s.length&&r.length===this._lastFinalConfigLength&&this._isOnlyLipstickChanged(r)&&this.currentMakeupInstance.updateLipstickConfig(s[0])?(be.info("lipstick fast update path"),[2]):(this._lastFinalConfigLength=r.length,[4,this.generateMakeup(e,t,i,n)])):[2];case 1:return(o=a.sent())?(this.mesh=e,this.faceLandMarks=t,this.lipmesh=i,this.currentMakeupInstance&&this.currentMakeupInstance.destroy(),o&&(this.currentMakeupInstance=o),this._applied&&this.currentMakeupInstance.apply(this._target),[2]):(this.currentMakeupInstance&&this.currentMakeupInstance.destroy(),this._applied=!1,[2])}}))}))},e.prototype.updateMakeupConfigShortcut=function(e){return ge(this,void 0,void 0,(function(){return ve(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){be.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 xe=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 we=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)}}(),Se=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},Me=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Te=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{h(n.next(e))}catch(e){s(e)}}function a(e){try{h(n.throw(e))}catch(e){s(e)}}function h(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}h((n=n.apply(e,t||[])).next())}))},Ce=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])}}},Ee=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.")},Re=(0,_.jl)("Effect"),Le=function(){function e(e,t,i,n,r,s,o,a,h,u,c){this.type="face",this._filters=[],this._destroyed=!1,this._visible=!0,this._intensity=1,this._filterIntensity=1,this.localSpriteSheets={},this._filtersActived=!0,this.makeupConfig=[],Re.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,h&&(this.angles=h),void 0!==u&&(this.intensity=u),this._app3d=n,this._canvas=c}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&&(ke.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,ke.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,ke.instance.mesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lipmesh",{set:function(e){this._destroyed||(this._lipVertex=e,ke.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,ke.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 Te(this,void 0,Promise,(function(){var e;return Ce(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 Te(this,void 0,Promise,(function(){var t,i,n,r,s,o;return Ce(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 Te(this,void 0,void 0,(function(){return Ce(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 Te(this,void 0,void 0,(function(){var e;return Ce(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 Te(this,void 0,Promise,(function(){var e,t,i,n,r,s,o,a;return Ce(this,(function(h){switch(h.label){case 0:return[4,this._getConfig()];case 1:e=h.sent(),t=e.makeup,i=!1;try{for(n=Ee(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.hasLipstickMakeup=function(){return Te(this,void 0,Promise,(function(){var e,t;return Ce(this,(function(i){switch(i.label){case 0:return[4,this._getConfig()];case 1:return e=i.sent(),(t=e.makeup)?[2,t.some((function(e){return"lipstick"===e.type}))]:[2,!1]}}))}))},e.prototype.needDetection=function(){return Te(this,void 0,Promise,(function(){var e,t,i,n;return Ce(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 Te(this,void 0,Promise,(function(){var e,t;return Ce(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 Te(this,void 0,Promise,(function(){var t;return Ce(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=[]),Te(this,void 0,Promise,(function(){return Ce(this,(function(e){return[2]}))}))},e.prototype.load3d=function(e){return Te(this,void 0,void 0,(function(){return Ce(this,(function(e){return[2]}))}))},e.prototype.initThreeApp=function(){return Te(this,void 0,void 0,(function(){return Ce(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();ke.instance.addMakeupConfig(this._key,e,this.intensity),this.makeupConfig=e},e.prototype.resize=function(e,t){ke.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,ke.instance.MakeupConfigExist(this._key)||ke.instance.addMakeupConfig(this._key,this.makeupConfig,this.intensity),ke.instance.setMakeupConfigVisible(this._key,!0),ke.instance.updateMakeupFilter(this._meshVertex,this.faceLandMarks,this._lipVertex,this.renderer).then((function(){Re.info("merged makeup updated,start apply"),ke.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),ke.instance.removeMakeupConfig(this._key),e||ke.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(){ke.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=xe.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(),h={};this.localSpriteSheets=h;try{for(var u=Ee(s),c=u.next();!c.done;c=u.next()){var l=c.value;if(l.src)if(l.src instanceof Array)l.src.forEach((function(e,t){var i=n.checkSpriteSheetJSON(e);if(i){var r=i.meta.image,s="".concat(n._key,"|").concat(r);if(xe.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="",h[s]=i}else{if(xe.getInstance().addRef(e),o.P6.kN[e])return;if(a.resources[e])return;a.add(e,e)}}));else{var p="".concat(this._key,"|").concat(l.src);if(xe.getInstance().addRef(p),o.P6.kN[p])continue;if(0===l.src.indexOf("blob:")){var f=o.xE.from(l.src);o.xE.addToCache(f,p)}else a.add(p,l.src)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(t)throw t.error}}return new Promise((function(e){a.load((function(t,i){return Te(n,void 0,void 0,(function(){var t,n,s,a,u;return Ce(this,(function(c){switch(c.label){case 0:for(s in t=function(e){var t;return Ce(this,(function(i){switch(i.label){case 0:return r.iV[e]?[2,"continue"]:h[e]?(t=new o.c2(o.P6.kN[e],h[e],"@".concat((0,m.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,c.label=1;case 1:return a<n.length?(u=n[a],[5,t(u)]):[3,4];case 2:c.sent(),c.label=3;case 3:return a++,[3,1];case 4:for(u in i)r.iV[u]||h[u]||(r.iV[u]=i[u]);return e(),[2]}}))}))}))}))},e.prototype.checkSpriteSheetJSON=function(e){try{return JSON.parse(e)}catch(e){return null}},Se([(0,l.M)("Effect"),Me("design:type",Function),Me("design:paramtypes",[Boolean]),Me("design:returntype",void 0)],e.prototype,"remove",null),Se([(0,l.M)("Effect"),Me("design:type",Function),Me("design:paramtypes",[Boolean]),Me("design:returntype",void 0)],e.prototype,"destroy",null),Se([(0,l.M)("Effect"),Me("design:type",Function),Me("design:paramtypes",["function"==typeof(t=void 0!==o.W2&&o.W2)?t:Object]),Me("design:returntype",void 0)],e.prototype,"_removeFilter",null),e}(),Ie=function(e){function t(t,i,n,r,s,o,a,h){var u=e.call(this,"default",i,n,r,s,o,a,h)||this;return u._json=t,u._app3d=r,u}return we(t,e),t.prototype.load=function(e){return Te(this,void 0,Promise,(function(){var t,i,n,r,s,o;return Ce(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 Te(this,void 0,void 0,(function(){return Ce(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||[]),h={},u=function(e){if(!e.src)return"continue";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 xe.getInstance().addRef(u);if(e.objectSrc&&e.objectSrc.length){var c=o.xE.from(e.objectSrc[i]);o.xE.addToCache(c,u),xe.getInstance().addRef(u)}else if(0===a.indexOf("blob:")){c=o.xE.from(a);o.xE.addToCache(c,u)}else s.add(u,a);r.meta.image="",h[u]=r}else{if(o.P6.kN[t])return;if(s.resources[t])return;if(e.objectSrc&&e.objectSrc.length){c=o.xE.from(e.objectSrc[i],{resolution:(0,m.u)()});o.xE.addToCache(c,t)}else s.add(t,t)}}));else{if(xe.getInstance().addRef(e.src),o.P6.kN[e.src])return"continue";if(s.resources[e.src])return Re.info("already loaded file",e.src),"continue";if(e.objectSrc){Re.info("use imagebitmap to create texture");var t=o.xE.from(e.objectSrc);o.xE.addToCache(t,e.src),xe.getInstance().addRef(e.src)}else if(0===e.src.indexOf("blob:")){t=o.xE.from(e.src);Re.info("JSONEffect blob texture",t),o.xE.addToCache(t,e.src),xe.getInstance().addRef(e.src)}else s.add(e.src)}};try{for(var c=Ee(a),l=c.next();!l.done;l=c.next()){u(l.value)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(t)throw t.error}}return new Promise((function(e){return Te(n,void 0,void 0,(function(){var t=this;return Ce(this,(function(i){return s.load((function(i,n){return Te(t,void 0,void 0,(function(){var t,i,s,a,u;return Ce(this,(function(c){switch(c.label){case 0:for(s in t=function(e){var t;return Ce(this,(function(i){switch(i.label){case 0:return r.iV[e]?[2,"continue"]:h[e]?(t=new o.c2(o.P6.kN[e],h[e],"@".concat((0,m.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,c.label=1;case 1:return a<i.length?(u=i[a],[5,t(u)]):[3,4];case 2:c.sent(),c.label=3;case 3:return a++,[3,1];case 4:for(u in n)r.iV[u]||h[u]||(r.iV[u]=n[u]);return e(),[2]}}))}))})),[2]}))}))}))},t.prototype.loadSticker3d=function(e){return Te(this,void 0,Promise,(function(){return Ce(this,(function(e){return[2]}))}))},t}(Le),Pe=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)}}(),Oe=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},Fe=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},je=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{h(n.next(e))}catch(e){s(e)}}function a(e){try{h(n.throw(e))}catch(e){s(e)}}function h(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}h((n=n.apply(e,t||[])).next())}))},Ue=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])}}},Ve=((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 je(this,void 0,Promise,(function(){var e;return Ue(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 je(this,void 0,Promise,(function(){var e,t;return Ue(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 je(this,void 0,void 0,(function(){return Ue(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 je(this,void 0,void 0,(function(){var e;return Ue(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 je(this,void 0,void 0,(function(){return Ue(this,(function(e){return[2]}))}))},e.prototype.initThreeApp=function(){return je(this,void 0,void 0,(function(){return Ue(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=xe.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}},Oe([(0,l.M)("Effect"),Fe("design:type",Function),Fe("design:paramtypes",[]),Fe("design:returntype",void 0)],e.prototype,"remove",null),Oe([(0,l.M)("Effect"),Fe("design:type",Function),Fe("design:paramtypes",[]),Fe("design:returntype",void 0)],e.prototype,"destroy",null),e}()),Ae=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 Pe(t,e),t.prototype.load=function(){return je(this,void 0,Promise,(function(){var e,t;return Ue(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 je(this,void 0,void 0,(function(){return Ue(this,(function(e){return[2]}))}))},t.prototype.loadSticker3d=function(e){return je(this,void 0,Promise,(function(){return Ue(this,(function(e){return[2]}))}))},t.prototype.loadHand3d=function(e){return je(this,void 0,Promise,(function(){return Ue(this,(function(e){return[2]}))}))},t}(Ve),Ge=i(5156),Ne=i(6309),De=i(5562),ze=(0,_.jl)("videoFrameTextureManager"),We=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 ze.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){ze.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,h=a.CONTEXT_UID||0;s._glTextures[h]||(s._glTextures[h]=a.texture.initTexture(s));var u=s._glTextures[h];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){ze.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(){ze.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}(),Be=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},Ke=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Je=function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{h(n.next(e))}catch(e){s(e)}}function a(e){try{h(n.throw(e))}catch(e){s(e)}}function h(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}h((n=n.apply(e,t||[])).next())}))},Xe=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])}}},qe=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 Ze=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,m.u)(),o.Xd.FILTER_RESOLUTION=(0,m.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 Be(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 Je(this,void 0,Promise,(function(){var e;return Xe(this,(function(t){switch(t.label){case 0:return e=new Ne.e({}),Ye.info("loader init"),[4,e.init()];case 1:return t.sent(),Ye.info("loader init done"),this._options.plugin3d&&this._options.plugin3d(Le,Ie,e,wx.window),[2]}}))}))},t.prototype.loadHand3d=function(){return Je(this,void 0,Promise,(function(){var e;return Xe(this,(function(t){switch(t.label){case 0:return e=new Ne.e({}),Ye.info("+++++loader init"),[4,e.init()];case 1:return t.sent(),Ye.info("+++++loader init done"),this._options.plugin3d&&this._options.pluginHand(Ve,Ae,e,wx.window),[2]}}))}))},t.prototype.setup=function(){return Je(this,void 0,void 0,(function(){return Xe(this,(function(e){switch(e.label){case 0:return this._setup?[2]:(this._config=new g.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:v.t.instance.options.width,height:v.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,h=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&&_e.s.checkEnabled("beautify")&&"Sticker"===this._mode3d||_e.s.checkEnabled("beautify")&&"AR"===this._mode3d||_e.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 c=a,l=c.width,p=c.height,f=c.data;if(this._baseSprite){if(this._baseSprite.texture.width===l&&this._baseSprite.texture.height===p)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),l,p)}else{var d=o.xE.fromBuffer(new Uint8Array(f),l,p);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/l,this._options.height/p);this._baseSprite.scale.set(y*(0,m.u)()),this._makeupContainer.addChild(this._baseSprite)}}(_e.s.checkEnabled("beautify")||_e.s.checkEnabled("segmentation")||_e.s.checkEnabled("hair"))&&(e.prototype.setMesh.call(this,r),e.prototype.setReshapeMarks.call(this,n),n&&n.length?(this._faceLandmarks=n,this._angles=h,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=h,e.faceLandMarks=n,e.tick()})),"Sticker"===this._mode3d&&this._app3d&&this._app3d.loaded&&(this._app3d.facelandmarks=n,this._app3d.angles=h)):(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(),_e.s.checkEnabled("beautify")&&"Sticker"===this._mode3d&&this._app3d&&this._app3d.loaded&&this._app3d.render(),_e.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,ke.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,ke.instance.updateMakeupConfigShortcut(this._renderer)):this._baseSprite.texture.baseTexture.resource.data=e.data}else{var a=this._baseSprite.texture.baseTexture.resource,h=a.source;if(h.width!==e.width||h.height!==e.height){r=this._baseSprite.texture;this._baseSprite.texture=o.xE.from(e),r!==this._baseSprite.texture&&($e.baseTexture=this._baseSprite.texture,ke.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 We(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=v.t.instance.options.mirror?[this.mirrorFilter]:[],v.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=v.t.instance.options,a=s.width,u=s.height,c="data"in i?o.xE.fromBuffer(new Uint8Array(i.data.buffer),i.width,i.height):o.xE.from(i),l=new h.jy(c);"video"===n&&(l.blendMode_1=6),l.width=a,l.height=u,l.id=r,t&&(l.zIndex=t),this._frontContainer.addChild(l)},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*v.t.instance.options.width,this.points[i].y=e[i].y*v.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 Je(this,void 0,Promise,(function(){var r,s=this;return Xe(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 Je(this,void 0,Promise,(function(){var s,o=this;return Xe(this,(function(a){return _.b_.time("AI init duration"),_e.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,h){return Je(o,void 0,void 0,(function(){var o,h,u,c,l,p,f,d,y,m,g,v,b,k,x,w,S,M=this;return Xe(this,(function(T){switch(T.label){case 0:for(o=[].concat(this._effects),h=[],u=[],c=[],l=[],p=[],f=[],d=[],y=[],e.length||(this.filterActivedEffect=null),m=[],g=function(n){var s=o.findIndex((function(t){return t.url===e[n]}));if(s>-1)h.push(o[s]),o[s],u.push(t[n]),c.push(i[n]),o.splice(s,1);else{var a=e[n];y.push(function(e){return Je(this,void 0,Promise,(function(){var t,i;return Xe(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)),m.push(a),p.push(t[n]),f.push(i[n])}},v=0;v<e.length;v++)g(v);return[4,Promise.all(y)];case 1:for(b=T.sent(),!1,k=!1,x=0;x<b.length;x++)w=m[x],S=void 0,(S=new Le(w,this._makeupContainer,this._finalContainer,this._app3d,this._options,this._meshVertex,this._faceLandmarks,this.lipVertex,this._angles,p[x],this._canvas)).filterIntensity=f[x],b[x].sticker3d&&b[x].sticker3d.length&&(k=!0),S.renderer=this._renderer,l.push(S);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:T.sent(),this.lib3dLoaded=!0,T.label=3;case 3:return _.b_.timeEnd("require 3d lib"),l.forEach((function(e){d.push(e.load((function(e){e&&(M.need3dRefresh=!0)})).then((function(){return e.intensity=e.intensity,M._app3d||"face"!==e.type||(M._app3d=e.app3d),M._appHand3d||"hand"!==e.type||(M._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<l.length;i++){var n=l[i];M.latestEffectUrls&&-1===M.latestEffectUrls.indexOf(n.getUrl())&&(n.destroy(!0),t=!0)}if(t)Ye.info(s+"end");else{o.forEach((function(e){e.remove(!0)})),M._effects=h,h.forEach((function(e,t){e.intensity=u[t],e.filterIntensity=c[t]}));for(i=0;i<l.length;i++){n=l[i];M._effects.push(n),n.apply({filterTarget:M._makeupContainer,filterCallback:function(){}})}o.forEach((function(e){e.destroy(!0)})),_.b_.timeEnd("renderer apply effect"),(l.length||o.length)&&ke.instance.updateMakeupConfigShortcut(M._renderer),a(M._effects)}})),[2]}}))}))}))])}))}))},t.prototype.setEffectJSON=function(e){return Je(this,void 0,void 0,(function(){var t,i,n,r,s,o,a,h,u,c,l,p,f,d,y=this;return Xe(this,(function(_){switch(_.label){case 0:return i=e.makeup,n=e.filter,r=e.sticker,s=e.sticker3d,o=e.hand,a=i?i.filter((function(e){return"lipstick"===e.type})):[],h=i?i.filter((function(e){return"lipstick"!==e.type})):[],u=1===a.length&&0===h.length,c=!(n&&n.length||r&&r.length||s&&s.length||o&&o.length),l=ke.instance.currentMakeupInstance,p=l&&0===l._makeupMeshes.length,u&&c&&p&&this._effects.length>0&&l&&l.updateLipstickConfig(a[0])?[2]:s&&s.length&&!this.lib3dLoaded?(Ye.info("require 3d lib"),[4,this.loadLib3d()]):[3,2];case 1:_.sent(),this.lib3dLoaded=!0,_.label=2;case 2:return o&&o.length&&!this.libHand3dLoaded?(Ye.info("require 3d hand lib"),[4,this.loadHand3d()]):[3,4];case 3:_.sent(),this.libHand3dLoaded=!0,_.label=4;case 4:return f=!1,(d=function(){_e.s.checkEnabled("beautify")&&y._meshVertex&&(t&&clearTimeout(t),f=!0,y.getJSONEffectForFace(e)),_e.s.checkEnabled("handLandmark")&&o&&o.length&&(f=!0,y.getJSONEffectForHand(e)),f||(t=setTimeout(d,20))})(),[2]}}))}))},t.prototype.getJSONEffectForHand=function(e){var t=this,i=new Ae(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;console.log("zy sdk getJSONEffectForFace",e);var i=[].concat(this._effects);this._effects=[],i.forEach((function(e){e.destroy()}));var n=new Ie(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 Le(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 Je(this,void 0,void 0,(function(){return Xe(this,(function(e){return[2]}))}))},t.prototype.setAvatar=function(e,t){return Je(this,void 0,void 0,(function(){return Xe(this,(function(e){return[2]}))}))},t.prototype.registerAvatar=function(e){},t.prototype.reCorrectAvatar=function(){return Je(this,void 0,void 0,(function(){return Xe(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 Je(this,void 0,Promise,(function(){var t,i,n,s,o,a,h;return Xe(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=qe(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&&(h=n.return)&&h.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 Ge.Z(r);s.zIndex=20;var o=this._options,a=o.width,h=o.height;s.x=a/2,s.y=h/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),ke.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,l.M)("ArRenderer"),Ke("design:type",Function),Ke("design:paramtypes",[Object]),Ke("design:returntype",void 0)],t.prototype,"destroy",null),t}(De.F)}}]);