!function(e,r){"object"==typeofexports&&"object"==typeofmodule?module.exports=r():"function"==typeofdefine&&define.amd?define("cryptoPro",[],r):"object"==typeofexports?exports.cryptoPro=r():e.cryptoPro=r()}(window,(function(){returnfunction(e){varr={};functiont(n){if(r[n])returnr[n].exports;vara=r[n]={i:n,l:!1,exports:{}};returne[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}returnt.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeofSymbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)returne;if(4&r&&"object"==typeofe&&e&&e.__esModule)returne;varn=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeofe)for(varaine)t.d(n,a,function(r){returne[r]}.bind(null,a));returnn},t.n=function(e){varr=e&&e.__esModule?function(){returne.default}:function(){returne};returnt.d(r,"a",r),r},t.o=function(e,r){returnObject.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=12)}([function(e,r,t){"use strict";varn=this&&this.__awaiter||function(e,r,t,n){returnnew(t||(t=Promise))((function(a,_){functions(e){try{i(n.next(e))}catch(e){_(e)}}functiono(e){try{i(n.throw(e))}catch(e){_(e)}}functioni(e){varr;e.done?a(e.value):(r=e.value,rinstanceoft?r:newt((function(e){e(r)}))).then(s,o)}i((n=n.apply(e,r||[])).next())}))},a=this&&this.__generator||function(e,r){vart,n,a,_,s={label:0,sent:function(){if(1&a[0])throwa[1];returna[1]},trys:[],ops:[]};return_={next:o(0),throw:o(1),return:o(2)},"function"==typeofSymbol&&(_[Symbol.iterator]=function(){returnthis}),_;functiono(_){returnfunction(o){returnfunction(_){if(t)thrownewTypeError("Generator is already executing.");for(;s;)try{if(t=1,n&&(a=2&_[0]?n.return:_[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,_[1])).done)returna;switch(n=0,a&&(_=[2&_[0],a.value]),_[0]){case0:case1:a=_;break;case4:returns.label++,{value:_[1],done:!1};case5:s.label++,n=_[1],_=[0];continue;case7:_=s.ops.pop(),s.trys.pop();continue;default:if(!(a=s.trys,(a=a.length>0&&a[a.length-1])||6!==_[0]&&2!==_[0])){s=0;continue}if(3===_[0]&&(!a||_[1]>a[0]&&_[1]<a[3])){s.label=_[1];break}if(6===_[0]&&s.label<a[1]){s.label=a[1],a=_;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(_);break}a[2]&&s.ops.pop(),s.trys.pop();continue}_=r.call(e,s)}catch(e){_=[6,e],n=0}finally{t=a=0}if(5&_[0])throw_[1];return{value:_[0]?_[1]:void0,done:!0}}([_,o])}}};Object.defineProperty(r,"__esModule",{value:!0});var_=t(1),s=!1,o=!1;r._afterPluginsLoaded=function(e){varr=Boolean(window.Promise);returnfunction(){for(vari=[],c=0;c<arguments.length;c++)i[c]=arguments[c];returnn(this,void0,void0,(function(){varn,c;returna(this,(function(a){switch(a.label){case0:if(!o){try{t(15)}catch(e){throwconsole.error(e),newError(_._extractMeaningfulErrorMessage(e)||"Ошибка при подключении модуля для работы с Cades plugin")}o=!0}if(n=window.cadesplugin,!r)thrownewError("Необходим полифилл для Promise");if(!n)thrownewError("Не подключен модуль для работы с Cades plugin");s||(n.set_log_level(n.LOG_LEVEL_ERROR),s=!0),a.label=1;case1:returna.trys.push([1,3,,4]),[4,n];case2:returna.sent(),[3,4];case3:throwc=a.sent(),console.error(c),newError(_._extractMeaningfulErrorMessage(c)||"Ошибка при инициализации модуля для работы с Cades plugin");case4:return[4,e.apply(this,i)];case5:return[2,a.sent()]}}))}))}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r._extractMeaningfulErrorMessage=function(e){varr,t=(null===(r=window.cadesplugin)||void0===r?void0:r.getLastError)&&window.cadesplugin.getLastError(e);if(!(null==t?void0:t.message)){if(!e.message)returnnull;t=e}if(!/[а-яА-Я]/.test(t.message))returnnull;varn=t.message.match(/^(.*?)(?:(?:\.?\s?\(?(0x[0-9a-zA-Z]{1,8})\)?)|(?:\.?$))/)
varn=t(38),a=t(39),_=t(40);functions(){returni.TYPED_ARRAY_SUPPORT?2147483647:1073741823}functiono(e,r){if(s()<r)thrownewRangeError("Invalid typed array length");returni.TYPED_ARRAY_SUPPORT?(e=newUint8Array(r)).__proto__=i.prototype:(null===e&&(e=newi(r)),e.length=r),e}functioni(e,r,t){if(!(i.TYPED_ARRAY_SUPPORT||thisinstanceofi))returnnewi(e,r,t);if("number"==typeofe){if("string"==typeofr)thrownewError("If encoding is specified then the first argument must be a string");returnl(this,e)}returnc(this,e,r,t)}functionc(e,r,t,n){if("number"==typeofr)thrownewTypeError('"value" argument must not be a number');return"undefined"!=typeofArrayBuffer&&rinstanceofArrayBuffer?function(e,r,t,n){if(r.byteLength,t<0||r.byteLength<t)thrownewRangeError("'offset' is out of bounds");if(r.byteLength<t+(n||0))thrownewRangeError("'length' is out of bounds");r=void0===t&&void0===n?newUint8Array(r):void0===n?newUint8Array(r,t):newUint8Array(r,t,n);i.TYPED_ARRAY_SUPPORT?(e=r).__proto__=i.prototype:e=d(e,r);returne}(e,r,t,n):"string"==typeofr?function(e,r,t){"string"==typeoft&&""!==t||(t="utf8");if(!i.isEncoding(t))thrownewTypeError('"encoding" must be a valid string encoding');varn=0|g(r,t),a=(e=o(e,n)).write(r,t);a!==n&&(e=e.slice(0,a));returne}(e,r,t):function(e,r){if(i.isBuffer(r)){vart=0|f(r.length);return0===(e=o(e,t)).length||r.copy(e,0,0,t),e}if(r){if("undefined"!=typeofArrayBuffer&&r.bufferinstanceofArrayBuffer||"length"inr)return"number"!=typeofr.length||(n=r.length)!=n?o(e,0):d(e,r);if("Buffer"===r.type&&_(r.data))returnd(e,r.data)}varn;thrownewTypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,r)}functionu(e){if("number"!=typeofe)thrownewTypeError('"size" argument must be a number');if(e<0)thrownewRangeError('"size" argument must not be negative')}functionl(e,r){if(u(r),e=o(e,r<0?0:0|f(r)),!i.TYPED_ARRAY_SUPPORT)for(vart=0;t<r;++t)e[t]=0;returne}functiond(e,r){vart=r.length<0?0:0|f(r.length);e=o(e,t);for(varn=0;n<t;n+=1)e[n]=255&r[n];returne}functionf(e){if(e>=s())thrownewRangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return0|e}functiong(e,r){if(i.isBuffer(e))returne.length;if("undefined"!=typeofArrayBuffer&&"function"==typeofArrayBuffer.isView&&(ArrayBuffer.isView(e)||einstanceofArrayBuffer))returne.byteLength;"string"!=typeofe&&(e=""+e);vart=e.length;if(0===t)return0;for(varn=!1;;)switch(r){case"ascii":case"latin1":case"binary":returnt;case"utf8":case"utf-8":casevoid0:returnG(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return2*t;case"hex":returnt>>>1;case"base64":returnB(e).length;default:if(n)returnG(e).length;r=(""+r).toLowerCase(),n=!0}}functionp(e,r,t){varn=!1;if((void0===r||r<0)&&(r=0),r>this.length)return"";if((void0===t||t>this.length)&&(t=this.length),t<=0)return"";if((t>>>=0)<=(r>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":returnv(this,r,t);case"utf8":case"utf-8":returnw(this,r,t);case"ascii":returnS(this,r,t);case"latin1":case"binary":returnP(this,r,t);case"base64":returnb(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":returnR(this,r,t);default:if(n)thrownewTypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}functionC(e,r,t){varn=e[r];e[r]=e[t],e[t]=n}functionE(e,r,t,n,a){if(0===e.length)return-1;if("string"==typeoft?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=a?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(a)return-1;t=e.length-1}elseif(t<0){if(!a)return-1;t=0}if("string"==typeofr&&(r=i.from(r,n)),i.isBuffer(r))return0===r.length?-1:A(e,r,t,n,a);if("number"==typeofr)returnr&=255,i.TYPED_ARRAY_SUPPORT&&"function"==typeofUint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):A(e,[r],t,n,a);thrownewTypeError("val must be string, number or Buffer")}functionA(e,r,t,n,a){var_,s=1,o=e.length,i=r.length;if(void0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs
r.read=function(e,r,t,n,a){var_,s,o=8*a-n-1,i=(1<<o)-1,c=i>>1,u=-7,l=t?a-1:0,d=t?-1:1,f=e[r+l];for(l+=d,_=f&(1<<-u)-1,f>>=-u,u+=o;u>0;_=256*_+e[r+l],l+=d,u-=8);for(s=_&(1<<-u)-1,_>>=-u,u+=n;u>0;s=256*s+e[r+l],l+=d,u-=8);if(0===_)_=1-c;else{if(_===i)returns?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),_-=c}return(f?-1:1)*s*Math.pow(2,_-n)},r.write=function(e,r,t,n,a,_){vars,o,i,c=8*_-a-1,u=(1<<c)-1,l=u>>1,d=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:_-1,g=n?1:-1,p=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(o=isNaN(r)?1:0,s=u):(s=Math.floor(Math.log(r)/Math.LN2),r*(i=Math.pow(2,-s))<1&&(s--,i*=2),(r+=s+l>=1?d/i:d*Math.pow(2,1-l))*i>=2&&(s++,i/=2),s+l>=u?(o=0,s=u):s+l>=1?(o=(r*i-1)*Math.pow(2,a),s+=l):(o=r*Math.pow(2,l-1)*Math.pow(2,a),s=0));a>=8;e[t+f]=255&o,f+=g,o/=256,a-=8);for(s=s<<a|o,c+=a;c>0;e[t+f]=255&s,f+=g,s/=256,c-=8);e[t+f-g]|=128*p}},function(e,r){vart={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},function(module,exports,__webpack_require__){"use strict";(function(Buffer){var__awaiter=this&&this.__awaiter||function(e,r,t,n){returnnew(t||(t=Promise))((function(a,_){functions(e){try{i(n.next(e))}catch(e){_(e)}}functiono(e){try{i(n.throw(e))}catch(e){_(e)}}functioni(e){varr;e.done?a(e.value):(r=e.value,rinstanceoft?r:newt((function(e){e(r)}))).then(s,o)}i((n=n.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){vart,n,a,_,s={label:0,sent:function(){if(1&a[0])throwa[1];returna[1]},trys:[],ops:[]};return_={next:o(0),throw:o(1),return:o(2)},"function"==typeofSymbol&&(_[Symbol.iterator]=function(){returnthis}),_;functiono(_){returnfunction(o){returnfunction(_){if(t)thrownewTypeError("Generator is already executing.");for(;s;)try{if(t=1,n&&(a=2&_[0]?n.return:_[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,_[1])).done)returna;switch(n=0,a&&(_=[2&_[0],a.value]),_[0]){case0:case1:a=_;break;case4:returns.label++,{value:_[1],done:!1};case5:s.label++,n=_[1],_=[0];continue;case7:_=s.ops.pop(),s.trys.pop();continue;default:if(!(a=s.trys,(a=a.length>0&&a[a.length-1])||6!==_[0]&&2!==_[0])){s=0;continue}if(3===_[0]&&(!a||_[1]>a[0]&&_[1]<a[3])){s.label=_[1];break}if(6===_[0]&&s.label<a[1]){s.label=a[1],a=_;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(_);break}a[2]&&s.ops.pop(),s.trys.pop();continue}_=r.call(e,s)}catch(e){_=[6,e],n=0}finally{t=a=0}if(5&_[0])throw_[1];return{value:_[0]?_[1]:void0,done:!0}}([_,o])}}};Object.defineProperty(exports,"__esModule",{value:!0});varconstants_1=__webpack_require__(3),_afterPluginsLoaded_1=__webpack_require__(0),_extractMeaningfulErrorMessage_1=__webpack_require__(1),_generateCadesFn_1=__webpack_require__(2),_getCadesCert_1=__webpack_require__(4),_getDateObj_1=__webpack_require__(5);exports.addAttachedSignature=_afterPluginsLoaded_1._afterPluginsLoaded((function(thumbprint,signedMessage){return__awaiter(void0,void0,void0,(function(){varcadesplugin,cadesCertificate;return__generator(this,(function(_a){switch(_a.label){case0:returncadesplugin=window.cadesplugin,[4,_getCadesCert_1._getCadesCert(thumbprint)];case1:returncadesCertificate=_a.sent(),[2,eval(_generateCadesFn_1._generateCadesFn((function(){vare,r,t;try{e=_generateCadesFn_1.__cadesAsyncToken__+_generateCadesFn_1.__createCadesPluginObject__("CADESCOM.CPAttribute"),r=_generateCadesFn_1.__cadesAsyncToken__+_generateCadesFn_1.__createCadesPluginObject__("CAdESCOM.CadesSignedData"),t=_generateCadesFn_1.__cadesAsyncToken__+_generateCadesFn_1.__createCadesPluginObject__("CAdESCOM.CPSigner")}catch(e){throwconsole.error(e),newError(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(e)||"Ошибка при инициализации подписи")}varn,a,_,s=_getDateObj_1._getDateObj(newDate);try{_generateCadesFn_1.__cadesAsyncToken__,e.propset_Name(constants_1.CADESCOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME),_generateCadesFn_1.__cadesAsyncToken__,e.propset_Value(s)}catch(e){throwconsole.error(e),newError(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(e)||"Ошибкап