@uziee/document-scanner 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -6
- package/dist/index.es.js +713 -538
- package/dist/index.umd.js +11 -11
- package/dist/style.css +1 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(B,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],D):(B=typeof globalThis<"u"?globalThis:B||self,D(B.DocumentScanner={},B.React))})(this,function(B,D){"use strict";var ie={exports:{}},q={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var xe;function Ve(){if(xe)return q;xe=1;var O=D,i=Symbol.for("react.element"),n=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,c=O.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,x={key:!0,ref:!0,__self:!0,__source:!0};function u(f,a,b){var s,h={},p=null,g=null;b!==void 0&&(p=""+b),a.key!==void 0&&(p=""+a.key),a.ref!==void 0&&(g=a.ref);for(s in a)l.call(a,s)&&!x.hasOwnProperty(s)&&(h[s]=a[s]);if(f&&f.defaultProps)for(s in a=f.defaultProps,a)h[s]===void 0&&(h[s]=a[s]);return{$$typeof:i,type:f,key:p,ref:g,props:h,_owner:c.current}}return q.Fragment=n,q.jsx=u,q.jsxs=u,q}var Z={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var be;function Ue(){return be||(be=1,{}.NODE_ENV!=="production"&&function(){var O=D,i=Symbol.for("react.element"),n=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),f=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),s=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),w=Symbol.iterator,M="@@iterator";function S(e){if(e===null||typeof e!="object")return null;var r=w&&e[w]||e[M];return typeof r=="function"?r:null}var v=O.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function d(e){{for(var r=arguments.length,o=new Array(r>1?r-1:0),m=1;m<r;m++)o[m-1]=arguments[m];C("error",e,o)}}function C(e,r,o){{var m=v.ReactDebugCurrentFrame,R=m.getStackAddendum();R!==""&&(r+="%s",o=o.concat([R]));var E=o.map(function(j){return String(j)});E.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,E)}}var P=!1,N=!1,z=!1,L=!1,Y=!1,V;V=Symbol.for("react.module.reference");function le(e){return!!(typeof e=="string"||typeof e=="function"||e===l||e===x||Y||e===c||e===b||e===s||L||e===g||P||N||z||typeof e=="object"&&e!==null&&(e.$$typeof===p||e.$$typeof===h||e.$$typeof===u||e.$$typeof===f||e.$$typeof===a||e.$$typeof===V||e.getModuleId!==void 0))}function U(e,r,o){var m=e.displayName;if(m)return m;var R=r.displayName||r.name||"";return R!==""?o+"("+R+")":o}function H(e){return e.displayName||"Context"}function T(e){if(e==null)return null;if(typeof e.tag=="number"&&d("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case l:return"Fragment";case n:return"Portal";case x:return"Profiler";case c:return"StrictMode";case b:return"Suspense";case s:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case f:var r=e;return H(r)+".Consumer";case u:var o=e;return H(o._context)+".Provider";case a:return U(e,e.render,"ForwardRef");case h:var m=e.displayName||null;return m!==null?m:T(e.type)||"Memo";case p:{var R=e,E=R._payload,j=R._init;try{return T(j(E))}catch{return null}}}return null}var I=Object.assign,$=0,re,J,K,we,Ee,Se,_e;function ke(){}ke.__reactDisabledLog=!0;function Xe(){{if($===0){re=console.log,J=console.info,K=console.warn,we=console.error,Ee=console.group,Se=console.groupCollapsed,_e=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ke,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}$++}}function Qe(){{if($--,$===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},e,{value:re}),info:I({},e,{value:J}),warn:I({},e,{value:K}),error:I({},e,{value:we}),group:I({},e,{value:Ee}),groupCollapsed:I({},e,{value:Se}),groupEnd:I({},e,{value:_e})})}$<0&&d("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=v.ReactCurrentDispatcher,ue;function ne(e,r,o){{if(ue===void 0)try{throw Error()}catch(R){var m=R.stack.trim().match(/\n( *(at )?)/);ue=m&&m[1]||""}return`
|
|
18
|
+
`+ue+e}}var fe=!1,oe;{var qe=typeof WeakMap=="function"?WeakMap:Map;oe=new qe}function Te(e,r){if(!e||fe)return"";{var o=oe.get(e);if(o!==void 0)return o}var m;fe=!0;var R=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var E;E=ce.current,ce.current=null,Xe();try{if(r){var j=function(){throw Error()};if(Object.defineProperty(j.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(j,[])}catch(A){m=A}Reflect.construct(e,[],j)}else{try{j.call()}catch(A){m=A}e.call(j.prototype)}}else{try{throw Error()}catch(A){m=A}e()}}catch(A){if(A&&m&&typeof A.stack=="string"){for(var y=A.stack.split(`
|
|
19
|
+
`),F=m.stack.split(`
|
|
20
|
+
`),_=y.length-1,k=F.length-1;_>=1&&k>=0&&y[_]!==F[k];)k--;for(;_>=1&&k>=0;_--,k--)if(y[_]!==F[k]){if(_!==1||k!==1)do if(_--,k--,k<0||y[_]!==F[k]){var W=`
|
|
21
|
+
`+y[_].replace(" at new "," at ");return e.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",e.displayName)),typeof e=="function"&&oe.set(e,W),W}while(_>=1&&k>=0);break}}}finally{fe=!1,ce.current=E,Qe(),Error.prepareStackTrace=R}var Q=e?e.displayName||e.name:"",G=Q?ne(Q):"";return typeof e=="function"&&oe.set(e,G),G}function Ze(e,r,o){return Te(e,!1)}function et(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function ae(e,r,o){if(e==null)return"";if(typeof e=="function")return Te(e,et(e));if(typeof e=="string")return ne(e);switch(e){case b:return ne("Suspense");case s:return ne("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case a:return Ze(e.render);case h:return ae(e.type,r,o);case p:{var m=e,R=m._payload,E=m._init;try{return ae(E(R),r,o)}catch{}}}return""}var ee=Object.prototype.hasOwnProperty,De={},Oe=v.ReactDebugCurrentFrame;function se(e){if(e){var r=e._owner,o=ae(e.type,e._source,r?r.type:null);Oe.setExtraStackFrame(o)}else Oe.setExtraStackFrame(null)}function tt(e,r,o,m,R){{var E=Function.call.bind(ee);for(var j in e)if(E(e,j)){var y=void 0;try{if(typeof e[j]!="function"){var F=Error((m||"React class")+": "+o+" type `"+j+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[j]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw F.name="Invariant Violation",F}y=e[j](r,j,m,o,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(_){y=_}y&&!(y instanceof Error)&&(se(R),d("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",m||"React class",o,j,typeof y),se(null)),y instanceof Error&&!(y.message in De)&&(De[y.message]=!0,se(R),d("Failed %s type: %s",o,y.message),se(null))}}}var rt=Array.isArray;function de(e){return rt(e)}function nt(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,o=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return o}}function ot(e){try{return Me(e),!1}catch{return!0}}function Me(e){return""+e}function Pe(e){if(ot(e))return d("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",nt(e)),Me(e)}var te=v.ReactCurrentOwner,at={key:!0,ref:!0,__self:!0,__source:!0},Ie,Fe,he;he={};function st(e){if(ee.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function it(e){if(ee.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function lt(e,r){if(typeof e.ref=="string"&&te.current&&r&&te.current.stateNode!==r){var o=T(te.current.type);he[o]||(d('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',T(te.current.type),e.ref),he[o]=!0)}}function ct(e,r){{var o=function(){Ie||(Ie=!0,d("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};o.isReactWarning=!0,Object.defineProperty(e,"key",{get:o,configurable:!0})}}function ut(e,r){{var o=function(){Fe||(Fe=!0,d("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};o.isReactWarning=!0,Object.defineProperty(e,"ref",{get:o,configurable:!0})}}var ft=function(e,r,o,m,R,E,j){var y={$$typeof:i,type:e,key:r,ref:o,props:j,_owner:E};return y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(y,"_self",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.defineProperty(y,"_source",{configurable:!1,enumerable:!1,writable:!1,value:R}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y};function dt(e,r,o,m,R){{var E,j={},y=null,F=null;o!==void 0&&(Pe(o),y=""+o),it(r)&&(Pe(r.key),y=""+r.key),st(r)&&(F=r.ref,lt(r,R));for(E in r)ee.call(r,E)&&!at.hasOwnProperty(E)&&(j[E]=r[E]);if(e&&e.defaultProps){var _=e.defaultProps;for(E in _)j[E]===void 0&&(j[E]=_[E])}if(y||F){var k=typeof e=="function"?e.displayName||e.name||"Unknown":e;y&&ct(j,k),F&&ut(j,k)}return ft(e,y,F,R,m,te.current,j)}}var pe=v.ReactCurrentOwner,Ae=v.ReactDebugCurrentFrame;function X(e){if(e){var r=e._owner,o=ae(e.type,e._source,r?r.type:null);Ae.setExtraStackFrame(o)}else Ae.setExtraStackFrame(null)}var ve;ve=!1;function ge(e){return typeof e=="object"&&e!==null&&e.$$typeof===i}function Ne(){{if(pe.current){var e=T(pe.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function ht(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),o=e.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+
|
|
25
|
+
Check your code at `+r+":"+o+"."}return""}}var We={};function pt(e){{var r=Ne();if(!r){var o=typeof e=="string"?e:e.displayName||e.name;o&&(r=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+
|
|
27
|
+
Check the top-level render call using <`+o+">.")}return r}}function Le(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var o=pt(r);if(We[o])return;We[o]=!0;var m="";e&&e._owner&&e._owner!==pe.current&&(m=" It was passed a child from "+T(e._owner.type)+"."),X(e),d('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',o,m),X(null)}}function ze(e,r){{if(typeof e!="object")return;if(de(e))for(var o=0;o<e.length;o++){var m=e[o];ge(m)&&Le(m,r)}else if(ge(e))e._store&&(e._store.validated=!0);else if(e){var R=S(e);if(typeof R=="function"&&R!==e.entries)for(var E=R.call(e),j;!(j=E.next()).done;)ge(j.value)&&Le(j.value,r)}}}function vt(e){{var r=e.type;if(r==null||typeof r=="string")return;var o;if(typeof r=="function")o=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===a||r.$$typeof===h))o=r.propTypes;else return;if(o){var m=T(r);tt(o,e.props,"prop",m,e)}else if(r.PropTypes!==void 0&&!ve){ve=!0;var R=T(r);d("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",R||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&d("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function gt(e){{for(var r=Object.keys(e.props),o=0;o<r.length;o++){var m=r[o];if(m!=="children"&&m!=="key"){X(e),d("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",m),X(null);break}}e.ref!==null&&(X(e),d("Invalid attribute `ref` supplied to `React.Fragment`."),X(null))}}var Ye={};function Be(e,r,o,m,R,E){{var j=le(e);if(!j){var y="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var F=ht(R);F?y+=F:y+=Ne();var _;e===null?_="null":de(e)?_="array":e!==void 0&&e.$$typeof===i?(_="<"+(T(e.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):_=typeof e,d("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",_,y)}var k=dt(e,r,o,R,E);if(k==null)return k;if(j){var W=r.children;if(W!==void 0)if(m)if(de(W)){for(var Q=0;Q<W.length;Q++)ze(W[Q],e);Object.freeze&&Object.freeze(W)}else d("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ze(W,e)}if(ee.call(r,"key")){var G=T(e),A=Object.keys(r).filter(function(Ct){return Ct!=="key"}),me=A.length>0?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}";if(!Ye[G+me]){var jt=A.length>0?"{"+A.join(": ..., ")+": ...}":"{}";d(`A props object containing a "key" prop is being spread into JSX:
|
|
28
28
|
let props = %s;
|
|
29
29
|
<%s {...props} />
|
|
30
30
|
React keys must be passed directly to JSX without using spread:
|
|
31
31
|
let props = %s;
|
|
32
|
-
<%s key={someKey} {...props} />`,ge,K,pt,K),Ye[K+ge]=!0}}return e===a?ut(w):ct(w),w}}function ft(e,t,n){return Ue(e,t,n,!0)}function dt(e,t,n){return Ue(e,t,n,!1)}var ht=dt,vt=ft;Z.Fragment=a,Z.jsx=ht,Z.jsxs=vt}()),Z}({}).NODE_ENV==="production"?se.exports=Le():se.exports=ze();var j=se.exports;class Ve{constructor(){this.procCanvas=document.createElement("canvas"),this.procCtx=this.procCanvas.getContext("2d",{willReadFrequently:!0}),this.smoothCorners=null,this.missCount=0}detect(r,o=.18){const a=Math.floor(r.videoWidth*o),c=Math.floor(r.videoHeight*o);if(!a||!c)return null;this.procCanvas.width=a,this.procCanvas.height=c,this.procCtx.drawImage(r,0,0,a,c);const u=this.procCtx.getImageData(0,0,a,c).data,{brightness:l,saturation:i,avgBright:b,isTexturedBackground:s}=this.analyzeImage(u,a,c),p=this.createPaperMask(u,l,i,a,c,b,s);this.cleanMask(p,a,c,s);const m=this.findLargestBlob(p,a,c);if(!m||m.size<a*c*.06)return this.handleMiss();const d=this.findRegionCorners(m.pixels,a,c);if(!d)return this.handleMiss();if(!this.validateQuad(d,a,c))return this.handleMiss();const _={tl:[d.tl[0]/o,d.tl[1]/o],tr:[d.tr[0]/o,d.tr[1]/o],br:[d.br[0]/o,d.br[1]/o],bl:[d.bl[0]/o,d.bl[1]/o]};return this.missCount=0,this.smooth(_)}analyzeImage(r,o,a){const c=new Float32Array(o*a),g=new Float32Array(o*a);let u=0,l=0;for(let p=0,m=0;p<r.length;p+=4,m++){const d=r[p],_=r[p+1],P=r[p+2],y=(d+_+P)/3;c[m]=y,u+=y,y>150&&l++;const v=Math.max(d,_,P),f=Math.min(d,_,P);g[m]=v>0?(v-f)/v:0}const i=u/(o*a),s=l/(o*a)>.5||i>160;return{brightness:c,saturation:g,avgBright:i,isTexturedBackground:s}}createPaperMask(r,o,a,c,g,u,l){const i=new Uint8Array(c*g),b=l?this.calcLocalVariance(o,c,g):null;let s;l?s=u+15:s=Math.max(120,u);const p=.3,m=l?400:9999;for(let d=0;d<c*g;d++){const _=o[d],P=a[d];if(_<s||P>p)continue;const y=d*4,v=r[y],f=r[y+1],C=r[y+2];Math.abs(v-f)+Math.abs(f-C)+Math.abs(v-C)>80||l&&b&&b[d]>m||(i[d]=1)}return i}calcLocalVariance(r,o,a){const c=new Float32Array(o*a),u=Math.floor(3/2);for(let l=u;l<a-u;l++)for(let i=u;i<o-u;i++){let b=0,s=0,p=0;for(let d=-u;d<=u;d++)for(let _=-u;_<=u;_++){const P=r[(l+d)*o+(i+_)];b+=P,s+=P*P,p++}const m=b/p;c[l*o+i]=s/p-m*m}return c}cleanMask(r,o,a,c){const g=c?2:1;for(let u=0;u<g;u++){const l=new Uint8Array(o*a);for(let i=1;i<a-1;i++)for(let b=1;b<o-1;b++){const s=i*o+b;r[s]&&r[s-1]&&r[s+1]&&r[s-o]&&r[s+o]&&(l[s]=1)}for(let i=0;i<o*a;i++)r[i]=l[i]}for(let u=0;u<g;u++){const l=new Uint8Array(o*a);for(let i=1;i<a-1;i++)for(let b=1;b<o-1;b++){const s=i*o+b;(r[s]||r[s-1]||r[s+1]||r[s-o]||r[s+o])&&(l[s]=1)}for(let i=0;i<o*a;i++)r[i]=l[i]}}findLargestBlob(r,o,a){const c=new Uint8Array(o*a);let g=null,u=0;for(let l=0;l<a;l++)for(let i=0;i<o;i++){const b=l*o+i;if(!r[b]||c[b])continue;const s=new Set,p=[[i,l]];for(;p.length>0;){const[m,d]=p.pop();if(m<0||m>=o||d<0||d>=a)continue;const _=d*o+m;c[_]||!r[_]||(c[_]=1,s.add(_),p.push([m-1,d],[m+1,d],[m,d-1],[m,d+1]))}s.size>u&&(u=s.size,g={pixels:s,size:s.size})}return g}findRegionCorners(r,o,a){let c=0,g=0;for(const y of r){const v=y%o,f=Math.floor(y/o);c+=v,g+=f}const u=c/r.size,l=g/r.size;let i=null,b=1/0,s=null,p=-1/0,m=null,d=-1/0,_=null,P=-1/0;for(const y of r){const v=y%o,f=Math.floor(y/o);if(v<=u&&f<=l){const C=v+f;C<b&&(b=C,i=[v,f])}if(v>=u&&f<=l){const C=v-f;C>p&&(p=C,s=[v,f])}if(v>=u&&f>=l){const C=v+f;C>d&&(d=C,m=[v,f])}if(v<=u&&f>=l){const C=f-v;C>P&&(P=C,_=[v,f])}}return!i||!s||!m||!_?null:{tl:i,tr:s,br:m,bl:_}}validateQuad(r,o,a){const{tl:c,tr:g,br:u,bl:l}=r;for(const y of[c,g,u,l])if(!y||y[0]<0||y[0]>=o||y[1]<0||y[1]>=a)return!1;if(c[0]>=g[0]-5||l[0]>=u[0]-5||c[1]>=l[1]-5||g[1]>=u[1]-5)return!1;const i=Math.hypot(g[0]-c[0],g[1]-c[1]),b=Math.hypot(u[0]-l[0],u[1]-l[1]),s=Math.hypot(l[0]-c[0],l[1]-c[1]),p=Math.hypot(u[0]-g[0],u[1]-g[1]),m=(i+b)/2,d=(s+p)/2;if(m<10||d<10)return!1;const _=m/d;return!(_<.3||_>3.5||i/b>2.5||b/i>2.5||s/p>2.5||p/s>2.5||.5*Math.abs((g[0]-l[0])*(c[1]-u[1])-(c[0]-u[0])*(g[1]-l[1]))<o*a*.05)}smooth(r){if(!this.smoothCorners)return this.smoothCorners=r,r;if(this.cornerDistance(this.smoothCorners,r)>50)return this.smoothCorners=r,r;const a=.35;return this.smoothCorners={tl:this.lerp(this.smoothCorners.tl,r.tl,a),tr:this.lerp(this.smoothCorners.tr,r.tr,a),br:this.lerp(this.smoothCorners.br,r.br,a),bl:this.lerp(this.smoothCorners.bl,r.bl,a)},this.smoothCorners}cornerDistance(r,o){let a=0;for(const c of["tl","tr","br","bl"]){const g=r[c][0]-o[c][0],u=r[c][1]-o[c][1];a+=Math.sqrt(g*g+u*u)}return a/4}lerp(r,o,a){return[r[0]+a*(o[0]-r[0]),r[1]+a*(o[1]-r[1])]}handleMiss(){return this.missCount++,this.missCount<8&&this.smoothCorners?this.smoothCorners:null}reset(){this.smoothCorners=null,this.missCount=0}}const me=({onCapture:M})=>{const r=D.useRef(null),o=D.useRef(null),[a,c]=D.useState(!1),[g,u]=D.useState(null),[l,i]=D.useState([]),b=D.useRef(null),s=D.useRef(null),p=D.useRef(0);D.useEffect(()=>{b.current||(b.current=new Ve);let y=null;async function v(){try{const C=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment",width:{ideal:1920}}});r.current&&(r.current.srcObject=C,r.current.play(),y=requestAnimationFrame(f))}catch(C){console.error("Camera access error:",C)}}function f(){var C;if(((C=r.current)==null?void 0:C.readyState)>=2){const I=r.current,U=o.current;if(!U)return;const W=U.getContext("2d");U.width!==I.videoWidth&&(U.width=I.videoWidth,U.height=I.videoHeight),W.drawImage(I,0,0);const L=b.current.detect(I,.18);L?(s.current&&m(L,s.current)?p.current=Math.min(15,p.current+1):p.current=0,s.current=L,p.current>5&&(c(!0),u(L))):(p.current=Math.max(0,p.current-2),p.current===0&&(s.current=null,c(!1),u(null)))}y=requestAnimationFrame(f)}return v(),()=>{cancelAnimationFrame(y),b.current&&b.current.reset()}},[]);const m=(y,v)=>Math.abs(y.tl[0]-v.tl[0])+Math.abs(y.tl[1]-v.tl[1])<50,d=()=>{const y=r.current,v=s.current;if(!y||!v)return;const f=1240,C=1754,I=document.createElement("canvas");I.width=f,I.height=C;const U=I.getContext("2d"),W=document.createElement("canvas");W.width=y.videoWidth,W.height=y.videoHeight,W.getContext("2d").drawImage(y,0,0);const L=W.getContext("2d").getImageData(0,0,W.width,W.height),B=U.createImageData(f,C);for(let N=0;N<C;N++)for(let $=0;$<f;$++){const Y=$/f,O=N/C,z=Math.floor((1-Y)*(1-O)*v.tl[0]+Y*(1-O)*v.tr[0]+(1-Y)*O*v.bl[0]+Y*O*v.br[0]),H=Math.floor((1-Y)*(1-O)*v.tl[1]+Y*(1-O)*v.tr[1]+(1-Y)*O*v.bl[1]+Y*O*v.br[1]),J=(N*f+$)*4,X=(H*W.width+z)*4;B.data[J]=L.data[X],B.data[J+1]=L.data[X+1],B.data[J+2]=L.data[X+2],B.data[J+3]=255}U.putImageData(B,0,0);const re=I.toDataURL("image/jpeg",.92);i(N=>[...N,re])},_=()=>{l.length>0&&M(l)},P=()=>{if(!g||!r.current)return"";const y=r.current.videoWidth,v=r.current.videoHeight,f=C=>`${C[0]/y*100},${C[1]/v*100}`;return`${f(g.tl)} ${f(g.tr)} ${f(g.br)} ${f(g.bl)}`};return j.jsxs("div",{style:{position:"fixed",inset:0,backgroundColor:"#000",fontFamily:"system-ui, -apple-system, sans-serif",overflow:"hidden"},children:[j.jsx("video",{ref:r,style:{display:"none"},playsInline:!0,muted:!0}),j.jsx("canvas",{ref:o,style:{width:"100vw",height:"100vh",objectFit:"cover"}}),j.jsx("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10},children:g&&j.jsx("polygon",{points:P(),fill:"rgba(0, 255, 70, 0.15)",stroke:"#00FF46",strokeWidth:"0.5",style:{transition:"all 0.1s ease-out"}})}),j.jsx("div",{style:{position:"absolute",top:0,width:"100%",padding:"40px 0 20px",background:"linear-gradient(rgba(0,0,0,0.6), transparent)",textAlign:"center",zIndex:20},children:j.jsx("div",{style:{display:"inline-block",padding:"6px 16px",borderRadius:"20px",backgroundColor:a?"#00FF46":"rgba(255,255,255,0.2)",color:a?"#000":"#fff",fontSize:"12px",fontWeight:"bold"},children:a?"READY TO SCAN":"POSITION DOCUMENT"})}),j.jsxs("div",{style:{position:"absolute",bottom:0,width:"100%",height:"160px",background:"linear-gradient(transparent, rgba(0,0,0,0.8))",display:"flex",alignItems:"center",justifyContent:"space-around",zIndex:20},children:[j.jsxs("div",{onClick:_,style:{width:"64px",height:"64px",position:"relative",cursor:l.length>0?"pointer":"default",opacity:l.length>0?1:.4,transition:"transform 0.2s"},onMouseDown:y=>l.length>0&&(y.currentTarget.style.transform="scale(0.9)"),onMouseUp:y=>y.currentTarget.style.transform="scale(1)",children:[l.length>0?j.jsxs(j.Fragment,{children:[j.jsx("img",{src:l[l.length-1],style:{width:"100%",height:"100%",objectFit:"cover",border:"2px solid #fff",borderRadius:"4px"},alt:"preview"}),j.jsx("div",{style:{position:"absolute",top:"-8px",right:"-8px",background:"#00FF46",color:"#000",width:"22px",height:"22px",borderRadius:"50%",fontSize:"12px",fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid #000"},children:l.length})]}):j.jsx("div",{style:{width:"100%",height:"100%",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.1)",border:"1px dashed #555"}}),j.jsx("span",{style:{fontSize:"10px",display:"block",textAlign:"center",marginTop:"4px",color:"#fff"},children:"DONE"})]}),j.jsx("button",{onClick:d,disabled:!a,style:{width:"84px",height:"84px",borderRadius:"50%",border:`4px solid ${a?"#00FF46":"#555"}`,backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:j.jsx("div",{style:{width:"68px",height:"68px",borderRadius:"50%",backgroundColor:a?"#fff":"#444"}})}),j.jsx("div",{style:{width:"64px"}})]})]})};function Ne(){const[M,r]=D.useState(null);return j.jsxs("div",{style:{textAlign:"center",padding:"20px",fontFamily:"sans-serif"},children:[j.jsx("h1",{children:"JS Doc Scanner"}),M?j.jsxs("div",{children:[j.jsx("h3",{children:"Scanned Result:"}),M==null?void 0:M.map((o,a)=>j.jsx("img",{src:o,style:{width:"100%",maxWidth:"400px",border:"2px solid #ccc",margin:"10px"}},a)),j.jsx("br",{}),j.jsx("button",{onClick:()=>r(null),children:"Scan Again"})]}):j.jsx(me,{onCapture:o=>r(o)})]})}V.App=Ne,V.DocumentScanner=me,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
|
|
32
|
+
<%s key={someKey} {...props} />`,me,G,jt,G),Ye[G+me]=!0}}return e===l?gt(k):vt(k),k}}function mt(e,r,o){return Be(e,r,o,!0)}function xt(e,r,o){return Be(e,r,o,!1)}var bt=xt,yt=mt;Z.Fragment=l,Z.jsx=bt,Z.jsxs=yt}()),Z}({}).NODE_ENV==="production"?ie.exports=Ve():ie.exports=Ue();var t=ie.exports;class He{constructor(){this.procCanvas=document.createElement("canvas"),this.procCtx=this.procCanvas.getContext("2d",{willReadFrequently:!0}),this.smoothCorners=null,this.missCount=0}detect(i,n=.18){const l=Math.floor(i.videoWidth*n),c=Math.floor(i.videoHeight*n);if(!l||!c)return null;this.procCanvas.width=l,this.procCanvas.height=c,this.procCtx.drawImage(i,0,0,l,c);const u=this.procCtx.getImageData(0,0,l,c).data,{brightness:f,saturation:a,avgBright:b,isTexturedBackground:s}=this.analyzeImage(u,l,c),h=this.createPaperMask(u,f,a,l,c,b,s);this.cleanMask(h,l,c,s);const p=this.findLargestBlob(h,l,c);if(!p||p.size<l*c*.06)return this.handleMiss();const g=this.findRegionCorners(p.pixels,l,c);if(!g)return this.handleMiss();if(!this.validateQuad(g,l,c))return this.handleMiss();const w={tl:[g.tl[0]/n,g.tl[1]/n],tr:[g.tr[0]/n,g.tr[1]/n],br:[g.br[0]/n,g.br[1]/n],bl:[g.bl[0]/n,g.bl[1]/n]};return this.missCount=0,this.smooth(w)}analyzeImage(i,n,l){const c=new Float32Array(n*l),x=new Float32Array(n*l);let u=0,f=0;for(let h=0,p=0;h<i.length;h+=4,p++){const g=i[h],w=i[h+1],M=i[h+2],S=(g+w+M)/3;c[p]=S,u+=S,S>150&&f++;const v=Math.max(g,w,M),d=Math.min(g,w,M);x[p]=v>0?(v-d)/v:0}const a=u/(n*l),s=f/(n*l)>.5||a>160;return{brightness:c,saturation:x,avgBright:a,isTexturedBackground:s}}createPaperMask(i,n,l,c,x,u,f){const a=new Uint8Array(c*x),b=f?this.calcLocalVariance(n,c,x):null;let s;f?s=u+15:s=Math.max(120,u);const h=.3,p=f?400:9999;for(let g=0;g<c*x;g++){const w=n[g],M=l[g];if(w<s||M>h)continue;const S=g*4,v=i[S],d=i[S+1],C=i[S+2];Math.abs(v-d)+Math.abs(d-C)+Math.abs(v-C)>80||f&&b&&b[g]>p||(a[g]=1)}return a}calcLocalVariance(i,n,l){const c=new Float32Array(n*l),u=Math.floor(3/2);for(let f=u;f<l-u;f++)for(let a=u;a<n-u;a++){let b=0,s=0,h=0;for(let g=-u;g<=u;g++)for(let w=-u;w<=u;w++){const M=i[(f+g)*n+(a+w)];b+=M,s+=M*M,h++}const p=b/h;c[f*n+a]=s/h-p*p}return c}cleanMask(i,n,l,c){const x=c?2:1;for(let u=0;u<x;u++){const f=new Uint8Array(n*l);for(let a=1;a<l-1;a++)for(let b=1;b<n-1;b++){const s=a*n+b;i[s]&&i[s-1]&&i[s+1]&&i[s-n]&&i[s+n]&&(f[s]=1)}for(let a=0;a<n*l;a++)i[a]=f[a]}for(let u=0;u<x;u++){const f=new Uint8Array(n*l);for(let a=1;a<l-1;a++)for(let b=1;b<n-1;b++){const s=a*n+b;(i[s]||i[s-1]||i[s+1]||i[s-n]||i[s+n])&&(f[s]=1)}for(let a=0;a<n*l;a++)i[a]=f[a]}}findLargestBlob(i,n,l){const c=new Uint8Array(n*l);let x=null,u=0;for(let f=0;f<l;f++)for(let a=0;a<n;a++){const b=f*n+a;if(!i[b]||c[b])continue;const s=new Set,h=[[a,f]];for(;h.length>0;){const[p,g]=h.pop();if(p<0||p>=n||g<0||g>=l)continue;const w=g*n+p;c[w]||!i[w]||(c[w]=1,s.add(w),h.push([p-1,g],[p+1,g],[p,g-1],[p,g+1]))}s.size>u&&(u=s.size,x={pixels:s,size:s.size})}return x}findRegionCorners(i,n,l){let c=0,x=0;for(const S of i){const v=S%n,d=Math.floor(S/n);c+=v,x+=d}const u=c/i.size,f=x/i.size;let a=null,b=1/0,s=null,h=-1/0,p=null,g=-1/0,w=null,M=-1/0;for(const S of i){const v=S%n,d=Math.floor(S/n);if(v<=u&&d<=f){const C=v+d;C<b&&(b=C,a=[v,d])}if(v>=u&&d<=f){const C=v-d;C>h&&(h=C,s=[v,d])}if(v>=u&&d>=f){const C=v+d;C>g&&(g=C,p=[v,d])}if(v<=u&&d>=f){const C=d-v;C>M&&(M=C,w=[v,d])}}return!a||!s||!p||!w?null:{tl:a,tr:s,br:p,bl:w}}validateQuad(i,n,l){const{tl:c,tr:x,br:u,bl:f}=i;for(const S of[c,x,u,f])if(!S||S[0]<0||S[0]>=n||S[1]<0||S[1]>=l)return!1;if(c[0]>=x[0]-5||f[0]>=u[0]-5||c[1]>=f[1]-5||x[1]>=u[1]-5)return!1;const a=Math.hypot(x[0]-c[0],x[1]-c[1]),b=Math.hypot(u[0]-f[0],u[1]-f[1]),s=Math.hypot(f[0]-c[0],f[1]-c[1]),h=Math.hypot(u[0]-x[0],u[1]-x[1]),p=(a+b)/2,g=(s+h)/2;if(p<10||g<10)return!1;const w=p/g;return!(w<.3||w>3.5||a/b>2.5||b/a>2.5||s/h>2.5||h/s>2.5||.5*Math.abs((x[0]-f[0])*(c[1]-u[1])-(c[0]-u[0])*(x[1]-f[1]))<n*l*.05)}smooth(i){if(!this.smoothCorners)return this.smoothCorners=i,i;if(this.cornerDistance(this.smoothCorners,i)>50)return this.smoothCorners=i,i;const l=.35;return this.smoothCorners={tl:this.lerp(this.smoothCorners.tl,i.tl,l),tr:this.lerp(this.smoothCorners.tr,i.tr,l),br:this.lerp(this.smoothCorners.br,i.br,l),bl:this.lerp(this.smoothCorners.bl,i.bl,l)},this.smoothCorners}cornerDistance(i,n){let l=0;for(const c of["tl","tr","br","bl"]){const x=i[c][0]-n[c][0],u=i[c][1]-n[c][1];l+=Math.sqrt(x*x+u*u)}return l/4}lerp(i,n,l){return[i[0]+l*(n[0]-i[0]),i[1]+l*(n[1]-i[1])]}handleMiss(){return this.missCount++,this.missCount<8&&this.smoothCorners?this.smoothCorners:null}reset(){this.smoothCorners=null,this.missCount=0}}const ye=({onCapture:O,onClose:i})=>{const n=D.useRef(null),l=D.useRef(null),[c,x]=D.useState(!1),[u,f]=D.useState(null),[a,b]=D.useState([]),s=D.useRef(null),h=D.useRef(null),p=D.useRef(0);D.useEffect(()=>{s.current||(s.current=new He);let v=null;async function d(){try{const P=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment",width:{ideal:1920}}});n.current&&(n.current.srcObject=P,n.current.play(),v=requestAnimationFrame(C))}catch(P){console.error("Camera access error:",P)}}function C(){var P;if(((P=n.current)==null?void 0:P.readyState)>=2){const N=n.current,z=l.current;if(!z)return;const L=z.getContext("2d");z.width!==N.videoWidth&&(z.width=N.videoWidth,z.height=N.videoHeight),L.drawImage(N,0,0);const Y=s.current.detect(N,.18);Y?(h.current&&g(Y,h.current)?p.current=Math.min(15,p.current+1):p.current=0,h.current=Y,p.current>5&&(x(!0),f(Y))):(p.current=Math.max(0,p.current-2),p.current===0&&(h.current=null,x(!1),f(null)))}v=requestAnimationFrame(C)}return d(),()=>{cancelAnimationFrame(v),s.current&&s.current.reset()}},[]);const g=(v,d)=>Math.abs(v.tl[0]-d.tl[0])+Math.abs(v.tl[1]-d.tl[1])<50,w=()=>{const v=n.current,d=h.current;if(!v||!d)return;const C=1240,P=1754,N=document.createElement("canvas");N.width=C,N.height=P;const z=N.getContext("2d"),L=document.createElement("canvas");L.width=v.videoWidth,L.height=v.videoHeight,L.getContext("2d").drawImage(v,0,0);const Y=L.getContext("2d").getImageData(0,0,L.width,L.height),V=z.createImageData(C,P);for(let U=0;U<P;U++)for(let H=0;H<C;H++){const T=H/C,I=U/P,$=Math.floor((1-T)*(1-I)*d.tl[0]+T*(1-I)*d.tr[0]+(1-T)*I*d.bl[0]+T*I*d.br[0]),re=Math.floor((1-T)*(1-I)*d.tl[1]+T*(1-I)*d.tr[1]+(1-T)*I*d.bl[1]+T*I*d.br[1]),J=(U*C+H)*4,K=(re*L.width+$)*4;V.data[J]=Y.data[K],V.data[J+1]=Y.data[K+1],V.data[J+2]=Y.data[K+2],V.data[J+3]=255}z.putImageData(V,0,0);const le=N.toDataURL("image/jpeg",.92);b(U=>[...U,le])},M=()=>{a.length>0&&O(a)},S=()=>{if(!u||!n.current)return"";const v=n.current.videoWidth,d=n.current.videoHeight,C=P=>`${P[0]/v*100},${P[1]/d*100}`;return`${C(u.tl)} ${C(u.tr)} ${C(u.br)} ${C(u.bl)}`};return t.jsxs("div",{style:{position:"fixed",inset:0,backgroundColor:"#000",fontFamily:"system-ui, -apple-system, sans-serif",overflow:"hidden"},children:[t.jsx("video",{ref:n,style:{display:"none"},playsInline:!0,muted:!0}),t.jsx("canvas",{ref:l,style:{width:"100vw",height:"100vh",objectFit:"cover"}}),t.jsx("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10},children:u&&t.jsx("polygon",{points:S(),fill:"rgba(0, 255, 70, 0.15)",stroke:"#00FF46",strokeWidth:"0.2",style:{transition:"all 0.1s ease-out"}})}),t.jsxs("div",{style:{position:"absolute",top:0,width:"100%",padding:"40px 16px 20px",background:"linear-gradient(rgba(0,0,0,0.6), transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:20},children:[i&&t.jsx("button",{onClick:i,style:{position:"absolute",right:"16px",top:"40px",width:"44px",height:"44px",borderRadius:"50%",border:"none",backgroundColor:"rgba(255,255,255,0.15)",backdropFilter:"blur(8px)",color:"#fff",fontSize:"20px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"},onMouseEnter:v=>v.currentTarget.style.backgroundColor="rgba(255,255,255,0.25)",onMouseLeave:v=>v.currentTarget.style.backgroundColor="rgba(255,255,255,0.15)",children:t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),t.jsx("div",{style:{display:"inline-block",padding:"6px 16px",borderRadius:"20px",backgroundColor:c?"#00FF46":"rgba(255,255,255,0.2)",color:c?"#000":"#fff",fontSize:"12px",fontWeight:"bold"},children:c?"READY TO SCAN":"POSITION DOCUMENT"})]}),t.jsxs("div",{style:{position:"absolute",bottom:0,width:"100%",height:"160px",background:"linear-gradient(transparent, rgba(0,0,0,0.8))",display:"flex",alignItems:"center",justifyContent:"space-around",zIndex:20},children:[t.jsxs("div",{onClick:M,style:{width:"64px",height:"64px",position:"relative",cursor:a.length>0?"pointer":"default",opacity:a.length>0?1:.4,transition:"transform 0.2s"},onMouseDown:v=>a.length>0&&(v.currentTarget.style.transform="scale(0.9)"),onMouseUp:v=>v.currentTarget.style.transform="scale(1)",children:[a.length>0?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:a[a.length-1],style:{width:"100%",height:"100%",objectFit:"cover",border:"2px solid #fff",borderRadius:"4px"},alt:"preview"}),t.jsx("div",{style:{position:"absolute",top:"-8px",right:"-8px",background:"#00FF46",color:"#000",width:"22px",height:"22px",borderRadius:"50%",fontSize:"12px",fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid #000"},children:a.length})]}):t.jsx("div",{style:{width:"100%",height:"100%",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.1)",border:"1px dashed #555"}}),t.jsx("span",{style:{fontSize:"10px",display:"block",textAlign:"center",marginTop:"4px",color:"#fff"},children:"DONE"})]}),t.jsx("button",{onClick:w,disabled:!c,style:{width:"84px",height:"84px",borderRadius:"50%",border:`4px solid ${c?"#00FF46":"#555"}`,backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("div",{style:{width:"68px",height:"68px",borderRadius:"50%",backgroundColor:c?"#fff":"#444"}})}),t.jsx("div",{style:{width:"64px"}})]})]})},Rt="",je=()=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),t.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),t.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),t.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"}),t.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1"})]}),Ce=()=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14,2 14,8 20,8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),t.jsx("polyline",{points:"10,9 9,9 8,9"})]}),$e=()=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})}),Je=()=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})}),Re=()=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),t.jsx("polyline",{points:"7 10 12 15 17 10"}),t.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),Ge=()=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("polyline",{points:"1 20 1 14 7 14"}),t.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]});function Ke(){const[O,i]=D.useState(null),[n,l]=D.useState(!1),c=s=>{i(s),l(!1)},x=()=>{l(!0)},u=()=>{i(null),l(!0)},f=(s,h)=>{const p=document.createElement("a");p.href=s,p.download=`scanned-document-${h+1}.jpg`,document.body.appendChild(p),p.click(),document.body.removeChild(p)},a=()=>{O==null||O.forEach((s,h)=>{setTimeout(()=>f(s,h),h*200)})},b=()=>{l(!1)};return n?t.jsx(ye,{onCapture:c,onClose:b}):t.jsxs("div",{className:"app-container",children:[t.jsx("header",{className:"header",children:t.jsxs("div",{className:"header-content",children:[t.jsxs("a",{href:"/",className:"logo",children:[t.jsx("div",{className:"logo-icon",children:t.jsx(je,{})}),t.jsx("span",{className:"logo-text",children:"DocScanner"})]}),t.jsx("span",{className:"header-badge",children:"✨ 100% Browser-based"})]})}),t.jsxs("main",{className:"main-content",children:[t.jsxs("section",{className:"hero-section",children:[t.jsx("h1",{className:"hero-title",children:O?"Your Scanned Documents":"Smart Document Scanner"}),t.jsx("p",{className:"hero-subtitle",children:O?`Successfully captured ${O.length} document${O.length>1?"s":""}`:"Capture, enhance, and digitize your documents with precision edge detection — all in your browser"})]}),O?t.jsxs("section",{className:"results-section",children:[t.jsxs("div",{className:"results-header",children:[t.jsxs("h2",{className:"results-title",children:[t.jsx(Ce,{}),t.jsx("span",{children:"Scanned Documents"}),t.jsx("span",{className:"results-count",children:O.length})]}),t.jsxs("div",{className:"results-actions",children:[t.jsxs("button",{className:"btn btn-secondary",onClick:a,children:[t.jsx(Re,{}),t.jsx("span",{children:"Download All"})]}),t.jsxs("button",{className:"btn btn-primary",onClick:u,children:[t.jsx(Ge,{}),t.jsx("span",{children:"Scan More"})]})]})]}),t.jsx("div",{className:"results-grid",children:O.map((s,h)=>t.jsxs("article",{className:"result-card animate-fade-in",style:{animationDelay:`${h*.1}s`},children:[t.jsxs("span",{className:"result-card-number",children:["#",h+1]}),t.jsx("img",{src:s,alt:`Scanned document ${h+1}`,className:"result-card-image"}),t.jsx("div",{className:"result-card-overlay"}),t.jsx("div",{className:"result-card-actions",children:t.jsx("button",{className:"btn btn-icon",onClick:p=>{p.stopPropagation(),f(s,h)},title:"Download",children:t.jsx(Re,{})})})]},h))})]}):t.jsxs("section",{className:"empty-state animate-fade-in",children:[t.jsx("div",{className:"empty-state-icon",children:t.jsx(Ce,{})}),t.jsx("h3",{className:"empty-state-title",children:"No Documents Scanned Yet"}),t.jsx("p",{className:"empty-state-text",children:"Start scanning to capture and enhance your documents instantly"}),t.jsxs("button",{className:"btn btn-primary",onClick:x,children:[t.jsx(je,{})," Start Scanning"]})]})]}),t.jsx("footer",{className:"footer",children:t.jsxs("div",{className:"footer-content",children:[t.jsxs("div",{className:"footer-links",children:[t.jsxs("a",{href:"https://github.com/uzair2244/document-scanner",target:"_blank",rel:"noopener noreferrer",className:"footer-link",children:[t.jsx($e,{}),t.jsx("span",{children:"View on GitHub"})]}),t.jsxs("a",{href:"https://www.linkedin.com/in/muhammad-uzair-shahid-rao/",target:"_blank",rel:"noopener noreferrer",className:"footer-link",children:[t.jsx(Je,{}),t.jsx("span",{children:"Connect on LinkedIn"})]})]}),t.jsxs("p",{className:"footer-text",children:["Built with ❤️ by"," ",t.jsx("a",{href:"https://www.linkedin.com/in/muhammad-uzair-shahid-rao/",target:"_blank",rel:"noopener noreferrer",children:"Muhammad Uzair Shahid Rao"})," ","• © ",new Date().getFullYear()," DocScanner"]})]})})]})}B.App=Ke,B.DocumentScanner=ye,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap";:root{--bg-primary: #0a0a0f;--bg-secondary: #12121a;--bg-card: #1a1a24;--bg-card-hover: #22222e;--accent-primary: #6366f1;--accent-secondary: #818cf8;--accent-glow: rgba(99, 102, 241, .4);--success: #10b981;--success-glow: rgba(16, 185, 129, .3);--text-primary: #f8fafc;--text-secondary: #94a3b8;--text-muted: #64748b;--border-color: rgba(255, 255, 255, .08);--border-glow: rgba(99, 102, 241, .3);--gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);--gradient-dark: linear-gradient(180deg, #0a0a0f 0%, #12121a 100%);--gradient-card: linear-gradient(145deg, rgba(26, 26, 36, .9) 0%, rgba(18, 18, 26, .9) 100%);--font-primary: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;--font-display: "Space Grotesk", sans-serif;--spacing-xs: .25rem;--spacing-sm: .5rem;--spacing-md: 1rem;--spacing-lg: 1.5rem;--spacing-xl: 2rem;--spacing-2xl: 3rem;--radius-sm: 8px;--radius-md: 12px;--radius-lg: 16px;--radius-xl: 24px;--transition-fast: .15s ease;--transition-normal: .25s ease;--transition-slow: .4s ease;--shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);--shadow-md: 0 4px 20px rgba(0, 0, 0, .4);--shadow-lg: 0 8px 40px rgba(0, 0, 0, .5);--shadow-glow: 0 0 40px var(--accent-glow)}*,*:before,*:after{margin:0;padding:0;box-sizing:border-box}html{font-size:16px;scroll-behavior:smooth}body{font-family:var(--font-primary);background:var(--bg-primary);color:var(--text-primary);line-height:1.6;min-height:100vh;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#root{min-height:100vh;display:flex;flex-direction:column}.app-container{min-height:100vh;display:flex;flex-direction:column;background:var(--gradient-dark)}.header{position:sticky;top:0;z-index:100;padding:var(--spacing-md) var(--spacing-xl);background:rgba(10,10,15,.85);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);border-bottom:1px solid var(--border-color)}.header-content{max-width:1400px;margin:0 auto;display:flex;align-items:center;justify-content:space-between}.logo{display:flex;align-items:center;gap:var(--spacing-sm);text-decoration:none;transition:transform var(--transition-fast)}.logo:hover{transform:scale(1.02)}.logo-icon{width:42px;height:42px;display:flex;align-items:center;justify-content:center;background:var(--gradient-primary);border-radius:var(--radius-md);box-shadow:var(--shadow-glow)}.logo-icon svg{width:24px;height:24px;color:#fff}.logo-text{font-family:var(--font-display);font-size:1.5rem;font-weight:700;background:var(--gradient-primary);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}.header-badge{padding:var(--spacing-xs) var(--spacing-md);background:rgba(99,102,241,.1);border:1px solid var(--border-glow);border-radius:var(--radius-xl);font-size:.75rem;font-weight:500;color:var(--accent-secondary);letter-spacing:.5px}.main-content{flex:1;padding:var(--spacing-2xl) var(--spacing-xl);max-width:1400px;margin:0 auto;width:100%}.hero-section{text-align:center;margin-bottom:var(--spacing-2xl)}.hero-title{font-family:var(--font-display);font-size:2.5rem;font-weight:700;margin-bottom:var(--spacing-sm);background:linear-gradient(135deg,var(--text-primary) 0%,var(--text-secondary) 100%);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}.hero-subtitle{font-size:1.1rem;color:var(--text-secondary);max-width:500px;margin:0 auto}.results-section{margin-bottom:var(--spacing-2xl)}.results-header{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:var(--spacing-md);margin-bottom:var(--spacing-lg)}.results-title{display:flex;align-items:center;gap:var(--spacing-sm);font-size:1.25rem;font-weight:600;color:var(--text-primary)}.results-title svg{width:24px;height:24px;flex-shrink:0}.results-actions{display:flex;gap:var(--spacing-md);flex-wrap:wrap}.results-count{display:inline-flex;align-items:center;justify-content:center;min-width:28px;height:28px;padding:0 var(--spacing-sm);background:var(--gradient-primary);border-radius:var(--radius-xl);font-size:.85rem;font-weight:600}.results-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:var(--spacing-lg)}.result-card{position:relative;background:var(--gradient-card);border:1px solid var(--border-color);border-radius:var(--radius-lg);overflow:hidden;transition:all var(--transition-normal);cursor:pointer}.result-card:hover{transform:translateY(-4px);border-color:var(--border-glow);box-shadow:var(--shadow-lg),var(--shadow-glow)}.result-card-image{width:100%;aspect-ratio:3/4;object-fit:cover;display:block;transition:transform var(--transition-slow)}.result-card:hover .result-card-image{transform:scale(1.03)}.result-card-overlay{position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(180deg,transparent 60%,rgba(0,0,0,.8) 100%);opacity:0;transition:opacity var(--transition-normal)}.result-card:hover .result-card-overlay{opacity:1}.result-card-number{position:absolute;top:var(--spacing-md);left:var(--spacing-md);padding:var(--spacing-xs) var(--spacing-sm);background:rgba(0,0,0,.6);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:var(--radius-sm);font-size:.75rem;font-weight:600;color:var(--text-primary)}.result-card-actions{position:absolute;bottom:var(--spacing-md);right:var(--spacing-md);display:flex;gap:var(--spacing-sm);opacity:0;transform:translateY(8px);transition:all var(--transition-normal)}.result-card:hover .result-card-actions{opacity:1;transform:translateY(0)}.btn{display:inline-flex;align-items:center;justify-content:center;gap:var(--spacing-sm);padding:var(--spacing-md) var(--spacing-xl);font-family:var(--font-primary);font-size:.95rem;font-weight:500;border:none;border-radius:var(--radius-md);cursor:pointer;transition:all var(--transition-fast);text-decoration:none;white-space:nowrap}.btn svg{width:18px;height:18px;flex-shrink:0}.btn-primary{background:var(--gradient-primary);color:#fff;box-shadow:var(--shadow-md),0 0 20px var(--accent-glow)}.btn-primary:hover{transform:translateY(-2px);box-shadow:var(--shadow-lg),0 0 30px var(--accent-glow)}.btn-primary:active{transform:translateY(0)}.btn-secondary{background:var(--bg-card);color:var(--text-primary);border:1px solid var(--border-color)}.btn-secondary:hover{background:var(--bg-card-hover);border-color:var(--border-glow)}.btn-icon{width:40px;height:40px;padding:0;background:rgba(0,0,0,.5);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.1);border-radius:var(--radius-sm);color:#fff}.btn-icon svg{width:20px;height:20px}.btn-icon:hover{background:var(--accent-primary);border-color:var(--accent-primary)}.empty-state{text-align:center;padding:var(--spacing-2xl) var(--spacing-xl);background:var(--gradient-card);border:2px dashed var(--border-color);border-radius:var(--radius-xl)}.empty-state-icon{width:80px;height:80px;margin:0 auto var(--spacing-lg);display:flex;align-items:center;justify-content:center;background:rgba(99,102,241,.1);border-radius:50%;color:var(--accent-secondary)}.empty-state-icon svg{width:40px;height:40px}.empty-state-title{font-size:1.25rem;font-weight:600;color:var(--text-primary);margin-bottom:var(--spacing-sm)}.empty-state-text{color:var(--text-secondary);margin-bottom:var(--spacing-lg)}.footer{padding:var(--spacing-xl) var(--spacing-xl);background:var(--bg-secondary);border-top:1px solid var(--border-color)}.footer-content{max-width:1400px;margin:0 auto;display:flex;flex-direction:column;align-items:center;gap:var(--spacing-lg)}.footer-links{display:flex;gap:var(--spacing-lg)}.footer-link{display:flex;align-items:center;gap:var(--spacing-sm);padding:var(--spacing-sm) var(--spacing-md);background:var(--bg-card);border:1px solid var(--border-color);border-radius:var(--radius-md);color:var(--text-secondary);text-decoration:none;font-size:.9rem;font-weight:500;transition:all var(--transition-fast)}.footer-link:hover{background:var(--bg-card-hover);border-color:var(--border-glow);color:var(--text-primary);transform:translateY(-2px)}.footer-link svg{width:20px;height:20px}.footer-text{color:var(--text-muted);font-size:.85rem}.footer-text a{color:var(--accent-secondary);text-decoration:none;transition:color var(--transition-fast)}.footer-text a:hover{color:var(--accent-primary)}@keyframes fadeIn{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes pulse{0%,to{opacity:1}50%{opacity:.6}}@keyframes float{0%,to{transform:translateY(0)}50%{transform:translateY(-10px)}}.animate-fade-in{animation:fadeIn .5s ease forwards}.animate-pulse{animation:pulse 2s ease infinite}@media (max-width: 1024px){.results-header{flex-direction:column;align-items:flex-start}.results-actions{width:100%}.results-actions .btn{flex:1}}@media (max-width: 768px){.header{padding:var(--spacing-md)}.header-badge{display:none}.logo-text{font-size:1.25rem}.main-content{padding:var(--spacing-lg) var(--spacing-md)}.hero-title{font-size:1.75rem}.hero-subtitle{font-size:1rem}.results-grid{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:var(--spacing-md)}.btn{padding:var(--spacing-sm) var(--spacing-md);font-size:.875rem}.footer-links{flex-direction:column;width:100%}.footer-link{justify-content:center}}@media (max-width: 480px){.hero-title{font-size:1.5rem}.hero-subtitle{font-size:.9rem}.results-title{font-size:1rem}.results-actions{flex-direction:column}.results-actions .btn{width:100%;justify-content:center}.results-grid{grid-template-columns:1fr}.empty-state{padding:var(--spacing-lg) var(--spacing-md)}.empty-state-icon{width:60px;height:60px}.empty-state-icon svg{width:30px;height:30px}}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uziee/document-scanner",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "A lightweight, zero-dependency React document scanner with real-time edge detection, stability filtering, and perspective correction (bilinear warping) for high-resolution A4 captures.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|