@createlex/onetapforms-sdk 1.2.0 → 1.2.1
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/dist/autofill.d.ts +18 -0
- package/dist/index.cjs +55 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +53 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/onetapforms.umd.js +55 -0
- package/dist/onetapforms.umd.js.map +1 -1
- package/dist/onetapforms.umd.min.js +1 -1
- package/dist/onetapforms.umd.min.js.map +1 -1
- package/dist/types.d.ts +16 -0
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).OneTapForms={})}(this,function(t){"use strict";var e={},n={},o={};let r;const i=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];o.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},o.getSymbolTotalCodewords=function(t){return i[t]},o.getBCHDigit=function(t){let e=0;for(;0!==t;)e++,t>>>=1;return e},o.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');r=t},o.isKanjiModeEnabled=function(){return void 0!==r},o.toSJIS=function(t){return r(t)};var s,a={};function c(){this.buffer=[],this.length=0}(s=a).L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2},s.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},s.from=function(t,e){if(s.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+t)}}(t)}catch(t){return e}},c.prototype={get:function(t){const e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(let n=0;n<e;n++)this.putBit(1==(t>>>e-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var l=c;function u(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}u.prototype.set=function(t,e,n,o){const r=t*this.size+e;this.data[r]=n,o&&(this.reservedBit[r]=!0)},u.prototype.get=function(t,e){return this.data[t*this.size+e]},u.prototype.xor=function(t,e,n){this.data[t*this.size+e]^=n},u.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]};var d=u,f={};!function(t){const e=o.getSymbolSize;t.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,o=e(t),r=145===o?26:2*Math.ceil((o-13)/(2*n-2)),i=[o-7];for(let t=1;t<n-1;t++)i[t]=i[t-1]-r;return i.push(6),i.reverse()},t.getPositions=function(e){const n=[],o=t.getRowColCoords(e),r=o.length;for(let t=0;t<r;t++)for(let e=0;e<r;e++)0===t&&0===e||0===t&&e===r-1||t===r-1&&0===e||n.push([o[t],o[e]]);return n}}(f);var h={};const g=o.getSymbolSize;h.getPositions=function(t){const e=g(t);return[[0,0],[e-7,0],[0,e-7]]};var p={};!function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e=3,n=3,o=40,r=10;function i(e,n,o){switch(e){case t.Patterns.PATTERN000:return(n+o)%2==0;case t.Patterns.PATTERN001:return n%2==0;case t.Patterns.PATTERN010:return o%3==0;case t.Patterns.PATTERN011:return(n+o)%3==0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(o/3))%2==0;case t.Patterns.PATTERN101:return n*o%2+n*o%3==0;case t.Patterns.PATTERN110:return(n*o%2+n*o%3)%2==0;case t.Patterns.PATTERN111:return(n*o%3+(n+o)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}}t.isValid=function(t){return null!=t&&""!==t&&!isNaN(t)&&t>=0&&t<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(t){const n=t.size;let o=0,r=0,i=0,s=null,a=null;for(let c=0;c<n;c++){r=i=0,s=a=null;for(let l=0;l<n;l++){let n=t.get(c,l);n===s?r++:(r>=5&&(o+=e+(r-5)),s=n,r=1),n=t.get(l,c),n===a?i++:(i>=5&&(o+=e+(i-5)),a=n,i=1)}r>=5&&(o+=e+(r-5)),i>=5&&(o+=e+(i-5))}return o},t.getPenaltyN2=function(t){const e=t.size;let o=0;for(let n=0;n<e-1;n++)for(let r=0;r<e-1;r++){const e=t.get(n,r)+t.get(n,r+1)+t.get(n+1,r)+t.get(n+1,r+1);4!==e&&0!==e||o++}return o*n},t.getPenaltyN3=function(t){const e=t.size;let n=0,r=0,i=0;for(let o=0;o<e;o++){r=i=0;for(let s=0;s<e;s++)r=r<<1&2047|t.get(o,s),s>=10&&(1488===r||93===r)&&n++,i=i<<1&2047|t.get(s,o),s>=10&&(1488===i||93===i)&&n++}return n*o},t.getPenaltyN4=function(t){let e=0;const n=t.data.length;for(let o=0;o<n;o++)e+=t.data[o];return Math.abs(Math.ceil(100*e/n/5)-10)*r},t.applyMask=function(t,e){const n=e.size;for(let o=0;o<n;o++)for(let r=0;r<n;r++)e.isReserved(r,o)||e.xor(r,o,i(t,r,o))},t.getBestMask=function(e,n){const o=Object.keys(t.Patterns).length;let r=0,i=1/0;for(let s=0;s<o;s++){n(s),t.applyMask(s,e);const o=t.getPenaltyN1(e)+t.getPenaltyN2(e)+t.getPenaltyN3(e)+t.getPenaltyN4(e);t.applyMask(s,e),o<i&&(i=o,r=s)}return r}}(p);var m={};const w=a,y=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],E=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];m.getBlocksCount=function(t,e){switch(e){case w.L:return y[4*(t-1)+0];case w.M:return y[4*(t-1)+1];case w.Q:return y[4*(t-1)+2];case w.H:return y[4*(t-1)+3];default:return}},m.getTotalCodewordsCount=function(t,e){switch(e){case w.L:return E[4*(t-1)+0];case w.M:return E[4*(t-1)+1];case w.Q:return E[4*(t-1)+2];case w.H:return E[4*(t-1)+3];default:return}};var b={},v={};const C=new Uint8Array(512),x=new Uint8Array(256);!function(){let t=1;for(let e=0;e<255;e++)C[e]=t,x[t]=e,t<<=1,256&t&&(t^=285);for(let t=255;t<512;t++)C[t]=C[t-255]}(),v.log=function(t){if(t<1)throw new Error("log("+t+")");return x[t]},v.exp=function(t){return C[t]},v.mul=function(t,e){return 0===t||0===e?0:C[x[t]+x[e]]},function(t){const e=v;t.mul=function(t,n){const o=new Uint8Array(t.length+n.length-1);for(let r=0;r<t.length;r++)for(let i=0;i<n.length;i++)o[r+i]^=e.mul(t[r],n[i]);return o},t.mod=function(t,n){let o=new Uint8Array(t);for(;o.length-n.length>=0;){const t=o[0];for(let r=0;r<n.length;r++)o[r]^=e.mul(n[r],t);let r=0;for(;r<o.length&&0===o[r];)r++;o=o.slice(r)}return o},t.generateECPolynomial=function(n){let o=new Uint8Array([1]);for(let r=0;r<n;r++)o=t.mul(o,new Uint8Array([1,e.exp(r)]));return o}}(b);const T=b;function A(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}A.prototype.initialize=function(t){this.degree=t,this.genPoly=T.generateECPolynomial(this.degree)},A.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(t.length+this.degree);e.set(t);const n=T.mod(e,this.genPoly),o=this.degree-n.length;if(o>0){const t=new Uint8Array(this.degree);return t.set(n,o),t}return n};var I=A,P={},R={},B={isValid:function(t){return!isNaN(t)&&t>=1&&t<=40}},M={};const S="[0-9]+";let k="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";k=k.replace(/u/g,"\\u");const N="(?:(?![A-Z0-9 $%*+\\-./:]|"+k+")(?:.|[\r\n]))+";M.KANJI=new RegExp(k,"g"),M.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),M.BYTE=new RegExp(N,"g"),M.NUMERIC=new RegExp(S,"g"),M.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const L=new RegExp("^"+k+"$"),F=new RegExp("^"+S+"$"),U=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");M.testKanji=function(t){return L.test(t)},M.testNumeric=function(t){return F.test(t)},M.testAlphanumeric=function(t){return U.test(t)},function(t){const e=B,n=M;t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(t,n){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!e.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?t.ccBits[0]:n<27?t.ccBits[1]:t.ccBits[2]},t.getBestModeForData=function(e){return n.testNumeric(e)?t.NUMERIC:n.testAlphanumeric(e)?t.ALPHANUMERIC:n.testKanji(e)?t.KANJI:t.BYTE},t.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},t.isValid=function(t){return t&&t.bit&&t.ccBits},t.from=function(e,n){if(t.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+e)}}(e)}catch(t){return n}}}(R),function(t){const e=o,n=m,r=a,i=R,s=B,c=e.getBCHDigit(7973);function l(t,e){return i.getCharCountIndicator(t,e)+4}function u(t,e){let n=0;return t.forEach(function(t){const o=l(t.mode,e);n+=o+t.getBitsLength()}),n}t.from=function(t,e){return s.isValid(t)?parseInt(t,10):e},t.getCapacity=function(t,o,r){if(!s.isValid(t))throw new Error("Invalid QR Code version");void 0===r&&(r=i.BYTE);const a=8*(e.getSymbolTotalCodewords(t)-n.getTotalCodewordsCount(t,o));if(r===i.MIXED)return a;const c=a-l(r,t);switch(r){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},t.getBestVersionForData=function(e,n){let o;const s=r.from(n,r.M);if(Array.isArray(e)){if(e.length>1)return function(e,n){for(let o=1;o<=40;o++)if(u(e,o)<=t.getCapacity(o,n,i.MIXED))return o}(e,s);if(0===e.length)return 1;o=e[0]}else o=e;return function(e,n,o){for(let r=1;r<=40;r++)if(n<=t.getCapacity(r,o,e))return r}(o.mode,o.getLength(),s)},t.getEncodedBits=function(t){if(!s.isValid(t)||t<7)throw new Error("Invalid QR Code version");let n=t<<12;for(;e.getBCHDigit(n)-c>=0;)n^=7973<<e.getBCHDigit(n)-c;return t<<12|n}}(P);var D={};const q=o,z=q.getBCHDigit(1335);D.getEncodedBits=function(t,e){const n=t.bit<<3|e;let o=n<<10;for(;q.getBCHDigit(o)-z>=0;)o^=1335<<q.getBCHDigit(o)-z;return 21522^(n<<10|o)};var O={};const K=R;function _(t){this.mode=K.NUMERIC,this.data=t.toString()}_.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},_.prototype.getLength=function(){return this.data.length},_.prototype.getBitsLength=function(){return _.getBitsLength(this.data.length)},_.prototype.write=function(t){let e,n,o;for(e=0;e+3<=this.data.length;e+=3)n=this.data.substr(e,3),o=parseInt(n,10),t.put(o,10);const r=this.data.length-e;r>0&&(n=this.data.substr(e),o=parseInt(n,10),t.put(o,3*r+1))};var H=_;const j=R,J=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Q(t){this.mode=j.ALPHANUMERIC,this.data=t}Q.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},Q.prototype.getLength=function(){return this.data.length},Q.prototype.getBitsLength=function(){return Q.getBitsLength(this.data.length)},Q.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let n=45*J.indexOf(this.data[e]);n+=J.indexOf(this.data[e+1]),t.put(n,11)}this.data.length%2&&t.put(J.indexOf(this.data[e]),6)};var Y=Q;const $=R;function V(t){this.mode=$.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}V.getBitsLength=function(t){return 8*t},V.prototype.getLength=function(){return this.data.length},V.prototype.getBitsLength=function(){return V.getBitsLength(this.data.length)},V.prototype.write=function(t){for(let e=0,n=this.data.length;e<n;e++)t.put(this.data[e],8)};var X=V;const W=R,Z=o;function G(t){this.mode=W.KANJI,this.data=t}G.getBitsLength=function(t){return 13*t},G.prototype.getLength=function(){return this.data.length},G.prototype.getBitsLength=function(){return G.getBitsLength(this.data.length)},G.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let n=Z.toSJIS(this.data[e]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[e]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),t.put(n,13)}};var tt=G,et={exports:{}};!function(t){var e={single_source_shortest_paths:function(t,n,o){var r={},i={};i[n]=0;var s,a,c,l,u,d,f,h=e.PriorityQueue.make();for(h.push(n,0);!h.empty();)for(c in a=(s=h.pop()).value,l=s.cost,u=t[a]||{})u.hasOwnProperty(c)&&(d=l+u[c],f=i[c],(void 0===i[c]||f>d)&&(i[c]=d,h.push(c,d),r[c]=a));if(void 0!==o&&void 0===i[o]){var g=["Could not find a path from ",n," to ",o,"."].join("");throw new Error(g)}return r},extract_shortest_path_from_predecessor_list:function(t,e){for(var n=[],o=e;o;)n.push(o),t[o],o=t[o];return n.reverse(),n},find_path:function(t,n,o){var r=e.single_source_shortest_paths(t,n,o);return e.extract_shortest_path_from_predecessor_list(r,o)},PriorityQueue:{make:function(t){var n,o=e.PriorityQueue,r={};for(n in t=t||{},o)o.hasOwnProperty(n)&&(r[n]=o[n]);return r.queue=[],r.sorter=t.sorter||o.default_sorter,r},default_sorter:function(t,e){return t.cost-e.cost},push:function(t,e){var n={value:t,cost:e};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};t.exports=e}(et);var nt=et.exports;!function(t){const e=R,n=H,r=Y,i=X,s=tt,a=M,c=o,l=nt;function u(t){return unescape(encodeURIComponent(t)).length}function d(t,e,n){const o=[];let r;for(;null!==(r=t.exec(n));)o.push({data:r[0],index:r.index,mode:e,length:r[0].length});return o}function f(t){const n=d(a.NUMERIC,e.NUMERIC,t),o=d(a.ALPHANUMERIC,e.ALPHANUMERIC,t);let r,i;c.isKanjiModeEnabled()?(r=d(a.BYTE,e.BYTE,t),i=d(a.KANJI,e.KANJI,t)):(r=d(a.BYTE_KANJI,e.BYTE,t),i=[]);return n.concat(o,r,i).sort(function(t,e){return t.index-e.index}).map(function(t){return{data:t.data,mode:t.mode,length:t.length}})}function h(t,o){switch(o){case e.NUMERIC:return n.getBitsLength(t);case e.ALPHANUMERIC:return r.getBitsLength(t);case e.KANJI:return s.getBitsLength(t);case e.BYTE:return i.getBitsLength(t)}}function g(t,o){let a;const l=e.getBestModeForData(t);if(a=e.from(o,l),a!==e.BYTE&&a.bit<l.bit)throw new Error('"'+t+'" cannot be encoded with mode '+e.toString(a)+".\n Suggested mode is: "+e.toString(l));switch(a!==e.KANJI||c.isKanjiModeEnabled()||(a=e.BYTE),a){case e.NUMERIC:return new n(t);case e.ALPHANUMERIC:return new r(t);case e.KANJI:return new s(t);case e.BYTE:return new i(t)}}t.fromArray=function(t){return t.reduce(function(t,e){return"string"==typeof e?t.push(g(e,null)):e.data&&t.push(g(e.data,e.mode)),t},[])},t.fromString=function(n,o){const r=function(t){const n=[];for(let o=0;o<t.length;o++){const r=t[o];switch(r.mode){case e.NUMERIC:n.push([r,{data:r.data,mode:e.ALPHANUMERIC,length:r.length},{data:r.data,mode:e.BYTE,length:r.length}]);break;case e.ALPHANUMERIC:n.push([r,{data:r.data,mode:e.BYTE,length:r.length}]);break;case e.KANJI:n.push([r,{data:r.data,mode:e.BYTE,length:u(r.data)}]);break;case e.BYTE:n.push([{data:r.data,mode:e.BYTE,length:u(r.data)}])}}return n}(f(n,c.isKanjiModeEnabled())),i=function(t,n){const o={},r={start:{}};let i=["start"];for(let s=0;s<t.length;s++){const a=t[s],c=[];for(let t=0;t<a.length;t++){const l=a[t],u=""+s+t;c.push(u),o[u]={node:l,lastCount:0},r[u]={};for(let t=0;t<i.length;t++){const s=i[t];o[s]&&o[s].node.mode===l.mode?(r[s][u]=h(o[s].lastCount+l.length,l.mode)-h(o[s].lastCount,l.mode),o[s].lastCount+=l.length):(o[s]&&(o[s].lastCount=l.length),r[s][u]=h(l.length,l.mode)+4+e.getCharCountIndicator(l.mode,n))}}i=c}for(let t=0;t<i.length;t++)r[i[t]].end=0;return{map:r,table:o}}(r,o),s=l.find_path(i.map,"start","end"),a=[];for(let t=1;t<s.length-1;t++)a.push(i.table[s[t]].node);return t.fromArray(function(t){return t.reduce(function(t,e){const n=t.length-1>=0?t[t.length-1]:null;return n&&n.mode===e.mode?(t[t.length-1].data+=e.data,t):(t.push(e),t)},[])}(a))},t.rawSplit=function(e){return t.fromArray(f(e,c.isKanjiModeEnabled()))}}(O);const ot=o,rt=a,it=l,st=d,at=f,ct=h,lt=p,ut=m,dt=I,ft=P,ht=D,gt=R,pt=O;function mt(t,e,n){const o=t.size,r=ht.getEncodedBits(e,n);let i,s;for(i=0;i<15;i++)s=1==(r>>i&1),i<6?t.set(i,8,s,!0):i<8?t.set(i+1,8,s,!0):t.set(o-15+i,8,s,!0),i<8?t.set(8,o-i-1,s,!0):i<9?t.set(8,15-i-1+1,s,!0):t.set(8,15-i-1,s,!0);t.set(o-8,8,1,!0)}function wt(t,e,n){const o=new it;n.forEach(function(e){o.put(e.mode.bit,4),o.put(e.getLength(),gt.getCharCountIndicator(e.mode,t)),e.write(o)});const r=8*(ot.getSymbolTotalCodewords(t)-ut.getTotalCodewordsCount(t,e));for(o.getLengthInBits()+4<=r&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(0);const i=(r-o.getLengthInBits())/8;for(let t=0;t<i;t++)o.put(t%2?17:236,8);return function(t,e,n){const o=ot.getSymbolTotalCodewords(e),r=ut.getTotalCodewordsCount(e,n),i=o-r,s=ut.getBlocksCount(e,n),a=o%s,c=s-a,l=Math.floor(o/s),u=Math.floor(i/s),d=u+1,f=l-u,h=new dt(f);let g=0;const p=new Array(s),m=new Array(s);let w=0;const y=new Uint8Array(t.buffer);for(let t=0;t<s;t++){const e=t<c?u:d;p[t]=y.slice(g,g+e),m[t]=h.encode(p[t]),g+=e,w=Math.max(w,e)}const E=new Uint8Array(o);let b,v,C=0;for(b=0;b<w;b++)for(v=0;v<s;v++)b<p[v].length&&(E[C++]=p[v][b]);for(b=0;b<f;b++)for(v=0;v<s;v++)E[C++]=m[v][b];return E}(o,t,e)}function yt(t,e,n,o){let r;if(Array.isArray(t))r=pt.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");{let o=e;if(!o){const e=pt.rawSplit(t);o=ft.getBestVersionForData(e,n)}r=pt.fromString(t,o||40)}}const i=ft.getBestVersionForData(r,n);if(!i)throw new Error("The amount of data is too big to be stored in a QR Code");if(e){if(e<i)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+i+".\n")}else e=i;const s=wt(e,n,r),a=ot.getSymbolSize(e),c=new st(a);return function(t,e){const n=t.size,o=ct.getPositions(e);for(let e=0;e<o.length;e++){const r=o[e][0],i=o[e][1];for(let e=-1;e<=7;e++)if(!(r+e<=-1||n<=r+e))for(let o=-1;o<=7;o++)i+o<=-1||n<=i+o||(e>=0&&e<=6&&(0===o||6===o)||o>=0&&o<=6&&(0===e||6===e)||e>=2&&e<=4&&o>=2&&o<=4?t.set(r+e,i+o,!0,!0):t.set(r+e,i+o,!1,!0))}}(c,e),function(t){const e=t.size;for(let n=8;n<e-8;n++){const e=n%2==0;t.set(n,6,e,!0),t.set(6,n,e,!0)}}(c),function(t,e){const n=at.getPositions(e);for(let e=0;e<n.length;e++){const o=n[e][0],r=n[e][1];for(let e=-2;e<=2;e++)for(let n=-2;n<=2;n++)-2===e||2===e||-2===n||2===n||0===e&&0===n?t.set(o+e,r+n,!0,!0):t.set(o+e,r+n,!1,!0)}}(c,e),mt(c,n,0),e>=7&&function(t,e){const n=t.size,o=ft.getEncodedBits(e);let r,i,s;for(let e=0;e<18;e++)r=Math.floor(e/3),i=e%3+n-8-3,s=1==(o>>e&1),t.set(r,i,s,!0),t.set(i,r,s,!0)}(c,e),function(t,e){const n=t.size;let o=-1,r=n-1,i=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!t.isReserved(r,a-n)){let o=!1;s<e.length&&(o=1==(e[s]>>>i&1)),t.set(r,a-n,o),i--,-1===i&&(s++,i=7)}if(r+=o,r<0||n<=r){r-=o,o=-o;break}}}(c,s),isNaN(o)&&(o=lt.getBestMask(c,mt.bind(null,c,n))),lt.applyMask(o,c),mt(c,n,o),{modules:c,version:e,errorCorrectionLevel:n,maskPattern:o,segments:r}}n.create=function(t,e){if(void 0===t||""===t)throw new Error("No input text");let n,o,r=rt.M;return void 0!==e&&(r=rt.from(e.errorCorrectionLevel,rt.M),n=ft.from(e.version),o=lt.from(e.maskPattern),e.toSJISFunc&&ot.setToSJISFunction(e.toSJISFunc)),yt(t,n,r,o)};var Et={},bt={};!function(t){function e(t){if("number"==typeof t&&(t=t.toString()),"string"!=typeof t)throw new Error("Color should be defined as hex string");let e=t.slice().replace("#","").split("");if(e.length<3||5===e.length||e.length>8)throw new Error("Invalid hex color: "+t);3!==e.length&&4!==e.length||(e=Array.prototype.concat.apply([],e.map(function(t){return[t,t]}))),6===e.length&&e.push("F","F");const n=parseInt(e.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+e.slice(0,6).join("")}}t.getOptions=function(t){t||(t={}),t.color||(t.color={});const n=void 0===t.margin||null===t.margin||t.margin<0?4:t.margin,o=t.width&&t.width>=21?t.width:void 0,r=t.scale||4;return{width:o,scale:o?4:r,margin:n,color:{dark:e(t.color.dark||"#000000ff"),light:e(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},t.getScale=function(t,e){return e.width&&e.width>=t+2*e.margin?e.width/(t+2*e.margin):e.scale},t.getImageWidth=function(e,n){const o=t.getScale(e,n);return Math.floor((e+2*n.margin)*o)},t.qrToImageData=function(e,n,o){const r=n.modules.size,i=n.modules.data,s=t.getScale(r,o),a=Math.floor((r+2*o.margin)*s),c=o.margin*s,l=[o.color.light,o.color.dark];for(let t=0;t<a;t++)for(let n=0;n<a;n++){let u=4*(t*a+n),d=o.color.light;if(t>=c&&n>=c&&t<a-c&&n<a-c){d=l[i[Math.floor((t-c)/s)*r+Math.floor((n-c)/s)]?1:0]}e[u++]=d.r,e[u++]=d.g,e[u++]=d.b,e[u]=d.a}}}(bt),function(t){const e=bt;t.render=function(t,n,o){let r=o,i=n;void 0!==r||n&&n.getContext||(r=n,n=void 0),n||(i=function(){try{return document.createElement("canvas")}catch(t){throw new Error("You need to specify a canvas element")}}()),r=e.getOptions(r);const s=e.getImageWidth(t.modules.size,r),a=i.getContext("2d"),c=a.createImageData(s,s);return e.qrToImageData(c.data,t,r),function(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+"px",e.style.width=n+"px"}(a,i,s),a.putImageData(c,0,0),i},t.renderToDataURL=function(e,n,o){let r=o;void 0!==r||n&&n.getContext||(r=n,n=void 0),r||(r={});const i=t.render(e,n,r),s=r.type||"image/png",a=r.rendererOpts||{};return i.toDataURL(s,a.quality)}}(Et);var vt={};const Ct=bt;function xt(t,e){const n=t.a/255,o=e+'="'+t.hex+'"';return n<1?o+" "+e+'-opacity="'+n.toFixed(2).slice(1)+'"':o}function Tt(t,e,n){let o=t+e;return void 0!==n&&(o+=" "+n),o}vt.render=function(t,e,n){const o=Ct.getOptions(e),r=t.modules.size,i=t.modules.data,s=r+2*o.margin,a=o.color.light.a?"<path "+xt(o.color.light,"fill")+' d="M0 0h'+s+"v"+s+'H0z"/>':"",c="<path "+xt(o.color.dark,"stroke")+' d="'+function(t,e,n){let o="",r=0,i=!1,s=0;for(let a=0;a<t.length;a++){const c=Math.floor(a%e),l=Math.floor(a/e);c||i||(i=!0),t[a]?(s++,a>0&&c>0&&t[a-1]||(o+=i?Tt("M",c+n,.5+l+n):Tt("m",r,0),r=0,i=!1),c+1<e&&t[a+1]||(o+=Tt("h",s),s=0)):r++}return o}(i,r,o.margin)+'"/>',l='viewBox="0 0 '+s+" "+s+'"',u='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+l+' shape-rendering="crispEdges">'+a+c+"</svg>\n";return"function"==typeof n&&n(null,u),u};const At=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},It=n,Pt=Et,Rt=vt;function Bt(t,e,n,o,r){const i=[].slice.call(arguments,1),s=i.length,a="function"==typeof i[s-1];if(!a&&!At())throw new Error("Callback required as last argument");if(!a){if(s<1)throw new Error("Too few arguments provided");return 1===s?(n=e,e=o=void 0):2!==s||e.getContext||(o=n,n=e,e=void 0),new Promise(function(r,i){try{const i=It.create(n,o);r(t(i,e,o))}catch(t){i(t)}})}if(s<2)throw new Error("Too few arguments provided");2===s?(r=n,n=e,e=o=void 0):3===s&&(e.getContext&&void 0===r?(r=o,o=void 0):(r=o,o=n,n=e,e=void 0));try{const i=It.create(n,o);r(null,t(i,e,o))}catch(t){r(t)}}function Mt(t,e){return new Promise((n,o)=>{const r=setTimeout(n,t);e&&e.addEventListener("abort",()=>{clearTimeout(r),o(new Error("Aborted"))})})}e.create=It.create,e.toCanvas=Bt.bind(null,Pt.render),e.toDataURL=Bt.bind(null,Pt.renderToDataURL),e.toString=Bt.bind(null,function(t,e,n){return Rt.render(t,n)});let St=class{constructor(t){this.activePolling=null,this.config={apiUrl:"https://api.onetapforms.com",clientId:t.clientId,clientSecret:t.clientSecret,apiKey:t.apiKey??t.clientId,debug:!1,...t};const e={...this.config,apiKey:this.config.apiKey?"[REDACTED]":void 0,clientSecret:this.config.clientSecret?"[REDACTED]":void 0};this.log("OneTap Forms SDK initialized",e)}buildAuthHeaders(){return this.config.clientId&&this.config.clientSecret?{"X-Client-ID":this.config.clientId,"X-Client-Secret":this.config.clientSecret}:this.config.apiKey?{"X-API-Key":this.config.apiKey}:null}async request(t){try{this.log("Creating request",t);const e=function(){if("undefined"==typeof window||"undefined"==typeof navigator)return"desktop";const t=navigator.userAgent||"";return/iPhone|iPad|iPod|Android|webOS|BlackBerry|Windows Phone/i.test(t)||/iPad|Android(?!.*Mobile)/i.test(t)?"mobile":"desktop"}(),n=t.mode||"auto";let o="qr";"auto"===n?o="mobile"===e?"redirect":"qr":"redirect"===n?o="redirect":"qr"===n&&(o="qr"),this.log("Effective mode:",o,"Device:",e);const r=await this.createRequest({clientId:this.config.clientId,schemaId:t.schemaId,purpose:t.purpose,returnUrl:t.returnUrl,requestedBundles:t.bundles,requestedFields:t.fields,mode:o,metadata:t.metadata,customization:t.customization});this.log("Request created:",r),"redirect"===o&&r.redirectUrl?this.handleRedirect(r.redirectUrl):("qr"===o&&r.qrCodeData||r.qrCodeData)&&await this.handleQR(r,t)}catch(e){throw this.log("Error creating request:",e),t.onError&&t.onError(e instanceof Error?e:new Error("Unknown error")),e}}handleRedirect(t){this.log("Redirecting to:",t),window.location.href=t}async handleQR(t,n){const o=await async function(t){try{return await e.toDataURL(t,{errorCorrectionLevel:"M",margin:2,width:300,color:{dark:"#000000",light:"#FFFFFF"}})}catch(t){throw console.error("QR code generation failed:",t),new Error("Failed to generate QR code")}}(t.qrCodeData);this.log("QR code generated"),n.onQRReady&&n.onQRReady(o),this.activePolling=new AbortController;try{const e=await async function(t,e,n={}){const{interval:o=2e3,timeout:r=18e4,signal:i,onStatusChange:s}=n,a=Date.now();for(;;){if(null==i?void 0:i.aborted)throw new Error("Polling cancelled");if(Date.now()-a>r)throw new Error("Polling timeout");try{const n=await fetch(`${t}/api/onetapforms/requests/${e}/status`,{signal:i});if(!n.ok)throw new Error(`Status check failed: ${n.statusText}`);const r=await n.json();if(s&&s(r),r.approved||"completed"===r.status||"approved"===r.status||"denied"===r.status||"expired"===r.status)return r;await Mt(o,i)}catch(t){if(t instanceof Error&&"AbortError"===t.name)throw t;console.error("Polling error:",t),await Mt(o,i)}}}(this.config.apiUrl,t.requestId,{signal:this.activePolling.signal,onStatusChange:t=>{this.log("Status update:",t)}});(e.approved||"completed"===e.status||"approved"===e.status)&&e.exchangeToken&&(this.log("Request approved, token received"),n.onComplete&&n.onComplete({token:e.exchangeToken,requestId:t.requestId}))}catch(t){if(t instanceof Error&&"AbortError"===t.name)return void this.log("Polling cancelled");this.log("Polling error:",t),n.onError&&n.onError(t instanceof Error?t:new Error("Polling failed"))}}cancelPolling(){this.activePolling&&(this.activePolling.abort(),this.activePolling=null)}handleCallback(){const t=new URLSearchParams(window.location.search),e=t.get("token"),n=t.get("requestId");return e&&n?(this.log("Callback received with token"),{token:e,requestId:n}):null}async exchangeToken(t){this.log("Exchanging token (Note: This should be done server-side!)");const e=this.buildAuthHeaders();if(!e)throw new Error("Client credentials are required");const n=await fetch(`${this.config.apiUrl}/api/onetapforms/exchange`,{method:"POST",headers:{"Content-Type":"application/json",...e},body:JSON.stringify({token:t})});if(!n.ok)throw new Error(`Token exchange failed: ${n.statusText}`);return(await n.json()).data}async createRequest(t){const e=this.buildAuthHeaders();if(!e)throw new Error("Client credentials are required");const n=await fetch(`${this.config.apiUrl}/api/onetapforms/requests`,{method:"POST",headers:{"Content-Type":"application/json",...e},body:JSON.stringify(t)});if(!n.ok){const t=await n.json();throw new Error(t.message||"Failed to create request")}return n.json()}log(t,...e){this.config.debug&&console.log(`[OneTapForms] ${t}`,...e)}};class kt{constructor(t){this.instance=new St(t)}async request(t){return this.instance.request(t)}cancelPolling(){return this.instance.cancelPolling()}handleCallback(){return this.instance.handleCallback()}async exchangeToken(t){return this.instance.exchangeToken(t)}getAppDownloadUrl(){return"https://apps.apple.com/app/onetapforms"}showDownloadPrompt(t){if("undefined"==typeof window)return;const e=t?.title||"Download OneTapForms for Faster Form Completion",n=t?.message||"Complete forms in seconds with one tap! Download the OneTapForms app to instantly fill forms using Face ID/Touch ID.",o=t?.buttonText||"Download App",r=this.getAppDownloadUrl(),i=document.createElement("div");i.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n ";const s=document.createElement("div");s.style.cssText="\n background: white;\n padding: 24px;\n border-radius: 12px;\n max-width: 400px;\n margin: 20px;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n ";const a=document.createElement("h3");a.textContent=e,a.style.cssText="\n margin: 0 0 12px 0;\n font-size: 20px;\n font-weight: 600;\n color: #1a1a1a;\n ";const c=document.createElement("p");c.textContent=n,c.style.cssText="\n margin: 0 0 20px 0;\n font-size: 14px;\n color: #666;\n line-height: 1.5;\n ";const l=document.createElement("div");l.style.cssText="\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n ";const u=document.createElement("button");u.textContent="Maybe Later",u.style.cssText="\n padding: 10px 20px;\n border: 1px solid #ddd;\n background: white;\n border-radius: 6px;\n cursor: pointer;\n font-size: 14px;\n color: #666;\n ",u.onclick=()=>{document.body.removeChild(i),t?.onDismiss&&t.onDismiss()};const d=document.createElement("button");d.textContent=o,d.style.cssText="\n padding: 10px 20px;\n border: none;\n background: #007AFF;\n color: white;\n border-radius: 6px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n ",d.onclick=()=>{window.open(r,"_blank"),document.body.removeChild(i)},l.appendChild(u),l.appendChild(d),s.appendChild(a),s.appendChild(c),s.appendChild(l),i.appendChild(s),i.onclick=e=>{e.target===i&&(document.body.removeChild(i),t?.onDismiss&&t.onDismiss())},document.body.appendChild(i)}}var Nt=Object.freeze({__proto__:null,OneTapForms:kt,default:kt});function Lt(t){!function(){if("undefined"==typeof document)return;if(document.getElementById("onetapforms-styles"))return;const t=document.createElement("style");t.id="onetapforms-styles",t.textContent="\n .onetapforms-modal {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.6);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n .onetapforms-modal.active {\n opacity: 1;\n }\n .onetapforms-modal-content {\n background: white;\n padding: 32px;\n border-radius: 16px;\n max-width: 360px;\n width: 90%;\n text-align: center;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);\n transform: scale(0.95);\n transition: transform 0.2s ease;\n }\n .onetapforms-modal.active .onetapforms-modal-content {\n transform: scale(1);\n }\n .onetapforms-modal-title {\n margin: 0 0 8px 0;\n font-size: 20px;\n font-weight: 600;\n color: #1a1a1a;\n }\n .onetapforms-modal-subtitle {\n margin: 0 0 24px 0;\n font-size: 14px;\n color: #666;\n }\n .onetapforms-qr-container {\n background: #f5f5f5;\n border-radius: 12px;\n padding: 20px;\n margin-bottom: 20px;\n }\n .onetapforms-qr-container img {\n max-width: 100%;\n height: auto;\n }\n .onetapforms-status {\n font-size: 13px;\n color: #888;\n margin-bottom: 16px;\n }\n .onetapforms-close-btn {\n background: #f0f0f0;\n border: none;\n padding: 10px 24px;\n border-radius: 8px;\n cursor: pointer;\n font-size: 14px;\n color: #333;\n transition: background 0.15s;\n }\n .onetapforms-close-btn:hover {\n background: #e0e0e0;\n }\n .onetapforms-spinner {\n width: 200px;\n height: 200px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .onetapforms-spinner::after {\n content: '';\n width: 40px;\n height: 40px;\n border: 3px solid #e0e0e0;\n border-top-color: #007AFF;\n border-radius: 50%;\n animation: onetapforms-spin 0.8s linear infinite;\n }\n @keyframes onetapforms-spin {\n to { transform: rotate(360deg); }\n }\n",document.head.appendChild(t)}();const e=document.createElement("div");e.className="onetapforms-modal",e.innerHTML=`\n <div class="onetapforms-modal-content">\n <h3 class="onetapforms-modal-title">${t.title||"Scan to Complete"}</h3>\n <p class="onetapforms-modal-subtitle">${t.subtitle||"Scan with your OneTapForms app"}</p>\n <div class="onetapforms-qr-container">\n <div class="onetapforms-spinner"></div>\n </div>\n <p class="onetapforms-status">Waiting for scan...</p>\n <button class="onetapforms-close-btn">Cancel</button>\n </div>\n `;const n=e.querySelector(".onetapforms-qr-container"),o=e.querySelector(".onetapforms-status"),r=e.querySelector(".onetapforms-close-btn"),i=()=>{e.classList.remove("active"),setTimeout(()=>e.remove(),200),t.onClose&&t.onClose()};return r.addEventListener("click",i),e.addEventListener("click",t=>{t.target===e&&i()}),document.body.appendChild(e),requestAnimationFrame(()=>e.classList.add("active")),{setQR:t=>{n.innerHTML=`<img src="${t}" alt="QR Code" />`},setStatus:t=>{o.textContent=t},close:i}}function Ft(){if("undefined"==typeof document)return;document.querySelectorAll("[data-onetapforms]").forEach(t=>{if("true"===t.dataset.onetapformsInit)return;t.dataset.onetapformsInit="true";const e=t.dataset.clientId,n=t.dataset.clientSecret,o=t.dataset.purpose||"Complete form",r=t.dataset.bundles?.split(",").map(t=>t.trim())||["basic"],i=t.dataset.formId,s=t.dataset.apiUrl;e?Promise.resolve().then(function(){return Nt}).then(({OneTapForms:a})=>{const c=new a({clientId:e,clientSecret:n,apiUrl:s});t.addEventListener("click",async e=>{e.preventDefault();let n=null;try{await c.request({purpose:o,bundles:r,onQRReady:t=>{n=Lt({title:"Scan with OneTapForms",subtitle:o,onClose:()=>c.cancelPolling()}),n.setQR(t)},onComplete:e=>{n&&(n.setStatus("Complete!"),setTimeout(()=>n?.close(),500));const o=new CustomEvent("onetapforms:complete",{bubbles:!0,detail:e});if(t.dispatchEvent(o),i){const t=document.getElementById(i);if(t){let n=t.querySelector('input[name="onetapforms_token"]');n||(n=document.createElement("input"),n.type="hidden",n.name="onetapforms_token",t.appendChild(n)),n.value=e.token}}},onError:e=>{n&&n.close();const o=new CustomEvent("onetapforms:error",{bubbles:!0,detail:{error:e}});t.dispatchEvent(o)}})}catch(e){console.error("[OneTapForms] Request failed:",e);const n=new CustomEvent("onetapforms:error",{bubbles:!0,detail:{error:e}});t.dispatchEvent(n)}})}):console.error("[OneTapForms] Missing data-client-id attribute")})}if("undefined"!=typeof window&&"undefined"!=typeof document){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Ft):Ft();const t=new MutationObserver(t=>{for(const e of t)e.addedNodes.length&&Ft()});document.body?t.observe(document.body,{childList:!0,subtree:!0}):document.addEventListener("DOMContentLoaded",()=>{t.observe(document.body,{childList:!0,subtree:!0})})}t.OneTapForms=kt,t.default=kt,t.initWidgets=Ft,t.showQRModal=Lt,Object.defineProperty(t,"__esModule",{value:!0})}),"undefined"!=typeof window&&(window.OneTapForms=window.OneTapForms.OneTapForms||window.OneTapForms);
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).OneTapForms={})}(this,function(t){"use strict";var e={},n={},o={};let r;const i=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];o.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},o.getSymbolTotalCodewords=function(t){return i[t]},o.getBCHDigit=function(t){let e=0;for(;0!==t;)e++,t>>>=1;return e},o.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');r=t},o.isKanjiModeEnabled=function(){return void 0!==r},o.toSJIS=function(t){return r(t)};var s,a={};function c(){this.buffer=[],this.length=0}(s=a).L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2},s.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},s.from=function(t,e){if(s.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+t)}}(t)}catch(t){return e}},c.prototype={get:function(t){const e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(let n=0;n<e;n++)this.putBit(1==(t>>>e-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var l=c;function u(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}u.prototype.set=function(t,e,n,o){const r=t*this.size+e;this.data[r]=n,o&&(this.reservedBit[r]=!0)},u.prototype.get=function(t,e){return this.data[t*this.size+e]},u.prototype.xor=function(t,e,n){this.data[t*this.size+e]^=n},u.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]};var d=u,f={};!function(t){const e=o.getSymbolSize;t.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,o=e(t),r=145===o?26:2*Math.ceil((o-13)/(2*n-2)),i=[o-7];for(let t=1;t<n-1;t++)i[t]=i[t-1]-r;return i.push(6),i.reverse()},t.getPositions=function(e){const n=[],o=t.getRowColCoords(e),r=o.length;for(let t=0;t<r;t++)for(let e=0;e<r;e++)0===t&&0===e||0===t&&e===r-1||t===r-1&&0===e||n.push([o[t],o[e]]);return n}}(f);var h={};const g=o.getSymbolSize;h.getPositions=function(t){const e=g(t);return[[0,0],[e-7,0],[0,e-7]]};var p={};!function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e=3,n=3,o=40,r=10;function i(e,n,o){switch(e){case t.Patterns.PATTERN000:return(n+o)%2==0;case t.Patterns.PATTERN001:return n%2==0;case t.Patterns.PATTERN010:return o%3==0;case t.Patterns.PATTERN011:return(n+o)%3==0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(o/3))%2==0;case t.Patterns.PATTERN101:return n*o%2+n*o%3==0;case t.Patterns.PATTERN110:return(n*o%2+n*o%3)%2==0;case t.Patterns.PATTERN111:return(n*o%3+(n+o)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}}t.isValid=function(t){return null!=t&&""!==t&&!isNaN(t)&&t>=0&&t<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(t){const n=t.size;let o=0,r=0,i=0,s=null,a=null;for(let c=0;c<n;c++){r=i=0,s=a=null;for(let l=0;l<n;l++){let n=t.get(c,l);n===s?r++:(r>=5&&(o+=e+(r-5)),s=n,r=1),n=t.get(l,c),n===a?i++:(i>=5&&(o+=e+(i-5)),a=n,i=1)}r>=5&&(o+=e+(r-5)),i>=5&&(o+=e+(i-5))}return o},t.getPenaltyN2=function(t){const e=t.size;let o=0;for(let n=0;n<e-1;n++)for(let r=0;r<e-1;r++){const e=t.get(n,r)+t.get(n,r+1)+t.get(n+1,r)+t.get(n+1,r+1);4!==e&&0!==e||o++}return o*n},t.getPenaltyN3=function(t){const e=t.size;let n=0,r=0,i=0;for(let o=0;o<e;o++){r=i=0;for(let s=0;s<e;s++)r=r<<1&2047|t.get(o,s),s>=10&&(1488===r||93===r)&&n++,i=i<<1&2047|t.get(s,o),s>=10&&(1488===i||93===i)&&n++}return n*o},t.getPenaltyN4=function(t){let e=0;const n=t.data.length;for(let o=0;o<n;o++)e+=t.data[o];return Math.abs(Math.ceil(100*e/n/5)-10)*r},t.applyMask=function(t,e){const n=e.size;for(let o=0;o<n;o++)for(let r=0;r<n;r++)e.isReserved(r,o)||e.xor(r,o,i(t,r,o))},t.getBestMask=function(e,n){const o=Object.keys(t.Patterns).length;let r=0,i=1/0;for(let s=0;s<o;s++){n(s),t.applyMask(s,e);const o=t.getPenaltyN1(e)+t.getPenaltyN2(e)+t.getPenaltyN3(e)+t.getPenaltyN4(e);t.applyMask(s,e),o<i&&(i=o,r=s)}return r}}(p);var m={};const w=a,y=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],E=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];m.getBlocksCount=function(t,e){switch(e){case w.L:return y[4*(t-1)+0];case w.M:return y[4*(t-1)+1];case w.Q:return y[4*(t-1)+2];case w.H:return y[4*(t-1)+3];default:return}},m.getTotalCodewordsCount=function(t,e){switch(e){case w.L:return E[4*(t-1)+0];case w.M:return E[4*(t-1)+1];case w.Q:return E[4*(t-1)+2];case w.H:return E[4*(t-1)+3];default:return}};var b={},v={};const C=new Uint8Array(512),x=new Uint8Array(256);!function(){let t=1;for(let e=0;e<255;e++)C[e]=t,x[t]=e,t<<=1,256&t&&(t^=285);for(let t=255;t<512;t++)C[t]=C[t-255]}(),v.log=function(t){if(t<1)throw new Error("log("+t+")");return x[t]},v.exp=function(t){return C[t]},v.mul=function(t,e){return 0===t||0===e?0:C[x[t]+x[e]]},function(t){const e=v;t.mul=function(t,n){const o=new Uint8Array(t.length+n.length-1);for(let r=0;r<t.length;r++)for(let i=0;i<n.length;i++)o[r+i]^=e.mul(t[r],n[i]);return o},t.mod=function(t,n){let o=new Uint8Array(t);for(;o.length-n.length>=0;){const t=o[0];for(let r=0;r<n.length;r++)o[r]^=e.mul(n[r],t);let r=0;for(;r<o.length&&0===o[r];)r++;o=o.slice(r)}return o},t.generateECPolynomial=function(n){let o=new Uint8Array([1]);for(let r=0;r<n;r++)o=t.mul(o,new Uint8Array([1,e.exp(r)]));return o}}(b);const T=b;function A(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}A.prototype.initialize=function(t){this.degree=t,this.genPoly=T.generateECPolynomial(this.degree)},A.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(t.length+this.degree);e.set(t);const n=T.mod(e,this.genPoly),o=this.degree-n.length;if(o>0){const t=new Uint8Array(this.degree);return t.set(n,o),t}return n};var I=A,P={},B={},R={isValid:function(t){return!isNaN(t)&&t>=1&&t<=40}},M={};const S="[0-9]+";let k="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";k=k.replace(/u/g,"\\u");const N="(?:(?![A-Z0-9 $%*+\\-./:]|"+k+")(?:.|[\r\n]))+";M.KANJI=new RegExp(k,"g"),M.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),M.BYTE=new RegExp(N,"g"),M.NUMERIC=new RegExp(S,"g"),M.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const L=new RegExp("^"+k+"$"),F=new RegExp("^"+S+"$"),U=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");M.testKanji=function(t){return L.test(t)},M.testNumeric=function(t){return F.test(t)},M.testAlphanumeric=function(t){return U.test(t)},function(t){const e=R,n=M;t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(t,n){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!e.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?t.ccBits[0]:n<27?t.ccBits[1]:t.ccBits[2]},t.getBestModeForData=function(e){return n.testNumeric(e)?t.NUMERIC:n.testAlphanumeric(e)?t.ALPHANUMERIC:n.testKanji(e)?t.KANJI:t.BYTE},t.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},t.isValid=function(t){return t&&t.bit&&t.ccBits},t.from=function(e,n){if(t.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+e)}}(e)}catch(t){return n}}}(B),function(t){const e=o,n=m,r=a,i=B,s=R,c=e.getBCHDigit(7973);function l(t,e){return i.getCharCountIndicator(t,e)+4}function u(t,e){let n=0;return t.forEach(function(t){const o=l(t.mode,e);n+=o+t.getBitsLength()}),n}t.from=function(t,e){return s.isValid(t)?parseInt(t,10):e},t.getCapacity=function(t,o,r){if(!s.isValid(t))throw new Error("Invalid QR Code version");void 0===r&&(r=i.BYTE);const a=8*(e.getSymbolTotalCodewords(t)-n.getTotalCodewordsCount(t,o));if(r===i.MIXED)return a;const c=a-l(r,t);switch(r){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},t.getBestVersionForData=function(e,n){let o;const s=r.from(n,r.M);if(Array.isArray(e)){if(e.length>1)return function(e,n){for(let o=1;o<=40;o++)if(u(e,o)<=t.getCapacity(o,n,i.MIXED))return o}(e,s);if(0===e.length)return 1;o=e[0]}else o=e;return function(e,n,o){for(let r=1;r<=40;r++)if(n<=t.getCapacity(r,o,e))return r}(o.mode,o.getLength(),s)},t.getEncodedBits=function(t){if(!s.isValid(t)||t<7)throw new Error("Invalid QR Code version");let n=t<<12;for(;e.getBCHDigit(n)-c>=0;)n^=7973<<e.getBCHDigit(n)-c;return t<<12|n}}(P);var q={};const D=o,z=D.getBCHDigit(1335);q.getEncodedBits=function(t,e){const n=t.bit<<3|e;let o=n<<10;for(;D.getBCHDigit(o)-z>=0;)o^=1335<<D.getBCHDigit(o)-z;return 21522^(n<<10|o)};var O={};const K=B;function _(t){this.mode=K.NUMERIC,this.data=t.toString()}_.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},_.prototype.getLength=function(){return this.data.length},_.prototype.getBitsLength=function(){return _.getBitsLength(this.data.length)},_.prototype.write=function(t){let e,n,o;for(e=0;e+3<=this.data.length;e+=3)n=this.data.substr(e,3),o=parseInt(n,10),t.put(o,10);const r=this.data.length-e;r>0&&(n=this.data.substr(e),o=parseInt(n,10),t.put(o,3*r+1))};var H=_;const j=B,J=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Q(t){this.mode=j.ALPHANUMERIC,this.data=t}Q.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},Q.prototype.getLength=function(){return this.data.length},Q.prototype.getBitsLength=function(){return Q.getBitsLength(this.data.length)},Q.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let n=45*J.indexOf(this.data[e]);n+=J.indexOf(this.data[e+1]),t.put(n,11)}this.data.length%2&&t.put(J.indexOf(this.data[e]),6)};var Y=Q;const $=B;function V(t){this.mode=$.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}V.getBitsLength=function(t){return 8*t},V.prototype.getLength=function(){return this.data.length},V.prototype.getBitsLength=function(){return V.getBitsLength(this.data.length)},V.prototype.write=function(t){for(let e=0,n=this.data.length;e<n;e++)t.put(this.data[e],8)};var X=V;const W=B,Z=o;function G(t){this.mode=W.KANJI,this.data=t}G.getBitsLength=function(t){return 13*t},G.prototype.getLength=function(){return this.data.length},G.prototype.getBitsLength=function(){return G.getBitsLength(this.data.length)},G.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let n=Z.toSJIS(this.data[e]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[e]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),t.put(n,13)}};var tt=G,et={exports:{}};!function(t){var e={single_source_shortest_paths:function(t,n,o){var r={},i={};i[n]=0;var s,a,c,l,u,d,f,h=e.PriorityQueue.make();for(h.push(n,0);!h.empty();)for(c in a=(s=h.pop()).value,l=s.cost,u=t[a]||{})u.hasOwnProperty(c)&&(d=l+u[c],f=i[c],(void 0===i[c]||f>d)&&(i[c]=d,h.push(c,d),r[c]=a));if(void 0!==o&&void 0===i[o]){var g=["Could not find a path from ",n," to ",o,"."].join("");throw new Error(g)}return r},extract_shortest_path_from_predecessor_list:function(t,e){for(var n=[],o=e;o;)n.push(o),t[o],o=t[o];return n.reverse(),n},find_path:function(t,n,o){var r=e.single_source_shortest_paths(t,n,o);return e.extract_shortest_path_from_predecessor_list(r,o)},PriorityQueue:{make:function(t){var n,o=e.PriorityQueue,r={};for(n in t=t||{},o)o.hasOwnProperty(n)&&(r[n]=o[n]);return r.queue=[],r.sorter=t.sorter||o.default_sorter,r},default_sorter:function(t,e){return t.cost-e.cost},push:function(t,e){var n={value:t,cost:e};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};t.exports=e}(et);var nt=et.exports;!function(t){const e=B,n=H,r=Y,i=X,s=tt,a=M,c=o,l=nt;function u(t){return unescape(encodeURIComponent(t)).length}function d(t,e,n){const o=[];let r;for(;null!==(r=t.exec(n));)o.push({data:r[0],index:r.index,mode:e,length:r[0].length});return o}function f(t){const n=d(a.NUMERIC,e.NUMERIC,t),o=d(a.ALPHANUMERIC,e.ALPHANUMERIC,t);let r,i;c.isKanjiModeEnabled()?(r=d(a.BYTE,e.BYTE,t),i=d(a.KANJI,e.KANJI,t)):(r=d(a.BYTE_KANJI,e.BYTE,t),i=[]);return n.concat(o,r,i).sort(function(t,e){return t.index-e.index}).map(function(t){return{data:t.data,mode:t.mode,length:t.length}})}function h(t,o){switch(o){case e.NUMERIC:return n.getBitsLength(t);case e.ALPHANUMERIC:return r.getBitsLength(t);case e.KANJI:return s.getBitsLength(t);case e.BYTE:return i.getBitsLength(t)}}function g(t,o){let a;const l=e.getBestModeForData(t);if(a=e.from(o,l),a!==e.BYTE&&a.bit<l.bit)throw new Error('"'+t+'" cannot be encoded with mode '+e.toString(a)+".\n Suggested mode is: "+e.toString(l));switch(a!==e.KANJI||c.isKanjiModeEnabled()||(a=e.BYTE),a){case e.NUMERIC:return new n(t);case e.ALPHANUMERIC:return new r(t);case e.KANJI:return new s(t);case e.BYTE:return new i(t)}}t.fromArray=function(t){return t.reduce(function(t,e){return"string"==typeof e?t.push(g(e,null)):e.data&&t.push(g(e.data,e.mode)),t},[])},t.fromString=function(n,o){const r=function(t){const n=[];for(let o=0;o<t.length;o++){const r=t[o];switch(r.mode){case e.NUMERIC:n.push([r,{data:r.data,mode:e.ALPHANUMERIC,length:r.length},{data:r.data,mode:e.BYTE,length:r.length}]);break;case e.ALPHANUMERIC:n.push([r,{data:r.data,mode:e.BYTE,length:r.length}]);break;case e.KANJI:n.push([r,{data:r.data,mode:e.BYTE,length:u(r.data)}]);break;case e.BYTE:n.push([{data:r.data,mode:e.BYTE,length:u(r.data)}])}}return n}(f(n,c.isKanjiModeEnabled())),i=function(t,n){const o={},r={start:{}};let i=["start"];for(let s=0;s<t.length;s++){const a=t[s],c=[];for(let t=0;t<a.length;t++){const l=a[t],u=""+s+t;c.push(u),o[u]={node:l,lastCount:0},r[u]={};for(let t=0;t<i.length;t++){const s=i[t];o[s]&&o[s].node.mode===l.mode?(r[s][u]=h(o[s].lastCount+l.length,l.mode)-h(o[s].lastCount,l.mode),o[s].lastCount+=l.length):(o[s]&&(o[s].lastCount=l.length),r[s][u]=h(l.length,l.mode)+4+e.getCharCountIndicator(l.mode,n))}}i=c}for(let t=0;t<i.length;t++)r[i[t]].end=0;return{map:r,table:o}}(r,o),s=l.find_path(i.map,"start","end"),a=[];for(let t=1;t<s.length-1;t++)a.push(i.table[s[t]].node);return t.fromArray(function(t){return t.reduce(function(t,e){const n=t.length-1>=0?t[t.length-1]:null;return n&&n.mode===e.mode?(t[t.length-1].data+=e.data,t):(t.push(e),t)},[])}(a))},t.rawSplit=function(e){return t.fromArray(f(e,c.isKanjiModeEnabled()))}}(O);const ot=o,rt=a,it=l,st=d,at=f,ct=h,lt=p,ut=m,dt=I,ft=P,ht=q,gt=B,pt=O;function mt(t,e,n){const o=t.size,r=ht.getEncodedBits(e,n);let i,s;for(i=0;i<15;i++)s=1==(r>>i&1),i<6?t.set(i,8,s,!0):i<8?t.set(i+1,8,s,!0):t.set(o-15+i,8,s,!0),i<8?t.set(8,o-i-1,s,!0):i<9?t.set(8,15-i-1+1,s,!0):t.set(8,15-i-1,s,!0);t.set(o-8,8,1,!0)}function wt(t,e,n){const o=new it;n.forEach(function(e){o.put(e.mode.bit,4),o.put(e.getLength(),gt.getCharCountIndicator(e.mode,t)),e.write(o)});const r=8*(ot.getSymbolTotalCodewords(t)-ut.getTotalCodewordsCount(t,e));for(o.getLengthInBits()+4<=r&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(0);const i=(r-o.getLengthInBits())/8;for(let t=0;t<i;t++)o.put(t%2?17:236,8);return function(t,e,n){const o=ot.getSymbolTotalCodewords(e),r=ut.getTotalCodewordsCount(e,n),i=o-r,s=ut.getBlocksCount(e,n),a=o%s,c=s-a,l=Math.floor(o/s),u=Math.floor(i/s),d=u+1,f=l-u,h=new dt(f);let g=0;const p=new Array(s),m=new Array(s);let w=0;const y=new Uint8Array(t.buffer);for(let t=0;t<s;t++){const e=t<c?u:d;p[t]=y.slice(g,g+e),m[t]=h.encode(p[t]),g+=e,w=Math.max(w,e)}const E=new Uint8Array(o);let b,v,C=0;for(b=0;b<w;b++)for(v=0;v<s;v++)b<p[v].length&&(E[C++]=p[v][b]);for(b=0;b<f;b++)for(v=0;v<s;v++)E[C++]=m[v][b];return E}(o,t,e)}function yt(t,e,n,o){let r;if(Array.isArray(t))r=pt.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");{let o=e;if(!o){const e=pt.rawSplit(t);o=ft.getBestVersionForData(e,n)}r=pt.fromString(t,o||40)}}const i=ft.getBestVersionForData(r,n);if(!i)throw new Error("The amount of data is too big to be stored in a QR Code");if(e){if(e<i)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+i+".\n")}else e=i;const s=wt(e,n,r),a=ot.getSymbolSize(e),c=new st(a);return function(t,e){const n=t.size,o=ct.getPositions(e);for(let e=0;e<o.length;e++){const r=o[e][0],i=o[e][1];for(let e=-1;e<=7;e++)if(!(r+e<=-1||n<=r+e))for(let o=-1;o<=7;o++)i+o<=-1||n<=i+o||(e>=0&&e<=6&&(0===o||6===o)||o>=0&&o<=6&&(0===e||6===e)||e>=2&&e<=4&&o>=2&&o<=4?t.set(r+e,i+o,!0,!0):t.set(r+e,i+o,!1,!0))}}(c,e),function(t){const e=t.size;for(let n=8;n<e-8;n++){const e=n%2==0;t.set(n,6,e,!0),t.set(6,n,e,!0)}}(c),function(t,e){const n=at.getPositions(e);for(let e=0;e<n.length;e++){const o=n[e][0],r=n[e][1];for(let e=-2;e<=2;e++)for(let n=-2;n<=2;n++)-2===e||2===e||-2===n||2===n||0===e&&0===n?t.set(o+e,r+n,!0,!0):t.set(o+e,r+n,!1,!0)}}(c,e),mt(c,n,0),e>=7&&function(t,e){const n=t.size,o=ft.getEncodedBits(e);let r,i,s;for(let e=0;e<18;e++)r=Math.floor(e/3),i=e%3+n-8-3,s=1==(o>>e&1),t.set(r,i,s,!0),t.set(i,r,s,!0)}(c,e),function(t,e){const n=t.size;let o=-1,r=n-1,i=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!t.isReserved(r,a-n)){let o=!1;s<e.length&&(o=1==(e[s]>>>i&1)),t.set(r,a-n,o),i--,-1===i&&(s++,i=7)}if(r+=o,r<0||n<=r){r-=o,o=-o;break}}}(c,s),isNaN(o)&&(o=lt.getBestMask(c,mt.bind(null,c,n))),lt.applyMask(o,c),mt(c,n,o),{modules:c,version:e,errorCorrectionLevel:n,maskPattern:o,segments:r}}n.create=function(t,e){if(void 0===t||""===t)throw new Error("No input text");let n,o,r=rt.M;return void 0!==e&&(r=rt.from(e.errorCorrectionLevel,rt.M),n=ft.from(e.version),o=lt.from(e.maskPattern),e.toSJISFunc&&ot.setToSJISFunction(e.toSJISFunc)),yt(t,n,r,o)};var Et={},bt={};!function(t){function e(t){if("number"==typeof t&&(t=t.toString()),"string"!=typeof t)throw new Error("Color should be defined as hex string");let e=t.slice().replace("#","").split("");if(e.length<3||5===e.length||e.length>8)throw new Error("Invalid hex color: "+t);3!==e.length&&4!==e.length||(e=Array.prototype.concat.apply([],e.map(function(t){return[t,t]}))),6===e.length&&e.push("F","F");const n=parseInt(e.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+e.slice(0,6).join("")}}t.getOptions=function(t){t||(t={}),t.color||(t.color={});const n=void 0===t.margin||null===t.margin||t.margin<0?4:t.margin,o=t.width&&t.width>=21?t.width:void 0,r=t.scale||4;return{width:o,scale:o?4:r,margin:n,color:{dark:e(t.color.dark||"#000000ff"),light:e(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},t.getScale=function(t,e){return e.width&&e.width>=t+2*e.margin?e.width/(t+2*e.margin):e.scale},t.getImageWidth=function(e,n){const o=t.getScale(e,n);return Math.floor((e+2*n.margin)*o)},t.qrToImageData=function(e,n,o){const r=n.modules.size,i=n.modules.data,s=t.getScale(r,o),a=Math.floor((r+2*o.margin)*s),c=o.margin*s,l=[o.color.light,o.color.dark];for(let t=0;t<a;t++)for(let n=0;n<a;n++){let u=4*(t*a+n),d=o.color.light;if(t>=c&&n>=c&&t<a-c&&n<a-c){d=l[i[Math.floor((t-c)/s)*r+Math.floor((n-c)/s)]?1:0]}e[u++]=d.r,e[u++]=d.g,e[u++]=d.b,e[u]=d.a}}}(bt),function(t){const e=bt;t.render=function(t,n,o){let r=o,i=n;void 0!==r||n&&n.getContext||(r=n,n=void 0),n||(i=function(){try{return document.createElement("canvas")}catch(t){throw new Error("You need to specify a canvas element")}}()),r=e.getOptions(r);const s=e.getImageWidth(t.modules.size,r),a=i.getContext("2d"),c=a.createImageData(s,s);return e.qrToImageData(c.data,t,r),function(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+"px",e.style.width=n+"px"}(a,i,s),a.putImageData(c,0,0),i},t.renderToDataURL=function(e,n,o){let r=o;void 0!==r||n&&n.getContext||(r=n,n=void 0),r||(r={});const i=t.render(e,n,r),s=r.type||"image/png",a=r.rendererOpts||{};return i.toDataURL(s,a.quality)}}(Et);var vt={};const Ct=bt;function xt(t,e){const n=t.a/255,o=e+'="'+t.hex+'"';return n<1?o+" "+e+'-opacity="'+n.toFixed(2).slice(1)+'"':o}function Tt(t,e,n){let o=t+e;return void 0!==n&&(o+=" "+n),o}vt.render=function(t,e,n){const o=Ct.getOptions(e),r=t.modules.size,i=t.modules.data,s=r+2*o.margin,a=o.color.light.a?"<path "+xt(o.color.light,"fill")+' d="M0 0h'+s+"v"+s+'H0z"/>':"",c="<path "+xt(o.color.dark,"stroke")+' d="'+function(t,e,n){let o="",r=0,i=!1,s=0;for(let a=0;a<t.length;a++){const c=Math.floor(a%e),l=Math.floor(a/e);c||i||(i=!0),t[a]?(s++,a>0&&c>0&&t[a-1]||(o+=i?Tt("M",c+n,.5+l+n):Tt("m",r,0),r=0,i=!1),c+1<e&&t[a+1]||(o+=Tt("h",s),s=0)):r++}return o}(i,r,o.margin)+'"/>',l='viewBox="0 0 '+s+" "+s+'"',u='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+l+' shape-rendering="crispEdges">'+a+c+"</svg>\n";return"function"==typeof n&&n(null,u),u};const At=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},It=n,Pt=Et,Bt=vt;function Rt(t,e,n,o,r){const i=[].slice.call(arguments,1),s=i.length,a="function"==typeof i[s-1];if(!a&&!At())throw new Error("Callback required as last argument");if(!a){if(s<1)throw new Error("Too few arguments provided");return 1===s?(n=e,e=o=void 0):2!==s||e.getContext||(o=n,n=e,e=void 0),new Promise(function(r,i){try{const i=It.create(n,o);r(t(i,e,o))}catch(t){i(t)}})}if(s<2)throw new Error("Too few arguments provided");2===s?(r=n,n=e,e=o=void 0):3===s&&(e.getContext&&void 0===r?(r=o,o=void 0):(r=o,o=n,n=e,e=void 0));try{const i=It.create(n,o);r(null,t(i,e,o))}catch(t){r(t)}}function Mt(t,e){return new Promise((n,o)=>{const r=setTimeout(n,t);e&&e.addEventListener("abort",()=>{clearTimeout(r),o(new Error("Aborted"))})})}e.create=It.create,e.toCanvas=Rt.bind(null,Pt.render),e.toDataURL=Rt.bind(null,Pt.renderToDataURL),e.toString=Rt.bind(null,function(t,e,n){return Bt.render(t,n)});let St=class{constructor(t){this.activePolling=null,this.config={apiUrl:"https://api.onetapforms.com",clientId:t.clientId,clientSecret:t.clientSecret,apiKey:t.apiKey??t.clientId,debug:!1,...t};const e={...this.config,apiKey:this.config.apiKey?"[REDACTED]":void 0,clientSecret:this.config.clientSecret?"[REDACTED]":void 0};this.log("OneTap Forms SDK initialized",e)}buildAuthHeaders(){return this.config.clientId&&this.config.clientSecret?{"X-Client-ID":this.config.clientId,"X-Client-Secret":this.config.clientSecret}:this.config.apiKey?{"X-API-Key":this.config.apiKey}:null}async request(t){try{this.log("Creating request",t);const e=function(){if("undefined"==typeof window||"undefined"==typeof navigator)return"desktop";const t=navigator.userAgent||"";return/iPhone|iPad|iPod|Android|webOS|BlackBerry|Windows Phone/i.test(t)||/iPad|Android(?!.*Mobile)/i.test(t)?"mobile":"desktop"}(),n=t.mode||"auto";let o="qr";"auto"===n?o="mobile"===e?"redirect":"qr":"redirect"===n?o="redirect":"qr"===n&&(o="qr"),this.log("Effective mode:",o,"Device:",e);const r=await this.createRequest({clientId:this.config.clientId,schemaId:t.schemaId,purpose:t.purpose,returnUrl:t.returnUrl,requestedBundles:t.bundles,requestedFields:t.fields,mode:o,metadata:t.metadata,customization:t.customization});this.log("Request created:",r),"redirect"===o&&r.redirectUrl?this.handleRedirect(r.redirectUrl):("qr"===o&&r.qrCodeData||r.qrCodeData)&&await this.handleQR(r,t)}catch(e){throw this.log("Error creating request:",e),t.onError&&t.onError(e instanceof Error?e:new Error("Unknown error")),e}}handleRedirect(t){this.log("Redirecting to:",t),window.location.href=t}async handleQR(t,n){const o=await async function(t){try{return await e.toDataURL(t,{errorCorrectionLevel:"M",margin:2,width:300,color:{dark:"#000000",light:"#FFFFFF"}})}catch(t){throw console.error("QR code generation failed:",t),new Error("Failed to generate QR code")}}(t.qrCodeData);this.log("QR code generated"),n.onQRReady&&n.onQRReady(o),this.activePolling=new AbortController;try{const e=await async function(t,e,n={}){const{interval:o=2e3,timeout:r=18e4,signal:i,onStatusChange:s}=n,a=Date.now();for(;;){if(null==i?void 0:i.aborted)throw new Error("Polling cancelled");if(Date.now()-a>r)throw new Error("Polling timeout");try{const n=await fetch(`${t}/api/onetapforms/requests/${e}/status`,{signal:i});if(!n.ok)throw new Error(`Status check failed: ${n.statusText}`);const r=await n.json();if(s&&s(r),r.approved||"completed"===r.status||"approved"===r.status||"denied"===r.status||"expired"===r.status)return r;await Mt(o,i)}catch(t){if(t instanceof Error&&"AbortError"===t.name)throw t;console.error("Polling error:",t),await Mt(o,i)}}}(this.config.apiUrl,t.requestId,{signal:this.activePolling.signal,onStatusChange:t=>{this.log("Status update:",t)}});(e.approved||"completed"===e.status||"approved"===e.status)&&e.exchangeToken&&(this.log("Request approved, token received"),n.onComplete&&n.onComplete({token:e.exchangeToken,requestId:t.requestId}))}catch(t){if(t instanceof Error&&"AbortError"===t.name)return void this.log("Polling cancelled");this.log("Polling error:",t),n.onError&&n.onError(t instanceof Error?t:new Error("Polling failed"))}}cancelPolling(){this.activePolling&&(this.activePolling.abort(),this.activePolling=null)}handleCallback(){const t=new URLSearchParams(window.location.search),e=t.get("token"),n=t.get("requestId");return e&&n?(this.log("Callback received with token"),{token:e,requestId:n}):null}async exchangeToken(t){this.log("Exchanging token (Note: This should be done server-side!)");const e=this.buildAuthHeaders();if(!e)throw new Error("Client credentials are required");const n=await fetch(`${this.config.apiUrl}/api/onetapforms/exchange`,{method:"POST",headers:{"Content-Type":"application/json",...e},body:JSON.stringify({token:t})});if(!n.ok)throw new Error(`Token exchange failed: ${n.statusText}`);return(await n.json()).data}async createRequest(t){const e=this.buildAuthHeaders();if(!e)throw new Error("Client credentials are required");const n=await fetch(`${this.config.apiUrl}/api/onetapforms/requests`,{method:"POST",headers:{"Content-Type":"application/json",...e},body:JSON.stringify(t)});if(!n.ok){const t=await n.json();throw new Error(t.message||"Failed to create request")}return n.json()}log(t,...e){this.config.debug&&console.log(`[OneTapForms] ${t}`,...e)}};class kt{constructor(t){this.instance=new St(t)}async request(t){return this.instance.request(t)}cancelPolling(){return this.instance.cancelPolling()}handleCallback(){return this.instance.handleCallback()}async exchangeToken(t){return this.instance.exchangeToken(t)}getAppDownloadUrl(){return"https://apps.apple.com/app/onetapforms"}showDownloadPrompt(t){if("undefined"==typeof window)return;const e=t?.title||"Download OneTapForms for Faster Form Completion",n=t?.message||"Complete forms in seconds with one tap! Download the OneTapForms app to instantly fill forms using Face ID/Touch ID.",o=t?.buttonText||"Download App",r=this.getAppDownloadUrl(),i=document.createElement("div");i.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n ";const s=document.createElement("div");s.style.cssText="\n background: white;\n padding: 24px;\n border-radius: 12px;\n max-width: 400px;\n margin: 20px;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n ";const a=document.createElement("h3");a.textContent=e,a.style.cssText="\n margin: 0 0 12px 0;\n font-size: 20px;\n font-weight: 600;\n color: #1a1a1a;\n ";const c=document.createElement("p");c.textContent=n,c.style.cssText="\n margin: 0 0 20px 0;\n font-size: 14px;\n color: #666;\n line-height: 1.5;\n ";const l=document.createElement("div");l.style.cssText="\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n ";const u=document.createElement("button");u.textContent="Maybe Later",u.style.cssText="\n padding: 10px 20px;\n border: 1px solid #ddd;\n background: white;\n border-radius: 6px;\n cursor: pointer;\n font-size: 14px;\n color: #666;\n ",u.onclick=()=>{document.body.removeChild(i),t?.onDismiss&&t.onDismiss()};const d=document.createElement("button");d.textContent=o,d.style.cssText="\n padding: 10px 20px;\n border: none;\n background: #007AFF;\n color: white;\n border-radius: 6px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n ",d.onclick=()=>{window.open(r,"_blank"),document.body.removeChild(i)},l.appendChild(u),l.appendChild(d),s.appendChild(a),s.appendChild(c),s.appendChild(l),i.appendChild(s),i.onclick=e=>{e.target===i&&(document.body.removeChild(i),t?.onDismiss&&t.onDismiss())},document.body.appendChild(i)}}var Nt=Object.freeze({__proto__:null,OneTapForms:kt,default:kt});function Lt(t){!function(){if("undefined"==typeof document)return;if(document.getElementById("onetapforms-styles"))return;const t=document.createElement("style");t.id="onetapforms-styles",t.textContent="\n .onetapforms-modal {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.6);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n .onetapforms-modal.active {\n opacity: 1;\n }\n .onetapforms-modal-content {\n background: white;\n padding: 32px;\n border-radius: 16px;\n max-width: 360px;\n width: 90%;\n text-align: center;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);\n transform: scale(0.95);\n transition: transform 0.2s ease;\n }\n .onetapforms-modal.active .onetapforms-modal-content {\n transform: scale(1);\n }\n .onetapforms-modal-title {\n margin: 0 0 8px 0;\n font-size: 20px;\n font-weight: 600;\n color: #1a1a1a;\n }\n .onetapforms-modal-subtitle {\n margin: 0 0 24px 0;\n font-size: 14px;\n color: #666;\n }\n .onetapforms-qr-container {\n background: #f5f5f5;\n border-radius: 12px;\n padding: 20px;\n margin-bottom: 20px;\n }\n .onetapforms-qr-container img {\n max-width: 100%;\n height: auto;\n }\n .onetapforms-status {\n font-size: 13px;\n color: #888;\n margin-bottom: 16px;\n }\n .onetapforms-close-btn {\n background: #f0f0f0;\n border: none;\n padding: 10px 24px;\n border-radius: 8px;\n cursor: pointer;\n font-size: 14px;\n color: #333;\n transition: background 0.15s;\n }\n .onetapforms-close-btn:hover {\n background: #e0e0e0;\n }\n .onetapforms-spinner {\n width: 200px;\n height: 200px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .onetapforms-spinner::after {\n content: '';\n width: 40px;\n height: 40px;\n border: 3px solid #e0e0e0;\n border-top-color: #007AFF;\n border-radius: 50%;\n animation: onetapforms-spin 0.8s linear infinite;\n }\n @keyframes onetapforms-spin {\n to { transform: rotate(360deg); }\n }\n",document.head.appendChild(t)}();const e=document.createElement("div");e.className="onetapforms-modal",e.innerHTML=`\n <div class="onetapforms-modal-content">\n <h3 class="onetapforms-modal-title">${t.title||"Scan to Complete"}</h3>\n <p class="onetapforms-modal-subtitle">${t.subtitle||"Scan with your OneTapForms app"}</p>\n <div class="onetapforms-qr-container">\n <div class="onetapforms-spinner"></div>\n </div>\n <p class="onetapforms-status">Waiting for scan...</p>\n <button class="onetapforms-close-btn">Cancel</button>\n </div>\n `;const n=e.querySelector(".onetapforms-qr-container"),o=e.querySelector(".onetapforms-status"),r=e.querySelector(".onetapforms-close-btn"),i=()=>{e.classList.remove("active"),setTimeout(()=>e.remove(),200),t.onClose&&t.onClose()};return r.addEventListener("click",i),e.addEventListener("click",t=>{t.target===e&&i()}),document.body.appendChild(e),requestAnimationFrame(()=>e.classList.add("active")),{setQR:t=>{n.innerHTML=`<img src="${t}" alt="QR Code" />`},setStatus:t=>{o.textContent=t},close:i}}function Ft(){if("undefined"==typeof document)return;document.querySelectorAll("[data-onetapforms]").forEach(t=>{if("true"===t.dataset.onetapformsInit)return;t.dataset.onetapformsInit="true";const e=t.dataset.clientId,n=t.dataset.clientSecret,o=t.dataset.purpose||"Complete form",r=t.dataset.bundles?.split(",").map(t=>t.trim())||["basic"],i=t.dataset.formId,s=t.dataset.apiUrl;e?Promise.resolve().then(function(){return Nt}).then(({OneTapForms:a})=>{const c=new a({clientId:e,clientSecret:n,apiUrl:s});t.addEventListener("click",async e=>{e.preventDefault();let n=null;try{await c.request({purpose:o,bundles:r,onQRReady:t=>{n=Lt({title:"Scan with OneTapForms",subtitle:o,onClose:()=>c.cancelPolling()}),n.setQR(t)},onComplete:e=>{n&&(n.setStatus("Complete!"),setTimeout(()=>n?.close(),500));const o=new CustomEvent("onetapforms:complete",{bubbles:!0,detail:e});if(t.dispatchEvent(o),i){const t=document.getElementById(i);if(t){let n=t.querySelector('input[name="onetapforms_token"]');n||(n=document.createElement("input"),n.type="hidden",n.name="onetapforms_token",t.appendChild(n)),n.value=e.token}}},onError:e=>{n&&n.close();const o=new CustomEvent("onetapforms:error",{bubbles:!0,detail:{error:e}});t.dispatchEvent(o)}})}catch(e){console.error("[OneTapForms] Request failed:",e);const n=new CustomEvent("onetapforms:error",{bubbles:!0,detail:{error:e}});t.dispatchEvent(n)}})}):console.error("[OneTapForms] Missing data-client-id attribute")})}if("undefined"!=typeof window&&"undefined"!=typeof document){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Ft):Ft();const t=new MutationObserver(t=>{for(const e of t)e.addedNodes.length&&Ft()});document.body?t.observe(document.body,{childList:!0,subtree:!0}):document.addEventListener("DOMContentLoaded",()=>{t.observe(document.body,{childList:!0,subtree:!0})})}t.OneTapForms=kt,t.collectMappedFields=function(t=document){return"undefined"==typeof document?[]:Array.from(t.querySelectorAll("[data-otf-field]")).map(t=>{const e=t.getAttribute("data-otf-field");return e?{name:e,element:t}:null}).filter(t=>Boolean(t))},t.default=kt,t.initWidgets=Ft,t.otfFieldAttr=function(t){return{"data-otf-field":t}},t.previewAutofill=async function(t){const e=t.apiUrl||"https://api.createlex.com/api/onetapforms/autofill/preview",n={fields:t.fields||null,formTemplate:t.formTemplate},o={"Content-Type":"application/json"};t.token&&(o.Authorization=`Bearer ${t.token}`),t.userId&&(o["x-user-id"]=t.userId);const r=await fetch(e,{method:"POST",headers:o,body:JSON.stringify(n)});if(!r.ok){const t=await r.text();throw new Error(`Autofill preview failed: ${r.status} ${t}`)}return r.json()},t.showQRModal=Lt,Object.defineProperty(t,"__esModule",{value:!0})}),"undefined"!=typeof window&&(window.OneTapForms=window.OneTapForms.OneTapForms||window.OneTapForms);
|
|
2
2
|
//# sourceMappingURL=onetapforms.umd.min.js.map
|