// @link https://www.dataformsjs.com // @version 5.14.6 // @author Conrad Sollitt (https://conradsollitt.com) // @license MIT !function(){"use strict";var h,g={NotSet:"Not Set",Unknown:"Unknown",Mixed:"Mixed",Handlebars:"Handlebars",Vue:"Vue",Nunjucks:"Nunjucks",Underscore:"Underscore",Text:"Text"},c=g.NotSet,p=[g.Handlebars,g.Vue,g.Nunjucks,g.Underscore,g.Text],m=!1,f=!1,v=!1,C=null,E=0,t=null,w=!1,b=0,n=-1!==navigator.userAgent.indexOf("Trident/"),y=null,a=!1;function l(e,t,o,r){if(typeof e!==t)throw console.log(e),new TypeError("["+o+"] was not defined as a "+t+" when the function "+r+" was called")}function s(e,t,o){if(void 0===e)throw new TypeError("["+t+"] must first be defined before the function "+o+" is called");if("object"!=typeof e)throw console.log(e),new TypeError("["+t+"] was not defined as an object when the function "+o+" was called")}function i(e,t,o){if(""===e)throw new TypeError("["+t+"] must have a value when defined when the function "+o+" is called")}function d(e,t,o){if(void 0!==e[o])throw console.log(e),new TypeError("["+t+"."+o+"] is already defined")}function T(e,t,o,r){for(var n=0,a=r.length;n - "),n}catch(e){return console.error(e),n}}function r(e,t,o){e=document.createElement(e);return e.textContent=t,o&&(e.className=o),e}function L(e,t){console.error(e),window.setTimeout(function(){t&&null===t.parentNode&&((document.querySelector("body")||document.documentElement).appendChild(t),h.activeTemplate&&(h.activeTemplate.error=!0,h.activeTemplate.errorMessage=e.toString())),h.showError(t,e)},500)}function R(e,t,o){var r,n,a=null,l=null,i=null,s=null,d=null;if(null===t)i=e.getAttribute("data-template-id"),s=e.getAttribute("data-template-url"),null!==h.activeController&&(d=h.activeController.viewEngine);else{if(i=t.viewId,s=t.viewUrl,void 0!==t.viewEngine&&(d=t.viewEngine),void 0===s&&(s=null),null!==(i=void 0===i?null:i)&&null!==s)return void o(u(null,i,s,d,!0,"A controller must have either [viewId] or [viewUrl] defined but not both properties. This error is not possible when calling the [addController()] so one or more of the properties were modified by JavaScript code after the controller was already added."));if(null===i&&null===s)return"function"==typeof t.onRouteLoad||"function"==typeof t.onBeforeRender||"function"==typeof t.onRendered?void o(null):void o(u(null,i,s,d,!0,"A controller must have either [viewId] or [viewUrl] defined but neither property is defined. This error is not possible when calling the [addController()] so one or more of the properties were modified by JavaScript code after the controller was already added."))}for(r=0,n=h.compiledTemplates.length;r')}}catch(e){s=!(i=l=null),d=e}t={id:t,url:o,type:r,engine:l,html:i,error:n||s,errorMessage:n?a:d};return h.compiledTemplates.push(t),t}function U(t,o,e,r){var n="";try{if(e.error)return void h.showError(t,A(t,o)+e.errorMessage);switch(e.type){case g.Handlebars:case g.Underscore:n=e.engine(r);break;case g.Nunjucks:n=e.engine.render(r);break;case g.Text:case g.Vue:n=e.html;break;default:throw new TypeError("Unsupported or Unknown Template View Engine: "+e.type)}null===t.getAttribute("data-set-text-content")?t.innerHTML=n:t.textContent=n,h.updateTemplatesForIE(t)}catch(e){h.showError(t,A(t,o)+e)}}function V(){var e,s,d,t,o,r,n,u,a,l,p,i="hash"===y?window.location.hash:window.location.pathname,c=null,f=-1;if(200 element or [Controller] defined. Check to make sure that a controller or script for default route ["+h.settings.defaultRoute+"] exists.",h.showError(document.querySelector(h.settings.viewSelector),r)),v=!1}else h.activeController=c,u=function(){var e,t,o,r,n,a=c;if(a.modelName)h.activeModel=h.models[a.modelName];else{if(a.pageType&&void 0!==(o=h.pages[a.pageType]))if(a.viewEngine===g.Vue)if(e={},a.methods=void 0===a.methods?{}:a.methods,"function"==typeof o){e=new o;for(var l=h.getClassFunctionNames(o),i=["constructor","onRouteLoad","onBeforeRender","onRendered","onRouteUnload"],s=0;s tags are allowed."))),l=n.settings.lazyLoad.split(",").map(function(e){return e.trim()}),p=[],l.forEach(function(e){void 0===h.lazyLoad[e]?console.error("Missing [app.LazyLoad] scripts for: "+e):p.push(h.loadScripts(h.lazyLoad[e]))}),Promise.all(p).finally(function(){P(n),u()})):(P(n),u())}function P(e){if(null!==e.pageType&&void 0!==e.pageType&&void 0===e._pageCopied){var t=null;if(void 0===h.pages[e.pageType]?t="The page ["+e.pageType+"] has not been loaded for Controller[path="+e.path+"].":"object"==typeof h.pages[e.pageType]&&"object"!=typeof h.pages[e.pageType].model&&(t="Error - The [model] property for page object ["+e.pageType+"] must be a valid JavaScript Object."),null!==t)return e.settings=e.settings||{},e.settings.errorMessage=t,e.settings.hasError=!0,void h.showErrorAlert(t);var o=h.pages[e.pageType];if("function"==typeof o)for(var r=h.getClassFunctionNames(o),n=["onRouteLoad","onBeforeRender","onRendered","onRouteUnload"],a=0;a/g,">")},fetch:function(t,e,o){var r=h.deepClone({},h.settings.fetchOptions);return r.headers=h.getRequestHeaders(t),e&&(Object.assign(r,e),void 0!==e.headers&&(r.headers=Object.assign({},h.getRequestHeaders(t),e.headers))),!n||void 0!==r.method&&"GET"!==r.method&&"HEAD"!==r.method||"no-store"!==r.cache&&"no-cache"!==r.cache||((e=/([?&])_=[^&]*/).test(t)?t=t.replace(e,"$1_="+(new Date).getTime()):t+=(/\?/.test(t)?"&":"?")+"_="+(new Date).getTime()),fetch(t,r).then(function(e){return h.settings.logFetchRequests&&h.events&&"function"==typeof h.events.dispatch&&h.events.dispatch("fetch",{url:t,status:e.status}),Promise.resolve(e)}).then(function(e){var t=e.status;return 200<=t&&t<300||304===t?Promise.resolve(e):(t="Error loading data. Server Response Code: "+t+", Response Text: "+e.statusText,Promise.reject(t))}).then(function(e){var t=void 0===o?"application/json":o;return 0===(t=e.headers.has("Content-Type")?e.headers.get("Content-Type"):t).indexOf("application/json")?e.json():e.text()})},routingMode:function(){return y},changeRoute:function(e){if("string"!=typeof e)throw new TypeError("Expected string for app.changeRoute(path)");"history"===y?(window.history.pushState(null,null,e),V()):window.location.hash=0===e.indexOf("#")?e:"#"+e},pushStateClick:function(e){if(!0!==e.ctrlKey&&!e.metaKey)return e.preventDefault(),e.stopPropagation(),e.currentTarget.href?h.changeRoute(e.currentTarget.href):console.error("app.pushStateClick() called for an unknown link"),!1},addPage:function(e,t){var o,r=["onRouteLoad","onBeforeRender","onRendered","onRouteUnload"],n=(l(e,"string","name","app.addPage()"),i(e,"name","app.addPage()"),!1);if("object"==typeof t)o=t,n=!0;else{if("function"!=typeof t||"class"!==t.toString().substring(0,5))throw new TypeError("Page ["+e+"] must be defined as an object or a class when the function app.addPage() is called");o=t.prototype}return T(o,e,"page",r),r.pop(),S(o,e,"page",r),n&&s(t.model,"page."+e+".model","app.addPage()"),d(this.pages,"app.pages",e),this.pages[e]=t,this},addPlugin:function(e,t){function o(){"function"==typeof this.onRouteUnload&&this.onRouteUnload(),this.onRendered()}if(l(e,"string","name","app.addPlugin()"),i(e,"name","app.addPlugin()"),d(this.plugins,"app.plugins",e),"function"==typeof(t="function"==typeof t&&"class"===t.toString().substring(0,5)?new t:t))return this.plugins[e]={onRendered:t,reload:o},this;var r=["onRouteLoad","onBeforeRender","onRendered","onRouteUnload"];return l(t,"object","plugin","app.addPlugin()"),T(t,e,"plugin",r),r.pop(),S(t,e,"plugin",r),void 0===t.reload&&(t.reload=o),this.plugins[e]=t,this},addControl:function(e,t){if(l(e,"string","name","app.addControl()"),i(e,"name","app.addControl()"),e!==e.toLowerCase())throw new TypeError("Control names must be all lower-case. [app.addControl()] was called with: ["+e+"]");if(-1===e.indexOf("-"))throw new TypeError("Control names must contain a dash [-] character. [app.addControl()] was called with: ["+e+"]");if(-1!==e.indexOf(" "))throw new TypeError("Control names cannot contain a space. [app.addControl()] was called with: ["+e+"]");if(!1!==/[&<>"'/]/.test(e))throw new TypeError("Control names cannot contain HTML characters that need to be escaped. Invalid characters are [& < > \" ' /]. [app.addControl()] was called with: ["+e+"]");l(t,"object","control","app.addControl()"),void 0!==t.css&&l(t.css,"string","control.css","app.addControl()");var o=["onLoad","html","onUnload"];return S(t,e,"control",o),T(t,e,"control",o),o.pop(),S(t,e,"control",o),d(this.controls,"app.controls",e),this.controls[e]=t,this},addModel:function(e,t){return l(e,"string","name","app.addModel()"),i(e,"name","app.addModel()"),l(t,"object","model","app.addModel()"),d(this.models,"app.models",e),this.models[e]=t,this},addController:function(t){var e,o=["onRouteLoad","onBeforeRender","onRendered","onRouteUnload"];if(l(t,"object","controller","app.addController()"),l(t.path,"string","controller.path","app.addController()"),i(t.path,"controller.path","app.addController()"),this.controllers.forEach(function(e){if(e.path===t.path)throw new TypeError("[app.controllers(path="+t.path+")] is already defined")}),e="app.addController(path="+t.path+")",void 0===t.viewId)t.viewId=null;else{l(t.viewId,"string","controller.viewId",e),i(t.viewId,"controller.viewId",e);var r=t.viewId,n="controller.viewId",a=e;if(null===document.getElementById(r))throw new TypeError("An element was not found on the page with ["+n+"][id="+r+"] when the function "+a+" was called")}if(void 0===t.viewUrl?t.viewUrl=null:(l(t.viewUrl,"string","controller.viewUrl",e),i(t.viewUrl,"controller.viewUrl",e)),null!==t.viewId&&null!==t.viewUrl)throw new TypeError("A controller cannot have both [viewId] and [viewUrl] defined when calling "+e);if(void 0!==t.viewEngine){if(null===t.viewId&&null===t.viewUrl)throw new TypeError("When a controller uses the [viewEngine] property either [viewId] or [viewUrl] must also be defined when calling "+e);if(-1===p.indexOf(t.viewEngine))throw new TypeError("Invalid [viewEngine] property when calling "+e+". Valid values are: "+p.join(", "))}return null!==t.modelName&&void 0!==t.modelName&&(l(t.modelName,"string","controller.modelName",e),i(t.modelName,"controller.modelName",e),s(this.models[t.modelName],"app.models."+t.modelName,e)),null!==t.pageType&&void 0!==t.pageType&&(l(t.pageType,"string","controller.pageType",e),i(t.pageType,"controller.pageType",e)),T(t,t.path,"controller",o),null!==t.pageType&&void 0!==t.pageType||(o.pop(),o.push("viewId"),o.push("viewUrl"),S(t,t.path,"controller",o)),this.controllers.push(t),this},controller:function(e){for(var t=0,o=this.controllers.length;t or