!function(t,e){"object"==typeofexports&&"undefined"!=typeofmodule?e(exports,require("@tensorflow/tfjs-core"),require("@tensorflow/tfjs-converter")):"function"==typeofdefine&&define.amd?define(["exports","@tensorflow/tfjs-core","@tensorflow/tfjs-converter"],e):e(t.blazeface={},t.tf,t.tf)}(this,function(t,e,n){"use strict";functionr(t,e,n,r){returnnew(n||(n=Promise))(function(o,i){functions(t){try{c(r.next(t))}catch(t){i(t)}}functiona(t){try{c(r.throw(t))}catch(t){i(t)}}functionc(t){vare;t.done?o(t.value):(e=t.value,einstanceofn?e:newn(function(t){t(e)})).then(s,a)}c((r=r.apply(t,e||[])).next())})}functiono(t,e){varn,r,o,i,s={label:0,sent:function(){if(1&o[0])throwo[1];returno[1]},trys:[],ops:[]};returni={next:a(0),throw:a(1),return:a(2)},"function"==typeofSymbol&&(i[Symbol.iterator]=function(){returnthis}),i;functiona(i){returnfunction(a){returnfunction(i){if(n)thrownewTypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)returno;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case0:case1:o=i;break;case4:returns.label++,{value:i[1],done:!1};case5:s.label++,r=i[1],i=[0];continue;case7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throwi[1];return{value:i[0]?i[1]:void0,done:!0}}([i,a])}}}vari=function(t){return{startEndTensor:t,startPoint:e.slice(t,[0,0],[-1,2]),endPoint:e.slice(t,[0,2],[-1,2])}},s=function(t,n){varr=e.mul(t.startPoint,n),o=e.mul(t.endPoint,n),s=e.concat2d([r,o],1);returni(s)};functiona(t,n){varr,o,i;if(t.topLeftinstanceofe.Tensor&&t.bottomRightinstanceofe.Tensor){vars=e.tidy(function(){return[e.concat([e.slice(e.sub(n-1,t.topLeft),0,1),e.slice(t.topLeft,1,1)]),e.concat([e.sub(n-1,e.slice(t.bottomRight,0,1)),e.slice(t.bottomRight,1,1)])]});r=s[0],o=s[1],null!=t.landmarks&&(i=e.tidy(function(){varr=e.sub(e.tensor1d([n-1,0]),t.landmarks),o=e.tensor1d([1,-1]);returne.mul(r,o)}))}else{vara=t.topLeft,c=a[0],u=a[1],l=t.bottomRight,d=l[0],f=l[1];r=[n-1-c,u],o=[n-1-d,f],null!=t.landmarks&&(i=t.landmarks.map(function(t){return[n-1-t[0],t[1]]}))}varh={topLeft:r,bottomRight:o};returnnull!=i&&(h.landmarks=i),null!=t.probability&&(h.probability=t.probabilityinstanceofe.Tensor?t.probability.clone():t.probability),h}functionc(t,n){returne.tidy(function(){varr;returnr=t.hasOwnProperty("box")?t.box:t,e.squeeze(s(r,n).startEndTensor)})}varu=function(){functiont(t,n,r,o,i,s){this.blazeFaceModel=t,this.width=n,this.height=r,this.maxFaces=o;vara={strides:[n/16,n/8],anchors:[2,6]};this.anchorsData=function(t,e,n){for(varr=[],o=0;o<n.strides.length;o++)for(vari=n.strides[o],s=Math.floor((e+i-1)/i),a=Math.floor((t+i-1)/i),c=n.anchors[o],u=0;u<s;u++)for(varl=i*(u+.5),d=0;d<a;d++)for(varf=i*(d+.5),h=0;h<c;h++)r.push([f,l]);returnr}(n,r,a),this.anchors=e.tensor2d(this.anchorsData),this.inputSize=e.tensor1d([n,r]),this.iouThreshold=i,this.scoreThreshold=s}returnt.prototype.resizeAspectRatio=function(t,n,r){varo=t.shape[2],i=t.shape[1];if(!n||!r)return{ratio:1,image:t};vars=Math.min(n/o,r/i),a=Math.round(o*s),c=Math.round(i*s);return{ratio:s,image:e.image.resizeBilinear(t,[c,a])}},t.prototype.getBoundingBoxes=function(t,n,s){returnvoid0===s&&(s=!0),r(this,void0,void0,function(){vara,c,u,l,d,f,h,p,b,v,m,y,w,g=this;returno(this,function(x){switch(x.label){case0:returna=e.tidy(function(){varn,r,o,i,s,a,c,u,l,d,f,h,p,b=e.image.resizeBilinear(t,[g.width,g.height]),v=e.mul(e.sub(e.div(b,255),.5),2),m=g.blazeFaceModel.predict(v).sort(function(t,e){returnt.size-e.size}),y=e.concat([m[0],m[2]],2),w=e.concat([m[1],m[3]],2),x=e.concat([w,y],1),z=e.squeeze(x),T=(n=z,r=g.anchors,o=g.inputSize,i=e.slice(n,[0,1],[-1,2]),s=e.add(i,r),a=e.slice(n