text: /**
      * @license
      * Copyright 2019 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.
      * =============================================================================
      */
  import*as tf from"@tensorflow/tfjs-core";import{util,tidy,div,sub,buffer,Tensor,browser,pad3d,scalar,concat,tensor2d,tensor}from"@tensorflow/tfjs-core";import{loadGraphModel}from"@tensorflow/tfjs-converter";var VALID_OUTPUT_STRIDES=[8,16,32];function assertValidOutputStride(e){util.assert("number"==typeof e,function(){return"outputStride is not a number"}),util.assert(VALID_OUTPUT_STRIDES.indexOf(e)>=0,function(){return"outputStride of "+e+" is invalid. It must be either 8, 16, or 32"})}function assertValidResolution(e,t){util.assert("number"==typeof e,function(){return"resolution is not a number"}),util.assert((e-1)%t==0,function(){return"resolution of "+e+" is invalid for output stride "+t+"."})}function toFloatIfInt(e){return tidy(function(){return"int32"===e.dtype&&(e=e.toFloat()),e=div(e,127.5),sub(e,1)})}var MobileNet=function(){function e(e,t){this.model=e;var r=this.model.inputs[0].shape;util.assert(-1===r[1]&&-1===r[2],function(){return"Input shape ["+r[1]+", "+r[2]+"] must both be -1"}),this.outputStride=t}return e.prototype.predict=function(e){var t=this;return tidy(function(){var r=toFloatIfInt(e).expandDims(0),n=t.model.predict(r),o=n[0],i=n[1],s=n[2],a=n[3];return{heatmapScores:i.squeeze().sigmoid(),offsets:o.squeeze(),displacementFwd:s.squeeze(),displacementBwd:a.squeeze()}})},e.prototype.dispose=function(){this.model.dispose()},e}();function half(e){return Math.floor(e/2)}var MaxHeap=function(){function e(e,t){this.priorityQueue=new Array(e),this.numberOfElements=-1,this.getElementValue=t}return e.prototype.enqueue=function(e){this.priorityQueue[++this.numberOfElements]=e,this.swim(this.numberOfElements)},e.prototype.dequeue=function(){var e=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,e},e.prototype.empty=function(){return-1===this.numberOfElements},e.prototype.size=function(){return this.numberOfElements+1},e.prototype.all=function(){return this.priorityQueue.slice(0,this.numberOfElements+1)},e.prototype.max=function(){return this.priorityQueue[0]},e.prototype.swim=function(e){for(;e>0&&this.less(half(e),e);)this.exchange(e,half(e)),e=half(e)},e.prototype.sink=function(e){for(;2*e<=this.numberOfElements;){var t=2*e;if(t<this.numberOfElements&&this.less(t,t+1)&&t++,!this.less(e,t))break;this.exchange(e,t),e=t}},e.prototype.getValueAt=function(e){return this.getElementValue(this.priorityQueue[e])},e.prototype.less=function(e,t){return this.getValueAt(e)<this.getValueAt(t)},e.prototype.exchange=function(e,t){var r=this.priorityQueue[e];this.priorityQueue[e]=this.priorityQueue[t],this.priorityQueue[t]=r},e}();function scoreIsMaximumInLocalWindow(e,t,r,n,o,i){for(var s=i.shape,a=s[0],u=s[1],l=!0,f=Math.max(r-o,0),c=Math.min(r+o+1,a),d=f;d<c;++d){for(var p=Math.max(n-o,0),h=Math.min(n+o+1,u),m=p;m<h;++m)if(i.get(d,m,e)>t){l=!1;break}if(!l)break}return l}function buildPartWithScoreQueue(e,t,r){for(var n=r.shape,o=n[0],i=n[1],s=n[2],a=new MaxHeap(o*i*s,function(e){return e.score}),u=0;u<o;++u)for(var l=0;l<i;++l)for(var f=0;f<s;++f){var c=r.get(u,l,f);c<e||scoreIsMaximumInLocalWindow(f,c,u,l,t,r)&&a.enqueue({score:c,part:{heatmapY:u,heatmapX:l,id:f}})}return a}var partNames=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],NUM_KEYPOINTS=partNames.length,partIds=partNames.reduce(function(e,t,r){return e[t]=r,e},{}),connectedPartNames=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],poseChain=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]],connectedPartIndices=connectedPartNames.map(function(e){var t=e[0],r=e[1];return[partIds[t],partIds[r]]}),partChannels=["left_face","right_face","right_upper_leg_front","right_lower_leg_back","right_upper_leg_back","left_lower_leg_front","left_upper_leg_front","left_upper_leg_back","left_lower_leg_back","right_feet","right_lower_leg_front","left_feet","torso_front","torso_back","right_upper_arm_front","right_upper_arm_back","right_lower_arm_back","left_lower_arm_front","left_upper_arm_front","left_upper_arm_back","left_lower_arm_back","right_hand","right_lower_arm_front","left_hand"];function getOffsetPoint(e,t,r,n){return{y:n.get(e,t,r),x:n.get(e,t,r+NUM_KEYPOINTS)}}function getImageCoords(e,t,r){var n=getOffsetPoint(e.heatmapY,e.heatmapX,e.id,r),o=n.y,i=n.x;return{x:e.heatmapX*t+i,y:e.heatmapY*t+o}}function clamp(e,t,r){return e<t?t:e>r?r:e}function squaredDistance(e,t,r,n){var o=r-e,i=n-t;return o*o+i*i}function addVectors(e,t){return{x:e.x+t.x,y:e.y+t.y}}var parentChildrenTuples=poseChain.map(function(e){var t=e[0],r=e[1];return[partIds[t],partIds[r]]}),parentToChildEdges=parentChildrenTuples.map(function(e){return e[1]}),childToParentEdges=parentChildrenTuples.map(function(e){return e[0]});function getDisplacement(e,t,r){var n=r.shape[2]/2;return{y:r.get(t.y,t.x,e),x:r.get(t.y,t.x,n+e)}}function getStridedIndexNearPoint(e,t,r,n){return{y:clamp(Math.round(e.y/t),0,r-1),x:clamp(Math.round(e.x/t),0,n-1)}}function traverseToTargetKeypoint(e,t,r,n,o,i,s,a){void 0===a&&(a=2);for(var u=n.shape,l=u[0],f=u[1],c=getDisplacement(e,getStridedIndexNearPoint(t.position,i,l,f),s),d=addVectors(t.position,c),p=0;p<a;p++){var h=getStridedIndexNearPoint(d,i,l,f),m=getOffsetPoint(h.y,h.x,r,o);d=addVectors({x:h.x*i,y:h.y*i},{x:m.x,y:m.y})}var g=getStridedIndexNearPoint(d,i,l,f),_=n.get(g.y,g.x,r);return{position:d,part:partNames[r],score:_}}function decodePose(e,t,r,n,o,i){var s=t.shape[2],a=parentToChildEdges.length,u=new Array(s),l=e.part,f=e.score,c=getImageCoords(l,n,r);u[l.id]={score:f,part:partNames[l.id],position:c};for(var d=a-1;d>=0;--d){var p=parentToChildEdges[d],h=childToParentEdges[d];u[p]&&!u[h]&&(u[h]=traverseToTargetKeypoint(d,u[p],h,t,r,n,i))}for(d=0;d<a;++d){p=childToParentEdges[d],h=parentToChildEdges[d];u[p]&&!u[h]&&(u[h]=traverseToTargetKeypoint(d,u[p],h,t,r,n,o))}return u}function withinNmsRadiusOfCorrespondingPoint(e,t,r,n){var o=r.x,i=r.y;return e.some(function(e){var r=e.keypoints[n].position;return squaredDistance(i,o,r.y,r.x)<=t})}function getInstanceScore(e,t,r){return r.reduce(function(r,n,o){var i=n.position,s=n.score;return withinNmsRadiusOfCorrespondingPoint(e,t,i,o)||(r+=s),r},0)/r.length}var kLocalMaximumRadius=1;function decodeMultiplePoses(e,t,r,n,o,i,s,a){void 0===s&&(s=.5),void 0===a&&(a=20);for(var u=[],l=buildPartWithScoreQueue(s,kLocalMaximumRadius,e),f=a*a;u.length<i&&!l.empty();){var c=l.dequeue();if(!withinNmsRadiusOfCorrespondingPoint(u,f,getImageCoords(c.part,o,t),c.part.id)){var d=decodePose(c,e,t,o,r,n),p=getInstanceScore(u,f,d);u.push({keypoints:d,score:p})}}return u}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function __awaiter(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(s,a)}u((n=n.apply(e,t||[])).next())})}function __generator(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7: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=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function eitherPointDoesntMeetConfidence(e,t,r){return e<r||t<r}function getAdjacentKeyPoints(e,t){return connectedPartIndices.reduce(function(r,n){var o=n[0],i=n[1];return eitherPointDoesntMeetConfidence(e[o].score,e[i].score,t)?r:(r.push([e[o],e[i]]),r)},[])}var NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,POSITIVE_INFINITY=Number.POSITIVE_INFINITY;function getBoundingBox(e){return e.reduce(function(e,t){var r=e.maxX,n=e.maxY,o=e.minX,i=e.minY,s=t.position,a=s.x,u=s.y;return{maxX:Math.max(r,a),maxY:Math.max(n,u),minX:Math.min(o,a),minY:Math.min(i,u)}},{maxX:NEGATIVE_INFINITY,maxY:NEGATIVE_INFINITY,minX:POSITIVE_INFINITY,minY:POSITIVE_INFINITY})}function getBoundingBoxPoints(e){var t=getBoundingBox(e),r=t.minX,n=t.minY,o=t.maxX,i=t.maxY;return[{x:r,y:n},{x:o,y:n},{x:o,y:i},{x:r,y:i}]}function toTensorBuffer(e,t){return void 0===t&&(t="float32"),__awaiter(this,void 0,void 0,function(){var r;return __generator(this,function(n){switch(n.label){case 0:return[4,e.data()];case 1:return r=n.sent(),[2,buffer(e.shape,t,r)]}})})}function toTensorBuffers3D(e){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2,Promise.all(e.map(function(e){return toTensorBuffer(e,"float32")}))]})})}function scalePose(e,t,r,n,o){return void 0===n&&(n=0),void 0===o&&(o=0),{score:e.score,keypoints:e.keypoints.map(function(e){var i=e.score,s=e.part,a=e.position;return{score:i,part:s,position:{x:a.x*r+o,y:a.y*t+n}}})}}function scalePoses(e,t,r,n,o){return void 0===n&&(n=0),void 0===o&&(o=0),1===r&&1===t&&0===n&&0===o?e:e.map(function(e){return scalePose(e,t,r,n,o)})}function flipPoseHorizontal(e,t){return{score:e.score,keypoints:e.keypoints.map(function(e){var r=e.score,n=e.part,o=e.position;return{score:r,part:n,position:{x:t-1-o.x,y:o.y}}})}}function flipPosesHorizontal(e,t){return t<=0?e:e.map(function(e){return flipPoseHorizontal(e,t)})}function getInputTensorDimensions(e){return e instanceof Tensor?[e.shape[0],e.shape[1]]:[e.height,e.width]}function toInputTensor(e){return e instanceof Tensor?e:browser.fromPixels(e)}function padAndResizeTo(e,t){var r=t[0],n=t[1],o=getInputTensorDimensions(e),i=o[0],s=o[1],a=n/r,u=[0,0,0,0],l=u[0],f=u[1],c=u[2],d=u[3];return s/i<a?(l=0,f=0,c=Math.round(.5*(a*i-s)),d=Math.round(.5*(a*i-s))):(l=Math.round(.5*(1/a*s-i)),f=Math.round(.5*(1/a*s-i)),c=0,d=0),{resized:tidy(function(){var t=toInputTensor(e);return(t=pad3d(t,[[l,f],[c,d],[0,0]])).resizeBilinear([r,n])}),padding:{top:l,left:c,right:d,bottom:f}}}function scaleAndFlipPoses(e,t,r,n,o){var i=t[0],s=t[1],a=r[0],u=r[1],l=scalePoses(e,(i+n.top+n.bottom)/a,(s+n.left+n.right)/u,-n.top,-n.left);return o?flipPosesHorizontal(l,s):l}function mod(e,t){return tidy(function(){var r=e.div(scalar(t,"int32"));return e.sub(r.mul(scalar(t,"int32")))})}function argmax2d(e){var t=e.shape,r=t[0],n=t[1],o=t[2];return tidy(function(){var t=e.reshape([r*n,o]).argMax(0),i=t.div(scalar(n,"int32")).expandDims(1),s=mod(t,n).expandDims(1);return concat([i,s],1)})}function getPointsConfidence(e,t){for(var r=t.shape[0],n=new Float32Array(r),o=0;o<r;o++){var i=t.get(o,0),s=t.get(o,1);n[o]=e.get(i,s,o)}return n}function getOffsetPoint$1(e,t,r,n){return{y:n.get(e,t,r),x:n.get(e,t,r+NUM_KEYPOINTS)}}function getOffsetVectors(e,t){for(var r=[],n=0;n<NUM_KEYPOINTS;n++){var o=getOffsetPoint$1(e.get(n,0).valueOf(),e.get(n,1).valueOf(),n,t),i=o.x,s=o.y;r.push(s),r.push(i)}return tensor2d(r,[NUM_KEYPOINTS,2])}function getOffsetPoints(e,t,r){return tidy(function(){var n=getOffsetVectors(e,r);return e.toTensor().mul(scalar(t,"int32")).toFloat().add(n)})}function decodeSinglePose(e,t,r){return __awaiter(this,void 0,void 0,function(){var n,o,i,s,a,u,l,f,c,d;return __generator(this,function(p){switch(p.label){case 0:return n=0,o=argmax2d(e),[4,Promise.all([toTensorBuffer(e),toTensorBuffer(t),toTensorBuffer(o,"int32")])];case 1:return i=p.sent(),s=i[0],a=i[1],u=i[2],[4,toTensorBuffer(l=getOffsetPoints(u,r,a))];case 2:return f=p.sent(),c=Array.from(getPointsConfidence(s,u)),d=c.map(function(e,t){return n+=e,{position:{y:f.get(t,0),x:f.get(t,1)},part:partNames[t],score:e}}),o.dispose(),l.dispose(),[2,{keypoints:d,score:n/d.length}]}})})}var MOBILENET_BASE_URL="https://storage.googleapis.com/tfjs-models/savedmodel/posenet/mobilenet/",RESNET50_BASE_URL="https://storage.googleapis.com/tfjs-models/savedmodel/posenet/resnet50/";function resNet50Checkpoint(e,t){var r="model-stride"+e+".json";return 4==t?RESNET50_BASE_URL+"float/"+r:RESNET50_BASE_URL+"quant"+t+"/"+r}function mobileNetCheckpoint(e,t,r){var n={1:"100",.75:"075",.5:"050"},o="model-stride"+e+".json";return 4==r?MOBILENET_BASE_URL+"float/"+n[t]+"/"+o:MOBILENET_BASE_URL+"quant"+r+"/"+n[t]+"/"+o}function toFloatIfInt$1(e){return tidy(function(){"int32"===e.dtype&&(e=e.toFloat());var t=tensor([-123.15,-115.9,-103.06]);return e.add(t)})}var ResNet=function(){function e(e,t){this.model=e;var r=this.model.inputs[0].shape;util.assert(-1===r[1]&&-1===r[2],function(){return"Input shape ["+r[1]+", "+r[2]+"] must both be equal to or -1"}),this.outputStride=t}return e.prototype.predict=function(e){var t=this;return tidy(function(){var r=toFloatIfInt$1(e).expandDims(0),n=t.model.predict(r),o=n[0],i=n[1],s=n[2];return{heatmapScores:n[3].squeeze().sigmoid(),offsets:s.squeeze(),displacementFwd:o.squeeze(),displacementBwd:i.squeeze()}})},e.prototype.dispose=function(){this.model.dispose()},e}(),MOBILENET_V1_CONFIG={architecture:"MobileNetV1",outputStride:16,multiplier:.75,inputResolution:257},VALID_ARCHITECTURE=["MobileNetV1","ResNet50"],VALID_STRIDE={MobileNetV1:[8,16,32],ResNet50:[32,16]},VALID_INPUT_RESOLUTION=[161,193,257,289,321,353,385,417,449,481,513,801],VALID_MULTIPLIER={MobileNetV1:[.5,.75,1],ResNet50:[1]},VALID_QUANT_BYTES=[1,2,4];function validateModelConfig(e){if(null==(e=e||MOBILENET_V1_CONFIG).architecture&&(e.architecture="MobileNetV1"),VALID_ARCHITECTURE.indexOf(e.architecture)<0)throw new Error("Invalid architecture "+e.architecture+". Should be one of "+VALID_ARCHITECTURE);if(null==e.inputResolution&&(e.inputResolution=257),VALID_INPUT_RESOLUTION.indexOf(e.inputResolution)<0)throw new Error("Invalid inputResolution "+e.inputResolution+". Should be one of "+VALID_INPUT_RESOLUTION);if(null==e.outputStride&&(e.outputStride=16),VALID_STRIDE[e.architecture].indexOf(e.outputStride)<0)throw new Error("Invalid outputStride "+e.outputStride+". Should be one of "+VALID_STRIDE[e.architecture]+" for architecutre "+e.architecture+".");if(null==e.multiplier&&(e.multiplier=1),VALID_MULTIPLIER[e.architecture].indexOf(e.multiplier)<0)throw new Error("Invalid multiplier "+e.multiplier+". Should be one of "+VALID_MULTIPLIER[e.architecture]+" for architecutre "+e.architecture+".");if(null==e.quantBytes&&(e.quantBytes=4),VALID_QUANT_BYTES.indexOf(e.quantBytes)<0)throw new Error("Invalid quantBytes "+e.quantBytes+". Should be one of "+VALID_QUANT_BYTES+" for architecutre "+e.architecture+".");return e}var SINGLE_PERSON_INFERENCE_CONFIG={flipHorizontal:!1},MULTI_PERSON_INFERENCE_CONFIG={flipHorizontal:!1,maxDetections:5,scoreThreshold:.5,nmsRadius:20};function validateMultiPersonInputConfig(e){var t=e.maxDetections,r=e.scoreThreshold,n=e.nmsRadius;if(t<=0)throw new Error("Invalid maxDetections "+t+". Should be > 0");if(r<0||r>1)throw new Error("Invalid scoreThreshold "+r+". Should be in range [0.0, 1.0]");if(n<=0)throw new Error("Invalid nmsRadius "+n+".")}var PoseNet=function(){function e(e,t){this.baseModel=e,this.inputResolution=t}return e.prototype.estimateMultiplePoses=function(e,t){return void 0===t&&(t=MULTI_PERSON_INFERENCE_CONFIG),__awaiter(this,void 0,void 0,function(){var r,n,o,i,s,a,u,l,f,c,d,p,h,m,g,_,I,E,v,N,y;return __generator(this,function(T){switch(T.label){case 0:return r=__assign({},MULTI_PERSON_INFERENCE_CONFIG,t),validateMultiPersonInputConfig(t),n=this.baseModel.outputStride,o=this.inputResolution,assertValidOutputStride(n),assertValidResolution(this.inputResolution,n),i=getInputTensorDimensions(e),s=i[0],a=i[1],u=padAndResizeTo(e,[o,o]),l=u.resized,f=u.padding,c=this.baseModel.predict(l),d=c.heatmapScores,p=c.offsets,h=c.displacementFwd,m=c.displacementBwd,[4,toTensorBuffers3D([d,p,h,m])];case 1:return g=T.sent(),_=g[0],I=g[1],E=g[2],v=g[3],[4,decodeMultiplePoses(_,I,E,v,n,r.maxDetections,r.scoreThreshold,r.nmsRadius)];case 2:return N=T.sent(),y=scaleAndFlipPoses(N,[s,a],[o,o],f,r.flipHorizontal),d.dispose(),p.dispose(),h.dispose(),m.dispose(),l.dispose(),[2,y]}})})},e.prototype.estimateSinglePose=function(e,t){return void 0===t&&(t=SINGLE_PERSON_INFERENCE_CONFIG),__awaiter(this,void 0,void 0,function(){var r,n,o,i,s,a,u,l,f,c,d,p,h,m,g,_;return __generator(this,function(I){switch(I.label){case 0:return r=__assign({},SINGLE_PERSON_INFERENCE_CONFIG,t),n=this.baseModel.outputStride,o=this.inputResolution,assertValidOutputStride(n),assertValidResolution(o,n),i=getInputTensorDimensions(e),s=i[0],a=i[1],u=padAndResizeTo(e,[o,o]),l=u.resized,f=u.padding,c=this.baseModel.predict(l),d=c.heatmapScores,p=c.offsets,h=c.displacementFwd,m=c.displacementBwd,[4,decodeSinglePose(d,p,n)];case 1:return g=I.sent(),_=scaleAndFlipPoses([g],[s,a],[o,o],f,r.flipHorizontal),d.dispose(),p.dispose(),h.dispose(),m.dispose(),l.dispose(),[2,_[0]]}})})},e.prototype.estimatePoses=function(e,t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(r){switch(r.label){case 0:return"single-person"!=t.decodingMethod?[3,2]:[4,this.estimateSinglePose(e,t)];case 1:return[2,[r.sent()]];case 2:return[2,this.estimateMultiplePoses(e,t)]}})})},e.prototype.dispose=function(){this.baseModel.dispose()},e}();function loadMobileNet(e){return __awaiter(this,void 0,void 0,function(){var t,r,n,o,i,s;return __generator(this,function(a){switch(a.label){case 0:if(t=e.outputStride,r=e.quantBytes,n=e.multiplier,null==tf)throw new Error("Cannot find TensorFlow.js. If you are using a <script> tag, please also include @tensorflow/tfjs on the page before using this\n        model.");return o=mobileNetCheckpoint(t,n,r),[4,loadGraphModel(e.modelUrl||o)];case 1:return i=a.sent(),s=new MobileNet(i,t),[2,new PoseNet(s,e.inputResolution)]}})})}function loadResNet(e){return __awaiter(this,void 0,void 0,function(){var t,r,n,o,i;return __generator(this,function(s){switch(s.label){case 0:if(t=e.outputStride,r=e.quantBytes,null==tf)throw new Error("Cannot find TensorFlow.js. If you are using a <script> tag, please also include @tensorflow/tfjs on the page before using this\n        model.");return n=resNet50Checkpoint(t,r),[4,loadGraphModel(e.modelUrl||n)];case 1:return o=s.sent(),i=new ResNet(o,t),[2,new PoseNet(i,e.inputResolution)]}})})}function load(e){return void 0===e&&(e=MOBILENET_V1_CONFIG),__awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return"ResNet50"===(e=validateModelConfig(e)).architecture?[2,loadResNet(e)]:"MobileNetV1"===e.architecture?[2,loadMobileNet(e)]:[2,null]})})}export{decodeMultiplePoses,decodeSinglePose,MobileNet,partChannels,partIds,partNames,poseChain,load,PoseNet,VALID_INPUT_RESOLUTION,getAdjacentKeyPoints,getBoundingBox,getBoundingBoxPoints,scalePose};
  