shark-mvc
Version:
Shark-MVC is a small MVC framework born to make our small JS apps easier to build.
8 lines • 87.6 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery"),require("mustache"),require("moment"),require("preact-html-converter"),require("html2hscript"),require("preact")):"function"==typeof define&&define.amd?define("shark-mvc",["jquery","mustache","moment","preact-html-converter","html2hscript","preact"],t):"object"==typeof exports?exports["shark-mvc"]=t(require("jquery"),require("mustache"),require("moment"),require("preact-html-converter"),require("html2hscript"),require("preact")):e.SharkMVC=t(e.$,e.Mustache,e.Moment,e["preact-html-converter"],e.html2hscript,e.preact)}(window,(function(e,t,r,n,o,a){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=41)}([function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=function(e){return e&&"Widget"===e.type}},function(e,t){e.exports=r},function(e,t){e.exports="2"},function(e,t,r){var n=r(4);e.exports=function(e){return e&&"VirtualNode"===e.type&&e.version===n}},function(e,t){e.exports=function(e){return e&&"Thunk"===e.type}},function(e,t){e.exports=function(e){return e&&("function"==typeof e.hook&&!e.hasOwnProperty("hook")||"function"==typeof e.unhook&&!e.hasOwnProperty("unhook"))}},function(e,t,r){var n=r(4);e.exports=function(e){return e&&"VirtualText"===e.type&&e.version===n}},function(e,t){var r=Array.isArray,n=Object.prototype.toString;e.exports=r||function(e){return"[object Array]"===n.call(e)}},function(e,t){e.exports=n},function(e,t){e.exports=o},function(e,t,r){var n=r(24);e.exports=n},function(e,t){e.exports=a},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){var n=r(4);function o(e,t,r){this.type=Number(e),this.vNode=t,this.patch=r}o.NONE=0,o.VTEXT=1,o.VNODE=2,o.WIDGET=3,o.PROPS=4,o.ORDER=5,o.INSERT=6,o.REMOVE=7,o.THUNK=8,e.exports=o,o.prototype.version=n,o.prototype.type="VirtualPatch"},function(e,t,r){var n=r(5),o=r(8),a=r(2),i=r(6);function s(e,t){var r=e.vnode;if(r||(r=e.vnode=e.render(t)),!(n(r)||o(r)||a(r)))throw new Error("thunk did not return a valid node");return r}e.exports=function(e,t){var r=e,n=t;i(t)&&(n=s(t,e));i(e)&&(r=s(e,null));return{a:r,b:n}}},function(e,t,r){"use strict";e.exports=function(e){return"object"==typeof e&&null!==e}},function(e,t,r){(function(t){var n,o=void 0!==t?t:"undefined"!=typeof window?window:{},a=r(37);"undefined"!=typeof document?n=document:(n=o["__GLOBAL_DOCUMENT_CACHE@4"])||(n=o["__GLOBAL_DOCUMENT_CACHE@4"]=a),e.exports=n}).call(this,r(14))},function(e,t,r){var n=r(18),o=r(20),a=r(5),i=r(8),s=r(2),l=r(16);e.exports=function e(t,r){var c=r&&r.document||n,d=r?r.warn:null;if(t=l(t).a,s(t))return t.init();if(i(t))return c.createTextNode(t.text);if(!a(t))return d&&d("Item is not a valid virtual dom node",t),null;var p=null===t.namespace?c.createElement(t.tagName):c.createElementNS(t.namespace,t.tagName),u=t.properties;o(p,u);for(var h=t.children,_=0;_<h.length;_++){var f=e(h[_],r);f&&p.appendChild(f)}return p}},function(e,t,r){var n=r(17),o=r(7);function a(e,t,r,n){if(n){var a=n[t];if(o(a))a.unhook&&a.unhook(e,t,r);else if("attributes"===t)for(var i in a)e.removeAttribute(i);else if("style"===t)for(var s in a)e.style[s]="";else e[t]="string"==typeof a?"":null}}function i(e,t,r,o,a){var i=r?r[o]:void 0;if("attributes"!==o)if(i&&n(i)&&s(i)!==s(a))e[o]=a;else{n(e[o])||(e[o]={});var l="style"===o?"":void 0;for(var c in a){var d=a[c];e[o][c]=void 0===d?l:d}}else for(var p in a){var u=a[p];void 0===u?e.removeAttribute(p):e.setAttribute(p,u)}}function s(e){return Object.getPrototypeOf?Object.getPrototypeOf(e):e.__proto__?e.__proto__:e.constructor?e.constructor.prototype:void 0}e.exports=function(e,t,r){for(var s in t){var l=t[s];void 0===l?a(e,s,l,r):o(l)?(a(e,s,l,r),l.hook&&l.hook(e,s,r?r[s]:void 0)):n(l)?i(e,t,r,s,l):e[s]=l}}},function(e,t,r){var n=r(34);e.exports=n},function(e,t,r){var n=r(36);e.exports=n},function(e,t,r){var n=r(19);e.exports=n},function(e,t,r){"use strict";var n=r(9),o=r(25),a=r(26),i=r(5),s=r(8),l=r(2),c=r(7),d=r(6),p=r(27),u=r(29),h=r(30);function _(e){return i(e)||s(e)||l(e)||d(e)}function f(e){try{return JSON.stringify(e,null," ")}catch(t){return String(e)}}e.exports=function(e,t,r){var i,s,l,d,m=[];!r&&(g=t,"string"==typeof g||n(g)||_(g))&&(r=t,s={});var g;i=p(e,s=s||t||{}),s.hasOwnProperty("key")&&(l=s.key,s.key=void 0);s.hasOwnProperty("namespace")&&(d=s.namespace,s.namespace=void 0);"INPUT"!==i||d||!s.hasOwnProperty("value")||void 0===s.value||c(s.value)||(s.value=u(s.value));(function(e){for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];if(c(r))continue;"ev-"===t.substr(0,3)&&(e[t]=h(r))}})(s),null!=r&&function e(t,r,o,i){if("string"==typeof t)r.push(new a(t));else if("number"==typeof t)r.push(new a(String(t)));else if(_(t))r.push(t);else{if(!n(t)){if(null==t)return;throw l={foreignObject:t,parentVnode:{tagName:o,properties:i}},(c=new Error).type="virtual-hyperscript.unexpected.virtual-element",c.message="Unexpected virtual child passed to h().\nExpected a VNode / Vthunk / VWidget / string but:\ngot:\n"+f(l.foreignObject)+".\nThe parent vnode is:\n"+f(l.parentVnode),c.foreignObject=l.foreignObject,c.parentVnode=l.parentVnode,c}for(var s=0;s<t.length;s++)e(t[s],r,o,i)}var l,c}(r,m,i,s);return new o(i,s,m,l,d)}},function(e,t,r){var n=r(4),o=r(5),a=r(2),i=r(6),s=r(7);e.exports=d;var l={},c=[];function d(e,t,r,n,d){this.tagName=e,this.properties=t||l,this.children=r||c,this.key=null!=n?String(n):void 0,this.namespace="string"==typeof d?d:null;var p,u=r&&r.length||0,h=0,_=!1,f=!1,m=!1;for(var g in t)if(t.hasOwnProperty(g)){var y=t[g];s(y)&&y.unhook&&(p||(p={}),p[g]=y)}for(var v=0;v<u;v++){var w=r[v];o(w)?(h+=w.count||0,!_&&w.hasWidgets&&(_=!0),!f&&w.hasThunks&&(f=!0),m||!w.hooks&&!w.descendantHooks||(m=!0)):!_&&a(w)?"function"==typeof w.destroy&&(_=!0):!f&&i(w)&&(f=!0)}this.count=u+h,this.hasWidgets=_,this.hasThunks=f,this.hooks=p,this.descendantHooks=m}d.prototype.version=n,d.prototype.type="VirtualNode"},function(e,t,r){var n=r(4);function o(e){this.text=String(e)}e.exports=o,o.prototype.version=n,o.prototype.type="VirtualText"},function(e,t,r){"use strict";var n=r(28),o=/([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/,a=/^\.|#/;e.exports=function(e,t){if(!e)return"DIV";var r,i,s,l,c=!t.hasOwnProperty("id"),d=n(e,o),p=null;a.test(d[1])&&(p="DIV");for(l=0;l<d.length;l++)(i=d[l])&&(s=i.charAt(0),p?"."===s?(r=r||[]).push(i.substring(1,i.length)):"#"===s&&c&&(t.id=i.substring(1,i.length)):p=i);r&&(t.className&&r.push(t.className),t.className=r.join(" "));return t.namespace?p:p.toUpperCase()}},function(e,t){var r,n,o;
/*!
* Cross-Browser Split 1.1.1
* Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
* Available under the MIT License
* ECMAScript compliant, uniform cross-browser split method
*/
e.exports=(n=String.prototype.split,o=/()??/.exec("")[1]===r,function(e,t,a){if("[object RegExp]"!==Object.prototype.toString.call(t))return n.call(e,t,a);var i,s,l,c,d=[],p=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.extended?"x":"")+(t.sticky?"y":""),u=0;for(t=new RegExp(t.source,p+"g"),e+="",o||(i=new RegExp("^"+t.source+"$(?!\\s)",p)),a=a===r?-1>>>0:a>>>0;(s=t.exec(e))&&!((l=s.index+s[0].length)>u&&(d.push(e.slice(u,s.index)),!o&&s.length>1&&s[0].replace(i,(function(){for(var e=1;e<arguments.length-2;e++)arguments[e]===r&&(s[e]=r)})),s.length>1&&s.index<e.length&&Array.prototype.push.apply(d,s.slice(1)),c=s[0].length,u=l,d.length>=a));)t.lastIndex===s.index&&t.lastIndex++;return u===e.length?!c&&t.test("")||d.push(""):d.push(e.slice(u)),d.length>a?d.slice(0,a):d})},function(e,t,r){"use strict";function n(e){if(!(this instanceof n))return new n(e);this.value=e}e.exports=n,n.prototype.hook=function(e,t){e[t]!==this.value&&(e[t]=this.value)}},function(e,t,r){"use strict";var n=r(31);function o(e){if(!(this instanceof o))return new o(e);this.value=e}e.exports=o,o.prototype.hook=function(e,t){n(e)[t.substr(3)]=this.value},o.prototype.unhook=function(e,t){n(e)[t.substr(3)]=void 0}},function(e,t,r){"use strict";r(32)("ev-store","7");e.exports=function(e){var t=e["__EV_STORE_KEY@7"];t||(t=e["__EV_STORE_KEY@7"]={});return t}},function(e,t,r){"use strict";var n=r(33);e.exports=function(e,t,r){var o="__INDIVIDUAL_ONE_VERSION_"+e,a=n(o+"_ENFORCE_SINGLETON",t);if(a!==t)throw new Error("Can only have one copy of "+e+".\nYou already have version "+a+" installed.\nThis means you cannot install version "+t);return n(o,r)}},function(e,t,r){"use strict";(function(t){var r="undefined"!=typeof window?window:void 0!==t?t:{};e.exports=function(e,t){if(e in r)return r[e];return r[e]=t,t}}).call(this,r(14))},function(e,t,r){var n=r(9),o=r(15),a=r(5),i=r(8),s=r(2),l=r(6),c=r(16),d=r(35);function p(e,t){var r={a:e};return u(e,t,r,0),r}function u(e,t,r,n){if(e!==t){var c=r[n],p=!1;if(l(e)||l(t))_(e,t,r,n);else if(null==t)s(e)||(h(e,r,n),c=r[n]),c=g(c,new o(o.REMOVE,e,t));else if(a(t))if(a(e))if(e.tagName===t.tagName&&e.namespace===t.namespace&&e.key===t.key){var y=d(e.properties,t.properties);y&&(c=g(c,new o(o.PROPS,e,y))),c=function(e,t,r,n,i){for(var s=e.children,l=function(e,t){var r=m(t),n=r.keys,o=r.free;if(o.length===t.length)return{children:t,moves:null};var a=m(e),i=a.keys;if(a.free.length===e.length)return{children:t,moves:null};for(var s=[],l=0,c=o.length,d=0,p=0;p<e.length;p++){var u,h=e[p];h.key?n.hasOwnProperty(h.key)?(u=n[h.key],s.push(t[u])):(u=p-d++,s.push(null)):l<c?(u=o[l++],s.push(t[u])):(u=p-d++,s.push(null))}for(var _=l>=o.length?t.length:o[l],g=0;g<t.length;g++){var y=t[g];y.key?i.hasOwnProperty(y.key)||s.push(y):g>=_&&s.push(y)}for(var v,w=s.slice(),b=0,O=[],x=[],R=0;R<t.length;){var P=t[R];for(v=w[b];null===v&&w.length;)O.push(f(w,b,null)),v=w[b];v&&v.key===P.key?(b++,R++):P.key?(v&&v.key&&n[v.key]!==R+1?(O.push(f(w,b,v.key)),(v=w[b])&&v.key===P.key?b++:x.push({key:P.key,to:R})):x.push({key:P.key,to:R}),R++):v&&v.key&&O.push(f(w,b,v.key))}for(;b<w.length;)v=w[b],O.push(f(w,b,v&&v.key));if(O.length===d&&!x.length)return{children:s,moves:null};return{children:s,moves:{removes:O,inserts:x}}}(s,t.children),c=l.children,d=s.length,p=c.length,h=d>p?d:p,_=0;_<h;_++){var y=s[_],v=c[_];i+=1,y?u(y,v,r,i):v&&(n=g(n,new o(o.INSERT,null,v))),a(y)&&y.count&&(i+=y.count)}l.moves&&(n=g(n,new o(o.ORDER,e,l.moves)));return n}(e,t,r,c,n)}else c=g(c,new o(o.VNODE,e,t)),p=!0;else c=g(c,new o(o.VNODE,e,t)),p=!0;else i(t)?i(e)?e.text!==t.text&&(c=g(c,new o(o.VTEXT,e,t))):(c=g(c,new o(o.VTEXT,e,t)),p=!0):s(t)&&(s(e)||(p=!0),c=g(c,new o(o.WIDGET,e,t)));c&&(r[n]=c),p&&h(e,r,n)}}function h(e,t,r){!function e(t,r,n){if(a(t)){if(t.hooks&&(r[n]=g(r[n],new o(o.PROPS,t,function(e){var t={};for(var r in e)t[r]=void 0;return t}(t.hooks)))),t.descendantHooks||t.hasThunks)for(var i=t.children,s=i.length,c=0;c<s;c++){var d=i[c];e(d,r,n+=1),a(d)&&d.count&&(n+=d.count)}}else l(t)&&_(t,null,r,n)}(e,t,r),function e(t,r,n){if(s(t))"function"==typeof t.destroy&&(r[n]=g(r[n],new o(o.REMOVE,t,null)));else if(a(t)&&(t.hasWidgets||t.hasThunks))for(var i=t.children,c=i.length,d=0;d<c;d++){var p=i[d];e(p,r,n+=1),a(p)&&p.count&&(n+=p.count)}else l(t)&&_(t,null,r,n)}(e,t,r)}function _(e,t,r,n){var a=c(e,t),i=p(a.a,a.b);(function(e){for(var t in e)if("a"!==t)return!0;return!1})(i)&&(r[n]=new o(o.THUNK,null,i))}function f(e,t,r){return e.splice(t,1),{from:t,key:r}}function m(e){for(var t={},r=[],n=e.length,o=0;o<n;o++){var a=e[o];a.key?t[a.key]=o:r.push(o)}return{keys:t,free:r}}function g(e,t){return e?(n(e)?e.push(t):e=[e,t],e):t}e.exports=p},function(e,t,r){var n=r(17),o=r(7);function a(e){return Object.getPrototypeOf?Object.getPrototypeOf(e):e.__proto__?e.__proto__:e.constructor?e.constructor.prototype:void 0}e.exports=function e(t,r){var i;for(var s in t){s in r||((i=i||{})[s]=void 0);var l=t[s],c=r[s];if(l!==c)if(n(l)&&n(c))if(a(c)!==a(l))(i=i||{})[s]=c;else if(o(c))(i=i||{})[s]=c;else{var d=e(l,c);d&&((i=i||{})[s]=d)}else(i=i||{})[s]=c}for(var p in r)p in t||((i=i||{})[p]=r[p]);return i}},function(e,t,r){var n=r(18),o=r(9),a=r(19),i=r(38),s=r(39);function l(e,t,r){var o=function(e){var t=[];for(var r in e)"a"!==r&&t.push(Number(r));return t}(t);if(0===o.length)return e;var a=i(e,t.a,o),s=e.ownerDocument;r.document||s===n||(r.document=s);for(var l=0;l<o.length;l++){var d=o[l];e=c(e,a[d],t[d],r)}return e}function c(e,t,r,n){if(!t)return e;var a;if(o(r))for(var i=0;i<r.length;i++)a=s(r[i],t,n),t===e&&(e=a);else a=s(r,t,n),t===e&&(e=a);return e}e.exports=function e(t,r,n){return(n=n||{}).patch=n.patch&&n.patch!==e?n.patch:l,n.render=n.render||a,n.patch(t,r,n)}},function(e,t){},function(e,t){var r={};function n(e,t,r){if(0===e.length)return!1;for(var n,o,a=0,i=e.length-1;a<=i;){if(o=e[n=(i+a)/2>>0],a===i)return o>=t&&o<=r;if(o<t)a=n+1;else{if(!(o>r))return!0;i=n-1}}return!1}function o(e,t){return e>t?1:-1}e.exports=function(e,t,a,i){return a&&0!==a.length?(a.sort(o),function e(t,o,a,i,s){if(i=i||{},t){n(a,s,s)&&(i[s]=t);var l=o.children;if(l)for(var c=t.childNodes,d=0;d<o.children.length;d++){s+=1;var p=l[d]||r,u=s+(p.count||0);n(a,s,u)&&e(c[d],p,a,i,s),s=u}}return i}(e,t,a,i,0)):{}}},function(e,t,r){var n=r(20),o=r(2),a=r(15),i=r(40);function s(e,t){"function"==typeof t.destroy&&o(t)&&t.destroy(e)}e.exports=function(e,t,r){var o=e.type,l=e.vNode,c=e.patch;switch(o){case a.REMOVE:return function(e,t){var r=e.parentNode;r&&r.removeChild(e);return s(e,t),null}(t,l);case a.INSERT:return function(e,t,r){var n=r.render(t,r);e&&e.appendChild(n);return e}(t,c,r);case a.VTEXT:return function(e,t,r,n){var o;if(3===e.nodeType)e.replaceData(0,e.length,r.text),o=e;else{var a=e.parentNode;o=n.render(r,n),a&&o!==e&&a.replaceChild(o,e)}return o}(t,0,c,r);case a.WIDGET:return function(e,t,r,n){var o,a=i(t,r);o=a?r.update(t,e)||e:n.render(r,n);var l=e.parentNode;l&&o!==e&&l.replaceChild(o,e);a||s(e,t);return o}(t,l,c,r);case a.VNODE:return function(e,t,r,n){var o=e.parentNode,a=n.render(r,n);o&&a!==e&&o.replaceChild(a,e);return a}(t,0,c,r);case a.ORDER:return function(e,t){for(var r,n,o,a=e.childNodes,i={},s=0;s<t.removes.length;s++)n=t.removes[s],r=a[n.from],n.key&&(i[n.key]=r),e.removeChild(r);for(var l=a.length,c=0;c<t.inserts.length;c++)o=t.inserts[c],r=i[o.key],e.insertBefore(r,o.to>=l++?null:a[o.to])}(t,c),t;case a.PROPS:return n(t,c,l.properties),t;case a.THUNK:return function(e,t){e&&t&&e!==t&&e.parentNode&&e.parentNode.replaceChild(t,e);return t}(t,r.patch(t,c,r));default:return t}}},function(e,t,r){var n=r(2);e.exports=function(e,t){if(n(e)&&n(t))return"name"in e&&"name"in t?e.id===t.id:e.init===t.init;return!1}},function(e,t,r){"use strict";r.r(t),r.d(t,"Component",(function(){return I})),r.d(t,"Controller",(function(){return H})),r.d(t,"Jaw",(function(){return c})),r.d(t,"ModelRenderer",(function(){return u})),r.d(t,"PreactRenderer",(function(){return F})),r.d(t,"RenderableJaw",(function(){return V})),r.d(t,"Shark",(function(){return D})),r.d(t,"SmartModel",(function(){return h})),r.d(t,"Utils",(function(){return s})),r.d(t,"View",(function(){return U})),r.d(t,"VirtualDOMRenderer",(function(){return E}));var n=r(1),o=r.n(n),a=r(0),i=r.n(a);class s{constructor(){this.__id="Utils"}static betterRandom(e,t){var r=parseFloat(e),n=Math.random();return!(t=parseFloat(t))&&e&&(r=0,t=parseFloat(e)),r||(r=0),t||(t=1),n*=t-r,n+=r}static betterRandomInt(e,t){return Math.round(s.betterRandom(e,t))}static camelToDashed(e){let t="";return e.split("").forEach((e,r)=>{e.toLowerCase()!==e&&(r>0&&(t+="-"),e=e.toLowerCase()),t+=e}),t}static computeHash(e){return(s.safeStringify(e)||"").split("").reduce((function(e,t){return(e=(e<<5)-e+t.charCodeAt(0))&e}),0)}static dashedToCamel(e){let t=e,r=0;for(;r>-1;)r=t.indexOf("-"),r>-1&&(t=t.substr(0,r)+t.substr(r+1,1).toUpperCase()+t.substr(r+2));return t}static extractDifferentProperties(e,t){var r={};for(var n in e)e[n]&&t[n]&&e[n]!==t[n]&&(r[n]=t[n]);return r}static flatten(e){var t={};for(var r in e)"function"!=typeof e[r]&&("object"==typeof e[r]?t[r]=s.flatten(e[r]):t[r]=e[r]);return t}static generateGUID(e="",t=""){return e+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})).toUpperCase()+t}static getDeepProperty(e,t){if(e){for(var r=t.split("."),n=e,o=0;o<r.length-1;o++){var a=-1;if((i=r[o].indexOf("["))>-1&&(a=parseInt(r[o].substring(i+1,r[o].indexOf("]"))),r[o]=r[o].substr(0,i)),-1===a){if(!n[r[o]])break;n=n[r[o]]}else{if(!n[r[o]][a])break;n=n[r[o]][a]}}var i;a=-1;return(i=r[o].indexOf("["))>-1&&(a=parseInt(r[o].substring(i+1,r[o].indexOf("]"))),r[o]=r[o].substr(0,i)),-1===a?n[r[o]]:n[r[o]][a]}}static matchLists(e=[],t={},r={}){e.forEach(e=>{for(const r in e)if("Guid"===r.substr(-2)){const n=r.substr(0,r.length-2),o=t[n];o&&(e["__"+n]=s.safp(o,"guid",e[r]))}})}static matchProperties(e,t,r){var n={createMissingProperties:!1,exclude:[],matchEmptyParameters:!0,matchUndefinedParameters:!1};for(var o in i.a.extend(!0,n,r),Array.isArray(n.exclude)||(n.exclude=[]),t)0!==n.exclude.length&&-1!==n.exclude.indexOf(o)||void 0===e[o]&&!n.createMissingProperties||!(t[o]&&""!==t[o]||n.matchEmptyParameters)||void 0===t[o]&&!n.matchUndefinedParameters||(Array.isArray(t[o])?e[o]=t[o].map((function(e){return e})):"object"!=typeof t[o]&&"object"!=typeof e[o]||null===t[o]||null===e[o]?e[o]=t[o]:e[o]&&"Object"===e[o].constructor.name&&"Object"===t[o].constructor.name&&Object.keys(e[o]).length>0?s.matchProperties(e[o],t[o],r):e[o]&&"Object"===e[o].constructor.name&&"string"==typeof t[o]?e[o]=i.a.extend(!0,e[o],s.parseJSON(t[o],"object")):e[o]&&"Array"===e[o].constructor.name&&"string"==typeof t[o]?e[o]=s.parseJSON(t[o],"array"):e[o]=i.a.extend(!0,{},t[o]))}static moveCaretToEnd(e){setTimeout((function(){if("number"==typeof e.selectionStart)e.selectionStart=e.selectionEnd=e.value.length;else if(void 0!==e.createTextRange){e.focus();var t=e.createTextRange();t.collapse(!1),t.select()}}),10)}static parseJSON(e,t){if("string"==typeof e&&"array"===e.toLowerCase())return[];if(""===e||'""'===e)switch(t){case"array":return[];default:return{}}else if("string"==typeof e){let r;try{r=JSON.parse(e)}catch(n){console.error("Utisl.parseJSON",{error:n,data:e,expectedType:t}),r=null}if(null===r||""===r)switch(t){case"array":return[];case"object":return{};default:return r}else switch(t){case"array":return"function"==typeof r.splice?r:[];default:return r}}else{if(void 0!==e)return e;switch(t){case"array":return[];default:return{}}}}static replaceNullValue(e,t){if(e.push)for(var r=0;r<e.length;r++)s.replaceNullValue(e[r],t);else for(var n in e)void 0!==e[n]&&null!==e[n]||(e[n]=t)}static safeStringify(e){return JSON.stringify(e,(e,t)=>(t instanceof Map&&(t=Array.from(t)),"__shguid"!==e&&"__"===e.substr(0,2)?"":t))}static safp(e,t,r,n){return s.searchArrayForProperty(e,t,r,n)}static searchArrayForProperty(e,t,r,n){if(e){switch(typeof n){case"undefined":n="first";break;case"boolean":n=n?"first":"all"}for(var o,a=[],i=(o=t.indexOf(".")>-1?t.split("."):[t]).length,s=e.length,l=0;l<s;l++){var c=e[l][o[0]];if(c)for(var d=1;d<i&&c[o[d]];d++)c=c[o[d]];if(c===r)switch(n){case"all":a.push(e[l]);break;case"first":return e[l];case"index":return l}}return a.length>0?a:null}console.error("Error, cant search on a null list.")}static setDeepProperty(e,t,r,n){var o=t.split(".");return e[o[n=n||0]]||(e[o[n]]={}),n<o.length-1?s.setDeepProperty(e[o[n]],t,r,n+1):e[o[n]]=r,e}static trace(e){try{AppData.consoleDebugActive&&console.debug(e)}catch(t){alert(e)}}static toCamelCase(e){return e.substr(0,1).toLowerCase()+e.substr(1)}static toTitleCase(e,t=!0){return e.substr(0,1).toUpperCase()+(t?e.substr(1).toLowerCase():e.substr(1))}static vibrate(e){e||(e=200);try{navigator.notification.vibrate(e)}catch(e){}}static zeroFill(e,t){var r=e.toString(),n=r.length;return n<t&&(r=(r="0000000000000000000000000000000000000000"+r).substr(40+n-t)),r}}class l{constructor(e,t){if(null!=e&&""!==e||(e=this.constructor.name.substr(0,1).toLowerCase()+this.constructor.name.substr(1)),"string"!=typeof e)throw new Error("Jaw id must be passed");Object.defineProperty(this,"className",{configurable:!1,enumerable:!0,value:e,writable:!1}),Object.defineProperty(this,"id",{configurable:!1,enumerable:!0,value:e,writable:!1}),this.isInitialized=!1,this.currentOpenOptions={},this.route=null,this.store={},this.__store={getLabel:function(){return function(e,t){return e.indexOf("{{")>-1&&(e=t(e)),t(D.labels.labels[e])}}},this.__activeComponents=[],this.__autoBoundProperties=[],this.__childTemplates={},this.__dynamicDataBindings={},this.__listeners={},this.__methods={},this.__viewBinds={},this.__viewBinds2={};for(const e in t)this.addMethod(e,t[e])}addComponent(e){return void 0===e?(console.error("Jaw.addComponent: You can't pass this type of data (must be a component)"),this.__activeComponents):("string"==typeof e&&(e=D.__components[e]),this.__activeComponents.push(e),this.__activeComponents)}addComponents(e){return Array.isArray(e)?e.forEach(e=>{this.addComponent(e)},this):console.error("Jaw.addComponents: You can't pass this type of data (must be an array)"),this.__activeComponents}init(){this.trace("The init method for "+this.className+" has not been implemented.","info")}_extractComponentsValidMethodList(e,t,r){const n=[];return e.forEach(e=>{-1===t.indexOf(e.id)?(n.push(...this._extractValidMethodList(e)),t.push(e.id)):r.push("= NO "+e.id),e.__activeComponents.length>0&&n.push(...this._extractComponentsValidMethodList(e.__activeComponents,t,r))}),n}_extractValidMethodList(e){const t=[];for(var r in e)"function"==typeof e[r]&&r.indexOf("Handler")>-1&&t.push({handlerName:r,handlerHolder:e});if(e.__proto__ instanceof l){const r=e.__proto__;Object.getOwnPropertyNames(e.__proto__).forEach(n=>{"function"==typeof r[n]&&"constructor"!==n&&n.indexOf("Handler")>-1&&t.push({handlerName:n,handlerHolder:e})}),t.push(...this._extractValidMethodList(e.__proto__))}return t}_initComponents(e=null,t=[]){null===e&&(e=this.__activeComponents),e.forEach((function(e){-1===t.indexOf(e.id)&&("function"==typeof e.jawInit&&e.jawInit.call(e,{jaw:currJaw}),"function"!=typeof e.init||e.isInitialized||(e.init.call(e),e.isInitialized=!0),t.push(e.id),e.__activeComponents.length>0&&this._initComponents(e.__activeComponents,t))}),this)}__singleSet(e,t){this.__store[e]=t;const r=this;Object.defineProperty(this.store,e,{configurable:!0,enumerable:!0,get:()=>r.__store[e],set(t){const n=r.__store[e];r.__store[e]=t,D.settings.enableJawStoreAutoRender&&s.computeHash(t)!==s.computeHash(n)&&D.render()}})}}l.prototype.addMethod=function(e,t,r){var n={context:this,smartUnlisten:!0};i.a.extend(!0,n,r),this[e]=t.bind(n.context),this.__methods[e]=this.__methods[e]||{},this.__methods[e].name=e,this.__methods[e].settings=n},l.prototype.emit=function(e,t){return i()(this).trigger(e,t)},l.prototype.get=function(e){return arguments.length>1&&console.warn("WARNING!! The jaw.get() method has deprecated the 'forcedType' parameter, and now works only on jaw-local data"),this.__store[e]},l.prototype.on=function(e,t){return i()(this).on(e,t)},l.prototype.set=function(e,t,r,n){if(void 0===n&&(n=!1),void 0!==r&&(console.warn("WARNING!! The Jaw.prototype.set() method called with 'options' parameter setted."),"boolean"==typeof r&&(n=r)),Array.isArray(e))for(var o=e.length,a=0;a<o;a++){var s=e[a];""===s.name?(console.warn("WARNING!!! Ability of set a 'top level' property on a Jaw is deprecated and will be removed"),i.a.extend(!0,this.__store,s.value)):this.__singleSet(s.name,s.value)}else if("object"==typeof e)for(let t in e)this.__singleSet(t,e[t]);else"string"==typeof e?""===e?(console.warn("WARNING!!! Ability of set a 'top level' property on a Jaw is deprecated and will be removed"),i.a.extend(!0,this.__store,t)):this.__singleSet(e,t):console.error("Jaw.prototype.set: This kind of data could not be used.");D.trace({__store:this.__store,nameOrItems:e,value:t,options:r,requireRender:n,type:typeof e},D.TRACE_LOG),n&&D.render()},l.prototype.setRenderElements=function(e){console.warn("Jaw.prototype.setRenderElements: This method MUST NOT be used, replace it with 'set' method."),this.set(e,null,{},!0)},l.__getNodeDepth=function(e){let t=0;for(;"BODY"!=e.nodeName;)e=e.parentNode,t++;return t},l.prototype.smartListen2=function(e,t){const r=[];for(let e in this)"function"==typeof this[e]&&e.indexOf("Handler")>-1&&r.push({handlerName:e,handlerHolder:this});this.__activeComponents.forEach(e=>{for(let t in e)"function"==typeof e[t]&&t.indexOf("Handler")>-1&&r.push({handlerName:t,handlerHolder:e})}),r.forEach(e=>{let t,r=e.handlerName;t=r.lastIndexOf("_")>-1?r.substr(0,r.lastIndexOf("_")):r;let n=t,o="#"+n,a=!0,s=document.querySelector(o),c="singleNode";if(!s)if(o="."+n,s=document.querySelectorAll(o),0===s.length)D.__controllers[t]?c="manager":a=!1;else{c="multiNode";const t=[];s.forEach(e=>{t.push(l.__getNodeDepth(e))});const r=Math.min(...t);e.depthList=t,e.minDepth=r}if(e.targetType=c,a){let r=!1;"manager"===c&&(e.handlerHolder.__listeners[t]?e.handlerHolder.__listeners[t][eventName]?"component"===e.handlerHolder.type&&(r=!0):r=!0:(r=!0,e.handlerHolder.__listeners[t]={}),r&&(this.trace("Auto-listener assigned to the '"+D.__controllers[t].className+"' Controller for the '"+eventName+"' event.","log"),e.handlerHolder.__listeners[t][eventName]={handler:currHandler,target:"controller",type:"autoListener"},"component"===e.handlerHolder.type&&i()(D.__controllers[t]).off(eventName,e.handlerHolder[currHandler]),i()(D.__controllers[t]).on(eventName,e.handlerHolder[currHandler])))}},this),this.trace("Jaw.prototype.smartListen2: validMethodList",r,"log")},l.prototype.smartListen=function(e,t){void 0===t&&(t=!1);var r=this._extractValidMethodList(this);console.log("smartListen",{__validMethodList:this.__validMethodList,jaw:this});const n=[],o=[];r.push(...this._extractComponentsValidMethodList(this.__activeComponents,n,o)),console.log({processedComponentList:n,__activeComponents:this.__activeComponents,notProcessedComponentList:o,validMethodList:r}),this.trace("Jaw.prototype.smartListen: validMethodList",r,"log"),this.__validMethodList=r,r.forEach((function(r){var n,o=r.handlerName,a=!0;n=o.indexOf("_")>-1?o.substr(0,o.indexOf("_")):o;var s=r.handlerHolder.className+"_"+n,l="#"+s,c=o.substring(o.indexOf("_")+1,o.indexOf("Handler")),d=i()(l);if(e){var p=i()(e);t&&"#"+n===e?(this.trace(d,p,"log"),d=p):(0===(d=p.find(l)).length&&(l="#"+n,d=p.find(l)),0===d.length&&(l="."+s,d=p.find(l)),0===d.length&&(l="."+n,d=p.find(l)),d.selector!==p.selector&&0===d.closest(p).length&&(a=!1))}else 0===d.length&&(l="#"+n,d=i()(l)),0===d.length&&(l="."+s,d=i()(l)),0===d.length&&(l="."+n,d=i()(l));if(a){var u=!1;if(d.length>0){if(r.handlerHolder.__listeners||(r.handlerHolder.__listeners={}),r.handlerHolder.__listeners[l]?r.handlerHolder.__listeners[l][c]?"component"===r.handlerHolder.type&&(u=!0):u=!0:(u=!0,r.handlerHolder.__listeners[l]={}),u){this.trace("Auto-listener assigned to '"+l+"' item of the '"+r.handlerHolder.className+"' "+r.handlerHolder.type+" for the '"+c+"' event.","log");var h=function(e){e.data.handler.call(r.handlerHolder,e,this.dataset)};"component"===r.handlerHolder.type&&r.handlerHolder.__listeners[l][c]&&r.handlerHolder.__listeners[l][c].handler&&d.off(c,r.handlerHolder.__listeners[l][c].handler),r.handlerHolder.__listeners[l][c]={context:"jaw",handler:h,originalHandler:o,target:"DOM",type:"autoListener"},d.on(c,{handler:r.handlerHolder[o],handlerHolder:r.handlerHolder},h),r.handlerHolder.__methods||(r.handlerHolder.__methods={}),r.handlerHolder.__methods[o]&&r.handlerHolder.__methods[o].settings&&void 0!==r.handlerHolder.__methods[o].settings.smartUnlisten&&(r.handlerHolder.__listeners[l][c].smartUnlisten=r.handlerHolder.__methods[o].settings.smartUnlisten)}}else D.__controllers[n]&&(r.handlerHolder.__listeners[n]?r.handlerHolder.__listeners[n][c]?"component"===r.handlerHolder.type&&(u=!0):u=!0:(u=!0,r.handlerHolder.__listeners[n]={}),u&&(this.trace("Auto-listener assigned to the '"+D.__controllers[n].className+"' Controller for the '"+c+"' event.","log"),r.handlerHolder.__listeners[n][c]={handler:o,target:"controller",type:"autoListener"},"component"===r.handlerHolder.type&&i()(D.__controllers[n]).off(c,r.handlerHolder[o]),i()(D.__controllers[n]).on(c,r.handlerHolder[o])))}else this.trace("Auto-listener not assigned for the '"+c+"' event because of the container selector. The target: ",d,"log")}),this)},l.prototype.smartUnlisten=function(e){console.log("smartUnlisten",{__validMethodList:this.__validMethodList}),this.__validMethodList&&this.__validMethodList.forEach(e=>{for(var t in e.handlerHolder.__listeners){var r=e.handlerHolder.__listeners[t];for(var n in r){var o=r[n];if(!0===o.smartUnlisten||void 0===o.smartUnlisten){switch(o.target){case"DOM":i()(t).off(n,e.handlerHolder[o.handler]);break;case"controller":i()(D.__controllers[t]).off(n,e.handlerHolder[o.handler])}delete e.handlerHolder.__listeners[t][n]}}delete e.handlerHolder.__listeners[t]}})},l.prototype.trace=function(e,t){D&&D.trace&&D.trace(e,t)},l.prototype.updateDisplay=function(e,t){D.get(e,"appData");console.warn("UPDATE DISPLAY!!!!!!");var r=i()("body"),n="sh-model",o=r.find("[data-"+n+"]");if(0===o.length&&(n="sh-reference-model",o=r.find("[data-"+n+"]")),(o=r.find("[data-"+n+"='"+e+"']")).length>0){var a,s=(e=o.data(n)).indexOf("["),l=-1;s>-1&&(l=e.substring(s+1,e.indexOf("]")),e=e.substr(0,s)),(a=-1===l?D.getReferenceModel(e):D.getReferenceModel(e)[l]).__dirtyProperties.map((function(t){var r=o.find("[data-sh-prop^='"+t+"@']").add("[data-sh-model-prop^='"+t+"@']");if(r.length>0){var n=D.getTemplate("models."+e+"_"+t);if(""!==n){var s=i.a.extend({},D.__templateMap,jaw.__childTemplates),l=Mustache.render(n,this.__store,s);r.html(l)}else r.html(a[t])}})),a.__dirtyProperties=[],a.__isDirty=!1}};var c=l,d=r(3),p=r.n(d);var u=class{constructor(e){this.model=e,this.parseModelValues()}__parseModelValues(){for(let e in this.model)"function"!=typeof this.model[e]&&(this[e]=this.model[e])}parseModelValues(e){return this.__parseModelValues(e)}setModel(e){this.model=e}};var h=class{constructor(e,t,r){Object.defineProperties(this,{__shguid:{value:s.generateGUID(),writable:!1}}),r&&s.matchProperties(this,r,{createMissingProperties:!0,matchEmptyParameters:!0}),Object.defineProperties(this,{__clean:{value:e=>(this.__dirtyProperties=e?this.__dirtyProperties.filter(t=>-1===e.indexOf(t.property)):[],this.__isDirty=this.__dirtyProperties.length>0,this.__dirtyProperties),writable:!1},__export:{value:e=>{const t={};if(e&&e.hasOwnProperty("fields"))e.fields.forEach(e=>{this.hasOwnProperty(e)&&(t[e]=this[e])});else for(let e in this)"function"!=typeof this[e]&&"__"!==e.substr(0,2)&&"jQuery"!==e.substr(0,6)&&(t[e]=this[e]);return t},writable:!1},__import:{value:(e,t)=>{const r=Object.assign({createMissingProperties:!1,matchEmptyParameters:!0},t);return s.matchProperties(this,e,r)},writable:!1},__restore:{value:e=>{e||(this.__dirtyProperties.forEach((function(e){this.set(e.property,e.originalValue)}),this),this.__dirtyProperties=[],this.__isDirty=!1)},writable:!1},__setPropertyDirtiness:{value:(e,t)=>{const r=this.__dirtyProperties.findIndex(t=>t.property===e);if(-1===r)this.__dirtyProperties.push({property:e,originalValue:t.oldValue});else if(t.newValue===this.__dirtyProperties[r].originalValue)this.__dirtyProperties.splice(r,1);else if(Array.isArray(t.newValue)&&Array.isArray(this.__dirtyProperties[r].originalValue))try{s.computeHash(t.newValue)===s.computeHash(this.__dirtyProperties[r].originalValue)&&this.__dirtyProperties.splice(r,1)}catch(e){console.error(e)}},writable:!1},__toJSON:{value:e=>{"boolean"==typeof e||(e=!1);var t={};for(var r in this)"function"==typeof this[r]||"__"===r.substr(0,2)&&"__shguid"!==r&&!e||"jQuery"===r.substr(0,6)||(t[r]=this[r]);return t},writable:!1}}),Object.defineProperties(this,{__dirtyProperties:{value:[],writable:!0}}),this.__boundProperties=[],this.__isDirty=!1,this.__modelStructure=r,this.__renderer=new u(this)}addRenderer(e){this.__renderer=this.__=e,this.__renderer.setModel(this)}clean(e){return this.__clean(e)}emit(e,t){return i()(this).trigger(e,t)}export(e){return this.__export(e)}exportArrayField(e,t="JSON"){return this.__exportArrayField(e,t)}__exportArrayField(e,t="JSON"){const r=s.getDeepProperty(this,e);let n;switch(t){case"JSON":n=JSON.stringify(r)}return n}exportBooleanField(e,t="number"){return this.__exportBooleanField(e,t)}__exportBooleanField(e,t="number"){const r=s.getDeepProperty(this,e);let n;switch(t){case"number":n=!0===r?1:0;break;case"string":n=r.toString()}return n}exportDateField(e,t="ISO",r=!0){return this.__exportDateField(e,t,r)}__exportDateField(e,t="ISO",r=!0){const n=s.getDeepProperty(this,e);let o;const a=p()(n);return o=a.isValid()?r?a.utc().format("YYYY-MM-DD HH:mm:ss"):a.format("YYYY-MM-DD HH:mm:ss"):"0000-00-00 00:00:00",o}exportNumberField(e,t){return this.__exportNumberField(e,t)}__exportNumberField(e,t){const r=s.getDeepProperty(this,e);let n;return"number"==typeof r?n=r:"string"==typeof r&&(n=parseFloat(r)),n}exportObjectField(e,t="JSON"){return this.__exportObjectField(e,t)}__exportObjectField(e,t="JSON"){const r=s.getDeepProperty(this,e);let n;switch(t){case"JSON":n=JSON.stringify(r)}return n}import(e,t){return this.__import(e,t)}importBooleanField(e,t){return this.__importBooleanField(e,t)}__importBooleanField(e,t){if(void 0===t||null==t)return!1;let r,n=!1;return"number"==typeof t?(r=1===t,n=!0):"string"==typeof t?(r="false"!==t.toLowerCase()&&(1===parseInt(t)||"true"===t.toLowerCase()),n=!0):"boolean"==typeof t&&(r=t,n=!0),n&&s.setDeepProperty(this,e,r),n}importDateField(e,t,r=!0){return this.__importDateField(e,t,r)}__importDateField(e,t,r){if(void 0===t||null==t)return!1;let n;return n=r?p.a.utc(t).local():p()(t),s.setDeepProperty(this,e,n),n.isValid()}importNumberField(e,t,r){return this.__importNumberField(e,t,r)}__importNumberField(e,t,r){if(void 0===t||null==t)return!1;let n;return"number"==typeof t?n=t:"string"==typeof t&&(n=parseFloat(t)),isNaN(n)?void 0!==r&&"number"==typeof r&&(s.setDeepProperty(this,e,r),!0):(s.setDeepProperty(this,e,n),!0)}importField(e,t,r){if(r=Object.assign({acceptUndefined:!1,dataType:"auto",defaultValue:void 0,useUTC:!0},r),(void 0===t||null==t)&&!r.acceptUndefined)return!1;switch(r.dataType){case"auto":break;case"boolean":return this.importBooleanField(e,t);case"date":return this.importDateField(e,t,r.useUTC);case"number":return this.importNumberField(e,t,r.defaultValue)}return!0}isDirty(){return this.__isDirty}off(e,t){return i()(this).off(e,t)}on(e,t){return i()(this).on(e,t)}restore(e){this.__restore(e)}__singleSet(e,t,r){let n=s.getDeepProperty(this,e);const o=s.computeHash(n);let a=!0;switch(typeof n){case"number":D.trace("%cChiamato il metodo set e la propietà è di tipo "+typeof n,"font-size: 16px; color: red;",D.TRACE_LOG),t=parseFloat(t);break;case"object":if(Array.isArray(n)&&!Array.isArray(t)){let e=Array.from(n),r=e.indexOf(t);if(r>-1)e.splice(r,1);else{let r=e.indexOf(parseFloat(t));r>-1?e.splice(r,1):e.push(t)}t=e,D.trace(`%cChiamato il metodo set e la propietà è di tipo ${typeof e} ed è un array`,"font-size: 16px; color: red;",D.TRACE_LOG)}else D.activeFeatures.moment&&(n._isAMomentObject||n instanceof p.a)?(D.trace(`%cChiamato il metodo set e la propietà è di tipo ${typeof n} ed è un moment`,"font-size: 16px; color: red;",D.TRACE_LOG),t=p()(t)):D.trace("%cChiamato il metodo set e la propietà è di tipo "+typeof n,"font-size: 16px; color: red;",D.TRACE_LOG);if(Array.isArray(n)&&Array.isArray(t))try{a=o!==s.computeHash(t)}catch(e){console.error(e)}break;case"string":D.trace("%cChiamato il metodo set e la propietà è di tipo "+typeof n,"font-size: 16px; color: red;",D.TRACE_LOG),void 0!==t?"function"==typeof t.toString&&(t=t.toString()):t=""}var i={modelName:this.__modelName,newValue:t,oldValue:s.getDeepProperty(this,e),property:e};if(s.setDeepProperty(this,e,t),i.oldValue!==i.newValue&&a){this.__setPropertyDirtiness(e,i),this.__isDirty=this.__dirtyProperties.length>0,D.settings.enableSmartModelSetUpdatesView&&document.querySelectorAll(`[data-sh-prop="${e}"]`).forEach(e=>{if(e!==r){const r=e.closest("[data-shguid]");let n=r?r.dataset.shguid:"";if(""===n||n===this.__shguid){let r=!1,n=!1;switch(e.nodeName.toUpperCase()){case"INPUT":switch(e.type.toUpperCase()){case"CHECKBOX":case"RADIO":break;default:r=!0}break;case"SELECT":case"TEXTAREA":r=!0;break;default:n=!0}r?e.value=t:n?e.innerHTML=t:D.trace("Non aggiorno il valore",{eventData:i},D.TRACE_LOG)}}}),"function"==typeof this.onDataChanged&&this.onDataChanged.call(this,i);const n=s.toTitleCase(e,!1).replace(/\./g,"_");"Data"!==n&&n!==e&&"function"==typeof this["on"+n+"Changed"]&&this["on"+n+"Changed"].call(this,i),this.emit("dataChanged",i),"data"!==e&&this.emit(e+"Changed",i)}}set(e,t,r){if(Array.isArray(e))e.forEach(e=>{this.__singleSet(e.name,e.value,r)});else if("object"==typeof e)for(let t in e)this.__singleSet(t,e[t],r);else"string"==typeof e?this.__singleSet(e,t,r):console.error("Shark.set: This kind of data could not be used.");this.__renderer&&"function"==typeof this.__renderer.parseModelValues&&this.__renderer.parseModelValues({name:e,value:t})}toJSON(e){return this.__toJSON(e)}toString(e){return JSON.stringify(this.toJSON(e))}},_=function(){if(void 0===o.a)throw new Error("Mustache is needed to use MustacheRenderer!")};_.prototype.render=function(e,t){console.time("MustacheRenderer.render"),D.trace("MustacheRenderer.render: ",e,t,D.TRACE_INFO);if(t=i.a.extend({renderOnScreen:!0},t),!e.__templateParsed){for(var r=e.templateContent,n=0,a=r.match(/{{>[\w\.]+\}\}/g);a&&n<100;)a.forEach((function(e){var t=e.replace("{{>","").replace("}}","");t?r=r.replace(e,D.getTemplate(t)):D.trace("MustacheRenderer.render > Missing SubTemplate: "+t,D.TRACE_ERROR)})),a=r.match(/{{>[\w\.]+\}\}/g),n++;for(var l=r.match(/{{=>[\w\.]+\}\}/g);l;)l.forEach((function(e){let t=!0,n=e.replace("{{=>","").replace("}}","");n.indexOf(".")>-1&&(n=n.substr(0,n.indexOf(".")),t=!1);let o=D.__components[n];if(o){if(t&&(r=r.replace(e,o.templateContent)),o.__templates)for(let e in o.__templates)r=r.replace(`{{=>${n}.${e}}}`,o.__templates[e])}else D.trace("MustacheRenderer.render > Missing component: "+n,D.TRACE_ERROR),r=r.replace(e,e.replace("{{=>","{{>"))})),l=r.match(/{{=>[\w\.]+\}\}/g);let t=new RegExp(/<shark-[\w]+.+\/*>/g),o=r.match(t);for(;o;)o.forEach((function(e){let t=e,n="";t.indexOf("></shark-")>-1&&(t=t.substr(0,t.indexOf("></shark-"))),t.indexOf("/>")>-1&&(t=t.substr(0,t.indexOf("/>"))),t.indexOf(">")>-1&&(t=t.substr(0,t.indexOf(">"))),t.indexOf(" ")>-1&&(t=t.substr(0,t.indexOf(" "))),t=t.replace("<shark-",""),t.indexOf("-")>-1&&(t=s.dashedToCamel(t));let o=e.indexOf('template="');o>-1&&(n=e.substring(o+10,e.indexOf('"',o+11)),"default"===n&&(n=""));let a=D.__components[t];a?""===n?r=r.replace(e,a.templateContent):a.__templates&&a.__templates[n]&&(r=r.replace(e,a.__templates[n])):(D.trace("MustacheRenderer.render > Missing component: "+t+", removing from template.",D.TRACE_ERROR),r=r.replace(e,""))})),o=r.match(t);r=r.replace(/data-sh-model=\"(.\S+)\"/g,'$& data-shguid="{{__shguid}}"'),e.__autoBoundListSection=[];const i=r.match(/{{\[\>[\w\.]+\}\}/g);i&&(i.forEach(t=>{const n=t.replace("{{[>","").replace("}}","");let o=new RegExp("{{\\[\\>"+n+"\\}\\}([\\s\\S]*){{"+n+"\\<\\]\\}\\}","g").exec(r)[1];const a=o.indexOf(">");o=o.substr(0,a)+' data-shguid="{{__shguid}}"'+o.substr(a),console.log({listSection:t}),e.__autoBoundListSection.push({propertyName:n,template:o});const i=new RegExp("{{\\[\\>("+n+")\\}\\}","g"),s=new RegExp("{{("+n+")\\<\\]\\}\\}","g");r=(r=r.replace(i,'<shark-list property="'+n+'">{{#$1}}')).replace(s,"{{/$1}}</shark-list>")}),console.log({__autoBoundListSection:e.__autoBoundListSection})),console.time("autoBind"),D.trace({renderField:r.match(/{{[\w\.]+\}\}/g),renderListOrPresence:r.match(/{{#[\w\.]+\}\}/g),renderAbsence:r.match(/{{\^[\w\.]+\}\}/g)},D.TRACE_LOG),D.trace({renderField:[...new Set(r.match(/{{[\w\.]+\}\}/g))].map(e=>e.replace("{{","").replace("}}","")),renderListOrPresence:[...new Set(r.match(/{{#[\w\.]+\}\}/g))].map(e=>e.replace("{{#","").replace("}}","")),renderAbsence:[...new Set(r.match(/{{\^[\w\.]+\}\}/g))].map(e=>e.replace("{{^","").replace("}}",""))},D.TRACE_LOG);const c=[...[...new Set(r.match(/{{[\w\.]+\}\}/g))].map(e=>e.replace("{{","").replace("}}","")),...[...new Set(r.match(/{{#[\w\.]+\}\}/g))].map(e=>e.replace("{{#","").replace("}}","")),...[...new Set(r.match(/{{\^[\w\.]+\}\}/g))].map(e=>e.replace("{{^","").replace("}}",""))];D.__autoBoundProperties=[];for(const t in D.__store)c.indexOf(t)>-1&&(D.__autoBoundProperties.push(t),e.__autoBoundProperties.push(t));D.trace({renderField:c,SharkAutoBoundProperties:D.__autoBoundProperties,JawAutoBoundProperties:e.__autoBoundProperties}),console.timeEnd("autoBind");for(const e in D.__store)D.__store[e]instanceof h&&(D.__store[e].__boundProperties=[]);const d=r.match(/{{[\w\.]+\}\}/g);d&&d.length>0&&d.forEach(e=>{const t=e.replace("{{","").replace("}}","").split("."),r=D.get(t[0]);r&&r instanceof h&&-1===r.__boundProperties.indexOf(t[1])&&(r.__boundProperties.push(t[1]),D.trace("dynamicFields",r,"log"))}),D.__dynamicSections={};const p=r.match(/\<shark-section(.*?)\>/g);p&&p.length>0&&(p.forEach(e=>{const t=e,n="</shark-section>",o={closeTag:n,openTag:t,rGuid:D.__generateGUID("rid_"),storeReference:/model=\"(.*?)\"/g.exec(e)[1]};var a=new RegExp(t+"(.*?)"+n.replace("/","/"),"gs");o.templateContent=a.exec(r)[1],r=window.customElements?r.replace(e,`<shark-section data-sh-rguid='${o.rGuid}'>${t}`).replace(n,n+"</shark-section>"):r.replace(e,`<span data-sh-rguid='${o.rGuid}'>${t}`).replace(n,n+"</span>"),D.__dynamicSections[o.storeReference]?D.__dynamicSections[o.storeReference].push(o):D.__dynamicSections[o.storeReference]=[o]}),D.trace("dynamicSections",D.__dynamicSections,"log")),r=r.replace(/\[\[([\w\.]+)\]\]/g,"{{{__renderer.$1}}}"),e.__parsedTemplate=r,e.__templateParsed=!0}const c={},d=[];e.__activeComponents.forEach(e=>{-1===d.indexOf(e.id)&&Object.assign(c,e.__store),e.__activeComponents.forEach(e=>{-1===d.indexOf(e.id)&&Object.assign(c,e.__store)})});const p=i.a.extend({},D.__templateMap,e.__childTemplates),u=Object.assign({},D.__store,c,e.__store),_=o.a.render(e.__parsedTemplate,u,p);if(!t.renderOnScreen)return console.timeEnd("MustacheRenderer.render"),_;i()(t.container).html(_),console.timeEnd("MustacheRenderer.render")},_.prototype.renderItem=function(e){if(!e.templateSource)throw new Error("MustacheRenderer.renderItem: To render an item you must specify the template parameter");var t={append:!1,childTemplates:{},containerSelector:"",renderItems:{},replace:!1,templateSource:null};if(i.a.extend(!0,t,e),D.trace("MustacheRenderer.renderItem",t,D.TRACE_INFO),e.replace&&""===e.containerSelector)throw new Error("Could not use replace parameter without setting a containerSelector!");var r=i.a.extend({},D.__templateMap,t.childTemplates),n=o.a.render(t.templateSource,t.renderItems,r);if(""===e.containerSelector||!e.containerSelector)return n;e.append?i()(e.containerSelector).append(n):e.replace?i()(e.containerSelector).replaceWith(n):i()(e.containerSelector).html(n)};var f=r(11),m=r.n(f),g=r(12),y=r.n(g),v=r(21),w=r.n(v),b=r(22),O=r.n(b),x=r(23),R=r.n(x);var P,E=class{constructor(){if(void 0===o.a)throw new Error("Mustache is needed to use VirtualDOMRenderer!");this.rootNode=null,this.tree=null}render(e,t){return new Promise((r,n)=>{console.time("VirtualDOMRenderer.render"),D.trace("VirtualDOMRenderer.render: ",e,t,D.TRACE_INFO);if(t=i.a.extend({renderOnScreen:!0},t),!e.__templateParsed){for(var a=e.templateContent,l=a.match(/{{=>[\w\.]+\}\}/g);l;)l.forEach((function(e){let t=!0,r=e.replace("{{=>","").replace("}}","");r.indexOf(".")>-1&&(r=r.substr(0,r.indexOf(".")),t=!1);let n=D.__components[r];if(n){if(t&&(a=a.replace(e,n.templateContent)),n.__templates)for(let e in n.__templates)a=a.replace(`{{=>${r}.${e}}}`,n.__templates[e])}else D.trace("VirtualDOMRenderer.render > Missing component: "+r,D.TRACE_ERROR),a=a.replace(e,e.replace("{{=>","{{>"))})),l=a.match(/{{=>[\w\.]+\}\}/g);let t=new RegExp(/<shark-[\w]+.+\/*>/g),r=a.match(t);for(;r;)r.forEach((function(e){let t=e,r="";t.indexOf("></shark-")>-1&&(t=t.substr(0,t.indexOf("></shark-"))),t.indexOf("/>")>-1&&(t=t.substr(0,t.indexOf("/>"))),t.indexOf(">")>-1&&(t=t.substr(0,t.indexOf(">"))),t.indexOf(" ")>-1&&(t=t.substr(0,t.indexOf(" "))),t=t.replace("<shark-",""),t.indexOf("-")>-1&&(t=s.dashedToCamel(t));let n=e.indexOf('template="');n>-1&&(r=e.substring(n+10,e.indexOf('"',n+11)),"default"===r&&(r=""));let o=D.__components[t];o?""===r?a=a.replace(e,o.templateContent):o.__templates&&o.__templates[r]&&(a=a.replace(e,o.__templates[r])):(D.trace("VirtualDOMRenderer.render > Missing component: "+t+", removing from template.",D.TRACE_ERROR),a=a.replace(e,""))})),r=a.match(t);a=a.replace(/data-sh-model=\"(.\S+)\"/g,'$& data-shguid="{{__shguid}}"'),e.__autoBoundListSection=[];const n=a.match(/{{\[\>[\w\.]+\}\}/g);n&&(n.forEach(t=>{const r=t.replace("{{[>","").replace("}}","");let n=new RegExp("{{\\[\\>"+r+"\\}\\}([\\s\\S]*){{"+r+"\\<\\]\\}\\}","g").exec(a)[1];const o=n.indexOf(">");n=n.substr(0,o)+' data-shguid="{{__shguid}}"'+n.substr(o),console.log({listSection:t}),e.__autoBoundListSection.push({propertyName:r,template:n});const i=new RegExp("{{\\[\\>("+r+")\\}\\}","g"),s=new RegExp("{{("+r+")\\<\\]\\}\\}","g");a=(a=a.replace(i,'<shark-list property="'+r+'">{{#$1}}')).replace(s,"{{/$1}}</shark-list>")}),console.log({__autoBoundListSection:e.__autoBoundListSection})),console.time("autoBind"),D.trace({renderField:a.match(/{{[\w\.]+\}\}/g),renderListOrPresence:a.match(/{{#[\w\.]+\}\}/g),renderAbsence:a.match(/{{\^[\w\.]+\}\}/g)},D.TRACE_LOG),D.trace({renderField:[...new Set(a.match(/{{[\w\.]+\}\}/g))].map(e=>e.replace("{{","").replace("}}","")),renderListOrPresence:[...new Set(a.match(/{{#[\w\.]+\}\}/g))].map(e=>e.replace("{{#","").replace("}}","")),renderAbsence:[...new Set(a.match(/{{\^[\w\.]+\}\}/g))].map(e=>e.replace("{{^","").replace("}}",""))},D.TRACE_LOG);const o=[...[...new Set(a.match(/{{[\w\.]+\}\}/g))].map(e=>e.replace("{{","").replace("}}","")),...[...new Set(a.match(/{{#[\w\.]+\}\}/g))].map(e=>e.replace("{{#","").replace("}}","")),...[...new Set(a.match(/{{\^[\w\.]+\}\}/g))].map(e=>e.replace("{{^","").replace("}}",""))];D.__autoBoundProperties=[];for(const t in D.__store)o.indexOf(t)>-1&&(D.__autoBoundProperties.push(t),e.__autoBoundProperties.push(t));D.trace({renderField:o,SharkAutoBoundProperties:D.__autoBoundProperties,JawAutoBoundProperties:e.__autoBoundProperties}),console.timeEnd("autoBind");for(const e in D.__store)D.__store[e]instanceof h&&(D.__store[e].__boundProperties=[]);const i=a.match(/{{[\w\.]+\}\}/g);i&&i.length>0&&i.forEach(e=>{const t=e.replace("{{","").replace("}}","").split("."),r=D.get(t[0]);r&&r instanceof h&&-1===r.__boundProperties.indexOf(t[1])&&(r.__boundProperties.push(t[1]),D.trace("dynamicFields",r,"log"))}),D.__dynamicSections={};const c=a.match(/\<shark-section(.*?)\>/g);c&&c.length>0&&(c.forEach(e=>{const t=e,r="</shark-section>",n={closeTag:r,openTag:t,rGuid:D.__generateGUID("rid_"),storeReference:/model=\"(.*?)\"/g.exec(e)[1]};var o=new RegExp(t+"(.*?)"+r.replace("/","/"),"gs");n.templateContent=o.exec(a)[1],a=window.customElements?a.replace(e,`<shark-section data-sh-rguid='${n.rGuid}'>${t}`).replace(r,r+"</shark-section>"):a.replace(e,`<span data-sh-rguid='${n.rGuid}'>${t}`).replace(r,r+"</span>"),D.__dynamicSections[n.storeReference]?D.__dynamicSections[n.storeReference].push(n):D.__dynamicSections[n.storeReference]=[n]}),D.trace("dynamicSections",D.__dynamicSections,"log")),a=(a=(a=(a=(a=(a=a.replace(/\[\[([\w\.]+)\]\]/g,"{{{__renderer.$1}}}")).replace(/\t/g,"")).replace(/<br[\s\S\ ]*?(?=>)/g,"$&/")).replace(/<hr[\s\S\ ]*?(?=>)/g,"$&/")).replace(/<img [\s\S\ ]*?(?=>)/g,"$&/")).replace(/<input [\s\S\ ]*?(?=>)/g,"$&/"),e.__parsedTemplate=a,e.__templateParsed=!0}const c={},d=[];e.__activeComponents.forEach(e=>{-1===d.indexOf(e.id)&&Object.assign(c,e.__store),e.__activeComponents.forEach(e=>{-1===d.indexOf(e.id)&&Object.assign(c,e.__store)})});const p=i.a.extend({},D.__templateMap,e.__childTemplates),u=Object.assign({},D.__store,c,e.__store);let _=o.a.render(e.__parsedTemplate,u,p);if(t.renderOnScreen){const e=this;_="<span>"+_+"</span>",e.tree?(console.time("VirtualDOMRenderer.patch"),m()(_.trim(),(function(t,n){var o=new Function("h","return "+n)(y.a),a=w()(e.tree,o);e.rootNode=O()(e.rootNode,a),e.tree=o,console.timeEnd("VirtualDOMRenderer.render"),console.timeEnd("VirtualDOMRenderer.patch"),r()}))):(console.time("VirtualDOMRenderer.patch"),m()(_.trim(),(function(n,o){e.tree=new Function("h","return "+o)(y.a),e.rootNode=R()(e.tree),i()(t.container).append(e.rootNode),console.timeEnd("VirtualDOMRenderer.render"),console.timeEnd("VirtualDOMRenderer.patch"),r()})))}else r(_)})}},C=new Uint8Array(16);function T(){if(!P&&!(P="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-support