Built@main artplayer-plugin-danmuku-mask

This commit is contained in:
Harvey Zack committed 2024-10-08 11:57:45 +08:00
1 parent 7a1240b889
commit e9d544f416
5 files changed
+33 -1

No files matched your search

@@ -0,0 +1,8 @@
/*!
* artplayer-plugin-danmuku-mask.js v1.0.0
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2024 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,n,s){var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},o="function"==typeof a[n]&&a[n],l=o.cache||{},i="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,r){if(!l[t]){if(!e[t]){var s="function"==typeof a[n]&&a[n];if(!r&&s)return s(t,!0);if(o)return o(t,!0);if(i&&"string"==typeof t)return i(t);var p=Error("Cannot find module '"+t+"'");throw p.code="MODULE_NOT_FOUND",p}d.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},d.cache={};var c=l[t]=new u.Module(t);e[t][0].call(c.exports,d,c,c.exports,this)}return l[t].exports;function d(e){var t=d.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=l,u.parent=o,u.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return a[n]}}),a[n]=u;for(var p=0;p<t.length;p++)u(t[p]);if(r){var c=u(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=c:"function"==typeof define&&define.amd&&define(function(){return c})}}({"3nz8g":[function(e,t,r){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",()=>o);var s=e("@tensorflow/tfjs-core");e("@tensorflow/tfjs-backend-webgl"),e("@tensorflow/tfjs-backend-cpu");var a=e("@tensorflow-models/body-segmentation");function o(e={}){return t=>{let{template:{$player:r,$video:n,$danmuku:o}}=t,l=null,i=null,u=null,p=null,c=!1,d={solutionPath:e.solutionPath||"https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation",modelSelection:e.modelSelection||1,smoothSegmentation:void 0===e.smoothSegmentation||e.smoothSegmentation,minDetectionConfidence:e.minDetectionConfidence||.5,minTrackingConfidence:e.minTrackingConfidence||.5,selfieMode:e.selfieMode||!1,drawContour:e.drawContour||!1,foregroundThreshold:e.foregroundThreshold||.5,opacity:e.opacity||1,maskBlurAmount:e.maskBlurAmount||3};async function f(){try{await s.setBackend("webgl"),console.log("Using WebGL backend")}catch(e){console.warn("WebGL backend not available, falling back to CPU"),await s.setBackend("cpu")}}async function h(){await f();let e=a.SupportedModels.MediaPipeSelfieSegmentation,t={runtime:"mediapipe",modelType:"general",solutionPath:d.solutionPath,modelSelection:d.modelSelection,smoothSegmentation:d.smoothSegmentation,minDetectionConfidence:d.minDetectionConfidence,minTrackingConfidence:d.minTrackingConfidence,selfieMode:d.selfieMode};try{l=await a.createSegmenter(e,t),c=!0,console.log("Segmenter initialized successfully")}catch(e){console.error("Error initializing segmenter:",e),c=!1}}async function m(){if(!c||n.paused||n.ended){p=requestAnimationFrame(m);return}try{i.width=n.videoWidth,i.height=n.videoHeight;let e=await l.segmentPeople(n);if(!e||0===e.length){p=requestAnimationFrame(m);return}let t=await a.toBinaryMask(e,{r:255,g:255,b:255,a:255},{r:0,g:0,b:0,a:255},d.drawContour,d.foregroundThreshold);await a.drawMask(i,n,t,d.opacity,d.maskBlurAmount);let r=u.getImageData(0,0,i.width,i.height);u.putImageData(function(e){let t=e.data;for(let e=0;e<t.length;e+=4)t[e]>250&&t[e+1]>250&&t[e+2]>250&&(t[e+3]=0);return e}(r),0,0),o.style.maskImage=`url(${i.toDataURL()})`}catch(e){console.error("Error in segmentBody:",e)}p=requestAnimationFrame(m)}async function g(){c||await h(),i||(u=(i=document.createElement("canvas")).getContext("2d"),Object.assign(i.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",opacity:"0"}),r.appendChild(i)),Object.assign(o.style,{maskMode:"alpha",maskSize:"contain",maskRepeat:"no-repeat",backgroundSize:"contain",backgroundRepeat:"no-repeat"}),m()}function x(){o.style.maskImage="none",p&&(cancelAnimationFrame(p),p=null)}return t.on("ready",g),t.on("destroy",x),{name:"artplayerPluginDanmukuMask",start:g,stop:x}}}"undefined"!=typeof window&&(window.artplayerPluginDanmukuMask=o)},{"@tensorflow/tfjs-core":"2nuhV","@tensorflow/tfjs-backend-webgl":"2cOos","@tensorflow/tfjs-backend-cpu":"61SaF","@tensorflow-models/body-segmentation":"79Ppz","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],"2nuhV":[function(e,t,r){/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */var n=e("@parcel/transformer-js/src/esmodule-helpers.js"Line truncated
@@ -0,0 +1,8 @@
/*!
* artplayer-plugin-danmuku-mask.js v1.0.0
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2024 Harvey Zack
* Released under the MIT License.
*/
!function(e,r,t,n,a){var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof o[n]&&o[n],i=s.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(r,t){if(!i[r]){if(!e[r]){var a="function"==typeof o[n]&&o[n];if(!t&&a)return a(r,!0);if(s)return s(r,!0);if(l&&"string"==typeof r)return l(r);var c=Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}f.resolve=function(t){var n=e[r][1][t];return null!=n?n:t},f.cache={};var p=i[r]=new u.Module(r);e[r][0].call(p.exports,f,p,p.exports,this)}return i[r].exports;function f(e){var r=f.resolve(e);return!1===r?{}:u(r)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=i,u.parent=s,u.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]},Object.defineProperty(u,"root",{get:function(){return o[n]}}),o[n]=u;for(var c=0;c<r.length;c++)u(r[c]);if(t){var p=u(t);"object"==typeof exports&&"undefined"!=typeof module?module.exports=p:"function"==typeof define&&define.amd&&define(function(){return p})}}({laCzO:[function(e,r,t){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(t),n.export(t,"default",function(){return l});var a=e("@swc/helpers/_/_async_to_generator"),o=e("@swc/helpers/_/_ts_generator"),s=e("@tensorflow/tfjs-core");e("@tensorflow/tfjs-backend-webgl"),e("@tensorflow/tfjs-backend-cpu");var i=e("@tensorflow-models/body-segmentation");function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(r){var t=r.template,n=t.$player,l=t.$video,u=t.$danmuku,c=null,p=null,f=null,d=null,h=!1,m={solutionPath:e.solutionPath||"https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation",modelSelection:e.modelSelection||1,smoothSegmentation:void 0===e.smoothSegmentation||e.smoothSegmentation,minDetectionConfidence:e.minDetectionConfidence||.5,minTrackingConfidence:e.minTrackingConfidence||.5,selfieMode:e.selfieMode||!1,drawContour:e.drawContour||!1,foregroundThreshold:e.foregroundThreshold||.5,opacity:e.opacity||1,maskBlurAmount:e.maskBlurAmount||3};function g(){return(g=(0,a._)(function(){return(0,o._)(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,4]),[4,s.setBackend("webgl")];case 1:return e.sent(),console.log("Using WebGL backend"),[3,4];case 2:return e.sent(),console.warn("WebGL backend not available, falling back to CPU"),[4,s.setBackend("cpu")];case 3:return e.sent(),[3,4];case 4:return[2]}})})).apply(this,arguments)}function v(){return(v=(0,a._)(function(){var e,r;return(0,o._)(this,function(t){switch(t.label){case 0:return[4,function(){return g.apply(this,arguments)}()];case 1:t.sent(),e=i.SupportedModels.MediaPipeSelfieSegmentation,r={runtime:"mediapipe",modelType:"general",solutionPath:m.solutionPath,modelSelection:m.modelSelection,smoothSegmentation:m.smoothSegmentation,minDetectionConfidence:m.minDetectionConfidence,minTrackingConfidence:m.minTrackingConfidence,selfieMode:m.selfieMode},t.label=2;case 2:return t.trys.push([2,4,,5]),[4,i.createSegmenter(e,r)];case 3:return c=t.sent(),h=!0,console.log("Segmenter initialized successfully"),[3,5];case 4:return console.error("Error initializing segmenter:",t.sent()),h=!1,[3,5];case 5:return[2]}})})).apply(this,arguments)}function _(){return x.apply(this,arguments)}function x(){return(x=(0,a._)(function(){var e,r,t,n,a;return(0,o._)(this,function(o){switch(o.label){case 0:if(!h||l.paused||l.ended)return d=requestAnimationFrame(_),[2];o.label=1;case 1:return o.trys.push([1,5,,6]),p.width=l.videoWidth,p.height=l.videoHeight,[4,c.segmentPeople(l)];case 2:if(!(e=o.sent())||0===e.length)return d=requestAnimationFrame(_),[2];return r={r:255,g:255,b:255,a:255},t={r:0,g:0,b:0,a:255},[4,i.toBinaryMask(e,r,t,m.drawContour,m.foregroundThreshold)];case 3:return n=o.sent(),[4,i.drawMask(p,l,n,m.opacity,m.maskBlurAmount)];case 4:return o.sent(),a=f.getImageData(0,0,p.width,p.height),f.putImageData(function(e){for(var r=e.data,t=0;t<r.length;t+=4)r[t]>250&&r[t+1]>250&&r[t+2]>250&&(r[t+3]=0);return e}(a),0,0),u.style.maskImage="url(".concat(p.toDataURL(),")"),[3,6];case 5:return console.error("Error in segmentBody:",o.sent()),[3,6];case 6:return d=requestAnimationFrame(_),[2]}})})).apply(this,arguments)}function y(){return b.apply(this,arguments)}function b(){return(b=(0,a._)(function(){return(0,o._)(this,function(e){switch(e.label){case 0:if(h)return[3,2];return[4,function(){return v.apply(this,arguments)}()];case 1:e.sent(),e.label=2;case 2:return p||(f=(p=document.createElement("canvas")).getContext("2d"),Object.assign(p.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",opacity:"0"}),n.appendChild(p)),Object.assign(u.style,{maskMode:"alpha",maskSize:"contain",maskRepeat:"no-repeat",backgroundSize:"contain",backgroundRepeat:"no-repeat"}),_(),[2]}})})).apply(this,arguments)}functLine truncated
@@ -1 +1 @@
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAKwB;AALxB;AACA;AACA;AACA;AAEe,SAAS,2BAA2B,SAAS,CAAC,CAAC;IAC1D,OAAO,CAAC;QACJ,MAAM,EACF,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAC1C,GAAG;QAEJ,IAAI,YAAY;QAChB,IAAI,SAAS;QACb,IAAI,MAAM;QACV,IAAI,mBAAmB;QACvB,IAAI,gBAAgB;QAEpB,MAAM,SAAS;YACX,cAAc,OAAO,YAAY,IAAI;YACrC,gBAAgB,OAAO,cAAc,IAAI;YACzC,oBAAoB,OAAO,kBAAkB,KAAK,YAAY,OAAO,kBAAkB,GAAG;YAC1F,wBAAwB,OAAO,sBAAsB,IAAI;YACzD,uBAAuB,OAAO,qBAAqB,IAAI;YACvD,YAAY,OAAO,UAAU,IAAI;YACjC,aAAa,OAAO,WAAW,IAAI;YACnC,qBAAqB,OAAO,mBAAmB,IAAI;YACnD,SAAS,OAAO,OAAO,IAAI;YAC3B,gBAAgB,OAAO,cAAc,IAAI;QAC7C;QAEA,eAAe;YACX,IAAI;gBACA,MAAM,UAAG,UAAU,CAAC;gBACpB,QAAQ,GAAG,CAAC;YAChB,EAAE,OAAO,GAAG;gBACR,QAAQ,IAAI,CAAC;gBACb,MAAM,UAAG,UAAU,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AAA;QAExC,IAAA,CAAA,cAAc,GAAG;QACjB,IAAA,CAAA,QAAQ,GAAG;QACX,IAAA,CAAA,UAAU,GAAG;QACb,IAAA,CAAA,gBAAgB,GAAG;QACnB,IAAA,CAAA,cAAc,GAAG;QAGjB,oEAAoE;QACpE,yEAAyE;QACzE,2EAA2E;QAC3E,IAAA,CAAA,aAAa,GAAG;QAChB,8EAA8E;QAC9E,gBAAgB;QAChB,IAAA,CAAA,WAAW,GAAG;QAId,IAAA,CAAA,UAAU,GAAiB,EAAE;QAC7B;;;SAGG,GACH,IAAA,CAAA,iBAAiB,GAAa,EAAE;QAChC,IAAA,CAAA,WAAW,GAAG;QAEd,IAAA,CAAA,UAAU,GAAG,IAAI;QAOjB,IAAA,CAAA,SAAS,GAAG;QACZ,IAAA,CAAA,aAAa,GAAgB;YAC3B,UAAU;YACV,YAAY;YACZ,WAAW;YACX,SAAS,EAAE;YACX,QAAQ;YACR,IAAI,eAAJ;gBAEM,OAAO,MAAM,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA,IAAK,EAAE,IAAI;YACxD;QACL;IAOH;IALE,UAAA;QACE,IAAK,MAAM,gBAAgB,IAAI,CAAC,mBAAmB,CACjD,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,OAAO;IAElD;AACD;AAED,MAAa;IAgBX,YAAmB,GAALine truncated
@@ -0,0 +1,8 @@
/*!
* artplayer-plugin-danmuku-mask.js v1.0.0
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2024 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,n,s){var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},o="function"==typeof a[n]&&a[n],l=o.cache||{},i="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,r){if(!l[t]){if(!e[t]){var s="function"==typeof a[n]&&a[n];if(!r&&s)return s(t,!0);if(o)return o(t,!0);if(i&&"string"==typeof t)return i(t);var p=Error("Cannot find module '"+t+"'");throw p.code="MODULE_NOT_FOUND",p}d.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},d.cache={};var c=l[t]=new u.Module(t);e[t][0].call(c.exports,d,c,c.exports,this)}return l[t].exports;function d(e){var t=d.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=l,u.parent=o,u.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return a[n]}}),a[n]=u;for(var p=0;p<t.length;p++)u(t[p]);if(r){var c=u(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=c:"function"==typeof define&&define.amd&&define(function(){return c})}}({"3nz8g":[function(e,t,r){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",()=>o);var s=e("@tensorflow/tfjs-core");e("@tensorflow/tfjs-backend-webgl"),e("@tensorflow/tfjs-backend-cpu");var a=e("@tensorflow-models/body-segmentation");function o(e={}){return t=>{let{template:{$player:r,$video:n,$danmuku:o}}=t,l=null,i=null,u=null,p=null,c=!1,d={solutionPath:e.solutionPath||"https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation",modelSelection:e.modelSelection||1,smoothSegmentation:void 0===e.smoothSegmentation||e.smoothSegmentation,minDetectionConfidence:e.minDetectionConfidence||.5,minTrackingConfidence:e.minTrackingConfidence||.5,selfieMode:e.selfieMode||!1,drawContour:e.drawContour||!1,foregroundThreshold:e.foregroundThreshold||.5,opacity:e.opacity||1,maskBlurAmount:e.maskBlurAmount||3};async function f(){try{await s.setBackend("webgl"),console.log("Using WebGL backend")}catch(e){console.warn("WebGL backend not available, falling back to CPU"),await s.setBackend("cpu")}}async function h(){await f();let e=a.SupportedModels.MediaPipeSelfieSegmentation,t={runtime:"mediapipe",modelType:"general",solutionPath:d.solutionPath,modelSelection:d.modelSelection,smoothSegmentation:d.smoothSegmentation,minDetectionConfidence:d.minDetectionConfidence,minTrackingConfidence:d.minTrackingConfidence,selfieMode:d.selfieMode};try{l=await a.createSegmenter(e,t),c=!0,console.log("Segmenter initialized successfully")}catch(e){console.error("Error initializing segmenter:",e),c=!1}}async function m(){if(!c||n.paused||n.ended){p=requestAnimationFrame(m);return}try{i.width=n.videoWidth,i.height=n.videoHeight;let e=await l.segmentPeople(n);if(!e||0===e.length){p=requestAnimationFrame(m);return}let t=await a.toBinaryMask(e,{r:255,g:255,b:255,a:255},{r:0,g:0,b:0,a:255},d.drawContour,d.foregroundThreshold);await a.drawMask(i,n,t,d.opacity,d.maskBlurAmount);let r=u.getImageData(0,0,i.width,i.height);u.putImageData(function(e){let t=e.data;for(let e=0;e<t.length;e+=4)t[e]>250&&t[e+1]>250&&t[e+2]>250&&(t[e+3]=0);return e}(r),0,0),o.style.maskImage=`url(${i.toDataURL()})`}catch(e){console.error("Error in segmentBody:",e)}p=requestAnimationFrame(m)}async function g(){c||await h(),i||(u=(i=document.createElement("canvas")).getContext("2d"),Object.assign(i.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",opacity:"0"}),r.appendChild(i)),Object.assign(o.style,{maskMode:"alpha",maskSize:"contain",maskRepeat:"no-repeat",backgroundSize:"contain",backgroundRepeat:"no-repeat"}),m()}function x(){o.style.maskImage="none",p&&(cancelAnimationFrame(p),p=null)}return t.on("ready",g),t.on("destroy",x),{name:"artplayerPluginDanmukuMask",start:g,stop:x}}}"undefined"!=typeof window&&(window.artplayerPluginDanmukuMask=o)},{"@tensorflow/tfjs-core":"2nuhV","@tensorflow/tfjs-backend-webgl":"2cOos","@tensorflow/tfjs-backend-cpu":"61SaF","@tensorflow-models/body-segmentation":"79Ppz","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],"2nuhV":[function(e,t,r){/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */var n=e("@parcel/transformer-js/src/esmodule-helpers.js"Line truncated
@@ -0,0 +1,8 @@
/*!
* artplayer-plugin-danmuku-mask.js v1.0.0
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2024 Harvey Zack
* Released under the MIT License.
*/
!function(e,r,t,n,a){var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof o[n]&&o[n],i=s.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(r,t){if(!i[r]){if(!e[r]){var a="function"==typeof o[n]&&o[n];if(!t&&a)return a(r,!0);if(s)return s(r,!0);if(l&&"string"==typeof r)return l(r);var c=Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}f.resolve=function(t){var n=e[r][1][t];return null!=n?n:t},f.cache={};var p=i[r]=new u.Module(r);e[r][0].call(p.exports,f,p,p.exports,this)}return i[r].exports;function f(e){var r=f.resolve(e);return!1===r?{}:u(r)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=i,u.parent=s,u.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]},Object.defineProperty(u,"root",{get:function(){return o[n]}}),o[n]=u;for(var c=0;c<r.length;c++)u(r[c]);if(t){var p=u(t);"object"==typeof exports&&"undefined"!=typeof module?module.exports=p:"function"==typeof define&&define.amd&&define(function(){return p})}}({laCzO:[function(e,r,t){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(t),n.export(t,"default",function(){return l});var a=e("@swc/helpers/_/_async_to_generator"),o=e("@swc/helpers/_/_ts_generator"),s=e("@tensorflow/tfjs-core");e("@tensorflow/tfjs-backend-webgl"),e("@tensorflow/tfjs-backend-cpu");var i=e("@tensorflow-models/body-segmentation");function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(r){var t=r.template,n=t.$player,l=t.$video,u=t.$danmuku,c=null,p=null,f=null,d=null,h=!1,m={solutionPath:e.solutionPath||"https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation",modelSelection:e.modelSelection||1,smoothSegmentation:void 0===e.smoothSegmentation||e.smoothSegmentation,minDetectionConfidence:e.minDetectionConfidence||.5,minTrackingConfidence:e.minTrackingConfidence||.5,selfieMode:e.selfieMode||!1,drawContour:e.drawContour||!1,foregroundThreshold:e.foregroundThreshold||.5,opacity:e.opacity||1,maskBlurAmount:e.maskBlurAmount||3};function g(){return(g=(0,a._)(function(){return(0,o._)(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,4]),[4,s.setBackend("webgl")];case 1:return e.sent(),console.log("Using WebGL backend"),[3,4];case 2:return e.sent(),console.warn("WebGL backend not available, falling back to CPU"),[4,s.setBackend("cpu")];case 3:return e.sent(),[3,4];case 4:return[2]}})})).apply(this,arguments)}function v(){return(v=(0,a._)(function(){var e,r;return(0,o._)(this,function(t){switch(t.label){case 0:return[4,function(){return g.apply(this,arguments)}()];case 1:t.sent(),e=i.SupportedModels.MediaPipeSelfieSegmentation,r={runtime:"mediapipe",modelType:"general",solutionPath:m.solutionPath,modelSelection:m.modelSelection,smoothSegmentation:m.smoothSegmentation,minDetectionConfidence:m.minDetectionConfidence,minTrackingConfidence:m.minTrackingConfidence,selfieMode:m.selfieMode},t.label=2;case 2:return t.trys.push([2,4,,5]),[4,i.createSegmenter(e,r)];case 3:return c=t.sent(),h=!0,console.log("Segmenter initialized successfully"),[3,5];case 4:return console.error("Error initializing segmenter:",t.sent()),h=!1,[3,5];case 5:return[2]}})})).apply(this,arguments)}function _(){return x.apply(this,arguments)}function x(){return(x=(0,a._)(function(){var e,r,t,n,a;return(0,o._)(this,function(o){switch(o.label){case 0:if(!h||l.paused||l.ended)return d=requestAnimationFrame(_),[2];o.label=1;case 1:return o.trys.push([1,5,,6]),p.width=l.videoWidth,p.height=l.videoHeight,[4,c.segmentPeople(l)];case 2:if(!(e=o.sent())||0===e.length)return d=requestAnimationFrame(_),[2];return r={r:255,g:255,b:255,a:255},t={r:0,g:0,b:0,a:255},[4,i.toBinaryMask(e,r,t,m.drawContour,m.foregroundThreshold)];case 3:return n=o.sent(),[4,i.drawMask(p,l,n,m.opacity,m.maskBlurAmount)];case 4:return o.sent(),a=f.getImageData(0,0,p.width,p.height),f.putImageData(function(e){for(var r=e.data,t=0;t<r.length;t+=4)r[t]>250&&r[t+1]>250&&r[t+2]>250&&(r[t+3]=0);return e}(a),0,0),u.style.maskImage="url(".concat(p.toDataURL(),")"),[3,6];case 5:return console.error("Error in segmentBody:",o.sent()),[3,6];case 6:return d=requestAnimationFrame(_),[2]}})})).apply(this,arguments)}function y(){return b.apply(this,arguments)}function b(){return(b=(0,a._)(function(){return(0,o._)(this,function(e){switch(e.label){case 0:if(h)return[3,2];return[4,function(){return v.apply(this,arguments)}()];case 1:e.sent(),e.label=2;case 2:return p||(f=(p=document.createElement("canvas")).getContext("2d"),Object.assign(p.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",opacity:"0"}),n.appendChild(p)),Object.assign(u.style,{maskMode:"alpha",maskSize:"contain",maskRepeat:"no-repeat",backgroundSize:"contain",backgroundRepeat:"no-repeat"}),_(),[2]}})})).apply(this,arguments)}functLine truncated