sunuid-sdk 1.0.25 → 1.0.27

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.
@@ -1,4 +1,11 @@
1
- !function(t,e,n,r,i,o){"use strict";function s(t,e,n,r,i,o,s){try{var a=t[o](s),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(r,i)}function a(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function a(t){s(o,r,i,a,c,"next",t)}function c(t){s(o,r,i,a,c,"throw",t)}a(void 0)})}}function c(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,p(r.key),r)}}function h(t,e,n){return(e=p(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function u(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?l(Object(n),!0).forEach(function(e){h(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function f(){
1
+ !function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function t(e,t,n,i,r,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(i,r)}function n(e){return function(){var n=this,i=arguments;return new Promise(function(r,o){var s=e.apply(n,i);function a(e){t(s,r,o,a,c,"next",e)}function c(e){t(s,r,o,a,c,"throw",e)}a(void 0)})}}function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,d(i.key),i)}}function r(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(){
2
2
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
3
- var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var c=r&&r.prototype instanceof a?r:a,h=Object.create(c.prototype);return d(h,"_invoke",function(n,r,i){var o,a,c,h=0,l=i||[],u=!1,f={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,n){return o=e,a=0,c=t,f.n=n,s}};function d(n,r){for(a=n,c=r,e=0;!u&&h&&!i&&e<l.length;e++){var i,o=l[e],d=f.p,p=o[2];n>3?(i=p===r)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=d&&((i=n<2&&d<o[1])?(a=0,f.v=r,f.n=o[1]):d<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,f.n=p,a=0))}if(i||n>1)return s;throw u=!0,r}return function(i,l,p){if(h>1)throw TypeError("Generator is already running");for(u&&1===l&&d(l,p),a=l,c=p;(e=a<2?t:c)||!u;){o||(a?a<3?(a>1&&(f.n=-1),d(a,c)):f.n=c:f.v=c);try{if(h=2,o){if(a||(i="next"),e=o[i]){if(!(e=e.call(o,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=t}else if((e=(u=f.n<0)?c:n.call(r,f))!==s)break}catch(e){o=t,a=1,c=e}finally{h=1}}return{value:e,done:u}}}(n,i,o),!0),h}var s={};function a(){}function c(){}function h(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(d(e={},r,function(){return this}),e),u=h.prototype=a.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,d(t,i,"GeneratorFunction")),t.prototype=Object.create(u),t}return c.prototype=h,d(u,"constructor",h),d(h,"constructor",c),c.displayName="GeneratorFunction",d(h,i,"GeneratorFunction"),d(u),d(u,i,"Generator"),d(u,r,function(){return this}),d(u,"toString",function(){return"[object Generator]"}),(f=function(){return{w:o,m:p}})()}function d(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}d=function(t,e,n,r){function o(e,n){d(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},d(t,e,n,r)}function p(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function g(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var _={},y=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},m={},w={};let b;const v=[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];w.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},w.getSymbolTotalCodewords=function(t){return v[t]},w.getBCHDigit=function(t){let e=0;for(;0!==t;)e++,t>>>=1;return e},w.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');b=t},w.isKanjiModeEnabled=function(){return void 0!==b},w.toSJIS=function(t){return b(t)};var E,T={};function I(){this.buffer=[],this.length=0}(E=T).L={bit:1},E.M={bit:0},E.Q={bit:3},E.H={bit:2},E.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},E.from=function(t,e){if(E.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 E.L;case"m":case"medium":return E.M;case"q":case"quartile":return E.Q;case"h":case"high":return E.H;default:throw new Error("Unknown EC Level: "+t)}}(t)}catch(t){return e}},I.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 C=I;function k(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)}k.prototype.set=function(t,e,n,r){const i=t*this.size+e;this.data[i]=n,r&&(this.reservedBit[i]=!0)},k.prototype.get=function(t,e){return this.data[t*this.size+e]},k.prototype.xor=function(t,e,n){this.data[t*this.size+e]^=n},k.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]};var A=k,R={};!function(t){const e=w.getSymbolSize;t.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,r=e(t),i=145===r?26:2*Math.ceil((r-13)/(2*n-2)),o=[r-7];for(let t=1;t<n-1;t++)o[t]=o[t-1]-i;return o.push(6),o.reverse()},t.getPositions=function(e){const n=[],r=t.getRowColCoords(e),i=r.length;for(let t=0;t<i;t++)for(let e=0;e<i;e++)0===t&&0===e||0===t&&e===i-1||t===i-1&&0===e||n.push([r[t],r[e]]);return n}}(R);var P={};const L=w.getSymbolSize;P.getPositions=function(t){const e=L(t);return[[0,0],[e-7,0],[0,e-7]]};var S={};!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,r=40,i=10;function o(e,n,r){switch(e){case t.Patterns.PATTERN000:return(n+r)%2==0;case t.Patterns.PATTERN001:return n%2==0;case t.Patterns.PATTERN010:return r%3==0;case t.Patterns.PATTERN011:return(n+r)%3==0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case t.Patterns.PATTERN101:return n*r%2+n*r%3==0;case t.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case t.Patterns.PATTERN111:return(n*r%3+(n+r)%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 r=0,i=0,o=0,s=null,a=null;for(let c=0;c<n;c++){i=o=0,s=a=null;for(let h=0;h<n;h++){let n=t.get(c,h);n===s?i++:(i>=5&&(r+=e+(i-5)),s=n,i=1),n=t.get(h,c),n===a?o++:(o>=5&&(r+=e+(o-5)),a=n,o=1)}i>=5&&(r+=e+(i-5)),o>=5&&(r+=e+(o-5))}return r},t.getPenaltyN2=function(t){const e=t.size;let r=0;for(let n=0;n<e-1;n++)for(let i=0;i<e-1;i++){const e=t.get(n,i)+t.get(n,i+1)+t.get(n+1,i)+t.get(n+1,i+1);4!==e&&0!==e||r++}return r*n},t.getPenaltyN3=function(t){const e=t.size;let n=0,i=0,o=0;for(let r=0;r<e;r++){i=o=0;for(let s=0;s<e;s++)i=i<<1&2047|t.get(r,s),s>=10&&(1488===i||93===i)&&n++,o=o<<1&2047|t.get(s,r),s>=10&&(1488===o||93===o)&&n++}return n*r},t.getPenaltyN4=function(t){let e=0;const n=t.data.length;for(let r=0;r<n;r++)e+=t.data[r];return Math.abs(Math.ceil(100*e/n/5)-10)*i},t.applyMask=function(t,e){const n=e.size;for(let r=0;r<n;r++)for(let i=0;i<n;i++)e.isReserved(i,r)||e.xor(i,r,o(t,i,r))},t.getBestMask=function(e,n){const r=Object.keys(t.Patterns).length;let i=0,o=1/0;for(let s=0;s<r;s++){n(s),t.applyMask(s,e);const r=t.getPenaltyN1(e)+t.getPenaltyN2(e)+t.getPenaltyN3(e)+t.getPenaltyN4(e);t.applyMask(s,e),r<o&&(o=r,i=s)}return i}}(S);var O={};const x=T,B=[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],M=[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];O.getBlocksCount=function(t,e){switch(e){case x.L:return B[4*(t-1)+0];case x.M:return B[4*(t-1)+1];case x.Q:return B[4*(t-1)+2];case x.H:return B[4*(t-1)+3];default:return}},O.getTotalCodewordsCount=function(t,e){switch(e){case x.L:return M[4*(t-1)+0];case x.M:return M[4*(t-1)+1];case x.Q:return M[4*(t-1)+2];case x.H:return M[4*(t-1)+3];default:return}};var D={},N={};const U=new Uint8Array(512),Y=new Uint8Array(256);!function(){let t=1;for(let e=0;e<255;e++)U[e]=t,Y[t]=e,t<<=1,256&t&&(t^=285);for(let t=255;t<512;t++)U[t]=U[t-255]}(),N.log=function(t){if(t<1)throw new Error("log("+t+")");return Y[t]},N.exp=function(t){return U[t]},N.mul=function(t,e){return 0===t||0===e?0:U[Y[t]+Y[e]]},function(t){const e=N;t.mul=function(t,n){const r=new Uint8Array(t.length+n.length-1);for(let i=0;i<t.length;i++)for(let o=0;o<n.length;o++)r[i+o]^=e.mul(t[i],n[o]);return r},t.mod=function(t,n){let r=new Uint8Array(t);for(;r.length-n.length>=0;){const t=r[0];for(let i=0;i<n.length;i++)r[i]^=e.mul(n[i],t);let i=0;for(;i<r.length&&0===r[i];)i++;r=r.slice(i)}return r},t.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=t.mul(r,new Uint8Array([1,e.exp(i)]));return r}}(D);const F=D;function H(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}H.prototype.initialize=function(t){this.degree=t,this.genPoly=F.generateECPolynomial(this.degree)},H.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=F.mod(e,this.genPoly),r=this.degree-n.length;if(r>0){const t=new Uint8Array(this.degree);return t.set(n,r),t}return n};var q=H,z={},j={},W={isValid:function(t){return!isNaN(t)&&t>=1&&t<=40}},Q={};const G="[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 J="(?:(?![A-Z0-9 $%*+\\-./:]|"+K+")(?:.|[\r\n]))+";Q.KANJI=new RegExp(K,"g"),Q.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Q.BYTE=new RegExp(J,"g"),Q.NUMERIC=new RegExp(G,"g"),Q.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const V=new RegExp("^"+K+"$"),$=new RegExp("^"+G+"$"),Z=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Q.testKanji=function(t){return V.test(t)},Q.testNumeric=function(t){return $.test(t)},Q.testAlphanumeric=function(t){return Z.test(t)},function(t){const e=W,n=Q;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}}}(j),function(t){const e=w,n=O,r=T,i=j,o=W,s=e.getBCHDigit(7973);function a(t,e){return i.getCharCountIndicator(t,e)+4}function c(t,e){let n=0;return t.forEach(function(t){const r=a(t.mode,e);n+=r+t.getBitsLength()}),n}t.from=function(t,e){return o.isValid(t)?parseInt(t,10):e},t.getCapacity=function(t,r,s){if(!o.isValid(t))throw new Error("Invalid QR Code version");void 0===s&&(s=i.BYTE);const c=8*(e.getSymbolTotalCodewords(t)-n.getTotalCodewordsCount(t,r));if(s===i.MIXED)return c;const h=c-a(s,t);switch(s){case i.NUMERIC:return Math.floor(h/10*3);case i.ALPHANUMERIC:return Math.floor(h/11*2);case i.KANJI:return Math.floor(h/13);case i.BYTE:default:return Math.floor(h/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 r=1;r<=40;r++)if(c(e,r)<=t.getCapacity(r,n,i.MIXED))return r}(e,s);if(0===e.length)return 1;o=e[0]}else o=e;return function(e,n,r){for(let i=1;i<=40;i++)if(n<=t.getCapacity(i,r,e))return i}(o.mode,o.getLength(),s)},t.getEncodedBits=function(t){if(!o.isValid(t)||t<7)throw new Error("Invalid QR Code version");let n=t<<12;for(;e.getBCHDigit(n)-s>=0;)n^=7973<<e.getBCHDigit(n)-s;return t<<12|n}}(z);var X={};const tt=w,et=tt.getBCHDigit(1335);X.getEncodedBits=function(t,e){const n=t.bit<<3|e;let r=n<<10;for(;tt.getBCHDigit(r)-et>=0;)r^=1335<<tt.getBCHDigit(r)-et;return 21522^(n<<10|r)};var nt={};const rt=j;function it(t){this.mode=rt.NUMERIC,this.data=t.toString()}it.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},it.prototype.getLength=function(){return this.data.length},it.prototype.getBitsLength=function(){return it.getBitsLength(this.data.length)},it.prototype.write=function(t){let e,n,r;for(e=0;e+3<=this.data.length;e+=3)n=this.data.substr(e,3),r=parseInt(n,10),t.put(r,10);const i=this.data.length-e;i>0&&(n=this.data.substr(e),r=parseInt(n,10),t.put(r,3*i+1))};var ot=it;const st=j,at=["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 ct(t){this.mode=st.ALPHANUMERIC,this.data=t}ct.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},ct.prototype.getLength=function(){return this.data.length},ct.prototype.getBitsLength=function(){return ct.getBitsLength(this.data.length)},ct.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let n=45*at.indexOf(this.data[e]);n+=at.indexOf(this.data[e+1]),t.put(n,11)}this.data.length%2&&t.put(at.indexOf(this.data[e]),6)};var ht=ct;const lt=j;function ut(t){this.mode=lt.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}ut.getBitsLength=function(t){return 8*t},ut.prototype.getLength=function(){return this.data.length},ut.prototype.getBitsLength=function(){return ut.getBitsLength(this.data.length)},ut.prototype.write=function(t){for(let e=0,n=this.data.length;e<n;e++)t.put(this.data[e],8)};var ft=ut;const dt=j,pt=w;function gt(t){this.mode=dt.KANJI,this.data=t}gt.getBitsLength=function(t){return 13*t},gt.prototype.getLength=function(){return this.data.length},gt.prototype.getBitsLength=function(){return gt.getBitsLength(this.data.length)},gt.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let n=pt.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 _t=gt,yt={exports:{}};!function(t){var e={single_source_shortest_paths:function(t,n,r){var i={},o={};o[n]=0;var s,a,c,h,l,u,f,d=e.PriorityQueue.make();for(d.push(n,0);!d.empty();)for(c in a=(s=d.pop()).value,h=s.cost,l=t[a]||{})l.hasOwnProperty(c)&&(u=h+l[c],f=o[c],(void 0===o[c]||f>u)&&(o[c]=u,d.push(c,u),i[c]=a));if(void 0!==r&&void 0===o[r]){var p=["Could not find a path from ",n," to ",r,"."].join("");throw new Error(p)}return i},extract_shortest_path_from_predecessor_list:function(t,e){for(var n=[],r=e;r;)n.push(r),t[r],r=t[r];return n.reverse(),n},find_path:function(t,n,r){var i=e.single_source_shortest_paths(t,n,r);return e.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(t){var n,r=e.PriorityQueue,i={};for(n in t=t||{},r)r.hasOwnProperty(n)&&(i[n]=r[n]);return i.queue=[],i.sorter=t.sorter||r.default_sorter,i},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}(yt);var mt=yt.exports;!function(t){const e=j,n=ot,r=ht,i=ft,o=_t,s=Q,a=w,c=mt;function h(t){return unescape(encodeURIComponent(t)).length}function l(t,e,n){const r=[];let i;for(;null!==(i=t.exec(n));)r.push({data:i[0],index:i.index,mode:e,length:i[0].length});return r}function u(t){const n=l(s.NUMERIC,e.NUMERIC,t),r=l(s.ALPHANUMERIC,e.ALPHANUMERIC,t);let i,o;a.isKanjiModeEnabled()?(i=l(s.BYTE,e.BYTE,t),o=l(s.KANJI,e.KANJI,t)):(i=l(s.BYTE_KANJI,e.BYTE,t),o=[]);return n.concat(r,i,o).sort(function(t,e){return t.index-e.index}).map(function(t){return{data:t.data,mode:t.mode,length:t.length}})}function f(t,s){switch(s){case e.NUMERIC:return n.getBitsLength(t);case e.ALPHANUMERIC:return r.getBitsLength(t);case e.KANJI:return o.getBitsLength(t);case e.BYTE:return i.getBitsLength(t)}}function d(t,s){let c;const h=e.getBestModeForData(t);if(c=e.from(s,h),c!==e.BYTE&&c.bit<h.bit)throw new Error('"'+t+'" cannot be encoded with mode '+e.toString(c)+".\n Suggested mode is: "+e.toString(h));switch(c!==e.KANJI||a.isKanjiModeEnabled()||(c=e.BYTE),c){case e.NUMERIC:return new n(t);case e.ALPHANUMERIC:return new r(t);case e.KANJI:return new o(t);case e.BYTE:return new i(t)}}t.fromArray=function(t){return t.reduce(function(t,e){return"string"==typeof e?t.push(d(e,null)):e.data&&t.push(d(e.data,e.mode)),t},[])},t.fromString=function(n,r){const i=function(t){const n=[];for(let r=0;r<t.length;r++){const i=t[r];switch(i.mode){case e.NUMERIC:n.push([i,{data:i.data,mode:e.ALPHANUMERIC,length:i.length},{data:i.data,mode:e.BYTE,length:i.length}]);break;case e.ALPHANUMERIC:n.push([i,{data:i.data,mode:e.BYTE,length:i.length}]);break;case e.KANJI:n.push([i,{data:i.data,mode:e.BYTE,length:h(i.data)}]);break;case e.BYTE:n.push([{data:i.data,mode:e.BYTE,length:h(i.data)}])}}return n}(u(n,a.isKanjiModeEnabled())),o=function(t,n){const r={},i={start:{}};let o=["start"];for(let s=0;s<t.length;s++){const a=t[s],c=[];for(let t=0;t<a.length;t++){const h=a[t],l=""+s+t;c.push(l),r[l]={node:h,lastCount:0},i[l]={};for(let t=0;t<o.length;t++){const s=o[t];r[s]&&r[s].node.mode===h.mode?(i[s][l]=f(r[s].lastCount+h.length,h.mode)-f(r[s].lastCount,h.mode),r[s].lastCount+=h.length):(r[s]&&(r[s].lastCount=h.length),i[s][l]=f(h.length,h.mode)+4+e.getCharCountIndicator(h.mode,n))}}o=c}for(let t=0;t<o.length;t++)i[o[t]].end=0;return{map:i,table:r}}(i,r),s=c.find_path(o.map,"start","end"),l=[];for(let t=1;t<s.length-1;t++)l.push(o.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)},[])}(l))},t.rawSplit=function(e){return t.fromArray(u(e,a.isKanjiModeEnabled()))}}(nt);const wt=w,bt=T,vt=C,Et=A,Tt=R,It=P,Ct=S,kt=O,At=q,Rt=z,Pt=X,Lt=j,St=nt;function Ot(t,e,n){const r=t.size,i=Pt.getEncodedBits(e,n);let o,s;for(o=0;o<15;o++)s=1==(i>>o&1),o<6?t.set(o,8,s,!0):o<8?t.set(o+1,8,s,!0):t.set(r-15+o,8,s,!0),o<8?t.set(8,r-o-1,s,!0):o<9?t.set(8,15-o-1+1,s,!0):t.set(8,15-o-1,s,!0);t.set(r-8,8,1,!0)}function xt(t,e,n){const r=new vt;n.forEach(function(e){r.put(e.mode.bit,4),r.put(e.getLength(),Lt.getCharCountIndicator(e.mode,t)),e.write(r)});const i=8*(wt.getSymbolTotalCodewords(t)-kt.getTotalCodewordsCount(t,e));for(r.getLengthInBits()+4<=i&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);const o=(i-r.getLengthInBits())/8;for(let t=0;t<o;t++)r.put(t%2?17:236,8);return function(t,e,n){const r=wt.getSymbolTotalCodewords(e),i=kt.getTotalCodewordsCount(e,n),o=r-i,s=kt.getBlocksCount(e,n),a=r%s,c=s-a,h=Math.floor(r/s),l=Math.floor(o/s),u=l+1,f=h-l,d=new At(f);let p=0;const g=new Array(s),_=new Array(s);let y=0;const m=new Uint8Array(t.buffer);for(let t=0;t<s;t++){const e=t<c?l:u;g[t]=m.slice(p,p+e),_[t]=d.encode(g[t]),p+=e,y=Math.max(y,e)}const w=new Uint8Array(r);let b,v,E=0;for(b=0;b<y;b++)for(v=0;v<s;v++)b<g[v].length&&(w[E++]=g[v][b]);for(b=0;b<f;b++)for(v=0;v<s;v++)w[E++]=_[v][b];return w}(r,t,e)}function Bt(t,e,n,r){let i;if(Array.isArray(t))i=St.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");{let r=e;if(!r){const e=St.rawSplit(t);r=Rt.getBestVersionForData(e,n)}i=St.fromString(t,r||40)}}const o=Rt.getBestVersionForData(i,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(e){if(e<o)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+o+".\n")}else e=o;const s=xt(e,n,i),a=wt.getSymbolSize(e),c=new Et(a);return function(t,e){const n=t.size,r=It.getPositions(e);for(let e=0;e<r.length;e++){const i=r[e][0],o=r[e][1];for(let e=-1;e<=7;e++)if(!(i+e<=-1||n<=i+e))for(let r=-1;r<=7;r++)o+r<=-1||n<=o+r||(e>=0&&e<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===e||6===e)||e>=2&&e<=4&&r>=2&&r<=4?t.set(i+e,o+r,!0,!0):t.set(i+e,o+r,!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=Tt.getPositions(e);for(let e=0;e<n.length;e++){const r=n[e][0],i=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(r+e,i+n,!0,!0):t.set(r+e,i+n,!1,!0)}}(c,e),Ot(c,n,0),e>=7&&function(t,e){const n=t.size,r=Rt.getEncodedBits(e);let i,o,s;for(let e=0;e<18;e++)i=Math.floor(e/3),o=e%3+n-8-3,s=1==(r>>e&1),t.set(i,o,s,!0),t.set(o,i,s,!0)}(c,e),function(t,e){const n=t.size;let r=-1,i=n-1,o=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(i,a-n)){let r=!1;s<e.length&&(r=1==(e[s]>>>o&1)),t.set(i,a-n,r),o--,-1===o&&(s++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}(c,s),isNaN(r)&&(r=Ct.getBestMask(c,Ot.bind(null,c,n))),Ct.applyMask(r,c),Ot(c,n,r),{modules:c,version:e,errorCorrectionLevel:n,maskPattern:r,segments:i}}m.create=function(t,e){if(void 0===t||""===t)throw new Error("No input text");let n,r,i=bt.M;return void 0!==e&&(i=bt.from(e.errorCorrectionLevel,bt.M),n=Rt.from(e.version),r=Ct.from(e.maskPattern),e.toSJISFunc&&wt.setToSJISFunction(e.toSJISFunc)),Bt(t,n,i,r)};var Mt={},Dt={},Nt={exports:{}},Ut={exports:{}};let Yt=e,Ft=n,Ht=Ut.exports=function(){Ft.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};Yt.inherits(Ht,Ft),Ht.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}.bind(this))},Ht.prototype.write=function(t,e){if(!this.writable)return this.emit("error",new Error("Stream not writable")),!1;let n;return n=Buffer.isBuffer(t)?t:Buffer.from(t,e||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused},Ht.prototype.end=function(t,e){t&&this.write(t,e),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},Ht.prototype.destroySoon=Ht.prototype.end,Ht.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("Unexpected end of input")),this.destroy()},Ht.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},Ht.prototype._processReadAllowingLess=function(t){this._reads.shift();let e=this._buffers[0];e.length>t.length?(this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length))):(this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e))},Ht.prototype._processRead=function(t){this._reads.shift();let e=0,n=0,r=Buffer.alloc(t.length);for(;e<t.length;){let i=this._buffers[n++],o=Math.min(i.length,t.length-e);i.copy(r,e,0,o),e+=o,o!==i.length&&(this._buffers[--n]=i.slice(o))}n>0&&this._buffers.splice(0,n),this._buffered-=t.length,t.func.call(this,r)},Ht.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else{if(!(this._buffered>=t.length))break;this._processRead(t)}}this._buffers&&!this.writable&&this._end()}catch(t){this.emit("error",t)}};var qt=Ut.exports,zt={exports:{}},jt={exports:{}},Wt={};let Qt=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];Wt.getImagePasses=function(t,e){let n=[],r=t%8,i=e%8,o=(t-r)/8,s=(e-i)/8;for(let t=0;t<Qt.length;t++){let e=Qt[t],a=o*e.x.length,c=s*e.y.length;for(let t=0;t<e.x.length&&e.x[t]<r;t++)a++;for(let t=0;t<e.y.length&&e.y[t]<i;t++)c++;a>0&&c>0&&n.push({width:a,height:c,index:t})}return n},Wt.getInterlaceIterator=function(t){return function(e,n,r){let i=e%Qt[r].x.length,o=(e-i)/Qt[r].x.length*8+Qt[r].x[i],s=n%Qt[r].y.length;return 4*o+((n-s)/Qt[r].y.length*8+Qt[r].y[s])*t*4}};var Gt=function(t,e,n){let r=t+e-n,i=Math.abs(r-t),o=Math.abs(r-e),s=Math.abs(r-n);return i<=o&&i<=s?t:o<=s?e:n};let Kt=Wt,Jt=Gt;function Vt(t,e,n){let r=t*e;return 8!==n&&(r=Math.ceil(r/(8/n))),r}let $t=jt.exports=function(t,e){let n=t.width,r=t.height,i=t.interlace,o=t.bpp,s=t.depth;if(this.read=e.read,this.write=e.write,this.complete=e.complete,this._imageIndex=0,this._images=[],i){let t=Kt.getImagePasses(n,r);for(let e=0;e<t.length;e++)this._images.push({byteWidth:Vt(t[e].width,o,s),height:t[e].height,lineIndex:0})}else this._images.push({byteWidth:Vt(n,o,s),height:r,lineIndex:0});this._xComparison=8===s?o:16===s?2*o:1};$t.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},$t.prototype._unFilterType1=function(t,e,n){let r=this._xComparison,i=r-1;for(let o=0;o<n;o++){let n=t[1+o],s=o>i?e[o-r]:0;e[o]=n+s}},$t.prototype._unFilterType2=function(t,e,n){let r=this._lastLine;for(let i=0;i<n;i++){let n=t[1+i],o=r?r[i]:0;e[i]=n+o}},$t.prototype._unFilterType3=function(t,e,n){let r=this._xComparison,i=r-1,o=this._lastLine;for(let s=0;s<n;s++){let n=t[1+s],a=o?o[s]:0,c=s>i?e[s-r]:0,h=Math.floor((c+a)/2);e[s]=n+h}},$t.prototype._unFilterType4=function(t,e,n){let r=this._xComparison,i=r-1,o=this._lastLine;for(let s=0;s<n;s++){let n=t[1+s],a=o?o[s]:0,c=s>i?e[s-r]:0,h=s>i&&o?o[s-r]:0,l=Jt(c,a,h);e[s]=n+l}},$t.prototype._reverseFilterLine=function(t){let e,n=t[0],r=this._images[this._imageIndex],i=r.byteWidth;if(0===n)e=t.slice(1,i+1);else switch(e=Buffer.alloc(i),n){case 1:this._unFilterType1(t,e,i);break;case 2:this._unFilterType2(t,e,i);break;case 3:this._unFilterType3(t,e,i);break;case 4:this._unFilterType4(t,e,i);break;default:throw new Error("Unrecognised filter type - "+n)}this.write(e),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=e,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())};var Zt=jt.exports;let Xt=e,te=qt,ee=Zt,ne=zt.exports=function(t){te.call(this);let e=[],n=this;this._filter=new ee(t,{read:this.read.bind(this),write:function(t){e.push(t)},complete:function(){n.emit("complete",Buffer.concat(e))}}),this._filter.start()};Xt.inherits(ne,te);var re=zt.exports,ie={exports:{}},oe={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5},se={exports:{}};let ae=[];!function(){for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)1&e?e=3988292384^e>>>1:e>>>=1;ae[t]=e}}();let ce=se.exports=function(){this._crc=-1};ce.prototype.write=function(t){for(let e=0;e<t.length;e++)this._crc=ae[255&(this._crc^t[e])]^this._crc>>>8;return!0},ce.prototype.crc32=function(){return-1^this._crc},ce.crc32=function(t){let e=-1;for(let n=0;n<t.length;n++)e=ae[255&(e^t[n])]^e>>>8;return-1^e};var he=se.exports;let le=oe,ue=he,fe=ie.exports=function(t,e){this._options=t,t.checkCRC=!1!==t.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[le.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[le.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[le.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[le.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[le.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[le.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.finished=e.finished,this.simpleTransparency=e.simpleTransparency,this.headersFinished=e.headersFinished||function(){}};fe.prototype.start=function(){this.read(le.PNG_SIGNATURE.length,this._parseSignature.bind(this))},fe.prototype._parseSignature=function(t){let e=le.PNG_SIGNATURE;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return void this.error(new Error("Invalid file signature"));this.read(8,this._parseChunkBegin.bind(this))},fe.prototype._parseChunkBegin=function(t){let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r="";for(let e=4;e<8;e++)r+=String.fromCharCode(t[e]);let i=Boolean(32&t[4]);if(this._hasIHDR||n===le.TYPE_IHDR){if(this._crc=new ue,this._crc.write(Buffer.from(r)),this._chunks[n])return this._chunks[n](e);i?this.read(e+4,this._skipChunk.bind(this)):this.error(new Error("Unsupported critical chunk type "+r))}else this.error(new Error("Expected IHDR on beggining"))},fe.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},fe.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},fe.prototype._parseChunkEnd=function(t){let e=t.readInt32BE(0),n=this._crc.crc32();this._options.checkCRC&&n!==e?this.error(new Error("Crc error - "+e+" - "+n)):this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},fe.prototype._handleIHDR=function(t){this.read(t,this._parseIHDR.bind(this))},fe.prototype._parseIHDR=function(t){this._crc.write(t);let e=t.readUInt32BE(0),n=t.readUInt32BE(4),r=t[8],i=t[9],o=t[10],s=t[11],a=t[12];if(8!==r&&4!==r&&2!==r&&1!==r&&16!==r)return void this.error(new Error("Unsupported bit depth "+r));if(!(i in le.COLORTYPE_TO_BPP_MAP))return void this.error(new Error("Unsupported color type"));if(0!==o)return void this.error(new Error("Unsupported compression method"));if(0!==s)return void this.error(new Error("Unsupported filter method"));if(0!==a&&1!==a)return void this.error(new Error("Unsupported interlace method"));this._colorType=i;let c=le.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:e,height:n,depth:r,interlace:Boolean(a),palette:Boolean(i&le.COLORTYPE_PALETTE),color:Boolean(i&le.COLORTYPE_COLOR),alpha:Boolean(i&le.COLORTYPE_ALPHA),bpp:c,colorType:i}),this._handleChunkEnd()},fe.prototype._handlePLTE=function(t){this.read(t,this._parsePLTE.bind(this))},fe.prototype._parsePLTE=function(t){this._crc.write(t);let e=Math.floor(t.length/3);for(let n=0;n<e;n++)this._palette.push([t[3*n],t[3*n+1],t[3*n+2],255]);this.palette(this._palette),this._handleChunkEnd()},fe.prototype._handleTRNS=function(t){this.simpleTransparency(),this.read(t,this._parseTRNS.bind(this))},fe.prototype._parseTRNS=function(t){if(this._crc.write(t),this._colorType===le.COLORTYPE_PALETTE_COLOR){if(0===this._palette.length)return void this.error(new Error("Transparency chunk must be after palette"));if(t.length>this._palette.length)return void this.error(new Error("More transparent colors than palette size"));for(let e=0;e<t.length;e++)this._palette[e][3]=t[e];this.palette(this._palette)}this._colorType===le.COLORTYPE_GRAYSCALE&&this.transColor([t.readUInt16BE(0)]),this._colorType===le.COLORTYPE_COLOR&&this.transColor([t.readUInt16BE(0),t.readUInt16BE(2),t.readUInt16BE(4)]),this._handleChunkEnd()},fe.prototype._handleGAMA=function(t){this.read(t,this._parseGAMA.bind(this))},fe.prototype._parseGAMA=function(t){this._crc.write(t),this.gamma(t.readUInt32BE(0)/le.GAMMA_DIVISION),this._handleChunkEnd()},fe.prototype._handleIDAT=function(t){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-t,this._parseIDAT.bind(this,t))},fe.prototype._parseIDAT=function(t,e){if(this._crc.write(e),this._colorType===le.COLORTYPE_PALETTE_COLOR&&0===this._palette.length)throw new Error("Expected palette not found");this.inflateData(e);let n=t-e.length;n>0?this._handleIDAT(n):this._handleChunkEnd()},fe.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))},fe.prototype._parseIEND=function(t){this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()};var de=ie.exports,pe={};let ge=Wt,_e=[function(){},function(t,e,n,r){if(r===e.length)throw new Error("Ran out of data");let i=e[r];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=255},function(t,e,n,r){if(r+1>=e.length)throw new Error("Ran out of data");let i=e[r];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=e[r+1]},function(t,e,n,r){if(r+2>=e.length)throw new Error("Ran out of data");t[n]=e[r],t[n+1]=e[r+1],t[n+2]=e[r+2],t[n+3]=255},function(t,e,n,r){if(r+3>=e.length)throw new Error("Ran out of data");t[n]=e[r],t[n+1]=e[r+1],t[n+2]=e[r+2],t[n+3]=e[r+3]}],ye=[function(){},function(t,e,n,r){let i=e[0];t[n]=i,t[n+1]=i,t[n+2]=i,t[n+3]=r},function(t,e,n){let r=e[0];t[n]=r,t[n+1]=r,t[n+2]=r,t[n+3]=e[1]},function(t,e,n,r){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=r},function(t,e,n){t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3]}];function me(t,e,n,r,i,o){let s=t.width,a=t.height,c=t.index;for(let t=0;t<a;t++)for(let a=0;a<s;a++){let s=n(a,t,c);_e[r](e,i,s,o),o+=r}return o}function we(t,e,n,r,i,o){let s=t.width,a=t.height,c=t.index;for(let t=0;t<a;t++){for(let a=0;a<s;a++){let s=i.get(r),h=n(a,t,c);ye[r](e,s,h,o)}i.resetAfterLine()}}pe.dataToBitMap=function(t,e){let n,r,i=e.width,o=e.height,s=e.depth,a=e.bpp,c=e.interlace;8!==s&&(n=function(t,e){let n=[],r=0;function i(){if(r===t.length)throw new Error("Ran out of data");let i,o,s,a,c,h,l,u,f=t[r];switch(r++,e){default:throw new Error("unrecognised depth");case 16:l=t[r],r++,n.push((f<<8)+l);break;case 4:l=15&f,u=f>>4,n.push(u,l);break;case 2:c=3&f,h=f>>2&3,l=f>>4&3,u=f>>6&3,n.push(u,l,h,c);break;case 1:i=1&f,o=f>>1&1,s=f>>2&1,a=f>>3&1,c=f>>4&1,h=f>>5&1,l=f>>6&1,u=f>>7&1,n.push(u,l,h,c,a,s,o,i)}}return{get:function(t){for(;n.length<t;)i();let e=n.slice(0,t);return n=n.slice(t),e},resetAfterLine:function(){n.length=0},end:function(){if(r!==t.length)throw new Error("extra data found")}}}(t,s)),r=s<=8?Buffer.alloc(i*o*4):new Uint16Array(i*o*4);let h,l,u=Math.pow(2,s)-1,f=0;if(c)h=ge.getImagePasses(i,o),l=ge.getInterlaceIterator(i,o);else{let t=0;l=function(){let e=t;return t+=4,e},h=[{width:i,height:o}]}for(let e=0;e<h.length;e++)8===s?f=me(h[e],r,l,a,t,f):we(h[e],r,l,a,n,u);if(8===s){if(f!==t.length)throw new Error("extra data found")}else n.end();return r};var be=function(t,e){let n=e.depth,r=e.width,i=e.height,o=e.colorType,s=e.transColor,a=e.palette,c=t;return 3===o?function(t,e,n,r,i){let o=0;for(let s=0;s<r;s++)for(let r=0;r<n;r++){let n=i[t[o]];if(!n)throw new Error("index "+t[o]+" not in palette");for(let t=0;t<4;t++)e[o+t]=n[t];o+=4}}(t,c,r,i,a):(s&&function(t,e,n,r,i){let o=0;for(let s=0;s<r;s++)for(let r=0;r<n;r++){let n=!1;if(1===i.length?i[0]===t[o]&&(n=!0):i[0]===t[o]&&i[1]===t[o+1]&&i[2]===t[o+2]&&(n=!0),n)for(let t=0;t<4;t++)e[o+t]=0;o+=4}}(t,c,r,i,s),8!==n&&(16===n&&(c=Buffer.alloc(r*i*4)),function(t,e,n,r,i){let o=Math.pow(2,i)-1,s=0;for(let i=0;i<r;i++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)e[s+n]=Math.floor(255*t[s+n]/o+.5);s+=4}}(t,c,r,i,n))),c};let ve=e,Ee=r,Te=qt,Ie=re,Ce=de,ke=pe,Ae=be,Re=Nt.exports=function(t){Te.call(this),this._parser=new Ce(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};ve.inherits(Re,Te),Re.prototype._handleError=function(t){this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0},Re.prototype._inflateData=function(t){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=Ee.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let t=(1+(this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3))*this._bitmapInfo.height,e=Math.max(t,Ee.Z_MIN_CHUNK);this._inflate=Ee.createInflate({chunkSize:e});let n=t,r=this.emit.bind(this,"error");this._inflate.on("error",function(t){n&&r(t)}),this._filter.on("complete",this._complete.bind(this));let i=this._filter.write.bind(this._filter);this._inflate.on("data",function(t){n&&(t.length>n&&(t=t.slice(0,n)),n-=t.length,i(t))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(t)},Re.prototype._handleMetaData=function(t){this._metaData=t,this._bitmapInfo=Object.create(t),this._filter=new Ie(this._bitmapInfo)},Re.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t},Re.prototype._handlePalette=function(t){this._bitmapInfo.palette=t},Re.prototype._simpleTransparency=function(){this._metaData.alpha=!0},Re.prototype._headersFinished=function(){this.emit("metadata",this._metaData)},Re.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))},Re.prototype._complete=function(t){if(this.errord)return;let e;try{let n=ke.dataToBitMap(t,this._bitmapInfo);e=Ae(n,this._bitmapInfo),n=null}catch(t){return void this._handleError(t)}this.emit("parsed",e)};var Pe=Nt.exports,Le={exports:{}},Se={exports:{}};let Oe=oe;let xe=Gt;let Be={0:function(t,e,n,r,i){for(let o=0;o<n;o++)r[i+o]=t[e+o]},1:function(t,e,n,r,i,o){for(let s=0;s<n;s++){let n=s>=o?t[e+s-o]:0,a=t[e+s]-n;r[i+s]=a}},2:function(t,e,n,r,i){for(let o=0;o<n;o++){let s=e>0?t[e+o-n]:0,a=t[e+o]-s;r[i+o]=a}},3:function(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=e>0?t[e+s-n]:0,h=t[e+s]-(a+c>>1);r[i+s]=h}},4:function(t,e,n,r,i,o){for(let s=0;s<n;s++){let a=s>=o?t[e+s-o]:0,c=e>0?t[e+s-n]:0,h=e>0&&s>=o?t[e+s-(n+o)]:0,l=t[e+s]-xe(a,c,h);r[i+s]=l}}},Me={0:function(t,e,n){let r=0,i=e+n;for(let n=e;n<i;n++)r+=Math.abs(t[n]);return r},1:function(t,e,n,r){let i=0;for(let o=0;o<n;o++){let n=o>=r?t[e+o-r]:0,s=t[e+o]-n;i+=Math.abs(s)}return i},2:function(t,e,n){let r=0,i=e+n;for(let o=e;o<i;o++){let i=e>0?t[o-n]:0,s=t[o]-i;r+=Math.abs(s)}return r},3:function(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=e>0?t[e+o-n]:0,c=t[e+o]-(s+a>>1);i+=Math.abs(c)}return i},4:function(t,e,n,r){let i=0;for(let o=0;o<n;o++){let s=o>=r?t[e+o-r]:0,a=e>0?t[e+o-n]:0,c=e>0&&o>=r?t[e+o-(n+r)]:0,h=t[e+o]-xe(s,a,c);i+=Math.abs(h)}return i}};let De=oe,Ne=he,Ue=function(t,e,n,r){let i=-1!==[Oe.COLORTYPE_COLOR_ALPHA,Oe.COLORTYPE_ALPHA].indexOf(r.colorType);if(r.colorType===r.inputColorType){let e=function(){let t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),256!==new Int16Array(t)[0]}();if(8===r.bitDepth||16===r.bitDepth&&e)return t}let o=16!==r.bitDepth?t:new Uint16Array(t.buffer),s=255,a=Oe.COLORTYPE_TO_BPP_MAP[r.inputColorType];4!==a||r.inputHasAlpha||(a=3);let c=Oe.COLORTYPE_TO_BPP_MAP[r.colorType];16===r.bitDepth&&(s=65535,c*=2);let h=Buffer.alloc(e*n*c),l=0,u=0,f=r.bgColor||{};function d(){let t,e,n,a=s;switch(r.inputColorType){case Oe.COLORTYPE_COLOR_ALPHA:a=o[l+3],t=o[l],e=o[l+1],n=o[l+2];break;case Oe.COLORTYPE_COLOR:t=o[l],e=o[l+1],n=o[l+2];break;case Oe.COLORTYPE_ALPHA:a=o[l+1],t=o[l],e=t,n=t;break;case Oe.COLORTYPE_GRAYSCALE:t=o[l],e=t,n=t;break;default:throw new Error("input color type:"+r.inputColorType+" is not supported at present")}return r.inputHasAlpha&&(i||(a/=s,t=Math.min(Math.max(Math.round((1-a)*f.red+a*t),0),s),e=Math.min(Math.max(Math.round((1-a)*f.green+a*e),0),s),n=Math.min(Math.max(Math.round((1-a)*f.blue+a*n),0),s))),{red:t,green:e,blue:n,alpha:a}}void 0===f.red&&(f.red=s),void 0===f.green&&(f.green=s),void 0===f.blue&&(f.blue=s);for(let t=0;t<n;t++)for(let t=0;t<e;t++){let t=d();switch(r.colorType){case Oe.COLORTYPE_COLOR_ALPHA:case Oe.COLORTYPE_COLOR:8===r.bitDepth?(h[u]=t.red,h[u+1]=t.green,h[u+2]=t.blue,i&&(h[u+3]=t.alpha)):(h.writeUInt16BE(t.red,u),h.writeUInt16BE(t.green,u+2),h.writeUInt16BE(t.blue,u+4),i&&h.writeUInt16BE(t.alpha,u+6));break;case Oe.COLORTYPE_ALPHA:case Oe.COLORTYPE_GRAYSCALE:{let e=(t.red+t.green+t.blue)/3;8===r.bitDepth?(h[u]=e,i&&(h[u+1]=t.alpha)):(h.writeUInt16BE(e,u),i&&h.writeUInt16BE(t.alpha,u+2));break}default:throw new Error("unrecognised color Type "+r.colorType)}l+=a,u+=c}return h},Ye=function(t,e,n,r,i){let o;if("filterType"in r&&-1!==r.filterType){if("number"!=typeof r.filterType)throw new Error("unrecognised filter types");o=[r.filterType]}else o=[0,1,2,3,4];16===r.bitDepth&&(i*=2);let s=e*i,a=0,c=0,h=Buffer.alloc((s+1)*n),l=o[0];for(let e=0;e<n;e++){if(o.length>1){let e=1/0;for(let n=0;n<o.length;n++){let r=Me[o[n]](t,c,s,i);r<e&&(l=o[n],e=r)}}h[a]=l,a++,Be[l](t,c,s,h,a,i),a+=s,c+=s}return h},Fe=r,He=Se.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=null!=t.deflateLevel?t.deflateLevel:9,t.deflateStrategy=null!=t.deflateStrategy?t.deflateStrategy:3,t.inputHasAlpha=null==t.inputHasAlpha||t.inputHasAlpha,t.deflateFactory=t.deflateFactory||Fe.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType="number"==typeof t.colorType?t.colorType:De.COLORTYPE_COLOR_ALPHA,t.inputColorType="number"==typeof t.inputColorType?t.inputColorType:De.COLORTYPE_COLOR_ALPHA,-1===[De.COLORTYPE_GRAYSCALE,De.COLORTYPE_COLOR,De.COLORTYPE_COLOR_ALPHA,De.COLORTYPE_ALPHA].indexOf(t.colorType))throw new Error("option color type:"+t.colorType+" is not supported at present");if(-1===[De.COLORTYPE_GRAYSCALE,De.COLORTYPE_COLOR,De.COLORTYPE_COLOR_ALPHA,De.COLORTYPE_ALPHA].indexOf(t.inputColorType))throw new Error("option input color type:"+t.inputColorType+" is not supported at present");if(8!==t.bitDepth&&16!==t.bitDepth)throw new Error("option bit depth:"+t.bitDepth+" is not supported at present")};He.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},He.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},He.prototype.filterData=function(t,e,n){let r=Ue(t,e,n,this._options),i=De.COLORTYPE_TO_BPP_MAP[this._options.colorType];return Ye(r,e,n,this._options,i)},He.prototype._packChunk=function(t,e){let n=e?e.length:0,r=Buffer.alloc(n+12);return r.writeUInt32BE(n,0),r.writeUInt32BE(t,4),e&&e.copy(r,8),r.writeInt32BE(Ne.crc32(r.slice(4,r.length-4)),r.length-4),r},He.prototype.packGAMA=function(t){let e=Buffer.alloc(4);return e.writeUInt32BE(Math.floor(t*De.GAMMA_DIVISION),0),this._packChunk(De.TYPE_gAMA,e)},He.prototype.packIHDR=function(t,e){let n=Buffer.alloc(13);return n.writeUInt32BE(t,0),n.writeUInt32BE(e,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(De.TYPE_IHDR,n)},He.prototype.packIDAT=function(t){return this._packChunk(De.TYPE_IDAT,t)},He.prototype.packIEND=function(){return this._packChunk(De.TYPE_IEND,null)};var qe=Se.exports;let ze=e,je=n,We=oe,Qe=qe,Ge=Le.exports=function(t){je.call(this);let e=t||{};this._packer=new Qe(e),this._deflate=this._packer.createDeflate(),this.readable=!0};ze.inherits(Ge,je),Ge.prototype.pack=function(t,e,n,r){this.emit("data",Buffer.from(We.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,n)),r&&this.emit("data",this._packer.packGAMA(r));let i=this._packer.filterData(t,e,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(t){this.emit("data",this._packer.packIDAT(t))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(i)};var Ke=Le.exports,Je={},Ve={exports:{}};!function(t,n){let s=i.ok,a=r,c=e,h=o.kMaxLength;function l(t){if(!(this instanceof l))return new l(t);t&&t.chunkSize<a.Z_MIN_CHUNK&&(t.chunkSize=a.Z_MIN_CHUNK),a.Inflate.call(this,t),this._offset=void 0===this._offset?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,t&&null!=t.maxLength&&(this._maxLength=t.maxLength)}function u(t,e){e&&process.nextTick(e),t._handle&&(t._handle.close(),t._handle=null)}function f(t,e){return function(t,e){if("string"==typeof e&&(e=Buffer.from(e)),!(e instanceof Buffer))throw new TypeError("Not a string or buffer");let n=t._finishFlushFlag;return null==n&&(n=a.Z_FINISH),t._processChunk(e,n)}(new l(e),t)}l.prototype._processChunk=function(t,e,n){if("function"==typeof n)return a.Inflate._processChunk.call(this,t,e,n);let r,i,o=this,c=t&&t.length,l=this._chunkSize-this._offset,f=this._maxLength,d=0,p=[],g=0;function _(t,e){if(o._hadError)return;let n=l-e;if(s(n>=0,"have should not go down"),n>0){let t=o._buffer.slice(o._offset,o._offset+n);if(o._offset+=n,t.length>f&&(t=t.slice(0,f)),p.push(t),g+=t.length,f-=t.length,0===f)return!1}return(0===e||o._offset>=o._chunkSize)&&(l=o._chunkSize,o._offset=0,o._buffer=Buffer.allocUnsafe(o._chunkSize)),0===e&&(d+=c-t,c=t,!0)}this.on("error",function(t){r=t}),s(this._handle,"zlib binding closed");do{i=this._handle.writeSync(e,t,d,c,this._buffer,this._offset,l),i=i||this._writeState}while(!this._hadError&&_(i[0],i[1]));if(this._hadError)throw r;if(g>=h)throw u(this),new RangeError("Cannot create final Buffer. It would be larger than 0x"+h.toString(16)+" bytes");let y=Buffer.concat(p,g);return u(this),y},c.inherits(l,a.Inflate),t.exports=n=f,n.Inflate=l,n.createInflate=function(t){return new l(t)},n.inflateSync=f}(Ve,Ve.exports);var $e=Ve.exports,Ze={exports:{}};let Xe=Ze.exports=function(t){this._buffer=t,this._reads=[]};Xe.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e})},Xe.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let t=this._reads[0];if(!this._buffer.length||!(this._buffer.length>=t.length||t.allowLess))break;{this._reads.shift();let e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}}return this._reads.length>0?new Error("There are some read requests waitng on finished stream"):this._buffer.length>0?new Error("unrecognised content at end of stream"):void 0};var tn=Ze.exports,en={};let nn=tn,rn=Zt;en.process=function(t,e){let n=[],r=new nn(t);return new rn(e,{read:r.read.bind(r),write:function(t){n.push(t)},complete:function(){}}).start(),r.process(),Buffer.concat(n)};let on=!0,sn=r,an=$e;sn.deflateSync||(on=!1);let cn=tn,hn=en,ln=de,un=pe,fn=be;let dn=!0,pn=r;pn.deflateSync||(dn=!1);let gn=oe,_n=qe;let yn=function(t,e){if(!on)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n,r,i;let o=[];let s=new cn(t),a=new ln(e,{read:s.read.bind(s),error:function(t){n=t},metadata:function(t){r=t},gamma:function(t){i=t},palette:function(t){r.palette=t},transColor:function(t){r.transColor=t},inflateData:function(t){o.push(t)},simpleTransparency:function(){r.alpha=!0}});if(a.start(),s.process(),n)throw n;let c,h=Buffer.concat(o);if(o.length=0,r.interlace)c=sn.inflateSync(h);else{let t=(1+(r.width*r.bpp*r.depth+7>>3))*r.height;c=an(h,{chunkSize:t,maxLength:t})}if(h=null,!c||!c.length)throw new Error("bad png - invalid inflate data response");let l=hn.process(c,r);h=null;let u=un.dataToBitMap(l,r);l=null;let f=fn(u,r);return r.data=f,r.gamma=i||0,r},mn=function(t,e){if(!dn)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n=new _n(e||{}),r=[];r.push(Buffer.from(gn.PNG_SIGNATURE)),r.push(n.packIHDR(t.width,t.height)),t.gamma&&r.push(n.packGAMA(t.gamma));let i=n.filterData(t.data,t.width,t.height),o=pn.deflateSync(i,n.getDeflateOptions());if(i=null,!o||!o.length)throw new Error("bad png - invalid compressed data response");return r.push(n.packIDAT(o)),r.push(n.packIEND()),Buffer.concat(r)};Je.read=function(t,e){return yn(t,e||{})},Je.write=function(t,e){return mn(t,e)};let wn=e,bn=n,vn=Pe,En=Ke,Tn=Je,In=Dt.PNG=function(t){bn.call(this),t=t||{},this.width=0|t.width,this.height=0|t.height,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,t.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new vn(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(t){this.data=t,this.emit("parsed",t)}.bind(this)),this._packer=new En(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};wn.inherits(In,bn),In.sync=Tn,In.prototype.pack=function(){return this.data&&this.data.length?(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this):(this.emit("error","No data provided"),this)},In.prototype.parse=function(t,e){if(e){let t,n;t=function(t){this.removeListener("error",n),this.data=t,e(null,this)}.bind(this),n=function(n){this.removeListener("parsed",t),e(n,null)}.bind(this),this.once("parsed",t),this.once("error",n)}return this.end(t),this},In.prototype.write=function(t){return this._parser.write(t),!0},In.prototype.end=function(t){this._parser.end(t)},In.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)},In.prototype._gamma=function(t){this.gamma=t},In.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},In.bitblt=function(t,e,n,r,i,o,s,a){if(r|=0,i|=0,o|=0,s|=0,a|=0,(n|=0)>t.width||r>t.height||n+i>t.width||r+o>t.height)throw new Error("bitblt reading outside image");if(s>e.width||a>e.height||s+i>e.width||a+o>e.height)throw new Error("bitblt writing outside image");for(let c=0;c<o;c++)t.data.copy(e.data,(a+c)*e.width+s<<2,(r+c)*t.width+n<<2,(r+c)*t.width+n+i<<2)},In.prototype.bitblt=function(t,e,n,r,i,o,s){return In.bitblt(this,t,e,n,r,i,o,s),this},In.adjustGamma=function(t){if(t.gamma){for(let e=0;e<t.height;e++)for(let n=0;n<t.width;n++){let r=t.width*e+n<<2;for(let e=0;e<3;e++){let n=t.data[r+e]/255;n=Math.pow(n,1/2.2/t.gamma),t.data[r+e]=Math.round(255*n)}}t.gamma=0}},In.prototype.adjustGamma=function(){In.adjustGamma(this)};var Cn={};!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,r=t.width&&t.width>=21?t.width:void 0,i=t.scale||4;return{width:r,scale:r?4:i,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 r=t.getScale(e,n);return Math.floor((e+2*n.margin)*r)},t.qrToImageData=function(e,n,r){const i=n.modules.size,o=n.modules.data,s=t.getScale(i,r),a=Math.floor((i+2*r.margin)*s),c=r.margin*s,h=[r.color.light,r.color.dark];for(let t=0;t<a;t++)for(let n=0;n<a;n++){let l=4*(t*a+n),u=r.color.light;if(t>=c&&n>=c&&t<a-c&&n<a-c){u=h[o[Math.floor((t-c)/s)*i+Math.floor((n-c)/s)]?1:0]}e[l++]=u.r,e[l++]=u.g,e[l++]=u.b,e[l]=u.a}}}(Cn),function(e){const n=t,r=Dt.PNG,i=Cn;e.render=function(t,e){const n=i.getOptions(e),o=n.rendererOpts,s=i.getImageWidth(t.modules.size,n);o.width=s,o.height=s;const a=new r(o);return i.qrToImageData(a.data,t,n),a},e.renderToDataURL=function(t,n,r){void 0===r&&(r=n,n=void 0),e.renderToBuffer(t,n,function(t,e){t&&r(t);let n="data:image/png;base64,";n+=e.toString("base64"),r(null,n)})},e.renderToBuffer=function(t,n,r){void 0===r&&(r=n,n=void 0);const i=e.render(t,n),o=[];i.on("error",r),i.on("data",function(t){o.push(t)}),i.on("end",function(){r(null,Buffer.concat(o))}),i.pack()},e.renderToFile=function(t,r,i,o){void 0===o&&(o=i,i=void 0);let s=!1;const a=(...t)=>{s||(s=!0,o.apply(null,t))},c=n.createWriteStream(t);c.on("error",a),c.on("close",a),e.renderToFileStream(c,r,i)},e.renderToFileStream=function(t,n,r){e.render(n,r).pack().pipe(t)}}(Mt);var kn={};!function(e){const n=Cn,r={WW:" ",WB:"▄",BB:"█",BW:"▀"},i={BB:" ",BW:"▄",WW:"█",WB:"▀"};function o(t,e,n){return t&&e?n.BB:t&&!e?n.BW:!t&&e?n.WB:n.WW}e.render=function(t,e,s){const a=n.getOptions(e);let c=r;"#ffffff"!==a.color.dark.hex&&"#000000"!==a.color.light.hex||(c=i);const h=t.modules.size,l=t.modules.data;let u="",f=Array(h+2*a.margin+1).join(c.WW);f=Array(a.margin/2+1).join(f+"\n");const d=Array(a.margin+1).join(c.WW);u+=f;for(let t=0;t<h;t+=2){u+=d;for(let e=0;e<h;e++){u+=o(l[t*h+e],l[(t+1)*h+e],c)}u+=d+"\n"}return u+=f.slice(0,-1),"function"==typeof s&&s(null,u),u},e.renderToFile=function(n,r,i,o){void 0===o&&(o=i,i=void 0);const s=t,a=e.render(r,i);s.writeFile(n,a,o)}}(kn);var An={},Rn={render:function(t,e,n){const r=t.modules.size,i=t.modules.data,o=" ";let s="";const a=Array(r+3).join(o),c=Array(2).join(o);s+=a+"\n";for(let t=0;t<r;++t){s+=o;for(let e=0;e<r;e++)s+=i[t*r+e]?" ":o;s+=c+"\n"}return s+=a+"\n","function"==typeof n&&n(null,s),s}},Pn={};const Ln="",Sn="",On="",xn=""+Sn,Bn=""+Ln,Mn=function(t,e,n,r){const i=e+1;if(n>=i||r>=i||r<-1||n<-1)return"0";if(n>=e||r>=e||r<0||n<0)return"1";return t[r*e+n]?"2":"1"},Dn=function(t,e,n,r){return Mn(t,e,n,r)+Mn(t,e,n,r+1)};Pn.render=function(t,e,n){const r=t.modules.size,i=t.modules.data,o=!(!e||!e.inverse),s=e&&e.inverse?Bn:xn,a=function(t,e,n){return{"00":On+" "+t,"01":On+e+"▄"+t,"02":On+n+"▄"+t,10:On+e+"▀"+t,11:" ",12:"▄",20:On+n+"▀"+t,21:"▀",22:"█"}}(s,o?Sn:Ln,o?Ln:Sn),c=On+"\n"+s;let h=s;for(let t=-1;t<r+1;t+=2){for(let e=-1;e<r;e++)h+=a[Dn(i,r,e,t)];h+=a[Dn(i,r,r,t)]+c}return h+=On,"function"==typeof n&&n(null,h),h};const Nn=Rn,Un=Pn;An.render=function(t,e,n){return e&&e.small?Un.render(t,e,n):Nn.render(t,e,n)};var Yn,Fn={},Hn={};function qn(){if(Yn)return Hn;Yn=1;const t=Cn;function e(t,e){const n=t.a/255,r=e+'="'+t.hex+'"';return n<1?r+" "+e+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function n(t,e,n){let r=t+e;return void 0!==n&&(r+=" "+n),r}return Hn.render=function(r,i,o){const s=t.getOptions(i),a=r.modules.size,c=r.modules.data,h=a+2*s.margin,l=s.color.light.a?"<path "+e(s.color.light,"fill")+' d="M0 0h'+h+"v"+h+'H0z"/>':"",u="<path "+e(s.color.dark,"stroke")+' d="'+function(t,e,r){let i="",o=0,s=!1,a=0;for(let c=0;c<t.length;c++){const h=Math.floor(c%e),l=Math.floor(c/e);h||s||(s=!0),t[c]?(a++,c>0&&h>0&&t[c-1]||(i+=s?n("M",h+r,.5+l+r):n("m",o,0),o=0,s=!1),h+1<e&&t[c+1]||(i+=n("h",a),a=0)):o++}return i}(c,a,s.margin)+'"/>',f='viewBox="0 0 '+h+" "+h+'"',d='<svg xmlns="http://www.w3.org/2000/svg" '+(s.width?'width="'+s.width+'" height="'+s.width+'" ':"")+f+' shape-rendering="crispEdges">'+l+u+"</svg>\n";return"function"==typeof o&&o(null,d),d},Hn}!function(e){const n=qn();e.render=n.render,e.renderToFile=function(n,r,i,o){void 0===o&&(o=i,i=void 0);const s=t,a='<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'+e.render(r,i);s.writeFile(n,a,o)}}(Fn);var zn,jn,Wn={},Qn={};function Gn(){return zn||(zn=1,function(t){const e=Cn;t.render=function(t,n,r){let i=r,o=n;void 0!==i||n&&n.getContext||(i=n,n=void 0),n||(o=function(){try{return document.createElement("canvas")}catch(t){throw new Error("You need to specify a canvas element")}}()),i=e.getOptions(i);const s=e.getImageWidth(t.modules.size,i),a=o.getContext("2d"),c=a.createImageData(s,s);return e.qrToImageData(c.data,t,i),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,o,s),a.putImageData(c,0,0),o},t.renderToDataURL=function(e,n,r){let i=r;void 0!==i||n&&n.getContext||(i=n,n=void 0),i||(i={});const o=t.render(e,n,i),s=i.type||"image/png",a=i.rendererOpts||{};return o.toDataURL(s,a.quality)}}(Qn)),Qn}const Kn=y,Jn=m,Vn=Mt,$n=kn,Zn=An,Xn=Fn;function tr(t,e,n){if(void 0===t)throw new Error("String required as first argument");if(void 0===n&&(n=e,e={}),"function"!=typeof n){if(!Kn())throw new Error("Callback required as last argument");e=n||{},n=null}return{opts:e,cb:n}}function er(t){switch(t){case"svg":return Xn;case"txt":case"utf8":return $n;default:return Vn}}function nr(t,e,n){if(!n.cb)return new Promise(function(r,i){try{const o=Jn.create(e,n.opts);return t(o,n.opts,function(t,e){return t?i(t):r(e)})}catch(t){i(t)}});try{const r=Jn.create(e,n.opts);return t(r,n.opts,n.cb)}catch(t){n.cb(t)}}_.create=Jn.create,_.toCanvas=function(){if(jn)return Wn;jn=1;const t=y,e=m,n=Gn(),r=qn();function i(n,r,i,o,s){const a=[].slice.call(arguments,1),c=a.length,h="function"==typeof a[c-1];if(!h&&!t())throw new Error("Callback required as last argument");if(!h){if(c<1)throw new Error("Too few arguments provided");return 1===c?(i=r,r=o=void 0):2!==c||r.getContext||(o=i,i=r,r=void 0),new Promise(function(t,s){try{const s=e.create(i,o);t(n(s,r,o))}catch(t){s(t)}})}if(c<2)throw new Error("Too few arguments provided");2===c?(s=i,i=r,r=o=void 0):3===c&&(r.getContext&&void 0===s?(s=o,o=void 0):(s=o,o=i,i=r,r=void 0));try{const t=e.create(i,o);s(null,n(t,r,o))}catch(t){s(t)}}return Wn.create=e.create,Wn.toCanvas=i.bind(null,n.render),Wn.toDataURL=i.bind(null,n.renderToDataURL),Wn.toString=i.bind(null,function(t,e,n){return r.render(t,n)}),Wn}().toCanvas,_.toString=function(t,e,n){const r=tr(t,e,n),i=function(t){switch(t){case"svg":return Xn;case"terminal":return Zn;default:return $n}}(r.opts?r.opts.type:void 0);return nr(i.render,t,r)},_.toDataURL=function(t,e,n){const r=tr(t,e,n);return nr(er(r.opts.type).renderToDataURL,t,r)},_.toBuffer=function(t,e,n){const r=tr(t,e,n);return nr(er(r.opts.type).renderToBuffer,t,r)},_.toFile=function(t,e,n,r){if("string"!=typeof t||"string"!=typeof e&&"object"!=typeof e)throw new Error("Invalid argument");if(arguments.length<3&&!Kn())throw new Error("Too few arguments provided");const i=tr(e,n,r),o=i.opts.type||function(t){return t.slice((t.lastIndexOf(".")-1>>>0)+2).toLowerCase()}(t);return nr(er(o).renderToFile.bind(null,t),e,i)},_.toFileStream=function(t,e,n){if(arguments.length<2)throw new Error("Too few arguments provided");const r=tr(e,n,t.emit.bind(t,"error"));nr(er("png").renderToFileStream.bind(null,t),e,r)};var rr=g(_);!function(t,e){var n={apiUrl:(null===(e=t.SunuIDConfig)||void 0===e?void 0:e.apiUrl)||"https://api.sunuid.fayma.sn",clientId:null,secretId:null,type:1,theme:"light",language:"fr",autoRefresh:!0,refreshInterval:3e4,onSuccess:null,onError:null,onStatusUpdate:null,onExpired:null},r=function(){return e=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=u(u({},n),e),this.qrCode=null,this.refreshTimer=null,this.isInitialized=!1,this.socket=null,this.websocketRetryCount=0,this.maxWebSocketRetries=5,this.init()},r=[{key:"init",value:function(){if(!this.config.clientId||!this.config.secretId)throw new Error("SunuID: clientId et secretId sont requis");this.isInitialized=!0,console.log("SunuID SDK initialisé avec succès"),this.initWebSocket()}},{key:"initWebSocket",value:function(){var t=this;try{if("undefined"==typeof io)return this.websocketRetryCount++,void(this.websocketRetryCount<=this.maxWebSocketRetries?(console.warn("⚠️ Socket.IO non disponible (tentative ".concat(this.websocketRetryCount,"/").concat(this.maxWebSocketRetries,"), WebSocket sera initialisé plus tard")),setTimeout(function(){return t.initWebSocket()},1e3)):console.warn("⚠️ Socket.IO non disponible après plusieurs tentatives, WebSocket désactivé"));var e=this.getClientIP();this.socket||(this.socket=io("wss://samasocket.fayma.sn:9443",{query:{token:this.config.clientId,type:"web",userId:this.config.clientId,username:e}}),this.socket.on("connect",function(){console.log("🌐 WebSocket connecté avec succès"),console.log("📊 Socket ID:",t.socket.id)}),this.socket.on("disconnect",function(t){console.log("❌ WebSocket déconnecté:",t)}),this.socket.on("connect_error",function(t){console.error("❌ Erreur connexion WebSocket:",t)}),this.socket.on("qr_status_update",function(e){console.log("📱 Mise à jour statut QR reçue:",e),t.handleQRStatusUpdate(e)}),this.socket.on("qr_scan_success",function(e){console.log("✅ Scan QR réussi reçu:",e),t.handleQRScanSuccess(e)}),this.socket.on("qr_expired",function(e){console.log("⏰ QR expiré reçu:",e),t.handleQRExpired(e)}))}catch(t){console.error("❌ Erreur initialisation WebSocket:",t)}}},{key:"getClientIP",value:function(){return"127.0.0.1"}},{key:"handleQRStatusUpdate",value:function(t){this.config.onStatusUpdate&&this.config.onStatusUpdate(t)}},{key:"handleQRScanSuccess",value:function(t){this.config.onSuccess&&this.config.onSuccess(t)}},{key:"handleQRExpired",value:function(t){this.config.onExpired&&this.config.onExpired(t)}},{key:"emitWebSocketEvent",value:function(t,e){this.socket&&this.socket.connected?(this.socket.emit(t,e),console.log("📤 Événement WebSocket émis: ".concat(t),e)):"undefined"==typeof io?console.warn("⚠️ Socket.IO non disponible, impossible d'émettre l'événement:",t):console.warn("⚠️ WebSocket non connecté, impossible d'émettre l'événement:",t)}},{key:"getWebSocketStatus",value:function(){return this.socket?this.socket.connected?"connected":"disconnected":"not_initialized"}},{key:"forceWebSocketInit",value:function(){"undefined"==typeof io||this.socket||(console.log("🔄 Forçage de l'initialisation WebSocket..."),this.initWebSocket())}},{key:"generateQR",value:(_=a(f().m(function t(e){var n,r,i,o,s=arguments;return f().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=s.length>1&&void 0!==s[1]?s[1]:{},this.isInitialized){t.n=1;break}throw new Error("SunuID: SDK non initialisé");case 1:return t.p=1,t.n=2,this.makeRequest("/qr-generate",u({type:this.config.type},n));case 2:if(!(r=t.v).success){t.n=4;break}return i="".concat("https://sunuid.fayma.sn").concat(r.data.qrcode),t.n=3,this.displayQRCode(e,i,this.config.type,n);case 3:return this.startAutoRefresh(e,this.config.type,n),this.emitWebSocketEvent("qr_generated",{serviceId:r.data.service_id,type:this.config.type,qrCodeUrl:i,timestamp:Date.now()}),t.a(2,u(u({},r.data),{},{qrCodeUrl:i,sessionId:r.data.service_id}));case 4:throw new Error(r.message||"Erreur lors de la génération du QR code");case 5:t.n=7;break;case 6:throw t.p=6,o=t.v,console.error("Erreur API détectée:",o.message),console.log('Affichage du message "Service non disponible" pour type '+this.config.type),this.displayServiceUnavailable(e,this.config.type),new Error("Service non disponible");case 7:return t.a(2)}},t,this,[[1,6]])})),function(t){return _.apply(this,arguments)})},{key:"generateCustomQR",value:(g=a(f().m(function t(e,n){var r,i,o,s,a=arguments;return f().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=a.length>2&&void 0!==a[2]?a[2]:{},this.isInitialized){t.n=1;break}throw new Error("SunuID: SDK non initialisé");case 1:return t.p=1,t.n=2,this.makeRequest("/qr-generate",u({type:n},r));case 2:if(!(i=t.v).success){t.n=4;break}return o="".concat("https://sunuid.fayma.sn").concat(i.data.qrcode),t.n=3,this.displayQRCode(e,o,n,r);case 3:return this.startAutoRefresh(e,n,r),t.a(2,u(u({},i.data),{},{qrCodeUrl:o,sessionId:i.data.service_id}));case 4:throw new Error(i.message||"Erreur lors de la génération du QR code");case 5:t.n=7;break;case 6:throw t.p=6,s=t.v,console.error("Erreur API détectée:",s.message),console.log('Affichage du message "Service non disponible" pour type '+n),this.displayServiceUnavailable(e,n),new Error("Service non disponible");case 7:return t.a(2)}},t,this,[[1,6]])})),function(t,e){return g.apply(this,arguments)})},{key:"generateAuthQR",value:(p=a(f().m(function t(e){var n,r=arguments;return f().w(function(t){for(;;)if(0===t.n)return n=r.length>1&&void 0!==r[1]?r[1]:{},t.a(2,this.generateQR(e,n))},t,this)})),function(t){return p.apply(this,arguments)})},{key:"generateKYCQR",value:(d=a(f().m(function t(e){var n,r,i=arguments;return f().w(function(t){for(;;)switch(t.p=t.n){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:{},r=this.config.type,this.config.type=2,t.p=1,t.n=2,this.generateQR(e,n);case 2:return t.a(2,t.v);case 3:return t.p=3,this.config.type=r,t.f(3);case 4:return t.a(2)}},t,this,[[1,,3,4]])})),function(t){return d.apply(this,arguments)})},{key:"checkQRStatus",value:(l=a(f().m(function t(e){var n,r;return f().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.isInitialized){t.n=1;break}throw new Error("SunuID: SDK non initialisé");case 1:return t.p=1,t.n=2,this.makeRequest("/qr-status",{serviceId:e});case 2:if(!(n=t.v).success){t.n=3;break}return t.a(2,n.data);case 3:throw new Error(n.message||"Erreur lors de la vérification du statut");case 4:t.n=6;break;case 5:throw t.p=5,r=t.v,this.handleError(r),r;case 6:return t.a(2)}},t,this,[[1,5]])})),function(t){return l.apply(this,arguments)})},{key:"displayQRCode",value:(h=a(f().m(function t(e,n,r){var i,o,s,a,c,h,l,u,d,p,g=arguments;return f().w(function(t){for(;;)switch(t.p=t.n){case 0:if(i=g.length>3&&void 0!==g[3]?g[3]:{},o=document.getElementById(e)){t.n=1;break}throw new Error("Conteneur avec l'ID \"".concat(e,'" non trouvé'));case 1:return o.innerHTML="",t.p=2,s=this.socket?this.socket.id:"no-socket",a="code-".concat(s),c=i.partnerName||"SunuID",h="type-".concat(c),t.n=3,rr.toDataURL(a,{width:200,margin:2,color:{dark:"#000000",light:"#FFFFFF"}});case 3:l=t.v,(u=document.createElement("div")).className="sunuid-qr-code",u.innerHTML='\n <div class="sunuid-qr-header">\n <h3>'.concat(1===r?"Authentification":2===r?"Vérification KYC":3===r?"Service Type 3":"Service Type "+r,'</h3>\n </div>\n <div class="sunuid-qr-image">\n <div class="sunuid-qr-wrapper" style="position: relative; display: inline-block;">\n <img src="').concat(l,'" alt="QR Code SunuID" style="max-width: 300px; height: auto;">\n <div class="sunuid-qr-center-logo" style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; border-radius: 50%; padding: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">\n <svg width="40" height="40" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" fill="#007bff" stroke="#0056b3" stroke-width="2"/>\n <path d="M12 16 L16 16 L16 20 L20 20 L20 24 L16 24 L16 28 L12 28 Z" fill="white"/>\n <path d="M24 12 L28 12 L28 16 L24 16 Z" fill="white"/>\n <path d="M24 24 L28 24 L28 28 L24 28 Z" fill="white"/>\n <path d="M28 16 L32 16 L32 20 L28 20 Z" fill="white"/>\n </svg>\n </div>\n <div class="sunuid-qr-label" style="position: absolute; bottom: -30px; left: 50%; transform: translateX(-50%); background: #007bff; color: white; padding: 4px 12px; border-radius: 15px; font-size: 12px; font-weight: bold;">\n <span class="sunuid-label-text">').concat(h,'</span>\n </div>\n </div>\n </div>\n <div class="sunuid-qr-instructions">\n <p>Scannez ce QR code avec l\'application SunuID pour vous connecter</p>\n </div>\n <div class="sunuid-qr-status" id="sunuid-status">\n <p>En attente de scan...</p>\n </div>\n '),o.appendChild(u),this.applyTheme(i.theme||this.config.theme),console.log("🎨 QR code personnalisé généré:",{content:a,label:h,socketId:s}),t.n=5;break;case 4:t.p=4,p=t.v,console.error("❌ Erreur génération QR code:",p),(d=document.createElement("div")).className="sunuid-qr-code",d.innerHTML='\n <div class="sunuid-qr-header">\n <h3>'.concat(1===r?"Authentification":2===r?"Vérification KYC":3===r?"Service Type 3":"Service Type "+r,'</h3>\n </div>\n <div class="sunuid-qr-image">\n <img src="').concat(n,'" alt="QR Code SunuID" style="max-width: 300px; height: auto;">\n </div>\n <div class="sunuid-qr-instructions">\n <p>Scannez ce QR code avec l\'application SunuID pour vous connecter</p>\n </div>\n <div class="sunuid-qr-status" id="sunuid-status">\n <p>En attente de scan...</p>\n </div>\n '),o.appendChild(d),this.applyTheme(i.theme||this.config.theme);case 5:return t.a(2)}},t,this,[[2,4]])})),function(t,e,n){return h.apply(this,arguments)})},{key:"displayServiceUnavailable",value:function(t,e){console.log("displayServiceUnavailable appelée pour ".concat(t,", type: ").concat(e));var n=document.getElementById(t);n?n.innerHTML='\n <div class="sunuid-service-unavailable" style="\n text-align: center;\n padding: 40px 20px;\n background: #f8f9fa;\n border: 2px dashed #dee2e6;\n border-radius: 10px;\n color: #6c757d;\n font-family: Arial, sans-serif;\n ">\n <div style="font-size: 48px; margin-bottom: 20px;">⚠️</div>\n <h3 style="margin: 0 0 10px 0; color: #495057;">Service Non Disponible</h3>\n <p style="margin: 0; font-size: 14px;">\n Le service d\'authentification est temporairement indisponible.<br>\n Veuillez réessayer plus tard.\n </p>\n <div style="margin-top: 20px; font-size: 12px; color: #adb5bd;">\n Type: '.concat(e.toUpperCase(),"\n </div>\n </div>\n "):console.error("Container ".concat(t," non trouvé"))}},{key:"refreshQR",value:(s=a(f().m(function t(e){var n,r,i,o=arguments;return f().w(function(t){for(;;)switch(t.p=t.n){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:{},t.p=1,t.n=2,this.generateQR(e,n);case 2:return r=t.v,t.a(2,r);case 3:throw t.p=3,i=t.v,console.error("Erreur lors du rafraîchissement:",i.message),this.displayServiceUnavailable(e,this.config.type),i;case 4:return t.a(2)}},t,this,[[1,3]])})),function(t){return s.apply(this,arguments)})},{key:"startAutoRefresh",value:function(t,e,n){var r=this;this.config.autoRefresh&&(this.refreshTimer=setInterval(a(f().m(function i(){var o;return f().w(function(i){for(;;)switch(i.p=i.n){case 0:return i.p=0,i.n=1,r.refreshQR(t,e,n);case 1:i.n=3;break;case 2:i.p=2,o=i.v,console.warn("Erreur lors du rafraîchissement automatique:",o);case 3:return i.a(2)}},i,null,[[0,2]])})),this.config.refreshInterval))}},{key:"makeRequest",value:(o=a(f().m(function e(n,r){var i,o,s,a,c,h,l,d;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return o=(null===(i=t.SunuIDConfig)||void 0===i||null===(i=i.endpoints)||void 0===i?void 0:i[n.replace("/","")])||n,s="".concat(this.config.apiUrl).concat(o),void 0!==r.type&&console.log("🌐 Envoi requête API - Type: ".concat(r.type,", Endpoint: ").concat(n)),e.p=1,e.n=2,fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.config.clientId,":").concat(this.config.secretId),Accept:"application/json"},body:JSON.stringify(u(u({},r),{},{client_id:this.config.clientId,secret_id:this.config.secretId}))});case 2:if((a=e.v).ok){e.n=4;break}return e.n=3,a.text();case 3:c=e.v;try{h=JSON.parse(c)}catch(t){h={message:c}}throw new Error(h.message||"Erreur HTTP: ".concat(a.status));case 4:return e.n=5,a.json();case 5:return l=e.v,e.a(2,l);case 6:throw e.p=6,d=e.v,console.error("Erreur API SunuID:",d),d;case 7:return e.a(2)}},e,this,[[1,6]])})),function(t,e){return o.apply(this,arguments)})},{key:"applyTheme",value:function(t){var e=document.querySelector(".sunuid-qr-code");e&&(e.className="sunuid-qr-code sunuid-theme-".concat(t))}},{key:"handleError",value:function(t){console.error("SunuID SDK Error:",t),this.config.onError&&this.config.onError(t)}},{key:"destroy",value:function(){this.refreshTimer&&clearInterval(this.refreshTimer),this.socket&&(this.socket.disconnect(),this.socket=null,console.log("🌐 WebSocket déconnecté")),this.isInitialized=!1,console.log("SunuID SDK détruit")}}],r&&c(e.prototype,r),i&&c(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,i,o,s,h,l,d,p,g,_}();t.SunuID=r,t.sunuidInstance=null,t.initSunuID=function(e){try{return t.sunuidInstance=new r(e),t.sunuidInstance}catch(t){throw console.error("Erreur lors de l'initialisation de SunuID:",t),t}}}(window)}(require$$1$2,require$$0,require$$1,require$$1$1,require$$0$1,require$$3);
3
+ var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var a=i&&i.prototype instanceof u?i:u,l=Object.create(a.prototype);return c(l,"_invoke",function(n,i,r){var o,a,c,u=0,l=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return o=t,a=0,c=e,f.n=n,s}};function p(n,i){for(a=n,c=i,t=0;!d&&u&&!r&&t<l.length;t++){var r,o=l[t],p=f.p,h=o[2];n>3?(r=h===i)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=p&&((r=n<2&&p<o[1])?(a=0,f.v=i,f.n=o[1]):p<h&&(r=n<3||o[0]>i||i>h)&&(o[4]=n,o[5]=i,f.n=h,a=0))}if(r||n>1)return s;throw d=!0,i}return function(r,l,h){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,h),a=l,c=h;(t=a<2?e:c)||!d;){o||(a?a<3?(a>1&&(f.n=-1),p(a,c)):f.n=c:f.v=c);try{if(u=2,o){if(a||(r="next"),t=o[r]){if(!(t=t.call(o,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=o.return)&&t.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);o=e}else if((t=(d=f.n<0)?c:n.call(i,f))!==s)break}catch(t){o=e,a=1,c=t}finally{u=1}}return{value:t,done:d}}}(n,r,o),!0),l}var s={};function u(){}function l(){}function d(){}t=Object.getPrototypeOf;var f=[][i]?t(t([][i]())):(c(t={},i,function(){return this}),t),p=d.prototype=u.prototype=Object.create(f);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,r,"GeneratorFunction")),e.prototype=Object.create(p),e}return l.prototype=d,c(p,"constructor",d),c(d,"constructor",l),l.displayName="GeneratorFunction",c(d,r,"GeneratorFunction"),c(p),c(p,r,"Generator"),c(p,i,function(){return this}),c(p,"toString",function(){return"[object Generator]"}),(a=function(){return{w:o,m:h}})()}function c(e,t,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}c=function(e,t,n,i){function o(t,n){c(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},c(e,t,n,i)}function u(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function l(t,n){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,s,a=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(e){u=!0,r=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw r}}return a}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}
4
+ /**
5
+ * SunuID SDK - Package d'intégration pour partenaires
6
+ *
7
+ * @version 1.0.0
8
+ * @author SunuID Team
9
+ * @license MIT
10
+ */(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}!function(e,t){var r={apiUrl:(null===(t=e.SunuIDConfig)||void 0===t?void 0:t.apiUrl)||"https://api.sunuid.fayma.sn",clientId:null,secretId:null,type:2,partnerName:"SunuID",theme:"light",language:"fr",autoRefresh:!0,refreshInterval:3e4,onSuccess:null,onError:null,onStatusUpdate:null,onExpired:null,enableSecurityLogs:!0,validateInputs:!0,maxRetries:3,requestTimeout:1e4,secureInit:!1,secureInitUrl:"http://localhost:8081/secure-init.php",token:null},o=function(){return t=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=s(s({},r),t),this.qrCode=null,this.refreshTimer=null,this.isInitialized=!1,this.socket=null,this.initPromise=this.init()},o=[{key:"init",value:(k=n(a().m(function e(){var t;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,!this.config.secureInit){e.n=2;break}return e.n=1,this.secureInit();case 1:e.n=3;break;case 2:this.config.validateInputs&&this.validateSecurityParams();case 3:this.logSecurityEvent("SDK_INIT_START",{apiUrl:this.config.apiUrl,type:this.config.type,partnerName:this.config.partnerName,secureInit:this.config.secureInit}),this.obfuscateCredentials(),this.isInitialized=!0,console.log("SunuID SDK initialisé avec succès"),this.logSecurityEvent("SDK_INIT_SUCCESS"),this.initWebSocket(),e.n=5;break;case 4:throw e.p=4,t=e.v,this.logSecurityEvent("SDK_INIT_ERROR",{error:t.message}),t;case 5:return e.a(2)}},e,this,[[0,4]])})),function(){return k.apply(this,arguments)})},{key:"secureInit",value:(b=n(a().m(function e(){var t,n,i,r,o;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,this.logSecurityEvent("SECURE_INIT_START"),t={type:this.config.type,partnerName:this.config.partnerName,theme:this.config.theme},e.n=1,fetch(this.config.secureInitUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t)});case 1:if((n=e.v).ok){e.n=2;break}throw new Error("Erreur HTTP: ".concat(n.status));case 2:return e.n=3,n.json();case 3:if((i=e.v).success){e.n=4;break}throw new Error(i.error||"Erreur lors de l'initialisation sécurisée");case 4:if(this.config.token=i.data.token,this.config.apiUrl=i.data.api_url,!(r=this.decodeSecureToken(i.data.token))){e.n=5;break}this.config.clientId=r.client_id,this.config.secretId=r.secret_id,e.n=6;break;case 5:throw new Error("Impossible de décoder le token sécurisé");case 6:this.config.expiresIn=i.data.expires_in,this.config.maxRequests=i.data.max_requests,this.config.requestCount=0,this.logSecurityEvent("SECURE_INIT_SUCCESS",{expiresIn:i.data.expires_in,maxRequests:i.data.max_requests}),console.log("✅ Initialisation sécurisée réussie"),e.n=8;break;case 7:throw e.p=7,o=e.v,this.logSecurityEvent("SECURE_INIT_ERROR",{error:o.message}),new Error("Échec de l'initialisation sécurisée: ".concat(o.message));case 8:return e.a(2)}},e,this,[[0,7]])})),function(){return b.apply(this,arguments)})},{key:"decodeSecureToken",value:function(e){try{var t=e.split(".");if(2!==t.length)return console.error("❌ Format de token invalide"),null;var n=l(t,2),i=n[0],r=(n[1],atob(i)),o=JSON.parse(r);return o.exp&&o.exp<Date.now()/1e3?(console.error("❌ Token expiré"),null):(console.log("✅ Token décodé avec succès"),o)}catch(e){return console.error("❌ Erreur décodage token:",e),null}}},{key:"initWebSocket",value:function(){var e=this;try{if("undefined"==typeof io)return console.warn("⚠️ Socket.IO non disponible, WebSocket sera initialisé plus tard"),void setTimeout(function(){return e.initWebSocket()},1e3);var t=this.getClientIP();this.socket||(this.socket=io("wss://samasocket.fayma.sn:9443",{query:{token:this.config.clientId,type:"web",userId:this.config.clientId,username:t}}),this.socket.on("connect",function(){console.log("🌐 WebSocket connecté avec succès"),console.log("📊 Socket ID:",e.socket.id)}),this.socket.on("disconnect",function(e){console.log("❌ WebSocket déconnecté:",e)}),this.socket.on("connect_error",function(e){console.error("❌ Erreur connexion WebSocket:",e)}),this.socket.on("qr_status_update",function(t){console.log("📱 Mise à jour statut QR reçue:",t),e.handleQRStatusUpdate(t)}),this.socket.on("qr_scan_success",function(t){console.log("✅ Scan QR réussi reçu:",t),e.handleQRScanSuccess(t)}),this.socket.on("qr_expired",function(t){console.log("⏰ QR expiré reçu:",t),e.handleQRExpired(t)}))}catch(e){console.error("❌ Erreur initialisation WebSocket:",e)}}},{key:"getClientIP",value:function(){return"127.0.0.1"}},{key:"getTypeName",value:function(e){switch(e){case 1:return"KYC";case 2:return"AUTH";case 3:return"SIGNATURE";default:return"TYPE-".concat(e)}}},{key:"validateSecurityParams",value:function(){var e=[];if(this.config.clientId&&"string"==typeof this.config.clientId?this.config.clientId.length<10&&e.push("clientId trop court"):e.push("clientId invalide ou manquant"),this.config.secretId&&"string"==typeof this.config.secretId?this.config.secretId.length<32&&e.push("secretId trop court (minimum 32 caractères)"):e.push("secretId invalide ou manquant"),this.config.apiUrl&&this.isValidUrl(this.config.apiUrl)||e.push("apiUrl invalide"),[1,2,3].includes(this.config.type)||e.push("type invalide (doit être 1, 2 ou 3)"),e.length>0)throw this.logSecurityEvent("VALIDATION_ERROR",{errors:e}),new Error("Paramètres de sécurité invalides: ".concat(e.join(", ")));this.logSecurityEvent("VALIDATION_SUCCESS")}},{key:"isValidUrl",value:function(e){try{var t=new URL(e);return"https:"===t.protocol||"http:"===t.protocol}catch(e){return!1}}},{key:"logSecurityEvent",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.config.enableSecurityLogs){var i={timestamp:(new Date).toISOString(),event:t,data:n,userAgent:navigator.userAgent,url:e.location.href};console.warn("🔒 [SECURITY]",i),e.SunuIDSecurityLogs||(e.SunuIDSecurityLogs=[]),e.SunuIDSecurityLogs.push(i)}}},{key:"obfuscateCredentials",value:function(){this.config.originalClientId=this.config.clientId,this.config.originalSecretId=this.config.secretId,this.config.clientId&&(this.config.clientIdDisplay=this.config.clientId.replace(/(.{3}).*(.{3})/,"$1***$2")),this.config.secretId&&(this.config.secretIdDisplay=this.config.secretId.replace(/(.{4}).*(.{4})/,"$1***$2"))}},{key:"sanitizeInput",value:function(e){return"string"!=typeof e?e:e.replace(/[<>]/g,"").replace(/javascript:/gi,"").trim()}},{key:"handleQRStatusUpdate",value:function(e){this.config.onStatusUpdate&&this.config.onStatusUpdate(e)}},{key:"handleQRScanSuccess",value:function(e){this.config.onSuccess&&this.config.onSuccess(e)}},{key:"handleQRExpired",value:function(e){this.config.onExpired&&this.config.onExpired(e)}},{key:"emitWebSocketEvent",value:function(e,t){this.socket&&this.socket.connected?(this.socket.emit(e,t),console.log("📤 Événement WebSocket émis: ".concat(e),t)):"undefined"==typeof io?console.warn("⚠️ Socket.IO non disponible, impossible d'émettre l'événement:",e):console.warn("⚠️ WebSocket non connecté, impossible d'émettre l'événement:",e)}},{key:"getWebSocketStatus",value:function(){return this.socket?this.socket.connected?"connected":"disconnected":"not_initialized"}},{key:"forceWebSocketInit",value:function(){"undefined"==typeof io||this.socket||(console.log("🔄 Forçage de l'initialisation WebSocket..."),this.initWebSocket())}},{key:"generateQR",value:(I=n(a().m(function e(t){var n,i,r,o,c,u=this,l=arguments;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=l.length>1&&void 0!==l[1]?l[1]:{},!this.initPromise){e.n=2;break}return e.n=1,this.initPromise;case 1:this.initPromise=null;case 2:if(this.isInitialized){e.n=3;break}throw new Error("SunuID: SDK non initialisé");case 3:return e.p=3,e.n=4,this.makeRequest("/qr-generate",s({type:this.config.type},n));case 4:if(!(i=e.v).success){e.n=5;break}return r="".concat("https://sunuid.fayma.sn").concat(i.data.qrcode),this.currentQRUrl=r,this.displayQRCode(t,r,this.config.type,n),this.pendingQRInfo&&i.data.code&&(o=function(){if(u.socket&&u.socket.id&&"unknown"!==u.socket.id){var e=u.socket.id,t="".concat(u.config.type,"-").concat(i.data.code,"-").concat(e),n=i.data.partnerName||u.config.partnerName||"SunuID",r=u.getTypeName(u.config.type),s="".concat(r," - ").concat(n);u.generateCustomQRCode(t,s,u.pendingQRInfo.options),u.pendingQRInfo=null}else setTimeout(o,100)})(),this.startAutoRefresh(t,this.config.type,n),this.emitWebSocketEvent("qr_generated",{serviceId:i.data.service_id,type:this.config.type,qrCodeUrl:r,code:i.data.code,timestamp:Date.now()}),e.a(2,s(s({},i.data),{},{qrCodeUrl:r,sessionId:i.data.service_id}));case 5:throw new Error(i.message||"Erreur lors de la génération du QR code");case 6:e.n=8;break;case 7:throw e.p=7,c=e.v,console.error("Erreur API détectée:",c.message),console.error("Stack trace complet:",c.stack),console.error("Configuration SDK:",{apiUrl:this.config.apiUrl,type:this.config.type,secureInit:this.config.secureInit,clientId:this.config.clientId?"***"+this.config.clientId.slice(-4):"null",secretId:this.config.secretId?"***"+this.config.secretId.slice(-4):"null"}),console.log('Affichage du message "Service non disponible" pour type '+this.config.type),this.displayServiceUnavailable(t,this.config.type),new Error("Service non disponible");case 8:return e.a(2)}},e,this,[[3,7]])})),function(e){return I.apply(this,arguments)})},{key:"generateCustomQR",value:(S=n(a().m(function e(t,n){var i,r,o,c,u,l=this,d=arguments;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:if(i=d.length>2&&void 0!==d[2]?d[2]:{},!this.initPromise){e.n=2;break}return e.n=1,this.initPromise;case 1:this.initPromise=null;case 2:if(this.isInitialized){e.n=3;break}throw new Error("SunuID: SDK non initialisé");case 3:return e.p=3,e.n=4,this.makeRequest("/qr-generate",s({type:n},i));case 4:if(!(r=e.v).success){e.n=5;break}return o="".concat("https://sunuid.fayma.sn").concat(r.data.qrcode),this.displayQRCode(t,o,n,i),this.pendingQRInfo&&r.data.code&&(c=function(){if(l.socket&&l.socket.id&&"unknown"!==l.socket.id){var e=l.socket.id,t="".concat(n,"-").concat(r.data.code,"-").concat(e),i=r.data.partnerName||l.config.partnerName||"SunuID",o=l.getTypeName(n),s="".concat(o," - ").concat(i);l.generateCustomQRCode(t,s,l.pendingQRInfo.options),l.pendingQRInfo=null}else setTimeout(c,100)})(),this.startAutoRefresh(t,n,i),e.a(2,s(s({},r.data),{},{qrCodeUrl:o,sessionId:r.data.service_id}));case 5:throw new Error(r.message||"Erreur lors de la génération du QR code");case 6:e.n=8;break;case 7:throw e.p=7,u=e.v,console.error("Erreur API détectée:",u.message),console.error("Stack trace complet:",u.stack),console.error("Configuration SDK (Custom):",{apiUrl:this.config.apiUrl,type:n,secureInit:this.config.secureInit,clientId:this.config.clientId?"***"+this.config.clientId.slice(-4):"null",secretId:this.config.secretId?"***"+this.config.secretId.slice(-4):"null"}),console.log('Affichage du message "Service non disponible" pour type '+n),this.displayServiceUnavailable(t,n),new Error("Service non disponible");case 8:return e.a(2)}},e,this,[[3,7]])})),function(e,t){return S.apply(this,arguments)})},{key:"generateAuthQR",value:(m=n(a().m(function e(t){var n,i=arguments;return a().w(function(e){for(;;)if(0===e.n)return n=i.length>1&&void 0!==i[1]?i[1]:{},e.a(2,this.generateQR(t,n))},e,this)})),function(e){return m.apply(this,arguments)})},{key:"generateKYCQR",value:(v=n(a().m(function e(t){var n,i,r=arguments;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:return n=r.length>1&&void 0!==r[1]?r[1]:{},i=this.config.type,this.config.type=1,e.p=1,e.n=2,this.generateQR(t,n);case 2:return e.a(2,e.v);case 3:return e.p=3,this.config.type=i,e.f(3);case 4:return e.a(2)}},e,this,[[1,,3,4]])})),function(e){return v.apply(this,arguments)})},{key:"generateSignatureQR",value:(y=n(a().m(function e(t){var n,i,r=arguments;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:return n=r.length>1&&void 0!==r[1]?r[1]:{},i=this.config.type,this.config.type=3,e.p=1,e.n=2,this.generateQR(t,n);case 2:return e.a(2,e.v);case 3:return e.p=3,this.config.type=i,e.f(3);case 4:return e.a(2)}},e,this,[[1,,3,4]])})),function(e){return y.apply(this,arguments)})},{key:"checkQRStatus",value:(g=n(a().m(function e(t){var n,i;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.isInitialized){e.n=1;break}throw new Error("SunuID: SDK non initialisé");case 1:return e.p=1,e.n=2,this.makeRequest("/qr-status",{serviceId:t});case 2:if(!(n=e.v).success){e.n=3;break}return e.a(2,n.data);case 3:throw new Error(n.message||"Erreur lors de la vérification du statut");case 4:e.n=6;break;case 5:throw e.p=5,i=e.v,this.handleError(i),i;case 6:return e.a(2)}},e,this,[[1,5]])})),function(e){return g.apply(this,arguments)})},{key:"displayQRCode",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=document.getElementById(e);if(!r)throw new Error("Conteneur avec l'ID \"".concat(e,'" non trouvé'));r.innerHTML="";var o=document.createElement("div");o.className="sunuid-qr-code",this.getTypeName(n),o.innerHTML='\n <div class="sunuid-qr-header">\n <h3>'.concat(1===n?"Vérification KYC":2===n?"Authentification":3===n?"Signature":"Service Type "+n,'</h3>\n </div>\n <div class="sunuid-qr-image" id="sunuid-qr-container">\n <div style="text-align: center; padding: 40px;">\n <div class="sunuid-loader">\n <div class="sunuid-spinner"></div>\n <p style="margin-top: 20px; color: #666;">Initialisation en cours...</p>\n <p style="font-size: 12px; color: #999; margin-top: 10px;">Connexion API et WebSocket</p>\n <p style="font-size: 11px; color: #ccc; margin-top: 5px;">Attente du Socket ID...</p>\n </div>\n </div>\n </div>\n <div class="sunuid-qr-instructions" style="display: none;">\n <p>Scannez ce QR code avec l\'application SunuID pour vous connecter</p>\n </div>\n <div class="sunuid-qr-status" id="sunuid-status" style="display: none;">\n <p>En attente de scan...</p>\n </div>\n '),r.appendChild(o),this.pendingQRInfo={containerId:e,type:n,options:i},this.applyTheme(i.theme||this.config.theme)}},{key:"generateCustomQRCode",value:(h=n(a().m(function e(t,n){var i,r,o,s,c,u;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=1,console.log("🎨 Début génération QR personnalisé avec PHP..."),console.log("📄 Contenu:",t),console.log("🏷️ Label:",n),i=document.getElementById("sunuid-qr-container")){e.n=2;break}return console.error("❌ QR container not found"),this.displayFallbackImage(),e.a(2);case 2:return console.log("✅ QR container trouvé"),i.innerHTML='<div style="text-align: center; padding: 20px;"><p>Génération QR code avec PHP...</p></div>',console.log("🔄 Appel endpoint PHP..."),e.n=3,fetch("http://localhost:8081/qr-generator.php",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:t,label:n,size:300,margin:10})});case 3:if(r=e.v,console.log("📥 Réponse PHP reçue - Status:",r.status),r.ok){e.n=4;break}throw new Error("Erreur HTTP: ".concat(r.status));case 4:return e.n=5,r.json();case 5:if((o=e.v).success){e.n=6;break}throw new Error("Erreur PHP: ".concat(o.error));case 6:console.log("✅ QR code généré par PHP avec succès"),console.log("📊 Taille:",o.data.size+"px"),console.log("📊 Longueur base64:",o.data.length+" caractères"),this.currentQRUrl=o.data.dataUrl,i.innerHTML='\n <div class="sunuid-qr-ready" style="text-align: center; padding: 20px;">\n <img src="'.concat(o.data.dataUrl,'" alt="QR Code SunuID" style="max-width: 300px; border: 2px solid #ddd; border-radius: 10px;">\n </div>\n '),s=i.parentElement.querySelector(".sunuid-qr-instructions"),c=i.parentElement.querySelector(".sunuid-qr-status"),s&&(s.style.display="block",s.classList.add("sunuid-qr-ready")),c&&(c.style.display="block",c.classList.add("sunuid-qr-ready")),console.log("✅ QR code PHP affiché dans le conteneur"),e.n=8;break;case 7:e.p=7,u=e.v,console.error("❌ Erreur génération QR PHP:",u),console.error("Stack trace:",u.stack),this.displayFallbackImage();case 8:return e.a(2)}},e,this,[[1,7]])})),function(e,t){return h.apply(this,arguments)})},{key:"addLogoToCenter",value:function(e,t,n,i,r){try{var o=new Image;o.onload=function(){var r=40,s=t+(i-r)/2,a=n+(i-r)/2;e.fillStyle="white",e.fillRect(s-2,a-2,44,44),e.drawImage(o,s,a,r,r)},o.src="src/logoqr.png"}catch(e){console.warn("Logo non disponible:",e)}}},{key:"displayFallbackImage",value:function(){console.log("⚠️ Affichage de l'image de fallback");var e=document.getElementById("sunuid-qr-container");e?e.innerHTML='\n <div style="text-align: center; padding: 20px; color: #666;">\n <p>⚠️ Génération QR personnalisé non disponible</p>\n <p>Utilisation de l\'image par défaut</p>\n <p><strong>Debug:</strong> QRCode disponible: '.concat("undefined"!=typeof QRCode,"</p>\n <p><strong>Debug:</strong> Container trouvé: ").concat(null!==e,"</p>\n </div>\n "):console.error("❌ Container QR non trouvé pour fallback")}},{key:"displayServiceUnavailable",value:function(e,t){console.log("displayServiceUnavailable appelée pour ".concat(e,", type: ").concat(t));var n=document.getElementById(e);n?n.innerHTML='\n <div class="sunuid-service-unavailable" style="\n text-align: center;\n padding: 40px 20px;\n background: #f8f9fa;\n border: 2px dashed #dee2e6;\n border-radius: 10px;\n color: #6c757d;\n font-family: Arial, sans-serif;\n ">\n <div style="font-size: 48px; margin-bottom: 20px;">⚠️</div>\n <h3 style="margin: 0 0 10px 0; color: #495057;">Service Non Disponible</h3>\n <p style="margin: 0; font-size: 14px;">\n Le service d\'authentification est temporairement indisponible.<br>\n Veuillez réessayer plus tard.\n </p>\n <div style="margin-top: 20px; font-size: 12px; color: #adb5bd;">\n Type: '.concat(String(t).toUpperCase(),"\n </div>\n </div>\n "):console.error("Container ".concat(e," non trouvé"))}},{key:"refreshQR",value:(p=n(a().m(function e(t){var n,i,r,o=arguments;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:{},e.p=1,e.n=2,this.generateQR(t,n);case 2:return i=e.v,e.a(2,i);case 3:throw e.p=3,r=e.v,console.error("Erreur lors du rafraîchissement:",r.message),this.displayServiceUnavailable(t,this.config.type),r;case 4:return e.a(2)}},e,this,[[1,3]])})),function(e){return p.apply(this,arguments)})},{key:"startAutoRefresh",value:function(e,t,i){var r=this;this.config.autoRefresh&&(this.refreshTimer=setInterval(n(a().m(function n(){var o;return a().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,r.refreshQR(e,t,i);case 1:n.n=3;break;case 2:n.p=2,o=n.v,console.warn("Erreur lors du rafraîchissement automatique:",o);case 3:return n.a(2)}},n,null,[[0,2]])})),this.config.refreshInterval))}},{key:"makeRequest",value:(d=n(a().m(function t(n,i){var r,o,s,c,l,d,f,p,h,g=this;return a().w(function(t){for(;;)switch(t.n){case 0:if(this.isInitialized){t.n=1;break}throw this.logSecurityEvent("REQUEST_BEFORE_INIT",{endpoint:n}),new Error("SDK non initialisé");case 1:if(!this.config.secureInit){t.n=2;break}if(this.config.requestCount++,!(this.config.requestCount>this.config.maxRequests)){t.n=2;break}throw this.logSecurityEvent("API_REQUEST_LIMIT_EXCEEDED",{requestCount:this.config.requestCount,maxRequests:this.config.maxRequests}),new Error("Limite de requêtes dépassée");case 2:s=this.sanitizeRequestData(i),console.log("🔍 Debug makeRequest - endpoint:",n),console.log("🔍 Debug makeRequest - apiUrl:",this.config.apiUrl),console.log("🔍 Debug makeRequest - url:","".concat(this.config.apiUrl).concat(n)),console.log("🔍 Debug makeRequest - data:",JSON.stringify(s,null,2)),console.log("🔍 Debug makeRequest - secureInit:",this.config.secureInit),console.log("🔍 Debug makeRequest - isInitialized:",this.isInitialized),c=(null===(r=e.SunuIDConfig)||void 0===r||null===(r=r.endpoints)||void 0===r?void 0:r[n.replace("/","")])||n,l="".concat(this.config.apiUrl).concat(c),console.log("🔍 URL finale construite:",l),console.log("🔍 EndpointPath:",c),console.log("🔍 SunuIDConfig endpoints:",JSON.stringify(null===(o=e.SunuIDConfig)||void 0===o?void 0:o.endpoints)),this.logSecurityEvent("API_REQUEST_START",{endpoint:c,url:l,dataKeys:Object.keys(s),secureInit:this.config.secureInit}),d=0,f=this.config.maxRetries,p=a().m(function e(){var t,n,i,r,o,u,p,h;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,t=new AbortController,n=setTimeout(function(){return t.abort()},g.config.requestTimeout),i={"Content-Type":"application/json"},e.n=1,fetch(l,{method:"POST",headers:i,body:JSON.stringify(s),signal:t.signal});case 1:if(r=e.v,clearTimeout(n),r.ok){e.n=3;break}return e.n=2,r.text();case 2:o=e.v;try{u=JSON.parse(o)}catch(e){u={message:o}}throw g.logSecurityEvent("API_REQUEST_ERROR",{status:r.status,statusText:r.statusText,error:u.message}),new Error(u.message||"Erreur HTTP: ".concat(r.status));case 3:return e.n=4,r.json();case 4:return p=e.v,g.logSecurityEvent("API_REQUEST_SUCCESS",{endpoint:c,responseKeys:Object.keys(p)}),e.a(2,{v:p});case 5:if(e.p=5,h=e.v,d++,"AbortError"!==h.name){e.n=7;break}if(g.logSecurityEvent("API_REQUEST_TIMEOUT",{retryCount:d}),!(d>f)){e.n=6;break}throw new Error("Timeout de la requête API");case 6:return e.a(2,0);case 7:if(!(d>f)){e.n=8;break}throw g.logSecurityEvent("API_REQUEST_MAX_RETRIES",{retryCount:d,error:h.message}),h;case 8:return e.n=9,new Promise(function(e){return setTimeout(e,1e3*d)});case 9:return e.a(2)}},e,null,[[0,5]])});case 3:if(!(d<=f)){t.n=7;break}return t.d(u(p()),4);case 4:if(0!==(h=t.v)){t.n=5;break}return t.a(3,3);case 5:if(!h){t.n=6;break}return t.a(2,h.v);case 6:t.n=3;break;case 7:return t.a(2)}},t,this)})),function(e,t){return d.apply(this,arguments)})},{key:"sanitizeRequestData",value:function(e){for(var t={},n=0,i=Object.entries(e);n<i.length;n++){var r=l(i[n],2),o=r[0],s=r[1];"string"==typeof s?t[o]=this.sanitizeInput(s):"object"===f(s)&&null!==s?t[o]=this.sanitizeRequestData(s):t[o]=s}return t.client_id=this.config.originalClientId||this.config.clientId,t.secret_id=this.config.originalSecretId||this.config.secretId,console.log("🔍 Credentials dans sanitizeRequestData - clientId:",this.config.clientId),console.log("🔍 Credentials dans sanitizeRequestData - secretId:",this.config.secretId?"***"+this.config.secretId.slice(-4):"null"),console.log("🔍 Credentials dans sanitizeRequestData - sanitizedClientId:",t.client_id),console.log("🔍 Credentials dans sanitizeRequestData - sanitizedSecretId:",t.secret_id?"***"+t.secret_id.slice(-4):"null"),console.log("🔍 Credentials dans sanitizeRequestData - data complet:",JSON.stringify(t,null,2)),console.log("🔍 Credentials dans sanitizeRequestData - clientId:",this.config.clientId),console.log("🔍 Credentials dans sanitizeRequestData - secretId:",this.config.secretId?"***"+this.config.secretId.slice(-4):"null"),console.log("🔍 Credentials dans sanitizeRequestData - sanitizedClientId:",t.client_id),console.log("🔍 Credentials dans sanitizeRequestData - sanitizedSecretId:",t.secret_id?"***"+t.secret_id.slice(-4):"null"),console.log("🔍 Credentials dans sanitizeRequestData - data complet:",JSON.stringify(t,null,2)),t}},{key:"generateRequestId",value:function(){return"req_"+Date.now()+"_"+Math.random().toString(36).substr(2,9)}},{key:"applyTheme",value:function(e){var t=document.querySelector(".sunuid-qr-code");t&&(t.className="sunuid-qr-code sunuid-theme-".concat(e))}},{key:"handleError",value:function(e){console.error("SunuID SDK Error:",e),this.config.onError&&this.config.onError(e)}},{key:"getQRCode",value:function(){return this.currentQRUrl?this.currentQRUrl:null}},{key:"destroy",value:function(){this.refreshTimer&&clearInterval(this.refreshTimer),this.socket&&(this.socket.disconnect(),this.socket=null,console.log("🌐 WebSocket déconnecté")),this.isInitialized=!1,this.logSecurityEvent("SDK_DESTROY"),console.log("SunuID SDK détruit")}},{key:"getSecurityLogs",value:function(){return e.SunuIDSecurityLogs||[]}},{key:"clearSecurityLogs",value:function(){e.SunuIDSecurityLogs=[],this.logSecurityEvent("SECURITY_LOGS_CLEARED")}}],o&&i(t.prototype,o),c&&i(t,c),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,o,c,d,p,h,g,y,v,m,S,I,b,k}();e.SunuID=o,e.sunuidInstance=null,e.initSunuID=function(t){try{return e.sunuidInstance=new o(t),e.sunuidInstance}catch(e){throw console.error("Erreur lors de l'initialisation de SunuID:",e),e}}}(window)}();
4
11
  //# sourceMappingURL=sunuid-sdk.min.js.map