UNPKG

manyfest

Version:

JSON Object Manifest for Data Description and Parsing

3 lines (2 loc) 32.3 kB
"use strict";function _callSuper(e,t,r){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,r||[],_getPrototypeOf(e).constructor):t.apply(e,r))}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct=function(){return!!e})()}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,_toPropertyKey(s.key),s)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=_typeof(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _typeof(e){return _typeof="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},_typeof(e)}!function(e){if("object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Manyfest=e()}}((function(){return function e(t,r,s){function n(o,i){if(!r[o]){if(!t[o]){var c="function"==typeof require&&require;if(!i&&c)return c(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return n(t[o][1][e]||e)}),u,u.exports,e,t,r,s)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<s.length;o++)n(s[o]);return n}({1:[function(e,t,r){var s=function(){return _createClass((function e(t,r,s){_classCallCheck(this,e),"object"===_typeof(t)&&t.isFable?this.connectFable(t):this.fable=!1,this.fable?(this.UUID=t.getUUID(),this.options="object"===_typeof(r)?r:{}):(this.options="object"!==_typeof(t)||t.isFable?"object"===_typeof(r)?r:{}:t,this.UUID="CORE-SVC-".concat(Math.floor(89999*Math.random()+1e4))),this.serviceType="Unknown-".concat(this.UUID),this.Hash="string"==typeof s?s:this.fable||"string"!=typeof r?"".concat(this.UUID):r}),[{key:"connectFable",value:function(e){if("object"!==_typeof(e)||!e.isFable){var t="Fable Service Provider Base: Cannot connect to Fable, invalid Fable object passed in. The pFable parameter was a [".concat(_typeof(e),"].}");return console.log(t),new Error(t)}return this.fable||(this.fable=e),this.log||(this.log=this.fable.Logging),this.services||(this.services=this.fable.services),this.servicesMap||(this.servicesMap=this.fable.servicesMap),!0}}])}();_defineProperty(s,"isFableService",!0),t.exports=s,t.exports.CoreServiceProviderBase=s},{}],2:[function(e,t,r){t.exports=function(e,t){return t.startsWith(e)&&t.endsWith(e)?t.substring(1,t.length-1):t}},{}],3:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.translationTable={}}),[{key:"translationCount",value:function(){return Object.keys(this.translationTable).length}},{key:"addTranslation",value:function(e){var t=this;if("object"!=_typeof(e))return this.logError("Hash translation addTranslation expected a translation be type object but was passed in ".concat(_typeof(e))),!1;Object.keys(e).forEach((function(r){"string"!=typeof e[r]?t.logError("Hash translation addTranslation expected a translation destination hash for [".concat(r,"] to be a string but the referrant was a ").concat(_typeof(e[r]))):t.translationTable[r]=e[r]}))}},{key:"removeTranslationHash",value:function(e){e in this.translationTable&&delete this.translationTable[e]}},{key:"removeTranslation",value:function(e){var t=this;return"string"==typeof e?(this.removeTranslationHash(e),!0):"object"==_typeof(e)?(Object.keys(e).forEach((function(e){t.removeTranslation(e)})),!0):(this.logError("Hash translation removeTranslation expected either a string or an object but the passed-in translation was type ".concat(_typeof(e))),!1)}},{key:"clearTranslations",value:function(){this.translationTable={}}},{key:"translate",value:function(e){return e in this.translationTable?this.translationTable[e]:e}}])}();t.exports=n},{"./Manyfest-LogToConsole.js":4}],4:[function(e,t,r){t.exports=function(e,t){var r="string"==typeof e?e:"";console.log("[Manyfest] ".concat(r)),t&&console.log(JSON.stringify(t))}},{}],5:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-ObjectAddress-GetValue.js"),a={DataFormat:e("./Manyfest-ObjectAddress-Parser.js")},o=function(){return _createClass((function e(){_classCallCheck(this,e),this.getObjectValueClass=new n(s,s)}),[{key:"checkAddressExists",value:function(e,t,r){if("object"!=_typeof(e))return!1;if("string"!=typeof t)return!1;var n=void 0===r?e:r,o=a.DataFormat.stringGetFirstSegment(t);if(o.length==t.length){var i=t.indexOf("["),c=t.indexOf("]"),l=t.indexOf("(");if(l>0&&a.DataFormat.stringCountEnclosures(t)>0){var u=t.substring(0,l).trim();return u in e&&"function"==typeof e[u]}if(i>0&&c>i&&c-i>1){var f=t.substring(0,i).trim();if("object"!==_typeof(e[f]))return!1;var h=t.substring(i+1,c).trim(),d=parseInt(h,10);return Array.isArray(e[f])!=isNaN(d)&&(isNaN(d)?(h=this.cleanWrapCharacters('"',h),h=this.cleanWrapCharacters("`",h),(h=this.cleanWrapCharacters("'",h))in e[f]):d in e[f])}return t in e}var p=o,g=t.substring(o.length+1),y=p.indexOf("["),b=p.indexOf("]"),v=p.indexOf("(");if(v>0&&a.DataFormat.stringCountEnclosures(p)>0){var A=p.substring(0,v).trim();if("function"==!_typeof(e[A]))return!1;var j=a.DataFormat.stringGetSegments(a.DataFormat.stringGetEnclosureValueByIndex(p.substring(A.length),0),",");if(0==j.length||""==j[0]){if(!(A in e))return s.log("Function ".concat(A," does not exist (address [").concat(t,"])")),!1;try{return this.checkAddressExists(e[A].apply(e),g,n)}catch(e){return s.log("Error calling function ".concat(A," (address [").concat(t,"]): ").concat(e.message)),!1}}else{for(var m=[],_=void 0===r?e:r,E=0;E<j.length;E++)m.push(this.getObjectValueClass.getValueAtAddress(_,j[E]));if(!(A in e))return s.log("Function ".concat(A," does not exist (address [").concat(t,"])")),!1;try{return this.checkAddressExists(e[A].apply(e,m),g,_)}catch(e){return s.log("Error calling function ".concat(A," (address [").concat(t,"]): ").concat(e.message)),!1}}}else if(y>0&&b>y&&b-y>1){var C=p.substring(0,y).trim(),O=p.substring(y+1,b).trim(),T=parseInt(O,10);return Array.isArray(e[C])!=isNaN(T)&&(isNaN(T)?(O=this.cleanWrapCharacters('"',O),O=this.cleanWrapCharacters("`",O),O=this.cleanWrapCharacters("'",O),this.checkAddressExists(e[C][O],g,n)):this.checkAddressExists(e[C][T],g,n))}return(!(p in e)||"object"===_typeof(e[p]))&&(p in e||(e[p]={}),this.checkAddressExists(e[p],g,n))}}])}();t.exports=o},{"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-GetValue.js":7,"./Manyfest-ObjectAddress-Parser.js":8}],6:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-CleanWrapCharacters.js"),a=e("../source/Manyfest-ParseConditionals.js"),o=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.cleanWrapCharacters=n}),[{key:"checkRecordFilters",value:function(e,t){return a(this,e,t)}},{key:"deleteValueAtAddress",value:function(e,t,r){if("object"==_typeof(e)&&"string"==typeof t){var s="";"string"==typeof r&&(s=r);var n=t.indexOf(".");if(-1==n){var a=t.indexOf("["),o=t.indexOf("]"),i=t.indexOf("{}");if(a>0&&o>a&&o-a>1){var c=t.substring(0,a).trim();if("object"!==_typeof(e[c]))return!1;var l=t.substring(a+1,o).trim(),u=parseInt(l,10);return Array.isArray(e[c])!=isNaN(u)&&(isNaN(u)?(l=this.cleanWrapCharacters('"',l),l=this.cleanWrapCharacters("`",l),l=this.cleanWrapCharacters("'",l),delete e[c][l],!0):(delete e[c][u],!0))}if(a>0&&o>a&&o-a==1){var f=t.substring(0,a).trim();if(!Array.isArray(e[f]))return!1;for(var h=e[f],d=h.length-1;d>=0;d--){this.checkRecordFilters(t,h[d])&&h.splice(d,1)}return!0}if(i>0){var p=t.substring(0,i).trim();return"object"==_typeof(e[p])&&(delete e[p],!0)}return delete e[t],!0}var g=t.substring(0,n),y=t.substring(n+1),b=g.indexOf("["),v=g.indexOf("]");if(b>0&&v>b&&v-b>1){var A=g.substring(0,b).trim(),j=g.substring(b+1,v).trim(),m=parseInt(j,10);return Array.isArray(e[A])!=isNaN(m)&&("object"==_typeof(e[A])&&(isNaN(m)?(j=this.cleanWrapCharacters('"',j),j=this.cleanWrapCharacters("`",j),j=this.cleanWrapCharacters("'",j),s="".concat(s).concat(s.length>0?".":"").concat(g),this.deleteValueAtAddress(e[A][j],y,s)):(s="".concat(s).concat(s.length>0?".":"").concat(g),this.deleteValueAtAddress(e[A][m],y,s))))}if(b>0&&v>b&&v-b==1){var _=t.substring(0,b).trim();if(!Array.isArray(e[_]))return!1;var E=e[_];s="".concat(s).concat(s.length>0?".":"").concat(_);for(var C={},O=0;O<E.length;O++){var T="".concat(s,"[").concat(O,"]"),D=this.deleteValueAtAddress(e[_][O],y,T);C["".concat(T,".").concat(y)]=D}return C}var k=t.indexOf("{}");if(k>0){var x=t.substring(0,k).trim();if("object"!=_typeof(e[x]))return!1;var V=e[x],M=Object.keys(V);s="".concat(s).concat(s.length>0?".":"").concat(x);for(var S={},N=0;N<M.length;N++){var w="".concat(s,".").concat(M[N]),F=this.deleteValueAtAddress(e[x][M[N]],y,w);this.checkRecordFilters(t,F)&&(S["".concat(w,".").concat(y)]=F)}return S}return g in e&&"object"!==_typeof(e[g])?void 0:g in e?(s="".concat(s).concat(s.length>0?".":"").concat(g),this.deleteValueAtAddress(e[g],y,s)):(s="".concat(s).concat(s.length>0?".":"").concat(g),e[g]={},this.deleteValueAtAddress(e[g],y,s))}}}])}();t.exports=o},{"../source/Manyfest-ParseConditionals.js":11,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],7:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-CleanWrapCharacters.js"),a=e("../source/Manyfest-ParseConditionals.js"),o={DataFormat:e("./Manyfest-ObjectAddress-Parser.js")},i=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.cleanWrapCharacters=n}),[{key:"checkRecordFilters",value:function(e,t){return a(this,e,t)}},{key:"getValueAtAddress",value:function(e,t,r,s){if("object"==_typeof(e)&&"string"==typeof t){var n="";"string"==typeof r&&(n=r);var a=void 0===s?e:s,i=o.DataFormat.stringGetFirstSegment(t);if(""==i){for(var c=o.DataFormat.stringGetSegments(n),l=0,u=0;u<t.length&&"."==t.charAt(u);u++)l++;var f=c.length-l;if(f<0)return;var h=t.slice(l);return f>0&&(h="".concat(c.slice(0,f).join("."),".").concat(h)),this.logInfo("Back-navigation detected. Recursing back to address [".concat(h,"]")),this.getValueAtAddress(a,h)}if(i.length!=t.length){var d=i,p=t.substring(i.length+1),g=d.indexOf("["),y=d.indexOf("]"),b=d.indexOf("(");if(b>0&&o.DataFormat.stringCountEnclosures(d)>0){var v=d.substring(0,b).trim();if(n="".concat(n).concat(n.length>0?".":"").concat(d),"function"==!_typeof(e[v]))return!1;var A=o.DataFormat.stringGetSegments(o.DataFormat.stringGetEnclosureValueByIndex(d.substring(v.length),0),",");if(0==A.length||""==A[0]){if(!(v in e))return console.log("Function ".concat(v," does not exist (address [").concat(t,"])")),!1;try{return this.getValueAtAddress(e[v].apply(e),p,n,a)}catch(e){return console.log("Error in getValueAtAddress calling function ".concat(v," (address [").concat(t,"]): ").concat(e.message)),!1}}else{for(var j=[],m=void 0===s?e:s,_=0;_<A.length;_++)!(A[_].length>=2)||'"'!=A[_].charAt(0)&&"'"!=A[_].charAt(0)&&"`"!=A[_].charAt(0)||'"'!=A[_].charAt(A[_].length-1)&&"'"!=A[_].charAt(A[_].length-1)&&"`"!=A[_].charAt(A[_].length-1)?j.push(this.getValueAtAddress(m,A[_])):j.push(A[_].substring(1,A[_].length-1));if(!(v in e))return console.log("Function ".concat(v," does not exist (address [").concat(t,"])")),!1;try{return this.getValueAtAddress(e[v].apply(e,j),p,n,m)}catch(e){return console.log("Error in getValueAtAddress calling function ".concat(v," (address [").concat(t,"]): ").concat(e.message)),!1}}}else{if(g>0&&y>g&&y-g>1){var E=d.substring(0,g).trim(),C=d.substring(g+1,y).trim(),O=parseInt(C,10);if(Array.isArray(e[E])==isNaN(O))return;if("object"!=_typeof(e[E]))return;return isNaN(O)?(C=this.cleanWrapCharacters('"',C),C=this.cleanWrapCharacters("`",C),C=this.cleanWrapCharacters("'",C),n="".concat(n).concat(n.length>0?".":"").concat(d),this.getValueAtAddress(e[E][C],p,n,a)):(n="".concat(n).concat(n.length>0?".":"").concat(d),this.getValueAtAddress(e[E][O],p,n,a))}if(g>0&&y>g&&y-g==1){var T=t.substring(0,g).trim();if(!Array.isArray(e[T]))return!1;var D=e[T];n="".concat(n).concat(n.length>0?".":"").concat(T);for(var k={},x=0;x<D.length;x++){var V="".concat(n,"[").concat(x,"]"),M=this.getValueAtAddress(e[T][x],p,V,a);k["".concat(V,".").concat(p)]=M}return k}}var S=t.indexOf("{}");if(S>0){var N=t.substring(0,S).trim();if("object"!=_typeof(e[N]))return!1;var w=e[N],F=Object.keys(w);n="".concat(n).concat(n.length>0?".":"").concat(N);for(var H={},P=0;P<F.length;P++){var I="".concat(n,".").concat(F[P]),W=this.getValueAtAddress(e[N][F[P]],p,I,a);this.checkRecordFilters(t,W)&&(H["".concat(I,".").concat(p)]=W)}return H}return d in e&&"object"!==_typeof(e[d])?void 0:d in e?(n="".concat(n).concat(n.length>0?".":"").concat(d),this.getValueAtAddress(e[d],p,n,a)):(n="".concat(n).concat(n.length>0?".":"").concat(d),e[d]={},this.getValueAtAddress(e[d],p,n,a))}var R=t.indexOf("["),L=t.indexOf("]"),G=t.indexOf("{}"),J=t.indexOf("(");if(!(J>0&&o.DataFormat.stringCountEnclosures(t)>0)){if(R>0&&L>R&&L-R>1){var B=t.substring(0,R).trim();if("object"!==_typeof(e[B]))return;var U=t.substring(R+1,L).trim(),z=parseInt(U,10);if(Array.isArray(e[B])==isNaN(z))return;return isNaN(z)?(U=this.cleanWrapCharacters('"',U),U=this.cleanWrapCharacters("`",U),U=this.cleanWrapCharacters("'",U),e[B][U]):e[B][z]}if(R>0&&L>R&&L-R==1){var q=t.substring(0,R).trim();if(!Array.isArray(e[q]))return!1;for(var K=e[q],Q=[],X=0;X<K.length;X++){this.checkRecordFilters(t,K[X])&&Q.push(K[X])}return Q}if(G>0){var $=t.substring(0,G).trim();return"object"==_typeof(e[$])&&e[$]}return null!=_typeof(e[t])?e[t]:void 0}var Y=t.substring(0,J).trim();if("function"==!_typeof(e[Y]))return!1;var Z=o.DataFormat.stringGetSegments(o.DataFormat.stringGetEnclosureValueByIndex(t.substring(Y.length),0),",");if(0==Z.length||""==Z[0]){if(!(Y in e))return console.log("Function ".concat(Y," does not exist (address [").concat(t,"])")),!1;try{return e[Y].apply(e)}catch(e){return console.log("Error in getValueAtAddress calling function ".concat(Y," (address [").concat(t,"]): ").concat(e.message)),!1}}else{for(var ee=[],te=void 0===s?e:s,re=0;re<Z.length;re++)!(Z[re].length>=2)||'"'!=Z[re].charAt(0)&&"'"!=Z[re].charAt(0)&&"`"!=Z[re].charAt(0)||'"'!=Z[re].charAt(Z[re].length-1)&&"'"!=Z[re].charAt(Z[re].length-1)&&"`"!=Z[re].charAt(Z[re].length-1)?ee.push(this.getValueAtAddress(te,Z[re])):ee.push(Z[re].substring(1,Z[re].length-1));if(!(Y in e))return console.log("Function ".concat(Y," does not exist (address [").concat(t,"])")),!1;try{return e[Y].apply(e,ee)}catch(e){return console.log("Error in getValueAtAddress calling function ".concat(Y," (address [").concat(t,"]): ").concat(e.message)),!1}}}}}])}();t.exports=i},{"../source/Manyfest-ParseConditionals.js":11,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-Parser.js":8}],8:[function(e,t,r){t.exports={stringCountSegments:function(e,t,r,s){var n="string"==typeof e?e:"",a="string"==typeof t?t:".",o="object"==_typeof(r)?pEnclosureStart:{"{":0,"[":1,"(":2},i="object"==_typeof(s)?pEnclosureEnd:{"}":0,"]":1,")":2};if(e.length<1)return 0;for(var c=1,l=[],u=0;u<n.length;u++)n[u]==a&&0==l.length?c++:n[u]in o?l.push(o[n[u]]):n[u]in i&&i[n[u]]==l[l.length-1]&&l.pop();return c},stringGetFirstSegment:function(e,t,r,s){var n="string"==typeof e?e:"",a="string"==typeof t?t:".",o="object"==_typeof(r)?pEnclosureStart:{"{":0,"[":1,"(":2},i="object"==_typeof(s)?pEnclosureEnd:{"}":0,"]":1,")":2};if(e.length<1)return 0;for(var c=[],l=0;l<n.length;l++){if(n[l]==a&&0==c.length)return n.substring(0,l);n[l]in o?c.push(o[n[l]]):n[l]in i&&i[n[l]]==c[c.length-1]&&c.pop()}return n},stringGetSegments:function(e,t,r,s){var n="string"==typeof e?e:"",a="string"==typeof t?t:".",o="object"==_typeof(r)?pEnclosureStart:{"{":0,"[":1,"(":2},i="object"==_typeof(s)?pEnclosureEnd:{"}":0,"]":1,")":2},c=0,l=[];if(e.length<1)return l;for(var u=[],f=0;f<n.length;f++)n[f]==a&&0==u.length?(l.push(n.substring(c,f)),c=f+1):n[f]in o?u.push(o[n[f]]):n[f]in i&&i[n[f]]==u[u.length-1]&&u.pop();return c<n.length&&l.push(n.substring(c)),l},stringCountEnclosures:function(e,t,r){for(var s="string"==typeof e?e:"",n="string"==typeof t?t:"(",a="string"==typeof r?r:")",o=0,i=0,c=0;c<s.length;c++)s[c]==n?(0==i&&o++,i++):s[c]==a&&i--;return o},stringGetEnclosureValueByIndex:function(e,t,r,s){for(var n="string"==typeof e?e:"",a="number"==typeof t?t:0,o="string"==typeof r?r:"(",i="string"==typeof s?s:")",c=0,l=0,u=!1,f=0,h=0,d=0;d<n.length;d++)n[d]==o?1==++l&&a==++c-1&&(u=!0,f=d):n[d]==i&&0==--l&&u&&h<=f&&(h=d,u=!1);return c<=a?"":h>0&&h>f?n.substring(f+1,h):n.substring(f+1)}}},{}],9:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=e("./Manyfest-CleanWrapCharacters.js"),a=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s,this.cleanWrapCharacters=n}),[{key:"setValueAtAddress",value:function(e,t,r){if("object"!=_typeof(e))return!1;if("string"!=typeof t)return!1;var s=t.indexOf(".");if(-1==s){var n=t.indexOf("["),a=t.indexOf("]");if(n>0&&a>n&&a-n>1){var o=t.substring(0,n).trim();if("object"!==_typeof(e[o]))return!1;var i=t.substring(n+1,a).trim(),c=parseInt(i,10);return Array.isArray(e[o])!=isNaN(c)&&(isNaN(c)?(i=this.cleanWrapCharacters('"',i),i=this.cleanWrapCharacters("`",i),i=this.cleanWrapCharacters("'",i),e[o][i]=r,!0):(e[o][c]=r,!0))}return e[t]=r,!0}var l=t.substring(0,s),u=t.substring(s+1),f=l.indexOf("["),h=l.indexOf("]");if(f>0&&h>f&&h-f>1){var d=l.substring(0,f).trim(),p=l.substring(f+1,h).trim(),g=parseInt(p,10);return Array.isArray(e[d])!=isNaN(g)&&(isNaN(g)?(p=this.cleanWrapCharacters('"',p),p=this.cleanWrapCharacters("`",p),p=this.cleanWrapCharacters("'",p),this.setValueAtAddress(e[d][p],u,r)):this.setValueAtAddress(e[d][g],u,r))}return l in e&&"object"!==_typeof(e[l])?("__ERROR"in e||(e.__ERROR={}),e.__ERROR[t]=r,!1):(l in e||(e[l]={}),this.setValueAtAddress(e[l],u,r))}}])}();t.exports=a},{"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],10:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s}),[{key:"generateAddressses",value:function(e,t,r){var s="string"==typeof t?t:"",n="object"==_typeof(r)?r:{},a=_typeof(e),o={Address:s,Hash:s,Name:s,InSchema:!1};switch("object"==a&&null==e&&(a="null"),a){case"string":o.DataType="String",o.Default=e,n[s]=o;break;case"number":case"bigint":o.DataType="Number",o.Default=e,n[s]=o;break;case"undefined":case"null":o.DataType="Any",o.Default=e,n[s]=o;break;case"object":if(Array.isArray(e)){o.DataType="Array",""!=s&&(n[s]=o);for(var i=0;i<e.length;i++)this.generateAddressses(e[i],"".concat(s,"[").concat(i,"]"),n)}else{o.DataType="Object",""!=s&&(n[s]=o,s+=".");for(var c=Object.keys(e),l=0;l<c.length;l++)this.generateAddressses(e[c[l]],"".concat(s).concat(c[l]),n)}}return n}}])}();t.exports=n},{"./Manyfest-LogToConsole.js":4}],11:[function(e,t,r){var s="<<~?",n="?~>>",a=function(e,t,r,s,n){switch(s){case"TRUE":return!0===e.getValueAtAddress(t,r);case"FALSE":return!1===e.getValueAtAddress(t,r);case"LNGT":case"LENGTH_GREATER_THAN":switch(_typeof(e.getValueAtAddress(t,r))){case"string":case"object":return e.getValueAtAddress(t,r).length>n;default:return!1}break;case"LNLT":case"LENGTH_LESS_THAN":switch(_typeof(e.getValueAtAddress(t,r))){case"string":case"object":return e.getValueAtAddress(t,r).length<n;default:return!1}break;case"!=":return e.getValueAtAddress(t,r)!=n;case"<":return e.getValueAtAddress(t,r)<n;case">":return e.getValueAtAddress(t,r)>n;case"<=":return e.getValueAtAddress(t,r)<=n;case">=":return e.getValueAtAddress(t,r)>=n;case"===":return e.getValueAtAddress(t,r)===n;default:return e.getValueAtAddress(t,r)==n}};t.exports=function(e,t,r){for(var o=!0,i=t.indexOf(s);-1!=i;){var c=t.indexOf(n,i+4);if(-1!=c){var l=t.substring(i+4,c).split(","),u=l[0],f="EXISTS";l.length>1&&(f=l[1]);var h=!1;l.length>2&&(h=l[2]),o=o&&a(e,r,u,f,h),i=t.indexOf(s,c+4)}else i=-1}return o}},{}],12:[function(e,t,r){var s=e("./Manyfest-LogToConsole.js"),n=function(){return _createClass((function e(t,r){_classCallCheck(this,e),this.logInfo="function"==typeof t?t:s,this.logError="function"==typeof r?r:s}),[{key:"resolveAddressMappings",value:function(e,t){if("object"!=_typeof(e))return this.logError("Attempted to resolve address mapping but the descriptor was not an object."),!1;if("object"!=_typeof(t))return!0;var r=Object.keys(e),s={};return r.forEach((function(t){"Hash"in e[t]&&(s[e[t].Hash]=t)})),Object.keys(t).forEach((function(r){var n=t[r],a=!1,o=!1;r in e?a=r:r in s&&(a=s[r]),a?(o=e[a],delete e[a]):o={Hash:r},e[n]=o})),!0}},{key:"safeResolveAddressMappings",value:function(e,t){var r=JSON.parse(JSON.stringify(e));return this.resolveAddressMappings(r,t),r}},{key:"mergeAddressMappings",value:function(e,t){if("object"!=_typeof(t)||"object"!=_typeof(e))return this.logError("Attempted to merge two schema descriptors but both were not objects."),!1;var r=JSON.parse(JSON.stringify(t)),s=JSON.parse(JSON.stringify(e));return Object.keys(r).forEach((function(e){e in s||(s[e]=r[e])})),s}}])}();t.exports=n},{"./Manyfest-LogToConsole.js":4}],13:[function(e,t,r){var s=e("fable-serviceproviderbase"),n=e("./Manyfest-LogToConsole.js"),a=e("./Manyfest-HashTranslation.js"),o=e("./Manyfest-ObjectAddress-CheckAddressExists.js"),i=e("./Manyfest-ObjectAddress-GetValue.js"),c=e("./Manyfest-ObjectAddress-SetValue.js"),l=e("./Manyfest-ObjectAddress-DeleteValue.js"),u=e("./Manyfest-ObjectAddressGeneration.js"),f=e("./Manyfest-SchemaManipulation.js"),h={Scope:"DEFAULT",Descriptors:{}},d=function(e){function t(e,r,s){var h;return _classCallCheck(this,t),(h=_callSuper(this,t,void 0===e?[{}]:[e,r,s])).serviceType="Manifest",h.logInfo=n,h.logError=n,h.objectAddressCheckAddressExists=new o(h.logInfo,h.logError),h.objectAddressGetValue=new i(h.logInfo,h.logError),h.objectAddressSetValue=new c(h.logInfo,h.logError),h.objectAddressDeleteValue=new l(h.logInfo,h.logError),"defaultValues"in h.options||(h.options.defaultValues={String:"",Number:0,Float:0,Integer:0,PreciseNumber:"0.0",Boolean:!1,Binary:0,DateTime:0,Array:[],Object:{},Null:null}),"strict"in h.options||(h.options.strict=!1),h.scope=void 0,h.elementAddresses=void 0,h.elementHashes=void 0,h.elementDescriptors=void 0,h.reset(),"object"===_typeof(h.options)&&h.loadManifest(h.options),h.schemaManipulations=new f(h.logInfo,h.logError),h.objectAddressGeneration=new u(h.logInfo,h.logError),h.hashTranslations=new a(h.logInfo,h.logError),h.numberRegex=/^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/,_assertThisInitialized(h)}return _inherits(t,e),_createClass(t,[{key:"reset",value:function(){this.scope="DEFAULT",this.elementAddresses=[],this.elementHashes={},this.elementDescriptors={}}},{key:"clone",value:function(){var e=JSON.parse(JSON.stringify(this.options)),r=new t(this.getManifest(),this.logInfo,this.logError,e);return r.hashTranslations.addTranslation(this.hashTranslations.translationTable),r}},{key:"deserialize",value:function(e){return this.loadManifest(JSON.parse(e))}},{key:"loadManifest",value:function(e){"object"!==_typeof(e)&&this.logError("(".concat(this.scope,") Error loading manifest; expecting an object but parameter was type ").concat(_typeof(e),"."));for(var t="object"==_typeof(e)?e:{},r=Object.keys(h),s=0;s<r.length;s++)r[s]in t||(t[r[s]]=JSON.parse(JSON.stringify(h[r[s]])));if("Scope"in t?"string"==typeof t.Scope?this.scope=t.Scope:this.logError("(".concat(this.scope,") Error loading scope from manifest; expecting a string but property was type ").concat(_typeof(t.Scope),"."),t):this.logError("(".concat(this.scope,') Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.'),t),"Descriptors"in t)if("object"===_typeof(t.Descriptors))for(var n=Object.keys(t.Descriptors),a=0;a<n.length;a++)this.addDescriptor(n[a],t.Descriptors[n[a]]);else this.logError("(".concat(this.scope,") Error loading description object from manifest object. Expecting an object in 'Manifest.Descriptors' but the property was type ").concat(_typeof(t.Descriptors),"."),t);else this.logError("(".concat(this.scope,') Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.'),t);if("HashTranslations"in t&&"object"===_typeof(t.HashTranslations))for(var o=0;o<t.HashTranslations.length;o++);}},{key:"serialize",value:function(){return JSON.stringify(this.getManifest())}},{key:"getManifest",value:function(){return{Scope:this.scope,Descriptors:JSON.parse(JSON.stringify(this.elementDescriptors)),HashTranslations:JSON.parse(JSON.stringify(this.hashTranslations.translationTable))}}},{key:"addDescriptor",value:function(e,t){return"object"===_typeof(t)?("Address"in t||(t.Address=e),e in this.elementDescriptors||this.elementAddresses.push(e),this.elementDescriptors[e]=t,this.elementHashes[e]=e,"Hash"in t?this.elementHashes[t.Hash]=e:t.Hash=e,!0):(this.logError("(".concat(this.scope,") Error loading object descriptor for address '").concat(e,"' from manifest object. Expecting an object but property was type ").concat(_typeof(t),".")),!1)}},{key:"getDescriptorByHash",value:function(e){return this.getDescriptor(this.resolveHashAddress(e))}},{key:"getDescriptor",value:function(e){return this.elementDescriptors[e]}},{key:"eachDescriptor",value:function(e){for(var t=Object.keys(this.elementDescriptors),r=0;r<t.length;r++)e(this.elementDescriptors[t[r]])}},{key:"checkAddressExistsByHash",value:function(e,t){return this.checkAddressExists(e,this.resolveHashAddress(t))}},{key:"checkAddressExists",value:function(e,t){return this.objectAddressCheckAddressExists.checkAddressExists(e,t)}},{key:"resolveHashAddress",value:function(e){var t=e in this.elementHashes,r=e in this.hashTranslations.translationTable;return t&&!r?this.elementHashes[e]:r&&this.hashTranslations.translate(e)in this.elementHashes?this.elementHashes[this.hashTranslations.translate(e)]:r?this.hashTranslations.translate(e):e}},{key:"getValueByHash",value:function(e,t){var r=this.getValueAtAddress(e,this.resolveHashAddress(t));return void 0===r&&(r=this.getDefaultValue(this.getDescriptorByHash(t))),r}},{key:"getValueAtAddress",value:function(e,t){if(""!=t.trim()){var r=this.objectAddressGetValue.getValueAtAddress(e,t);return void 0===r&&(r=this.getDefaultValue(this.getDescriptor(t))),r}this.logError("(".concat(this.scope,") Error getting value at address; address is an empty string."),e)}},{key:"setValueByHash",value:function(e,t,r){return this.setValueAtAddress(e,this.resolveHashAddress(t),r)}},{key:"setValueAtAddress",value:function(e,t,r){return this.objectAddressSetValue.setValueAtAddress(e,t,r)}},{key:"deleteValueByHash",value:function(e,t,r){return this.deleteValueAtAddress(e,this.resolveHashAddress(t),r)}},{key:"deleteValueAtAddress",value:function(e,t,r){return this.objectAddressDeleteValue.deleteValueAtAddress(e,t,r)}},{key:"validate",value:function(e){var t={Error:null,Errors:[],MissingElements:[]};"object"!==_typeof(e)&&(t.Error=!0,t.Errors.push("Expected passed in object to be type object but was passed in ".concat(_typeof(e))));for(var r=function(e,r){t.Error=!0,t.Errors.push('Element at address "'.concat(e,'" ').concat(r,"."))},s=0;s<this.elementAddresses.length;s++){var n=this.getDescriptor(this.elementAddresses[s]),a=this.checkAddressExists(e,n.Address),o=this.getValueAtAddress(e,n.Address);if(void 0!==o&&a||(t.MissingElements.push(n.Address),(n.Required||this.options.strict)&&r(n.Address,"is flagged REQUIRED but is not set in the object")),n.DataType){var i=_typeof(o);switch(n.DataType.toString().trim().toLowerCase()){case"string":"string"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));break;case"precisenumber":"string"!=i?r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i)):this.numberRegex.test(o)||r(n.Address,"has a DataType ".concat(n.DataType," but is not a valid number"));break;case"number":"number"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));break;case"integer":if("number"!=i)r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));else o.toString().indexOf(".")>-1&&r(n.Address,"has a DataType ".concat(n.DataType," but has a decimal point in the number."));break;case"float":"number"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(i));break;case"datetime":"Invalid Date"==new Date(o).toString()&&r(n.Address,"has a DataType ".concat(n.DataType," but is not parsable as a Date by Javascript"));default:"string"!=i&&r(n.Address,"has a DataType ".concat(n.DataType," (which auto-converted to String because it was unrecognized) but is of the type ").concat(i))}}}return t}},{key:"getDefaultValue",value:function(e){if("object"==_typeof(e)){if("Default"in e)return e.Default;var t="DataType"in e?e.DataType:"String";return t in this.options.defaultValues?this.options.defaultValues[t]:null}}},{key:"populateDefaults",value:function(e,t){return this.populateObject(e,t,(function(e){return"Default"in e}))}},{key:"populateObject",value:function(e,t,r){var s=this,n="object"===_typeof(e)?e:{},a=void 0!==t&&t,o="function"==typeof r?r:function(e){return!0};return this.elementAddresses.forEach((function(e){var t=s.getDescriptor(e);o(t)&&(!a&&s.checkAddressExists(n,e)||s.setValueAtAddress(n,e,s.getDefaultValue(t)))})),n}}])}(s);t.exports=d},{"./Manyfest-HashTranslation.js":3,"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-CheckAddressExists.js":5,"./Manyfest-ObjectAddress-DeleteValue.js":6,"./Manyfest-ObjectAddress-GetValue.js":7,"./Manyfest-ObjectAddress-SetValue.js":9,"./Manyfest-ObjectAddressGeneration.js":10,"./Manyfest-SchemaManipulation.js":12,"fable-serviceproviderbase":1}]},{},[13])(13)})); //# sourceMappingURL=manyfest.compatible.min.js.map