diff --git a/form2/dist/index.js b/form2/dist/index.js index 7f4bb9a..e5b39b8 100644 --- a/form2/dist/index.js +++ b/form2/dist/index.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("form2",[],t):"object"==typeof exports?exports.form2=t():e.form2=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}Object.defineProperty(t,"__esModule",{value:!0}),t.formField=t.form=void 0;var o=n(1),u=r(o),a=n(3),i=r(a);t.form=u,t.formField=i},function(e,t,n){"use strict";function r(e){var t=e.main,n=e.get,r=e.elm,u=e.emit,a=e.update,i=e.msg,c=n("form-field");t(function(e){return[l,f,s]});var l=function(e){var t=e.on;t("form-field:change",d),t("submit",v)},f=function(){"isvalid"in r.dataset&&i.set(function(e){return e.isValid=Boolean(r.dataset.isvalid)})},s=function(e){var t=e.expose;t({validate:d})},d=function(){var e=!0;c("map",function(t){var n=t.isValid;n||(e=!1)}),e!=i.getState().isValid&&(i.set(function(t){return t.isValid=e}),u("form:"+(e?"valid":"invalid"),(0,o.getFormData)(r)))},v=function(e){var t=i.getState(),n=t.isValid;n&&u("form:submit",(0,o.getFormData)(r)),e.preventDefault()};a(function(e){i.set(function(t){return t.data=e.data})})}Object.defineProperty(t,"__esModule",{value:!0}),t.model=void 0,t.default=r;var o=n(2);t.model={isValid:!1,data:{}}},function(e,t){"use strict";function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Object.defineProperty(t,"__esModule",{value:!0});t.getRules=function(e){var t=new Function("return "+e.dataset.rules)(),n=t?t:null,r=e.type&&"checkbox"==e.type,o=r?e.checked?e.value:"":e.form[e.name].value;return{value:o,rules:n}},t.formatError=function(e){var t=Object.keys(e),r=t[0];return n({},r,!0)},t.debounce=function(e,t){var n=void 0;return function(){var r=this,o=arguments;clearTimeout(n),n=setTimeout(function(){return e.apply(r,o)},t)}},t.getFormData=function(e){var t=Array.from(e.elements).reduce(function(e,t){if(t.name){var n=(new Function("return "+t.dataset.rules)(),t.type&&"checkbox"==t.type),r=n?t.checked?t.value:"":t.form[t.name].value;e[t.name]=r}return e},{});return t}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){var t=e.main,n=e.elm,r=e.msg,u=e.injection,a=e.emit,s=e.update,d=e.trigger,v=u.validators;t(function(e){return[p,m]});var p=function(e){var t=e.on;t("input",l,(0,c.debounce)(y,250)),t("blur",l,b),t("change",f,b),t("focus",l+", "+f,g)},m=function(e){var t=e.expose;t({map:x})},y=function(e){var t=e.target,n=t.name,u=t.value;(0,i.default)(o({},n,(0,c.getRules)(e.target)),v).then(function(e){r.set(function(e){e.error=null,e.isValid=Boolean(u),e.value=u})}).catch(function(e){return r.set(function(e){e.isValid=!1,e.value=u})}).finally(h)},b=function(e){var t=e.target,n=t.name,u=t.value,a="checkbox"==e.target.type;(0,i.default)(o({},n,(0,c.getRules)(e.target)),v).then(function(t){r.set(function(t){t.error=null,t.isValid=Boolean(u),t.focus=!1,t.value=a?e.target.checked?u:"":u})}).catch(function(t){r.set(function(r){r.error=(0,c.formatError)(t[n]),r.isValid=!1,r.focus=!1,r.value=a?e.target.checked?u:"":u})}).finally(h)},h=function(){a("form-field:change",{element:n,state:r.getState()})},g=function(e){r.set(function(e){e.focus=!0,e.touched=!0})},x=function(e){e(r.getState())};s(function(e){var t=n.querySelector("input,select,textarea");r.set(function(n){n.data=e.data,n.value=n.touched?n.value:t.dataset.initialValue,n.value&&!n.touched&&(setTimeout(function(e){d("input","[name="+t.name+"]"),d("change","[name="+t.name+"]"),n.value=t.value}),n.touched=!0)})})}Object.defineProperty(t,"__esModule",{value:!0}),t.view=t.model=void 0,t.default=u;var a=n(4),i=r(a),c=n(2),l='input[data-rules]:not([type="checkbox"]):not([type="radio"])',f='input[data-rules][type="checkbox"],input[data-rules][type="radio"],select[data-rules]';t.model={touched:!1,focus:!1,error:null,isValid:!0,value:void 0,data:{}},t.view=function(e){var t=e.touched?"touched":"",n=e.error?"error":"",r=e.focus?"focus":"";return Object.assign({},e,{fieldClass:(t+" "+n+" "+r).trim()})}},function(e,t,n){var r,o,u;(function(e){"use strict";var n="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};!function(a,i){"object"==n(t)&&"object"==n(e)?e.exports=i():(o=[],r=i,u="function"==typeof r?r.apply(t,o):r,!(void 0!==u&&(e.exports=u)))}(void 0,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return new Promise(function(n,r){var o={};return Object.keys(e).forEach(function(n){var r=e[n];Object.keys(r.rules||{}).forEach(function(u){if(!t[u])return console.warn("[Validation] There is no rule => "+u);var a=t[u]({value:r.value,data:r.rules[u],fields:e});a||(o[n]=o[n]||{},o[n][u]={data:r})})}),Object.keys(o).length?r(o):n(e)})}}])})}).call(t,n(5)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("form2",[],t):"object"==typeof exports?exports.form2=t():e.form2=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}Object.defineProperty(t,"__esModule",{value:!0}),t.formField=t.form=void 0;var o=n(1),u=r(o),a=n(3),i=r(a);t.form=u,t.formField=i},function(e,t,n){"use strict";function r(e){var t=e.main,n=e.get,r=e.elm,u=e.emit,a=e.update,i=e.msg,c=n("form-field");t(function(e){return[l,f,s]});var l=function(e){var t=e.on;t("form-field:change",d),t("submit",v)},f=function(){"isvalid"in r.dataset&&i.set(function(e){return e.isValid=Boolean(r.dataset.isvalid)})},s=function(e){var t=e.expose;t({validate:d})},d=function(){var e=!0;c("map",function(t){var n=t.isValid;n||(e=!1)}),e!=i.getState().isValid&&(i.set(function(t){return t.isValid=e}),u("form:"+(e?"valid":"invalid"),(0,o.getFormData)(r)))},v=function(e){var t=i.getState(),n=t.isValid;n&&u("form:submit",(0,o.getFormData)(r)),e.preventDefault()};a(function(e){i.set(function(t){return t.data=e.data})})}Object.defineProperty(t,"__esModule",{value:!0}),t.model=void 0,t.default=r;var o=n(2);t.model={isValid:!1,data:{}}},function(e,t){"use strict";function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Object.defineProperty(t,"__esModule",{value:!0});t.getRules=function(e){var t=new Function("return "+e.dataset.rules)(),n=t?t:null,r=e.type&&"checkbox"==e.type,o=r?e.checked?e.value:"":e.form[e.name].value;return{value:o,rules:n}},t.formatError=function(e){var t=Object.keys(e),r=t[0];return n({},r,!0)},t.debounce=function(e,t){var n=void 0;return function(){var r=this,o=arguments;clearTimeout(n),n=setTimeout(function(){return e.apply(r,o)},t)}},t.getFormData=function(e){var t=Array.from(e.elements).reduce(function(e,t){if(t.name){var n=(new Function("return "+t.dataset.rules)(),t.type&&"checkbox"==t.type),r=t.type&&"file"==t.type;e[t.name]=t.form[t.name].value,n&&(e[t.name]=t.checked?t.value:""),r&&t.value&&(e[t.name]=t.files)}return e},{});return t}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){var t=e.main,n=e.elm,r=e.msg,u=e.injection,a=e.emit,s=e.update,d=e.trigger,v=u.validators;t(function(e){return[p,m]});var p=function(e){var t=e.on;t("input",l,(0,c.debounce)(y,250)),t("blur",l,b),t("change",f,b),t("focus",l+", "+f,g)},m=function(e){var t=e.expose;t({map:x})},y=function(e){var t=e.target,n=t.name,u=t.value;(0,i.default)(o({},n,(0,c.getRules)(e.target)),v).then(function(e){r.set(function(e){e.error=null,e.isValid=Boolean(u),e.value=u})}).catch(function(e){return r.set(function(e){e.isValid=!1,e.value=u})}).finally(h)},b=function(e){var t=e.target,n=t.name,u=t.value,a="checkbox"==e.target.type;(0,i.default)(o({},n,(0,c.getRules)(e.target)),v).then(function(t){r.set(function(t){t.error=null,t.isValid=Boolean(u),t.focus=!1,t.value=a?e.target.checked?u:"":u})}).catch(function(t){r.set(function(r){r.error=(0,c.formatError)(t[n]),r.isValid=!1,r.focus=!1,r.value=a?e.target.checked?u:"":u})}).finally(h)},h=function(){a("form-field:change",{element:n,state:r.getState()})},g=function(e){r.set(function(e){e.focus=!0,e.touched=!0})},x=function(e){e(r.getState())};s(function(e){var t=n.querySelector("input,select,textarea");r.set(function(n){n.data=e.data,n.value=n.touched?n.value:t.dataset.initialValue,n.value&&!n.touched&&(setTimeout(function(e){d("input","[name="+t.name+"]"),d("change","[name="+t.name+"]"),n.value=t.value}),n.touched=!0)})})}Object.defineProperty(t,"__esModule",{value:!0}),t.view=t.model=void 0,t.default=u;var a=n(4),i=r(a),c=n(2),l='input[data-rules]:not([type="checkbox"]):not([type="radio"])',f='input[data-rules][type="checkbox"],input[data-rules][type="radio"],select[data-rules]';t.model={touched:!1,focus:!1,error:null,isValid:!0,value:void 0,data:{}},t.view=function(e){var t=e.touched?"touched":"",n=e.error?"error":"",r=e.focus?"focus":"";return Object.assign({},e,{fieldClass:(t+" "+n+" "+r).trim()})}},function(e,t,n){var r,o,u;(function(e){"use strict";var n="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};!function(a,i){"object"==n(t)&&"object"==n(e)?e.exports=i():(o=[],r=i,u="function"==typeof r?r.apply(t,o):r,!(void 0!==u&&(e.exports=u)))}(void 0,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return new Promise(function(n,r){var o={};return Object.keys(e).forEach(function(n){var r=e[n];Object.keys(r.rules||{}).forEach(function(u){if(!t[u])return console.warn("[Validation] There is no rule => "+u);var a=t[u]({value:r.value,data:r.rules[u],fields:e});a||(o[n]=o[n]||{},o[n][u]={data:r})})}),Object.keys(o).length?r(o):n(e)})}}])})}).call(t,n(5)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}])}); \ No newline at end of file diff --git a/form2/utils.js b/form2/utils.js index 48d4a93..1df9bc7 100644 --- a/form2/utils.js +++ b/form2/utils.js @@ -32,12 +32,22 @@ export const getFormData = (form) => { if (el.name) { const therules = (new Function(`return ${el.dataset.rules}`))() const rules = therules ? therules : null + const isCheckbox = (el.type && (el.type == 'checkbox')) - const value = isCheckbox - ? el.checked ? el.value : '' - : el.form[el.name].value - acc[el.name] = value + const isFile = (el.type && (el.type == 'file')) + + acc[el.name] = el.form[el.name].value + + if (isCheckbox) { + acc[el.name] = el.checked ? el.value : '' + } + + if (isFile && el.value) { + acc[el.name] = el.files + } + } + return acc }, {}) diff --git a/spa/dist/index.js b/spa/dist/index.js index 5caeb6f..ed91906 100644 --- a/spa/dist/index.js +++ b/spa/dist/index.js @@ -1 +1 @@ -!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("spa",[],n):"object"==typeof exports?exports.spa=n():t.spa=n()}(this,function(){return function(t){function n(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function t(t,n){var e=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(e.push(u.value),!n||e.length!==n);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return e}return function(n,e){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return t(n,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=e(1),i=!0,u={};n.default=function(t){var n=t.start,e=t.routes,i=t.transition;e.forEach(function(t){var e=t.name,u=t.module,c=t.template,s=t.path;(0,o.registerApplication)(e,function(){return Promise.all([u(),c()]).then(function(t){var n=r(t,2),e=(n[0],n[1]);return e}).then(a(e,i,n))},s)}),(0,o.start)()};var a=function(t,n,e){return function(r){return{bootstrap:function(){return Promise.resolve()},unmount:function(){return Promise.resolve()},mount:function(){r=r.default?r.default:r;var o=document.querySelector("[data-outlet]");return i?Promise.resolve().then(function(t){return i=!1}).then(function(n){return u[t]=o}).then(function(t){return e()}):t in u?(n?n(o,u[t],function(){return o.parentNode.replaceChild(u[t],o)}):o.parentNode.replaceChild(u[t],o),Promise.resolve()):Promise.resolve().then(function(e){var i=document.createElement("html");i.innerHTML=r;var a=i.querySelector("[data-outlet]");return Promise.resolve().then(function(t){return n?n(o,a,function(){return o.parentNode.replaceChild(a,o)}):o.parentNode.replaceChild(a,o)}).then(function(n){return u[t]=a})})}}}}},function(t,n,e){(function(t){!function(t,e){e(n)}(this,function(n){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function o(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),e.push.apply(e,r)}return e}function i(t){for(var n=1;n1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw Error("bootstrap max time must be a positive integer number of milliseconds");yt.bootstrap={millis:t,dieOnTimeout:n}}function w(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw Error("mount max time must be a positive integer number of milliseconds");yt.mount={millis:t,dieOnTimeout:n}}function y(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw Error("unmount max time must be a positive integer number of milliseconds");yt.unmount={millis:t,dieOnTimeout:n}}function O(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw Error("unload max time must be a positive integer number of milliseconds");yt.unload={millis:t,dieOnTimeout:n}}function j(t,n,e){var r=1e3;return new Promise(function(o,i){function u(t){if(!a)if(!0===t)c=!0,e.dieOnTimeout?i("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds")):console.error("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds -- we're no longer going to warn you about it."));else if(!c){var o=t,s=o*r;console.warn("".concat(n," did not resolve or reject within ").concat(s," milliseconds")),s+r0&&void 0!==arguments[0]?arguments[0]:{};return i({},yt,{},t)}function P(t,n){for(var e=0;e1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==lt?t:(t.status=pt,j(t.bootstrap(I(t)),"Bootstrapping appOrParcel '".concat(t.name,"'"),t.timeouts.bootstrap).then(function(){return t.status=mt,t}).catch(function(e){if(t.status=wt,n)throw s(e,t);return u(e,t),t}))})}function x(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){function e(){return j(t.unmount(I(t)),"Unmounting application ".concat(t.name,"'"),t.timeouts.unmount).then(function(){t.status=mt}).catch(function(e){if(n){var r=s(e,t);throw t.status=wt,r}u(e,t),t.status=wt})}if(t.status!==ht)return t;t.status=bt;var r=Object.keys(t.parcels).map(function(n){return t.parcels[n].unmountThisParcel()});return Promise.all(r).then(e,function(r){return e().then(function(){var e=Error(r.message);if(n){var o=s(e,t);throw t.status=wt,o}u(e,t),t.status=wt})}).then(function(){return t})})}function _(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==mt?t:(Ot||(window.dispatchEvent(new at("single-spa:before-first-mount")),Ot=!0),j(t.mount(I(t)),"Mounting application '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=ht,jt||(window.dispatchEvent(new at("single-spa:first-mount")),jt=!0),t}).catch(function(e){function r(){if(n){var r=s(e,t);throw t.status=wt,r}return u(e,t),t.status=wt,t}return t.status=ht,x(t).then(r,r)}))})}function D(){return C.apply(Pt,arguments)}function C(t,n){var r=this;if(!t||"object"!==e(t)&&"function"!=typeof t)throw Error("Cannot mount parcel without a config object or config loading function");if(t.name&&"string"!=typeof t.name)throw Error("Parcel name must be a string, if provided");if("object"!==e(n))throw Error("Parcel ".concat(name," has invalid customProps -- must be an object"));if(!n.domElement)throw Error("Parcel ".concat(name," cannot be mounted without a domElement provided as a prop"));var o,i=Et++,u="function"==typeof t,a=u?t:function(){return Promise.resolve(t)},c={id:i,parcels:{},status:u?ft:lt,customProps:n,parentName:r.name,unmountThisParcel:function(){if(c.status!==ht)throw Error("Cannot unmount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return x(c,!0).then(function(t){return c.parentName&&delete r.parcels[c.id],t}).then(function(t){return l(t),t}).catch(function(t){throw c.status=wt,p(t),t})}};r.parcels[i]=c;var f=a();if(!f||"function"!=typeof f.then)throw Error("When mounting a parcel, the config loading function must return a promise that resolves with the parcel config");var l,p,m=(f=f.then(function(t){if(!t)throw Error("When mounting a parcel, the config loading function returned a promise that did not resolve with a parcel config");var n=t.name||"parcel-".concat(i);if(!T(t.bootstrap))throw Error("Parcel ".concat(n," must have a valid bootstrap function"));if(!T(t.mount))throw Error("Parcel ".concat(n," must have a valid mount function"));if(!T(t.unmount))throw Error("Parcel ".concat(n," must have a valid unmount function"));if(t.update&&!T(t.update))throw Error("Parcel ".concat(n," provided an invalid update function"));var e=A(t.bootstrap),r=A(t.mount),u=A(t.unmount);c.status=lt,c.name=n,c.bootstrap=e,c.mount=r,c.unmount=u,c.timeouts=E(t.timeouts),t.update&&(c.update=A(t.update),o.update=function(t){return c.customProps=t,U(function(t){return Promise.resolve().then(function(){if(t.status!==ht)throw Error("Cannot update parcel '".concat(t.name,"' because it is not mounted"));return t.status=vt,j(t.update(I(t)),"Updating parcel '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=ht,t}).catch(function(n){var e=s(n,t);throw t.status=wt,e})})}(c))})})).then(function(){return S(c,!0)}),d=m.then(function(){return _(c,!0)}),h=new Promise(function(t,n){l=t,p=n});return o={mount:function(){return U(Promise.resolve().then(function(){if(c.status!==mt)throw Error("Cannot mount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return r.parcels[i]=c,_(c)}))},unmount:function(){return U(c.unmountThisParcel())},getStatus:function(){return c.status},loadPromise:U(f),bootstrapPromise:U(m),mountPromise:U(d),unmountPromise:U(h)}}function U(t){return t.then(function(){return null})}function I(t){var n=i({},t.customProps,{name:t.name,mountParcel:C.bind(t),singleSpa:it});return t.unmountThisParcel&&(n.unmountSelf=t.unmountThisParcel),n}function L(t){return Promise.resolve().then(function(){return t.status!==st?t:(t.status=ft,Promise.resolve().then(function(){var r=t.loadImpl(I(t));if(!N(r))throw Error("single-spa loading function did not return a promise. Check the second argument to registerApplication('".concat(t.name,"', loadingFunction, activityFunction)"));return r.then(function(r){var o;return"object"!==e(n=r)&&(o="does not export anything"),T(n.bootstrap)||(o="does not export a bootstrap function or array of functions"),T(n.mount)||(o="does not export a mount function or array of functions"),T(n.unmount)||(o="does not export an unmount function or array of functions"),o?(console.error("The loading function for single-spa application '".concat(t.name,"' resolved with the following, which does not have bootstrap, mount, and unmount functions"),n),u(o,t),t.status=wt,t):(n.devtools&&n.devtools.overlays&&(t.devtools.overlays=i({},t.devtools.overlays,{},n.devtools.overlays)),t.status=lt,t.bootstrap=A(n.bootstrap,"App '".concat(t.name,"' bootstrap function")),t.mount=A(n.mount,"App '".concat(t.name,"' mount function")),t.unmount=A(n.unmount,"App '".concat(t.name,"' unmount function")),t.unload=A(n.unload||[],"App '".concat(t.name,"' unload function")),t.timeouts=E(n.timeouts),t)})}).catch(function(n){return u(n,t),t.status=wt,t}));var n})}function M(t){var n,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof t)n=t;else if(this&&this.href)n=this.href;else{if(!(t&&t.currentTarget&&t.currentTarget.href&&t.preventDefault))throw Error("singleSpaNavigate must be either called with a string url, with an tag as its context, or with an event whose currentTarget is an tag");n=t.currentTarget.href,t.preventDefault()}var r=R(window.location.href),o=R(n);if(0===n.indexOf("#"))window.location.hash="#"+o.anchor;else if(r.host!==o.host&&o.host){if(e.isTestingEnv)return{wouldHaveReloadedThePage:!0};window.location.href=n}else(function(t,n){return n===t||n==="/"+t})(o.path+"?"+o.query,r.path+"?"+r.query)?window.location.hash="#"+o.anchor:window.history.pushState(null,null,n)}function B(t){var n=this;if(t){var e=t[0].type;At.indexOf(e)>=0&&Tt[e].forEach(function(e){e.apply(n,t)})}}function q(){rt([],arguments)}function G(t){try{return new PopStateEvent("popstate",{state:t})}catch(e){var n=document.createEvent("PopStateEvent");return n.initPopStateEvent("popstate",!1,!1,t),n}}function R(t){for(var n={strictMode:!0,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e=n.parser.strict.exec(t),r={},o=14;o--;)r[n.key[o]]=e[o]||"";return r[n.q.name]={},r[n.key[12]].replace(n.q.parser,function(t,e,o){e&&(r[n.q.name][e]=o)}),r}function k(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!Dt){var n=t.fn.on,e=t.fn.off;t.fn.on=function(t,e){return W.call(this,n,window.addEventListener,t,e,arguments)},t.fn.off=function(t,n){return W.call(this,e,window.removeEventListener,t,n,arguments)},Dt=!0}}function W(t,n,e,r,o){return"string"!=typeof e?t.apply(this,o):(e.split(/\s+/).forEach(function(t){At.indexOf(t)>=0&&(n(t,r),e=e.replace(t,""))}),""===e.trim()?this:t.apply(this,o))}function F(t){return Promise.resolve().then(function(){var n=Ct[t.name];return n?t.status===st?(K(t,n),t):t.status===gt?n.promise.then(function(){return t}):t.status!==mt?t:(t.status=gt,j(t.unload(I(t)),"Unloading application '".concat(t.name,"'"),t.timeouts.unload).then(function(){return K(t,n),t}).catch(function(e){return function(t,n,e){delete Ct[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,u(e,t),t.status=wt,n.reject(e)}(t,n,e),t})):t})}function K(t,n){delete Ct[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=st,n.resolve()}function $(t,n,e,r){Ct[t.name]={app:t,resolve:e,reject:r},Object.defineProperty(Ct[t.name],"promise",{get:n})}function H(){return Ut.filter(f).map(b)}function J(){return Ut.map(b)}function Q(t){var n=P(Ut,function(n){return n.name===t});return n?n.status:null}function V(t,n,e){return console.warn('declareChildApplication is deprecated and will be removed in the next major version, use "registerApplication" instead'),z(t,n,e)}function z(t,n,r){var o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("string"!=typeof t||0===t.length)throw Error("The first argument must be a non-empty string 'appName'");if(-1!==J().indexOf(t))throw Error("There is already an app declared with name ".concat(t));if("object"!==e(i)||Array.isArray(i))throw Error("customProps must be an object");if(!n)throw Error("The application or loading function is required");if(o="function"!=typeof n?function(){return Promise.resolve(n)}:n,"function"!=typeof r)throw Error("The activeWhen argument must be a function");Ut.push({name:t,loadImpl:o,activeWhen:r,status:st,parcels:{},devtools:{overlays:{options:{},selectors:[]}},customProps:i}),k(),rt()}function X(t){for(var n=[],e=0;e1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof t)throw Error("unloadApplication requires a string 'appName'");var e=P(Ut,function(n){return n.name===t});if(!e)throw Error("Could not unload application '".concat(t,"' because no such application has been registered"));var r,o=function(t){return Ct[t]}(e.name);if(n&&n.waitForUnmount){if(o)return o.promise;var i=new Promise(function(t,n){$(e,function(){return i},t,n)});return i}return o?(r=o.promise,nt(e,o.resolve,o.reject)):r=new Promise(function(t,n){$(e,function(){return r},t,n),nt(e,t,n)}),r}function nt(t,n,e){x(t).then(F).then(function(){n(),setTimeout(function(){rt()})}).catch(e)}function et(){return rt()}function rt(){function t(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=H();t&&n(),r.forEach(function(t){return t.resolve(o)});try{var u=i?"single-spa:no-app-change":"single-spa:app-change";window.dispatchEvent(new at(u,e())),window.dispatchEvent(new at("single-spa:routing-event",e()))}catch(t){setTimeout(function(){throw t})}if(It=!1,Lt.length>0){var a=Lt;Lt=[],rt(a)}return o}function n(){r.forEach(function(t){B(t.eventArguments)}),B(o)}function e(){var t={detail:{}};return o&&o[0]&&(t.detail.originalEvent=o[0]),t}var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=arguments.length>1?arguments[1]:void 0;if(It)return new Promise(function(t,n){Lt.push({resolve:t,reject:n,eventArguments:o})});It=!0;var i=!0;return Mt?Promise.resolve().then(function(){window.dispatchEvent(new at("single-spa:before-routing-event",e()));var o=Object.keys(Ct).map(function(t){return Ct[t].app}).filter(l).map(F),u=Ut.filter(v).filter(f).filter(h).map(x).map(function(t){return t.then(F)}),a=u.concat(o);a.length>0&&(i=!1);var c=Promise.all(a),s=Y(),m=s.map(function(t){return L(t).then(S).then(function(t){return c.then(function(){return _(t)})})});m.length>0&&(i=!1);var b=Ut.filter(v).filter(l).filter(p).filter(d).filter(function(t){return s.indexOf(t)<0}).map(function(t){return S(t).then(function(){return c}).then(function(){return _(t)})});return b.length>0&&(i=!1),c.catch(function(t){throw n(),t}).then(function(){return n(),Promise.all(m.concat(b)).catch(function(t){throw r.forEach(function(n){return n.reject(t)}),t}).then(function(){return t(!1)})})}):Promise.resolve().then(function(){var e=Y().map(L);return e.length>0&&(i=!1),Promise.all(e).then(t).catch(function(t){throw n(),t})})}function ot(){Mt=!0,rt()}var it=Object.freeze({get start(){return ot},get ensureJQuerySupport(){return k},get setBootstrapMaxTime(){return g},get setMountMaxTime(){return w},get setUnmountMaxTime(){return y},get setUnloadMaxTime(){return O},get registerApplication(){return z},get getMountedApps(){return H},get getAppStatus(){return Q},get unloadApplication(){return tt},get checkActivityFunctions(){return X},get getAppNames(){return J},get declareChildApplication(){return V},get unloadChildApplication(){return Z},get navigateToUrl(){return M},get triggerAppChange(){return et},get addErrorHandler(){return a},get removeErrorHandler(){return c},get mountRootParcel(){return D},get NOT_LOADED(){return st},get LOADING_SOURCE_CODE(){return ft},get NOT_BOOTSTRAPPED(){return lt},get BOOTSTRAPPING(){return pt},get NOT_MOUNTED(){return mt},get MOUNTING(){return dt},get UPDATING(){return vt},get MOUNTED(){return ht},get UNMOUNTING(){return bt},get SKIP_BECAUSE_BROKEN(){return wt}}),ut=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof t?t:"undefined"!=typeof self?self:{}).CustomEvent,at=function(){try{var t=new ut("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?ut:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,n){var e=document.createEvent("CustomEvent");return n?e.initCustomEvent(t,n.bubbles,n.cancelable,n.detail):e.initCustomEvent(t,!1,!1,void 0),e}:function(t,n){var e=document.createEventObject();return e.type=t,n?(e.bubbles=Boolean(n.bubbles),e.cancelable=Boolean(n.cancelable),e.detail=n.detail):(e.bubbles=!1,e.cancelable=!1,e.detail=void 0),e},ct=[],st="NOT_LOADED",ft="LOADING_SOURCE_CODE",lt="NOT_BOOTSTRAPPED",pt="BOOTSTRAPPING",mt="NOT_MOUNTED",dt="MOUNTING",ht="MOUNTED",vt="UPDATING",bt="UNMOUNTING",gt="UNLOADING",wt="SKIP_BECAUSE_BROKEN",yt={bootstrap:{millis:4e3,dieOnTimeout:!1},mount:{millis:3e3,dieOnTimeout:!1},unmount:{millis:3e3,dieOnTimeout:!1},unload:{millis:3e3,dieOnTimeout:!1}},Ot=!1,jt=!1,Et=0,Pt={parcels:{}},Tt={hashchange:[],popstate:[]},At=["hashchange","popstate"];window.addEventListener("hashchange",q),window.addEventListener("popstate",q);var Nt=window.addEventListener,St=window.removeEventListener;window.addEventListener=function(t,n){return"function"==typeof n&&At.indexOf(t)>=0&&!P(Tt[t],function(t){return t===n})?void Tt[t].push(n):Nt.apply(this,arguments)},window.removeEventListener=function(t,n){return"function"==typeof n&&At.indexOf(t)>=0?void(Tt[t]=Tt[t].filter(function(t){return t!==n})):St.apply(this,arguments)};var xt=window.history.pushState;window.history.pushState=function(t){var n=xt.apply(this,arguments);return q(G(t)),n};var _t=window.history.replaceState;window.history.replaceState=function(t){var n=_t.apply(this,arguments);return q(G(t)),n},window.singleSpaNavigate=M;var Dt=!1,Ct={},Ut=[],It=!1,Lt=[],Mt=!1;setTimeout(function(){Mt||console.warn("singleSpa.start() has not been called, ".concat(5e3,"ms after single-spa was loaded. Before start() is called, apps can be declared and loaded, but not bootstrapped or mounted. See https://github.com/CanopyTax/single-spa/blob/master/docs/single-spa-api.md#start"))},5e3);var Bt={getRawAppData:function(){return[].concat(Ut)},reroute:rt,NOT_LOADED:st,toLoadPromise:L,toBootstrapPromise:S,unregisterApplication:function(t){if(!Ut.find(function(n){return n.name===t}))throw Error("Cannot unregister application '".concat(t,"' because no such application has been registered"));return tt(t).then(function(){var n=Ut.findIndex(function(n){return n.name===t});Ut.splice(n,1)})}};window&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Bt),n.BOOTSTRAPPING=pt,n.LOADING_SOURCE_CODE=ft,n.MOUNTED=ht,n.MOUNTING=dt,n.NOT_BOOTSTRAPPED=lt,n.NOT_LOADED=st,n.NOT_MOUNTED=mt,n.SKIP_BECAUSE_BROKEN=wt,n.UNMOUNTING=bt,n.UPDATING=vt,n.addErrorHandler=a,n.checkActivityFunctions=X,n.declareChildApplication=V,n.ensureJQuerySupport=k,n.getAppNames=J,n.getAppStatus=Q,n.getMountedApps=H,n.mountRootParcel=D,n.navigateToUrl=M,n.registerApplication=z,n.removeErrorHandler=c,n.setBootstrapMaxTime=g,n.setMountMaxTime=w,n.setUnloadMaxTime=O,n.setUnmountMaxTime=y,n.start=ot,n.triggerAppChange=et,n.unloadApplication=tt,n.unloadChildApplication=Z,Object.defineProperty(n,"__esModule",{value:!0})})}).call(n,function(){return this}())}])}); \ No newline at end of file +!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("spa",[],n):"object"==typeof exports?exports.spa=n():t.spa=n()}(this,function(){return function(t){function n(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function t(t,n){var e=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(e.push(u.value),!n||e.length!==n);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return e}return function(n,e){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return t(n,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=e(1),i=!0,u={};n.default=function(t){var n=t.start,e=t.routes,i=t.transition;e.forEach(function(t){var e=t.name,u=t.module,c=t.template,s=t.path;(0,o.registerApplication)(e,function(){return Promise.all([u(),c()]).then(function(t){var n=r(t,2),e=(n[0],n[1]);return e}).then(a(e,i,n))},s)}),(0,o.start)()};var a=function(t,n,e){return function(r){return{bootstrap:function(){return Promise.resolve()},unmount:function(){return Promise.resolve()},mount:function(){r=r.default?r.default:r;var o=document.querySelector("[data-outlet]");return i?Promise.resolve().then(function(t){return i=!1}).then(function(n){return u[t]=o}).then(function(t){return e()}):t in u?(n?n(o,u[t],function(){return o.parentNode.replaceChild(u[t],o)}):o.parentNode.replaceChild(u[t],o),Promise.resolve()):Promise.resolve().then(function(e){var i=document.createElement("html");i.innerHTML=r;var a=i.querySelector("[data-outlet]");return Promise.resolve().then(function(t){return n?n(o,a,function(){return o.parentNode.replaceChild(a,o)}):o.parentNode.replaceChild(a,o)}).then(function(n){return u[t]=a})})}}}}},function(t,n,e){(function(t){!function(t,e){e(n)}(this,function(n){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function o(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),e.push.apply(e,r)}return e}function i(t){for(var n=1;n=200}function E(t){return t.name}function P(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw Error("bootstrap max time must be a positive integer number of milliseconds");St.bootstrap={millis:t,dieOnTimeout:n}}function T(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw Error("mount max time must be a positive integer number of milliseconds");St.mount={millis:t,dieOnTimeout:n}}function A(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw Error("unmount max time must be a positive integer number of milliseconds");St.unmount={millis:t,dieOnTimeout:n}}function S(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw Error("unload max time must be a positive integer number of milliseconds");St.unload={millis:t,dieOnTimeout:n}}function N(t,n,e){var r=1e3;return new Promise(function(o,i){function u(t){if(!a)if(!0===t)c=!0,e.dieOnTimeout?i("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds")):console.error("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds -- we're no longer going to warn you about it."));else if(!c){var o=t,s=o*r;console.warn("".concat(n," did not resolve or reject within ").concat(s," milliseconds")),s+r0&&void 0!==arguments[0]?arguments[0]:{};return i({},St,{},t)}function x(t,n){for(var e=0;e1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==bt?t:(t.status=gt,N(t.bootstrap(G(t)),"Bootstrapping appOrParcel '".concat(t.name,"'"),t.timeouts.bootstrap).then(function(){return t.status=wt,t}).catch(function(e){if(t.status=At,n)throw d(e,t);return l(e,t),t}))})}function L(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){function e(){return N(t.unmount(G(t)),"Unmounting application ".concat(t.name,"'"),t.timeouts.unmount).then(function(){t.status=wt}).catch(function(e){if(n){var r=d(e,t);throw t.status=At,r}l(e,t),t.status=At})}if(t.status!==Ot)return t;t.status=Et;var r=Object.keys(t.parcels).map(function(n){return t.parcels[n].unmountThisParcel()});return Promise.all(r).then(e,function(r){return e().then(function(){var e=Error(r.message);if(n){var o=d(e,t);throw t.status=At,o}l(e,t),t.status=At})}).then(function(){return t})})}function M(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==wt?t:(Nt||(window.dispatchEvent(new mt("single-spa:before-first-mount")),Nt=!0),N(t.mount(G(t)),"Mounting application '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=Ot,_t||(window.dispatchEvent(new mt("single-spa:first-mount")),_t=!0),t}).catch(function(e){function r(){if(n){var r=d(e,t);throw t.status=At,r}return l(e,t),t.status=At,t}return t.status=Ot,L(t).then(r,r)}))})}function I(){return B.apply(Dt,arguments)}function B(t,n){var r=this;if(!t||"object"!==e(t)&&"function"!=typeof t)throw Error("Cannot mount parcel without a config object or config loading function");if(t.name&&"string"!=typeof t.name)throw Error("Parcel name must be a string, if provided");if("object"!==e(n))throw Error("Parcel ".concat(name," has invalid customProps -- must be an object"));if(!n.domElement)throw Error("Parcel ".concat(name," cannot be mounted without a domElement provided as a prop"));var o,i=xt++,u="function"==typeof t,a=u?t:function(){return Promise.resolve(t)},c={id:i,parcels:{},status:u?vt:bt,customProps:n,parentName:r.name,unmountThisParcel:function(){if(c.status!==Ot)throw Error("Cannot unmount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return L(c,!0).then(function(t){return c.parentName&&delete r.parcels[c.id],t}).then(function(t){return f(t),t}).catch(function(t){throw c.status=At,l(t),t})}};r.parcels[i]=c;var s=a();if(!s||"function"!=typeof s.then)throw Error("When mounting a parcel, the config loading function must return a promise that resolves with the parcel config");var f,l,p=(s=s.then(function(t){if(!t)throw Error("When mounting a parcel, the config loading function returned a promise that did not resolve with a parcel config");var n=t.name||"parcel-".concat(i);if(!D(t.bootstrap))throw Error("Parcel ".concat(n," must have a valid bootstrap function"));if(!D(t.mount))throw Error("Parcel ".concat(n," must have a valid mount function"));if(!D(t.unmount))throw Error("Parcel ".concat(n," must have a valid unmount function"));if(t.update&&!D(t.update))throw Error("Parcel ".concat(n," provided an invalid update function"));var e=C(t.bootstrap),r=C(t.mount),u=C(t.unmount);c.status=bt,c.name=n,c.bootstrap=e,c.mount=r,c.unmount=u,c.timeouts=_(t.timeouts),t.update&&(c.update=C(t.update),o.update=function(t){return c.customProps=t,q(function(t){return Promise.resolve().then(function(){if(t.status!==Ot)throw Error("Cannot update parcel '".concat(t.name,"' because it is not mounted"));return t.status=jt,N(t.update(G(t)),"Updating parcel '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=Ot,t}).catch(function(n){var e=d(n,t);throw t.status=At,e})})}(c))})})).then(function(){return R(c,!0)}),m=p.then(function(){return M(c,!0)}),h=new Promise(function(t,n){f=t,l=n});return o={mount:function(){return q(Promise.resolve().then(function(){if(c.status!==wt)throw Error("Cannot mount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return r.parcels[i]=c,M(c)}))},unmount:function(){return q(c.unmountThisParcel())},getStatus:function(){return c.status},loadPromise:q(s),bootstrapPromise:q(p),mountPromise:q(m),unmountPromise:q(h)}}function q(t){return t.then(function(){return null})}function G(t){var n=i({},t.customProps,{name:t.name,mountParcel:B.bind(t),singleSpa:lt});return t.unmountThisParcel&&(n.unmountSelf=t.unmountThisParcel),n}function k(t){return Promise.resolve().then(function(){return t.status!==ht&&t.status!==Tt?t:(t.status=vt,Promise.resolve().then(function(){var r=t.loadImpl(G(t));if(!U(r))throw new Ct("single-spa loading function did not return a promise. Check the second argument to registerApplication('".concat(t.name,"', loadingFunction, activityFunction)"));return r.then(function(r){var o;return t.loadErrorTime=null,"object"!==e(n=r)&&(o="does not export anything"),D(n.bootstrap)||(o="does not export a bootstrap function or array of functions"),D(n.mount)||(o="does not export a mount function or array of functions"),D(n.unmount)||(o="does not export an unmount function or array of functions"),o?(console.error("The loading function for single-spa application '".concat(t.name,"' resolved with the following, which does not have bootstrap, mount, and unmount functions"),n),l(o,t),t.status=At,t):(n.devtools&&n.devtools.overlays&&(t.devtools.overlays=i({},t.devtools.overlays,{},n.devtools.overlays)),t.status=bt,t.bootstrap=C(n.bootstrap,"App '".concat(t.name,"' bootstrap function")),t.mount=C(n.mount,"App '".concat(t.name,"' mount function")),t.unmount=C(n.unmount,"App '".concat(t.name,"' unmount function")),t.unload=C(n.unload||[],"App '".concat(t.name,"' unload function")),t.timeouts=_(n.timeouts),t)})}).catch(function(n){return l(n,t),n instanceof Ct?t.status=At:(t.status=Tt,t.loadErrorTime=(new Date).getTime()),t}));var n})}function W(t){var n,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof t)n=t;else if(this&&this.href)n=this.href;else{if(!(t&&t.currentTarget&&t.currentTarget.href&&t.preventDefault))throw Error("singleSpaNavigate must be either called with a string url, with an tag as its context, or with an event whose currentTarget is an tag");n=t.currentTarget.href,t.preventDefault()}var r=H(window.location.href),o=H(n);if(0===n.indexOf("#"))window.location.hash="#"+o.anchor;else if(r.host!==o.host&&o.host){if(e.isTestingEnv)return{wouldHaveReloadedThePage:!0};window.location.href=n}else(function(t,n){return n===t||n==="/"+t})(o.path+"?"+o.query,r.path+"?"+r.query)?window.location.hash="#"+o.anchor:window.history.pushState(null,null,n)}function F(t){var n=this;if(t){var e=t[0].type;Rt.indexOf(e)>=0&&Ut[e].forEach(function(e){e.apply(n,t)})}}function K(){st([],arguments)}function $(t){try{return new PopStateEvent("popstate",{state:t})}catch(e){var n=document.createEvent("PopStateEvent");return n.initPopStateEvent("popstate",!1,!1,t),n}}function H(t){for(var n={strictMode:!0,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e=n.parser.strict.exec(t),r={},o=14;o--;)r[n.key[o]]=e[o]||"";return r[n.q.name]={},r[n.key[12]].replace(n.q.parser,function(t,e,o){e&&(r[n.q.name][e]=o)}),r}function J(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!qt){var n=t.fn.on,e=t.fn.off;t.fn.on=function(t,e){return Q.call(this,n,window.addEventListener,t,e,arguments)},t.fn.off=function(t,n){return Q.call(this,e,window.removeEventListener,t,n,arguments)},qt=!0}}function Q(t,n,e,r,o){return"string"!=typeof e?t.apply(this,o):(e.split(/\s+/).forEach(function(t){Rt.indexOf(t)>=0&&(n(t,r),e=e.replace(t,""))}),""===e.trim()?this:t.apply(this,o))}function V(t){return Promise.resolve().then(function(){var n=Gt[t.name];return n?t.status===ht?(z(t,n),t):t.status===Pt?n.promise.then(function(){return t}):t.status!==wt?t:(t.status=Pt,N(t.unload(G(t)),"Unloading application '".concat(t.name,"'"),t.timeouts.unload).then(function(){return z(t,n),t}).catch(function(e){return function(t,n,e){delete Gt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,l(e,t),t.status=At,n.reject(e)}(t,n,e),t})):t})}function z(t,n){delete Gt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=ht,n.resolve()}function X(t,n,e,r){Gt[t.name]={app:t,resolve:e,reject:r},Object.defineProperty(Gt[t.name],"promise",{get:n})}function Y(){return kt.filter(h).map(E)}function Z(){return kt.map(E)}function tt(t){var n=x(kt,function(n){return n.name===t});return n?n.status:null}function nt(t,n,e){return console.warn('declareChildApplication is deprecated and will be removed in the next major version, use "registerApplication" instead'),et(t,n,e)}function et(t,n,r){var o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("string"!=typeof t||0===t.length)throw Error("The first argument must be a non-empty string 'appName'");if(-1!==Z().indexOf(t))throw Error("There is already an app declared with name ".concat(t));if("object"!==e(i)||Array.isArray(i))throw Error("customProps must be an object");if(!n)throw Error("The application or loading function is required");if(o="function"!=typeof n?function(){return Promise.resolve(n)}:n,"function"!=typeof r)throw Error("The activeWhen argument must be a function");kt.push({loadErrorTime:null,name:t,loadImpl:o,activeWhen:r,status:ht,parcels:{},devtools:{overlays:{options:{},selectors:[]}},customProps:i}),J(),st()}function rt(t){for(var n=[],e=0;e1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof t)throw Error("unloadApplication requires a string 'appName'");var e=x(kt,function(n){return n.name===t});if(!e)throw Error("Could not unload application '".concat(t,"' because no such application has been registered"));var r,o=function(t){return Gt[t]}(e.name);if(n&&n.waitForUnmount){if(o)return o.promise;var i=new Promise(function(t,n){X(e,function(){return i},t,n)});return i}return o?(r=o.promise,at(e,o.resolve,o.reject)):r=new Promise(function(t,n){X(e,function(){return r},t,n),at(e,t,n)}),r}function at(t,n,e){L(t).then(V).then(function(){n(),setTimeout(function(){st()})}).catch(e)}function ct(){return st()}function st(){function t(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=Y();t&&n(),r.forEach(function(t){return t.resolve(o)});try{var u=i?"single-spa:no-app-change":"single-spa:app-change";window.dispatchEvent(new mt(u,e())),window.dispatchEvent(new mt("single-spa:routing-event",e()))}catch(t){setTimeout(function(){throw t})}if(Wt=!1,Ft.length>0){var a=Ft;Ft=[],st(a)}return o}function n(){r.forEach(function(t){F(t.eventArguments)}),F(o)}function e(){var t={detail:{}};return o&&o[0]&&(t.detail.originalEvent=o[0]),t}var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=arguments.length>1?arguments[1]:void 0;if(Wt)return new Promise(function(t,n){Ft.push({resolve:t,reject:n,eventArguments:o})});Wt=!0;var i=!0;return Kt?Promise.resolve().then(function(){window.dispatchEvent(new mt("single-spa:before-routing-event",e()));var o=Object.keys(Gt).map(function(t){return Gt[t].app}).filter(v).map(V),u=kt.filter(O).filter(h).filter(y).map(L).map(function(t){return t.then(V)}).concat(o);u.length>0&&(i=!1);var a=Promise.all(u),c=ot(),s=c.map(function(t){return k(t).then(R).then(function(t){return a.then(function(){return M(t)})})});s.length>0&&(i=!1);var f=kt.filter(O).filter(v).filter(b).filter(w).filter(function(t){return c.indexOf(t)<0}).map(function(t){return R(t).then(function(){return a}).then(function(){return M(t)})});return f.length>0&&(i=!1),a.catch(function(t){throw n(),t}).then(function(){return n(),Promise.all(s.concat(f)).catch(function(t){throw r.forEach(function(n){return n.reject(t)}),t}).then(function(){return t(!1)})})}):Promise.resolve().then(function(){var e=ot().map(k);return e.length>0&&(i=!1),Promise.all(e).then(t).catch(function(t){throw n(),t})})}function ft(){Kt=!0,st()}var lt=Object.freeze({__proto__:null,get start(){return ft},get ensureJQuerySupport(){return J},get setBootstrapMaxTime(){return P},get setMountMaxTime(){return T},get setUnmountMaxTime(){return A},get setUnloadMaxTime(){return S},get registerApplication(){return et},get getMountedApps(){return Y},get getAppStatus(){return tt},get unloadApplication(){return ut},get checkActivityFunctions(){return rt},get getAppNames(){return Z},get declareChildApplication(){return nt},get unloadChildApplication(){return it},get navigateToUrl(){return W},get triggerAppChange(){return ct},get addErrorHandler(){return p},get removeErrorHandler(){return m},get mountRootParcel(){return I},get NOT_LOADED(){return ht},get LOADING_SOURCE_CODE(){return vt},get NOT_BOOTSTRAPPED(){return bt},get BOOTSTRAPPING(){return gt},get NOT_MOUNTED(){return wt},get MOUNTING(){return yt},get UPDATING(){return jt},get LOAD_ERROR(){return Tt},get MOUNTED(){return Ot},get UNMOUNTING(){return Et},get SKIP_BECAUSE_BROKEN(){return At}}),pt=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof t?t:"undefined"!=typeof self?self:{}).CustomEvent,mt=function(){try{var t=new pt("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?pt:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,n){var e=document.createEvent("CustomEvent");return n?e.initCustomEvent(t,n.bubbles,n.cancelable,n.detail):e.initCustomEvent(t,!1,!1,void 0),e}:function(t,n){var e=document.createEventObject();return e.type=t,n?(e.bubbles=Boolean(n.bubbles),e.cancelable=Boolean(n.cancelable),e.detail=n.detail):(e.bubbles=!1,e.cancelable=!1,e.detail=void 0),e},dt=[],ht="NOT_LOADED",vt="LOADING_SOURCE_CODE",bt="NOT_BOOTSTRAPPED",gt="BOOTSTRAPPING",wt="NOT_MOUNTED",yt="MOUNTING",Ot="MOUNTED",jt="UPDATING",Et="UNMOUNTING",Pt="UNLOADING",Tt="LOAD_ERROR",At="SKIP_BECAUSE_BROKEN",St={bootstrap:{millis:4e3,dieOnTimeout:!1},mount:{millis:3e3,dieOnTimeout:!1},unmount:{millis:3e3,dieOnTimeout:!1},unload:{millis:3e3,dieOnTimeout:!1}},Nt=!1,_t=!1,xt=0,Dt={parcels:{}},Ct=function(t){function n(){return function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),f(this,u(n).apply(this,arguments))}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&a(t,n)}(n,t),n}(s(Error)),Ut={hashchange:[],popstate:[]},Rt=["hashchange","popstate"];window.addEventListener("hashchange",K),window.addEventListener("popstate",K);var Lt=window.addEventListener,Mt=window.removeEventListener;window.addEventListener=function(t,n){return"function"==typeof n&&Rt.indexOf(t)>=0&&!x(Ut[t],function(t){return t===n})?void Ut[t].push(n):Lt.apply(this,arguments)},window.removeEventListener=function(t,n){return"function"==typeof n&&Rt.indexOf(t)>=0?void(Ut[t]=Ut[t].filter(function(t){return t!==n})):Mt.apply(this,arguments)};var It=window.history.pushState;window.history.pushState=function(t){var n=It.apply(this,arguments);return K($(t)),n};var Bt=window.history.replaceState;window.history.replaceState=function(t){var n=Bt.apply(this,arguments);return K($(t)),n},window.singleSpaNavigate=W;var qt=!1,Gt={},kt=[],Wt=!1,Ft=[],Kt=!1;setTimeout(function(){Kt||console.warn("singleSpa.start() has not been called, ".concat(5e3,"ms after single-spa was loaded. Before start() is called, apps can be declared and loaded, but not bootstrapped or mounted. See https://github.com/CanopyTax/single-spa/blob/master/docs/single-spa-api.md#start"))},5e3);var $t={getRawAppData:function(){return[].concat(kt)},reroute:st,NOT_LOADED:ht,toLoadPromise:k,toBootstrapPromise:R,unregisterApplication:function(t){if(!kt.find(function(n){return n.name===t}))throw Error("Cannot unregister application '".concat(t,"' because no such application has been registered"));return ut(t).then(function(){var n=kt.findIndex(function(n){return n.name===t});kt.splice(n,1)})}};window&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=$t),n.BOOTSTRAPPING=gt,n.LOADING_SOURCE_CODE=vt,n.LOAD_ERROR=Tt,n.MOUNTED=Ot,n.MOUNTING=yt,n.NOT_BOOTSTRAPPED=bt,n.NOT_LOADED=ht,n.NOT_MOUNTED=wt,n.SKIP_BECAUSE_BROKEN=At,n.UNMOUNTING=Et,n.UPDATING=jt,n.addErrorHandler=p,n.checkActivityFunctions=rt,n.declareChildApplication=nt,n.ensureJQuerySupport=J,n.getAppNames=Z,n.getAppStatus=tt,n.getMountedApps=Y,n.mountRootParcel=I,n.navigateToUrl=W,n.registerApplication=et,n.removeErrorHandler=m,n.setBootstrapMaxTime=P,n.setMountMaxTime=T,n.setUnloadMaxTime=S,n.setUnmountMaxTime=A,n.start=ft,n.triggerAppChange=ct,n.unloadApplication=ut,n.unloadChildApplication=it,Object.defineProperty(n,"__esModule",{value:!0})})}).call(n,function(){return this}())}])}); \ No newline at end of file