text: !function(a){"use strict";function b(a){return a=a||"",/\/$/.test(a)?a:a+="/"}var c=a.module("ng.cork.api.client",["ng.cork.util","ng.cork.deep.extend"]),d=a.copy,e=a.isString,f=a.isFunction;c.factory("CorkApiClient",["$injector","$http","corkUtil","corkDeepExtend",function(a,c,g,h){function i(a,b){return/^(http[s]?:)?\/\//.test(b)||(/^\//.test(b)&&(b=b.substring(1)),b=a+b),b}var j=g.isInjectable,k={baseUrl:"/"},l=function(g){var l=this;g=h(d(k),g||{}),g.baseUrl=b(g.baseUrl);var m={};l.middleware=function(a,b){if(!e(a))throw new Error("Invalid middleware name.");if(arguments.length>1){if(m[a])throw new Error('Middleware "'+a+'" is already registered.');if(!f(b)&&!j(b))throw new Error('Invalid middleware "'+a+'".');return m[a]=b,this}if(!m[a])throw new Error('Unknown middleware "'+a+'".');return m[a]};var n={},o={};l.service=function(b,c){if(!e(b))throw new Error("Invalid service name.");if(arguments.length>1){if(n[b])throw new Error('Service "'+b+'" is already registered.');if(e(c))n[b]=function(){return a.get(b)};else{if(!f(c))throw new Error('Invalid factory or configuration for service "'+b+'".');n[b]=c}return this}if(!o[b]){if(!n[b])throw new Error('Unknown service "'+b+'".');o[b]=n[b]()}return o[b]},l.execute=function(a){var b=f(a.url)?a.url(a):a.url;return b=b||"",a.url=i(g.baseUrl,b),c(a)},Object.defineProperty(this,"baseUrl",{get:function(){return g.baseUrl}})};return l}])}(angular),function(a){"use strict";var b=a.module("ng.cork.api.request",["ng.cork.util","ng.cork.deep.obj"]),c=a.copy,d=(a.isObject,["method","url","params","data","headers","xsrfHeaderName","xsrfCookieName","transformRequest","transformResponse","cache","timeout","withCredentials","responseType"]);b.factory("CorkApiRequest",["CorkDeepObj",function(a){var b=function(b){a.call(this,b)};return b.prototype=Object.create(a.prototype),b.prototype.constructor=b,Object.defineProperty(b.prototype,"config",{get:function(){var a={};for(var b in this)-1!==d.indexOf(b)&&(a[b]=c(this[b]));return a}}),b}])}(angular),function(a){"use strict";{var b=a.module("ng.cork.api.service",["ng.cork.util","ng.cork.deep.extend","ng.cork.api.request"]),c=a.copy,d=a.isString,e=a.isFunction;a.isObject}b.factory("CorkApiService",["$q","$http","corkUtil","corkDeepExtend","CorkApiRequest",function(b,f,g,h,i){function j(a,b){var c,d,e,f=b||{},g=a.replace(/(\/)?:(\w+)(\?|\*)?/g,function(b,g,h,i){if(c=f.hasOwnProperty(h),"?"!==i&&!c)throw new Error('Missing parameter "'+h+'" when compiling URL for pattern "'+a+'".');return d=":"+h,"?"===i?(d+="\\?",c&&f[h]||(d="/"+d)):"*"===i&&(d+="\\*"),e=c&&f[h]||"",b.replace(new RegExp(d),e)});return g}function k(a,c,d,e){function f(a){i<j.length?(g="request"===c?j[i](d):j[i](d,a),b.all([g]).then(function(b){"request"===c&&"undefined"!=typeof b[0]?h.resolve(b[0]):"error"===c&&n(g)&&"undefined"!=typeof b[0]?h.resolve(b[0]):f("undefined"!=typeof b[0]?b[0]:a)},function(b){"error"===c?f("undefined"!=typeof b?b:a):h.reject(b)}),i++):"error"===c?h.reject(a):h.resolve(a)}var g,h=b.defer(),i=0,j=a[c];return f(e),h.promise}function l(a,b,c){if(b.hasOwnProperty("url")&&!d(b.url)&&!e(b.url))throw new Error('Invalid url for service method "'+a+'".');if(b.hasOwnProperty("pattern")&&!d(b.pattern))throw new Error('Invalid pattern for service method "'+a+'".');if(!d(b.verb))throw new Error('Invalid verb for service method "'+a+'".')}function m(c,d,f){function g(a){var c=a.config;return c.method=f.verb,c.url=c.url||f.url,e(c.url)?c.url=c.url(c):c.url||(c.url=j(f.pattern,a.urlParams)),d(c).then(function(b){return k(f,"success",a,b)},function(c){return k(f,"error",a,c).then(function(a){return a},function(a){return b.reject(a)})})}return f.args=f.args||a.noop,f.request=f.request||[],f.success=f.success||[],f.error=f.error||[],function(){var a=Array.prototype.slice.call(arguments),b=new c(f.config);return b.replay=function(a){return h(b,a),g(b)},a.unshift(b),f.args.apply(null,a),k(f,"request",b).then(function(a){return a?a:g(b)})}}var n=g.isPromise,o=function(a){var b=this,d=c(a);if(d.execute=d.execute||f,!e(d.execute))throw new Error('Invalid execute fn for service "'+b.name+'".');b.addMethod=function(a,e){if(!g.isObjectObject(e))throw new Error('Invalid options for service method "'+a+'".');var f=d.all?c(d.all):{};e=h(f,e),l(a,e),Object.defineProperty(b,a,{value:m(i,d.execute,e)})};var j=d.methods||{};for(var k in j)b.addMethod(k,j[k]);Object.defineProperty(b,"name",{get:function(){return d.name}})};return o}])}(angular),function(a){"use strict";a.module("ng.cork.api",["ng.cork.api.client","ng.cork.api.request","ng.cork.api.service"])}(angular);