uploadcare-widget
Version:
Uploadcare Widget: file uploader.
26 lines (25 loc) • 86.8 kB
JavaScript
/**
* @license uploadcare-widget v3.23.3
*
* Copyright (c) 2025 Uploadcare, Inc.
*
* This source code is licensed under the BSD 2-Clause License
* found in the LICENSE file in the root directory of this source tree.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).uploadcare=t(e.$)}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function r(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 o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(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:String(t)}function s(e){return(s="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})(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(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,a(i.key),i)}}function f(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t,n){return(t=a(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=p(e);if(t){var r=p(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return v(this,n)}}function _(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}function b(){return(b="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=_(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}}).apply(this,arguments)}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){l=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return s}}(e,t)||k(e,t)||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 A(e){return function(e){if(Array.isArray(e))return x(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||k(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){if(e){if("string"==typeof e)return x(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(e,t):void 0}}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var S=function(){var e;try{var t;return null!=(e=window.console)&&"function"==typeof e.log?(t=e).log.apply(t,arguments):void 0}catch(e){}},C=function(){var e;if(!(null!=(e=window.console)?e.debug:void 0))return S.apply(void 0,["Debug:"].concat(Array.prototype.slice.call(arguments)));try{var t;return(t=window.console).debug.apply(t,arguments)}catch(e){}},T=function(){var e;if(!(null!=(e=window.console)?e.warn:void 0))return S.apply(void 0,["Warning:"].concat(Array.prototype.slice.call(arguments)));try{var t;return(t=window.console).warn.apply(t,arguments)}catch(e){}},j={},U=function(e){if(null==j[e])return j[e]=!0,T(e)},I=function(){return"object"===("undefined"==typeof window?"undefined":s(window))},O=Object.freeze({__proto__:null,isWindowDefined:I});function P(e,t,n){var i;if("RequestThrottledError"===(null==e||null===(i=e.responseJSON)||void 0===i||null===(i=i.error)||void 0===i?void 0:i.error_code)&&n.attempt<t.throttledAttempts){var r=Number.parseFloat(e.getResponseHeader("retry-after"));return{shouldRetry:!0,retryTimeout:Number.isFinite(r)?Math.ceil(1e3*r):15e3}}return-1!==["error","timeout"].indexOf(e.statusText)&&n.attempt<t.attempts?{shouldRetry:!0,retryTimeout:Math.round(t.baseTimeout*Math.pow(t.factor,n.attempt))}:{shouldRetry:!1}}function D(e,t,i,r){var a=["baseTimeout","attempts","factor"].find((function(e){return void 0===i[e]}));if(a)return T('Option key "'.concat(a,'" is missed in the retry config.')),e;r={attempt:r.attempt||0,timeoutId:null,jqXHR:null},i=o({baseTimeout:null,attempts:null,factor:null,onAttemptFail:null,debugUploads:!1},i);var s=function(e,t,i,r){return function(){var a=n.default.Deferred();function s(){r.jqXHR=n.default.ajax(t).retry(i,o(o({},r),{},{attempt:r.attempt+1})).done(a.resolve).fail(a.reject)}for(var u,l=P(e,i,r),c=l.shouldRetry,f=l.retryTimeout,d=arguments.length,h=new Array(d),p=0;p<d;p++)h[p]=arguments[p];c?(null===(u=i.onAttemptFail)||void 0===u||u.call(i,{attempt:r.attempt}),i.debugUploads&&S("Attempt failed. Retry #".concat(r.attempt+1," in ").concat(f,"ms"),e),r.timeoutId=setTimeout(s,f)):"resolved"===e.state()?a.resolveWith(e,h):a.rejectWith(e,h);return a}}(e,t,i,r),u=e.then(s,s);return u.abort=function(){var t;clearTimeout(r.timeoutId);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];e.abort.apply(e,i),null===(t=r.jqXHR)||void 0===t||t.abort.apply(t,i)},u}I()&&n.default.ajaxPrefilter((function(e,t,n){n.retry=function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return D(n,e,t,i)}})),I()&&window.XDomainRequest&&n.default.ajaxTransport((function(e){var t;if(e.crossDomain&&e.async)return e.timeout&&(e.xdrTimeout=e.timeout,delete e.timeout),{send:function(n,i){function r(e,n,r,o){t.onload=t.onerror=t.ontimeout=function(){},t=void 0,i(e,n,r,o)}(t=new XDomainRequest).onload=function(){r(200,"OK",{text:t.responseText},"Content-Type: "+t.contentType)},t.onerror=function(){r(404,"Not Found")},t.onprogress=function(){},t.ontimeout=function(){r(0,"timeout")},t.timeout=e.xdrTimeout||Number.MAX_VALUE,t.open(e.type,e.url.replace(/^https?:/,"")),t.send(e.hasContent&&e.data||null)},abort:function(){t&&(t.onerror=function(){},t.abort())}}}));var E,R=I()&&!!(window.File&&window.FileList&&window.FileReader),F=I()&&!(!window.FormData||!R),z=I()&&("draggable"in(E=document.createElement("div"))||"ondragstart"in E&&"ondrop"in E),B=I()&&function(){var e;return!(!(e=document.createElement("canvas")).getContext||!e.getContext("2d"))}(),L=R&&z,M=null,N=I()&&/^[^(]+\(iP(?:hone|od|ad);\s*(.+?)\)/.exec(navigator.userAgent);if(N){var W=/OS (\d*)_(\d*)/.exec(N[1]);W&&(M=+W[1]+W[2]/10)}var K=I()&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),q=!1;try{I()&&new window.Blob&&(q=window.Blob)}catch(e){}var G=I()&&(window.URL||window.webkitURL||!1),X=G&&G.createObjectURL&&G,J=I()&&(null!=window.FileReader?window.FileReader.prototype.readAsArrayBuffer:void 0)&&window.FileReader,V=[].indexOf,$=function(e){var t,n,i,r;for(r=[],n=0,i=e.length;n<i;n++)t=e[n],V.call(r,t)<0&&r.push(t);return r},H=function(e){return setTimeout(e,0)},Y=function(e){var t,n;return t=!1,n=null,function(){return t||(n=e.apply(this,arguments),t=!0),n}},Q=function(e){return n.default.Deferred().resolve(e).promise()},Z=function(e,t){var i;return i={},n.default.each(t,(function(t,r){var o=e[r];n.default.isFunction(o)?i[r]=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var a=o.apply(e,n);return a===e?i:a}:i[r]=o})),i},ee=function(e){return e.replace(/([A-Z])/g,"_$1").toUpperCase()},te=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},ne=/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)\??([^#]*)#?(.*)$/,ie=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,re=new RegExp("".concat(ie.source,"~[0-9]+"),"i"),oe=new RegExp("^/?(".concat(ie.source,")(?:/(-/(?:[^/]+/)+)?([^/]*))?$"),"i"),ae=function(e){return oe.exec(ne.exec(e)[3])},se=function(e){return e.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},ue=function(e){var t;return"http:"!==(t=document.location.protocol)&&(t="https:"),e.replace(/^\/\//,t+"//").replace(/\/+$/,"")},le=function(e,t,n){var i,r;return e[0]>t[0]||e[1]>t[1]||n?(r=t[0]/e[0],i=t[1]/e[1],!t[0]||t[1]&&r>i?[Math.round(i*e[0]),t[1]]:[t[0],Math.round(r*e[1])]):e.slice()},ce=["image/*","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"].join(","),fe="B KB MB GB TB PB EB ZB YB".split(" "),de={dataType:"json",crossDomain:!0,cache:!1},he=function(e,t,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=n.default.ajax(n.default.extend({url:e,type:t,data:i},r,de)).retry(r.retryConfig).fail((function(t,n,i){var r="".concat(n," (").concat(i,")");T("JSONP unexpected error: ".concat(r," while loading ").concat(e))})),a=o.then((function(e){var t,i;return e.error?("string"==typeof e.error?(t=e.error,i=e.error_code):(t=e.error.content,i=e.error.error_code),n.default.Deferred().reject({message:t,code:i})):e}));return a.abort=o.abort.bind(o),a},pe=function(e,t,n,i){var r,o,a,s,u,l;if(window.HTMLCanvasElement.prototype.toBlob)return e.toBlob(i,t,n);for(a=(a=e.toDataURL(t,n)).split(","),o=window.atob(a[1]),r=new Uint8Array(o.length),s=u=0,l=o.length;u<l;s=u+=1)r[s]=o.charCodeAt(s);return i(new window.Blob([r],{type:/:(.+\/.+);/.exec(a[0])[1]}))},me=function(e){var t,n,i;return i=0,t=[],n=function(){var e;return t.length?(e=t.shift(),H((function(){return e(n)}))):i-=1},function(r){return!e||i<e?(i+=1,H((function(){return r(n)}))):t.push(r)}},ge=[["notify","progress",2],["resolve","done",0],["reject","fail",1]],ve=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return n.default.Deferred((function(t){return n.default.each(ge,(function(r,o){var a;return a=n.default.isFunction(i[o[2]])&&i[o[2]],e[o[1]]((function(){var i;return(i=a&&a.apply(this,arguments))&&n.default.isFunction(i.promise)?i.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[o[0]+"With"](this===e?t.promise():this,a?[i]:arguments)}))}))})).promise()},ye=function(e){var t;return t=o({},t=e.metadataCallback?e.metadataCallback()||{}:e.metadata||{}),n.default.each(t,(function(e,n){t[e]=String(n)})),t},_e=55,be=110,we=165,Ae=255,ke="rgba(".concat(_e,", ").concat(be,", ").concat(we,", ").concat(Ae/255,")");function xe(e,t){try{var n=[e-1,t-1,1,1],i=document.createElement("canvas");i.width=1,i.height=1;var r=document.createElement("canvas");r.width=e,r.height=t;var o=i.getContext("2d"),a=r.getContext("2d");a&&(a.fillStyle=ke,a.fillRect.apply(a,n),o.drawImage(r,e-1,t-1,1,1,0,0,1,1));var s=o&&o.getImageData(0,0,1,1).data,u=!1;return s&&(u=s[0]===_e&&s[1]===be&&s[2]===we&&s[3]===Ae),r.width=r.height=1,u}catch(n){return S("Failed to test for max canvas size of ".concat(e,"x").concat(t,"."),n),!1}}function Se(e,t){var n={};return function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];var a=t(r,n);return a in n?n[a]:n[a]=e.apply(void 0,r)}}var Ce={squareSide:[Math.floor(Math.sqrt(5e6)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},Te=Ce.squareSide[Ce.squareSide.length-1];function je(e){return function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];var o=n.default.Deferred();return H((function(){var t=e.apply(void 0,i);o.resolve(t)})),o.promise()}}function Ue(e,t){for(var n=w(e,1)[0],i=Object.keys(t).map((function(e){return parseInt(e,10)})).sort((function(e,t){return e-t})),r=0;r<i.length;r++){var o=i[r],a=!!t[o];if(o>n&&a)return o;if(o<n&&!a)return o}return n}var Ie=je(Se(xe,Ue)),Oe=je(Se(xe,Ue));function Pe(e,t){var i=n.default.Deferred(),r=Ce.squareSide.find((function(n){return n*n>=e*t})),o=Ce.dimension.find((function(n){return n>=e&&n>=t}));if(!r||!o)return i.reject();var a=[Ie(r,r),Oe(o,1)];return n.default.when.apply(n.default,a).done((function(e,t){e&&t?i.resolve():i.reject()})),i.promise()}const De=e=>{if(e<=0n)return"0";let t="";for(;e>0n;){t="0123456789abcdefghijklmnopqrstuvwxyz"[Number(e%36n)]+t,e/=36n}return t},Ee="0123456789abcdef".split(""),Re=[-2147483648,8388608,32768,128],Fe=[24,16,8,0],ze=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];
/**
* [js-sha256]{@link https://github.com/emn178/js-sha256}
*
* @license MIT
* @version 0.11.1
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2025
*/class Be{blocks;h0;h1;h2;h3;h4;h5;h6;h7;block;start;bytes;hBytes;first;lastByteIndex;constructor(){this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225,this.block=this.start=this.bytes=this.hBytes=0,this.first=!0,this.lastByteIndex=0}update(e){let t,n,i=0;const r=e.length,o=this.blocks;for(;i<r;){for(n=this.start;i<r&&n<64;++i)t=e.charCodeAt(i),t<128?o[n>>>2]|=t<<Fe[3&n++]:t<2048?(o[n>>>2]|=(192|t>>>6)<<Fe[3&n++],o[n>>>2]|=(128|63&t)<<Fe[3&n++]):t<55296||t>=57344?(o[n>>>2]|=(224|t>>>12)<<Fe[3&n++],o[n>>>2]|=(128|t>>>6&63)<<Fe[3&n++],o[n>>>2]|=(128|63&t)<<Fe[3&n++]):(t=65536+((1023&t)<<10|1023&e.charCodeAt(++i)),o[n>>>2]|=(240|t>>>18)<<Fe[3&n++],o[n>>>2]|=(128|t>>>12&63)<<Fe[3&n++],o[n>>>2]|=(128|t>>>6&63)<<Fe[3&n++],o[n>>>2]|=(128|63&t)<<Fe[3&n++]);this.lastByteIndex=n,this.bytes+=n-this.start,n>=64?(this.block=o[16],this.start=n-64,this.hash()):this.start=n}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}finalize(){const e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=Re[3&t],this.block=e[16],t>=56&&(e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}hash(){let e,t,n,i,r,o,a,s,u,l,c,f=this.h0,d=this.h1,h=this.h2,p=this.h3,m=this.h4,g=this.h5,v=this.h6,y=this.h7;const _=this.blocks;for(e=16;e<64;++e)r=_[e-15],t=(r>>>7|r<<25)^(r>>>18|r<<14)^r>>>3,r=_[e-2],n=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,_[e]=_[e-16]+t+_[e-7]+n<<0;for(c=d&h,e=0;e<64;e+=4)this.first?(s=704751109,r=_[0]-210244248,y=r-1521486534<<0,p=r+143694565<<0,this.first=!1):(t=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),n=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),s=f&d,i=s^f&h^c,a=m&g^~m&v,r=y+n+a+ze[e]+_[e],o=t+i,y=p+r<<0,p=r+o<<0),t=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),n=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),u=p&f,i=u^p&d^s,a=y&m^~y&g,r=v+n+a+ze[e+1]+_[e+1],o=t+i,v=h+r<<0,h=r+o<<0,t=(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),n=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7),l=h&p,i=l^h&f^u,a=v&y^~v&m,r=g+n+a+ze[e+2]+_[e+2],o=t+i,g=d+r<<0,d=r+o<<0,t=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),n=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7),c=d&h,i=c^d&p^l,a=g&v^~g&y,r=m+n+a+ze[e+3]+_[e+3],o=t+i,m=f+r<<0,f=r+o<<0;this.h0=this.h0+f<<0,this.h1=this.h1+d<<0,this.h2=this.h2+h<<0,this.h3=this.h3+p<<0,this.h4=this.h4+m<<0,this.h5=this.h5+g<<0,this.h6=this.h6+v<<0,this.h7=this.h7+y<<0}hex(){this.finalize();const e=this.h0,t=this.h1,n=this.h2,i=this.h3,r=this.h4,o=this.h5,a=this.h6,s=this.h7;return Ee[e>>>28&15]+Ee[e>>>24&15]+Ee[e>>>20&15]+Ee[e>>>16&15]+Ee[e>>>12&15]+Ee[e>>>8&15]+Ee[e>>>4&15]+Ee[15&e]+Ee[t>>>28&15]+Ee[t>>>24&15]+Ee[t>>>20&15]+Ee[t>>>16&15]+Ee[t>>>12&15]+Ee[t>>>8&15]+Ee[t>>>4&15]+Ee[15&t]+Ee[n>>>28&15]+Ee[n>>>24&15]+Ee[n>>>20&15]+Ee[n>>>16&15]+Ee[n>>>12&15]+Ee[n>>>8&15]+Ee[n>>>4&15]+Ee[15&n]+Ee[i>>>28&15]+Ee[i>>>24&15]+Ee[i>>>20&15]+Ee[i>>>16&15]+Ee[i>>>12&15]+Ee[i>>>8&15]+Ee[i>>>4&15]+Ee[15&i]+Ee[r>>>28&15]+Ee[r>>>24&15]+Ee[r>>>20&15]+Ee[r>>>16&15]+Ee[r>>>12&15]+Ee[r>>>8&15]+Ee[r>>>4&15]+Ee[15&r]+Ee[o>>>28&15]+Ee[o>>>24&15]+Ee[o>>>20&15]+Ee[o>>>16&15]+Ee[o>>>12&15]+Ee[o>>>8&15]+Ee[o>>>4&15]+Ee[15&o]+Ee[a>>>28&15]+Ee[a>>>24&15]+Ee[a>>>20&15]+Ee[a>>>16&15]+Ee[a>>>12&15]+Ee[a>>>8&15]+Ee[a>>>4&15]+Ee[15&a]+Ee[s>>>28&15]+Ee[s>>>24&15]+Ee[s>>>20&15]+Ee[s>>>16&15]+Ee[s>>>12&15]+Ee[s>>>8&15]+Ee[s>>>4&15]+Ee[15&s]}}const Le=e=>{const t=function(e){const t=new Be;t.update(e);const n=t.hex();return BigInt("0x"+n)}(e);return De(t).slice(0,10)},Me=(e,t)=>((e,t)=>{const n=new URL(t);return n.hostname=`${e}.${n.hostname}`,n.toString().replace(/\/$/,"")})(Le(e),t);var Ne,We,Ke,qe,Ge,Xe,Je,Ve,$e,He,Ye,Qe,Ze,et,tt,nt,it,rt,ot,at,st,ut,lt,ct=[].indexOf;Ge={live:!0,manualStart:!1,locale:null,localePluralize:null,localeTranslations:null,systemDialog:!1,crop:!1,previewStep:!1,imagesOnly:!1,clearable:!1,multiple:!1,multipleMax:1e3,multipleMin:1,multipleMaxStrict:!1,imageShrink:!1,pathValue:!0,tabs:"file camera url facebook gdrive gphotos dropbox instagram evernote flickr onedrive",preferredTypes:"",inputAcceptTypes:"",doNotStore:!1,publicKey:null,secureSignature:"",secureExpire:"",pusherKey:"79ae88bd931ea68464d9",cdnBase:"https://ucarecdn.com",cdnBasePrefixed:"https://ucarecd.net",urlBase:"https://upload.uploadcare.com",socialBase:"https://social.uploadcare.com",previewProxy:null,previewUrlCallback:null,remoteTabSessionKey:null,metadata:null,metadataCallback:null,imagePreviewMaxSize:26214400,multipartMinSize:10485760,multipartPartSize:5242880,multipartMinLastPartSize:1048576,multipartConcurrency:4,multipartMaxAttempts:null,retryAttempts:3,retryThrottledAttempts:10,retryBaseTimeout:1e3,retryFactor:2,parallelDirectUploads:10,passWindowOpen:!1,cameraMirrorDefault:!0,enableAudioRecording:!0,enableVideoRecording:!0,videoPreferredMimeTypes:null,audioBitsPerSecond:null,videoBitsPerSecond:null,topLevelOrigin:null,scriptBase:"//ucarecdn.com/widget/".concat("3.23.3","/uploadcare/"),debugUploads:!1,integration:""},Xe=o({},Ge),ot={multipleMax:{from:0,to:1e3}},Ke={multipleMax:{min:1,max:1e3}},tt={tabs:{all:"file camera url facebook gdrive gphotos dropbox instagram evernote flickr onedrive box vk huddle",default:Ge.tabs}},nt=I()&&(document.currentScript||(lt=document.getElementsByTagName("script"))[lt.length-1]),($e=I()&&n.default(nt).data("integration"))&&null!=$e&&(Ge=n.default.extend(Ge,{integration:$e})),it=function(e){return n.default.isArray(e)||(e=(e=n.default.trim(e))?e.split(" "):[]),e},Ne=function(e,t){var n,i,r,o,a,s,u,l,c=Object.prototype.hasOwnProperty;for(n=0,a=t.length;n<a;n++){if(o=t[n],l=u=it(e[o]),c.apply(tt,[o]))for(l=[],r=0,s=u.length;r<s;r++)i=u[r],c.apply(tt[o],[i])?l=l.concat(it(tt[o][i])):l.push(i);e[o]=$(l)}return e},at=function(e,t){var n,i,r;for(n=0,r=t.length;n<r;n++)null!=e[i=t[n]]&&(e[i]=ue(e[i]));return e},Je=function(e,t){var i,r,o,a;for(i=0,o=t.length;i<o;i++)null!=e[r=t[i]]&&("string"==typeof(a=e[r])?(a=n.default.trim(a).toLowerCase(),e[r]=!("false"===a||"disabled"===a)):e[r]=!!a);return e},Ve=function(e,t){var n,i,r;for(n=0,r=t.length;n<r;n++)null!=e[i=t[n]]&&(e[i]=parseInt(e[i]));return e},He=function(e){return e._userAgent="UploadcareWidget/".concat("3.23.3","/").concat(e.publicKey," (JavaScript").concat(e.integration?"; ".concat(e.integration):"",")"),e},Ye=function(e){e.retryAttempts===Xe.retryAttempts&&null!==e.multipartMaxAttempts&&(e.retryAttempts=e.multipartMaxAttempts),e.retryConfig={baseTimeout:e.retryBaseTimeout,factor:e.retryFactor,attempts:e.retryAttempts,debugUploads:e.debugUploads,throttledAttempts:e.retryThrottledAttempts}},rt=function(e,t){var n,i;for(n in t)i=t[n],null!=e[n]&&e[n]===i.from&&(e[n]=i.to);return e},We=function(e,t){var n,i,r;for(n in t){var o=t[n];r=o.min,i=o.max,null!=e[n]&&(e[n]=Math.min(Math.max(e[n],r),i))}return e},st=function(e,t){for(var n=0,i=t.length;n<i;n++){var r=t[n];e[r]&&"function"!=typeof e[r]&&U('Option "'.concat(r,'" is expected to be a function. Instead got: ').concat(s(e[r])))}},ut=function(e,t){for(var n=0,i=t.length;n<i;n++){var r=t[n];e[r]&&(o=e[r],"[object Object]"!==Object.prototype.toString.call(o))&&U('Option "'.concat(r,'" is expected to be an object. Instead got: ').concat(s(e[r])))}var o},Ze=function(e){var t;return{downscale:"x"===(t=/^([0-9]+)([x:])([0-9]+)\s*(|upscale|minimum)$/i.exec(n.default.trim(e.toLowerCase()))||[])[2],upscale:!!t[4],notLess:"minimum"===t[4],preferedSize:t.length?[+t[1],+t[3]]:void 0}},et=function(e){var t=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i.exec(n.default.trim(e.toLowerCase()))||[];if(!t.length)return!1;var i=t[1]*t[2],r=Te*Te;return i>r?(U("Shrinked size can not be larger than ".concat(Math.floor(r/1e3/1e3),"MP. ")+"You have set ".concat(t[1],"x").concat(t[2]," (")+"".concat(Math.ceil(i/1e3/100)/10,"MP).")),!1):{quality:t[3]?t[3]/100:void 0,size:i}},qe=function(e,t){var n,i,r,o;return this.previewProxy?(i=(r=!/\?/.test(this.previewProxy))||!/=$/.test(this.previewProxy),n=!r&&!/[&?=]$/.test(this.previewProxy),o=encodeURIComponent(e),i&&(o="url="+o),n&&(o="&"+o),r&&(o="?"+o),this.previewProxy+o):e},Qe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];Ne(e,["tabs","preferredTypes","videoPreferredMimeTypes"]),at(e,["cdnBase","socialBase","urlBase","scriptBase","cdnBasePrefixed","topLevelOrigin"]),Je(e,["doNotStore","imagesOnly","multiple","clearable","pathValue","previewStep","systemDialog","debugUploads","multipleMaxStrict","cameraMirrorDefault"]),Ve(e,["multipleMax","multipleMin","multipartMinSize","multipartPartSize","multipartMinLastPartSize","multipartConcurrency","multipartMaxAttempts","retryAttempts","retryThrottledAttempts","retryBaseTimeout","retryFactor","parallelDirectUploads"]),st(e,["previewUrlCallback","metadataCallback"]),ut(e,["metadata"]),rt(e,ot),We(e,Ke),He(e),Ye(e),!1===e.crop||n.default.isArray(e.crop)||(/^(disabled?|false|null)$/i.test(e.crop)?e.crop=!1:n.default.isPlainObject(e.crop)?e.crop=[e.crop]:e.crop=n.default.map((""+e.crop).split(","),Ze)),e.imageShrink&&!n.default.isPlainObject(e.imageShrink)&&(e.imageShrink=et(e.imageShrink)),(e.crop||e.multiple)&&(e.previewStep=!0),F||(e.systemDialog=!1),e.validators&&(e.validators=e.validators.slice()),e.previewProxy&&!e.previewUrlCallback&&(e.previewUrlCallback=qe);var i=e.tabs.indexOf("skydrive");return-1!==i&&(e.tabs[i]="onedrive"),!t.includes("cdnBase")&&e.publicKey&&e.cdnBase===Xe.cdnBase&&(e.cdnBase=Me(e.publicKey,e.cdnBasePrefixed)),e};var ft,dt=function(){var e={},t=[];for(var n in Ge){var i=window["UPLOADCARE_".concat(ee(n))];null!=i&&(t.push(n),e[n]=i)}return Object.defineProperty(e,"__dirtyKeys",{value:t,enumerable:!1,writable:!1,configurable:!1}),e},ht=Y((function(e,t){var i=[];if(!t){var r=dt();i.push.apply(i,A(r.__dirtyKeys)),Ge=n.default.extend(Ge,r)}var o=e||{};i.push.apply(i,A(Object.keys(o)));var a=Qe(n.default.extend(Ge,o),i);return mt.fire(a),Object.defineProperty(a,"__dirtyKeys",{value:i,enumerable:!1,writable:!1,configurable:!1}),a})),pt=function(e){var t=[],i=ht();t.push.apply(t,A(i.__dirtyKeys));var r=n.default.extend({},i);if(!n.default.isEmptyObject(e)){var o=Object.keys(e);t.push.apply(t,o),r=Qe(n.default.extend(r,e),t)}return r},mt=I()&&n.default.Callbacks("once memory"),gt=function(){function e(){u(this,e),this.urls=[],this.styles=[]}return f(e,[{key:"addUrl",value:function(e){if(!/^https?:\/\//i.test(e))throw new Error("Embedded urls should be absolute. "+e);if(!(ct.call(this.urls,e)>=0))return this.urls.push(e)}},{key:"addStyle",value:function(e){return this.styles.push(e)}}]),e}(),vt=function(e,t){var i;return i=n.default.Deferred(),t&&(e.src=t),e.complete?i.resolve(e):(n.default(e).one("load",(function(){return i.resolve(e)})),n.default(e).one("error",(function(){return i.reject(e)}))),i.promise()},yt=function e(t){return n.default.isArray(t)?n.default.when.apply(null,n.default.map(t,e)):t.src?vt(t):vt(new window.Image,t)},_t=function(){var e=n.default.Deferred();if(void 0!==ft)e.resolve(ft);else{var t=new window.Image;t.onload=function(){ft=t.naturalWidth<t.naturalHeight,t.src="//:0",e.resolve(ft)},t.src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k="}return e.promise()},bt=function(e,t,i){var r=n.default.Deferred();return H((function(){try{var n=document.createElement("canvas"),o=n.getContext("2d");n.width=t,n.height=i,o.imageSmoothingQuality="high",o.drawImage(e,0,0,t,i),e.src="//:0",e.width=e.height=1,r.resolve(n)}catch(e){S("Failed to shrink image to size ".concat(t,"x").concat(i,"."),e),r.reject(e)}})),r.promise()},wt=function(e,t,i,r,o){var a=function(e,t,n,i){var r=[],o=t,a=n;do{r.push([o,a]),o=Math.round(o/i),a=Math.round(a/i)}while(o<e*i);return r.reverse()}(t,i,r,o),s=n.default.Deferred(),u=n.default.Deferred();u.resolve(e);var l,c=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=k(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(a);try{var f=function(){var e=w(l.value,2),r=e[0],o=e[1];u=u.then((function(e){var t=n.default.Deferred();return Pe(r,o).then((function(){return t.resolve(e,!1)})).fail((function(){return t.resolve(e,!0)})),t.promise()})).then((function(e,t){return t?e:bt(e,r,o)})).then((function(e){return s.notify((t-r)/(t-i)),e}))};for(c.s();!(l=c.n()).done;)f()}catch(e){c.e(e)}finally{c.f()}return u.done((function(e){s.resolve(e)})),u.fail((function(e){s.reject(e)})),s.promise()},At=function(e,t){var i=n.default.Deferred();if(.71*e.width*e.height*.71<t.size)return i.reject("not required");var r=e.width,o=e.height,a=r/o,s=Math.floor(Math.sqrt(t.size*a)),u=Math.floor(t.size/Math.sqrt(t.size*a));return Pe(s,u).fail((function(){i.reject("not supported")})).then((function(){("imageSmoothingQuality"in document.createElement("canvas").getContext("2d")&&!M&&!K?function(e,t,n){return bt(e,t,n)}(e,s,u):wt(e,r,s,u,.71)).done((function(e){return i.resolve(e)})).progress((function(e){return i.notify(e)})).fail((function(){return i.reject("not supported")}))})),i.promise()},kt=I()&&window.DataView,xt=me(1),St=function(e,t){var i=n.default.Deferred();return X&&kt&&q?(xt((function(r){i.always(r),Dt(e).then((function(e){if(e)return i.reject("skipped"),n.default.Deferred().reject()})).then((function(){return Pt(e).fail((function(){i.reject("not image")}))})).done((function(r){i.notify(.1);var o=n.default.when(jt(e),_t(),Ut(e)).always((function(e,a,s){i.notify(.2);var u="resolved"===o.state(),l=At(r,t);l.progress((function(e){return i.notify(.2+.6*e)})),l.fail(i.reject),l.done((function(r){var o="image/jpeg",l=t.quality||.8;!u&&zt(r)&&(o="image/png",l=void 0),pe(r,o,l,(function(t){r.width=r.height=1,i.notify(.9);var o=n.default.Deferred().resolve(t);e&&(o=o.then((function(t){return It(t,e,a)})).catch((function(){return t}))),(null==s?void 0:s.length)>0&&(o=o.then((function(e){return Ot(e,s)})).catch((function(){return t}))),o.done(i.resolve),o.fail((function(){return i.resolve(t)}))}))}))}))}))})),i.promise()):i.reject("support")},Ct=function(e){var t,i,r,o,a;return a=function(e,n){var i;return(i=new J).onload=function(){return n(new kt(i.result))},i.onerror=function(e){return t.reject("reader",e)},i.readAsArrayBuffer(e)},r=function(){return a(e.slice(i,i+128),(function(e){var t,n,r;for(t=n=0,r=e.byteLength;r>=0?n<r:n>r;t=r>=0?++n:--n)if(255===e.getUint8(t)){i+=t;break}return o()}))},o=function(){var n;return n=i,a(e.slice(i,i+=4),(function(o){var s,u;return 4!==o.byteLength||255!==o.getUint8(0)?t.reject("corrupted"):218===(u=o.getUint8(1))?t.resolve():(s=o.getUint16(2)-2,a(e.slice(i,i+=s),(function(e){return e.byteLength!==s?t.reject("corrupted"):(t.notify(n,s,u,e),r())})))}))},t=n.default.Deferred(),J&&kt?(i=2,a(e.slice(0,2),(function(e){return 65496!==e.getUint16(0)?t.reject("not jpeg"):r()})),t.promise()):t.reject("support")},Tt=function(e,t,i){var r,o,a,s;return r=n.default.Deferred(),a=[],o=[],(s=Ct(e)).fail(r.reject),s.progress((function(e,n,i){if(i===t)return a.push(e),o.push(n)})),s.done((function(){var n,s,u,l,c,f,d,h,p;for(d=[e.slice(0,2)],l=0,f=i.length;l<f;l++)n=i[l],(u=new kt(new ArrayBuffer(4))).setUint16(0,65280+t),u.setUint16(2,n.byteLength+2),d.push(u.buffer),d.push(n);for(h=2,s=c=0,p=a.length;p>=0?c<p:c>p;s=p>=0?++c:--c)a[s]>h&&d.push(e.slice(h,a[s])),h=a[s]+o[s]+4;return d.push(e.slice(h,e.size)),r.resolve(new q(d,{type:e.type}))})),r.promise()},jt=function(e){var t=null,i=Ct(e);return i.progress((function(e,n,i,r){if(!t&&225===i&&r.byteLength>=14&&1165519206===r.getUint32(0)&&0===r.getUint16(4))return t=r})),i.then((function(){return t}),(function(){return n.default.Deferred().reject(t)}))},Ut=function(e){var t=[],i=Ct(e);return i.progress((function(e,n,i,r){226===i&&1229144927===r.getUint32(0)&&1347571526===r.getUint32(4)&&1229735168===r.getUint32(8)&&t.push(r)})),i.then((function(){return t}),(function(){return n.default.Deferred().reject(t)}))},It=function(e,t,n){return n&&Et(t,1),Tt(e,225,[t.buffer])},Ot=function(e,t){return Tt(e,226,t.map((function(e){return e.buffer})))},Pt=function(e){var t=n.default.Deferred();return Ot(e,[]).catch((function(){return e})).then((function(e){var n=yt(X.createObjectURL(e));n.always((function(e){X.revokeObjectURL(e.src)})),n.fail((function(){t.reject()})),n.done((function(e){t.resolve(e)}))})).fail((function(){t.reject()})),t.promise()},Dt=function(e){var t=[1,3],n=[192,193,194,195,197,198,199,201,202,203,205,206,207],i=!1,r=Ct(e);return r.progress((function(e,r,o,a){if(!i&&n.indexOf(o)>=0){var s=a.getUint8(5);t.indexOf(s)<0&&(i=!0)}})),r.then((function(){return i})).catch((function(){return i}))},Et=function(e,t){Ft(e,(function(n,i){return e.setUint16(n,t,i)}))},Rt=function(e){return Ft(e,(function(t,n){return e.getUint16(t,n)}))},Ft=function(e,t){var n,i,r,o;if(!e||e.byteLength<14||1165519206!==e.getUint32(0)||0!==e.getUint16(4))return null;if(18761===e.getUint16(6))i=!0;else{if(19789!==e.getUint16(6))return null;i=!1}if(42!==e.getUint16(8,i))return null;for(r=8+e.getUint32(10,i),n=0,o=e.getUint16(r-2,i);o>=0?n<o:n>o;o>=0?++n:--n){if(e.byteLength<r+10)return null;if(274===e.getUint16(r,i))return t(r+8,i);r+=12}return null},zt=function(e){var t,n,i,r,o,a;for(50,(t=document.createElement("canvas")).width=t.height=50,(n=t.getContext("2d")).drawImage(e,0,0,50,50),i=n.getImageData(0,0,50,50).data,t.width=t.height=1,r=o=3,a=i.length;o<a;r=o+=4)if(i[r]<254)return!0;return!1},Bt=function(){function e(t,n){var i,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,e),this.settings=n,this.sourceInfo=r,this.fileId=null,this.fileName=null,this.sanitizedName=null,this.fileSize=null,this.isStored=null,this.cdnUrlModifiers=null,this.isImage=null,this.imageInfo=null,this.videoInfo=null,this.contentInfo=null,this.mimeType=null,this.s3Bucket=null,this.metadata=null,(i=this.sourceInfo).source||(i.source=this.sourceName),this.__setupValidation(),this.__initApi()}return f(e,[{key:"__startUpload",value:function(){return n.default.Deferred().resolve()}},{key:"__completeUpload",value:function(){var e,t,n,i,r=this;return n=0,this.settings.debugUploads&&(C("Load file info.",this.fileId,this.settings.publicKey),t=setInterval((function(){return C("Still waiting for file ready.",n,r.fileId,r.settings.publicKey)}),5e3),this.apiDeferred.done((function(){return C("File uploaded.",n,r.fileId,r.settings.publicKey)})).always((function(){return clearInterval(t)}))),i=100,(e=function(){if("pending"===r.apiDeferred.state())return n+=1,r.__updateInfo().done((function(){return setTimeout(e,i),i+=50}))})()}},{key:"__updateInfo",value:function(){var e=this;return he("".concat(this.settings.urlBase,"/info/"),"GET",{jsonerrors:1,file_id:this.fileId,pub_key:this.settings.publicKey,wait_is_ready:+(null===this.isImage)},{headers:{"X-UC-User-Agent":this.settings._userAgent},retryConfig:this.settings.retryConfig}).fail((function(t){return e.settings.debugUploads&&S("Can't load file info. Probably removed.",e.fileId,e.settings.publicKey,t.message),e.__rejectApi("info",t)})).done(this.__handleFileData.bind(this))}},{key:"__handleFileData",value:function(e){if(this.fileName=e.original_filename,this.sanitizedName=e.filename,this.fileSize=e.size,this.isImage=e.is_image,this.imageInfo=e.image_info,this.videoInfo=e.video_info,this.contentInfo=e.content_info,this.mimeType=e.mime_type,this.isStored=e.is_stored,this.s3Bucket=e.s3_bucket,this.metadata=e.metadata,e.default_effects&&(this.cdnUrlModifiers="-/"+e.default_effects),this.s3Bucket&&this.cdnUrlModifiers&&this.__rejectApi("baddata"),this.__runValidators(),e.is_ready)return this.__resolveApi()}},{key:"__progressInfo",value:function(){var e;return{state:this.__progressState,uploadProgress:this.__progress,progress:"ready"===(e=this.__progressState)||"error"===e?1:.9*this.__progress,incompleteFileInfo:this.__fileInfo()}}},{key:"__fileInfo",value:function(){var e;return e=this.s3Bucket?"https://".concat(this.s3Bucket,".s3.amazonaws.com/").concat(this.fileId,"/").concat(this.sanitizedName):"".concat(this.settings.cdnBase,"/").concat(this.fileId,"/"),{uuid:this.fileId,name:this.fileName,size:this.fileSize,isStored:this.isStored,isImage:this.isImage,originalImageInfo:this.imageInfo,originalVideoInfo:this.videoInfo,originalContentInfo:this.contentInfo,mimeType:this.mimeType,originalUrl:this.fileId?e:null,cdnUrl:this.fileId?"".concat(e).concat(this.cdnUrlModifiers||""):null,cdnUrlModifiers:this.cdnUrlModifiers,sourceInfo:this.sourceInfo,metadata:this.metadata}}},{key:"__setupValidation",value:function(){if(this.validators=this.settings.validators||this.settings.__validators||[],this.settings.imagesOnly)return this.validators.push((function(e){if(!1===e.isImage)throw new Error("image")}))}},{key:"__runValidators",value:function(){var e,t,n,i,r,o,a;n=this.__fileInfo();try{for(r=this.validators,o=[],t=0,i=r.length;t<i;t++)a=r[t],o.push(a(n));return o}catch(t){return e=t,this.__rejectApi(e.message)}}},{key:"__initApi",value:function(){return this.apiDeferred=n.default.Deferred(),this.__progressState="uploading",this.__progress=0,this.__notifyApi()}},{key:"__notifyApi",value:function(){return this.apiDeferred.notify(this.__progressInfo())}},{key:"__rejectApi",value:function(e,t){return this.__progressState="error",this.__notifyApi(),this.apiDeferred.reject(e,this.__fileInfo(),t)}},{key:"__resolveApi",value:function(){return this.__progressState="ready",this.__notifyApi(),this.apiDeferred.resolve(this.__fileInfo())}},{key:"__cancel",value:function(){return this.__rejectApi("user")}},{key:"__extendApi",value:function(e){var t=this;return e.cancel=this.__cancel.bind(this),e.pipe=e.then=function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return t.__extendApi(ve.apply(void 0,[e].concat(i)))},e}},{key:"promise",value:function(){var e,t=this;return this.__apiPromise||(this.__apiPromise=this.__extendApi(this.apiDeferred.promise()),this.__runValidators(),"pending"===this.apiDeferred.state()&&((e=this.__startUpload()).done((function(){return t.__progressState="uploaded",t.__progress=1,t.__notifyApi(),t.__completeUpload()})),e.progress((function(e){if(e>t.__progress)return t.__progress=e,t.__notifyApi()})),e.fail((function(e){return t.__rejectApi("upload",e)})),this.apiDeferred.always(e.reject))),this.__apiPromise}}]),e}(),Lt=null,Mt=function(e){h(i,e);var t=y(i);function i(e){var n;return u(this,i),(n=t.apply(this,arguments)).__file=e,n.fileName=n.__file.name||"original",n.__notifyApi(),n}return f(i,[{key:"setFile",value:function(e){if(e&&(this.__file=e),this.sourceInfo.file=this.__file,this.__file)return this.fileSize=this.__file.size,this.fileType=this.__file.type||"application/octet-stream",this.settings.debugUploads&&C("Use local file.",this.fileName,this.fileType,this.fileSize),this.__runValidators(),this.__notifyApi()}},{key:"__startUpload",value:function(){var e,t,i,r=this;return this.apiDeferred.always((function(){return r.__file=null,r.__file})),this.__file.size>=this.settings.multipartMinSize&&q?(this.setFile(),this.multipartUpload()):(t=M,!this.settings.imageShrink||t&&t<8?(this.setFile(),this.directUpload()):(e=n.default.Deferred(),i=.4,St(this.__file,this.settings.imageShrink).progress((function(t){return e.notify(t*i)})).done(this.setFile.bind(this)).fail((function(){return r.setFile(),i*=.1})).always((function(){return e.notify(i),r.directUpload().done(e.resolve).fail(e.reject).progress((function(t){return e.notify(i+t*(1-i))}))})),e))}},{key:"__autoAbort",value:function(e){return this.apiDeferred.fail((function(){return e.abort()})),e}},{key:"directRunner",value:function(e){return Lt||(Lt=me(this.settings.parallelDirectUploads)),Lt(e)}},{key:"directUpload",value:function(){var e,t=this;return e=n.default.Deferred(),this.__file?this.fileSize>104857600?(this.__rejectApi("size"),e):(this.directRunner((function(i){if(e.always(i),"pending"===t.apiDeferred.state()){var r=new window.FormData;return r.append("UPLOADCARE_PUB_KEY",t.settings.publicKey),r.append("signature",t.settings.secureSignature),r.append("expire",t.settings.secureExpire),r.append("UPLOADCARE_STORE",t.settings.doNotStore?"":"auto"),r.append("file",t.__file,t.fileName),r.append("file_name",t.fileName),r.append("source",t.sourceInfo.source),n.default.each(ye(t.settings),(function(e,t){r.append("metadata[".concat(e,"]"),t)})),t.__autoAbort(n.default.ajax({xhr:function(){var t;return t=n.default.ajaxSettings.xhr(),t.upload&&t.upload.addEventListener("progress",(function(t){return e.notify(t.loaded/t.total)}),!1),t},crossDomain:!0,type:"POST",url:"".concat(t.settings.urlBase,"/base/?jsonerrors=1"),headers:{"X-UC-User-Agent":t.settings._userAgent},contentType:!1,processData:!1,data:r,dataType:"json"}).retry(t.settings.retryConfig).done((function(n){if(null!=n?n.file:void 0)return t.fileId=n.file,e.resolve();if(n.error){var i=n.error,r=i.content,o=i.error_code;return e.reject({message:r,code:o})}return e.reject()})).fail(e.reject))}})),e):(this.__rejectApi("baddata"),e)}},{key:"multipartUpload",value:function(){var e,t=this;return e=n.default.Deferred(),this.__file?(this.multipartStart().done((function(n){return t.uploadParts(n.parts,n.uuid).done((function(){return t.multipartComplete(n.uuid).done((function(n){return t.fileId=n.uuid,t.__handleFileData(n),e.resolve()})).fail(e.reject)})).progress(e.notify).fail(e.reject)})).fail(e.reject),e):e}},{key:"multipartStart",value:function(){var e=this,t={UPLOADCARE_PUB_KEY:this.settings.publicKey,signature:this.settings.secureSignature,expire:this.settings.secureExpire,filename:this.fileName,source:this.sourceInfo.source,size:this.fileSize,content_type:this.fileType,part_size:this.settings.multipartPartSize,UPLOADCARE_STORE:this.settings.doNotStore?"":"auto"};return n.default.each(ye(this.settings),(function(e,n){t["metadata[".concat(e,"]")]=n})),this.__autoAbort(he("".concat(this.settings.urlBase,"/multipart/start/?jsonerrors=1"),"POST",t,{headers:{"X-UC-User-Agent":this.settings._userAgent},retryConfig:this.settings.retryConfig})).fail((function(n){if(e.settings.debugUploads)return S("Can't start multipart upload.",n.message,t)}))}},{key:"uploadParts",value:function(e,t){var i,r,a,s,u,l,c,f,d,h,p=this;for(u=[],s=Date.now(),h=function(e,t){var n,r,o;if(u[e]=t,!(Date.now()-s<250)){for(s=Date.now(),o=0,n=0,r=u.length;n<r;n++)o+=t=u[n];return i.notify(o/p.fileSize)}},i=n.default.Deferred(),r=0,d=0,f=0,c=function(){if(!(f>=p.fileSize)){var a=f+p.settings.multipartPartSize;p.fileSize<a+p.settings.multipartMinLastPartSize&&(a=p.fileSize);var s=p.__file.slice(f,a);f=a;var l=d;return r+=1,d+=1,function(){if("pending"===p.apiDeferred.state())return u[l]=0,p.__autoAbort(n.default.ajax({xhr:function(){var e;return e=n.default.ajaxSettings.xhr(),e.responseType="text",e.upload&&e.upload.addEventListener("progress",(function(e){return h(l,e.loaded)}),!1),e},url:e[l],crossDomain:!0,type:"PUT",processData:!1,contentType:p.fileType,data:s}).retry(o(o({},p.settings.retryConfig),{},{onAttemptFail:function(e){var n=e.attempt;p.settings.debugUploads&&C("Part #".concat(l,"(").concat(n,") upload is failed."),t)}})).done((function(){if(r-=1,c(),!r)return i.resolve()})).fail((function(){return p.settings.debugUploads&&S("Part #".concat(l," and file upload is failed."),t),i.reject()})))}()}},a=0,l=this.settings.multipartConcurrency;l>=0?a<l:a>l;l>=0?++a:--a)c();return i}},{key:"multipartComplete",value:function(e){var t,n=this;return t={UPLOADCARE_PUB_KEY:this.settings.publicKey,uuid:e},this.__autoAbort(he("".concat(this.settings.urlBase,"/multipart/complete/?jsonerrors=1"),"POST",t,{headers:{"X-UC-User-Agent":this.settings._userAgent},retryConfig:this.settings.retryConfig})).fail((function(t){if(n.settings.debugUploads)return S("Can't complete multipart upload.",e,n.settings.publicKey,t.message)}))}}]),i}(Bt);Mt.prototype.sourceName="local";var Nt=function(e){h(i,e);var t=y(i);function i(e){var r;return u(this,i),(r=t.apply(this,arguments)).__input=e,r.fileId=te(),r.fileName=n.default(r.__input).val().split("\\").pop(),r.__notifyApi(),r}return f(i,[{key:"__startUpload",value:function(){var e,t,i,r;return e=n.default.Deferred(),r="".concat(this.settings.urlBase,"/iframe/"),i="uploadcare--iframe-".concat(this.fileId),this.__iframe=n.default("<iframe>").attr({id:i,name:i}).css("display","none").appendTo("body").on("load",e.resolve).on("error",e.reject),t=function(e,t){return n.default("<input/>",{type:"hidden",name:e,value:t})},n.default(this.__input).attr("name","file"),this.__iframeForm=n.default("<form>").attr({method:"POST",action:r,enctype:"multipart/form-data",target:i}).append(t("UPLOADCARE_PUB_KEY",this.settings.publicKey)).append(t("UPLOADCARE_SIGNATURE",this.settings.secureSignature)).append(t("UPLOADCARE_EXPIRE",this.settings.secureExpire)).append(t("UPLOADCARE_FILE_ID",this.fileId)).append(t("UPLOADCARE_STORE",this.settings.doNotStore?"":"auto")).append(t("UPLOADCARE_SOURCE",this.sourceInfo.source)).append(this.__input).css("display","none").appendTo("body").submit(),e.always(this.__cleanUp.bind(this))}},{key:"__cleanUp",value:function(){var e,t;return null!=(e=this.__iframe)&&e.off("load error").remove(),null!=(t=this.__iframeForm)&&t.remove(),this.__iframe=null,this.__iframeForm=null,this.__iframeForm}}]),i}(Bt);Nt.prototype.sourceName="local-compat";var Wt=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){
/*!
* Pusher JavaScript Library v1.12.2
* http://pusherapp.com/
*
* Copyright 2011, Pusher
* Released under the MIT licence.
*/
var n=O.isWindowDefined;(function(){var e,t;(e=function(t,n){this.options=n||{},this.key=t,this.channels=new e.Channels,this.global_emitter=new e.EventsDispatcher;var i=this;this.checkAppKey(),this.connection=new e.Connection(this.key,this.options),this.connection.bind("connected",(function(){i.subscribeAll()})).bind("message",(function(e){var t,n=0===e.event.indexOf("pusher_internal:");e.channel&&(t=i.channel(e.channel))&&t.emit(e.event,e.data),n||i.global_emitter.emit(e.event,e.data)})).bind("disconnected",(function(){i.channels.disconnect()})).bind("error",(function(t){e.warn("Error",t)})),e.instances.push(this),e.isReady&&i.connect()}).instances=[],e.prototype={channel:function(e){return this.channels.find(e)},connect:function(){this.connection.connect()},disconnect:function(){this.connection.disconnect()},bind:function(e,t){return this.global_emitter.bind(e,t),this},bind_all:function(e){return this.global_emitter.bind_all(e),this},subscribeAll:function(){var e;for(e in this.channels.channels)this.channels.channels.hasOwnProperty(e)&&this.subscribe(e)},subscribe:function(e){var t=this,n=this.channels.add(e,this);return"connected"===this.connection.state&&n.authorize(this.connection.socket_id,this.options,(function(i,r){i?n.emit("pusher:subscription_error",r):t.send_event("pusher:subscribe",{channel:e,auth:r.auth,channel_data:r.channel_data})})),n},unsubscribe:function(e){this.channels.remove(e),"connected"===this.connection.state&&this.send_event("pusher:unsubscribe",{channel:e})},send_event:function(e,t,n){return this.connection.send_event(e,t,n)},checkAppKey:function(){null!==this.key&&void 0!==this.key||e.warn("Warning","You must pass your app key when you instantiate Pusher.")}},e.Util={extend:function e(t,n){for(var i in n)n[i]&&n[i].constructor&&n[i].constructor===Object?t[i]=e(t[i]||{},n[i]):t[i]=n[i];return t},stringify:function(){for(var e=["Pusher"],t=0;t<arguments.length;t++)"string"==typeof arguments[t]?e.push(arguments[t]):null==window.JSON?e.push(arguments[t].toString()):e.push(JSON.stringify(arguments[t]));return e.join(" : ")},arrayIndexOf:function(e,t){var n=Array.prototype.indexOf;if(null==e)return-1;if(n&&e.indexOf===n)return e.indexOf(t);for(i=0,l=e.length;i<l;i++)if(e[i]===t)return i;return-1}},e.debug=function(){e.log&&e.log(e.Util.stringify.apply(this,arguments))},e.warn=function(){if(window.console&&window.console.warn)window.console.warn(e.Util.stringify.apply(this,arguments));else{if(!e.log)return;e.log(e.Util.stringify.apply(this,arguments))}},e.VERSION="1.12.2",e.host="ws.pusherapp.com",e.ws_port=80,e.wss_port=443,e.channel_auth_endpoint="/pusher/auth",e.cdn_http="http://js.pusher.com/",e.cdn_https="https://d3dy5gmtp8yhk7.cloudfront.net/",e.dependency_suffix=".min",e.channel_auth_transport="ajax",e.activity_timeout=12e4,e.pong_timeout=3e4,e.isReady=!1,e.ready=function(){e.isReady=!0;for(var t=0,n=e.instances.length;t<n;t++)e.instances[t].connect()},function(){function t(){this._callbacks={}}function n(e){this.callbacks=new t,this.global_callbacks=[],this.failThrough=e}t.prototype.get=function(e){return this._callbacks[this._prefix(e)]},t.prototype.add=function(e,t){var n=this._prefix(e);this._callbacks[n]=this._callbacks[n]||[],this._callbacks[n].push(t)},t.prototype.remove=function(t,n){if(this.get(t)){var i=e.Util.arrayIndexOf(this.get(t),n);this._callbacks[this._prefix(t)].splice(i,1)}},t.prototype._prefix=function(e){return"_"+e},n.prototype.bind=function(e,t){return this.callbacks.add(e,t),this},n.prototype.unbind=function(e,t){return this.callbacks.remove(e,t),this},n.prototype.emit=function(e,t){for(var n=0;n<this.global_callbacks.length;n++)this.global_callbacks[n](e,t);var i=this.callbacks.get(e);if(i)for(n=0;n<i.length;n++)i[n](t);else this.failThrough&&this.failThrough(e,t);return this},n.prototype.bind_all=function(e){return this.global_callbacks.push(e),this},e.EventsDispatcher=n}(),function(){function t(e,t,n){void 0!==t[e]&&t[e](n)}function n(t,n,i){e.EventsDispatcher.call(this),this.state=void 0,this.errors=[],this.stateActions=i,this.transitions=n,this.transition(t)}n.prototype.transition=function(n,i){var r,o=this.state,a=this.stateActions;if(o&&-1==e.Util.arrayIndexOf(this.transitions[o],n))throw this.emit("invalid_transition_attempt",{oldState:o,newState:n}),new Error("Invalid transition ["+o+" to "+n+"