text: !function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.songo=r():t.songo=r()}(this,function(){return function(t){function r(e){if(i[e])return i[e].exports;var o=i[e]={exports:{},id:e,loaded:!1};return t[e].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var i={};return r.m=t,r.c=i,r.p="",r(0)}([function(t,r,i){"use strict";function e(t){return h.btoa?h.btoa(t):encodeURIComponent(t)}function o(t){t=decodeURIComponent(t);var r={};try{r=JSON.parse(t)}catch(i){r={}}return r}function n(t){return new c(t)}var s=i(1),u=i(3),p=i(4),a=i(2),h=this,c=function(){function t(t){void 0===t&&(t=a.DEFAULT_ENTITY),t.meta=t.meta||{},t.sort=t.sort||[],t.query=t.query||{},t.meta.page=void 0!==t.meta.page?t.meta.page:a.DEFAULT_PAGE,t.meta.limit=void 0!==t.meta.limit?t.meta.limit:a.DEFAULT_LIMIT,t.meta.skip=void 0!==t.meta.skip?t.meta.skip:a.DEFAULT_SKIP,this.meta=t.meta,this.sort=t.sort,this.query=t.query,this.parse()}return t.prototype.parse=function(){this.Meta=s.metaParser(this.meta),this.Sort=u.sortParser(this.sort),this.Query=p.queryParser(this.query)},Object.defineProperty(t.prototype,"string",{get:function(){return this.toString()},enumerable:!0,configurable:!0}),t.prototype.toQuery=function(){return this.toString()},t.prototype.toParams=function(){return this.parse(),{limit:this.Meta.limit,page:this.Meta.page,skip:this.Meta.skip,sort:this.Sort.normalize(),query:e(JSON.stringify(this.query))}},t.prototype.fromParams=function(t){var r=t.limit,i=t.page,e=t.skip,n=t.sort,s=t.query;return void 0!==r&&(this.meta.limit=r),void 0!==i&&(this.meta.page=i),void 0!==e&&(this.meta.skip=e),void 0!==n&&(this.sort="string"==typeof n?n.split(","):Array.isArray(n)?n:[]),void 0!==s&&(this.query=o(s)),this},t.prototype.toString=function(){return this.parse(),[this.Meta,this.Sort,this.Query].filter(function(t){return t+""}).join("&")},t.prototype.clearSort=function(){return this.sort=[],this.parse(),this},t.prototype.indexSort=function(t){return this.sort.map(function(t){return t.replace(/^[\-\+]/,"")}).indexOf(t.replace(/^[\-\+]/,""))},t.prototype.onlySort=function(t){return this.sort=[t],this.parse(),this},t.prototype.setSort=function(t){var r=this.indexSort(t);return r>=0?(this.sort.splice(r,1),this.unshiftSort(t)):this.unshiftSort(t),this.parse(),this},t.prototype.unshiftSort=function(t){var r=this.indexSort(t);return r>=0&&this.sort.splice(r,1),this.sort.unshift(t),this.parse(),this},t.prototype.removeSort=function(t){var r=this.indexSort(t);return r>=0&&this.sort.splice(r,1),this.parse(),this},t.prototype.pushSort=function(t){var r=this.indexSort(t);return r>=0&&this.sort.splice(r,1),this.sort.push(t),this.parse(),this},t.prototype.popSort=function(){return this.sort.pop(),this.parse(),this},t.prototype.shiftSort=function(){return this.sort.shift(),this.parse(),this},t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=n},function(t,r,i){"use strict";function e(t){void 0===t&&(t={limit:o.DEFAULT_LIMIT,page:o.DEFAULT_PAGE,skip:o.DEFAULT_SKIP});var r=t.limit||o.DEFAULT_LIMIT,i=t.page||o.DEFAULT_PAGE,e=t.skip||o.DEFAULT_SKIP;return new n(r,i,e)}var o=i(2),n=function(){function t(t,r,i){this.limit=t,this.page=r,this.skip=i,this._limit=t,this._page=r,this._skip=i}return t.prototype.toString=function(){return"_limit="+this.limit+"&_page="+this.page+"&_skip="+this.skip},t.prototype.toJson=function(t,r){return JSON.stringify(this.toObject(),t,r)},t.prototype.toObject=function(){return{_limit:this._limit,_page:this._page,_skip:this._skip}},t}();r.metaParser=e},function(t,r){"use strict";var i={};r.DEFAULT_QUERY=i;var e="";r.DEFAULT_SORT=e;var o=10;r.DEFAULT_LIMIT=o;var n=0;r.DEFAULT_PAGE=n;var s=0;r.DEFAULT_SKIP=s;var u={query:i,sort:[],limit:o,page:n,skip:s};r.DEFAULT_ENTITY=u},function(t,r){"use strict";function i(t){return void 0===t&&(t=[]),t=t.length?t:[],new e(t)}r.sortParser=i;var e=function(){function t(t){var r=this;this.sortArray=t,Array.isArray(t)&&t.length&&t.forEach(function(t,i){return r[i]=t})}return t.prototype.normalize=function(){return this.sortArray.map(function(t){return t.replace(/^\+/,"")}).join(",")},t.prototype.toString=function(){return"_sort="+this.normalize()},t}()},function(t,r){"use strict";function i(t,r,i){if(void 0===i&&(i={}),void 0!==r&&null!==r&&""!==r){var e=t.match(/((?=\$)?[^\$]+(?=\$))/gi),o=e.length>1?e.slice(0,e.length-1):[],n=e[e.length-1],s=t.match(/((?=\$)?\w+(?!=\$))$/i)[1],u=o.length?"$"+o.join("$")+"$":"";return i[""+u+s]=i[""+u+s]||[],i[""+u+s].push("$"+n+"$"+r),i}}function e(t,r){if(t&&Object.keys(t))for(var i in t)t.hasOwnProperty(i)&&"function"==typeof r&&r.call(t,t[i],i,t)}function o(t){return void 0===t&&(t={}),new n(t)}r.queryParser=o;var n=function(){function t(t){this.queryObject=t,this.query={},this.object={},this.parse(t)}return t.prototype.parse=function(t){var r=this;e(t,function(t,e){/^\$[^\$]{2}\$/.test(e)&&i(e,t,r.object)}),e(this.object,function(t,i){r.query[i]=t.sort().join(",")})},Object.defineProperty(t.prototype,"string",{get:function(){return this.toString()},enumerable:!0,configurable:!0}),t.prototype.toJson=function(t,r){return JSON.stringify(this.toObject(),t,r)},t.prototype.toObject=function(){return this.object},t.prototype.toString=function(){var t=[];return e(this.query,function(r,i){t.push(i+"="+r)}),t.sort(),t.join("&")},t}()}])});