1!function(p){var f;function l(){var e=Error.apply(this,arguments);e.name=this.name="FlashError",this.stack=e.stack,this.message=e.message}function u(){var e=Error.apply(this,arguments);e.name=this.name="WebcamError",this.stack=e.stack,this.message=e.message}var e=function(){};e.prototype=Error.prototype,l.prototype=new e,u.prototype=new e;var g={version:"1.0.26",protocol:location.protocol.match(/https/i)?"https":"http",loaded:!1,live:!1,userMedia:!0,iOS:/iPad|iPhone|iPod/.test(navigator.userAgent)&&!p.MSStream,params:{width:0,height:0,dest_width:0,dest_height:0,image_format:"jpeg",jpeg_quality:90,enable_flash:!0,force_flash:!1,flip_horiz:!1,fps:30,upload_name:"webcam",constraints:null,swfURL:"",flashNotDetectedText:"ERROR: No Adobe Flash Player detected. Webcam.js relies on Flash for browsers that do not support getUserMedia (like yours).",noInterfaceFoundText:"No supported webcam interface found.",unfreeze_snap:!0,iosPlaceholderText:"Click here to open camera.",user_callback:null,user_canvas:null},errors:{FlashError:l,WebcamError:u},hooks:{},init:function(){var t=this;this.mediaDevices=navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?navigator.mediaDevices:navigator.mozGetUserMedia||navigator.webkitGetUserMedia?{getUserMedia:function(a){return new Promise(function(e,t){(navigator.mozGetUserMedia||navigator.webkitGetUserMedia).call(navigator,a,e,t)})}}:null,p.URL=p.URL||p.webkitURL||p.mozURL||p.msURL,this.userMedia=this.userMedia&&!!this.mediaDevices&&!!p.URL,navigator.userAgent.match(/Firefox\D+(\d+)/)&&parseInt(RegExp.$1,10)<21&&(this.userMedia=null),this.userMedia&&p.addEventListener("beforeunload",function(e){t.reset()})},exifOrientation:function(e){var t=new DataView(e);if(255!=t.getUint8(0)||216!=t.getUint8(1))return console.log("Not a valid JPEG file"),0;for(var a=2;a<e.byteLength;){if(255!=t.getUint8(a))return console.log("Not a valid marker at offset "+a+", found: "+t.getUint8(a)),0;if(225==t.getUint8(a+1)){a+=4;var i="";for(n=0;n<4;n++)i+=String.fromCharCode(t.getUint8(a+n));if("Exif"!=i)return console.log("Not valid EXIF data found"),0;a+=6;var s=null;if(18761==t.getUint16(a))s=!1;else{if(19789!=t.getUint16(a))return console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)"),0;s=!0}if(42!=t.getUint16(a+2,!s))return console.log("Not valid TIFF data! (no 0x002A)"),0;var r=t.getUint32(a+4,!s);if(r<8)return console.log("Not valid TIFF data! (First offset less than 8)",t.getUint32(a+4,!s)),0;for(var o=a+r,h=t.getUint16(o,!s),l=0;l<h;l++){var c=o+12*l+2;if(274==t.getUint16(c,!s)){var d=t.getUint16(c+2,!s),m=t.getUint32(c+4,!s);if(3!=d&&1!=m)return console.log("Invalid EXIF orientation value type ("+d+") or count ("+m+")"),0;var p=t.getUint16(c+8,!s);return p<1||8<p?(console.log("Invalid EXIF orientation value ("+p+")"),0):p}}}else a+=2+t.getUint16(a+2)}return 0},fixOrientation:function(e,i,s){var r=new Image;r.addEventListener("load",function(e){var t=document.createElement("canvas"),a=t.getContext("2d");switch(i<5?(t.width=r.width,t.height=r.height):(t.width=r.height,t.height=r.width),i){case 2:a.transform(-1,0,0,1,r.width,0);break;case 3:a.transform(-1,0,0,-1,r.width,r.height);break;case 4:a.transform(1,0,0,-1,0,r.height);break;case 5:a.transform(0,1,1,0,0,0);break;case 6:a.transform(0,1,-1,0,r.height,0);break;case 7:a.transform(0,-1,-1,0,r.height,r.width);break;case 8:a.transform(0,-1,1,0,0,r.width)}a.drawImage(r,0,0),s.src=t.toDataURL()},!1),r.src=e},attach:function(t){if("string"==typeof t&&(t=document.getElementById(t)||document.querySelector(t)),!t)return this.dispatch("error",new u("Could not locate DOM element to attach to."));(this.container=t).innerHTML="";var e=document.createElement("div");if(t.appendChild(e),this.peg=e,this.params.width||(this.params.width=t.offsetWidth),this.params.height||(this.params.height=t.offsetHeight),!this.params.width||!this.params.height)return this.dispatch("error",new u("No width and/or height for webcam. Please call set() first, or attach to a visible element."));this.params.dest_width||(this.params.dest_width=this.params.width),this.params.dest_height||(this.params.dest_height=this.params.height),this.userMedia=f===undefined?this.userMedia:f,this.params.force_flash&&(f=this.userMedia,this.userMedia=null),"number"!=typeof this.params.fps&&(this.params.fps=30);var a=this.params.width/this.params.dest_width,i=this.params.height/this.params.dest_height;if(this.userMedia){var s=document.createElement("video");s.setAttribute("autoplay","autoplay"),s.setAttribute("playsinline","playsinline"),s.style.width=this.params.dest_width+"px",s.style.height=this.params.dest_height+"px",1==a&&1==i||(t.style.overflow="hidden",s.style.webkitTransformOrigin="0px 0px",s.style.mozTransformOrigin="0px 0px",s.style.msTransformOrigin="0px 0px",s.style.oTransformOrigin="0px 0px",s.style.transformOrigin="0px 0px",s.style.webkitTransform="scaleX("+a+") scaleY("+i+")",s.style.mozTransform="scaleX("+a+") scaleY("+i+")",s.style.msTransform="scaleX("+a+") scaleY("+i+")",s.style.oTransform="scaleX("+a+") scaleY("+i+")",s.style.transform="scaleX("+a+") scaleY("+i+")"),t.appendChild(s),this.video=s;var r=this;this.mediaDevices.getUserMedia({audio:!1,video:this.params.constraints||{mandatory:{minWidth:this.params.dest_width,minHeight:this.params.dest_height}}}).then(function(t){s.onloadedmetadata=function(e){r.stream=t,r.loaded=!0,r.live=!0,r.dispatch("load"),r.dispatch("live"),r.flip()},"srcObject"in s?s.srcObject=t:s.src=p.URL.createObjectURL(t)})["catch"](function(e){r.params.enable_flash&&r.detectFlash()?setTimeout(function(){r.params.force_flash=1,r.attach(t)},1):r.dispatch("error",e)})}else if(this.iOS){(d=document.createElement("div")).id=this.container.id+"-ios_div",d.className="webcamjs-ios-placeholder",d.style.width=this.params.width+"px",d.style.height=this.params.height+"px",d.style.textAlign="center",d.style.display="table-cell",d.style.verticalAlign="middle",d.style.backgroundRepeat="no-repeat",d.style.backgroundSize="contain",d.style.backgroundPosition="center";var o=document.createElement("span");o.className="webcamjs-ios-text",o.innerHTML=this.params.iosPlaceholderText,d.appendChild(o);var l=document.createElement("img");l.id=this.container.id+"-ios_img",l.style.width=this.params.dest_width+"px",l.style.height=this.params.dest_height+"px",l.
1style.display="none",d.appendChild(l);var n=document.createElement("input");n.id=this.container.id+"-ios_input",n.setAttribute("type","file"),n.setAttribute("accept","image/*"),n.setAttribute("capture","camera");r=this;var c=this.params;n.addEventListener("change",function(e){if(0<e.target.files.length&&0==e.target.files[0].type.indexOf("image/")){var a=URL.createObjectURL(e.target.files[0]),h=new Image;h.addEventListener("load",function(e){var t=document.createElement("canvas");t.width=c.dest_width,t.height=c.dest_height;var a=t.getContext("2d");ratio=Math.min(h.width/c.dest_width,h.height/c.dest_height);var i=c.dest_width*ratio,s=c.dest_height*ratio,r=(h.width-i)/2,o=(h.height-s)/2;a.drawImage(h,r,o,i,s,0,0,c.dest_width,c.dest_height);var n=t.toDataURL();l.src=n,d.style.backgroundImage="url('"+n+"')"},!1);var t=new FileReader;t.addEventListener("load",function(e){var t=r.exifOrientation(e.target.result);1<t?r.fixOrientation(a,t,h):h.src=a},!1);var i=new XMLHttpRequest;i.open("GET",a,!0),i.responseType="blob",i.onload=function(e){200!=this.status&&0!==this.status||t.readAsArrayBuffer(this.response)},i.send()}},!1),n.style.display="none",t.appendChild(n),d.addEventListener("click",function(e){c.user_callback?r.snap(c.user_callback,c.user_canvas):(n.style.display="block",n.focus(),n.click(),n.style.display="none")},!1),t.appendChild(d),this.loaded=!0,this.live=!0}else if(this.params.enable_flash&&this.detectFlash()){var d;p.Webcam=g,(d=document.createElement("div")).innerHTML=this.getSWFHTML(),t.appendChild(d)}else this.dispatch("error",new u(this.params.noInterfaceFoundText));if(this.params.crop_width&&this.params.crop_height){var h=Math.floor(this.params.crop_width*a),m=Math.floor(this.params.crop_height*i);t.style.width=h+"px",t.style.height=m+"px",t.style.overflow="hidden",t.scrollLeft=Math.floor(this.params.width/2-h/2),t.scrollTop=Math.floor(this.params.height/2-m/2)}else t.style.width=this.params.width+"px",t.style.height=this.params.height+"px"},reset:function(){if(this.preview_active&&this.unfreeze(),this.unflip(),this.userMedia){if(this.stream)if(this.stream.getVideoTracks){var e=this.stream.getVideoTracks();e&&e[0]&&e[0].stop&&e[0].stop()}else this.stream.stop&&this.stream.stop();delete this.stream,delete this.video}if(!0!==this.userMedia&&this.loaded&&!this.iOS){var t=this.getMovie();t&&t._releaseCamera&&t._releaseCamera()}this.container&&(this.container.innerHTML="",delete this.container),this.loaded=!1,this.live=!1},set:function(){if(1==arguments.length)for(var e in arguments[0])this.params[e]=arguments[0][e];else this.params[arguments[0]]=arguments[1]},on:function(e,t){e=e.replace(/^on/i,"").toLowerCase(),this.hooks[e]||(this.hooks[e]=[]),this.hooks[e].push(t)},off:function(e,t){if(e=e.replace(/^on/i,"").toLowerCase(),this.hooks[e])if(t){var a=this.hooks[e].indexOf(t);-1<a&&this.hooks[e].splice(a,1)}else this.hooks[e]=[]},dispatch:function(){var e,t=arguments[0].replace(/^on/i,"").toLowerCase(),a=Array.prototype.slice.call(arguments,1);if(this.hooks[t]&&this.hooks[t].length){for(var i=0,s=this.hooks[t].length;i<s;i++){var r=this.hooks[t][i];"function"==typeof r?r.apply(this,a):"object"==typeof r&&2==r.length?r[0][r[1]].apply(r[0],a):p[r]&&p[r].apply(p,a)}return!0}return"error"==t&&(e=a[0]instanceof l||a[0]instanceof u?a[0].message:"Could not access webcam: "+a[0].name+": "+a[0].message+" "+a[0].toString(),alert("Webcam.js Error: "+e)),!1},setSWFLocation:function(e){this.set("swfURL",e)},detectFlash:function(){var e="Shockwave Flash",t="application/x-shockwave-flash",a=p,i=navigator,s=!1;if("undefined"!=typeof i.plugins&&"object"==typeof i.plugins[e])i.plugins[e].description&&"undefined"!=typeof i.mimeTypes&&i.mimeTypes[t]&&i.mimeTypes[t].enabledPlugin&&(s=!0);else if("undefined"!=typeof a.ActiveXObject)try{var r=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(r)r.GetVariable("$version")&&(s=!0)}catch(o){}return s},getSWFHTML:function(){var e="",t=this.params.swfURL;if(location.protocol.match(/file/))return this.dispatch("error",new l("Flash does not work from local disk. Please run from a web server.")),'<h3 style="color:red">ERROR: the Webcam.js Flash fallback does not work from local disk. Please run it from a web server.</h3>';if(!this.detectFlash())return this.dispatch("error",new l("Adobe Flash Player not found. Please install from get.adobe.com/flashplayer and try again.")),'<h3 style="color:red">'+this.params.flashNotDetectedText+"</h3>";if(!t){for(var a="",i=document.getElementsByTagName("script"),s=0,r=i.length;s<r;s++){var o=i[s].getAttribute("src");o&&o.match(/\/webcam(\.min)?\.js/)&&(a=o.replace(/\/webcam(\.min)?\.js.*$/,""),s=r)}t=a?a+"/webcam.swf":"webcam.swf"}p.localStorage&&!localStorage.getItem("visited")&&(this.params.new_user=1,localStorage.setItem("visited",1));var n="";for(var h in this.params)n&&(n+="&"),n+=h+"="+escape(this.params[h]);return e+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" type="application/x-shockwave-flash" codebase="'+this.protocol+'://download.macromedia.com/pub/s
1hockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+this.params.width+'" height="'+this.params.height+'" id="webcam_movie_obj" align="middle"><param name="wmode" value="opaque" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+t+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+n+'"/><embed id="webcam_movie_embed" src="'+t+'" wmode="opaque" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+this.params.width+'" height="'+this.params.height+'" name="webcam_movie_embed" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+n+'"></embed></object>'},getMovie:function(){if(!this.loaded)return this.dispatch("error",new l("Flash Movie is not loaded yet"));var e=document.getElementById("webcam_movie_obj");return e&&e._snap||(e=document.getElementById("webcam_movie_embed")),e||this.dispatch("error",new l("Cannot locate Flash movie in DOM")),e},freeze:function(){var e=this,t=this.params;this.preview_active&&this.unfreeze();var a=this.params.width/this.params.dest_width,i=this.params.height/this.params.dest_height;this.unflip();var s=t.crop_width||t.dest_width,r=t.crop_height||t.dest_height,o=document.createElement("canvas");o.width=s,o.height=r;var n=o.getContext("2d");this.preview_canvas=o,this.preview_context=n,1==a&&1==i||(o.style.webkitTransformOrigin="0px 0px",o.style.mozTransformOrigin="0px 0px",o.style.msTransformOrigin="0px 0px",o.style.oTransformOrigin="0px 0px",o.style.transformOrigin="0px 0px",o.style.webkitTransform="scaleX("+a+") scaleY("+i+")",o.style.mozTransform="scaleX("+a+") scaleY("+i+")",o.style.msTransform="scaleX("+a+") scaleY("+i+")",o.style.oTransform="scaleX("+a+") scaleY("+i+")",o.style.transform="scaleX("+a+") scaleY("+i+")"),this.snap(function(){o.style.position="relative",o.style.left=e.container.scrollLeft+"px",o.style.top=e.container.scrollTop+"px",e.container.insertBefore(o,e.peg),e.container.style.overflow="hidden",e.preview_active=!0},o)},unfreeze:function(){this.preview_active&&(this.container.removeChild(this.preview_canvas),delete this.preview_context,delete this.preview_canvas,this.preview_active=!1,this.flip())},flip:function(){if(this.params.flip_horiz){var e=this.container.style;e.webkitTransform="scaleX(-1)",e.mozTransform="scaleX(-1)",e.msTransform="scaleX(-1)",e.oTransform="scaleX(-1)",e.transform="scaleX(-1)",e.filter="FlipH",e.msFilter="FlipH"}},unflip:function(){if(this.params.flip_horiz){var e=this.container.style;e.webkitTransform="scaleX(1)",e.mozTransform="scaleX(1)",e.msTransform="scaleX(1)",e.oTransform="scaleX(1)",e.transform="scaleX(1)",e.filter="",e.msFilter=""}},savePreview:function(e,t){var a=this.params,i=this.preview_canvas,s=this.preview_context;t&&t.getContext("2d").drawImage(i,0,0);e(t?null:i.toDataURL("image/"+a.image_format,a.jpeg_quality/100),i,s),this.params.unfreeze_snap&&this.unfreeze()},snap:function(a,i){a||(a=this.params.user_callback),i||(i=this.params.user_canvas);var s=this.params;if(!this.loaded)return this.dispatch("error",new u("Webcam is not loaded yet"));if(!a)return this.dispatch("error",new u("Please provide a callback function or canvas to snap()"));if(this.preview_active)return this.savePreview(a,i),null;var r=document.createElement("canvas");r.width=this.params.dest_width,r.height=this.params.dest_height;var o=r.getContext("2d");this.params.flip_horiz&&(o.translate(s.dest_width,0),o.scale(-1,1));var t=function(){if(this.src&&this.width&&this.height&&o.drawImage(this,0,0,s.dest_width,s.dest_height),s.crop_width&&s.crop_height){var e=document.createElement("canvas");e.width=s.crop_width,e.height=s.crop_height;var t=e.getContext("2d");t.drawImage(r,Math.floor(s.dest_width/2-s.crop_width/2),Math.floor(s.dest_height/2-s.crop_height/2),s.crop_width,s.crop_height,0,0,s.crop_width,s.crop_height),o=t,r=e}i&&i.getContext("2d").drawImage(r,0,0);a(i?null:r.toDataURL("image/"+s.image_format,s.jpeg_quality/100),r,o)};if(this.userMedia)o.drawImage(this.video,0,0,this.params.dest_width,this.params.dest_height),t();else if(this.iOS){var n=document.getElementById(this.container.id+"-ios_div"),h=document.getElementById(this.container.id+"-ios_img"),l=document.getElementById(this.container.id+"-ios_input");iFunc=function(e){t.call(h),h.removeEventListener("load",iFunc),n.style.backgroundImage="none",h.removeAttribute("src"),l.value=null},l.value?iFunc(null):(h.addEventListener("load",iFunc),l.style.display="block",l.focus(),l.click(),l.style.display="none")}else{var e=this.getMovie()._snap();(h=new Image).onload=t,h.src="data:image/"+this.params.image_format
1+";base64,"+e}return null},configure:function(e){e||(e="camera"),this.getMovie()._configure(e)},flashNotify:function(e,t){switch(e){case"flashLoadComplete":this.loaded=!0,this.dispatch("load");break;case"cameraLive":this.live=!0,this.dispatch("live");break;case"error":this.dispatch("error",new l(t))}},b64ToUint6:function(e){return 64<e&&e<91?e-65:96<e&&e<123?e-71:47<e&&e<58?e+4:43===e?62:47===e?63:0},base64DecToArr:function(e,t){for(var a,i,s=e.replace(/[^A-Za-z0-9\+\/]/g,""),r=s.length,o=t?Math.ceil((3*r+1>>2)/t)*t:3*r+1>>2,n=new Uint8Array(o),h=0,l=0,c=0;c<r;c++)if(i=3&c,h|=this.b64ToUint6(s.charCodeAt(c))<<18-6*i,3==i||r-c==1){for(a=0;a<3&&l<o;a++,l++)n[l]=h>>>(16>>>a&24)&255;h=0}return n},upload:function(e,t,a){var i=this.params.upload_name||"webcam",s="";if(!e.match(/^data\:image\/(\w+)/))throw"Cannot locate image format in Data URI";s=RegExp.$1;var r=e.replace(/^data\:image\/\w+\;base64\,/,""),o=new XMLHttpRequest;o.open("POST",t,!0),o.upload&&o.upload.addEventListener&&o.upload.addEventListener("progress",function(e){if(e.lengthComputable){var t=e.loaded/e.total;g.dispatch("uploadProgress",t,e)}},!1);var n=this;o.onload=function(){a&&a.apply(n,[o.status,o.responseText,o.statusText]),g.dispatch("uploadComplete",o.status,o.responseText,o.statusText)};var h=new Blob([this.base64DecToArr(r)],{type:"image/"+s}),l=new FormData;l.append(i,h,i+"."+s.replace(/e/,"")),o.send(l)}};g.init(),"function"==typeof define&&define.amd?define(function(){return g}):"object"==typeof module&&module.exports?module.exports=g:p.Webcam=g}(window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.