portal-sincoar/frontend/target/maia/resources/js/payment_checkout_stable.js

1092 lines
52 KiB
JavaScript

! function() {
const domain = "paymentez.com";
let listServers = ["http://localhost:3000", "http://localhost:8080", `https://ccapi-dev.${domain}`, `https://ccapi-stg.${domain}`, `https://ccapi-qa.${domain}`, `https://ccapi.${domain}`];
window.addEventListener("message", function(event) {
if (new RegExp(listServers.join("|")).test(event.origin) && ("close-payment-popup" === event.data && document.querySelectorAll(".payment-checkout-modal__closeIcon")[0].click(), "resize-payment-popup" === event.data)) {
let el = document,
event = document.createEvent("HTMLEvents");
event.initEvent("resize", !0, !1), el.dispatchEvent(event)
}
})
}(), Array.prototype.forEach || (Array.prototype.forEach = function(fun) {
"use strict";
if (void 0 === this || null === this || "function" != typeof fun) throw new TypeError;
let t = Object(this),
len = t.length >>> 0,
thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (let i = 0; i < len; i++) i in t && fun.call(thisArg, t[i], i, t)
}), Function.prototype.bind || (Function.prototype.bind = function(oThis) {
if ("function" != typeof this) throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
let aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function() {},
fBound = function() {
return fToBind.apply(this instanceof fNOP ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)))
};
return fNOP.prototype = this.prototype, fBound.prototype = new fNOP, fBound
}), Array.prototype.forEach || (Array.prototype.forEach = function(callback, thisArg) {
if (null === this) throw new TypeError(" this is null or not defined");
if ("function" != typeof callback) throw new TypeError(callback + " is not a function");
let O = Object(this),
len = O.length >>> 0;
for (let k = 0; k < len; k++) k in O && callback.call(thisArg, O[k], k, O)
}),
function(undefined) {
"use strict";
if ("undefined" == typeof window) return;
let count = 0,
logEnabled = !1,
hiddenCheckEnabled = !1,
msgHeaderLen = "message".length,
msgId = "[iFrameSizer]",
msgIdLen = msgId.length,
pagePosition = null,
requestAnimationFrame = window.requestAnimationFrame,
resetRequiredMethods = {
max: 1,
scroll: 1,
bodyScroll: 1,
documentElementScroll: 1
},
settings = {},
timer = null,
logId = "Host Page",
defaults = {
autoResize: !0,
bodyBackground: null,
bodyMargin: null,
bodyMarginV1: 4, /** CAMBIADO 8*/
bodyPadding: null,
checkOrigin: !0,
inPageLinks: !1,
enablePublicMethods: !0,
heightCalculationMethod: "bodyOffset",
id: "iFrameResizer",
interval: 32,
log: !1,
maxHeight: 1 / 0,
maxWidth: 1 / 0,
minHeight: 0,
minWidth: 0,
resizeFrom: "parent",
scrolling: !0,
sizeHeight: !0,
sizeWidth: !1,
warningTimeout: 5e3,
tolerance: 0,
widthCalculationMethod: "scroll",
closedCallback: function() {},
initCallback: function() {},
messageCallback: function() {
warn("MessageCallback function not defined")
},
resizedCallback: function() {},
scrollCallback: function() {
return !0
}
};
function addEventListener(obj, evt, func) {
"addEventListener" in window ? obj.addEventListener(evt, func, !1) : "attachEvent" in window && obj.attachEvent("on" + evt, func)
}
function removeEventListener(el, evt, func) {
"removeEventListener" in window ? el.removeEventListener(evt, func, !1) : "detachEvent" in window && el.detachEvent("on" + evt, func)
}
function formatLogHeader(iframeId) {
return msgId + "[" + function(iframeId) {
let retStr = "Host page: " + iframeId;
return window.top !== window.self && (retStr = window.parentIFrame && window.parentIFrame.getId ? window.parentIFrame.getId() + ": " + iframeId : "Nested host page: " + iframeId), retStr
}(iframeId) + "]"
}
function isLogEnabled(iframeId) {
return settings[iframeId] ? settings[iframeId].log : logEnabled
}
function log(iframeId, msg) {
output("log", iframeId, msg, isLogEnabled(iframeId))
}
function info(iframeId, msg) {
output("info", iframeId, msg, isLogEnabled(iframeId))
}
function warn(iframeId, msg) {
output("warn", iframeId, msg, !0)
}
function output(type, iframeId, msg, enabled) {
!0 === enabled && "object" == typeof window.console && console[type](formatLogHeader(iframeId), msg)
}
function iFrameListener(event) {
function resizeIFrame() {
ensureInRange("Height"), ensureInRange("Width"), syncResize(function() {
setSize(messageData), setPagePosition(iframeId), callback("resizedCallback", messageData)
}, messageData, "init")
}
function ensureInRange(Dimension) {
let max = Number(settings[iframeId]["max" + Dimension]),
min = Number(settings[iframeId]["min" + Dimension]),
dimension = Dimension.toLowerCase(),
size = Number(messageData[dimension]);
log(iframeId, "Checking " + dimension + " is in range " + min + "-" + max), size < min && (size = min, log(iframeId, "Set " + dimension + " to min value")), size > max && (size = max, log(iframeId, "Set " + dimension + " to max value")), messageData[dimension] = "" + size
}
function getMsgBody(offset) {
return msg.substr(msg.indexOf(":") + msgHeaderLen + offset)
}
function sendPageInfoToIframe(iframe, iframeId) {
debouce(function() {
trigger("Send Page Info", "pageInfo:" + function() {
let bodyPosition = document.body.getBoundingClientRect(),
iFramePosition = messageData.iframe.getBoundingClientRect();
return JSON.stringify({
iframeHeight: iFramePosition.height,
iframeWidth: iFramePosition.width,
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10),
offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10),
scrollTop: window.pageYOffset,
scrollLeft: window.pageXOffset
})
}(), iframe, iframeId)
}, 32)
}
function getElementPosition(target) {
let iFramePosition = target.getBoundingClientRect();
return getPagePosition(iframeId), {
x: Math.floor(Number(iFramePosition.left) + Number(pagePosition.x)),
y: Math.floor(Number(iFramePosition.top) + Number(pagePosition.y))
}
}
function scrollRequestFromChild(addOffset) {
let offset = addOffset ? getElementPosition(messageData.iframe) : {
x: 0,
y: 0
},
newPosition = {
x: Number(messageData.width) + offset.x,
y: Number(messageData.height) + offset.y
};
log(iframeId, "Reposition requested from iFrame (offset x:" + offset.x + " y:" + offset.y + ")"), window.top !== window.self ? window.parentIFrame ? window.parentIFrame["scrollTo" + (addOffset ? "Offset" : "")](newPosition.x, newPosition.y) : warn(iframeId, "Unable to scroll to requested position, window.parentIFrame not found") : (pagePosition = newPosition, scrollTo(), log(iframeId, "--"))
}
function scrollTo() {
!1 !== callback("scrollCallback", pagePosition) ? setPagePosition(iframeId) : unsetPagePosition()
}
function callback(funcName, val) {
return chkCallback(iframeId, funcName, val)
}
let msg = event.data,
messageData = {},
iframeId = null;
"[iFrameResizerChild]Ready" === msg ? function() {
for (let iframeId in settings) trigger("iFrame requested init", createOutgoingMsg(iframeId), document.getElementById(iframeId), iframeId)
}() : msgId === ("" + msg).substr(0, msgIdLen) && msg.substr(msgIdLen).split(":")[0] in settings ? (messageData = function() {
let data = msg.substr(msgIdLen).split(":");
return {
iframe: settings[data[0]] && settings[data[0]].iframe,
id: data[0],
height: data[1],
width: data[2],
type: data[3]
}
}(), iframeId = logId = messageData.id, settings[iframeId] && (settings[iframeId].loaded = !0), ! function() {
let retCode = messageData.type in {
true: 1,
false: 1,
undefined: 1
};
return retCode && log(iframeId, "Ignoring init message from meta parent page"), retCode
}() && function(iframeId) {
let retBool = !0;
return settings[iframeId] || (retBool = !1, warn(messageData.type + " No settings for " + iframeId + ". Message was: " + msg)), retBool
}(iframeId) && (log(iframeId, "Received: " + msg), function() {
let retBool = !0;
return null === messageData.iframe && (warn(iframeId, "IFrame (" + messageData.id + ") not found"), retBool = !1), retBool
}() && function() {
let origin = event.origin,
checkOrigin = settings[iframeId] && settings[iframeId].checkOrigin;
if (checkOrigin && "" + origin != "null" && !(checkOrigin.constructor === Array ? function() {
let i = 0,
retCode = !1;
for (log(iframeId, "Checking connection is from allowed list of origins: " + checkOrigin); i < checkOrigin.length; i++)
if (checkOrigin[i] === origin) {
retCode = !0;
break
}
return retCode
}() : function() {
let remoteHost = settings[iframeId] && settings[iframeId].remoteHost;
return log(iframeId, "Checking connection is from: " + remoteHost), origin === remoteHost
}())) throw new Error("Unexpected message received from: " + origin + " for " + messageData.iframe.id + ". Message was: " + event.data + ". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");
return !0
}() && function() {
switch (settings[iframeId] && settings[iframeId].firstRun && settings[iframeId] && (settings[iframeId].firstRun = !1), messageData.type) {
case "close":
settings[iframeId].closeRequestCallback ? chkCallback(iframeId, "closeRequestCallback", settings[iframeId].iframe) : closeIFrame(messageData.iframe);
break;
case "message":
msgBody = getMsgBody(6), log(iframeId, "MessageCallback passed: {iframe: " + messageData.iframe.id + ", message: " + msgBody + "}"), callback("messageCallback", {
iframe: messageData.iframe,
message: JSON.parse(msgBody)
}), log(iframeId, "--");
break;
case "scrollTo":
scrollRequestFromChild(!1);
break;
case "scrollToOffset":
scrollRequestFromChild(!0);
break;
case "pageInfo":
sendPageInfoToIframe(settings[iframeId] && settings[iframeId].iframe, iframeId),
function() {
function setListener(type, func) {
function sendPageInfo() {
settings[id] ? sendPageInfoToIframe(settings[id].iframe, id) : stop()
}["scroll", "resize"].forEach(function(evt) {
log(id, type + evt + " listener for sendPageInfo"), func(window, evt, sendPageInfo)
})
}
function stop() {
setListener("Remove ", removeEventListener)
}
let id = iframeId;
setListener("Add ", addEventListener), settings[id] && (settings[id].stopPageInfo = stop)
}();
break;
case "pageInfoStop":
settings[iframeId] && settings[iframeId].stopPageInfo && (settings[iframeId].stopPageInfo(), delete settings[iframeId].stopPageInfo);
break;
case "inPageLink":
! function(location) {
let hash = location.split("#")[1] || "",
hashData = decodeURIComponent(hash),
target = document.getElementById(hashData) || document.getElementsByName(hashData)[0];
target ? function() {
let jumpPosition = getElementPosition(target);
log(iframeId, "Moving to in page link (#" + hash + ") at x: " + jumpPosition.x + " y: " + jumpPosition.y), pagePosition = {
x: jumpPosition.x,
y: jumpPosition.y
}, scrollTo(), log(iframeId, "--")
}() : window.top !== window.self ? window.parentIFrame ? window.parentIFrame.moveToAnchor(hash) : log(iframeId, "In page link #" + hash + " not found and window.parentIFrame not found") : log(iframeId, "In page link #" + hash + " not found")
}(getMsgBody(9));
break;
case "reset":
resetIFrame(messageData);
break;
case "init":
resizeIFrame(), callback("initCallback", messageData.iframe);
break;
default:
resizeIFrame()
}
var msgBody
}())) : info(iframeId, "Ignored: " + msg)
}
function chkCallback(iframeId, funcName, val) {
let func = null,
retVal = null;
if (settings[iframeId]) {
if ("function" != typeof(func = settings[iframeId][funcName])) throw new TypeError(funcName + " on iFrame[" + iframeId + "] is not a function");
retVal = func(val)
}
return retVal
}
function closeIFrame(iframe) {
let iframeId = iframe.id;
log(iframeId, "Removing iFrame: " + iframeId), iframe.parentNode && iframe.parentNode.removeChild(iframe), chkCallback(iframeId, "closedCallback", iframeId), log(iframeId, "--"), delete settings[iframeId]
}
function getPagePosition(iframeId) {
null === pagePosition && log(iframeId, "Get page position: " + (pagePosition = {
x: window.pageXOffset !== undefined ? window.pageXOffset : document.documentElement.scrollLeft,
y: window.pageYOffset !== undefined ? window.pageYOffset : document.documentElement.scrollTop
}).x + "," + pagePosition.y)
}
function setPagePosition(iframeId) {
null !== pagePosition && (window.scrollTo(pagePosition.x, pagePosition.y), log(iframeId, "Set page position: " + pagePosition.x + "," + pagePosition.y), unsetPagePosition())
}
function unsetPagePosition() {
pagePosition = null
}
function resetIFrame(messageData) {
log(messageData.id, "Size reset requested by " + ("init" === messageData.type ? "host page" : "iFrame")), getPagePosition(messageData.id), syncResize(function() {
setSize(messageData), trigger("reset", "reset", messageData.iframe, messageData.id)
}, messageData, "reset")
}
function setSize(messageData) {
function chkZero(dimension) {
hiddenCheckEnabled || "0" !== messageData[dimension] || (hiddenCheckEnabled = !0, log(iframeId, "Hidden iFrame detected, creating visibility listener"), function() {
function checkIFrames() {
function checkIFrame(settingId) {
function chkDimension(dimension) {
return "0px" === (settings[settingId] && settings[settingId].iframe.style[dimension])
}
settings[settingId] && null !== settings[settingId].iframe.offsetParent && (chkDimension("height") || chkDimension("width")) && trigger("Visibility change", "resize", settings[settingId].iframe, settingId)
}
for (let settingId in settings) checkIFrame(settingId)
}
function mutationObserved(mutations) {
log("window", "Mutation observed: " + mutations[0].target + " " + mutations[0].type), debouce(checkIFrames, 16)
}
let MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
MutationObserver && function() {
let target = document.querySelector("body");
new MutationObserver(mutationObserved).observe(target, {
attributes: !0,
attributeOldValue: !1,
characterData: !0,
characterDataOldValue: !1,
childList: !0,
subtree: !0
})
}()
}())
}
function processDimension(dimension) {
! function(dimension) {
messageData.iframe.style[dimension] = messageData[dimension] + "px", log(messageData.id, "IFrame (" + iframeId + ") " + dimension + " set to " + messageData[dimension] + "px")
}(dimension), chkZero(dimension)
}
let iframeId = messageData.iframe.id;
settings[iframeId] && (settings[iframeId].sizeHeight && processDimension("height"), settings[iframeId].sizeWidth && processDimension("width"))
}
function syncResize(func, messageData, doNotSync) {
doNotSync !== messageData.type && requestAnimationFrame ? (log(messageData.id, "Requesting animation frame"), requestAnimationFrame(func)) : func()
}
function trigger(calleeMsg, msg, iframe, id, noResponseWarning) {
let errorShown = !1;
id = id || iframe.id, settings[id] && (iframe && "contentWindow" in iframe && null !== iframe.contentWindow ? function() {
let target = settings[id] && settings[id].targetOrigin;
log(id, "[" + calleeMsg + "] Sending msg to iframe[" + id + "] (" + msg + ") targetOrigin: " + target), iframe.contentWindow.postMessage(msgId + msg, target)
}() : warn(id, "[" + calleeMsg + "] IFrame(" + id + ") not found"), noResponseWarning && settings[id] && settings[id].warningTimeout && (settings[id].msgTimeout = setTimeout(function() {
!settings[id] || settings[id].loaded || errorShown || (errorShown = !0, warn(id, "IFrame has not responded within " + settings[id].warningTimeout / 1e3 + " seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ingored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))
}, settings[id].warningTimeout)))
}
function createOutgoingMsg(iframeId) {
return iframeId + ":" + settings[iframeId].bodyMarginV1 + ":" + settings[iframeId].sizeWidth + ":" + settings[iframeId].log + ":" + settings[iframeId].interval + ":" + settings[iframeId].enablePublicMethods + ":" + settings[iframeId].autoResize + ":" + settings[iframeId].bodyMargin + ":" + settings[iframeId].heightCalculationMethod + ":" + settings[iframeId].bodyBackground + ":" + settings[iframeId].bodyPadding + ":" + settings[iframeId].tolerance + ":" + settings[iframeId].inPageLinks + ":" + settings[iframeId].resizeFrom + ":" + settings[iframeId].widthCalculationMethod
}
function setupIFrame(iframe, options) {
let iframeId = function(iframeId) {
return logId = iframeId, "" === iframeId && (iframe.id = iframeId = function() {
let id = options && options.id || defaults.id + count++;
return null !== document.getElementById(id) && (id += count++), id
}(), logEnabled = (options || {}).log, logId = iframeId, log(iframeId, "Added missing iframe ID: " + iframeId + " (" + iframe.src + ")")), iframeId
}(iframe.id);
var msg;
iframeId in settings && "iFrameResizer" in iframe ? warn(iframeId, "Ignored iFrame, already setup.") : (! function(options) {
var remoteHost;
options = options || {}, settings[iframeId] = {
firstRun: !0,
iframe: iframe,
remoteHost: iframe.src.split("/").slice(0, 3).join("/")
},
function(options) {
if ("object" != typeof options) throw new TypeError("Options is not an object")
}(options),
function(options) {
for (let option in defaults) defaults.hasOwnProperty(option) && (settings[iframeId][option] = options.hasOwnProperty(option) ? options[option] : defaults[option])
}(options), settings[iframeId] && (settings[iframeId].targetOrigin = !0 === settings[iframeId].checkOrigin ? "" === (remoteHost = settings[iframeId].remoteHost) || "file://" === remoteHost ? "*" : remoteHost : "*")
}(options), function() {
switch (log(iframeId, "IFrame scrolling " + (settings[iframeId] && settings[iframeId].scrolling ? "enabled" : "disabled") + " for " + iframeId), iframe.style.overflow = !1 === (settings[iframeId] && settings[iframeId].scrolling) ? "hidden" : "auto", settings[iframeId] && settings[iframeId].scrolling) {
case !0:
iframe.scrolling = "yes";
break;
case !1:
iframe.scrolling = "no";
break;
default:
iframe.scrolling = settings[iframeId] ? settings[iframeId].scrolling : "no"
}
}(), function() {
function addStyle(style) {
1 / 0 !== settings[iframeId][style] && 0 !== settings[iframeId][style] && (iframe.style[style] = settings[iframeId][style] + "px", log(iframeId, "Set " + style + " = " + settings[iframeId][style] + "px"))
}
function chkMinMax(dimension) {
if (settings[iframeId]["min" + dimension] > settings[iframeId]["max" + dimension]) throw new Error("Value for min" + dimension + " can not be greater than max" + dimension)
}
chkMinMax("Height"), chkMinMax("Width"), addStyle("maxHeight"), addStyle("minHeight"), addStyle("maxWidth"), addStyle("minWidth")
}(), "number" != typeof(settings[iframeId] && settings[iframeId].bodyMargin) && "0" !== (settings[iframeId] && settings[iframeId].bodyMargin) || (settings[iframeId].bodyMarginV1 = settings[iframeId].bodyMargin, settings[iframeId].bodyMargin = settings[iframeId].bodyMargin + "px"), msg = createOutgoingMsg(iframeId), addEventListener(iframe, "load", function() {
trigger("iFrame.onload", msg, iframe, undefined, !0),
function() {
let firstRun = settings[iframeId] && settings[iframeId].firstRun,
resetRequertMethod = settings[iframeId] && settings[iframeId].heightCalculationMethod in resetRequiredMethods;
!firstRun && resetRequertMethod && resetIFrame({
iframe: iframe,
height: 0,
width: 0,
type: "init"
})
}()
}), trigger("init", msg, iframe, undefined, !0), Function.prototype.bind && settings[iframeId] && (settings[iframeId].iframe.iFrameResizer = {
close: closeIFrame.bind(null, settings[iframeId].iframe),
resize: trigger.bind(null, "Window resize", "resize", settings[iframeId].iframe),
moveToAnchor: function(anchor) {
trigger("Move to anchor", "moveToAnchor:" + anchor, settings[iframeId].iframe, iframeId)
},
sendMessage: function(message) {
trigger("Send Message", "message:" + (message = JSON.stringify(message)), settings[iframeId].iframe, iframeId)
}
}))
}
function debouce(fn, time) {
null === timer && (timer = setTimeout(function() {
timer = null, fn()
}, time))
}
function resizeIFrames(event) {
log("window", "Trigger event: " + event), debouce(function() {
sendTriggerMsg("Window " + event, "resize")
}, 16)
}
function tabVisible() {
"hidden" !== document.visibilityState && (log("document", "Trigger event: Visiblity change"), debouce(function() {
sendTriggerMsg("Tab Visable", "resize")
}, 16))
}
function sendTriggerMsg(eventName, event) {
for (let iframeId in settings) settings[iframeId = iframeId] && "parent" === settings[iframeId].resizeFrom && settings[iframeId].autoResize && !settings[iframeId].firstRun && trigger(eventName, event, document.getElementById(iframeId), iframeId);
var iframeId
}
function factory() {
function init(options, element) {
element && (! function() {
if (!element.tagName) throw new TypeError("Object is not a valid DOM element");
if ("IFRAME" !== element.tagName.toUpperCase()) throw new TypeError("Expected <IFRAME> tag, found <" + element.tagName + ">")
}(), setupIFrame(element, options), iFrames.push(element))
}
let iFrames;
return function() {
let x, vendors = ["moz", "webkit", "o", "ms"];
for (x = 0; x < vendors.length && !requestAnimationFrame; x += 1) requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"];
requestAnimationFrame || log("setup", "RequestAnimationFrame not supported")
}(), addEventListener(window, "message", iFrameListener), addEventListener(window, "resize", function() {
resizeIFrames("resize")
}), addEventListener(document, "visibilitychange", tabVisible), addEventListener(document, "-webkit-visibilitychange", tabVisible), addEventListener(window, "focusin", function() {
resizeIFrames("focus")
}), addEventListener(window, "focus", function() {
resizeIFrames("focus")
}),
function(options, target) {
switch (iFrames = [], function(options) {
options && options.enablePublicMethods && warn("enablePublicMethods option has been removed, public methods are now always available in the iFrame")
}(options), typeof target) {
case "undefined":
case "string":
Array.prototype.forEach.call(document.querySelectorAll(target || "iframe"), init.bind(undefined, options));
break;
case "object":
init(options, target);
break;
default:
throw new TypeError("Unexpected data type (" + typeof target + ")")
}
return iFrames
}
}
var $;
window.jQuery && (($ = window.jQuery).fn ? $.fn.iFrameResize || ($.fn.iFrameResize = function(options) {
return this.filter("iframe").each(function(index, element) {
setupIFrame(element, options)
}).end()
}) : info("", "Unable to bind to jQuery, it is not fully loaded.")), "function" == typeof define && define.amd ? define([], factory) : "object" == typeof module && "object" == typeof module.exports ? module.exports = factory() : window.iFrameResize = window.iFrameResize || factory()
}(),
function(root, factory) {
let cssId = "paymentCheckoutCss";
if (!document.getElementById(cssId)) {
let head = document.getElementsByTagName("head")[0],
link = document.createElement("link");
link.id = cssId, link.rel = "stylesheet", link.type = "text/css", link.href = "https://cdn.paymentez.com/ccapi/sdk/payment_checkout_stable.min.css", link.media = "all", head.appendChild(link)
}
"function" == typeof define && define.amd ? define(factory) : "object" == typeof exports ? module.exports = factory() : root.PaymentCheckout = factory()
}(this, function() {
let transitionEvent = function() {
let t, el = document.createElement("payment-checkout-test-transition"),
transitions = {
transition: "transitionend",
OTransition: "oTransitionEnd",
MozTransition: "transitionend",
WebkitTransition: "webkitTransitionEnd"
};
for (t in transitions)
if (void 0 !== el.style[t]) return transitions[t]
}();
function Modal(options) {
this.opts = function() {
for (let i = 1; i < arguments.length; i++)
for (let key in arguments[i]) arguments[i].hasOwnProperty(key) && (arguments[0][key] = arguments[i][key]);
return arguments[0]
}({}, {
client_app_code: null,
client_app_key: null,
env_mode: null,
locale: "en",
onClose: null,
onOpen: null,
onResponse: null,
beforeOpen: null,
beforeClose: null,
stickyFooter: !1,
footer: !1,
cssClass: [],
closeLabel: "",
loadingLabel: "",
errorLabel: "",
closeMethods: ["overlay", "button", "escape"]
}, options), this.DOMAIN = "paymentez.com", this.SERVER_LOCAL_URL = "http://localhost:8080", this.SERVER_DEV_URL = `https://ccapi-dev.${this.DOMAIN}`, this.SERVER_STG_URL = `https://ccapi-stg.${this.DOMAIN}`, this.SERVER_QA_URL = `https://ccapi-qa.${this.DOMAIN}`, this.SERVER_PROD_URL = `https://ccapi.${this.DOMAIN}`, this.PG_MICROS_STAGING = `https://pg-micros-stg.${this.DOMAIN}/v1/unixtime/`, this.PG_MICROS_PRODUCTION = `https://pg-micros.${this.DOMAIN}/v1/unixtime/`, this.init()
}
function _getUniqToken(auth_timestamp, payment_client_app_key) {
return function(message) {
let sha256 = new jsSHA("SHA-256", "TEXT");
return sha256.update(message), sha256.getHash("HEX")
}(payment_client_app_key + auth_timestamp)
}
function _consumeInitCheckout(initCheckoutRequest, successCallback, errorCallback, timestamp) {
fetch(function() {
return {
local: this.SERVER_LOCAL_URL,
dev: this.SERVER_DEV_URL,
stg: this.SERVER_STG_URL,
"prod-qa": this.SERVER_QA_URL,
prod: this.SERVER_PROD_URL
}[this.opts.env_mode] || this.SERVER_STG_URL
}.call(this) + "/v2/transaction/init_checkout", {
method: "POST",
body: JSON.stringify(initCheckoutRequest),
headers: {
"Content-Type": "application/json",
"Auth-Token": function(payment_client_app_code, app_client_key, auth_timestamp) {
let string_auth_token = payment_client_app_code + ";" + auth_timestamp + ";" + _getUniqToken(auth_timestamp, app_client_key);
return btoa(string_auth_token)
}(this.opts.client_app_code, this.opts.client_app_key, timestamp)
}
}).then(response => 200 === response.status ? Promise.resolve(response.json()) : response.json().then(Promise.reject.bind(Promise))).then(response => {
successCallback(response)
}).catch(error => {
error = error.hasOwnProperty("error") ? error : {
error: {
type: "Server Error",
help: "Please Try Again Later",
description: "Something Went Wrong"
}
}, errorCallback(error)
})
}
function _recalculateFooterPosition() {
this.modalBoxFooter && (this.modalBoxFooter.style.width = this.modalBox.clientWidth + "px", this.modalBoxFooter.style.left = this.modalBox.offsetLeft + "px")
}
return Modal.prototype.init = function() {
let self = this;
this.modal || ("pt" === self.opts.locale ? (self.opts.closeLabel = "Fechar", self.opts.loadingLabel = "Carregando...", self.opts.errorLabel = "Desculpe, houve um problema ao carregar o Checkout: ") : "es" === self.opts.locale ? (self.opts.closeLabel = "Cerrar", self.opts.loadingLabel = "Cargando...", self.opts.errorLabel = "Disculpe, se produjo un problema cargando el Checkout: ") : (self.opts.closeLabel = "Close", self.opts.loadingLabel = "Loading...", self.opts.errorLabel = "Sorry, there was a problem loading Checkout: "), function() {
this.modal = document.createElement("div"), this.modal.classList.add("payment-checkout-modal"), (0 === this.opts.closeMethods.length || -1 === this.opts.closeMethods.indexOf("overlay")) && this.modal.classList.add("payment-checkout-modal--noOverlayClose");
this.modal.style.display = "none", this.opts.cssClass.forEach(function(item) {
"string" == typeof item && this.modal.classList.add(item)
}, this), -1 !== this.opts.closeMethods.indexOf("button") && (this.modalCloseBtn = document.createElement("button"), this.modalCloseBtn.classList.add("payment-checkout-modal__close"), this.modalCloseBtnIcon = document.createElement("span"), this.modalCloseBtnIcon.classList.add("payment-checkout-modal__closeIcon"), this.modalCloseBtnIcon.innerHTML = "×", this.modalCloseBtnLabel = document.createElement("span"), this.modalCloseBtnLabel.classList.add("payment-checkout-modal__closeLabel"), this.modalCloseBtnLabel.innerHTML = this.opts.closeLabel, this.modalCloseBtn.appendChild(this.modalCloseBtnIcon), this.modalCloseBtn.appendChild(this.modalCloseBtnLabel));
this.modalBox = document.createElement("div"), this.modalBox.classList.add("payment-checkout-modal-box"), this.modalBoxContent = document.createElement("div"), this.modalBoxContent.classList.add("payment-checkout-modal-box__content"), this.modalBox.appendChild(this.modalBoxContent), -1 !== this.opts.closeMethods.indexOf("button") && this.modal.appendChild(this.modalCloseBtn);
this.modal.appendChild(this.modalBox)
}.call(this), function() {
this._events = {
clickCloseBtn: this.close.bind(this),
clickOverlay: function(event) {
-1 !== this.opts.closeMethods.indexOf("overlay") && ! function(el, cls) {
for (;
(el = el.parentElement) && !el.classList.contains(cls););
return el
}(event.target, "payment-checkout-modal") && event.clientX < this.modal.clientWidth && this.close()
}.bind(this),
resize: this.checkOverflow.bind(this),
keyboardNav: function(event) {
-1 !== this.opts.closeMethods.indexOf("escape") && 27 === event.which && this.isOpen() && this.close()
}.bind(this)
}, -1 !== this.opts.closeMethods.indexOf("button") && this.modalCloseBtn.addEventListener("click", this._events.clickCloseBtn);
this.modal.addEventListener("mousedown", this._events.clickOverlay), window.addEventListener("resize", this._events.resize), document.addEventListener("keydown", this._events.keyboardNav)
}.call(this), document.body.insertBefore(this.modal, document.body.firstChild), this.opts.footer && this.addFooter())
}, Modal.prototype.destroy = function() {
null !== this.modal && (function() {
-1 !== this.opts.closeMethods.indexOf("button") && this.modalCloseBtn.removeEventListener("click", this._events.clickCloseBtn);
this.modal.removeEventListener("mousedown", this._events.clickOverlay), window.removeEventListener("resize", this._events.resize), document.removeEventListener("keydown", this._events.keyboardNav)
}.call(this), this.modal.parentNode.removeChild(this.modal), this.modal = null)
}, Modal.prototype.open = function(orderRequest) {
let self = this;
"function" == typeof self.opts.beforeOpen && self.opts.beforeOpen(), this.modal.style.removeProperty ? this.modal.style.removeProperty("display") : this.modal.style.removeAttribute("display"), document.body.classList.add("payment-checkout-enabled"), this.setStickyFooter(this.opts.stickyFooter), this.modal.classList.add("payment-checkout-modal--visible"), this.modalBoxContent.innerHTML = '<div class="payment_dialog_info"><i class="fa fa-times-circle"></i><span>' + self.opts.loadingLabel + "</span></div>";
let installments_type = -1;
parseInt(orderRequest.order_installments_type) >= 0 && (installments_type = orderRequest.order_installments_type);
let params = {
session_id: "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, function(c) {
let r = 16 * Math.random() | 0,
v = "x" == c ? r : 3 & r | 8;
return v.toString(16)
}),
locale: self.opts.locale,
origin: orderRequest.origin || "CheckoutJs",
user: {
id: orderRequest.user_id,
email: orderRequest.user_email,
phone: orderRequest.user_phone
},
order: {
amount: orderRequest.order_amount,
description: orderRequest.order_description,
vat: orderRequest.order_vat,
dev_reference: orderRequest.order_reference,
installments_type: installments_type,
currency: "USD"
},
conf: {
allowed_card_brands: orderRequest.conf_exclusive_types || orderRequest.conf_allowed_card_brands,
allowed_card_types: orderRequest.conf_allowed_card_types,
invalid_card_type_message: orderRequest.conf_invalid_card_type_message,
style_version: orderRequest.style_version || "2",
theme: {
primary_color: "#00BF84",
secondary_color: "#545454",
logo: "https://controlarmas.ccffaa.mil.ec/wp-content/uploads/sites/6/2022/07/CONTROL-DE-ARMAS.png",
background_image: null
}
},
billing_address: orderRequest.billing_address,
extra_data: orderRequest.extra_data
},
taxable_amount = orderRequest.order_taxable_amount;
void 0 !== taxable_amount && null !== taxable_amount && taxable_amount >= 0 && (params.order.taxable_amount = taxable_amount);
let tax_percentage = orderRequest.order_tax_percentage;
void 0 !== tax_percentage && null !== tax_percentage && tax_percentage >= 0 && (params.order.tax_percentage = tax_percentage),
function(initCheckoutRequest, successCallback, errorCallback) {
fetch(function() {
return {
local: this.PG_MICROS_STAGING,
dev: this.PG_MICROS_STAGING,
stg: this.PG_MICROS_STAGING,
"prod-qa": this.PG_MICROS_PRODUCTION,
prod: this.PG_MICROS_PRODUCTION
}[this.opts.env_mode] || this.PG_MICROS_STAGING
}.call(this), {
timeout: 2e3,
method: "GET",
headers: {
"Content-Type": "application/json"
}
}).then(response => 200 === response.status ? Promise.resolve(response.json()) : response.json().then(Promise.reject.bind(Promise))).then(response => {
_consumeInitCheckout.call(this, initCheckoutRequest, successCallback, errorCallback, String(response.unixtime))
}).catch(error => {
console.error(error), _consumeInitCheckout.call(this, initCheckoutRequest, successCallback, errorCallback, String(Math.floor((new Date).getTime() / 1e3)))
})
}.call(this, params, function(checkout_response) {
self.openModal(checkout_response.checkout_url)
}, function(error_response) {
self.modalBoxContent.innerHTML = '<div class="payment_dialog_error"><i class="fa fa-times-circle"></i><span>' + self.opts.errorLabel + error_response.error.type + "</span></div>"
}), transitionEvent ? this.modal.addEventListener(transitionEvent, function handler() {
"function" == typeof self.opts.onOpen && self.opts.onOpen.call(self), self.modal.removeEventListener(transitionEvent, handler, !1)
}, !1) : "function" == typeof self.opts.onOpen && self.opts.onOpen.call(self), this.checkOverflow()
}, Modal.prototype.openModal = function(iframe_url) {
let self = this;
this.modalBoxContent.innerHTML = "";
let content = document.createElement("iframe");
content.setAttribute("id", "modalBoxContentPaymentCheckout"), content.setAttribute("scrolling", "no"), content.setAttribute("width", "100%"), content.setAttribute("frameBorder", "0"), content.setAttribute("padding", "0"), content.setAttribute("margin", "0"), content.setAttribute("src", iframe_url), this.modalBoxContent.appendChild(content), this.checkOverflow(), iFrameResize({
log: !1,
checkOrigin: !1,
messageCallback: function(messageData) {
"function" == typeof self.opts.onResponse && (self.opts.onResponse.call(this, messageData.message), self.close())
}
}, "#modalBoxContentPaymentCheckout")
}, Modal.prototype.isOpen = function() {
return !!this.modal.classList.contains("payment-checkout-modal--visible")
}, Modal.prototype.close = function() {
if ("function" == typeof this.opts.beforeClose) {
if (!this.opts.beforeClose.call(this)) return
}
document.body.classList.remove("payment-checkout-enabled"), this.modal.classList.remove("payment-checkout-modal--visible");
let self = this;
transitionEvent ? this.modal.addEventListener(transitionEvent, function handler() {
self.modal.removeEventListener(transitionEvent, handler, !1), self.modal.style.display = "none", "function" == typeof self.opts.onClose && self.opts.onClose.call(this)
}, !1) : (self.modal.style.display = "none", "function" == typeof self.opts.onClose && self.opts.onClose.call(this))
}, Modal.prototype.setContent = function(content) {}, Modal.prototype.getContent = function() {
return this.modalBoxContent
}, Modal.prototype.addFooter = function() {
(function() {
this.modalBoxFooter = document.createElement("div"), this.modalBoxFooter.classList.add("payment-checkout-modal-box__footer"), this.modalBox.appendChild(this.modalBoxFooter)
}).call(this)
}, Modal.prototype.setFooterContent = function(content) {
this.modalBoxFooter.innerHTML = content
}, Modal.prototype.getFooterContent = function() {
return this.modalBoxFooter
}, Modal.prototype.setStickyFooter = function(isSticky) {
this.isOverflow() || (isSticky = !1), isSticky ? this.modalBox.contains(this.modalBoxFooter) && (this.modalBox.removeChild(this.modalBoxFooter), this.modal.appendChild(this.modalBoxFooter), this.modalBoxFooter.classList.add("payment-checkout-modal-box__footer--sticky"), _recalculateFooterPosition.call(this), this.modalBoxContent.style["padding-bottom"] = this.modalBoxFooter.clientHeight + 20 + "px") : this.modalBoxFooter && (this.modalBox.contains(this.modalBoxFooter) || (this.modal.removeChild(this.modalBoxFooter), this.modalBox.appendChild(this.modalBoxFooter), this.modalBoxFooter.style.width = "auto", this.modalBoxFooter.style.left = "", this.modalBoxContent.style["padding-bottom"] = "", this.modalBoxFooter.classList.remove("payment-checkout-modal-box__footer--sticky")))
}, Modal.prototype.addFooterBtn = function(label, cssClass, callback) {
let btn = document.createElement("button");
return btn.innerHTML = label, btn.addEventListener("click", callback), "string" == typeof cssClass && cssClass.length && cssClass.split(" ").forEach(function(item) {
btn.classList.add(item)
}), this.modalBoxFooter.appendChild(btn), btn
}, Modal.prototype.resize = function() {
console.warn("Resize is deprecated and will be removed in version 1.0")
}, Modal.prototype.isOverflow = function() {
let viewportHeight = window.innerHeight;
return this.modalBox.clientHeight >= viewportHeight
}, Modal.prototype.checkOverflow = function() {
this.modal.classList.contains("payment-checkout-modal--visible") && (this.isOverflow() ? this.modal.classList.add("payment-checkout-modal--overflow") : this.modal.classList.remove("payment-checkout-modal--overflow"), !this.isOverflow() && this.opts.stickyFooter ? this.setStickyFooter(!1) : this.isOverflow() && this.opts.stickyFooter && (_recalculateFooterPosition.call(this), this.setStickyFooter(!0)))
}, {
modal: Modal
}
});
"use strict";
! function(I) {
function w(c, a, d) {
var f, n, k, e, h, q, y, p, u, l = 0,
b = [],
g = 0,
m = !1,
t = [],
r = [],
z = !1;
if (f = (d = d || {}).encoding || "UTF8", (u = d.numRounds || 1) !== parseInt(u, 10) || 1 > u) throw Error("numRounds must a integer >= 1");
if (0 !== c.lastIndexOf("SHA-", 0)) throw Error("Chosen SHA variant is not supported");
if (q = function(b, a) {
return A(b, a, c)
}, y = function(b, a, l, f) {
var g, e;
if ("SHA-224" !== c && "SHA-256" !== c) throw Error("Unexpected error in SHA-2 implementation");
for (g = 15 + (a + 65 >>> 9 << 4), e = 16; b.length <= g;) b.push(0);
for (b[a >>> 5] |= 128 << 24 - a % 32, a += l, b[g] = 4294967295 & a, b[g - 1] = a / 4294967296 | 0, l = b.length, a = 0; a < l; a += e) f = A(b.slice(a, a + e), f, c);
if ("SHA-224" === c) b = [f[0], f[1], f[2], f[3], f[4], f[5], f[6]];
else {
if ("SHA-256" !== c) throw Error("Unexpected error in SHA-2 implementation");
b = f
}
return b
}, p = function(b) {
return b.slice()
}, "SHA-224" === c) h = 512, e = 224;
else {
if ("SHA-256" !== c) throw Error("Chosen SHA variant is not supported");
h = 512, e = 256
}
k = B(a, f), n = x(c), this.setHMACKey = function(b, a, g) {
var e;
if (!0 === m) throw Error("HMAC key already set");
if (!0 === z) throw Error("Cannot set HMAC key after calling update");
if (b = (a = B(a, f = (g || {}).encoding || "UTF8")(b)).binLen, a = a.value, g = (e = h >>> 3) / 4 - 1, e < b / 8) {
for (a = y(a, b, 0, x(c)); a.length <= g;) a.push(0);
a[g] &= 4294967040
} else if (e > b / 8) {
for (; a.length <= g;) a.push(0);
a[g] &= 4294967040
}
for (b = 0; b <= g; b += 1) t[b] = 909522486 ^ a[b], r[b] = 1549556828 ^ a[b];
n = q(t, n), l = h, m = !0
}, this.update = function(a) {
var c, f, e, d = 0,
p = h >>> 5;
for (a = (c = k(a, b, g)).binLen, f = c.value, c = a >>> 5, e = 0; e < c; e += p) d + h <= a && (n = q(f.slice(e, e + p), n), d += h);
l += d, b = f.slice(d >>> 5), g = a % h, z = !0
}, this.getHash = function(a, f) {
var d, h, k, q;
if (!0 === m) throw Error("Cannot call getHash after setting HMAC key");
switch (k = C(f), a) {
case "HEX":
d = function(a) {
return D(a, e, k)
};
break;
case "B64":
d = function(a) {
return E(a, e, k)
};
break;
case "BYTES":
d = function(a) {
return F(a, e)
};
break;
case "ARRAYBUFFER":
try {
h = new ArrayBuffer(0)
} catch (v) {
throw Error("ARRAYBUFFER not supported by this environment")
}
d = function(a) {
return G(a, e)
};
break;
default:
throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")
}
for (q = y(b.slice(), g, l, p(n)), h = 1; h < u; h += 1) q = y(q, e, 0, x(c));
return d(q)
}, this.getHMAC = function(a, f) {
var d, k, t, u;
if (!1 === m) throw Error("Cannot call getHMAC without first setting HMAC key");
switch (t = C(f), a) {
case "HEX":
d = function(a) {
return D(a, e, t)
};
break;
case "B64":
d = function(a) {
return E(a, e, t)
};
break;
case "BYTES":
d = function(a) {
return F(a, e)
};
break;
case "ARRAYBUFFER":
try {
d = new ArrayBuffer(0)
} catch (v) {
throw Error("ARRAYBUFFER not supported by this environment")
}
d = function(a) {
return G(a, e)
};
break;
default:
throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER")
}
return k = y(b.slice(), g, l, p(n)), u = q(r, x(c)), d(u = y(k, e, h, u))
}
}
function m() {}
function D(c, a, d) {
var b, g, l = "";
for (a /= 8, b = 0; b < a; b += 1) g = c[b >>> 2] >>> 8 * (3 + b % 4 * -1), l += "0123456789abcdef".charAt(g >>> 4 & 15) + "0123456789abcdef".charAt(15 & g);
return d.outputUpper ? l.toUpperCase() : l
}
function E(c, a, d) {
var g, f, n, l = "",
b = a / 8;
for (g = 0; g < b; g += 3)
for (f = g + 1 < b ? c[g + 1 >>> 2] : 0, n = g + 2 < b ? c[g + 2 >>> 2] : 0, n = (c[g >>> 2] >>> 8 * (3 + g % 4 * -1) & 255) << 16 | (f >>> 8 * (3 + (g + 1) % 4 * -1) & 255) << 8 | n >>> 8 * (3 + (g + 2) % 4 * -1) & 255, f = 0; 4 > f; f += 1) l += 8 * g + 6 * f <= a ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n >>> 6 * (3 - f) & 63) : d.b64Pad;
return l
}
function F(c, a) {
var b, g, d = "",
l = a / 8;
for (b = 0; b < l; b += 1) g = c[b >>> 2] >>> 8 * (3 + b % 4 * -1) & 255, d += String.fromCharCode(g);
return d
}
function G(c, a) {
var l, g, d = a / 8,
b = new ArrayBuffer(d);
for (g = new Uint8Array(b), l = 0; l < d; l += 1) g[l] = c[l >>> 2] >>> 8 * (3 + l % 4 * -1) & 255;
return b
}
function C(c) {
var a = {
outputUpper: !1,
b64Pad: "=",
shakeLen: -1
};
if (c = c || {}, a.outputUpper = c.outputUpper || !1, !0 === c.hasOwnProperty("b64Pad") && (a.b64Pad = c.b64Pad), "boolean" != typeof a.outputUpper) throw Error("Invalid outputUpper formatting option");
if ("string" != typeof a.b64Pad) throw Error("Invalid b64Pad formatting option");
return a
}
function B(c, a) {
var d;
switch (a) {
case "UTF8":
case "UTF16BE":
case "UTF16LE":
break;
default:
throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")
}
switch (c) {
case "HEX":
d = function(a, b, c) {
var d, k, e, h, q, f = a.length;
if (0 != f % 2) throw Error("String of HEX type must be in byte increments");
for (b = b || [0], q = (c = c || 0) >>> 3, d = 0; d < f; d += 2) {
if (k = parseInt(a.substr(d, 2), 16), isNaN(k)) throw Error("String of HEX type contains invalid characters");
for (e = (h = (d >>> 1) + q) >>> 2; b.length <= e;) b.push(0);
b[e] |= k << 8 * (3 + h % 4 * -1)
}
return {
value: b,
binLen: 4 * f + c
}
};
break;
case "TEXT":
d = function(c, b, d) {
var f, n, e, h, q, m, p, r, k = 0;
if (b = b || [0], q = (d = d || 0) >>> 3, "UTF8" === a)
for (r = 3, e = 0; e < c.length; e += 1)
for (n = [], 128 > (f = c.charCodeAt(e)) ? n.push(f) : 2048 > f ? (n.push(192 | f >>> 6), n.push(128 | 63 & f)) : 55296 > f || 57344 <= f ? n.push(224 | f >>> 12, 128 | f >>> 6 & 63, 128 | 63 & f) : (e += 1, f = 65536 + ((1023 & f) << 10 | 1023 & c.charCodeAt(e)), n.push(240 | f >>> 18, 128 | f >>> 12 & 63, 128 | f >>> 6 & 63, 128 | 63 & f)), h = 0; h < n.length; h += 1) {
for (m = (p = k + q) >>> 2; b.length <= m;) b.push(0);
b[m] |= n[h] << 8 * (r + p % 4 * -1), k += 1
} else if ("UTF16BE" === a || "UTF16LE" === a)
for (r = 2, n = "UTF16LE" === a || "UTF16LE" !== a && !1, e = 0; e < c.length; e += 1) {
for (f = c.charCodeAt(e), !0 === n && (f = (h = 255 & f) << 8 | f >>> 8), m = (p = k + q) >>> 2; b.length <= m;) b.push(0);
b[m] |= f << 8 * (r + p % 4 * -1), k += 2
}
return {
value: b,
binLen: 8 * k + d
}
};
break;
case "B64":
d = function(a, b, c) {
var d, k, e, h, q, m, p, f = 0;
if (-1 === a.search(/^[a-zA-Z0-9=+\/]+$/)) throw Error("Invalid character in base-64 string");
if (k = a.indexOf("="), a = a.replace(/\=/g, ""), -1 !== k && k < a.length) throw Error("Invalid '=' found in base-64 string");
for (b = b || [0], m = (c = c || 0) >>> 3, k = 0; k < a.length; k += 4) {
for (q = a.substr(k, 4), e = h = 0; e < q.length; e += 1) h |= (d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(q[e])) << 18 - 6 * e;
for (e = 0; e < q.length - 1; e += 1) {
for (d = (p = f + m) >>> 2; b.length <= d;) b.push(0);
b[d] |= (h >>> 16 - 8 * e & 255) << 8 * (3 + p % 4 * -1), f += 1
}
}
return {
value: b,
binLen: 8 * f + c
}
};
break;
case "BYTES":
d = function(a, b, c) {
var d, n, k, e, h;
for (b = b || [0], k = (c = c || 0) >>> 3, n = 0; n < a.length; n += 1) d = a.charCodeAt(n), e = (h = n + k) >>> 2, b.length <= e && b.push(0), b[e] |= d << 8 * (3 + h % 4 * -1);
return {
value: b,
binLen: 8 * a.length + c
}
};
break;
case "ARRAYBUFFER":
try {
d = new ArrayBuffer(0)
} catch (l) {
throw Error("ARRAYBUFFER not supported by this environment")
}
d = function(a, b, c) {
var d, n, k, e, h;
for (b = b || [0], n = (c = c || 0) >>> 3, h = new Uint8Array(a), d = 0; d < a.byteLength; d += 1) k = (e = d + n) >>> 2, b.length <= k && b.push(0), b[k] |= h[d] << 8 * (3 + e % 4 * -1);
return {
value: b,
binLen: 8 * a.byteLength + c
}
};
break;
default:
throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER")
}
return d
}
function r(c, a) {
return c >>> a | c << 32 - a
}
function J(c, a, d) {
return c & a ^ ~c & d
}
function K(c, a, d) {
return c & a ^ c & d ^ a & d
}
function L(c) {
return r(c, 2) ^ r(c, 13) ^ r(c, 22)
}
function M(c) {
return r(c, 6) ^ r(c, 11) ^ r(c, 25)
}
function N(c) {
return r(c, 7) ^ r(c, 18) ^ c >>> 3
}
function O(c) {
return r(c, 17) ^ r(c, 19) ^ c >>> 10
}
function P(c, a) {
var d = (65535 & c) + (65535 & a);
return ((c >>> 16) + (a >>> 16) + (d >>> 16) & 65535) << 16 | 65535 & d
}
function Q(c, a, d, l) {
var b = (65535 & c) + (65535 & a) + (65535 & d) + (65535 & l);
return ((c >>> 16) + (a >>> 16) + (d >>> 16) + (l >>> 16) + (b >>> 16) & 65535) << 16 | 65535 & b
}
function R(c, a, d, l, b) {
var g = (65535 & c) + (65535 & a) + (65535 & d) + (65535 & l) + (65535 & b);
return ((c >>> 16) + (a >>> 16) + (d >>> 16) + (l >>> 16) + (b >>> 16) + (g >>> 16) & 65535) << 16 | 65535 & g
}
function x(c) {
var d, a = [];
if (0 !== c.lastIndexOf("SHA-", 0)) throw Error("No SHA variants supported");
switch (a = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428], d = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], c) {
case "SHA-224":
break;
case "SHA-256":
a = d;
break;
case "SHA-384":
case "SHA-512":
a = [new m, new m, new m, new m, new m, new m, new m, new m];
break;
default:
throw Error("Unknown SHA variant")
}
return a
}
function A(c, a, d) {
var l, b, g, f, n, k, e, h, m, r, p, w, t, x, u, z, A, B, C, D, E, F, G, v = [];
if ("SHA-224" !== d && "SHA-256" !== d) throw Error("Unexpected error in SHA-2 implementation");
for (r = 64, w = 1, F = Number, t = P, x = Q, u = R, z = N, A = O, B = L, C = M, E = K, D = J, G = H, d = a[0], l = a[1], b = a[2], g = a[3], f = a[4], n = a[5], k = a[6], e = a[7], p = 0; p < r; p += 1) 16 > p ? (m = p * w, h = c.length <= m ? 0 : c[m], m = c.length <= m + 1 ? 0 : c[m + 1], v[p] = new F(h, m)) : v[p] = x(A(v[p - 2]), v[p - 7], z(v[p - 15]), v[p - 16]), h = u(e, C(f), D(f, n, k), G[p], v[p]), m = t(B(d), E(d, l, b)), e = k, k = n, n = f, f = t(g, h), g = b, b = l, l = d, d = t(h, m);
return a[0] = t(d, a[0]), a[1] = t(l, a[1]), a[2] = t(b, a[2]), a[3] = t(g, a[3]), a[4] = t(f, a[4]), a[5] = t(n, a[5]), a[6] = t(k, a[6]), a[7] = t(e, a[7]), a
}
var H;
H = [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], "function" == typeof define && define.amd ? define(function() {
return w
}) : "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (module.exports = w), exports = w) : I.jsSHA = w
}(this);