!function(n,t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?module.exports=t(require("jquery")):n.bootbox=t(n.jQuery)}(this,function e(n,t){"use strict";function b(t,i,r){return n.extend(!0,{},t,function(n,t){var r=n.length,i={};if(r<1||2<r)throw new Error("Invalid argument length");return 2===r||"string"==typeof n[0]?(i[t[0]]=n[0],i[t[1]]=n[1]):i=n[0],i}(i,r))}function h(n,i,r,o){var c,s,l,h,a;return o&&o[0]&&(c=o[0].locale||f.locale,(o[0].swapButtonOrder||f.swapButtonOrder)&&(i=i.reverse())),a={className:"bootbox-"+n,buttons:function(n,t){for(var r,s,u,f={},i=0,h=n.length;i<h;i++){var o=n[i],c=o.toLowerCase(),l=o.toUpperCase();f[c]={label:(r=l,s=t,u=e[s],u?u[r]:e.en[r])}}return f}(i,c)},s=b(a,o,r),h={},u(l=i,function(n,t){h[t]=!0}),u(s.buttons,function(n){if(h[n]===t)throw new Error('button key "'+n+'" is not allowed (options are '+l.join(" ")+")");}),s}function v(n){return Object.keys(n).length}function u(t,i){var r=0;n.each(t,function(n,t){i(n,t,r++)})}function y(n){n.data.dialog.find(".bootbox-accept").first().trigger("focus")}function k(n){n.target===n.data.dialog[0]&&n.data.dialog.remove()}function d(n){n.target===n.data.dialog[0]&&(n.data.dialog.off("escape.close.bb"),n.data.dialog.off("click"))}function c(t,i,r){t.stopPropagation();t.preventDefault();n.isFunction(r)&&!1===r.call(i,t)||i.modal("hide")}function p(n){return/([01][0-9]|2[0-3]):[0-5][0-9]?:[0-5][0-9]/.test(n)}function w(n){return/(\d{4})-(\d{2})-(\d{2})/.test(n)}var o,l,s,a,i;Object.keys||(Object.keys=(o=Object.prototype.hasOwnProperty,l=!{toString:null}.propertyIsEnumerable("toString"),a=(s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(n){if("function"!=typeof n&&("object"!=typeof n||null===n))throw new TypeError("Object.keys called on non-object");var i,t,r=[];for(i in n)o.call(n,i)&&r.push(i);if(l)for(t=0;t<a;t++)o.call(n,s[t])&&r.push(s[t]);return r}));i={};i.VERSION="5.5.2";var e={en:{OK:"OK",CANCEL:"Cancel",CONFIRM:"OK"}},r={dialog:'<div class="bootbox modal" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-body"><div class="bootbox-body"><\/div><\/div><\/div><\/div><\/div>',header:'<div class="modal-header"><h5 class="modal-title"><\/h5><\/div>',footer:'<div class="modal-footer"><\/div>',closeButton:'<button type="button" class="bootbox-close-button close" aria-hidden="true">&times;<\/button>',form:'<form class="bootbox-form"><\/form>',button:'<button type="button" class="btn"><\/button>',option:"<option><\/option>",promptMessage:'<div class="bootbox-prompt-message"><\/div>',inputs:{text:'<input class="bootbox-input bootbox-input-text form-control" autocomplete="off" type="text" />',textarea:'<textarea class="bootbox-input bootbox-input-textarea form-control"><\/textarea>',email:'<input class="bootbox-input bootbox-input-email form-control" autocomplete="off" type="email" />',select:'<select class="bootbox-input bootbox-input-select form-control"><\/select>',checkbox:'<div class="form-check checkbox"><label class="form-check-label"><input class="form-check-input bootbox-input bootbox-input-checkbox" type="checkbox" /><\/label><\/div>',radio:'<div class="form-check radio"><label class="form-check-label"><input class="form-check-input bootbox-input bootbox-input-radio" type="radio" name="bootbox-radio" /><\/label><\/div>',date:'<input class="bootbox-input bootbox-input-date form-control" autocomplete="off" type="date" />',time:'<input class="bootbox-input bootbox-input-time form-control" autocomplete="off" type="time" />',number:'<input class="bootbox-input bootbox-input-number form-control" autocomplete="off" type="number" />',password:'<input class="bootbox-input bootbox-input-password form-control" autocomplete="off" type="password" />',range:'<input class="bootbox-input bootbox-input-range form-control-range" autocomplete="off" type="range" />'}},f={locale:"en",backdrop:"static",animate:!0,className:null,closeButton:!0,show:!0,container:"body",value:"",inputType:"text",swapButtonOrder:!1,centerVertical:!1,multiple:!1,scrollable:!1,reusable:!1};return i.locales=function(n){return n?e[n]:e},i.addLocale=function(t,r){return n.each(["OK","CANCEL","CONFIRM"],function(n,t){if(!r[t])throw new Error('Please supply a translation for "'+t+'"');}),e[t]={OK:r.OK,CANCEL:r.CANCEL,CONFIRM:r.CONFIRM},i},i.removeLocale=function(n){if("en"===n)throw new Error('"en" is used as the default and fallback locale and cannot be removed.');return delete e[n],i},i.setLocale=function(n){return i.setDefaults("locale",n)},i.setDefaults=function(){var t={};return 2===arguments.length?t[arguments[0]]=arguments[1]:t=arguments[0],n.extend(f,t),i},i.hideAll=function(){return n(".bootbox").modal("hide"),i},i.init=function(t){return e(t||n)},i.dialog=function(i){var a,l;if(n.fn.modal===t)throw new Error('"$.fn.modal" is not defined; please double check you have included the Bootstrap JavaScript library. See https://getbootstrap.com/docs/4.4/getting-started/javascript/ for more details.');(i=function(t){var i,r;if("object"!=typeof t)throw new Error("Please supply an object of options");if(!t.message)throw new Error('"message" option must not be null or an empty string.');return t.backdrop=(t=n.extend({},f,t)).backdrop?"string"!=typeof t.backdrop||"static"!==t.backdrop.toLowerCase()||"static":!1!==t.backdrop&&0!==t.backdrop&&"static",t.buttons||(t.buttons={}),i=t.buttons,r=v(i),u(i,function(u,f,e){if(n.isFunction(f)&&(f=i[u]={callback:f}),"object"!==n.type(f))throw new Error('button with key "'+u+'" must be an object');if(f.label||(f.label=u),!f.className){var o=!1;o=t.swapButtonOrder?0===e:e===r-1;f.className=r<=2&&o?"btn-primary":"btn-secondary btn-default"}}),t}(i),n.fn.modal.Constructor.VERSION)?(i.fullBootstrapVersion=n.fn.modal.Constructor.VERSION,a=i.fullBootstrapVersion.indexOf("."),i.bootstrap=i.fullBootstrapVersion.substring(0,a)):(i.bootstrap="2",i.fullBootstrapVersion="2.3.2",console.warn("Bootbox will *mostly* work with Bootstrap 2, but we do not officially support it. Please upgrade, if possible."));var e=n(r.dialog),o=e.find(".modal-dialog"),h=e.find(".modal-body"),w=n(r.header),p=n(r.footer),b=i.buttons,s={onEscape:i.onEscape};if(h.find(".bootbox-body").html(i.message),0<v(i.buttons)&&(u(b,function(t,i){var u=n(r.button);switch(u.data("bb-handler",t),u.addClass(i.className),t){case"ok":case"confirm":u.addClass("bootbox-accept");break;case"cancel":u.addClass("bootbox-cancel")}u.html(i.label);p.append(u);s[t]=i.callback}),h.after(p)),!0===i.animate&&e.addClass("fade"),i.className&&e.addClass(i.className),i.size)switch(i.fullBootstrapVersion.substring(0,3)<"3.1"&&console.warn('"size" requires Bootstrap 3.1.0 or higher. You appear to be using '+i.fullBootstrapVersion+". Please upgrade to use this option."),i.size){case"small":case"sm":o.addClass("modal-sm");break;case"large":case"lg":o.addClass("modal-lg");break;case"extra-large":case"xl":o.addClass("modal-xl");i.fullBootstrapVersion.substring(0,3)<"4.2"&&console.warn('Using size "xl"/"extra-large" requires Bootstrap 4.2.0 or higher. You appear to be using '+i.fullBootstrapVersion+". Please upgrade to use this option.")}if((i.scrollable&&(o.addClass("modal-dialog-scrollable"),i.fullBootstrapVersion.substring(0,3)<"4.3"&&console.warn('Using "scrollable" requires Bootstrap 4.3.0 or higher. You appear to be using '+i.fullBootstrapVersion+". Please upgrade to use this option.")),i.title&&(h.before(w),e.find(".modal-title").html(i.title)),i.closeButton)&&(l=n(r.closeButton),i.title?3<i.bootstrap?e.find(".modal-header").append(l):e.find(".modal-header").prepend(l):l.prependTo(h)),i.centerVertical&&(o.addClass("modal-dialog-centered"),i.fullBootstrapVersion<"4.0.0"&&console.warn('"centerVertical" requires Bootstrap 4.0.0-beta.3 or higher. You appear to be using '+i.fullBootstrapVersion+". Please upgrade to use this option.")),i.reusable||e.one("hide.bs.modal",{dialog:e},d),i.onHide){if(!n.isFunction(i.onHide))throw new Error('Argument supplied to "onHide" must be a function');e.on("hide.bs.modal",i.onHide)}if(i.reusable||e.one("hidden.bs.modal",{dialog:e},k),i.onHidden){if(!n.isFunction(i.onHidden))throw new Error('Argument supplied to "onHidden" must be a function');e.on("hidden.bs.modal",i.onHidden)}if(i.onShow){if(!n.isFunction(i.onShow))throw new Error('Argument supplied to "onShow" must be a function');e.on("show.bs.modal",i.onShow)}if(e.one("shown.bs.modal",{dialog:e},y),i.onShown){if(!n.isFunction(i.onShown))throw new Error('Argument supplied to "onShown" must be a function');e.on("shown.bs.modal",i.onShown)}return!0===i.backdrop&&e.on("click.dismiss.bs.modal",function(n){e.children(".modal-backdrop").length&&(n.currentTarget=e.children(".modal-backdrop").get(0));n.target===n.currentTarget&&e.trigger("escape.close.bb")}),e.on("escape.close.bb",function(n){s.onEscape&&c(n,e,s.onEscape)}),e.on("click",".modal-footer button:not(.disabled)",function(i){var r=n(this).data("bb-handler");r!==t&&c(i,e,s[r])}),e.on("click",".bootbox-close-button",function(n){c(n,e,s.onEscape)}),e.on("keyup",function(n){27===n.which&&e.trigger("escape.close.bb")}),n(i.container).append(e),e.modal({backdrop:i.backdrop,keyboard:!1,show:!1}),i.show&&e.modal("show"),e},i.alert=function(){var t;if((t=h("alert",["ok"],["message","callback"],arguments)).callback&&!n.isFunction(t.callback))throw new Error('alert requires the "callback" property to be a function when provided');return t.buttons.ok.callback=t.onEscape=function(){return!n.isFunction(t.callback)||t.callback.call(this)},i.dialog(t)},i.confirm=function(){var t;if(t=h("confirm",["cancel","confirm"],["message","callback"],arguments),!n.isFunction(t.callback))throw new Error("confirm requires a callback");return t.buttons.cancel.callback=t.onEscape=function(){return t.callback.call(this,!1)},t.buttons.confirm.callback=function(){return t.callback.call(this,!0)},i.dialog(t)},i.prompt=function(){var e,l,c,o,b,s,a,k,v,d;if(c=n(r.form),(e=h("prompt",["cancel","confirm"],["title","callback"],arguments)).value||(e.value=f.value),e.inputType||(e.inputType=f.inputType),b=e.show===t?f.show:e.show,e.show=!1,e.buttons.cancel.callback=e.onEscape=function(){return e.callback.call(this,null)},e.buttons.confirm.callback=function(){var t;if("checkbox"===e.inputType)t=o.find("input:checked").map(function(){return n(this).val()}).get();else if("radio"===e.inputType)t=o.find("input:checked").val();else{if(o[0].checkValidity&&!o[0].checkValidity())return!1;t="select"===e.inputType&&!0===e.multiple?o.find("option:selected").map(function(){return n(this).val()}).get():o.val()}return e.callback.call(this,t)},!e.title)throw new Error("prompt requires a title");if(!n.isFunction(e.callback))throw new Error("prompt requires a callback");if(!r.inputs[e.inputType])throw new Error("Invalid prompt type");switch(o=n(r.inputs[e.inputType]),e.inputType){case"text":case"textarea":case"email":case"password":o.val(e.value);e.placeholder&&o.attr("placeholder",e.placeholder);e.pattern&&o.attr("pattern",e.pattern);e.maxlength&&o.attr("maxlength",e.maxlength);e.required&&o.prop({required:!0});e.rows&&!isNaN(parseInt(e.rows))&&"textarea"===e.inputType&&o.attr({rows:e.rows});break;case"date":case"time":case"number":case"range":if(o.val(e.value),e.placeholder&&o.attr("placeholder",e.placeholder),e.pattern&&o.attr("pattern",e.pattern),e.required&&o.prop({required:!0}),"date"!==e.inputType&&e.step){if(!("any"===e.step||!isNaN(e.step)&&0<parseFloat(e.step)))throw new Error('"step" must be a valid positive number or the value "any". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step for more information.');o.attr("step",e.step)}(function(n,i,r){var e=!1,u=!0,f=!0;if("date"===n)i===t||(u=w(i))?r===t||(f=w(r))||console.warn('Browsers which natively support the "date" input type expect date values to be of the form "YYYY-MM-DD" (see ISO-8601 https://www.iso.org/iso-8601-date-and-time-format.html). Bootbox does not enforce this rule, but your max value may not be enforced by this browser.'):console.warn('Browsers which natively support the "date" input type expect date values to be of the form "YYYY-MM-DD" (see ISO-8601 https://www.iso.org/iso-8601-date-and-time-format.html). Bootbox does not enforce this rule, but your min value may not be enforced by this browser.');else if("time"===n){if(i!==t&&!(u=p(i)))throw new Error('"min" is not a valid time. See https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.time for more information.');if(r!==t&&!(f=p(r)))throw new Error('"max" is not a valid time. See https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.time for more information.');}else{if(i!==t&&isNaN(i))throw u=!1,new Error('"min" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min for more information.');if(r!==t&&isNaN(r))throw f=!1,new Error('"max" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max for more information.');}if(u&&f){if(r<=i)throw new Error('"max" must be greater than "min". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max for more information.');e=!0}return e})(e.inputType,e.min,e.max)&&(e.min!==t&&o.attr("min",e.min),e.max!==t&&o.attr("max",e.max));break;case"select":if(a={},s=e.inputOptions||[],!n.isArray(s))throw new Error("Please pass an array of input options");if(!s.length)throw new Error('prompt with "inputType" set to "select" requires at least one option');e.placeholder&&o.attr("placeholder",e.placeholder);e.required&&o.prop({required:!0});e.multiple&&o.prop({multiple:!0});u(s,function(i,u){var e=o,f;if(u.value===t||u.text===t)throw new Error('each option needs a "value" property and a "text" property');u.group&&(a[u.group]||(a[u.group]=n("<optgroup />").attr("label",u.group)),e=a[u.group]);f=n(r.option);f.attr("value",u.value).text(u.text);e.append(f)});u(a,function(n,t){o.append(t)});o.val(e.value);break;case"checkbox":if(k=n.isArray(e.value)?e.value:[e.value],!(s=e.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "checkbox" requires at least one option');o=n('<div class="bootbox-checkbox-list"><\/div>');u(s,function(i,f){if(f.value===t||f.text===t)throw new Error('each option needs a "value" property and a "text" property');var s=n(r.inputs[e.inputType]);s.find("input").attr("value",f.value);s.find("label").append("\n"+f.text);u(k,function(n,t){t===f.value&&s.find("input").prop("checked",!0)});o.append(s)});break;case"radio":if(e.value!==t&&n.isArray(e.value))throw new Error('prompt with "inputType" set to "radio" requires a single, non-array value for "value"');if(!(s=e.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "radio" requires at least one option');o=n('<div class="bootbox-radiobutton-list"><\/div>');v=!0;u(s,function(i,u){if(u.value===t||u.text===t)throw new Error('each option needs a "value" property and a "text" property');var f=n(r.inputs[e.inputType]);f.find("input").attr("value",u.value);f.find("label").append("\n"+u.text);e.value!==t&&u.value===e.value&&(f.find("input").prop("checked",!0),v=!1);o.append(f)});v&&o.find('input[type="radio"]').first().prop("checked",!0)}return(c.append(o),c.on("submit",function(n){n.preventDefault();n.stopPropagation();l.find(".bootbox-accept").trigger("click")}),""!==n.trim(e.message))?(d=n(r.promptMessage).html(e.message),c.prepend(d),e.message=c):e.message=c,(l=i.dialog(e)).off("shown.bs.modal",y),l.on("shown.bs.modal",function(){o.focus()}),!0===b&&l.modal("show"),l},i})