From 5ae4eb9b8f2b03baebbb9da1eb2a6bee642c610d Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Mon, 14 Feb 2022 02:56:05 -0800 Subject: [PATCH 01/24] Super messy initial working version. To clean up. --- bookwyrm/static/js/bookwyrm.js | 59 ++++++++++++++++++++ bookwyrm/static/js/vendor/quagga.min.js | 1 + bookwyrm/templates/layout.html | 7 +++ bookwyrm/templates/search/barcode_modal.html | 14 +++++ 4 files changed, 81 insertions(+) create mode 100644 bookwyrm/static/js/vendor/quagga.min.js create mode 100644 bookwyrm/templates/search/barcode_modal.html diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index cf3ce303..b826a54e 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -47,6 +47,10 @@ let BookWyrm = new (class { .forEach((node) => node.addEventListener("toggle", this.handleDetailsDropdown.bind(this)) ); + + document + .querySelector("#barcode_scanner_modal") + .addEventListener("open", this.openBarcodeScanner.bind(this)); } /** @@ -427,9 +431,11 @@ let BookWyrm = new (class { }); modalElement.addEventListener("keydown", handleFocusTrap); + modalElement.dispatchEvent(new Event('open')); } function handleModalClose(modalElement) { + modalElement.dispatchEvent(new Event('close')); modalElement.removeEventListener("keydown", handleFocusTrap); htmlElement.classList.remove("is-clipped"); modalElement.classList.remove("is-active"); @@ -632,4 +638,57 @@ let BookWyrm = new (class { } } } + + openBarcodeScanner(event) { + /*function onScanSuccess(decodedText, decodedResult) { + alert(`${decodedText}`, decodedResult); + } + + function onScanFailure(error) { + alert(error); + }*/ + + Quagga.init({ + inputStream : { + name: "Live", + type: "LiveStream", + target: "#barcode_scanner" + }, + decoder : { + readers: [ + "ean_reader", + { + format: "ean_reader", + config: { + supplements: [ "ean_2_reader", "ean_5_reader" ] + } + } + ], + debug: { + drawBoundingBox: true, + drawScanline: true, + showPattern: true, + }, + multiple: false + }, + debug: true + }, function(err) { + if (err) { + console.log(err); + return; + } + + console.log('started'); + Quagga.start(); + }); + + Quagga.onDetected(function(result) { + var code = result.codeResult.code; + + location.href = `search?q=${code}`; + Quagga.stop(); + + console.log(code); + }); + } })(); diff --git a/bookwyrm/static/js/vendor/quagga.min.js b/bookwyrm/static/js/vendor/quagga.min.js new file mode 100644 index 00000000..f7a30f41 --- /dev/null +++ b/bookwyrm/static/js/vendor/quagga.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(e.toString()).default:"object"==typeof exports?exports.Quagga=e(e.toString()).default:t.Quagga=e(e.toString()).default}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=166)}([function(t,e){function n(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}t.exports=n},function(t,e,n){"use strict";function r(t,e){return this._row=[],this.config=t||{},this.supplements=e,this}var o=n(3);r.prototype._nextUnset=function(t,e){var n;for(void 0===e&&(e=0),n=e;nn)return Number.MAX_VALUE;u+=c}return u/f},r.prototype._nextSet=function(t,e){var n;for(e=e||0,n=e;n1&&(t[n[r]]=o)},r.prototype._matchTrace=function(t,e){var n,r,o=[],i=this,a=i._nextSet(i._row),u=!i._row[a],c=0,s={error:Number.MAX_VALUE,code:-1,start:0};if(t){for(n=0;n=0;r--)e=Math.floor(Math.random()*r),n=t[r],t[r]=t[e],t[e]=n;return t},toPointList:function(t){var e,n,r=[],o=[];for(e=0;e=e&&o.push(t[r]);return o},maxIndex:function(t){var e,n=0;for(e=0;et[n]&&(n=e);return n},max:function t(e){var n,t=0;for(n=0;nt&&(t=e[n]);return t},sum:function t(e){for(var n=e.length,t=0;n--;)t+=e[n];return t}}},function(t,e,n){"use strict";function r(t,e){t=a()(o(),t),u.a.call(this,t,e)}function o(){var t={};return Object.keys(r.CONFIG_KEYS).forEach(function(e){t[e]=r.CONFIG_KEYS[e].default}),t}var i=n(28),a=n.n(i),u=n(1),c=Object.assign||function(t){for(var e=1;ea.AVG_CODE_ERROR?null:f}s++,i[s]=1,c=!c}return null},r.prototype._findPattern=function(t,e,n,r,o){var i,a,u,c,s=[],f=this,l=0,d={error:Number.MAX_VALUE,code:-1,start:0,end:0};for(e||(e=f._nextSet(f._row)),void 0===n&&(n=!1),void 0===r&&(r=!0),void 0===o&&(o=f.AVG_CODE_ERROR),i=0;i=0&&n._matchRange(t,e.start,0))return e;r=e.end,e=null}},r.prototype._verifyTrailingWhitespace=function(t){var e,n=this;return e=t.end+(t.end-t.start),e=i.CODE_G_START?(t.code=t.code-i.CODE_G_START,a|=1<<5-r):a|=0<<5-r,e.push(t.code),n.push(t)}if(null===(o=i._calculateFirstDigit(a)))return null;if(e.unshift(o),null===(t=i._findPattern(i.MIDDLE_PATTERN,t.end,!0,!1)))return null;for(n.push(t),r=0;r<6;r++){if(!(t=i._decodeCode(t.end,i.CODE_G_START)))return null;n.push(t),e.push(t.code)}return t},r.prototype._decode=function(){var t,e,n=this,r=[],o=[],i={};if(!(t=n._findStart()))return null;if(e={code:t.code,start:t.start,end:t.end},o.push(e),!(e=n._decodePayload(e,r,o)))return null;if(!(e=n._findEnd(e.end,!1)))return null;if(o.push(e),!n._checksum(r))return null;if(this.supplements.length>0){var a=this._decodeExtensions(e.end);if(!a)return null;var u=a.decodedCodes[a.decodedCodes.length-1],s={start:u.start+((u.end-u.start)/2|0),end:u.end};if(!n._verifyTrailingWhitespace(s))return null;i={supplement:a,code:r.join("")+a.code}}return c({code:r.join(""),start:t.start,end:e.end,codeset:"",startInfo:t,decodedCodes:o},i)},r.prototype._decodeExtensions=function(t){var e,n,r=this._nextSet(this._row,t),o=this._findPattern(this.EXTENSION_START_PATTERN,r,!1,!1);if(null===o)return null;for(e=0;e=0;e-=2)n+=t[e];for(n*=3,e=t.length-1;e>=0;e-=2)n+=t[e];return n%10==0},r.CONFIG_KEYS={supplements:{type:"arrayOf(string)",default:[],description:"Allowed extensions to be decoded (2 and/or 5)"}},e.a=r},function(t,e,n){var r=n(38),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();t.exports=i},function(t,e){function n(t){return null!=t&&"object"==typeof t}t.exports=n},function(t,e){function n(t){var e=new Float32Array(2);return e[0]=t[0],e[1]=t[1],e}t.exports=n},function(t,e,n){function r(t){return null==t?void 0===t?c:u:s&&s in Object(t)?i(t):a(t)}var o=n(11),i=n(119),a=n(146),u="[object Null]",c="[object Undefined]",s=o?o.toStringTag:void 0;t.exports=r},function(t,e,n){"use strict";e.a={drawRect:function(t,e,n,r){n.strokeStyle=r.color,n.fillStyle=r.color,n.lineWidth=1,n.beginPath(),n.strokeRect(t.x,t.y,e.x,e.y)},drawPath:function(t,e,n,r){n.strokeStyle=r.color,n.fillStyle=r.color,n.lineWidth=r.lineWidth,n.beginPath(),n.moveTo(t[0][e.x],t[0][e.y]);for(var o=1;o-1&&t%1==0&&t0?Math.floor(this.x+.5):Math.floor(this.x-.5),this.y=this.y>0?Math.floor(this.y+.5):Math.floor(this.y-.5),this}}}function o(t,e,n){n||(n=t);for(var r=t.data,o=r.length,i=n.data;o--;)i[o]=r[o]>o]++;return a}function a(t,e){function n(t,e){var n,r=0;for(n=t;n<=e;n++)r+=a[n];return r}function r(t,e){var n,r=0;for(n=t;n<=e;n++)r+=n*a[n];return r}function o(){var o,u,c,s,f,l,d,h=[0],p=(1<c)for(i=s[u],i.score=o,i.item=t[r],c=Number.MAX_VALUE,a=0;ae[r]?r++:n++;return o}function _(t,e){function n(t){for(var e=0,n=t[Math.floor(t.length/2)];e0&&(n=Math.abs(t[e]-d)>Math.abs(t[e-1]-d)?t[e-1]:t[e]),d/nc[f-1]/c[f]?{x:n,y:n}:null}var r,o=p(e.x),i=p(e.y),a=Math.max(e.x,e.y),u=v(o,i),c=[8,10,15,20,32,60,80],s={"x-small":5,small:4,medium:3,large:2,"x-large":1},f=s[t]||s.medium,l=c[f],d=Math.floor(a/l);return r=n(u),r||(r=n(p(a)))||(r=n(p(d*l))),r}function g(t){return{value:parseFloat(t),unit:(t.indexOf("%"),t.length,"%")}}function y(t,e,n){var r={width:t,height:e},o=Object.keys(n).reduce(function(t,e){var o=n[e],i=g(o),a=C[e](i,r);return t[e]=a,t},{});return{sx:o.left,sy:o.top,sw:o.right-o.left,sh:o.bottom-o.top}}var m=n(50),x=n(3);e.b=r,e.f=u,e.g=c,e.h=s,e.c=f,e.d=l,e.i=d,e.a=h,e.e=_,e.j=y;var b={clone:n(7)},E={clone:n(83)},C={top:function(t,e){if("%"===t.unit)return Math.floor(e.height*(t.value/100))},right:function(t,e){if("%"===t.unit)return Math.floor(e.width-e.width*(t.value/100))},bottom:function(t,e){if("%"===t.unit)return Math.floor(e.height-e.height*(t.value/100))},left:function(t,e){if("%"===t.unit)return Math.floor(e.width*(t.value/100))}}},function(t,e,n){"use strict";function r(t,e,n,r){e?this.data=e:n?(this.data=new n(t.x*t.y),n===Array&&r&&a.a.init(this.data,0)):(this.data=new Uint8Array(t.x*t.y),Uint8Array===Array&&r&&a.a.init(this.data,0)),this.size=t}var o=n(53),i=n(19),a=n(3),u={clone:n(7)};r.prototype.inImageWithBorder=function(t,e){return t.x>=e&&t.y>=e&&t.x0&&(a=g[r-1],a.m00+=1,a.m01+=n,a.m10+=e,a.m11+=e*n,a.m02+=o,a.m20+=e*e);for(i=0;i=0?x:-x)+m,a.theta=(180*h/m+90)%180-90,a.theta<0&&(a.theta+=180),a.rad=h>m?h-m:h,a.vec=u.clone([Math.cos(h),Math.sin(h)]),y.push(a));return y},r.prototype.show=function(t,e){var n,r,o,i,a,u,c;for(e||(e=1),n=t.getContext("2d"),t.width=this.size.x,t.height=this.size.y,r=n.getImageData(0,0,t.width,t.height),o=r.data,i=0,c=0;c360)&&(e=360);for(var o=[0,1,1],a=[0,0,0],u=[255,255,255],c=[0,0,0],s=[],f=t.getContext("2d"),l=f.getImageData(r.x,r.y,this.size.x,this.size.y),d=l.data,h=this.data.length;h--;)o[0]=this.data[h]*e,s=o[0]<=0?u:o[0]>=360?c:n.i(i.a)(o,a),d[4*h+0]=s[0],d[4*h+1]=s[1],d[4*h+2]=s[2],d[4*h+3]=255;f.putImageData(l,r.x,r.y)},e.a=r},function(t,e,n){function r(t,e,n){"__proto__"==e&&o?o(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var o=n(37);t.exports=r},function(t,e,n){function r(t,e){var n=i(t,e);return o(n)?n:void 0}var o=n(97),i=n(120);t.exports=r},function(t,e,n){function r(t){if("string"==typeof t||o(t))return t;var e=t+"";return"0"==e&&1/t==-i?"-0":e}var o=n(27),i=1/0;t.exports=r},function(t,e,n){function r(t){return null!=t&&i(t.length)&&!o(t)}var o=n(25),i=n(26);t.exports=r},function(t,e,n){function r(t){if(!i(t))return!1;var e=o(t);return e==u||e==c||e==a||e==s}var o=n(8),i=n(0),a="[object AsyncFunction]",u="[object Function]",c="[object GeneratorFunction]",s="[object Proxy]";t.exports=r},function(t,e){function n(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=r}var r=9007199254740991;t.exports=n},function(t,e,n){function r(t){return"symbol"==typeof t||i(t)&&o(t)==a}var o=n(8),i=n(6),a="[object Symbol]";t.exports=r},function(t,e,n){var r=n(100),o=n(116),i=o(function(t,e,n){r(t,e,n)});t.exports=i},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){"use strict";var r={searchDirections:[[0,1],[1,1],[1,0],[1,-1],[0,-1],[-1,-1],[-1,0],[-1,1]],create:function(t,e){function n(t,e,n,r){var o,f,l;for(o=0;o<7;o++){if(f=t.cy+c[t.dir][0],l=t.cx+c[t.dir][1],i=f*s+l,a[i]===e&&(0===u[i]||u[i]===n))return u[i]=n,t.cy=f,t.cx=l,!0;0===u[i]&&(u[i]=r),t.dir=(t.dir+1)%8}return!1}function r(t,e,n){return{dir:n,x:t,y:e,next:null,prev:null}}function o(t,e,o,i,a){var u,c,s,f=null,l={cx:e,cy:t,dir:0};if(n(l,i,o,a)){f=r(e,t,l.dir),u=f,s=l.dir,c=r(l.cx,l.cy,0),c.prev=u,u.next=c,c.next=null,u=c;do l.dir=(l.dir+6)%8,n(l,i,o,a),s!==l.dir?(u.dir=l.dir,c=r(l.cx,l.cy,0),c.prev=u,u.next=c,c.next=null,u=c):(u.dir=s,u.x=l.cx,u.y=l.cy),s=l.dir;while(l.cx!==e||l.cy!==t);f.prev=u.prev,u.prev.next=f}return f}var i,a=t.data,u=e.data,c=this.searchDirections,s=t.size.x;return{trace:function(t,e,r,o){return n(t,e,r,o)},contourTracing:function(t,e,n,r,i){return o(t,e,n,r,i)}}}};e.a=r},function(t,e,n){"use strict";function r(){o.a.call(this)}var o=n(1),i=n(3),a={ALPHABETH_STRING:{value:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%"},ALPHABET:{value:[48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,45,46,32,42,36,47,43,37]},CHARACTER_ENCODINGS:{value:[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,148,168,162,138,42]},ASTERISK:{value:148},FORMAT:{value:"code_39",writeable:!1}};r.prototype=Object.create(o.a.prototype,a),r.prototype.constructor=r,r.prototype._decode=function(){var t,e,n,r,o=this,a=[0,0,0,0,0,0,0,0,0],u=[],c=o._findStart();if(!c)return null;r=o._nextSet(o._row,c.end);do{if(a=o._toCounters(r,a),(n=o._toPattern(a))<0)return null;if((t=o._patternToChar(n))<0)return null;u.push(t),e=r,r+=i.a.sum(a),r=o._nextSet(o._row,r)}while("*"!==t);return u.pop(),u.length&&o._verifyTrailingWhitespace(e,r,a)?{code:u.join(""),start:c.start,end:r,startInfo:c,decodedCodes:u}:null},r.prototype._verifyTrailingWhitespace=function(t,e,n){var r=i.a.sum(n);return 3*(e-t-r)>=r},r.prototype._patternToChar=function(t){var e,n=this;for(e=0;ee&&(r=t[n]);return r},r.prototype._toPattern=function(t){for(var e,n,r=t.length,o=0,i=r,a=0,u=this;i>3;){for(o=u._findNextWidth(t,o),i=0,e=0,n=0;no&&(e|=1<0;n++)if(t[n]>o&&(i--,2*t[n]>=a))return-1;return e}}return-1},r.prototype._findStart=function(){var t,e,n,r=this,o=r._nextSet(r._row),i=o,a=[0,0,0,0,0,0,0,0,0],u=0,c=!1;for(t=o;t0)for(r=0;r0){if(!(t=Y.filter(function(t){return!t.busy})[0]))return;w.attachData(t.imageData)}else w.attachData(S.data);w.grab()&&(t?(t.busy=!0,t.worker.postMessage({cmd:"process",imageData:t.imageData},[t.imageData.buffer])):_())}else _()}function y(){var t=null,e=1e3/($.frequency||60);T=!1,function n(r){t=t||r,T||(r>=t&&(t+=e,g()),window.requestAnimFrame(n))}(performance.now())}function m(){Q&&"LiveStream"===$.inputStream.type?y():g()}function x(t){var e,n={worker:void 0,imageData:new Uint8Array(R.getWidth()*R.getHeight()),busy:!0};e=C(),n.worker=new Worker(e),n.worker.onmessage=function(r){if("initialized"===r.data.event)return URL.revokeObjectURL(e),n.busy=!1,n.imageData=new Uint8Array(r.data.imageData),t(n);"processed"===r.data.event?(n.imageData=new Uint8Array(r.data.imageData),n.busy=!1,v(r.data.result,n.imageData)):r.data.event},n.worker.postMessage({cmd:"init",size:{x:R.getWidth(),y:R.getHeight()},imageData:n.imageData,config:b($)},[n.imageData.buffer])}function b(t){return X({},t,{inputStream:X({},t.inputStream,{target:null})})}function E(t){function e(t){self.postMessage({event:"processed",imageData:o.data,result:t},[o.data.buffer])}function n(){self.postMessage({event:"initialized",imageData:o.data},[o.data.buffer])}if(t){var r=t().default;if(!r)return void self.postMessage({event:"error",message:"Quagga could not be created"})}var o;self.onmessage=function(t){if("init"===t.data.cmd){var i=t.data.config;i.numOfWorkers=0,o=new r.ImageWrapper({x:t.data.size.x,y:t.data.size.y},new Uint8Array(t.data.imageData)),r.init(i,n,o),r.onProcessed(e)}else"process"===t.data.cmd?(o.data=new Uint8Array(t.data.imageData),r.start()):"setReaders"===t.data.cmd&&r.setReaders(t.data.readers)}}function C(){var e,n;return void 0!==t&&(n=t),e=new Blob(["("+E.toString()+")("+n+");"],{type:"text/javascript"}),window.URL.createObjectURL(e)}function O(t){P?P.setReaders(t):Q&&Y.length>0&&Y.forEach(function(e){e.worker.postMessage({cmd:"setReaders",readers:t})})}function A(t,e){var n=t-Y.length;if(0===n)return e&&e();if(n<0){return Y.slice(n).forEach(function(t){t.worker.terminate()}),Y=Y.slice(0,n),e&&e()}for(var r=function(n){Y.push(n),Y.length>=t&&e&&e()},o=0;oe},getPoints:function(){return a},getCenter:function(){return u}}},createPoint:function(t,e,n){return{rad:t[n],point:t,id:e}}}},function(t,e,n){"use strict";e.a=function(){function t(t){return o[t]||(o[t]={subscribers:[]}),o[t]}function e(){o={}}function n(t,e){t.async?setTimeout(function(){t.callback(e)},4):t.callback(e)}function r(e,n,r){var o;if("function"==typeof n)o={callback:n,async:r};else if(o=n,!o.callback)throw"Callback was not specified on options";t(e).subscribers.push(o)}var o={};return{subscribe:function(t,e,n){return r(t,e,n)},publish:function(e,r){var o=t(e),i=o.subscribers;i.filter(function(t){return!!t.once}).forEach(function(t){n(t,r)}),o.subscribers=i.filter(function(t){return!t.once}),o.subscribers.forEach(function(t){n(t,r)})},once:function(t,e,n){r(t,{callback:e,async:n,once:!0})},unsubscribe:function(n,r){var o;n?(o=t(n),o.subscribers=o&&r?o.subscribers.filter(function(t){return t.callback!==r}):[]):e()}}}()},function(t,e,n){"use strict";function r(){return navigator.mediaDevices&&"function"==typeof navigator.mediaDevices.enumerateDevices?navigator.mediaDevices.enumerateDevices():Promise.reject(new Error("enumerateDevices is not defined"))}function o(t){return navigator.mediaDevices&&"function"==typeof navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia(t):Promise.reject(new Error("getUserMedia is not defined"))}e.b=r,e.a=o},function(t,e,n){"use strict";function r(t,e,n){n||(n={data:null,size:e}),this.data=n.data,this.originalSize=n.size,this.I=n,this.from=t,this.size=e}r.prototype.show=function(t,e){var n,r,o,i,a,u,c;for(e||(e=1),n=t.getContext("2d"),t.width=this.size.x,t.height=this.size.y,r=n.getImageData(0,0,t.width,t.height),o=r.data,i=0,a=0;a>>16&65535,r=65535&t,o=e>>>16&65535,i=65535&e;return r*i+(n*i+r*o<<16>>>0)|0},"function"!=typeof Object.assign&&(Object.assign=function(t){"use strict";if(null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n1&&(!e.inImageWithBorder(t[0],0)||!e.inImageWithBorder(t[1],0));)r-=Math.ceil(r/2),o(-r);return t}function u(t){return[{x:(t[1][0]-t[0][0])/2+t[0][0],y:(t[1][1]-t[0][1])/2+t[0][1]},{x:(t[3][0]-t[2][0])/2+t[2][0],y:(t[3][1]-t[2][1])/2+t[2][1]}]}function c(t){var n,o=null,i=r.a.getBarcodeLine(e,t[0],t[1]);for(r.a.toBinaryLine(i),n=0;nE?l:E,g.push(l)}var o,i,a,u,c,s,f,l,d=0|e.x,h=0|e.y,p=0|n.x,v=0|n.y,_=Math.abs(v-h)>Math.abs(p-d),g=[],y=t.data,m=t.size.x,x=0,b=255,E=0;for(_&&(s=d,d=h,h=s,s=p,p=v,v=s),d>p&&(s=d,d=p,p=s,s=h,h=v,v=s),o=p-d,i=Math.abs(v-h),a=o/2|0,c=h,u=hl?o.DIR.UP:o.DIR.DOWN,d.push({pos:0,val:f[0]}),a=0;ah&&f[a+1]>.5*l?o.DIR.UP:r,r!==i&&(d.push({pos:a,val:f[a]}),r=i);for(d.push({pos:f.length,val:f[f.length-1]}),u=d[0].pos;ul?0:1;for(a=1;ad[a].val?d[a].val+(d[a+1].val-d[a].val)/3*2|0:d[a+1].val+(d[a].val-d[a+1].val)/3|0,u=d[a].pos;uh?0:1;return{line:f,threshold:h}},r.debug={printFrequency:function(t,e){var n,r=e.getContext("2d");for(e.width=t.length,e.height=256,r.beginPath(),r.strokeStyle="blue",n=0;n0?t.videoWidth>10&&t.videoHeight>10?e():window.setTimeout(r,500):n("Unable to play video stream. Is webcam working?"),o--}var o=10;r()})}function o(t,e){return n.i(d.a)(e).then(function(e){return new Promise(function(n){s=e,t.setAttribute("autoplay",!0),t.setAttribute("muted",!0),t.setAttribute("playsinline",!0),t.srcObject=e,t.addEventListener("loadedmetadata",function(){t.play(),n()})})}).then(r.bind(null,t))}function i(t){var e=l()(t,["width","height","facingMode","aspectRatio","deviceId"]);return void 0!==t.minAspectRatio&&t.minAspectRatio>0&&(e.aspectRatio=t.minAspectRatio,console.log("WARNING: Constraint 'minAspectRatio' is deprecated; Use 'aspectRatio' instead")),void 0!==t.facing&&(e.facingMode=t.facing,console.log("WARNING: Constraint 'facing' is deprecated. Use 'facingMode' instead'")),e}function a(t){var e={audio:!1,video:i(t)};return e.video.deviceId&&e.video.facingMode&&delete e.video.facingMode,Promise.resolve(e)}function u(){return n.i(d.b)().then(function(t){return t.filter(function(t){return"videoinput"===t.kind})})}function c(){if(s){var t=s.getVideoTracks();if(t&&t.length)return t[0]}}var s,f=n(162),l=n.n(f),d=n(52);e.a={request:function(t,e){return a(e).then(o.bind(null,t))},release:function(){var t=s&&s.getVideoTracks();t&&t.length&&t[0].stop(),s=null},enumerateVideoDevices:u,getActiveStreamLabel:function(){var t=c();return t?t.label:""},getActiveTrack:c}},function(t,e,n){"use strict";function r(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;return/^blob\:/i.test(t)?i(t).then(o).then(function(t){return a(t,e)}):Promise.resolve(null)}function o(t){return new Promise(function(e){var n=new FileReader;n.onload=function(t){return e(t.target.result)},n.readAsArrayBuffer(t)})}function i(t){return new Promise(function(e,n){var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="blob",r.onreadystatechange=function(){r.readyState!==XMLHttpRequest.DONE||200!==r.status&&0!==r.status||e(this.response)},r.onerror=n,r.send()})}function a(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d,n=new DataView(t),r=t.byteLength,o=e.reduce(function(t,e){var n=Object.keys(l).filter(function(t){return l[t]===e})[0];return n&&(t[n]=e),t},{}),i=2;if(255!==n.getUint8(0)||216!==n.getUint8(1))return!1;for(;i1?i.size:Math.floor(e/o*i.size):e,r=i.size?e/o>1?Math.floor(o/e*i.size):i.size:o,s.x=n,s.y=r}var n,r,o={},i=null,a=["canrecord","ended"],u={},c={x:0,y:0},s={x:0,y:0};return o.getRealWidth=function(){return t.videoWidth},o.getRealHeight=function(){return t.videoHeight},o.getWidth=function(){return n},o.getHeight=function(){return r},o.setWidth=function(t){n=t},o.setHeight=function(t){r=t},o.setInputStream=function(e){i=e,t.src=void 0!==e.src?e.src:""},o.ended=function(){return t.ended},o.getConfig=function(){return i},o.setAttribute=function(e,n){t.setAttribute(e,n)},o.pause=function(){t.pause()},o.play=function(){t.play()},o.setCurrentTime=function(e){"LiveStream"!==i.type&&(t.currentTime=e)},o.addEventListener=function(e,n,r){a.indexOf(e)!==-1?(u[e]||(u[e]=[]),u[e].push(n)):t.addEventListener(e,n,r)},o.clearEventHandlers=function(){a.forEach(function(e){var n=u[e];n&&n.length>0&&n.forEach(function(n){t.removeEventListener(e,n)})})},o.trigger=function(t,n){var r,i=u[t];if("canrecord"===t&&e(),i&&i.length>0)for(r=0;r1?a.size:Math.floor(u/c*a.size):u,o=a.size?u/c>1?Math.floor(c/u*a.size):a.size:c,x.x=n,x.y=o,l=!0,s=0,setTimeout(function(){e("canrecord",[])},0)},p,h,a.sequence)}function e(t,e){var n,r=y[t];if(r&&r.length>0)for(n=0;nf&&(f=o.box[r][0]),o.box[r][1]l&&(l=o.box[r][1]);for(a=[[c,s],[f,s],[f,l],[c,l]],u=p.halfSample?2:1,i=M.invert(i,i),r=0;r<4;r++)I.transformMat2(a[r],a[r],i);for(r=0;r<4;r++)I.scale(a[r],a[r],u);return a}function a(){n.i(w.f)(v,E),E.zeroBorder()}function u(){var t,e,n,r,o,i,a,u=[];for(t=0;t0&&r[x.data[n]-1]++;return r=r.map(function(t,e){return{val:t,label:e+1}}),r.sort(function(t,e){return e.val-t.val}),r.filter(function(t){return t.val>=5})}function s(t,e){var n,r,o,a,u=[],c=[];for(n=0;n=2){for(o=0;ol&&c.push(t[o]);if(c.length>=2){for(a=f(c),i=0,o=0;o1&&a.length>=c.length/4*3&&a.length>t.length/4&&(i/=a.length,u={index:e[1]*z.x+e[0],pos:{x:n,y:r},box:[I.clone([n,r]),I.clone([n+g.size.x,r]),I.clone([n+g.size.x,r+g.size.y]),I.clone([n,r+g.size.y])],moments:a,rad:i,vec:I.clone([Math.cos(i),Math.sin(i)])},s.push(u))}}return s}function h(t){function e(){var t;for(t=0;ta&&n(u):x.data[u]=Number.MAX_VALUE}var r,o,i=0,a=.95,u=0;for(T.a.init(m.data,0),T.a.init(x.data,0),T.a.init(b.data,null),r=0;r0) {length=length - 1|0;images[outImagePtr+length|0]=(images[aImagePtr+length|0]|0) - (images[bImagePtr+length|0]|0)|0;}}function bitwiseOr(aImagePtr, bImagePtr, outImagePtr) {aImagePtr=aImagePtr|0;bImagePtr=bImagePtr|0;outImagePtr=outImagePtr|0;var length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;images[outImagePtr+length|0]=images[aImagePtr+length|0]|0|(images[bImagePtr+length|0]|0)|0;}}function countNonZero(imagePtr) {imagePtr=imagePtr|0;var sum=0,length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;sum=(sum|0)+(images[imagePtr+length|0]|0)|0;}return sum|0;}function init(imagePtr, value) {imagePtr=imagePtr|0;value=value|0;var length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;images[imagePtr+length|0]=value;}}function dilate(inImagePtr, outImagePtr) {inImagePtr=inImagePtr|0;outImagePtr=outImagePtr|0;var v=0,u=0,sum=0,yStart1=0,yStart2=0,xStart1=0,xStart2=0,offset=0;for (v=1; (v|0)<(size - 1|0); v=v+1|0) {offset=offset+size|0;for (u=1; (u|0)<(size - 1|0); u=u+1|0) {yStart1=offset - size|0;yStart2=offset+size|0;xStart1=u - 1|0;xStart2=u+1|0;sum=(images[inImagePtr+yStart1+xStart1|0]|0)+(images[inImagePtr+yStart1+xStart2|0]|0)+(images[inImagePtr+offset+u|0]|0)+(images[inImagePtr+yStart2+xStart1|0]|0)+(images[inImagePtr+yStart2+xStart2|0]|0)|0;if ((sum|0)>(0|0)) {images[outImagePtr+offset+u|0]=1;} else {images[outImagePtr+offset+u|0]=0;}}}return;}function memcpy(srcImagePtr, dstImagePtr) {srcImagePtr=srcImagePtr|0;dstImagePtr=dstImagePtr|0;var length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;images[dstImagePtr+length|0]=images[srcImagePtr+length|0]|0;}}function zeroBorder(imagePtr) {imagePtr=imagePtr|0;var x=0,y=0;for (x=0; (x|0)<(size - 1|0); x=x+1|0) {images[imagePtr+x|0]=0;images[imagePtr+y|0]=0;y=y+size - 1|0;images[imagePtr+y|0]=0;y=y+1|0;}for (x=0; (x|0)<(size|0); x=x+1|0) {images[imagePtr+y|0]=0;y=y+1|0;}}function skeletonize() {var subImagePtr=0,erodedImagePtr=0,tempImagePtr=0,skelImagePtr=0,sum=0,done=0;erodedImagePtr=imul(size, size)|0;tempImagePtr=erodedImagePtr+erodedImagePtr|0;skelImagePtr=tempImagePtr+erodedImagePtr|0;init(skelImagePtr, 0);zeroBorder(subImagePtr);do {erode(subImagePtr, erodedImagePtr);dilate(erodedImagePtr, tempImagePtr);subtract(subImagePtr, tempImagePtr, tempImagePtr);bitwiseOr(skelImagePtr, tempImagePtr, skelImagePtr);memcpy(erodedImagePtr, subImagePtr);sum=countNonZero(subImagePtr)|0;done=(sum|0) == 0|0;} while (!done);}return {skeletonize: skeletonize};} __webpack_exports__["a"]=Skeletonizer; },function(t,e,n){"use strict";function r(t){o.a.call(this,t),this.barSpaceRatio=[1,1]}var o=n(1),i=1,a=3,u={START_PATTERN:{value:[a,i,a,i,i,i]},STOP_PATTERN:{value:[a,i,i,i,a]},CODE_PATTERN:{value:[[i,i,a,a,i],[a,i,i,i,a],[i,a,i,i,a],[a,a,i,i,i],[i,i,a,i,a],[a,i,a,i,i],[i,a,a,i,i],[i,i,i,a,a],[a,i,i,a,i],[i,a,i,a,i]]},SINGLE_CODE_ERROR:{value:.78,writable:!0},AVG_CODE_ERROR:{value:.3,writable:!0},FORMAT:{value:"2of5"}},c=u.START_PATTERN.value.reduce(function(t,e){return t+e},0);r.prototype=Object.create(o.a.prototype,u),r.prototype.constructor=r,r.prototype._findPattern=function(t,e,n,r){var o,i,a,u,c=[],s=this,f=0,l={error:Number.MAX_VALUE,code:-1,start:0,end:0},d=s.AVG_CODE_ERROR;for(n=n||!1,r=r||!1,e||(e=s._nextSet(s._row)),o=0;o=0&&n._matchRange(t,e.start,0))return e;r=e.end,e=null}},r.prototype._verifyTrailingWhitespace=function(t){var e,n=this;return e=t.end+(t.end-t.start)/2,e1&&i._isStartEnd(n))break}while(ri._counters.length?i._counters.length:r,o=t.start+i._sumCounters(t.startCounter,r-8),{code:a.join(""),start:t.start,end:o,startInfo:t,decodedCodes:a}):null},r.prototype._verifyWhitespace=function(t,e){return(t-1<=0||this._counters[t-1]>=this._calculatePatternLength(t)/2)&&(e+8>=this._counters.length||this._counters[e+7]>=this._calculatePatternLength(e)/2)},r.prototype._calculatePatternLength=function(t){var e,n=0;for(e=t;e=0;i--)n=2==(1&i)?c.bar:c.space,r=1==(1&a)?n.wide:n.narrow,r.size+=u._counters[s+i],r.counts++,a>>=1;s+=8}return["space","bar"].forEach(function(t){var e=c[t];e.wide.min=Math.floor((e.narrow.size/e.narrow.counts+e.wide.size/e.wide.counts)/2),e.narrow.max=Math.ceil(e.wide.min),e.wide.max=Math.ceil((e.wide.size*u.MAX_ACCEPTABLE+u.PADDING)/e.wide.counts)}),c},r.prototype._charToPattern=function(t){var e,n=this,r=t.charCodeAt(0);for(e=0;e=0;r--){if(o=0==(1&r)?s.bar:s.space,i=1==(1&u)?o.wide:o.narrow,(a=c._counters[f+r])i.max)return!1;u>>=1}f+=8}return!0},r.prototype._patternToChar=function(t){var e,n=this;for(e=0;ei&&(i=r),rthis._counters.length)return-1;for(e=this._computeAlternatingThreshold(t,a),n=this._computeAlternatingThreshold(t+1,a),r=0;ro&&(c|=u),u>>=1;return c},r.prototype._isStartEnd=function(t){var e;for(e=0;eu.AVG_CODE_ERROR?null:(u.CODE_PATTERN[l.code]&&(l.correction.bar=o(u.CODE_PATTERN[l.code],a,this.MODULE_INDICES.bar),l.correction.space=o(u.CODE_PATTERN[l.code],a,this.MODULE_INDICES.space)),l)}f++,a[f]=1,s=!s}return null},r.prototype._correct=function(t,e){this._correctBars(t,e.bar,this.MODULE_INDICES.bar),this._correctBars(t,e.space,this.MODULE_INDICES.space)},r.prototype._findStart=function(){var t,e,n,r,i,a=[0,0,0,0,0,0],u=this,c=u._nextSet(u._row),s=!1,f=0,l={error:Number.MAX_VALUE,code:-1,start:0,end:0,correction:{bar:1,space:1}};for(t=c;t4)return-1;if(0==(1&i))for(var u=0;u="a"&&o<="d"){if(r>e-2)return null;var i=t[++r],a=i.charCodeAt(0),u=void 0;switch(o){case"a":if(!(i>="A"&&i<="Z"))return null;u=String.fromCharCode(a-64);break;case"b":if(i>="A"&&i<="E")u=String.fromCharCode(a-38);else if(i>="F"&&i<="J")u=String.fromCharCode(a-11);else if(i>="K"&&i<="O")u=String.fromCharCode(a+16);else if(i>="P"&&i<="S")u=String.fromCharCode(a+43);else{if(!(i>="T"&&i<="Z"))return null;u=String.fromCharCode(127)}break;case"c":if(i>="A"&&i<="O")u=String.fromCharCode(a-32);else{if("Z"!==i)return null;u=":"}break;case"d":if(!(i>="A"&&i<="Z"))return null;u=String.fromCharCode(a+32)}n.push(u)}else n.push(o)}return n},r.prototype._verifyChecksums=function(t){return this._matchCheckChar(t,t.length-2,20)&&this._matchCheckChar(t,t.length-1,15)},r.prototype._matchCheckChar=function(t,e,n){var r=this,o=t.slice(0,e),i=o.length,a=o.reduce(function(t,e,o){return t+((o*-1+(i-1))%n+1)*r.ALPHABET.indexOf(e.charCodeAt(0))},0);return this.ALPHABET[a%47]===t[e].charCodeAt(0)},e.a=r},function(t,e,n){"use strict";function r(){o.a.call(this)}var o=n(4),i={FORMAT:{value:"ean_2",writeable:!1}};r.prototype=Object.create(o.a.prototype,i),r.prototype.constructor=r,r.prototype.decode=function(t,e){this._row=t;var n,r=0,o=0,i=e,a=this._row.length,u=[],c=[];for(o=0;o<2&&i=this.CODE_G_START&&(r|=1<<1-o),1!=o&&(i=this._nextSet(this._row,n.end),i=this._nextUnset(this._row,i))}return 2!=u.length||parseInt(u.join(""))%4!==r?null:{code:u.join(""),decodedCodes:c,end:n.end}},e.a=r},function(t,e,n){"use strict";function r(){a.a.call(this)}function o(t){var e;for(e=0;e<10;e++)if(t===c[e])return e;return null}function i(t){var e,n=t.length,r=0;for(e=n-2;e>=0;e-=2)r+=t[e];for(r*=3,e=n-1;e>=0;e-=2)r+=t[e];return(r*=3)%10}var a=n(4),u={FORMAT:{value:"ean_5",writeable:!1}},c=[24,20,18,17,12,6,3,10,9,5];r.prototype=Object.create(a.a.prototype,u),r.prototype.constructor=r,r.prototype.decode=function(t,e){this._row=t;var n,r=0,a=0,u=e,c=this._row.length,s=[],f=[];for(a=0;a<5&&u=this.CODE_G_START&&(r|=1<<4-a),4!=a&&(u=this._nextSet(this._row,n.end),u=this._nextUnset(this._row,u))}return 5!=s.length?null:i(s)!==o(r)?null:{code:s.join(""),decodedCodes:f,end:n.end}},e.a=r},function(t,e,n){"use strict";function r(t,e){o.a.call(this,t,e)}var o=n(4),i={FORMAT:{value:"ean_8",writeable:!1}};r.prototype=Object.create(o.a.prototype,i),r.prototype.constructor=r,r.prototype._decodePayload=function(t,e,n){var r,o=this;for(r=0;r<4;r++){if(!(t=o._decodeCode(t.end,o.CODE_G_START)))return null;e.push(t.code),n.push(t)}if(null===(t=o._findPattern(o.MIDDLE_PATTERN,t.end,!0,!1)))return null;for(n.push(t),r=0;r<4;r++){if(!(t=o._decodeCode(t.end,o.CODE_G_START)))return null;n.push(t),e.push(t.code)}return t},e.a=r},function(t,e,n){"use strict";function r(t){t=a()(o(),t),u.a.call(this,t),this.barSpaceRatio=[1,1],t.normalizeBarSpaceWidth&&(this.SINGLE_CODE_ERROR=.38,this.AVG_CODE_ERROR=.09)}function o(){var t={};return Object.keys(r.CONFIG_KEYS).forEach(function(e){t[e]=r.CONFIG_KEYS[e].default}),t}var i=n(28),a=n.n(i),u=n(1),c=1,s=3,f={START_PATTERN:{value:[c,c,c,c]},STOP_PATTERN:{value:[c,c,s]},CODE_PATTERN:{value:[[c,c,s,s,c],[s,c,c,c,s],[c,s,c,c,s],[s,s,c,c,c],[c,c,s,c,s],[s,c,s,c,c],[c,s,s,c,c],[c,c,c,s,s],[s,c,c,s,c],[c,s,c,s,c]]},SINGLE_CODE_ERROR:{value:.78,writable:!0},AVG_CODE_ERROR:{value:.38,writable:!0},MAX_CORRECTION_FACTOR:{value:5},FORMAT:{value:"i2of5"}};r.prototype=Object.create(u.a.prototype,f),r.prototype.constructor=r,r.prototype._matchPattern=function(t,e){if(this.config.normalizeBarSpaceWidth){var n,r=[0,0],o=[0,0],i=[0,0],a=this.MAX_CORRECTION_FACTOR,c=1/a;for(n=0;n=0&&n._matchRange(t,e.start,0))return e;r=e.end,e=null}},r.prototype._verifyTrailingWhitespace=function(t){var e,n=this;return e=t.end+(t.end-t.start)/2,e=o.CODE_G_START&&(t.code=t.code-o.CODE_G_START,i|=1<<5-r),e.push(t.code),n.push(t)}return o._determineParity(i,e)?t:null},r.prototype._determineParity=function(t,e){var n,r;for(r=0;r0&&n(f)?e>1?r(f,e-1,n,a,u):o(u,f):a||(u[u.length]=f)}return u}var o=n(90),i=n(128);t.exports=r},function(t,e,n){var r=n(117),o=r();t.exports=o},function(t,e,n){function r(t,e){e=o(e,t);for(var n=0,r=e.length;null!=t&&n1?n[o-1]:void 0,u=o>2?n[2]:void 0;for(a=t.length>3&&"function"==typeof a?(o--,a):void 0,u&&i(n[0],n[1],u)&&(a=o<3?void 0:a,o=1),e=Object(e);++r-1}var o=n(12);t.exports=r},function(t,e,n){function r(t,e){var n=this.__data__,r=o(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var o=n(12);t.exports=r},function(t,e,n){function r(){this.size=0,this.__data__={hash:new o,map:new(a||i),string:new o}}var o=n(84),i=n(10),a=n(33);t.exports=r},function(t,e,n){function r(t){var e=o(this,t).delete(t);return this.size-=e?1:0,e}var o=n(14);t.exports=r},function(t,e,n){function r(t){return o(this,t).get(t)}var o=n(14);t.exports=r},function(t,e,n){function r(t){return o(this,t).has(t)}var o=n(14);t.exports=r},function(t,e,n){function r(t,e){var n=o(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}var o=n(14);t.exports=r},function(t,e,n){function r(t){var e=o(t,function(t){return n.size===i&&n.clear(),t}),n=e.cache;return e}var o=n(161),i=500;t.exports=r},function(t,e){function n(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}t.exports=n},function(t,e,n){(function(t){var r=n(38),o="object"==typeof e&&e&&!e.nodeType&&e,i=o&&"object"==typeof t&&t&&!t.nodeType&&t,a=i&&i.exports===o,u=a&&r.process,c=function(){try{return u&&u.binding&&u.binding("util")}catch(t){}}();t.exports=c}).call(e,n(29)(t))},function(t,e){function n(t){return o.call(t)}var r=Object.prototype,o=r.toString;t.exports=n},function(t,e){function n(t,e){return function(n){return t(e(n))}}t.exports=n},function(t,e){function n(t){var e=0,n=0;return function(){var a=i(),u=o-(a-n);if(n=a,u>0){if(++e>=r)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var r=800,o=16,i=Date.now;t.exports=n},function(t,e,n){function r(){this.__data__=new o,this.size=0}var o=n(10);t.exports=r},function(t,e){function n(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}t.exports=n},function(t,e){function n(t){return this.__data__.get(t)}t.exports=n},function(t,e){function n(t){return this.__data__.has(t)}t.exports=n},function(t,e,n){function r(t,e){var n=this.__data__;if(n instanceof o){var r=n.__data__;if(!i||r.length{% trans "Search" %} + + {% include "search/barcode_modal.html" with id="barcode_scanner_modal" %} - {% endblock %} From 82cb170a9112193ed8040f5f0a47bae63e7ffeff Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Tue, 15 Feb 2022 02:39:16 -0800 Subject: [PATCH 03/24] Switch version of quagga to new fork quagga2 --- bookwyrm/static/js/vendor/quagga.min.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bookwyrm/static/js/vendor/quagga.min.js b/bookwyrm/static/js/vendor/quagga.min.js index f7a30f41..84ccb74f 100644 --- a/bookwyrm/static/js/vendor/quagga.min.js +++ b/bookwyrm/static/js/vendor/quagga.min.js @@ -1 +1,3 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(e.toString()).default:"object"==typeof exports?exports.Quagga=e(e.toString()).default:t.Quagga=e(e.toString()).default}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=166)}([function(t,e){function n(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}t.exports=n},function(t,e,n){"use strict";function r(t,e){return this._row=[],this.config=t||{},this.supplements=e,this}var o=n(3);r.prototype._nextUnset=function(t,e){var n;for(void 0===e&&(e=0),n=e;nn)return Number.MAX_VALUE;u+=c}return u/f},r.prototype._nextSet=function(t,e){var n;for(e=e||0,n=e;n1&&(t[n[r]]=o)},r.prototype._matchTrace=function(t,e){var n,r,o=[],i=this,a=i._nextSet(i._row),u=!i._row[a],c=0,s={error:Number.MAX_VALUE,code:-1,start:0};if(t){for(n=0;n=0;r--)e=Math.floor(Math.random()*r),n=t[r],t[r]=t[e],t[e]=n;return t},toPointList:function(t){var e,n,r=[],o=[];for(e=0;e=e&&o.push(t[r]);return o},maxIndex:function(t){var e,n=0;for(e=0;et[n]&&(n=e);return n},max:function t(e){var n,t=0;for(n=0;nt&&(t=e[n]);return t},sum:function t(e){for(var n=e.length,t=0;n--;)t+=e[n];return t}}},function(t,e,n){"use strict";function r(t,e){t=a()(o(),t),u.a.call(this,t,e)}function o(){var t={};return Object.keys(r.CONFIG_KEYS).forEach(function(e){t[e]=r.CONFIG_KEYS[e].default}),t}var i=n(28),a=n.n(i),u=n(1),c=Object.assign||function(t){for(var e=1;ea.AVG_CODE_ERROR?null:f}s++,i[s]=1,c=!c}return null},r.prototype._findPattern=function(t,e,n,r,o){var i,a,u,c,s=[],f=this,l=0,d={error:Number.MAX_VALUE,code:-1,start:0,end:0};for(e||(e=f._nextSet(f._row)),void 0===n&&(n=!1),void 0===r&&(r=!0),void 0===o&&(o=f.AVG_CODE_ERROR),i=0;i=0&&n._matchRange(t,e.start,0))return e;r=e.end,e=null}},r.prototype._verifyTrailingWhitespace=function(t){var e,n=this;return e=t.end+(t.end-t.start),e=i.CODE_G_START?(t.code=t.code-i.CODE_G_START,a|=1<<5-r):a|=0<<5-r,e.push(t.code),n.push(t)}if(null===(o=i._calculateFirstDigit(a)))return null;if(e.unshift(o),null===(t=i._findPattern(i.MIDDLE_PATTERN,t.end,!0,!1)))return null;for(n.push(t),r=0;r<6;r++){if(!(t=i._decodeCode(t.end,i.CODE_G_START)))return null;n.push(t),e.push(t.code)}return t},r.prototype._decode=function(){var t,e,n=this,r=[],o=[],i={};if(!(t=n._findStart()))return null;if(e={code:t.code,start:t.start,end:t.end},o.push(e),!(e=n._decodePayload(e,r,o)))return null;if(!(e=n._findEnd(e.end,!1)))return null;if(o.push(e),!n._checksum(r))return null;if(this.supplements.length>0){var a=this._decodeExtensions(e.end);if(!a)return null;var u=a.decodedCodes[a.decodedCodes.length-1],s={start:u.start+((u.end-u.start)/2|0),end:u.end};if(!n._verifyTrailingWhitespace(s))return null;i={supplement:a,code:r.join("")+a.code}}return c({code:r.join(""),start:t.start,end:e.end,codeset:"",startInfo:t,decodedCodes:o},i)},r.prototype._decodeExtensions=function(t){var e,n,r=this._nextSet(this._row,t),o=this._findPattern(this.EXTENSION_START_PATTERN,r,!1,!1);if(null===o)return null;for(e=0;e=0;e-=2)n+=t[e];for(n*=3,e=t.length-1;e>=0;e-=2)n+=t[e];return n%10==0},r.CONFIG_KEYS={supplements:{type:"arrayOf(string)",default:[],description:"Allowed extensions to be decoded (2 and/or 5)"}},e.a=r},function(t,e,n){var r=n(38),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();t.exports=i},function(t,e){function n(t){return null!=t&&"object"==typeof t}t.exports=n},function(t,e){function n(t){var e=new Float32Array(2);return e[0]=t[0],e[1]=t[1],e}t.exports=n},function(t,e,n){function r(t){return null==t?void 0===t?c:u:s&&s in Object(t)?i(t):a(t)}var o=n(11),i=n(119),a=n(146),u="[object Null]",c="[object Undefined]",s=o?o.toStringTag:void 0;t.exports=r},function(t,e,n){"use strict";e.a={drawRect:function(t,e,n,r){n.strokeStyle=r.color,n.fillStyle=r.color,n.lineWidth=1,n.beginPath(),n.strokeRect(t.x,t.y,e.x,e.y)},drawPath:function(t,e,n,r){n.strokeStyle=r.color,n.fillStyle=r.color,n.lineWidth=r.lineWidth,n.beginPath(),n.moveTo(t[0][e.x],t[0][e.y]);for(var o=1;o-1&&t%1==0&&t0?Math.floor(this.x+.5):Math.floor(this.x-.5),this.y=this.y>0?Math.floor(this.y+.5):Math.floor(this.y-.5),this}}}function o(t,e,n){n||(n=t);for(var r=t.data,o=r.length,i=n.data;o--;)i[o]=r[o]>o]++;return a}function a(t,e){function n(t,e){var n,r=0;for(n=t;n<=e;n++)r+=a[n];return r}function r(t,e){var n,r=0;for(n=t;n<=e;n++)r+=n*a[n];return r}function o(){var o,u,c,s,f,l,d,h=[0],p=(1<c)for(i=s[u],i.score=o,i.item=t[r],c=Number.MAX_VALUE,a=0;ae[r]?r++:n++;return o}function _(t,e){function n(t){for(var e=0,n=t[Math.floor(t.length/2)];e0&&(n=Math.abs(t[e]-d)>Math.abs(t[e-1]-d)?t[e-1]:t[e]),d/nc[f-1]/c[f]?{x:n,y:n}:null}var r,o=p(e.x),i=p(e.y),a=Math.max(e.x,e.y),u=v(o,i),c=[8,10,15,20,32,60,80],s={"x-small":5,small:4,medium:3,large:2,"x-large":1},f=s[t]||s.medium,l=c[f],d=Math.floor(a/l);return r=n(u),r||(r=n(p(a)))||(r=n(p(d*l))),r}function g(t){return{value:parseFloat(t),unit:(t.indexOf("%"),t.length,"%")}}function y(t,e,n){var r={width:t,height:e},o=Object.keys(n).reduce(function(t,e){var o=n[e],i=g(o),a=C[e](i,r);return t[e]=a,t},{});return{sx:o.left,sy:o.top,sw:o.right-o.left,sh:o.bottom-o.top}}var m=n(50),x=n(3);e.b=r,e.f=u,e.g=c,e.h=s,e.c=f,e.d=l,e.i=d,e.a=h,e.e=_,e.j=y;var b={clone:n(7)},E={clone:n(83)},C={top:function(t,e){if("%"===t.unit)return Math.floor(e.height*(t.value/100))},right:function(t,e){if("%"===t.unit)return Math.floor(e.width-e.width*(t.value/100))},bottom:function(t,e){if("%"===t.unit)return Math.floor(e.height-e.height*(t.value/100))},left:function(t,e){if("%"===t.unit)return Math.floor(e.width*(t.value/100))}}},function(t,e,n){"use strict";function r(t,e,n,r){e?this.data=e:n?(this.data=new n(t.x*t.y),n===Array&&r&&a.a.init(this.data,0)):(this.data=new Uint8Array(t.x*t.y),Uint8Array===Array&&r&&a.a.init(this.data,0)),this.size=t}var o=n(53),i=n(19),a=n(3),u={clone:n(7)};r.prototype.inImageWithBorder=function(t,e){return t.x>=e&&t.y>=e&&t.x0&&(a=g[r-1],a.m00+=1,a.m01+=n,a.m10+=e,a.m11+=e*n,a.m02+=o,a.m20+=e*e);for(i=0;i=0?x:-x)+m,a.theta=(180*h/m+90)%180-90,a.theta<0&&(a.theta+=180),a.rad=h>m?h-m:h,a.vec=u.clone([Math.cos(h),Math.sin(h)]),y.push(a));return y},r.prototype.show=function(t,e){var n,r,o,i,a,u,c;for(e||(e=1),n=t.getContext("2d"),t.width=this.size.x,t.height=this.size.y,r=n.getImageData(0,0,t.width,t.height),o=r.data,i=0,c=0;c360)&&(e=360);for(var o=[0,1,1],a=[0,0,0],u=[255,255,255],c=[0,0,0],s=[],f=t.getContext("2d"),l=f.getImageData(r.x,r.y,this.size.x,this.size.y),d=l.data,h=this.data.length;h--;)o[0]=this.data[h]*e,s=o[0]<=0?u:o[0]>=360?c:n.i(i.a)(o,a),d[4*h+0]=s[0],d[4*h+1]=s[1],d[4*h+2]=s[2],d[4*h+3]=255;f.putImageData(l,r.x,r.y)},e.a=r},function(t,e,n){function r(t,e,n){"__proto__"==e&&o?o(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var o=n(37);t.exports=r},function(t,e,n){function r(t,e){var n=i(t,e);return o(n)?n:void 0}var o=n(97),i=n(120);t.exports=r},function(t,e,n){function r(t){if("string"==typeof t||o(t))return t;var e=t+"";return"0"==e&&1/t==-i?"-0":e}var o=n(27),i=1/0;t.exports=r},function(t,e,n){function r(t){return null!=t&&i(t.length)&&!o(t)}var o=n(25),i=n(26);t.exports=r},function(t,e,n){function r(t){if(!i(t))return!1;var e=o(t);return e==u||e==c||e==a||e==s}var o=n(8),i=n(0),a="[object AsyncFunction]",u="[object Function]",c="[object GeneratorFunction]",s="[object Proxy]";t.exports=r},function(t,e){function n(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=r}var r=9007199254740991;t.exports=n},function(t,e,n){function r(t){return"symbol"==typeof t||i(t)&&o(t)==a}var o=n(8),i=n(6),a="[object Symbol]";t.exports=r},function(t,e,n){var r=n(100),o=n(116),i=o(function(t,e,n){r(t,e,n)});t.exports=i},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){"use strict";var r={searchDirections:[[0,1],[1,1],[1,0],[1,-1],[0,-1],[-1,-1],[-1,0],[-1,1]],create:function(t,e){function n(t,e,n,r){var o,f,l;for(o=0;o<7;o++){if(f=t.cy+c[t.dir][0],l=t.cx+c[t.dir][1],i=f*s+l,a[i]===e&&(0===u[i]||u[i]===n))return u[i]=n,t.cy=f,t.cx=l,!0;0===u[i]&&(u[i]=r),t.dir=(t.dir+1)%8}return!1}function r(t,e,n){return{dir:n,x:t,y:e,next:null,prev:null}}function o(t,e,o,i,a){var u,c,s,f=null,l={cx:e,cy:t,dir:0};if(n(l,i,o,a)){f=r(e,t,l.dir),u=f,s=l.dir,c=r(l.cx,l.cy,0),c.prev=u,u.next=c,c.next=null,u=c;do l.dir=(l.dir+6)%8,n(l,i,o,a),s!==l.dir?(u.dir=l.dir,c=r(l.cx,l.cy,0),c.prev=u,u.next=c,c.next=null,u=c):(u.dir=s,u.x=l.cx,u.y=l.cy),s=l.dir;while(l.cx!==e||l.cy!==t);f.prev=u.prev,u.prev.next=f}return f}var i,a=t.data,u=e.data,c=this.searchDirections,s=t.size.x;return{trace:function(t,e,r,o){return n(t,e,r,o)},contourTracing:function(t,e,n,r,i){return o(t,e,n,r,i)}}}};e.a=r},function(t,e,n){"use strict";function r(){o.a.call(this)}var o=n(1),i=n(3),a={ALPHABETH_STRING:{value:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%"},ALPHABET:{value:[48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,45,46,32,42,36,47,43,37]},CHARACTER_ENCODINGS:{value:[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,148,168,162,138,42]},ASTERISK:{value:148},FORMAT:{value:"code_39",writeable:!1}};r.prototype=Object.create(o.a.prototype,a),r.prototype.constructor=r,r.prototype._decode=function(){var t,e,n,r,o=this,a=[0,0,0,0,0,0,0,0,0],u=[],c=o._findStart();if(!c)return null;r=o._nextSet(o._row,c.end);do{if(a=o._toCounters(r,a),(n=o._toPattern(a))<0)return null;if((t=o._patternToChar(n))<0)return null;u.push(t),e=r,r+=i.a.sum(a),r=o._nextSet(o._row,r)}while("*"!==t);return u.pop(),u.length&&o._verifyTrailingWhitespace(e,r,a)?{code:u.join(""),start:c.start,end:r,startInfo:c,decodedCodes:u}:null},r.prototype._verifyTrailingWhitespace=function(t,e,n){var r=i.a.sum(n);return 3*(e-t-r)>=r},r.prototype._patternToChar=function(t){var e,n=this;for(e=0;ee&&(r=t[n]);return r},r.prototype._toPattern=function(t){for(var e,n,r=t.length,o=0,i=r,a=0,u=this;i>3;){for(o=u._findNextWidth(t,o),i=0,e=0,n=0;no&&(e|=1<0;n++)if(t[n]>o&&(i--,2*t[n]>=a))return-1;return e}}return-1},r.prototype._findStart=function(){var t,e,n,r=this,o=r._nextSet(r._row),i=o,a=[0,0,0,0,0,0,0,0,0],u=0,c=!1;for(t=o;t0)for(r=0;r0){if(!(t=Y.filter(function(t){return!t.busy})[0]))return;w.attachData(t.imageData)}else w.attachData(S.data);w.grab()&&(t?(t.busy=!0,t.worker.postMessage({cmd:"process",imageData:t.imageData},[t.imageData.buffer])):_())}else _()}function y(){var t=null,e=1e3/($.frequency||60);T=!1,function n(r){t=t||r,T||(r>=t&&(t+=e,g()),window.requestAnimFrame(n))}(performance.now())}function m(){Q&&"LiveStream"===$.inputStream.type?y():g()}function x(t){var e,n={worker:void 0,imageData:new Uint8Array(R.getWidth()*R.getHeight()),busy:!0};e=C(),n.worker=new Worker(e),n.worker.onmessage=function(r){if("initialized"===r.data.event)return URL.revokeObjectURL(e),n.busy=!1,n.imageData=new Uint8Array(r.data.imageData),t(n);"processed"===r.data.event?(n.imageData=new Uint8Array(r.data.imageData),n.busy=!1,v(r.data.result,n.imageData)):r.data.event},n.worker.postMessage({cmd:"init",size:{x:R.getWidth(),y:R.getHeight()},imageData:n.imageData,config:b($)},[n.imageData.buffer])}function b(t){return X({},t,{inputStream:X({},t.inputStream,{target:null})})}function E(t){function e(t){self.postMessage({event:"processed",imageData:o.data,result:t},[o.data.buffer])}function n(){self.postMessage({event:"initialized",imageData:o.data},[o.data.buffer])}if(t){var r=t().default;if(!r)return void self.postMessage({event:"error",message:"Quagga could not be created"})}var o;self.onmessage=function(t){if("init"===t.data.cmd){var i=t.data.config;i.numOfWorkers=0,o=new r.ImageWrapper({x:t.data.size.x,y:t.data.size.y},new Uint8Array(t.data.imageData)),r.init(i,n,o),r.onProcessed(e)}else"process"===t.data.cmd?(o.data=new Uint8Array(t.data.imageData),r.start()):"setReaders"===t.data.cmd&&r.setReaders(t.data.readers)}}function C(){var e,n;return void 0!==t&&(n=t),e=new Blob(["("+E.toString()+")("+n+");"],{type:"text/javascript"}),window.URL.createObjectURL(e)}function O(t){P?P.setReaders(t):Q&&Y.length>0&&Y.forEach(function(e){e.worker.postMessage({cmd:"setReaders",readers:t})})}function A(t,e){var n=t-Y.length;if(0===n)return e&&e();if(n<0){return Y.slice(n).forEach(function(t){t.worker.terminate()}),Y=Y.slice(0,n),e&&e()}for(var r=function(n){Y.push(n),Y.length>=t&&e&&e()},o=0;oe},getPoints:function(){return a},getCenter:function(){return u}}},createPoint:function(t,e,n){return{rad:t[n],point:t,id:e}}}},function(t,e,n){"use strict";e.a=function(){function t(t){return o[t]||(o[t]={subscribers:[]}),o[t]}function e(){o={}}function n(t,e){t.async?setTimeout(function(){t.callback(e)},4):t.callback(e)}function r(e,n,r){var o;if("function"==typeof n)o={callback:n,async:r};else if(o=n,!o.callback)throw"Callback was not specified on options";t(e).subscribers.push(o)}var o={};return{subscribe:function(t,e,n){return r(t,e,n)},publish:function(e,r){var o=t(e),i=o.subscribers;i.filter(function(t){return!!t.once}).forEach(function(t){n(t,r)}),o.subscribers=i.filter(function(t){return!t.once}),o.subscribers.forEach(function(t){n(t,r)})},once:function(t,e,n){r(t,{callback:e,async:n,once:!0})},unsubscribe:function(n,r){var o;n?(o=t(n),o.subscribers=o&&r?o.subscribers.filter(function(t){return t.callback!==r}):[]):e()}}}()},function(t,e,n){"use strict";function r(){return navigator.mediaDevices&&"function"==typeof navigator.mediaDevices.enumerateDevices?navigator.mediaDevices.enumerateDevices():Promise.reject(new Error("enumerateDevices is not defined"))}function o(t){return navigator.mediaDevices&&"function"==typeof navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia(t):Promise.reject(new Error("getUserMedia is not defined"))}e.b=r,e.a=o},function(t,e,n){"use strict";function r(t,e,n){n||(n={data:null,size:e}),this.data=n.data,this.originalSize=n.size,this.I=n,this.from=t,this.size=e}r.prototype.show=function(t,e){var n,r,o,i,a,u,c;for(e||(e=1),n=t.getContext("2d"),t.width=this.size.x,t.height=this.size.y,r=n.getImageData(0,0,t.width,t.height),o=r.data,i=0,a=0;a>>16&65535,r=65535&t,o=e>>>16&65535,i=65535&e;return r*i+(n*i+r*o<<16>>>0)|0},"function"!=typeof Object.assign&&(Object.assign=function(t){"use strict";if(null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n1&&(!e.inImageWithBorder(t[0],0)||!e.inImageWithBorder(t[1],0));)r-=Math.ceil(r/2),o(-r);return t}function u(t){return[{x:(t[1][0]-t[0][0])/2+t[0][0],y:(t[1][1]-t[0][1])/2+t[0][1]},{x:(t[3][0]-t[2][0])/2+t[2][0],y:(t[3][1]-t[2][1])/2+t[2][1]}]}function c(t){var n,o=null,i=r.a.getBarcodeLine(e,t[0],t[1]);for(r.a.toBinaryLine(i),n=0;nE?l:E,g.push(l)}var o,i,a,u,c,s,f,l,d=0|e.x,h=0|e.y,p=0|n.x,v=0|n.y,_=Math.abs(v-h)>Math.abs(p-d),g=[],y=t.data,m=t.size.x,x=0,b=255,E=0;for(_&&(s=d,d=h,h=s,s=p,p=v,v=s),d>p&&(s=d,d=p,p=s,s=h,h=v,v=s),o=p-d,i=Math.abs(v-h),a=o/2|0,c=h,u=hl?o.DIR.UP:o.DIR.DOWN,d.push({pos:0,val:f[0]}),a=0;ah&&f[a+1]>.5*l?o.DIR.UP:r,r!==i&&(d.push({pos:a,val:f[a]}),r=i);for(d.push({pos:f.length,val:f[f.length-1]}),u=d[0].pos;ul?0:1;for(a=1;ad[a].val?d[a].val+(d[a+1].val-d[a].val)/3*2|0:d[a+1].val+(d[a].val-d[a+1].val)/3|0,u=d[a].pos;uh?0:1;return{line:f,threshold:h}},r.debug={printFrequency:function(t,e){var n,r=e.getContext("2d");for(e.width=t.length,e.height=256,r.beginPath(),r.strokeStyle="blue",n=0;n0?t.videoWidth>10&&t.videoHeight>10?e():window.setTimeout(r,500):n("Unable to play video stream. Is webcam working?"),o--}var o=10;r()})}function o(t,e){return n.i(d.a)(e).then(function(e){return new Promise(function(n){s=e,t.setAttribute("autoplay",!0),t.setAttribute("muted",!0),t.setAttribute("playsinline",!0),t.srcObject=e,t.addEventListener("loadedmetadata",function(){t.play(),n()})})}).then(r.bind(null,t))}function i(t){var e=l()(t,["width","height","facingMode","aspectRatio","deviceId"]);return void 0!==t.minAspectRatio&&t.minAspectRatio>0&&(e.aspectRatio=t.minAspectRatio,console.log("WARNING: Constraint 'minAspectRatio' is deprecated; Use 'aspectRatio' instead")),void 0!==t.facing&&(e.facingMode=t.facing,console.log("WARNING: Constraint 'facing' is deprecated. Use 'facingMode' instead'")),e}function a(t){var e={audio:!1,video:i(t)};return e.video.deviceId&&e.video.facingMode&&delete e.video.facingMode,Promise.resolve(e)}function u(){return n.i(d.b)().then(function(t){return t.filter(function(t){return"videoinput"===t.kind})})}function c(){if(s){var t=s.getVideoTracks();if(t&&t.length)return t[0]}}var s,f=n(162),l=n.n(f),d=n(52);e.a={request:function(t,e){return a(e).then(o.bind(null,t))},release:function(){var t=s&&s.getVideoTracks();t&&t.length&&t[0].stop(),s=null},enumerateVideoDevices:u,getActiveStreamLabel:function(){var t=c();return t?t.label:""},getActiveTrack:c}},function(t,e,n){"use strict";function r(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;return/^blob\:/i.test(t)?i(t).then(o).then(function(t){return a(t,e)}):Promise.resolve(null)}function o(t){return new Promise(function(e){var n=new FileReader;n.onload=function(t){return e(t.target.result)},n.readAsArrayBuffer(t)})}function i(t){return new Promise(function(e,n){var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="blob",r.onreadystatechange=function(){r.readyState!==XMLHttpRequest.DONE||200!==r.status&&0!==r.status||e(this.response)},r.onerror=n,r.send()})}function a(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d,n=new DataView(t),r=t.byteLength,o=e.reduce(function(t,e){var n=Object.keys(l).filter(function(t){return l[t]===e})[0];return n&&(t[n]=e),t},{}),i=2;if(255!==n.getUint8(0)||216!==n.getUint8(1))return!1;for(;i1?i.size:Math.floor(e/o*i.size):e,r=i.size?e/o>1?Math.floor(o/e*i.size):i.size:o,s.x=n,s.y=r}var n,r,o={},i=null,a=["canrecord","ended"],u={},c={x:0,y:0},s={x:0,y:0};return o.getRealWidth=function(){return t.videoWidth},o.getRealHeight=function(){return t.videoHeight},o.getWidth=function(){return n},o.getHeight=function(){return r},o.setWidth=function(t){n=t},o.setHeight=function(t){r=t},o.setInputStream=function(e){i=e,t.src=void 0!==e.src?e.src:""},o.ended=function(){return t.ended},o.getConfig=function(){return i},o.setAttribute=function(e,n){t.setAttribute(e,n)},o.pause=function(){t.pause()},o.play=function(){t.play()},o.setCurrentTime=function(e){"LiveStream"!==i.type&&(t.currentTime=e)},o.addEventListener=function(e,n,r){a.indexOf(e)!==-1?(u[e]||(u[e]=[]),u[e].push(n)):t.addEventListener(e,n,r)},o.clearEventHandlers=function(){a.forEach(function(e){var n=u[e];n&&n.length>0&&n.forEach(function(n){t.removeEventListener(e,n)})})},o.trigger=function(t,n){var r,i=u[t];if("canrecord"===t&&e(),i&&i.length>0)for(r=0;r1?a.size:Math.floor(u/c*a.size):u,o=a.size?u/c>1?Math.floor(c/u*a.size):a.size:c,x.x=n,x.y=o,l=!0,s=0,setTimeout(function(){e("canrecord",[])},0)},p,h,a.sequence)}function e(t,e){var n,r=y[t];if(r&&r.length>0)for(n=0;nf&&(f=o.box[r][0]),o.box[r][1]l&&(l=o.box[r][1]);for(a=[[c,s],[f,s],[f,l],[c,l]],u=p.halfSample?2:1,i=M.invert(i,i),r=0;r<4;r++)I.transformMat2(a[r],a[r],i);for(r=0;r<4;r++)I.scale(a[r],a[r],u);return a}function a(){n.i(w.f)(v,E),E.zeroBorder()}function u(){var t,e,n,r,o,i,a,u=[];for(t=0;t0&&r[x.data[n]-1]++;return r=r.map(function(t,e){return{val:t,label:e+1}}),r.sort(function(t,e){return e.val-t.val}),r.filter(function(t){return t.val>=5})}function s(t,e){var n,r,o,a,u=[],c=[];for(n=0;n=2){for(o=0;ol&&c.push(t[o]);if(c.length>=2){for(a=f(c),i=0,o=0;o1&&a.length>=c.length/4*3&&a.length>t.length/4&&(i/=a.length,u={index:e[1]*z.x+e[0],pos:{x:n,y:r},box:[I.clone([n,r]),I.clone([n+g.size.x,r]),I.clone([n+g.size.x,r+g.size.y]),I.clone([n,r+g.size.y])],moments:a,rad:i,vec:I.clone([Math.cos(i),Math.sin(i)])},s.push(u))}}return s}function h(t){function e(){var t;for(t=0;ta&&n(u):x.data[u]=Number.MAX_VALUE}var r,o,i=0,a=.95,u=0;for(T.a.init(m.data,0),T.a.init(x.data,0),T.a.init(b.data,null),r=0;r0) {length=length - 1|0;images[outImagePtr+length|0]=(images[aImagePtr+length|0]|0) - (images[bImagePtr+length|0]|0)|0;}}function bitwiseOr(aImagePtr, bImagePtr, outImagePtr) {aImagePtr=aImagePtr|0;bImagePtr=bImagePtr|0;outImagePtr=outImagePtr|0;var length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;images[outImagePtr+length|0]=images[aImagePtr+length|0]|0|(images[bImagePtr+length|0]|0)|0;}}function countNonZero(imagePtr) {imagePtr=imagePtr|0;var sum=0,length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;sum=(sum|0)+(images[imagePtr+length|0]|0)|0;}return sum|0;}function init(imagePtr, value) {imagePtr=imagePtr|0;value=value|0;var length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;images[imagePtr+length|0]=value;}}function dilate(inImagePtr, outImagePtr) {inImagePtr=inImagePtr|0;outImagePtr=outImagePtr|0;var v=0,u=0,sum=0,yStart1=0,yStart2=0,xStart1=0,xStart2=0,offset=0;for (v=1; (v|0)<(size - 1|0); v=v+1|0) {offset=offset+size|0;for (u=1; (u|0)<(size - 1|0); u=u+1|0) {yStart1=offset - size|0;yStart2=offset+size|0;xStart1=u - 1|0;xStart2=u+1|0;sum=(images[inImagePtr+yStart1+xStart1|0]|0)+(images[inImagePtr+yStart1+xStart2|0]|0)+(images[inImagePtr+offset+u|0]|0)+(images[inImagePtr+yStart2+xStart1|0]|0)+(images[inImagePtr+yStart2+xStart2|0]|0)|0;if ((sum|0)>(0|0)) {images[outImagePtr+offset+u|0]=1;} else {images[outImagePtr+offset+u|0]=0;}}}return;}function memcpy(srcImagePtr, dstImagePtr) {srcImagePtr=srcImagePtr|0;dstImagePtr=dstImagePtr|0;var length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;images[dstImagePtr+length|0]=images[srcImagePtr+length|0]|0;}}function zeroBorder(imagePtr) {imagePtr=imagePtr|0;var x=0,y=0;for (x=0; (x|0)<(size - 1|0); x=x+1|0) {images[imagePtr+x|0]=0;images[imagePtr+y|0]=0;y=y+size - 1|0;images[imagePtr+y|0]=0;y=y+1|0;}for (x=0; (x|0)<(size|0); x=x+1|0) {images[imagePtr+y|0]=0;y=y+1|0;}}function skeletonize() {var subImagePtr=0,erodedImagePtr=0,tempImagePtr=0,skelImagePtr=0,sum=0,done=0;erodedImagePtr=imul(size, size)|0;tempImagePtr=erodedImagePtr+erodedImagePtr|0;skelImagePtr=tempImagePtr+erodedImagePtr|0;init(skelImagePtr, 0);zeroBorder(subImagePtr);do {erode(subImagePtr, erodedImagePtr);dilate(erodedImagePtr, tempImagePtr);subtract(subImagePtr, tempImagePtr, tempImagePtr);bitwiseOr(skelImagePtr, tempImagePtr, skelImagePtr);memcpy(erodedImagePtr, subImagePtr);sum=countNonZero(subImagePtr)|0;done=(sum|0) == 0|0;} while (!done);}return {skeletonize: skeletonize};} __webpack_exports__["a"]=Skeletonizer; },function(t,e,n){"use strict";function r(t){o.a.call(this,t),this.barSpaceRatio=[1,1]}var o=n(1),i=1,a=3,u={START_PATTERN:{value:[a,i,a,i,i,i]},STOP_PATTERN:{value:[a,i,i,i,a]},CODE_PATTERN:{value:[[i,i,a,a,i],[a,i,i,i,a],[i,a,i,i,a],[a,a,i,i,i],[i,i,a,i,a],[a,i,a,i,i],[i,a,a,i,i],[i,i,i,a,a],[a,i,i,a,i],[i,a,i,a,i]]},SINGLE_CODE_ERROR:{value:.78,writable:!0},AVG_CODE_ERROR:{value:.3,writable:!0},FORMAT:{value:"2of5"}},c=u.START_PATTERN.value.reduce(function(t,e){return t+e},0);r.prototype=Object.create(o.a.prototype,u),r.prototype.constructor=r,r.prototype._findPattern=function(t,e,n,r){var o,i,a,u,c=[],s=this,f=0,l={error:Number.MAX_VALUE,code:-1,start:0,end:0},d=s.AVG_CODE_ERROR;for(n=n||!1,r=r||!1,e||(e=s._nextSet(s._row)),o=0;o=0&&n._matchRange(t,e.start,0))return e;r=e.end,e=null}},r.prototype._verifyTrailingWhitespace=function(t){var e,n=this;return e=t.end+(t.end-t.start)/2,e1&&i._isStartEnd(n))break}while(ri._counters.length?i._counters.length:r,o=t.start+i._sumCounters(t.startCounter,r-8),{code:a.join(""),start:t.start,end:o,startInfo:t,decodedCodes:a}):null},r.prototype._verifyWhitespace=function(t,e){return(t-1<=0||this._counters[t-1]>=this._calculatePatternLength(t)/2)&&(e+8>=this._counters.length||this._counters[e+7]>=this._calculatePatternLength(e)/2)},r.prototype._calculatePatternLength=function(t){var e,n=0;for(e=t;e=0;i--)n=2==(1&i)?c.bar:c.space,r=1==(1&a)?n.wide:n.narrow,r.size+=u._counters[s+i],r.counts++,a>>=1;s+=8}return["space","bar"].forEach(function(t){var e=c[t];e.wide.min=Math.floor((e.narrow.size/e.narrow.counts+e.wide.size/e.wide.counts)/2),e.narrow.max=Math.ceil(e.wide.min),e.wide.max=Math.ceil((e.wide.size*u.MAX_ACCEPTABLE+u.PADDING)/e.wide.counts)}),c},r.prototype._charToPattern=function(t){var e,n=this,r=t.charCodeAt(0);for(e=0;e=0;r--){if(o=0==(1&r)?s.bar:s.space,i=1==(1&u)?o.wide:o.narrow,(a=c._counters[f+r])i.max)return!1;u>>=1}f+=8}return!0},r.prototype._patternToChar=function(t){var e,n=this;for(e=0;ei&&(i=r),rthis._counters.length)return-1;for(e=this._computeAlternatingThreshold(t,a),n=this._computeAlternatingThreshold(t+1,a),r=0;ro&&(c|=u),u>>=1;return c},r.prototype._isStartEnd=function(t){var e;for(e=0;eu.AVG_CODE_ERROR?null:(u.CODE_PATTERN[l.code]&&(l.correction.bar=o(u.CODE_PATTERN[l.code],a,this.MODULE_INDICES.bar),l.correction.space=o(u.CODE_PATTERN[l.code],a,this.MODULE_INDICES.space)),l)}f++,a[f]=1,s=!s}return null},r.prototype._correct=function(t,e){this._correctBars(t,e.bar,this.MODULE_INDICES.bar),this._correctBars(t,e.space,this.MODULE_INDICES.space)},r.prototype._findStart=function(){var t,e,n,r,i,a=[0,0,0,0,0,0],u=this,c=u._nextSet(u._row),s=!1,f=0,l={error:Number.MAX_VALUE,code:-1,start:0,end:0,correction:{bar:1,space:1}};for(t=c;t4)return-1;if(0==(1&i))for(var u=0;u="a"&&o<="d"){if(r>e-2)return null;var i=t[++r],a=i.charCodeAt(0),u=void 0;switch(o){case"a":if(!(i>="A"&&i<="Z"))return null;u=String.fromCharCode(a-64);break;case"b":if(i>="A"&&i<="E")u=String.fromCharCode(a-38);else if(i>="F"&&i<="J")u=String.fromCharCode(a-11);else if(i>="K"&&i<="O")u=String.fromCharCode(a+16);else if(i>="P"&&i<="S")u=String.fromCharCode(a+43);else{if(!(i>="T"&&i<="Z"))return null;u=String.fromCharCode(127)}break;case"c":if(i>="A"&&i<="O")u=String.fromCharCode(a-32);else{if("Z"!==i)return null;u=":"}break;case"d":if(!(i>="A"&&i<="Z"))return null;u=String.fromCharCode(a+32)}n.push(u)}else n.push(o)}return n},r.prototype._verifyChecksums=function(t){return this._matchCheckChar(t,t.length-2,20)&&this._matchCheckChar(t,t.length-1,15)},r.prototype._matchCheckChar=function(t,e,n){var r=this,o=t.slice(0,e),i=o.length,a=o.reduce(function(t,e,o){return t+((o*-1+(i-1))%n+1)*r.ALPHABET.indexOf(e.charCodeAt(0))},0);return this.ALPHABET[a%47]===t[e].charCodeAt(0)},e.a=r},function(t,e,n){"use strict";function r(){o.a.call(this)}var o=n(4),i={FORMAT:{value:"ean_2",writeable:!1}};r.prototype=Object.create(o.a.prototype,i),r.prototype.constructor=r,r.prototype.decode=function(t,e){this._row=t;var n,r=0,o=0,i=e,a=this._row.length,u=[],c=[];for(o=0;o<2&&i=this.CODE_G_START&&(r|=1<<1-o),1!=o&&(i=this._nextSet(this._row,n.end),i=this._nextUnset(this._row,i))}return 2!=u.length||parseInt(u.join(""))%4!==r?null:{code:u.join(""),decodedCodes:c,end:n.end}},e.a=r},function(t,e,n){"use strict";function r(){a.a.call(this)}function o(t){var e;for(e=0;e<10;e++)if(t===c[e])return e;return null}function i(t){var e,n=t.length,r=0;for(e=n-2;e>=0;e-=2)r+=t[e];for(r*=3,e=n-1;e>=0;e-=2)r+=t[e];return(r*=3)%10}var a=n(4),u={FORMAT:{value:"ean_5",writeable:!1}},c=[24,20,18,17,12,6,3,10,9,5];r.prototype=Object.create(a.a.prototype,u),r.prototype.constructor=r,r.prototype.decode=function(t,e){this._row=t;var n,r=0,a=0,u=e,c=this._row.length,s=[],f=[];for(a=0;a<5&&u=this.CODE_G_START&&(r|=1<<4-a),4!=a&&(u=this._nextSet(this._row,n.end),u=this._nextUnset(this._row,u))}return 5!=s.length?null:i(s)!==o(r)?null:{code:s.join(""),decodedCodes:f,end:n.end}},e.a=r},function(t,e,n){"use strict";function r(t,e){o.a.call(this,t,e)}var o=n(4),i={FORMAT:{value:"ean_8",writeable:!1}};r.prototype=Object.create(o.a.prototype,i),r.prototype.constructor=r,r.prototype._decodePayload=function(t,e,n){var r,o=this;for(r=0;r<4;r++){if(!(t=o._decodeCode(t.end,o.CODE_G_START)))return null;e.push(t.code),n.push(t)}if(null===(t=o._findPattern(o.MIDDLE_PATTERN,t.end,!0,!1)))return null;for(n.push(t),r=0;r<4;r++){if(!(t=o._decodeCode(t.end,o.CODE_G_START)))return null;n.push(t),e.push(t.code)}return t},e.a=r},function(t,e,n){"use strict";function r(t){t=a()(o(),t),u.a.call(this,t),this.barSpaceRatio=[1,1],t.normalizeBarSpaceWidth&&(this.SINGLE_CODE_ERROR=.38,this.AVG_CODE_ERROR=.09)}function o(){var t={};return Object.keys(r.CONFIG_KEYS).forEach(function(e){t[e]=r.CONFIG_KEYS[e].default}),t}var i=n(28),a=n.n(i),u=n(1),c=1,s=3,f={START_PATTERN:{value:[c,c,c,c]},STOP_PATTERN:{value:[c,c,s]},CODE_PATTERN:{value:[[c,c,s,s,c],[s,c,c,c,s],[c,s,c,c,s],[s,s,c,c,c],[c,c,s,c,s],[s,c,s,c,c],[c,s,s,c,c],[c,c,c,s,s],[s,c,c,s,c],[c,s,c,s,c]]},SINGLE_CODE_ERROR:{value:.78,writable:!0},AVG_CODE_ERROR:{value:.38,writable:!0},MAX_CORRECTION_FACTOR:{value:5},FORMAT:{value:"i2of5"}};r.prototype=Object.create(u.a.prototype,f),r.prototype.constructor=r,r.prototype._matchPattern=function(t,e){if(this.config.normalizeBarSpaceWidth){var n,r=[0,0],o=[0,0],i=[0,0],a=this.MAX_CORRECTION_FACTOR,c=1/a;for(n=0;n=0&&n._matchRange(t,e.start,0))return e;r=e.end,e=null}},r.prototype._verifyTrailingWhitespace=function(t){var e,n=this;return e=t.end+(t.end-t.start)/2,e=o.CODE_G_START&&(t.code=t.code-o.CODE_G_START,i|=1<<5-r),e.push(t.code),n.push(t)}return o._determineParity(i,e)?t:null},r.prototype._determineParity=function(t,e){var n,r;for(r=0;r0&&n(f)?e>1?r(f,e-1,n,a,u):o(u,f):a||(u[u.length]=f)}return u}var o=n(90),i=n(128);t.exports=r},function(t,e,n){var r=n(117),o=r();t.exports=o},function(t,e,n){function r(t,e){e=o(e,t);for(var n=0,r=e.length;null!=t&&n1?n[o-1]:void 0,u=o>2?n[2]:void 0;for(a=t.length>3&&"function"==typeof a?(o--,a):void 0,u&&i(n[0],n[1],u)&&(a=o<3?void 0:a,o=1),e=Object(e);++r-1}var o=n(12);t.exports=r},function(t,e,n){function r(t,e){var n=this.__data__,r=o(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var o=n(12);t.exports=r},function(t,e,n){function r(){this.size=0,this.__data__={hash:new o,map:new(a||i),string:new o}}var o=n(84),i=n(10),a=n(33);t.exports=r},function(t,e,n){function r(t){var e=o(this,t).delete(t);return this.size-=e?1:0,e}var o=n(14);t.exports=r},function(t,e,n){function r(t){return o(this,t).get(t)}var o=n(14);t.exports=r},function(t,e,n){function r(t){return o(this,t).has(t)}var o=n(14);t.exports=r},function(t,e,n){function r(t,e){var n=o(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}var o=n(14);t.exports=r},function(t,e,n){function r(t){var e=o(t,function(t){return n.size===i&&n.clear(),t}),n=e.cache;return e}var o=n(161),i=500;t.exports=r},function(t,e){function n(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}t.exports=n},function(t,e,n){(function(t){var r=n(38),o="object"==typeof e&&e&&!e.nodeType&&e,i=o&&"object"==typeof t&&t&&!t.nodeType&&t,a=i&&i.exports===o,u=a&&r.process,c=function(){try{return u&&u.binding&&u.binding("util")}catch(t){}}();t.exports=c}).call(e,n(29)(t))},function(t,e){function n(t){return o.call(t)}var r=Object.prototype,o=r.toString;t.exports=n},function(t,e){function n(t,e){return function(n){return t(e(n))}}t.exports=n},function(t,e){function n(t){var e=0,n=0;return function(){var a=i(),u=o-(a-n);if(n=a,u>0){if(++e>=r)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var r=800,o=16,i=Date.now;t.exports=n},function(t,e,n){function r(){this.__data__=new o,this.size=0}var o=n(10);t.exports=r},function(t,e){function n(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}t.exports=n},function(t,e){function n(t){return this.__data__.get(t)}t.exports=n},function(t,e){function n(t){return this.__data__.has(t)}t.exports=n},function(t,e,n){function r(t,e){var n=this.__data__;if(n instanceof o){var r=n.__data__;if(!i||r.length=0;e--){var n=Math.floor(Math.random()*e),r=t[e];t[e]=t[n],t[n]=r}return t},toPointList:function(t){var e=t.reduce((function(t,e){var n="[".concat(e.join(","),"]");return t.push(n),t}),[]);return"[".concat(e.join(",\r\n"),"]")},threshold:function(t,e,n){return t.reduce((function(r,o){return n.apply(t,[o])>=e&&r.push(o),r}),[])},maxIndex:function(t){for(var e=0,n=0;nt[e]&&(e=n);return e},max:function(t){for(var e=0,n=0;ne&&(e=t[n]);return e},sum:function(t){for(var e=t.length,n=0;e--;)n+=t[e];return n}}},function(t,e,n){"use strict";n.d(e,"h",(function(){return l})),n.d(e,"i",(function(){return d})),n.d(e,"b",(function(){return p})),n.d(e,"j",(function(){return v})),n.d(e,"e",(function(){return y})),n.d(e,"c",(function(){return g})),n.d(e,"f",(function(){return x})),n.d(e,"g",(function(){return _})),n.d(e,"a",(function(){return b})),n.d(e,"d",(function(){return O}));var r=n(7),o=n(84),i={clone:r.clone,dot:r.dot},a=function(t,e){var n=[],r={rad:0,vec:i.clone([0,0])},o={};function a(t){o[t.id]=t,n.push(t)}function u(){var t,e=0;for(t=0;te},getPoints:function(){return n},getCenter:function(){return r}}},u=function(t,e,n){return{rad:t[n],point:t,id:e}},c=n(8),s={clone:r.clone},f={clone:o.clone};function l(t,e){return{x:t,y:e,toVec2:function(){return s.clone([this.x,this.y])},toVec3:function(){return f.clone([this.x,this.y,1])},round:function(){return this.x=this.x>0?Math.floor(this.x+.5):Math.floor(this.x-.5),this.y=this.y>0?Math.floor(this.y+.5):Math.floor(this.y-.5),this}}}function h(t,e){e||(e=8);for(var n=t.data,r=n.length,o=8-e,i=new Int32Array(1<>o]++;return i}function d(t,e){var n=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8,r=8-n;function o(t,n){for(var r=0,o=t;o<=n;o++)r+=e[o];return r}function i(t,n){for(var r=0,o=t;o<=n;o++)r+=o*e[o];return r}function a(){var r,a,u,s,f=[0],l=(1<c)for((i=s[u]).score=o,i.item=t[r],c=Number.MAX_VALUE,a=0;a1&&void 0!==arguments[1]?arguments[1]:[0,0,0],n=t[0],r=t[1],o=t[2],i=o*r,a=i*(1-Math.abs(n/60%2-1)),u=o-i,c=0,s=0,f=0;return n<60?(c=i,s=a):n<120?(c=a,s=i):n<180?(s=i,f=a):n<240?(s=a,f=i):n<300?(c=a,f=i):n<360&&(c=i,f=a),e[0]=255*(c+u)|0,e[1]=255*(s+u)|0,e[2]=255*(f+u)|0,e}function m(t){for(var e=[],n=[],r=1;re[r]?r++:n++;return o}(r,o),u=[8,10,15,20,32,60,80],c={"x-small":5,small:4,medium:3,large:2,"x-large":1},s=c[t]||c.medium,f=u[s],l=Math.floor(i/f);function h(t){for(var e=0,n=t[Math.floor(t.length/2)];e0&&(n=Math.abs(t[e]-l)>Math.abs(t[e-1]-l)?t[e-1]:t[e]),l/nu[s-1]/u[s]?{x:n,y:n}:null}return(n=h(a))||(n=h(m(i)))||(n=h(m(l*f))),n}var w={top:function(t,e){return"%"===t.unit?Math.floor(e.height*(t.value/100)):null},right:function(t,e){return"%"===t.unit?Math.floor(e.width-e.width*(t.value/100)):null},bottom:function(t,e){return"%"===t.unit?Math.floor(e.height-e.height*(t.value/100)):null},left:function(t,e){return"%"===t.unit?Math.floor(e.width*(t.value/100)):null}};function O(t,e,n){var r={width:t,height:e},o=Object.keys(n).reduce((function(t,e){var o=function(t){return{value:parseFloat(t),unit:(t.indexOf("%"),t.length,"%")}}(n[e]),i=w[e](o,r);return t[e]=i,t}),{});return{sx:o.left,sy:o.top,sw:o.right-o.left,sh:o.bottom-o.top}}},function(t,e,n){"use strict";var r=n(83),o=n.n(r),i=n(3),a=n.n(i),u=n(4),c=n.n(u),s=n(0),f=n.n(s),l=n(7),h=n(9),d=n(8),p={clone:l.clone};function v(t){if(t<0)throw new Error("expected positive number, received ".concat(t))}var y=function(){function t(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Uint8Array,o=arguments.length>3?arguments[3]:void 0;a()(this,t),f()(this,"data",void 0),f()(this,"size",void 0),f()(this,"indexMapping",void 0),n?this.data=n:(this.data=new r(e.x*e.y),o&&d.a.init(this.data,0)),this.size=e}return c()(t,[{key:"inImageWithBorder",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return v(e),t.x>=0&&t.y>=0&&t.x0&&((a=v[r-1]).m00+=1,a.m01+=n,a.m10+=e,a.m11+=e*n,a.m02+=o,a.m20+=e*e);for(i=0;i=0?x:-x)+g,a.theta=(180*f/g+90)%180-90,a.theta<0&&(a.theta+=180),a.rad=f>g?f-g:f,a.vec=p.clone([Math.cos(f),Math.sin(f)]),y.push(a));return y}},{key:"getAsRGBA",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=new Uint8ClampedArray(4*this.size.x*this.size.y),n=0;n1&&void 0!==arguments[1]?arguments[1]:1,n=t.getContext("2d");if(!n)throw new Error("Unable to get canvas context");var r=n.getImageData(0,0,t.width,t.height),o=this.getAsRGBA(e);t.width=this.size.x,t.height=this.size.y;var i=new ImageData(o,r.width,r.height);n.putImageData(i,0,0)}},{key:"overlay",value:function(t,e,n){var r=e<0||e>360?360:e,i=[0,1,1],a=[0,0,0],u=[255,255,255],c=[0,0,0],s=t.getContext("2d");if(!s)throw new Error("Unable to get canvas context");for(var f=s.getImageData(n.x,n.y,this.size.x,this.size.y),l=f.data,d=this.data.length;d--;){i[0]=this.data[d]*r;var p=4*d,v=i[0]<=0?u:i[0]>=360?c:Object(h.g)(i,a),y=o()(v,3);l[p]=y[0],l[p+1]=y[1],l[p+2]=y[2],l[p+3]=255}s.putImageData(f,n.x,n.y)}}]),t}();e.a=y},function(t,e,n){t.exports=n(228)},function(t,e,n){var r=n(227);function o(e,n,i){return"undefined"!=typeof Reflect&&Reflect.get?(t.exports=o=Reflect.get,t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=o=function(t,e,n){var o=r(t,e);if(o){var i=Object.getOwnPropertyDescriptor(o,e);return i.get?i.get.call(n):i.value}},t.exports.default=t.exports,t.exports.__esModule=!0),o(e,n,i||e)}t.exports=o,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){"use strict";e.a={drawRect:function(t,e,n,r){n.strokeStyle=r.color,n.fillStyle=r.color,n.lineWidth=r.lineWidth||1,n.beginPath(),n.strokeRect(t.x,t.y,e.x,e.y)},drawPath:function(t,e,n,r){n.strokeStyle=r.color,n.fillStyle=r.color,n.lineWidth=r.lineWidth,n.beginPath(),n.moveTo(t[0][e.x],t[0][e.y]);for(var o=1;oh&&(h=i.box[o][0]),i.box[o][1]d&&(d=i.box[o][1]);for(u=[[s,f],[h,f],[h,d],[s,d]],c=r.halfSample?2:1,a=y.invert(a,a),o=0;o<4;o++)v.transformMat2(u[o],u[o],a);for(o=0;o<4;o++)v.scale(u[o],u[o],c);return u}function E(t,e){l.subImageAsCopy(a,Object(x.h)(t,e)),p.skeletonize()}function M(t,e,n,r){var o,i,u,c,s=[],f=[],l=Math.ceil(h.x/3);if(t.length>=2){for(o=0;ol&&s.push(t[o]);if(s.length>=2){for(u=function(t){var e=Object(x.b)(t,.9),n=Object(x.j)(e,1,(function(t){return t.getPoints().length})),r=[],o=[];if(1===n.length){r=n[0].item.getPoints();for(var i=0;i1&&u.length>=s.length/4*3&&u.length>t.length/4&&(i/=u.length,c={index:e[1]*R.x+e[0],pos:{x:n,y:r},box:[v.clone([n,r]),v.clone([n+a.size.x,r]),v.clone([n+a.size.x,r+a.size.y]),v.clone([n,r+a.size.y])],moments:u,rad:i,vec:v.clone([Math.cos(i),Math.sin(i)])},f.push(c))}}return f}e.a={init:function(e,n){r=n,d=e,function(){o=r.halfSample?new g.a({x:d.size.x/2|0,y:d.size.y/2|0}):d,h=Object(x.a)(r.patchSize,o.size),R.x=o.size.x/h.x|0,R.y=o.size.y/h.y|0,l=new g.a(o.size,void 0,Uint8Array,!1),u=new g.a(h,void 0,Array,!0);var e=new ArrayBuffer(65536);a=new g.a(h,new Uint8Array(e,0,h.x*h.y)),i=new g.a(h,new Uint8Array(e,h.x*h.y*3,h.x*h.y),void 0,!0),p=Object(w.a)("undefined"!=typeof window?window:"undefined"!=typeof self?self:t,{size:h.x},e),f=new g.a({x:o.size.x/a.size.x|0,y:o.size.y/a.size.y|0},void 0,Array,!0),c=new g.a(f.size,void 0,void 0,!0),s=new g.a(f.size,void 0,Int32Array,!0)}(),r.useWorker||"undefined"==typeof document||(O.dom.binary=document.createElement("canvas"),O.dom.binary.className="binaryBuffer",O.ctx.binary=O.dom.binary.getContext("2d"),O.dom.binary.width=l.size.x,O.dom.binary.height=l.size.y)},locate:function(){r.halfSample&&Object(x.f)(d,o),Object(x.i)(o,l),l.zeroBorder();var t=function(){var t,e,n,r,o,c,s=[];for(t=0;t.95&&a(i):s.data[i]=Number.MAX_VALUE}for(_.a.init(c.data,0),_.a.init(s.data,0),_.a.init(f.data,null),e=0;e0&&r[s.data[n]-1]++;return(r=r.map((function(t,e){return{val:t,label:e+1}}))).sort((function(t,e){return e.val-t.val})),r.filter((function(t){return t.val>=5}))}(e);return 0===n.length?null:function(t,e){var n,r,o,i,a=[],u=[];for(n=0;n-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}},function(t,e){function n(e,r){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},t.exports.default=t.exports,t.exports.__esModule=!0,n(e,r)}t.exports=n,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){var r=n(22),o=n(18);t.exports=function(t){return"symbol"==typeof t||o(t)&&"[object Symbol]"==r(t)}},function(t,e,n){var r=n(42);t.exports=function(t){if("string"==typeof t||r(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}},function(t,e,n){var r=n(35)(n(17),"Map");t.exports=r},function(t,e,n){(function(e){var n="object"==typeof e&&e&&e.Object===Object&&e;t.exports=n}).call(this,n(46))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){var r=n(109),o=n(116),i=n(118),a=n(119),u=n(120);function c(t){var e=-1,n=null==t?0:t.length;for(this.clear();++et.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i);return t}},function(t,e){t.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}},function(t,e){t.exports=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}},function(t,e){t.exports=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}},function(t,e){t.exports=function(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t}},function(t,e){t.exports=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],o=e[2]-t[2];return Math.sqrt(n*n+r*r+o*o)}},function(t,e){t.exports=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],o=e[2]-t[2];return n*n+r*r+o*o}},function(t,e){t.exports=function(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}},function(t,e){t.exports=function(t){var e=t[0],n=t[1],r=t[2];return e*e+n*n+r*r}},function(t,e,n){var r=n(153),o=n(154),i=n(60),a=n(155);t.exports=function(t,e){return r(t)||o(t,e)||i(t,e)||a()},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){t.exports={EPSILON:n(71),create:n(72),clone:n(191),angle:n(192),fromValues:n(73),copy:n(193),set:n(194),equals:n(195),exactEquals:n(196),add:n(197),subtract:n(76),sub:n(198),multiply:n(77),mul:n(199),divide:n(78),div:n(200),min:n(201),max:n(202),floor:n(203),ceil:n(204),round:n(205),scale:n(206),scaleAndAdd:n(207),distance:n(79),dist:n(208),squaredDistance:n(80),sqrDist:n(209),length:n(81),len:n(210),squaredLength:n(82),sqrLen:n(211),negate:n(212),inverse:n(213),normalize:n(74),dot:n(75),cross:n(214),lerp:n(215),random:n(216),transformMat4:n(217),transformMat3:n(218),transformQuat:n(219),rotateX:n(220),rotateY:n(221),rotateZ:n(222),forEach:n(223)}},function(t,e,n){var r=n(229),o=n(243)((function(t,e){return null==t?{}:r(t,e)}));t.exports=o},function(t,e,n){var r=n(2),o=n(41),i=n(248),a=n(249);function u(e){var n="function"==typeof Map?new Map:void 0;return t.exports=u=function(t){if(null===t||!i(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return a(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)},t.exports.default=t.exports,t.exports.__esModule=!0,u(e)}t.exports=u,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){"use strict";var r=n(21),o={createContour2D:function(){return{dir:null,index:null,firstVertex:null,insideContours:null,nextpeer:null,prevpeer:null}},CONTOUR_DIR:{CW_DIR:0,CCW_DIR:1,UNKNOWN_DIR:2},DIR:{OUTSIDE_EDGE:-32767,INSIDE_EDGE:-32766},create:function(t,e){var n=t.data,i=e.data,a=t.size.x,u=t.size.y,c=r.a.create(t,e);return{rasterize:function(t){var e,r,s,f,l,h,d,p,v,y,g,x,_=[],m=0;for(x=0;x<400;x++)_[x]=0;for(_[0]=n[0],v=null,h=1;h0){a=a-1|0;r[n+a|0]=(r[t+a|0]|0)-(r[e+a|0]|0)|0}}function c(t,e,n){t|=0;e|=0;n|=0;var a=0;a=i(o,o)|0;while((a|0)>0){a=a-1|0;r[n+a|0]=r[t+a|0]|0|(r[e+a|0]|0)|0}}function s(t){t|=0;var e=0;var n=0;n=i(o,o)|0;while((n|0)>0){n=n-1|0;e=(e|0)+(r[t+n|0]|0)|0}return e|0}function f(t,e){t|=0;e|=0;var n=0;n=i(o,o)|0;while((n|0)>0){n=n-1|0;r[t+n|0]=e}}function l(t,e){t|=0;e|=0;var n=0;var i=0;var a=0;var u=0;var c=0;var s=0;var f=0;var l=0;for(n=1;(n|0)<(o-1|0);n=n+1|0){l=l+o|0;for(i=1;(i|0)<(o-1|0);i=i+1|0){u=l-o|0;c=l+o|0;s=i-1|0;f=i+1|0;a=(r[t+u+s|0]|0)+(r[t+u+f|0]|0)+(r[t+l+i|0]|0)+(r[t+c+s|0]|0)+(r[t+c+f|0]|0)|0;if((a|0)>(0|0)){r[e+l+i|0]=1}else{r[e+l+i|0]=0}}}}function h(t,e){t|=0;e|=0;var n=0;n=i(o,o)|0;while((n|0)>0){n=n-1|0;r[e+n|0]=r[t+n|0]|0}}function d(t){t|=0;var e=0;var n=0;for(e=0;(e|0)<(o-1|0);e=e+1|0){r[t+e|0]=0;r[t+n|0]=0;n=n+o-1|0;r[t+n|0]=0;n=n+1|0}for(e=0;(e|0)<(o|0);e=e+1|0){r[t+n|0]=0;n=n+1|0}}function p(){var t=0;var e=0;var n=0;var r=0;var p=0;var v=0;e=i(o,o)|0;n=e+e|0;r=n+e|0;f(r,0);d(t);do{a(t,e);l(e,n);u(t,n,n);c(r,n,r);h(e,t);p=s(t)|0;v=(p|0)==0|0}while(!v)}return{skeletonize:p}}},function(t,e,n){t.exports=n(263)},function(t,e,n){var r=n(91),o=n(48),i=n(121),a=n(123),u=n(13),c=n(56),s=n(54);t.exports=function t(e,n,f,l,h){e!==n&&i(n,(function(i,c){if(h||(h=new r),u(i))a(e,n,c,f,t,l,h);else{var d=l?l(s(e,c),i,c+"",e,n,h):void 0;void 0===d&&(d=i),o(e,c,d)}}),c)}},function(t,e,n){var r=n(24),o=n(97),i=n(98),a=n(99),u=n(100),c=n(101);function s(t){var e=this.__data__=new r(t);this.size=e.size}s.prototype.clear=o,s.prototype.delete=i,s.prototype.get=a,s.prototype.has=u,s.prototype.set=c,t.exports=s},function(t,e){t.exports=function(){this.__data__=[],this.size=0}},function(t,e,n){var r=n(25),o=Array.prototype.splice;t.exports=function(t){var e=this.__data__,n=r(e,t);return!(n<0)&&(n==e.length-1?e.pop():o.call(e,n,1),--this.size,!0)}},function(t,e,n){var r=n(25);t.exports=function(t){var e=this.__data__,n=r(e,t);return n<0?void 0:e[n][1]}},function(t,e,n){var r=n(25);t.exports=function(t){return r(this.__data__,t)>-1}},function(t,e,n){var r=n(25);t.exports=function(t,e){var n=this.__data__,o=r(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this}},function(t,e,n){var r=n(24);t.exports=function(){this.__data__=new r,this.size=0}},function(t,e){t.exports=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}},function(t,e){t.exports=function(t){return this.__data__.get(t)}},function(t,e){t.exports=function(t){return this.__data__.has(t)}},function(t,e,n){var r=n(24),o=n(44),i=n(47);t.exports=function(t,e){var n=this.__data__;if(n instanceof r){var a=n.__data__;if(!o||a.length<199)return a.push([t,e]),this.size=++n.size,this;n=this.__data__=new i(a)}return n.set(t,e),this.size=n.size,this}},function(t,e,n){var r=n(36),o=n(105),i=n(13),a=n(107),u=/^\[object .+?Constructor\]$/,c=Function.prototype,s=Object.prototype,f=c.toString,l=s.hasOwnProperty,h=RegExp("^"+f.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!i(t)||o(t))&&(r(t)?h:u).test(a(t))}},function(t,e,n){var r=n(27),o=Object.prototype,i=o.hasOwnProperty,a=o.toString,u=r?r.toStringTag:void 0;t.exports=function(t){var e=i.call(t,u),n=t[u];try{t[u]=void 0;var r=!0}catch(t){}var o=a.call(t);return r&&(e?t[u]=n:delete t[u]),o}},function(t,e){var n=Object.prototype.toString;t.exports=function(t){return n.call(t)}},function(t,e,n){var r,o=n(106),i=(r=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";t.exports=function(t){return!!i&&i in t}},function(t,e,n){var r=n(17)["__core-js_shared__"];t.exports=r},function(t,e){var n=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return n.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},function(t,e){t.exports=function(t,e){return null==t?void 0:t[e]}},function(t,e,n){var r=n(110),o=n(24),i=n(44);t.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||o),string:new r}}},function(t,e,n){var r=n(111),o=n(112),i=n(113),a=n(114),u=n(115);function c(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e1?n[i-1]:void 0,u=i>2?n[2]:void 0;for(a=t.length>3&&"function"==typeof a?(i--,a):void 0,u&&o(n[0],n[1],u)&&(a=i<3?void 0:a,i=1),e=Object(e);++r0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}},function(t,e,n){var r=n(26),o=n(39),i=n(31),a=n(13);t.exports=function(t,e,n){if(!a(n))return!1;var u=typeof e;return!!("number"==u?o(n)&&i(e,n.length):"string"==u&&e in n)&&r(n[e],t)}},function(t,e){"undefined"!=typeof window&&(window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)})),"function"!=typeof Math.imul&&(Math.imul=function(t,e){var n=65535&t,r=65535&e;return n*r+((t>>>16&65535)*r+n*(e>>>16&65535)<<16>>>0)|0}),"function"!=typeof Object.assign&&(Object.assign=function(t){"use strict";if(null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o);return t}},function(t,e){t.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]}},function(t,e){t.exports=function(t,e,n){var r=e[0]*n[1]-e[1]*n[0];return t[0]=t[1]=0,t[2]=r,t}},function(t,e){t.exports=function(t,e,n,r){var o=e[0],i=e[1];return t[0]=o+r*(n[0]-o),t[1]=i+r*(n[1]-i),t}},function(t,e){t.exports=function(t,e){e=e||1;var n=2*Math.random()*Math.PI;return t[0]=Math.cos(n)*e,t[1]=Math.sin(n)*e,t}},function(t,e){t.exports=function(t,e,n){var r=e[0],o=e[1];return t[0]=n[0]*r+n[2]*o,t[1]=n[1]*r+n[3]*o,t}},function(t,e){t.exports=function(t,e,n){var r=e[0],o=e[1];return t[0]=n[0]*r+n[2]*o+n[4],t[1]=n[1]*r+n[3]*o+n[5],t}},function(t,e){t.exports=function(t,e,n){var r=e[0],o=e[1];return t[0]=n[0]*r+n[3]*o+n[6],t[1]=n[1]*r+n[4]*o+n[7],t}},function(t,e){t.exports=function(t,e,n){var r=e[0],o=e[1];return t[0]=n[0]*r+n[4]*o+n[12],t[1]=n[1]*r+n[5]*o+n[13],t}},function(t,e,n){t.exports=function(t,e,n,o,i,a){var u,c;e||(e=2);n||(n=0);c=o?Math.min(o*e+n,t.length):t.length;for(u=n;un*n){var o=Math.sqrt(r);t[0]=e[0]/o*n,t[1]=e[1]/o*n}else t[0]=e[0],t[1]=e[1];return t}},function(t,e){t.exports=function(t){var e=new Float32Array(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}},function(t,e,n){t.exports=function(t,e){var n=r(t[0],t[1],t[2]),a=r(e[0],e[1],e[2]);o(n,n),o(a,a);var u=i(n,a);return u>1?0:Math.acos(u)};var r=n(73),o=n(74),i=n(75)},function(t,e){t.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}},function(t,e){t.exports=function(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}},function(t,e,n){t.exports=function(t,e){var n=t[0],o=t[1],i=t[2],a=e[0],u=e[1],c=e[2];return Math.abs(n-a)<=r*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(o-u)<=r*Math.max(1,Math.abs(o),Math.abs(u))&&Math.abs(i-c)<=r*Math.max(1,Math.abs(i),Math.abs(c))};var r=n(71)},function(t,e){t.exports=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}},function(t,e){t.exports=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}},function(t,e,n){t.exports=n(76)},function(t,e,n){t.exports=n(77)},function(t,e,n){t.exports=n(78)},function(t,e){t.exports=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t}},function(t,e){t.exports=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t}},function(t,e){t.exports=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}},function(t,e){t.exports=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}},function(t,e){t.exports=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}},function(t,e){t.exports=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}},function(t,e){t.exports=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t}},function(t,e,n){t.exports=n(79)},function(t,e,n){t.exports=n(80)},function(t,e,n){t.exports=n(81)},function(t,e,n){t.exports=n(82)},function(t,e){t.exports=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}},function(t,e){t.exports=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}},function(t,e){t.exports=function(t,e,n){var r=e[0],o=e[1],i=e[2],a=n[0],u=n[1],c=n[2];return t[0]=o*c-i*u,t[1]=i*a-r*c,t[2]=r*u-o*a,t}},function(t,e){t.exports=function(t,e,n,r){var o=e[0],i=e[1],a=e[2];return t[0]=o+r*(n[0]-o),t[1]=i+r*(n[1]-i),t[2]=a+r*(n[2]-a),t}},function(t,e){t.exports=function(t,e){e=e||1;var n=2*Math.random()*Math.PI,r=2*Math.random()-1,o=Math.sqrt(1-r*r)*e;return t[0]=Math.cos(n)*o,t[1]=Math.sin(n)*o,t[2]=r*e,t}},function(t,e){t.exports=function(t,e,n){var r=e[0],o=e[1],i=e[2],a=n[3]*r+n[7]*o+n[11]*i+n[15];return a=a||1,t[0]=(n[0]*r+n[4]*o+n[8]*i+n[12])/a,t[1]=(n[1]*r+n[5]*o+n[9]*i+n[13])/a,t[2]=(n[2]*r+n[6]*o+n[10]*i+n[14])/a,t}},function(t,e){t.exports=function(t,e,n){var r=e[0],o=e[1],i=e[2];return t[0]=r*n[0]+o*n[3]+i*n[6],t[1]=r*n[1]+o*n[4]+i*n[7],t[2]=r*n[2]+o*n[5]+i*n[8],t}},function(t,e){t.exports=function(t,e,n){var r=e[0],o=e[1],i=e[2],a=n[0],u=n[1],c=n[2],s=n[3],f=s*r+u*i-c*o,l=s*o+c*r-a*i,h=s*i+a*o-u*r,d=-a*r-u*o-c*i;return t[0]=f*s+d*-a+l*-c-h*-u,t[1]=l*s+d*-u+h*-a-f*-c,t[2]=h*s+d*-c+f*-u-l*-a,t}},function(t,e){t.exports=function(t,e,n,r){var o=n[1],i=n[2],a=e[1]-o,u=e[2]-i,c=Math.sin(r),s=Math.cos(r);return t[0]=e[0],t[1]=o+a*s-u*c,t[2]=i+a*c+u*s,t}},function(t,e){t.exports=function(t,e,n,r){var o=n[0],i=n[2],a=e[0]-o,u=e[2]-i,c=Math.sin(r),s=Math.cos(r);return t[0]=o+u*c+a*s,t[1]=e[1],t[2]=i+u*s-a*c,t}},function(t,e){t.exports=function(t,e,n,r){var o=n[0],i=n[1],a=e[0]-o,u=e[1]-i,c=Math.sin(r),s=Math.cos(r);return t[0]=o+a*s-u*c,t[1]=i+a*c+u*s,t[2]=e[2],t}},function(t,e,n){t.exports=function(t,e,n,o,i,a){var u,c;e||(e=3);n||(n=0);c=o?Math.min(o*e+n,t.length):t.length;for(u=n;u=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(u&&c){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),b(n),s}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;b(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:O(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},function(t,e,n){var r=n(230),o=n(240);t.exports=function(t,e){return r(t,e,(function(e,n){return o(t,n)}))}},function(t,e,n){var r=n(231),o=n(239),i=n(32);t.exports=function(t,e,n){for(var a=-1,u=e.length,c={};++a0&&i(f)?n>1?t(f,n-1,i,a,u):r(u,f):a||(u[u.length]=f)}return u}},function(t,e){t.exports=function(t,e){for(var n=-1,r=e.length,o=t.length;++nMath.abs(f-c),d=[],p=t.data,v=t.size.x,y=255,g=0;function x(t,e){u=p[e*v+t],y=ug?u:g,d.push(u)}h&&(i=c,c=s,s=i,i=f,f=l,l=i),c>f&&(i=c,c=f,f=i,i=s,s=l,l=i);var _=f-c,m=Math.abs(l-s);r=_/2|0,o=s;var b=sl?f.UP:f.DOWN,h.push({pos:0,val:s[0]}),i=0;id&&s[i+1]>.5*l?f.UP:r)&&(h.push({pos:i,val:s[i]}),r=o);for(h.push({pos:s.length,val:s[s.length-1]}),a=h[0].pos;al?0:1;for(i=1;ih[i].val?h[i].val+(h[i+1].val-h[i].val)/3*2|0:h[i+1].val+(h[i].val-h[i+1].val)/3|0,a=h[i].pos;ad?0:1;return{line:s,threshold:d}},s.debug={printFrequency:function(t,e){var n,r=e.getContext("2d");for(e.width=t.length,e.height=256,r.beginPath(),r.strokeStyle="blue",n=0;n1&&void 0!==arguments[1]?arguments[1]:0,n=e;nn)return Number.MAX_VALUE;o+=i}return o/u}},{key:"_nextSet",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e;n1&&(t[n[r]]=o)}},{key:"decodePattern",value:function(t){this._row=t;var e=this.decode();return null===e?(this._row.reverse(),(e=this.decode())&&(e.direction=l.Reverse,e.start=this._row.length-e.start,e.end=this._row.length-e.end)):e.direction=l.Forward,e&&(e.format=this.FORMAT),e}},{key:"_matchRange",value:function(t,e,n){var r;for(r=t=t<0?0:t;r0&&void 0!==arguments[0]?arguments[0]:this._nextUnset(this._row),e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._row.length,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=[],o=0;r[o]=0;for(var i=t;ithis.AVG_CODE_ERROR?null:(this.CODE_PATTERN[n.code]&&(n.correction.bar=this.calculateCorrection(this.CODE_PATTERN[n.code],r,this.MODULE_INDICES.bar),n.correction.space=this.calculateCorrection(this.CODE_PATTERN[n.code],r,this.MODULE_INDICES.space)),n)}r[++a]=1,i=!i}return null}},{key:"_correct",value:function(t,e){this._correctBars(t,e.bar,this.MODULE_INDICES.bar),this._correctBars(t,e.space,this.MODULE_INDICES.space)}},{key:"_findStart",value:function(){for(var t=[0,0,0,0,0,0],e=this._nextSet(this._row),n={error:Number.MAX_VALUE,code:-1,start:0,end:0,correction:{bar:1,space:1}},r=!1,o=0,i=e;i.48?null:o}n[++a]=1,i=!i}return null}},{key:"_findStart",value:function(){for(var t=this._nextSet(this._row),e=null;!e;){if(!(e=this._findPattern(I,t,!1,!0)))return null;var n=e.start-(e.end-e.start);if(n>=0&&this._matchRange(n,e.start,0))return e;t=e.end,e=null}return null}},{key:"_calculateFirstDigit",value:function(t){for(var e=0;e=10?(r.code-=10,o|=1<<5-i):o|=0<<5-i,e.push(r.code),n.push(r)}var a=this._calculateFirstDigit(o);if(null===a)return null;e.unshift(a);var u=this._findPattern(z,r.end,!0,!1);if(null===u||!u.end)return null;n.push(u);for(var c=0;c<6;c++){if(!(u=this._decodeCode(u.end,10)))return null;n.push(u),e.push(u.code)}return u}},{key:"_verifyTrailingWhitespace",value:function(t){var e=t.end+(t.end-t.start);return e=0;n-=2)e+=t[n];e*=3;for(var r=t.length-1;r>=0;r-=2)e+=t[r];return e%10==0}},{key:"_decodeExtensions",value:function(t){var e=this._nextSet(this._row,t),n=this._findPattern(U,e,!1,!1);if(null===n)return null;for(var r=0;r0){var u=this._decodeExtensions(a.end);if(!u)return null;if(!u.decodedCodes)return null;var c=u.decodedCodes[u.decodedCodes.length-1],s={start:c.start+((c.end-c.start)/2|0),end:c.end};if(!this._verifyTrailingWhitespace(s))return null;o={supplement:u,code:n.join("")+u.code}}return T(T({code:n.join(""),start:i.start,end:a.end,startInfo:i,decodedCodes:r},o),{},{format:this.FORMAT})}}]),n}(A),W=n(33),F=n.n(W);function V(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=C()(t);if(e){var o=C()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O()(this,n)}}var q=new Uint16Array(F()("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%").map((function(t){return t.charCodeAt(0)}))),G=new Uint16Array([52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,148,168,162,138,42]),H=function(t){b()(n,t);var e=V(n);function n(){var t;v()(this,n);for(var r=arguments.length,o=new Array(r),i=0;i3;){n=this._findNextWidth(t,n),r=0;for(var i=0,a=0;an&&(i|=1<0;u++)if(t[u]>n&&(r--,2*t[u]>=o))return-1;return i}}return-1}},{key:"_findNextWidth",value:function(t,e){for(var n=Number.MAX_VALUE,r=0;re&&(n=t[r]);return n}},{key:"_patternToChar",value:function(t){for(var e=0;e=r}},{key:"decode",value:function(t,e){var n=new Uint16Array([0,0,0,0,0,0,0,0,0]),r=[];if(!(e=this._findStart()))return null;var o,i,a=this._nextSet(this._row,e.end);do{n=this._toCounters(a,n);var u=this._toPattern(n);if(u<0)return null;if(null===(o=this._patternToChar(u)))return null;r.push(o),i=a,a+=S.a.sum(n),a=this._nextSet(this._row,a)}while("*"!==o);return r.pop(),r.length&&this._verifyTrailingWhitespace(i,a,n)?{code:r.join(""),start:e.start,end:a,startInfo:e,decodedCodes:r,format:this.FORMAT}:null}}]),n}(A),X=n(12),Q=n.n(X);function Y(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=C()(t);if(e){var o=C()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O()(this,n)}}var $=/[IOQ]/g,Z=/[A-Z0-9]{17}/,K=function(t){b()(n,t);var e=Y(n);function n(){var t;v()(this,n);for(var r=arguments.length,o=new Array(r),i=0;ir&&(r=o),othis._counters.length)return-1;for(var n=this._computeAlternatingThreshold(t,e),r=this._computeAlternatingThreshold(t+1,e),o=64,i=0,a=0,u=0;u<7;u++)i=0==(1&u)?n:r,this._counters[t+u]>i&&(a|=o),o>>=1;return a}},{key:"_isStartEnd",value:function(t){for(var e=0;e=this._calculatePatternLength(t)/2)&&(e+8>=this._counters.length||this._counters[e+7]>=this._calculatePatternLength(e)/2)}},{key:"_charToPattern",value:function(t){for(var e=t.charCodeAt(0),n=0;n=0;a--){var u=2==(1&a)?r.bar:r.space,c=1==(1&n)?u.wide:u.narrow;c.size+=this._counters[o+a],c.counts++,n>>=1}o+=8}return["space","bar"].forEach((function(t){var e=r[t];e.wide.min=Math.floor((e.narrow.size/e.narrow.counts+e.wide.size/e.wide.counts)/2),e.narrow.max=Math.ceil(e.wide.min),e.wide.max=Math.ceil((2*e.wide.size+1.5)/e.wide.counts)})),r}},{key:"_validateResult",value:function(t,e){for(var n,r=this._thresholdResultPattern(t,e),o=e,i=0;i=0;a--){var u=0==(1&a)?r.bar:r.space,c=1==(1&n)?u.wide:u.narrow,s=this._counters[o+a];if(sc.max)return!1;n>>=1}o+=8}return!0}},{key:"decode",value:function(t,e){if(this._counters=this._fillCounters(),!(e=this._findStart()))return null;var n,r=e.startCounter,o=[];do{if((n=this._toPattern(r))<0)return null;var i=this._patternToChar(n);if(null===i)return null;if(o.push(i),r+=8,o.length>1&&this._isStartEnd(n))break}while(rthis._counters.length?this._counters.length:r;var a=e.start+this._sumCounters(e.startCounter,r-8);return{code:o.join(""),start:e.start,end:a,startInfo:e,decodedCodes:o,format:this.FORMAT}}}]),n}(A);function ot(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=C()(t);if(e){var o=C()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O()(this,n)}}var it=function(t){b()(n,t);var e=ot(n);function n(){var t;v()(this,n);for(var r=arguments.length,o=new Array(r),i=0;i=10&&(n|=1<<1-c),1!==c&&(r=this._nextSet(this._row,u.end),r=this._nextUnset(this._row,r))}if(2!==i.length||parseInt(i.join(""))%4!==n)return null;var s=this._findStart();return{code:i.join(""),decodedCodes:a,end:u.end,format:this.FORMAT,startInfo:s,start:s.start}}}]),n}(B);function ft(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=C()(t);if(e){var o=C()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O()(this,n)}}var lt=[24,20,18,17,12,6,3,10,9,5];var ht=function(t){b()(n,t);var e=ft(n);function n(){var t;v()(this,n);for(var r=arguments.length,o=new Array(r),i=0;i=10&&(n|=1<<4-c),4!==c&&(r=this._nextSet(this._row,i.end),r=this._nextUnset(this._row,r))}if(5!==a.length)return null;if(function(t){for(var e=t.length,n=0,r=e-2;r>=0;r-=2)n+=t[r];n*=3;for(var o=e-1;o>=0;o-=2)n+=t[o];return(n*=3)%10}(a)!==function(t){for(var e=0;e<10;e++)if(t===lt[e])return e;return null}(n))return null;var s=this._findStart();return{code:a.join(""),decodedCodes:u,end:i.end,format:this.FORMAT,startInfo:s,start:s.start}}}]),n}(B);function dt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function pt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=C()(t);if(e){var o=C()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O()(this,n)}}var vt=function(t){b()(n,t);var e=pt(n);function n(){var t;v()(this,n);for(var r=arguments.length,o=new Array(r),i=0;i=10&&(r.code=r.code-10,o|=1<<5-i),e.push(r.code),n.push(r)}return this._determineParity(o,e)?r:null}},{key:"_determineParity",value:function(t,e){for(var n=0;n2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=new Array(t.length).fill(0),i=0,a={error:Number.MAX_VALUE,start:0,end:0},u=this.AVG_CODE_ERROR;n=n||!1,r=r||!1,e||(e=this._nextSet(this._row));for(var c=e;c=0&&this._matchRange(t,n.start,0))return n;e=n.end,n=null}return null}},{key:"_verifyTrailingWhitespace",value:function(t){var e=t.end+(t.end-t.start)/2;return e2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=[],i=0,a={error:Number.MAX_VALUE,code:-1,start:0,end:0},u=0,c=0,s=this.AVG_CODE_ERROR;e||(e=this._nextSet(this._row));for(var f=0;f=0&&this._matchRange(r,t.start,0))return t;e=t.end,t=null}return t}},{key:"_verifyTrailingWhitespace",value:function(t){var e=t.end+(t.end-t.start)/2;return e4)return-1;if(0==(1&o))for(var a=0;a="a"&&o<="d"){if(r>e-2)return null;var i=t[++r],a=i.charCodeAt(0),u=void 0;switch(o){case"a":if(!(i>="A"&&i<="Z"))return null;u=String.fromCharCode(a-64);break;case"b":if(i>="A"&&i<="E")u=String.fromCharCode(a-38);else if(i>="F"&&i<="J")u=String.fromCharCode(a-11);else if(i>="K"&&i<="O")u=String.fromCharCode(a+16);else if(i>="P"&&i<="S")u=String.fromCharCode(a+43);else{if(!(i>="T"&&i<="Z"))return null;u=String.fromCharCode(127)}break;case"c":if(i>="A"&&i<="O")u=String.fromCharCode(a-32);else{if("Z"!==i)return null;u=":"}break;case"d":if(!(i>="A"&&i<="Z"))return null;u=String.fromCharCode(a+32);break;default:return console.warn("* code_93_reader _decodeExtended hit default case, this may be an error",u),null}n.push(u)}else n.push(o)}return n}},{key:"_matchCheckChar",value:function(t,e,n){var r=t.slice(0,e),o=r.length,i=r.reduce((function(t,e,r){return t+((-1*r+(o-1))%n+1)*Ct.indexOf(e.charCodeAt(0))}),0);return Ct[i%47]===t[e].charCodeAt(0)}},{key:"_verifyChecksums",value:function(t){return this._matchCheckChar(t,t.length-2,20)&&this._matchCheckChar(t,t.length-1,15)}},{key:"decode",value:function(t,e){if(!(e=this._findStart()))return null;var n,r,o=new Uint16Array([0,0,0,0,0,0]),i=[],a=this._nextSet(this._row,e.end);do{o=this._toCounters(a,o);var u=this._toPattern(o);if(u<0)return null;if(null===(r=this._patternToChar(u)))return null;i.push(r),n=a,a+=S.a.sum(o),a=this._nextSet(this._row,a)}while("*"!==r);return i.pop(),i.length&&this._verifyEnd(n,a)&&this._verifyChecksums(i)?(i=i.slice(0,i.length-2),null===(i=this._decodeExtended(i))?null:{code:i.join(""),start:e.start,end:a,startInfo:e,decodedCodes:i,format:this.FORMAT}):null}}]),n}(A);function St(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=C()(t);if(e){var o=C()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O()(this,n)}}var At=/[AEIO]/g,kt=function(t){b()(n,t);var e=St(n);function n(){var t;v()(this,n);for(var r=arguments.length,o=new Array(r),i=0;i1&&(!e.inImageWithBorder(t[0])||!e.inImageWithBorder(t[1]));)o(-(r-=Math.ceil(r/2)));return t}(r,u,Math.floor(.1*i)))?null:(null===(o=a(r))&&(o=function(t,e,n){var r,o,i,u=Math.sqrt(Math.pow(t[1][0]-t[0][0],2)+Math.pow(t[1][1]-t[0][1],2)),c=null,s=Math.sin(n),f=Math.cos(n);for(r=1;r<16&&null===c;r++)i={y:(o=u/16*r*(r%2==0?-1:1))*s,x:o*f},e[0].y+=i.x,e[0].x-=i.y,e[1].y+=i.x,e[1].x-=i.y,c=a(e);return c}(t,r,u)),null===o?null:{codeResult:o.codeResult,line:r,angle:u,pattern:o.barcodeLine.line,threshold:o.barcodeLine.threshold})}return o(),{decodeFromBoundingBox:function(t){return u(t)},decodeFromBoundingBoxes:function(e){var n,r,o=[],i=t.multiple;for(n=0;n2&&void 0!==arguments[2]&&arguments[2];r(t,{callback:e,async:n,once:!0})},unsubscribe:function(n,r){if(n){var o=e(n);o.subscribers=o&&r?o.subscribers.filter((function(t){return t.callback!==r})):[]}else t={}}}}(),jt=n(20),It=n.n(jt),zt=n(11),Ut=n.n(zt),Lt=n(85),Nt=n.n(Lt),Bt=n(86);function Wt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=C()(t);if(e){var o=C()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O()(this,n)}}var Ft,Vt=function(t){b()(n,t);var e=Wt(n);function n(t,r){var o;return v()(this,n),o=e.call(this,t),M()(_()(o),"code",void 0),o.code=r,Object.setPrototypeOf(_()(o),n.prototype),o}return n}(n.n(Bt)()(Error)),qt="This may mean that the user has declined camera access, or the browser does not support media APIs. If you are running in iOS, you must use Safari.";function Gt(){try{return navigator.mediaDevices.enumerateDevices()}catch(e){var t=new Vt("enumerateDevices is not defined. ".concat(qt),-1);return Promise.reject(t)}}function Ht(t){try{return navigator.mediaDevices.getUserMedia(t)}catch(t){var e=new Vt("getUserMedia is not defined. ".concat(qt),-1);return Promise.reject(e)}}function Xt(t){return new Promise((function(e,n){var r=10;!function o(){r>0?t.videoWidth>10&&t.videoHeight>10?e():window.setTimeout(o,500):n(new Vt("Unable to play video stream. Is webcam working?",-1)),r--}()}))}function Qt(t,e){return Yt.apply(this,arguments)}function Yt(){return(Yt=It()(Ut.a.mark((function t(e,n){var r;return Ut.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Ht(n);case 2:if(r=t.sent,Ft=r,!e){t.next=11;break}return e.setAttribute("autoplay","true"),e.setAttribute("muted","true"),e.setAttribute("playsinline","true"),e.srcObject=r,e.addEventListener("loadedmetadata",(function(){e.play()})),t.abrupt("return",Xt(e));case 11:return t.abrupt("return",Promise.resolve());case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function $t(t){var e=Nt()(t,["width","height","facingMode","aspectRatio","deviceId"]);return void 0!==t.minAspectRatio&&t.minAspectRatio>0&&(e.aspectRatio=t.minAspectRatio,console.log("WARNING: Constraint 'minAspectRatio' is deprecated; Use 'aspectRatio' instead")),void 0!==t.facing&&(e.facingMode=t.facing,console.log("WARNING: Constraint 'facing' is deprecated. Use 'facingMode' instead'")),e}function Zt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=$t(t);return e&&e.deviceId&&e.facingMode&&delete e.facingMode,Promise.resolve({audio:!1,video:e})}function Kt(){return(Kt=It()(Ut.a.mark((function t(){var e;return Ut.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Gt();case 2:return e=t.sent,t.abrupt("return",e.filter((function(t){return"videoinput"===t.kind})));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Jt(){if(!Ft)return null;var t=Ft.getVideoTracks();return t&&null!=t&&t.length?t[0]:null}var te={requestedVideoElement:null,request:function(t,e){return It()(Ut.a.mark((function n(){var r;return Ut.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return te.requestedVideoElement=t,n.next=3,Zt(e);case 3:return r=n.sent,n.abrupt("return",Qt(t,r));case 5:case"end":return n.stop()}}),n)})))()},release:function(){var t=Ft&&Ft.getVideoTracks();return null!==te.requestedVideoElement&&te.requestedVideoElement.pause(),new Promise((function(e){setTimeout((function(){t&&t.length&&t[0].stop(),Ft=null,te.requestedVideoElement=null,e()}),0)}))},enumerateVideoDevices:function(){return Kt.apply(this,arguments)},getActiveStreamLabel:function(){var t=Jt();return t?t.label:""},getActiveTrack:Jt},ee=te;var ne={create:function(t){var e,n=document.createElement("canvas"),r=n.getContext("2d"),o=[],i=null!==(e=t.capacity)&&void 0!==e?e:20,a=!0===t.capture;function u(e){return!!i&&e&&!function(t,e){return e&&e.some((function(e){return Object.keys(e).every((function(n){return e[n]===t[n]}))}))}(e,t.blacklist)&&function(t,e){return"function"!=typeof e||e(t)}(e,t.filter)}return{addResult:function(t,e,c){var s={};u(c)&&(i--,s.codeResult=c,a&&(n.width=e.x,n.height=e.y,d.a.drawImage(t,e,r),s.frame=n.toDataURL()),o.push(s))},getResults:function(){return o}}}},re={inputStream:{name:"Live",type:"LiveStream",constraints:{width:640,height:480,facingMode:"environment"},area:{top:"0%",right:"0%",left:"0%",bottom:"0%"},singleChannel:!1},locate:!0,numOfWorkers:4,decoder:{readers:["code_128_reader"]},locator:{halfSample:!0,patchSize:"medium"}},oe=n(7),ie=function t(){v()(this,t),M()(this,"config",void 0),M()(this,"inputStream",void 0),M()(this,"framegrabber",void 0),M()(this,"inputImageWrapper",void 0),M()(this,"stopped",!1),M()(this,"boxSize",void 0),M()(this,"resultCollector",void 0),M()(this,"decoder",void 0),M()(this,"workerPool",[]),M()(this,"onUIThread",!0),M()(this,"canvasContainer",new ue)},ae=function t(){v()(this,t),M()(this,"image",void 0),M()(this,"overlay",void 0)},ue=function t(){v()(this,t),M()(this,"ctx",void 0),M()(this,"dom",void 0),this.ctx=new ae,this.dom=new ae},ce=n(23);function se(t){if("undefined"==typeof document)return null;if(t instanceof HTMLElement&&t.nodeName&&1===t.nodeType)return t;var e="string"==typeof t?t:"#interactive.viewport";return document.querySelector(e)}function fe(t,e){var n=function(t,e){var n=document.querySelector(t);return n||((n=document.createElement("canvas")).className=e),n}(t,e),r=n.getContext("2d");return{canvas:n,context:r}}function le(t){var e,n,r,o,i=se(null==t||null===(e=t.config)||void 0===e||null===(n=e.inputStream)||void 0===n?void 0:n.target),a=null==t||null===(r=t.config)||void 0===r||null===(o=r.inputStream)||void 0===o?void 0:o.type;if(!a)return null;var u=function(t){if("undefined"!=typeof document){var e=fe("canvas.imgBuffer","imgBuffer"),n=fe("canvas.drawingBuffer","drawingBuffer");return e.canvas.width=n.canvas.width=t.x,e.canvas.height=n.canvas.height=t.y,{dom:{image:e.canvas,overlay:n.canvas},ctx:{image:e.context,overlay:n.context}}}return null}(t.inputStream.getCanvasSize());if(!u)return{dom:{image:null,overlay:null},ctx:{image:null,overlay:null}};var c=u.dom;return"undefined"!=typeof document&&i&&("ImageStream"!==a||i.contains(c.image)||i.appendChild(c.image),i.contains(c.overlay)||i.appendChild(c.overlay)),u}var he={274:"orientation"},de=Object.keys(he).map((function(t){return he[t]}));function pe(t){return new Promise((function(e){var n=new FileReader;n.onload=function(t){return e(t.target.result)},n.readAsArrayBuffer(t)}))}function ve(t){return new Promise((function(e,n){var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="blob",r.onreadystatechange=function(){r.readyState!==XMLHttpRequest.DONE||200!==r.status&&0!==r.status||e(this.response)},r.onerror=n,r.send()}))}function ye(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:de,n=new DataView(t),r=t.byteLength,o=e.reduce((function(t,e){var n=Object.keys(he).filter((function(t){return he[t]===e}))[0];return n&&(t[n]=e),t}),{}),i=2;if(255!==n.getUint8(0)||216!==n.getUint8(1))return!1;for(;i1&&void 0!==arguments[1]?arguments[1]:de;return/^blob:/i.test(t)?ve(t).then(pe).then((function(t){return ye(t,e)})):Promise.resolve(null)}(t,["orientation"]).then((function(t){s[0].tags=t,e(s)})).catch((function(t){console.log(t),e(s)})):e(s))},i=0;i0&&n.forEach((function(n){t.removeEventListener(e,n)}))}))},trigger:function(o,a){var s,f,l,h,d,p=i[o];if("canrecord"===o&&(h=t.videoWidth,d=t.videoHeight,e=null!==(f=r)&&void 0!==f&&f.size?h/d>1?r.size:Math.floor(h/d*r.size):h,n=null!==(l=r)&&void 0!==l&&l.size?h/d>1?Math.floor(d/h*r.size):r.size:d,u.x=e,u.y=n),p&&p.length>0)for(s=0;s0)for(n=0;n1?n.size:Math.floor(r/o*n.size):r,e=null!==(f=n)&&void 0!==f&&f.size?r/o>1?Math.floor(o/r*n.size):n.size:o,v.x=t,v.y=e,u=!0,i=0,setTimeout((function(){y("canrecord",[])}),0)}),1,s,null===(l=n)||void 0===l?void 0:l.sequence)},ended:function(){return l},setAttribute:function(){},getConfig:function(){return n},pause:function(){a=!0},play:function(){a=!1},setCurrentTime:function(t){i=t},addEventListener:function(t,e){-1!==h.indexOf(t)&&(d[t]||(d[t]=[]),d[t].push(e))},clearEventHandlers:function(){Object.keys(d).forEach((function(t){return delete d[t]}))},setTopRight:function(t){p.x=t.x,p.y=t.y},getTopRight:function(){return p},setCanvasSize:function(t){v.x=t.x,v.y=t.y},getCanvasSize:function(){return v},getFrame:function(){var t,e;if(!u)return null;a||(t=null===(e=c)||void 0===e?void 0:e[i],i=t&&r&&r()};if(e)for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:"LiveStream",e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;switch(t){case"VideoStream":var r=document.createElement("video");return{video:r,inputStream:n.createVideoStream(r)};case"ImageStream":return{inputStream:n.createImageStream()};case"LiveStream":var o=null;return e&&((o=e.querySelector("video"))||(o=document.createElement("video"),e.appendChild(o))),{video:o,inputStream:n.createLiveStream(o)};default:return console.error("* setupInputStream invalid type ".concat(t)),{video:null,inputStream:null}}}(n,this.getViewPort(),Oe),i=o.video,a=o.inputStream;"LiveStream"===n&&i&&ee.request(i,r).then((function(){return a.trigger("canrecord")})).catch((function(e){return t(e)})),a.setAttribute("preload","auto"),a.setInputStream(this.context.config.inputStream),a.addEventListener("canrecord",this.canRecord.bind(void 0,t)),this.context.inputStream=a}}},{key:"getBoundingBoxes",value:function(){var t;return null!==(t=this.context.config)&&void 0!==t&&t.locate?ce.a.locate():[[Object(oe.clone)(this.context.boxSize[0]),Object(oe.clone)(this.context.boxSize[1]),Object(oe.clone)(this.context.boxSize[2]),Object(oe.clone)(this.context.boxSize[3])]]}},{key:"transformResult",value:function(t){var e=this,n=this.context.inputStream.getTopRight(),r=n.x,o=n.y;if((0!==r||0!==o)&&(t.barcodes&&t.barcodes.forEach((function(t){return e.transformResult(t)})),t.line&&2===t.line.length&&function(t,e,n){t[0].x+=e,t[0].y+=n,t[1].x+=e,t[1].y+=n}(t.line,r,o),t.box&&Ie(t.box,r,o),t.boxes&&t.boxes.length>0))for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1?arguments[1]:void 0,n=t;t&&this.context.onUIThread&&(this.transformResult(t),this.addResult(t,e),n=t.barcodes||t),Tt.publish("processed",n),this.hasCodeResult(t)&&Tt.publish("detected",n)}},{key:"locateAndDecode",value:function(){var t=this.getBoundingBoxes();if(t){var e,n=this.context.decoder.decodeFromBoundingBoxes(t)||{};n.boxes=t,this.publishResult(n,null===(e=this.context.inputImageWrapper)||void 0===e?void 0:e.data)}else{var r,o=this.context.decoder.decodeFromImage(this.context.inputImageWrapper);if(o)this.publishResult(o,null===(r=this.context.inputImageWrapper)||void 0===r?void 0:r.data);else this.publishResult()}}},{key:"startContinuousUpdate",value:function(){var t,e=this,n=null,r=1e3/((null===(t=this.context.config)||void 0===t?void 0:t.frequency)||60);this.context.stopped=!1;var o=this.context;!function t(i){n=n||i,o.stopped||(i>=n&&(n+=r,e.update()),window.requestAnimationFrame(t))}(performance.now())}},{key:"start",value:function(){var t,e;this.context.onUIThread&&"LiveStream"===(null===(t=this.context.config)||void 0===t||null===(e=t.inputStream)||void 0===e?void 0:e.type)?this.startContinuousUpdate():this.update()}},{key:"stop",value:(e=It()(Ut.a.mark((function t(){var e;return Ut.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.context.stopped=!0,je(0),null===(e=this.context.config)||void 0===e||!e.inputStream||"LiveStream"!==this.context.config.inputStream.type){t.next=6;break}return t.next=5,ee.release();case 5:this.context.inputStream.clearEventHandlers();case 6:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"setReaders",value:function(t){this.context.decoder&&this.context.decoder.setReaders(t),function(t){ke.forEach((function(e){return e.worker.postMessage({cmd:"setReaders",readers:t})}))}(t)}},{key:"registerReader",value:function(t,e){Dt.registerReader(t,e),this.context.decoder&&this.context.decoder.registerReader(t,e),function(t,e){ke.forEach((function(n){return n.worker.postMessage({cmd:"registerReader",name:t,reader:e})}))}(t,e)}}]),t}(),Ue=new ze,Le=Ue.context,Ne={init:function(t,e,n){var r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ue;return e||(r=new Promise((function(t,n){e=function(e){e?n(e):t()}}))),o.context.config=u()({},re,t),o.context.config.numOfWorkers>0&&(o.context.config.numOfWorkers=0),n?(o.context.onUIThread=!1,o.initializeData(n),e&&e()):o.initInputStream(e),r},start:function(){return Ue.start()},stop:function(){return Ue.stop()},pause:function(){Le.stopped=!0},onDetected:function(t){t&&("function"==typeof t||"object"===i()(t)&&t.callback)?Tt.subscribe("detected",t):console.trace("* warning: Quagga.onDetected called with invalid callback, ignoring")},offDetected:function(t){Tt.unsubscribe("detected",t)},onProcessed:function(t){t&&("function"==typeof t||"object"===i()(t)&&t.callback)?Tt.subscribe("processed",t):console.trace("* warning: Quagga.onProcessed called with invalid callback, ignoring")},offProcessed:function(t){Tt.unsubscribe("processed",t)},setReaders:function(t){t?Ue.setReaders(t):console.trace("* warning: Quagga.setReaders called with no readers, ignoring")},registerReader:function(t,e){t?e?Ue.registerReader(t,e):console.trace("* warning: Quagga.registerReader called with no reader, ignoring"):console.trace("* warning: Quagga.registerReader called with no name, ignoring")},registerResultCollector:function(t){t&&"function"==typeof t.addResult&&(Le.resultCollector=t)},get canvas(){return Le.canvasContainer},decodeSingle:function(t,e){var n=this,r=new ze;return(t=u()({inputStream:{type:"ImageStream",sequence:!1,size:800,src:t.src},numOfWorkers:1,locator:{halfSample:!1}},t)).numOfWorkers>0&&(t.numOfWorkers=0),t.numOfWorkers>0&&("undefined"==typeof Blob||"undefined"==typeof Worker)&&(console.warn("* no Worker and/or Blob support - forcing numOfWorkers to 0"),t.numOfWorkers=0),new Promise((function(o,i){try{n.init(t,(function(){Tt.once("processed",(function(t){r.stop(),e&&e.call(null,t),o(t)}),!0),r.start()}),null,r)}catch(t){i(t)}}))},get default(){return Ne},Readers:r,CameraAccess:ee,ImageDebug:d.a,ImageWrapper:c.a,ResultCollector:ne};e.default=Ne}]).default})); \ No newline at end of file From 340b306d2e6cc6e6fad36a51f15e4fe8bbe3e3e0 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sat, 26 Feb 2022 18:08:07 -0800 Subject: [PATCH 04/24] Fix path --- bookwyrm/templates/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index 54ccbe27..b059af6d 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -272,7 +272,7 @@ - + {% block scripts %}{% endblock %} From fcc8b6aaabe7df427038d485b3b1a07cf94fd193 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sat, 26 Feb 2022 18:19:12 -0800 Subject: [PATCH 05/24] Move to sass --- bookwyrm/static/css/bookwyrm.css | 1319 ----------------- bookwyrm/static/css/bookwyrm/_all.scss | 1 + .../css/bookwyrm/components/_barcode.scss | 14 + 3 files changed, 15 insertions(+), 1319 deletions(-) delete mode 100644 bookwyrm/static/css/bookwyrm.css create mode 100644 bookwyrm/static/css/bookwyrm/components/_barcode.scss diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css deleted file mode 100644 index f1faf30c..00000000 --- a/bookwyrm/static/css/bookwyrm.css +++ /dev/null @@ -1,1319 +0,0 @@ -html { - scroll-behavior: smooth; -} - -body { - min-height: 100vh; - display: flex; - flex-direction: column; -} - -button { - border: none; - margin: 0; - padding: 0; - width: auto; - overflow: visible; - background: transparent; - - /* inherit font, color & alignment from ancestor */ - color: inherit; - font: inherit; - text-align: inherit; - - /* Normalize `line-height`. Cannot be changed from `normal` in Firefox 4+. */ - line-height: normal; - - /* Corrects font smoothing for webkit */ - -webkit-font-smoothing: inherit; - -moz-osx-font-smoothing: inherit; - - /* Corrects inability to style clickable `input` types in iOS */ - -webkit-appearance: none; - - /* Generalizes pointer cursor */ - cursor: pointer; -} - -button::-moz-focus-inner { - /* Remove excess padding and border in Firefox 4+ */ - border: 0; - padding: 0; -} - -/* Better accessibility for keyboard users */ -*:focus-visible { - outline-style: auto !important; -} - -.image { - overflow: hidden; -} - -.navbar .logo { - max-height: 50px; -} - -.card { - overflow: visible; -} - -.card.has-border { - border: 1px solid #eee; -} - -.scroll-x { - overflow: hidden; - overflow-x: auto; -} - -.modal-card { - pointer-events: none; -} - -.modal-card > * { - pointer-events: all; -} - -/* stylelint-disable no-descending-specificity */ -.modal-card:focus { - outline-style: auto; -} - -.modal-card:focus:not(:focus-visible) { - outline-style: initial; -} - -.modal-card:focus-visible { - outline-style: auto; -} -/* stylelint-enable no-descending-specificity */ - -.modal-card.is-fullwidth { - min-width: 75% !important; -} - -@media only screen and (min-width: 769px) { - .modal-card.is-thin { - width: 350px !important; - } -} - -.modal-card-body { - max-height: 70vh; -} - -.clip-text { - max-height: 35em; - overflow: hidden; -} - -/** Utilities not covered by Bulma - ******************************************************************************/ - -@media only screen and (max-width: 768px) { - .is-sr-only-mobile { - border: none !important; - clip: rect(0, 0, 0, 0) !important; - height: 0.01em !important; - overflow: hidden !important; - padding: 0 !important; - position: absolute !important; - white-space: nowrap !important; - width: 0.01em !important; - } - - .m-0-mobile { - margin: 0 !important; - } - - .card-footer.is-stacked-mobile { - flex-direction: column; - } - - .card-footer.is-stacked-mobile .card-footer-item:not(:last-child) { - border-bottom: 1px solid #ededed; - border-right: 0; - } - - .is-flex-direction-row-mobile { - flex-direction: row !important; - } - - .is-flex-direction-column-mobile { - flex-direction: column !important; - } -} - -.tag.is-small { - height: auto; -} - -.button.is-transparent { - background-color: transparent; -} - -.card.is-stretchable { - display: flex; - flex-direction: column; - height: 100%; -} - -.card.is-stretchable .card-content { - flex-grow: 1; -} - -.preserve-whitespace p { - white-space: pre-wrap !important; -} - -.display-inline p { - display: inline !important; -} - -button .button-invisible-overlay { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - padding: 1rem; - box-sizing: border-box; - display: flex; - align-items: center; - flex-direction: column; - justify-content: center; - background: rgba(0, 0, 0, 66%); - color: white; - opacity: 0; - transition: opacity 0.2s ease; -} - -button:hover .button-invisible-overlay, -button:active .button-invisible-overlay, -button:focus-visible .button-invisible-overlay { - opacity: 1; -} - -/** File input styles - ******************************************************************************/ - -input[type="file"]::file-selector-button { - -moz-appearance: none; - -webkit-appearance: none; - background-color: #fff; - border-radius: 4px; - border: 1px solid #dbdbdb; - box-shadow: none; - color: #363636; - cursor: pointer; - font-size: 1rem; - height: 2.5em; - justify-content: center; - line-height: 1.5; - padding-bottom: calc(0.5em - 1px); - padding-left: 1em; - padding-right: 1em; - padding-top: calc(0.5em - 1px); - text-align: center; - white-space: nowrap; -} - -input[type="file"]::file-selector-button:hover { - border-color: #b5b5b5; - color: #363636; -} - -/** General `details` element styles - ******************************************************************************/ - -details summary { - cursor: pointer; -} - -summary::-webkit-details-marker { - display: none; -} - -details summary::marker { - content: none; -} - -details.detail-pinned-button summary { - position: absolute; - right: 0; -} - -details.detail-pinned-button form { - float: left; - width: 100%; - margin-top: 1em; -} - -/** Dropdown w/ Details element - ******************************************************************************/ - -details.dropdown[open] summary.dropdown-trigger::before { - content: ""; - position: fixed; - top: 0; - bottom: 0; - left: 0; - right: 0; -} - -details.dropdown .dropdown-menu { - display: block !important; -} - -details.dropdown .dropdown-menu button { - /* Fix weird Safari defaults */ - box-sizing: border-box; -} - -details.dropdown .dropdown-menu button:focus-visible, -details.dropdown .dropdown-menu a:focus-visible { - outline-style: auto; - outline-offset: -2px; -} - -@media only screen and (max-width: 768px) { - details.dropdown[open] summary.dropdown-trigger::before { - background-color: rgba(0, 0, 0, 50%); - z-index: 30; - } - - details .dropdown-menu { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - display: flex !important; - align-items: center; - justify-content: center; - pointer-events: none; - z-index: 100; - } - - details .dropdown-menu > * { - pointer-events: all; - } -} - -/** Details panel - ******************************************************************************/ - -details.details-panel { - box-shadow: 0 0 0 1px rgba(0, 0, 0, 10%); - transition: box-shadow 0.2s ease; - padding: 0.75rem; -} - -details[open].details-panel, -details.details-panel:hover { - box-shadow: 0 0 0 1px rgba(0, 0, 0, 20%); -} - -details.details-panel summary { - position: relative; -} - -details.details-panel summary .details-close { - position: absolute; - right: 0; - top: 0; - transform: rotate(45deg); - transition: transform 0.2s ease; -} - -details[open].details-panel summary .details-close { - transform: rotate(0deg); -} - -@media only screen and (min-width: 769px) { - .details-panel .filters-field:not(:last-child) { - border-right: 1px solid rgba(0, 0, 0, 10%); - margin-top: 0.75rem; - margin-bottom: 0.75rem; - padding-top: 0.25rem; - padding-bottom: 0.25rem; - } -} - -/** Shelving - ******************************************************************************/ - -/** @todo Replace icons with SVG symbols. - @see https://www.youtube.com/watch?v=9xXBYcWgCHA */ -.shelf-option:disabled > *::after { - font-family: icomoon; /* stylelint-disable font-family-no-missing-generic-family-keyword */ - content: "\e919"; /* icon-check */ - margin-left: 0.5em; -} - -/** Toggles - ******************************************************************************/ - -.toggle-button[aria-pressed="true"], -.toggle-button[aria-pressed="true"]:hover { - background-color: hsl(171deg, 100%, 41%); - color: white; -} - -.hide-active[aria-pressed="true"], -.hide-inactive[aria-pressed="false"] { - display: none; -} - -.transition-x.is-hidden, -.transition-y.is-hidden { - display: block !important; - visibility: hidden !important; - height: 0 !important; - width: 0 !important; - margin: 0 !important; - padding: 0 !important; - overflow: auto; -} - -.transition-x, -.transition-y { - transition-duration: 0.5s; - transition-timing-function: ease; -} - -.transition-x { - transition-property: width, margin-left, margin-right, padding-left, padding-right; -} - -.transition-y { - transition-property: height, margin-top, margin-bottom, padding-top, padding-bottom; -} - -@media (prefers-reduced-motion: reduce) { - .transition-x, - .transition-y { - transition-duration: 0.001ms !important; - } -} - -/** Stars - ******************************************************************************/ - -.stars { - white-space: nowrap; -} - -/** Stars in a review form - * - * Specificity makes hovering taking over checked inputs. - * - * \e9d9: filled star - * \e9d7: empty star; - * -------------------------------------------------------------------------- */ - -.form-rate-stars { - width: max-content; -} - -/* All stars are visually filled by default. */ -.form-rate-stars .icon::before { - content: "\e9d9"; /* icon-star-full */ -} - -/* Icons directly following half star inputs are marked as half */ -.form-rate-stars input.half:checked ~ .icon::before { - content: "\e9d8"; /* icon-star-half */ -} - -/* stylelint-disable no-descending-specificity */ -.form-rate-stars input.half:checked + input + .icon:hover::before { - content: "\e9d8" !important; /* icon-star-half */ -} - -/* Icons directly following half check inputs that follow the checked input are emptied. */ -.form-rate-stars input.half:checked + input + .icon ~ .icon::before { - content: "\e9d7"; /* icon-star-empty */ -} - -/* Icons directly following inputs that follow the checked input are emptied. */ -.form-rate-stars input:checked ~ input + .icon::before { - content: "\e9d7"; /* icon-star-empty */ -} - -/* When a label is hovered, repeat the fill-all-then-empty-following pattern. */ -.form-rate-stars:hover .icon.icon::before { - content: "\e9d9" !important; /* icon-star-full */ -} - -.form-rate-stars .icon:hover ~ .icon::before { - content: "\e9d7" !important; /* icon-star-empty */ -} - -/** Book covers - * - * - .is-cover gives the behaviour of the cover and its surrounding. (optional) - * - .cover-container gives the dimensions and position (for borders, image and other elements). - * - .book-cover is positioned and sized based on its container. - * - * To have the cover within specific dimensions, specify a width or height for - * standard bulma’s named breapoints: - * - * `is-(w|h)-(auto|xs|s|m|l|xl|xxl)[-(mobile|tablet|desktop)]` - * - * The cover will be centered horizontally and vertically within those dimensions. - * - * When using `.column.is-N`, add `.is-w-auto` to the container so that the flex - * calculations are not biased by the default `max-content`. - ******************************************************************************/ - -.column.is-cover { - flex-grow: 0 !important; -} - -.column.is-cover, -.column.is-cover + .column { - flex-basis: auto !important; -} - -.cover-container { - display: flex; - justify-content: center; - align-items: center; - position: relative; - width: max-content; - max-width: 100%; - overflow: hidden; -} - -/* Book cover - * -------------------------------------------------------------------------- */ - -.book-cover { - display: block; - max-width: 100%; - max-height: 100%; - - /* Useful when stretching under-sized images. */ - image-rendering: optimizequality; - image-rendering: smooth; -} - -/* Cover caption - * -------------------------------------------------------------------------- */ - -.no-cover .cover-caption { - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - padding: 0.5em; - font-size: 0.75em; - color: white; - background-color: #002549; - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - gap: 1em; - white-space: initial; - text-align: center; -} - -/** Avatars - ******************************************************************************/ - -.avatar { - vertical-align: middle; - display: inline; -} - -/** Statuses: Quotes - * - * \e906: icon-quote-open - * \e905: icon-quote-close - * - * The `content` class on the blockquote allows to apply styles to markdown - * generated HTML in the quote: https://bulma.io/documentation/elements/content/ - * - * ```html - *
- *
- * User generated quote in markdown… - *
- * - *

Book Title by Author

- *
- * ``` - ******************************************************************************/ - -.quote > blockquote { - position: relative; - padding-left: 2em; -} - -.quote > blockquote::before, -.quote > blockquote::after { - font-family: icomoon; - position: absolute; -} - -.quote > blockquote::before { - content: "\e907"; /* icon-quote-open */ - top: 0; - left: 0; -} - -.quote > blockquote::after { - content: "\e906"; /* icon-quote-close */ - right: 0; -} - -/** Animations and transitions - ******************************************************************************/ - -@keyframes turning { - from { transform: rotateZ(0deg); } - to { transform: rotateZ(360deg); } -} - -.is-processing .icon-spinner::before { - animation: turning 1.5s infinite linear; -} - -.icon-spinner { - display: none; -} - -.is-processing .icon-spinner { - display: flex; -} - -@media (prefers-reduced-motion: reduce) { - .is-processing .icon::before { - transition-duration: 0.001ms !important; - } -} - -/** Transient notification - ******************************************************************************/ - -#live-messages { - position: fixed; - bottom: 1em; - right: 1em; -} - -/** Tooltips - ******************************************************************************/ - -.tooltip { - width: 100%; -} - -/** States - ******************************************************************************/ - -/* "disabled" for non-buttons */ - -.is-disabled { - background-color: #dbdbdb; - border-color: #dbdbdb; - box-shadow: none; - color: #7a7a7a; - opacity: 0.5; - cursor: not-allowed; -} - -/* Book preview table - ******************************************************************************/ - -.book-preview td { - vertical-align: middle; -} - -@media only screen and (max-width: 768px) { - table.is-mobile, - table.is-mobile tbody { - display: block; - } - - table.is-mobile tr { - display: flex; - flex-wrap: wrap; - justify-content: space-between; - border-top: 1px solid #dbdbdb; - } - - table.is-mobile td { - display: block; - box-sizing: border-box; - flex: 1 0 100%; - order: 2; - border-bottom: 0; - } - - table.is-mobile td.book-preview-top-row { - order: 1; - flex-basis: auto; - } - - table.is-mobile td[data-title]:not(:empty)::before { - content: attr(data-title); - display: block; - font-size: 0.75em; - font-weight: bold; - } - - table.is-mobile td:empty { - padding: 0; - } - - table.is-mobile th, - table.is-mobile thead { - display: none; - } -} - -/* Book list - ******************************************************************************/ - -ol.ordered-list { - list-style: none; - counter-reset: list-counter; -} - -ol.ordered-list li { - counter-increment: list-counter; -} - -ol.ordered-list li::before { - content: counter(list-counter); - position: absolute; - left: -20px; - width: 20px; - height: 24px; - background-color: #fff; - border: 1px solid #dbdbdb; - border-right: 0; - border-top-left-radius: 2px; - border-top-right-radius: 2px; - display: flex; - justify-content: center; - align-items: center; - color: #888; - font-size: 0.8em; - font-weight: bold; -} - -@media only screen and (max-width: 768px) { - ol.ordered-list li::before { - left: 0; - z-index: 1; - border: 0; - border-right: 1px solid #dbdbdb; - border-bottom: 1px solid #dbdbdb; - border-radius: 0; - border-bottom-right-radius: 2px; - } -} - -.overflow-wrap-anywhere { - overflow-wrap: anywhere; - min-width: 10em; -} - -/* Threads - ******************************************************************************/ - -.thread .is-main .card { - box-shadow: 0 0.5em 1em -0.125em rgb(50 115 220 / 35%), 0 0 0 1px rgb(50 115 220 / 2%); -} - -.thread::after { - content: ""; - position: absolute; - z-index: -1; - top: 0; - bottom: 0; - left: 2.5em; - border-left: 2px solid #e0e0e0; -} - -/* Breadcrumbs - ******************************************************************************/ - -.breadcrumb li:first-child * { - padding-left: 0; -} - -.breadcrumb li > * { - align-items: center; - display: flex; - justify-content: center; - padding: 0 0.75em; -} - -/* Notifications page - ******************************************************************************/ - -.notification a.icon { - text-decoration: none !important; -} - -/* Breadcrumbs - ******************************************************************************/ - -.books-grid { - display: grid; - grid-template-columns: repeat(2, 1fr); - gap: 1rem; - align-items: end; - justify-items: stretch; -} - -.books-grid > .is-big { - grid-column: span 2; - grid-row: span 2; - justify-self: stretch; -} - -.books-grid .book-cover { - width: 100%; -} - -.books-grid .book-title { - --height-basis: 1.35rem; - - display: block; - margin-top: 0.5rem; - line-height: var(--height-basis); - min-height: calc(2 * var(--height-basis)); -} - -@media only screen and (min-width: 769px) { - .books-grid { - gap: 1.5rem; - grid-template-columns: repeat(auto-fill, minmax(8em, 1fr)); - } -} - -/* Copy - ******************************************************************************/ - -.horizontal-copy { - display: flex; - flex-direction: row; - align-items: center; - gap: 0.75rem; -} - -.horizontal-copy textarea { - min-width: initial; - white-space: nowrap; -} - -.horizontal-copy button { - align-self: stretch; - height: unset; -} - -.vertical-copy { - display: flex; - flex-direction: column; - align-items: stretch; - gap: 0.75rem; -} - -.vertical-copy button { - width: 100%; -} - -/* Dimensions - * @todo These could be in rem. - ******************************************************************************/ - -.is-32x32 { - min-width: 32px !important; - min-height: 32px !important; -} - -.is-96x96 { - min-width: 96px !important; - min-height: 96px !important; -} - -.is-w-auto { - width: auto !important; -} - -.is-w-xs { - width: 80px !important; -} - -.is-w-s { - width: 100px !important; -} - -.is-w-m { - width: 150px !important; -} - -.is-w-l { - width: 200px !important; -} - -.is-w-xl { - width: 250px !important; -} - -.is-w-xxl { - width: 500px !important; -} - -.is-h-xs { - height: 80px !important; -} - -.is-h-s { - height: 100px !important; -} - -.is-h-m { - height: 150px !important; -} - -.is-h-l { - height: 200px !important; -} - -.is-h-xl { - height: 250px !important; -} - -.is-h-xxl { - height: 500px !important; -} - -@media only screen and (max-width: 768px) { - .is-w-auto-mobile { - width: auto !important; - } - - .is-w-xs-mobile { - width: 80px !important; - } - - .is-w-s-mobile { - width: 100px !important; - } - - .is-w-m-mobile { - width: 150px !important; - } - - .is-w-l-mobile { - width: 200px !important; - } - - .is-w-xl-mobile { - width: 250px !important; - } - - .is-w-xxl-mobile { - width: 500px !important; - } - - .is-h-xs-mobile { - height: 80px !important; - } - - .is-h-s-mobile { - height: 100px !important; - } - - .is-h-m-mobile { - height: 150px !important; - } - - .is-h-l-mobile { - height: 200px !important; - } - - .is-h-xl-mobile { - height: 250px !important; - } - - .is-h-xxl-mobile { - height: 500px !important; - } -} - -@media only screen and (min-width: 769px) { - .is-w-auto-tablet { - width: auto !important; - } - - .is-w-xs-tablet { - width: 80px !important; - } - - .is-w-s-tablet { - width: 100px !important; - } - - .is-w-m-tablet { - width: 150px !important; - } - - .is-w-l-tablet { - width: 200px !important; - } - - .is-w-xl-tablet { - width: 250px !important; - } - - .is-w-xxl-tablet { - width: 500px !important; - } - - .is-h-xs-tablet { - height: 80px !important; - } - - .is-h-s-tablet { - height: 100px !important; - } - - .is-h-m-tablet { - height: 150px !important; - } - - .is-h-l-tablet { - height: 200px !important; - } - - .is-h-xl-tablet { - height: 250px !important; - } - - .is-h-xxl-tablet { - height: 500px !important; - } -} - -@media only screen and (min-width: 1024px) { - .is-w-auto-desktop { - width: auto !important; - } - - .is-w-xs-desktop { - width: 80px !important; - } - - .is-w-s-desktop { - width: 100px !important; - } - - .is-w-m-desktop { - width: 150px !important; - } - - .is-w-l-desktop { - width: 200px !important; - } - - .is-w-xl-desktop { - width: 250px !important; - } - - .is-w-xxl-desktop { - width: 500px !important; - } - - .is-h-xs-desktop { - height: 80px !important; - } - - .is-h-s-desktop { - height: 100px !important; - } - - .is-h-m-desktop { - height: 150px !important; - } - - .is-h-l-desktop { - height: 200px !important; - } - - .is-h-xl-desktop { - height: 250px !important; - } - - .is-h-xxl-desktop { - height: 500px !important; - } -} - -/* Alignments - * - * Use them with `.align.to-(c|t|r|b|l)[-(mobile|tablet)]` - ******************************************************************************/ - -/* Flex item position - * -------------------------------------------------------------------------- */ - -.align { - display: flex !important; - flex-direction: row !important; -} - -.align.to-c { - justify-content: center !important; -} - -.align.to-t { - align-items: flex-start !important; -} - -.align.to-r { - justify-content: flex-end !important; -} - -.align.to-b { - align-items: flex-end !important; -} - -.align.to-l { - justify-content: flex-start !important; -} - -@media screen and (max-width: 768px) { - .align.to-c-mobile { - justify-content: center !important; - } - - .align.to-t-mobile { - align-items: flex-start !important; - } - - .align.to-r-mobile { - justify-content: flex-end !important; - } - - .align.to-b-mobile { - align-items: flex-end !important; - } - - .align.to-l-mobile { - justify-content: flex-start !important; - } -} - -@media screen and (min-width: 769px) { - .align.to-c-tablet { - justify-content: center !important; - } - - .align.to-t-tablet { - align-items: flex-start !important; - } - - .align.to-r-tablet { - justify-content: flex-end !important; - } - - .align.to-b-tablet { - align-items: flex-end !important; - } - - .align.to-l-tablet { - justify-content: flex-start !important; - } -} - -/* Spacings - * - * Those are supplementary rules to Bulma’s. They follow the same conventions. - * Add those you’ll need. - ******************************************************************************/ - -.mr-auto { - margin-right: auto !important; -} - -.ml-auto { - margin-left: auto !important; -} - -@media screen and (max-width: 768px) { - .m-0-mobile { - margin: 0 !important; - } - - .mr-auto-mobile { - margin-right: auto !important; - } - - .ml-auto-mobile { - margin-left: auto !important; - } - - .mt-3-mobile { - margin-top: 0.75rem !important; - } - - .ml-3-mobile { - margin-left: 0.75rem !important; - } - - .mx-3-mobile { - margin-right: 0.75rem !important; - margin-left: 0.75rem !important; - } - - .my-3-mobile { - margin-top: 0.75rem !important; - margin-bottom: 0.75rem !important; - } -} - -@media screen and (min-width: 769px) { - .m-0-tablet { - margin: 0 !important; - } - - .mr-auto-tablet { - margin-right: auto !important; - } - - .ml-auto-tablet { - margin-left: auto !important; - } - - .mt-3-tablet { - margin-top: 0.75rem !important; - } - - .ml-3-tablet { - margin-left: 0.75rem !important; - } - - .mx-3-tablet { - margin-right: 0.75rem !important; - margin-left: 0.75rem !important; - } - - .my-3-tablet { - margin-top: 0.75rem !important; - margin-bottom: 0.75rem !important; - } -} - -/* Gaps (for Flexbox and Grid) - * - * Those are supplementary rules to Bulma’s. They follow the same conventions. - * Add those you’ll need. - ******************************************************************************/ - -.is-gap-0 { - gap: 0; -} - -.is-gap-1 { - gap: 0.25rem; -} - -.is-gap-2 { - gap: 0.5rem; -} - -.is-gap-3 { - gap: 0.75rem; -} - -.is-gap-4 { - gap: 1rem; -} - -.is-gap-5 { - gap: 1.5rem; -} - -.is-gap-6 { - gap: 3rem; -} - -.is-row-gap-0 { - row-gap: 0; -} - -.is-row-gap-1 { - row-gap: 0.25rem; -} - -.is-row-gap-2 { - row-gap: 0.5rem; -} - -.is-row-gap-3 { - row-gap: 0.75rem; -} - -.is-row-gap-4 { - row-gap: 1rem; -} - -.is-row-gap-5 { - row-gap: 1.5rem; -} - -.is-row-gap-6 { - row-gap: 3rem; -} - -.is-column-gap-0 { - column-gap: 0; -} - -.is-column-gap-1 { - column-gap: 0.25rem; -} - -.is-column-gap-2 { - column-gap: 0.5rem; -} - -.is-column-gap-3 { - column-gap: 0.75rem; -} - -.is-column-gap-4 { - column-gap: 1rem; -} - -.is-column-gap-5 { - column-gap: 1.5rem; -} - -.is-column-gap-6 { - column-gap: 3rem; -} - -/* Barcode scanner CSS */ -#barcode-scanner { - position: relative; - min-height: 200px; -} - -#barcode-scanner .drawingBuffer { - position: absolute; - top: 0; - left: 0; - height: auto; - width: 100%; -} diff --git a/bookwyrm/static/css/bookwyrm/_all.scss b/bookwyrm/static/css/bookwyrm/_all.scss index 11d7e403..e9333bd1 100644 --- a/bookwyrm/static/css/bookwyrm/_all.scss +++ b/bookwyrm/static/css/bookwyrm/_all.scss @@ -1,6 +1,7 @@ /** Imports ******************************************************************************/ @import "components/avatar"; +@import "components/barcode"; @import "components/book_cover"; @import "components/book_grid"; @import "components/book_list"; diff --git a/bookwyrm/static/css/bookwyrm/components/_barcode.scss b/bookwyrm/static/css/bookwyrm/components/_barcode.scss new file mode 100644 index 00000000..da1aa721 --- /dev/null +++ b/bookwyrm/static/css/bookwyrm/components/_barcode.scss @@ -0,0 +1,14 @@ + +/* Barcode scanner CSS */ +#barcode-scanner { + position: relative; + min-height: 200px; + + .drawingBuffer { + position: absolute; + top: 0; + left: 0; + height: auto; + width: 100%; + } +} From 649ffe571a96b0bb25249cc846fd8468ea73661a Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sat, 26 Feb 2022 18:29:38 -0800 Subject: [PATCH 06/24] Fix typos with searching --- bookwyrm/static/js/bookwyrm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index 10032c55..d7ba9ffe 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -689,7 +689,7 @@ let BookWyrm = new (class { statusNode.querySelector('.isbn').innerText = code; toggleStatus('found'); - const search = new Url('search'); + const search = new URL('/search', document.location); search.searchParams.set('q', code); cleanup(); From 8d0e5494808137d8763ee3f001c629de5c07ffb7 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sat, 26 Feb 2022 20:19:26 -0800 Subject: [PATCH 07/24] Improve visuals and quality of scanning --- .../css/bookwyrm/components/_barcode.scss | 10 +++++++++ bookwyrm/static/js/bookwyrm.js | 22 +++++++++++-------- bookwyrm/templates/search/barcode_modal.html | 4 ++-- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/bookwyrm/static/css/bookwyrm/components/_barcode.scss b/bookwyrm/static/css/bookwyrm/components/_barcode.scss index da1aa721..1abbf5d4 100644 --- a/bookwyrm/static/css/bookwyrm/components/_barcode.scss +++ b/bookwyrm/static/css/bookwyrm/components/_barcode.scss @@ -12,3 +12,13 @@ width: 100%; } } + +#barcode-status { + :dir(ltr) .select { + float: right; + } + + :dir(rtl) .select { + float: left; + } +} diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index d7ba9ffe..4944ada6 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -655,10 +655,13 @@ let BookWyrm = new (class { } } - function cleanup() { + function cleanup(clearDrawing = true) { Quagga.stop(); - scannerNode.replaceChildren(); cameraListNode.removeEventListener('change', changeListener); + + if (clearDrawing) { + scannerNode.replaceChildren(); + } } Quagga.onProcessed((result) => { @@ -683,7 +686,14 @@ let BookWyrm = new (class { } }); + let lastDetection = null; Quagga.onDetected((result) => { + // Detect the same code twice as an extra check to avoid bogus scans. + if (lastDetection === null || lastDetection !== result.codeResult.code) { + lastDetection = result.codeResult.code; + return; + } + const code = result.codeResult.code; statusNode.querySelector('.isbn').innerText = code; @@ -692,7 +702,7 @@ let BookWyrm = new (class { const search = new URL('/search', document.location); search.searchParams.set('q', code); - cleanup(); + cleanup(false); location.assign(search); }); @@ -711,12 +721,6 @@ let BookWyrm = new (class { constraints: { facingMode: "environment", }, - area: { - top: "25%", - right: "25%", - left: "25%", - bottom: "25%", - } }, decoder : { readers: [ diff --git a/bookwyrm/templates/search/barcode_modal.html b/bookwyrm/templates/search/barcode_modal.html index 17eb8829..00cc7c02 100644 --- a/bookwyrm/templates/search/barcode_modal.html +++ b/bookwyrm/templates/search/barcode_modal.html @@ -12,7 +12,7 @@
@@ -25,7 +25,7 @@ {% trans "Align your book's barcode with the camera." %}
From fee6ffcbd858b0a54bdadc236d17c448d78a5ba8 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sat, 26 Feb 2022 21:29:18 -0800 Subject: [PATCH 08/24] Fix formatting in chrome Was using experimental selector, forget about it. Also reduce jumping around of video size --- .../static/css/bookwyrm/components/_barcode.scss | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/bookwyrm/static/css/bookwyrm/components/_barcode.scss b/bookwyrm/static/css/bookwyrm/components/_barcode.scss index 1abbf5d4..c12d59ea 100644 --- a/bookwyrm/static/css/bookwyrm/components/_barcode.scss +++ b/bookwyrm/static/css/bookwyrm/components/_barcode.scss @@ -2,7 +2,7 @@ /* Barcode scanner CSS */ #barcode-scanner { position: relative; - min-height: 200px; + min-height: 450px; .drawingBuffer { position: absolute; @@ -13,12 +13,6 @@ } } -#barcode-status { - :dir(ltr) .select { - float: right; - } - - :dir(rtl) .select { - float: left; - } +#barcode-status .select { + float: right; } From 464050deaa4911bca518a43ee3568df296c257ad Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sat, 26 Feb 2022 21:32:01 -0800 Subject: [PATCH 09/24] Implement switching cameras Also, use session storage to remember last selected camera deviceId, if any --- bookwyrm/static/js/bookwyrm.js | 119 +++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 52 deletions(-) diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index 4944ada6..0ae95044 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -645,8 +645,7 @@ let BookWyrm = new (class { const cameraListNode = document.getElementById("barcode-camera-list"); let changeListener = cameraListNode.addEventListener('change', (event) => { - // TODO - //event.target.value + initBarcodes(event.target.value); }); function toggleStatus(status) { @@ -655,6 +654,71 @@ let BookWyrm = new (class { } } + function initBarcodes(cameraId = null) { + if (!cameraId) { + cameraId = sessionStorage.getItem('preferredCam'); + } else { + sessionStorage.setItem('preferredCam', cameraId); + } + + scannerNode.replaceChildren(); + Quagga.stop(); + Quagga.init({ + inputStream : { + name: "Live", + type: "LiveStream", + target: scannerNode, + constraints: { + facingMode: "environment", + deviceId: cameraId, + }, + }, + decoder : { + readers: [ + "ean_reader", + { + format: "ean_reader", + config: { + supplements: [ "ean_2_reader", "ean_5_reader" ] + } + } + ], + multiple: false + }, + }, (err) => { + if (err) { + console.log(err); + toggleStatus('access-denied'); + return; + } + + let activeId = null; + const track = Quagga.CameraAccess.getActiveTrack(); + if (track) { + activeId = track.getSettings().deviceId; + } + + Quagga.CameraAccess.enumerateVideoDevices().then((devices) => { + cameraListNode.replaceChildren(); + + for (const device of devices) { + const child = document.createElement('option'); + child.value = device.deviceId; + child.innerText = device.label.slice(0, 30); + + if (activeId === child.value) { + child.selected = true; + } + + cameraListNode.appendChild(child); + } + }); + + toggleStatus('scanning'); + Quagga.start(); + }); + } + function cleanup(clearDrawing = true) { Quagga.stop(); cameraListNode.removeEventListener('change', changeListener); @@ -709,55 +773,6 @@ let BookWyrm = new (class { event.target.addEventListener('close', cleanup, { once: true }); toggleStatus('grant-access'); - - // Clear camera list - cameraListNode.replaceChildren(); - - Quagga.init({ - inputStream : { - name: "Live", - type: "LiveStream", - target: scannerNode, - constraints: { - facingMode: "environment", - }, - }, - decoder : { - readers: [ - "ean_reader", - { - format: "ean_reader", - config: { - supplements: [ "ean_2_reader", "ean_5_reader" ] - } - } - ], - multiple: false - }, - }, (err) => { - if (err) { - console.log(err); - toggleStatus('access-denied'); - return; - } - - const stream = Quagga.CameraAccess.getActiveStreamLabel(); - Quagga.CameraAccess.enumerateVideoDevices().then((devices) => { - for (const device of devices) { - const child = document.createElement('option'); - child.value = device.deviceId || device.id; - child.innerText = device.label.slice(0, 30); - - if (stream === child.value) { - child.selected = true; - } - - cameraListNode.appendChild(child); - } - }); - - Quagga.start(); - toggleStatus('scanning'); - }); + initBarcodes(); } })(); From cdddf73e29ea23b72ab988b57dae1647cef8d1b8 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sat, 26 Feb 2022 23:22:44 -0800 Subject: [PATCH 10/24] Improve layout for some camera types --- .../static/css/bookwyrm/components/_barcode.scss | 14 +++++++++++--- bookwyrm/static/js/bookwyrm.js | 6 +++++- bookwyrm/templates/search/barcode_modal.html | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bookwyrm/static/css/bookwyrm/components/_barcode.scss b/bookwyrm/static/css/bookwyrm/components/_barcode.scss index c12d59ea..b6b41697 100644 --- a/bookwyrm/static/css/bookwyrm/components/_barcode.scss +++ b/bookwyrm/static/css/bookwyrm/components/_barcode.scss @@ -2,14 +2,22 @@ /* Barcode scanner CSS */ #barcode-scanner { position: relative; - min-height: 450px; + max-width: 100%; + text-align: center; + + video { + height: calc(70vh - 200px); + max-width: 100%; + } .drawingBuffer { position: absolute; top: 0; left: 0; - height: auto; - width: 100%; + right: 0; + margin: auto; + height: calc(70vh - 200px); + max-width: 100%; } } diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index 0ae95044..f6811614 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -751,11 +751,15 @@ let BookWyrm = new (class { }); let lastDetection = null; + let numDetected = 0; Quagga.onDetected((result) => { - // Detect the same code twice as an extra check to avoid bogus scans. + // Detect the same code 3 times as an extra check to avoid bogus scans. if (lastDetection === null || lastDetection !== result.codeResult.code) { + numDetected = 1; lastDetection = result.codeResult.code; return; + } else if (numDetected++ < 3) { + return; } const code = result.codeResult.code; diff --git a/bookwyrm/templates/search/barcode_modal.html b/bookwyrm/templates/search/barcode_modal.html index 00cc7c02..93789ae3 100644 --- a/bookwyrm/templates/search/barcode_modal.html +++ b/bookwyrm/templates/search/barcode_modal.html @@ -8,7 +8,7 @@ {% endblock %} {% block modal-body %} -
+
+
{% endblock %} From e71a5e3bdfe6a4077ddcbbffcf392f09519c44bc Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sun, 27 Feb 2022 00:00:22 -0800 Subject: [PATCH 13/24] Add barcode icon and use other icons Minor formatting and messaging tweaks --- .../css/bookwyrm/components/_barcode.scss | 1 + bookwyrm/static/css/fonts/icomoon.eot | Bin 10460 -> 10688 bytes bookwyrm/static/css/fonts/icomoon.svg | 1 + bookwyrm/static/css/fonts/icomoon.ttf | Bin 10296 -> 10524 bytes bookwyrm/static/css/fonts/icomoon.woff | Bin 10372 -> 10600 bytes bookwyrm/static/css/vendor/icons.css | 3 +++ bookwyrm/static/js/bookwyrm.js | 1 + bookwyrm/templates/search/barcode_modal.html | 9 ++++++++- 8 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bookwyrm/static/css/bookwyrm/components/_barcode.scss b/bookwyrm/static/css/bookwyrm/components/_barcode.scss index b6b41697..8c77d525 100644 --- a/bookwyrm/static/css/bookwyrm/components/_barcode.scss +++ b/bookwyrm/static/css/bookwyrm/components/_barcode.scss @@ -4,6 +4,7 @@ position: relative; max-width: 100%; text-align: center; + height: calc(70vh - 200px); video { height: calc(70vh - 200px); diff --git a/bookwyrm/static/css/fonts/icomoon.eot b/bookwyrm/static/css/fonts/icomoon.eot index 7b1f2d9d9f9d3ff8805e56d83c6c2ceba7654a8f..69628662beb9b527fe62d38c0d177366773ad879 100644 GIT binary patch delta 613 zcmaKoPe>F|9LK+J->74Ia7Wu2YZrHP++8IsVq<5avIp5E5{wKz1U0DbB90EYko^JY zw5JGUPTdv?jJgEVDI%tGm+BITcCuhOqEud-Ol^n<>*oP{Al;j@Eoal-oCR2#_-WZ%b;uLMugK-{(!=`~-j|k%-vYy> z%7QhY*=@MZS3KitIWCA&zc(`I$*ItfyUnQO(ez&wTX9Z6_-yr@&e8;xd9E_ih z(Z}-BRM3|#d*S)@?!Uw|l+~P-)hak87->W~IREO+v&XliWA)R)IAk#BVKUT1Gkg@* z!mYg%d&TB{vl(?!f>3KG-wzYk{Gmx2SAVK+)VeyQ4kmxoB<6h@IptrAU1pLoG-UWS zo*7uDe}|C31#Rd;96jiRh7>X|kjELELjfi(;tJ4LP>iEuZH}CiBJU_94YRE*d8B;X z;ktnkt`PKQXxYI`pzHLox~@0strF!-{8!+*2P7``-I#m4sN={2{1=0Yluk`9mhbjl z`h~dEx~(0tedykotjWeaIp=kN(vnxtX`Y{(O7$mRD<_o+#ZjIq-+JZVG#E9F#ZDvP I59B|xf82kgdjJ3c delta 369 zcmX>Qd?%3Yjs^pRg~miSGnPQzr#B}$l-C&V3Yy!ThbGY z3xKo$kiP&(bEM}~rs-XX-vQ*WU|>*A$Vg30kr$E&s#oOz%9~{X1vt1_%z%6cAYUaT zx1?f$9j7ypp917>$jMJm+`ntbGzJDW5gp$3c?M?Y3zJhAtF<$LJTaidm>Jj@7#S2^ioR5MS@p8*<*ip- zugw1c{r?}N2Pn?)QhYKWlQ`!pvH4>DVhW;PCmS$HZ}w%fWn@uOR#w{F$1E?mxmAgu zMds#H-N1N$o39MqEMUENujbAHF+lX>4Ql3$I+I_hO`cq@o}pwXutMO5Ad8@qV4C0@ e!3{t~j6kfzB*g#<1qKEthKUX$n`Jc?GXemcjbGRR diff --git a/bookwyrm/static/css/fonts/icomoon.svg b/bookwyrm/static/css/fonts/icomoon.svg index 7dbbe0dc..c67c8b22 100644 --- a/bookwyrm/static/css/fonts/icomoon.svg +++ b/bookwyrm/static/css/fonts/icomoon.svg @@ -39,6 +39,7 @@ + diff --git a/bookwyrm/static/css/fonts/icomoon.ttf b/bookwyrm/static/css/fonts/icomoon.ttf index 151f2b782e011873be7120240fc65777f3771917..12c79d551739bdbfe9e7246ae713b4d23545fdce 100644 GIT binary patch delta 595 zcmaJU9_nZ0RBhqb_2X~G7O7tX17r1h zXRfr-ZUE*6^P_bdskCANgF5v<-EFKq8Sg$#JxTp)VQKc16W)Dymc}m{)2_4PVO-+R zDwnDCMaP|gc&7U|H9soWyrty^8)Xc&lRRYk{e$pMKIy8LeaT319zDuOdSnIX#r}#F z-Hz6xkDGfpN8_zHhKRowl!B~%(_UyzZAvTWf3ivh<)K3Bv6v8w(cf>hzDT8ms~i)y z0@>z)F0Lqp917?|2?i=Sgb`F>;RGgtTvau8Lv(b)GLi6}YTmFqFv$rj9ft3Rw(Z+C z-vT?deI?X&KBB4X?dFcfys-Zw^!;r@wzquA|36rP2y=Hw5g6^;pf zwm<#j;IL_l;b6`T1cLA8&2n$gb9J9Ose0;t^+Pt5Epo}guyi1~3Ji(s%e8{Rr{WLv CgOqUq delta 367 zcmbOev?HLNfsuiMft#U$ftkU;KUm+0Ux?iRD6$8L6OwZi3ofsnxQ2m&Q3l9wNlz>; z0MY_L{sJJ)k)BhTrgtHJ2avylfk8PTBQ-HaUPvCOUX=qVZy_F6zyJR;F#dlm&LYk%wn}Win7^2U=vSb6#>o>I#W$~Hv}I&bQdU;l{EA6lZu3J$ zeioUVPjv(1`E9;3aI=6cWVm}ZcMgo6%%f(`s599`Z8D?9p+9LIa$+?LI3=E7JK&c)OUY@%= zB0aGfB=!Z!=YV2?^qk5xpx7S<1{DhsHrZv7myw#7!oZ+r0#suL!tyWvlw<$}fnqs8 zz6uC)aI=_a zCYij%+*F|00ifk=AUxBH^LIghaS6~z9&mNcKo&Fe#mPL3)uBKW7$g`37?^>MXJk-# zDf&|3rTNRMmu)X^z2bUh_W$qy|3DQ$8(uQJ6o<-Ohs!Yje=N=-&Mfv;Y_-?|u>dhe z(QiPL7-39C) zX3%FaW-w>4X0T^q5H=Q6M#hX#K8R)pVi3)0EUIh{#i~FWgw>%mLqo#>2Zsg+2O!DF z0H*$hA5c&LBE|&@3V#-Wg@E#m4iJ2xq2V78GduikU~0gRfjW=?1H)!-ML`xBY2U2$ zcz&C&4BRZ>5WDAa2To6}P&H@NoxDMHG9$xe2eoWP34v9DB7!c01%iEomxMTkWEdEM ViglT!fKdSgOrRj#d|z!TBLME8r#Aoq delta 413 zcmaD6)DkFC?(gQtz{mgu8Z8XmVA^7Gpr-glZIOC|0tal-PM@DL53Il^`2vCg~2+Iq}ugL%k0>yfOd=(Jp z;ASz)$StV=ifsV$!FYikr*lqzGEkkLS^`io3WWFX+A%FRu>xqZ+8!WZ0gO$VWbzVo zQ-NZ4fR?v`@Juhx-v#-_B|zT*Er+UO2C|r$FHGiPtQH1&MT|j!fti5~=xc?SqAwLD z&ta5Qu6o(_^7<>TS7!hJ{{PRw`2Vpui#W5`DzW)u{$dKEUxDfwL7}qwE2AwVi;}Xk z(q=PedAZHHO8hJ`H=pVT#`D{JW#DE3n$Ey*_iFAO7(F>c&74tZ@&vWXlhxHT6zv37 n2;2~45mXXP6PzOm@-HJ0>o7@y!;*o4Y4Srx;mwEDmofqX)LCPK diff --git a/bookwyrm/static/css/vendor/icons.css b/bookwyrm/static/css/vendor/icons.css index 4bc7cca5..6477aee5 100644 --- a/bookwyrm/static/css/vendor/icons.css +++ b/bookwyrm/static/css/vendor/icons.css @@ -149,3 +149,6 @@ .icon-download:before { content: "\ea36"; } +.icon-barcode:before { + content: "\e937"; +} diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index f6811614..efd5cfff 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -687,6 +687,7 @@ let BookWyrm = new (class { }, }, (err) => { if (err) { + scannerNode.replaceChildren(); console.log(err); toggleStatus('access-denied'); return; diff --git a/bookwyrm/templates/search/barcode_modal.html b/bookwyrm/templates/search/barcode_modal.html index 9480197f..3f7b01ce 100644 --- a/bookwyrm/templates/search/barcode_modal.html +++ b/bookwyrm/templates/search/barcode_modal.html @@ -12,19 +12,26 @@
- + From 9f67a74340737a902ffcb6317e03535196804402 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sun, 27 Feb 2022 00:04:25 -0800 Subject: [PATCH 14/24] Show grant access dialog every time we initialize --- bookwyrm/static/js/bookwyrm.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index efd5cfff..01c13091 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -655,6 +655,8 @@ let BookWyrm = new (class { } function initBarcodes(cameraId = null) { + toggleStatus('grant-access'); + if (!cameraId) { cameraId = sessionStorage.getItem('preferredCam'); } else { @@ -777,7 +779,6 @@ let BookWyrm = new (class { event.target.addEventListener('close', cleanup, { once: true }); - toggleStatus('grant-access'); initBarcodes(); } })(); From 43f62ef5d7add5d3a4fc8bc146ea5ed15693812e Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sun, 27 Feb 2022 00:18:38 -0800 Subject: [PATCH 15/24] d'oh, fix event leak --- bookwyrm/static/js/bookwyrm.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index 01c13091..39d5f664 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -644,9 +644,11 @@ let BookWyrm = new (class { const statusNode = document.getElementById("barcode-status"); const cameraListNode = document.getElementById("barcode-camera-list"); - let changeListener = cameraListNode.addEventListener('change', (event) => { + cameraListNode.addEventListener('change', onChangeCamera); + + function onChangeCamera(event) { initBarcodes(event.target.value); - }); + } function toggleStatus(status) { for (const child of statusNode.children) { @@ -724,7 +726,7 @@ let BookWyrm = new (class { function cleanup(clearDrawing = true) { Quagga.stop(); - cameraListNode.removeEventListener('change', changeListener); + cameraListNode.removeEventListener('change', onChangeCamera); if (clearDrawing) { scannerNode.replaceChildren(); From f5c66b5b4a9e983426a1ebf2389697224c965df3 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sun, 27 Feb 2022 00:33:54 -0800 Subject: [PATCH 16/24] Adjust layout more Ensure camera select box is never hidden. --- .../static/css/bookwyrm/components/_barcode.scss | 2 +- bookwyrm/static/js/bookwyrm.js | 2 +- bookwyrm/templates/search/barcode_modal.html | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bookwyrm/static/css/bookwyrm/components/_barcode.scss b/bookwyrm/static/css/bookwyrm/components/_barcode.scss index 8c77d525..c000a1a8 100644 --- a/bookwyrm/static/css/bookwyrm/components/_barcode.scss +++ b/bookwyrm/static/css/bookwyrm/components/_barcode.scss @@ -22,6 +22,6 @@ } } -#barcode-status .select { +#barcode-camera-list { float: right; } diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index 39d5f664..a9cc5c6c 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -642,7 +642,7 @@ let BookWyrm = new (class { openBarcodeScanner(event) { const scannerNode = document.getElementById("barcode-scanner"); const statusNode = document.getElementById("barcode-status"); - const cameraListNode = document.getElementById("barcode-camera-list"); + const cameraListNode = document.querySelector("#barcode-camera-list > select"); cameraListNode.addEventListener('change', onChangeCamera); diff --git a/bookwyrm/templates/search/barcode_modal.html b/bookwyrm/templates/search/barcode_modal.html index 3f7b01ce..cfbb4e1c 100644 --- a/bookwyrm/templates/search/barcode_modal.html +++ b/bookwyrm/templates/search/barcode_modal.html @@ -8,9 +8,17 @@ {% endblock %} {% block modal-body %} -
+
+
+
+ +
+ +
+
-