text: "use strict";var formsAngular=angular.module("formsAngular",["ngRoute","ui.router","ngSanitize","ui.select2","ui.date","ui.bootstrap","ngGrid","infinite-scroll","monospaced.elastic","textAngular","uploadModule","ui.bootstrap.datetimepicker"]);
  "use strict";formsAngular.controller("AnalysisCtrl",["$locationParse","$filter","$scope","$http","$location","$routeParams","urlService",function(e,t,a,r,n,l,i){var o=!0,s=new ngGridPdfExportPlugin({inhibitButton:!0}),c=new ngGridCsvExportPlugin({inhibitButton:!0});if(angular.extend(a,l),a.reportSchema={},a.gridOptions={columnDefs:"reportSchema.columnDefs",data:"report",showColumnMenu:!0,showFilter:!0,showFooter:!0,reallyShowFooter:!0,showTotals:!0,enableColumnResize:!0,footerRowHeight:65,multiSelect:!1,plugins:[s,c],afterSelectionChange:function(e){var t=a.reportSchema.drilldown;t&&(t=i.buildUrl(t.replace(/\|.+?\|/g,function(t){var r=t.slice(1,-1),n=/\((.+)\)/.exec(r);return n?a.reportSchema.params[n[1]].value:e.entity[r]})),window.location=t)},footerTemplate:'<div ng-show="gridOptions.reallyShowFooter" class="ngFooterPanel" ng-class="{\'ui-widget-content\': jqueryUITheme, \'ui-corner-bottom\': jqueryUITheme}" ng-style="footerStyle()"><div ng-show="gridOptions.showTotals" ng-style="{height: rowHeight+3}"><div ng-style="{ \'cursor\': row.cursor }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell ngTotalCell {{col.cellClass}}"><div class="ngVerticalBar" ng-style="{height: rowHeight}" ng-class="{ ngVerticalBarVisible: !$last }">&nbsp;</div><div ng-total-cell></div> </div></div><div class="ngTotalSelectContainer" ><div class="ngFooterTotalItems" ng-class="{\'ngNoMultiSelect\': !multiSelect}" ><span class="ngLabel">{{i18n.ngTotalItemsLabel}} {{maxRows()}}</span><span ng-show="filterText.length > 0" class="ngLabel">({{i18n.ngShowingItemsLabel}} {{totalFilteredItemsLength()}})</span></div><div class="ngFooterSelectedItems" ng-show="multiSelect">  <span class="ngLabel">{{i18n.ngSelectedItemsLabel}} {{selectedItems.length}}</span></div></div><div class="ngPagerContainer" style="float: right; margin-top: 10px;" ng-show="enablePaging" ng-class="{\'ngNoMultiSelect\': !multiSelect}"><div style="float:left; margin-right: 10px;" class="ngRowCountPicker"><span style="float: left; margin-top: 3px;" class="ngLabel">{{i18n.ngPageSizeLabel}}</span><select style="float: left;height: 27px; width: 100px" ng-model="pagingOptions.pageSize" ><option ng-repeat="size in pagingOptions.pageSizes">{{size}}</option></select></div><div style="float:left; margin-right: 10px; line-height:25px;" class="ngPagerControl" style="float: left; min-width: 135px;"><button class="ngPagerButton" ng-click="pageToFirst()" ng-disabled="cantPageBackward()" title="{{i18n.ngPagerFirstTitle}}"><div class="ngPagerFirstTriangle"><div class="ngPagerFirstBar"></div></div></button><button class="ngPagerButton" ng-click="pageBackward()" ng-disabled="cantPageBackward()" title="{{i18n.ngPagerPrevTitle}}"><div class="ngPagerFirstTriangle ngPagerPrevTriangle"></div></button><input class="ngPagerCurrent" min="1" max="{{maxPages()}}" type="number" style="width:50px; height: 24px; margin-top: 1px; padding: 0 4px;" ng-model="pagingOptions.currentPage"/><button class="ngPagerButton" ng-click="pageForward()" ng-disabled="cantPageForward()" title="{{i18n.ngPagerNextTitle}}"><div class="ngPagerLastTriangle ngPagerNextTriangle"></div></button><button class="ngPagerButton" ng-click="pageToLast()" ng-disabled="cantPageToLast()" title="{{i18n.ngPagerLastTitle}}"><div class="ngPagerLastTriangle"><div class="ngPagerLastBar"></div></div></button></div></div></div>'},a.report=[],!a.reportSchemaName&&l.r)switch(l.r.slice(0,1)){case"[":a.reportSchema.pipeline=JSON.parse(l.r);break;case"{":angular.extend(a.reportSchema,JSON.parse(l.r));break;default:throw new Error("No report instructions specified")}a.getTotalVal=function(e,r){var n="",l=_.find(a.reportSchema.columnDefs,function(t){return t.field===e});if(l)switch(l.totalsRow){case void 0:break;case"$SUM":for(var i=0,o=0;o<a.report.length;o++)i+=a.report[o][e];n=i,r&&(n=t(r)(n));break;default:n=l.totalsRow}return n},a.$on("exportToPDF",function(){s.createPDF()}),a.$on("exportToCSV",function(){c.createCSV()}),a.refreshQuery=function(){var e="/api/report/"+a.model,l="?";if(a.reportSchemaName&&(e+="/"+a.reportSchemaName),a.paramSchema){for(var i in a.record)if(a.record.hasOwnProperty(i)){var s=a.reportSchema.params[i];if(a.record[i]&&""!==a.record[i])a.param=a.record[i],s.conversionExpression&&(a.param=a.$eval(s.conversionExpression)),e+=l+i+"="+a.param,l="&";else if(s.required)return}}else{var c=n.$$url.match(/\?.*/);c&&(e+=l+c[0].slice(1))}r.get(e).success(function(e){if(e.success){if(a.report=e.report,a.reportSchema=e.schema,a.reportSchema.title=a.reportSchema.title||a.model,o&&(o=!1,a.$watch("reportSchema.columnDefs",function(e){var t=!1;if(e)for(var r=0;r<e.length;r++)if(e[r].totalsRow&&(t=!0),e[r].align){var n="fng-"+e[r].align;e[r].cellClass=e[r].cellClass||"",-1===e[r].cellClass.indexOf(n)&&(e[r].cellClass=e[r].cellClass+" "+n)}a.gridOptions.showTotals=t,a.gridOptions.reallyShowFooter=t,a.gridOptions.footerRowHeight=55+(t?10:0)},!0),!a.paramSchema&&e.schema.params)){a.paramSchema=[],a.record={};for(var r in e.schema.params)if(e.schema.params.hasOwnProperty(r)){var n=e.schema.params[r];if(!n.noInput){var l=a.paramSchema.push({name:r,id:"fp_"+r,label:n.label||t("titleCase")(r),type:n.type||"text",required:!0,add:n.add||void 0,size:n.size||"small"});"select"===n.type&&(a[r+"_Opts"]=n.enum,a.paramSchema[l-1].options=r+"_Opts")}var i=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3})(Z|[+ -]\d{4})$/.exec(n.value);i&&(n.value=moment(i[1]).format("YYYY-MM-DDTHH:mm:ss.SSS")+"Z"),a.record[r]=n.value}a.$watch("record",function(e,t){t!==e&&a.refreshQuery()},!0)}}else console.log(JSON.stringify(e)),a.reportSchema.title="Error - see console log"}).error(function(e){console.log(JSON.stringify(e)),n.path("/404")})},a.refreshQuery()}]);
  "use strict";formsAngular.controller("BaseCtrl",["$scope","$routeParams","$location","$http","$filter","$data","$locationParse","$modal","$window","urlService","$state","$stateParse","fileUpload","$route",function(e,t,n,a,r,o,i,s,l,c,d,u,f,m){function p(e,t,n){var a="#"+(n?"cg_":"")+t;e?$(a).removeClass(N):$(a).addClass(N)}function h(){var n="?l="+e.pageSize,a=function(e,t){t&&""!==t&&(n+="&"+e+"="+t)};return a("f",t.f),a("a",t.a),a("o",t.o),a("s",e.pagesLoaded*e.pageSize),e.pagesLoaded++,n}function v(e){var t=e.split("."),n=[t[0]];return t.length>1&&n.push(t.slice(1).join(".")),n}function g(e,t,n){var a=v(e);if(a.length>1)b(a[1],t[a[0]],n);else if(t[a[0]]){var r=t[a[0]];t[a[0]]=n(r)}}function b(e,t,n){if(void 0!==t)if($.isArray(t))for(var a=0;a<t.length;a++)g(e,t[a],n);else g(e,t,n)}function y(e,t,n,a){if(e.array){for(var r=[],o=0;o<t.length;o++)r.push({x:R(t[o],a,n,e.name)});return r}return e.select2?{id:t,text:R(t,a,n,e.name)}:R(t,a,n,e.name)}function w(e,t,n,a){if(e.array){for(var r=[],o=0;o<t.length;o++)r.push(T(t[o],n,a,e.name));return r}return T(t,n,a,e.name)}var D={},N="fng-invalid-required",S=o,L=!0;S.baseScope=e,e.record=S.record,e.phase="init",e.disableFunctions=S.disableFunctions,e.dataEventFunctions=S.dataEventFunctions,e.topLevelFormName=void 0,e.formSchema=[],e.tabs=[],e.listSchema=[],e.recordList=[],e.dataDependencies={},e.select2List=[],e.pageSize=20,e.pagesLoaded=0,e.filequeue=f.fieldData,e.$watchCollection("filequeue",function(t){t&&angular.isArray(t.file)&&!e.files&&(e.files=f.fieldData.file,e.$watchCollection("files",function(t,n){e[e.topLevelFormName]&&(_.isEqual(t,n)||(e[e.topLevelFormName].$pristine=!1))}))}),d&&d.params&&d.params.model?angular.extend(e,u(d)):angular.extend(e,i(n.$$path)),e.formPlusSlash=e.formName?e.formName+"/":"",e.modelNameDisplay=S.modelNameDisplay||r("titleCase")(e.modelName),e.generateEditUrl=function(t){return c.buildUrl(e.modelName+"/"+e.formPlusSlash+t._id+"/edit")},e.generateNewUrl=function(t){return t=t||e.modelName,c.buildUrl(t+"/new")},e.generateListUrl=function(t){return t=t||e.modelName,c.buildUrl(t)},e.go=function(e,t){d.go(e,t)},e.getId=function(e){return e._id},e.walkTree=function(e,t,n){for(var a=t.split("."),r=a.length-1,o=e,i=0;r>i&&(o=o[a[i]],angular.isArray(o)&&(o=o[n.scope().$index]),o);i++);return{lastObject:o,key:o?a[r]:void 0}},e.getData=function(t,n,a){var r=e.walkTree(t,n,a);return r.lastObject&&r.key?r.lastObject[r.key]:void 0},e.setData=function(t,n,a,r){var o=e.walkTree(t,n,a);o.lastObject[o.key]=r};var x=function(e,t){return(e.id||"f_"+e.name).replace(/\./g,"_")+t},C=function(t,r,o){var i;if(r.caster&&(t.array=!0,r=r.caster,$.extend(o,r.options)),"String"===r.instance)o.enum?(t.type=t.type||"select",o.required&&(e.$watch("record."+t.name,function(e){p(e,t.id,t.select2)},!0),setTimeout(function(){p(e.record[t.name],t.id,t.select2)},0)),t.select2?(e["select2"+t.name]={allowClear:!o.required,initSelection:function(e,t){t(e.select2("data"))},query:function(e){for(var t={results:[]},n=e.term.toUpperCase(),a=0;a<o.enum.length;a++)-1!==o.enum[a].toUpperCase().indexOf(n)&&t.results.push({id:a,text:o.enum[a]});e.callback(t)}},_.extend(e["select2"+t.name],t.select2),t.select2.s2query="select2"+t.name,e.select2List.push(t.name)):(t.options=x(t,"Options"),e[t.options]=o.enum)):(t.type||(t.type=-1!==t.name.toLowerCase().indexOf("password")?"password":"text"),o.match&&(t.add='pattern="'+o.match+'" '+(t.add||"")));else if("ObjectID"===r.instance)t.ref=o.ref,t.link&&t.link.linkOnly?(t.type="link",t.linkText=t.link.text,t.form=t.link.form,delete t.link):(t.type="select",t.select2?(e.select2List.push(t.name),t.select2.fngAjax?(i="ajax"+t.name.replace(/\./g,""),e[i]={allowClear:!o.required,minimumInputLength:2,initSelection:function(r,i){var s=r.val();s&&""!==s&&a.get("/api/"+o.ref+"/"+s+"/list").success(function(a){a.success===!1&&n.path("/404");var o={id:s,text:a.list};e.setData(D,t.name,r,o);var l=r.inheritedData("$ngModelController"),c=l.$pristine;c&&(l.$pristine=!1),i(o),c&&(l.$pristine=!0)}).error(function(){n.path("/404")})},ajax:{url:"/api/search/"+o.ref,data:function(e,t){return{q:e,pageLimit:10,page:t}},results:function(e){return{results:e.results,more:e.moreCount>0}}}},_.extend(e[i],t.select2),t.select2.fngAjax=i):(t.select2===!0&&(t.select2={}),e["select2"+t.name]={allowClear:!o.required,initSelection:function(n,a){var r=n.val();if(""!==r&&e[t.ids].length>0){var o=R(r,e[t.ids],e[t.options],t.name),i={id:r,text:o};a(i)}},query:function(n){for(var a={results:[]},r=n.term.toUpperCase(),o=0;o<e[t.options].length;o++)-1!==e[t.options][o].toUpperCase().indexOf(r)&&a.results.push({id:e[t.ids][o],text:e[t.options][o]});n.callback(a)}},_.extend(e["select2"+t.name],t.select2),t.select2.s2query="select2"+t.name,e.select2List.push(t.name),t.options=x(t,"Options"),t.ids=x(t,"_ids"),M(o.ref,t))):(t.options=x(t,"Options"),t.ids=x(t,"_ids"),M(o.ref,t)));else if("Date"===r.instance)t.type||(t.type=t.readonly?"text":"datetime");else if("boolean"===r.instance)t.type="checkbox";else if("fileuploader"===o.form.type)o.form.name&&(e.filequeue.file=e.record.file,e.$watchCollection("filequeue."+o.form.name,function(t){e.record[o.form.name]=t}),e.$watchCollection("record."+o.form.name,function(t){e.filequeue[o.form.name]=t}));else if("Number"===r.instance)t.type="number",o.min&&(t.add='min="'+o.min+'" '+(t.add||"")),o.max&&(t.add='max="'+o.max+'" '+(t.add||"")),t.step&&(t.add='step="'+t.step+'" '+(t.add||""));else{if("file"!==r.instance)throw new Error("Field "+t.name+" is of unsupported type "+r.instance);t.type="fileuploader"}return o.required&&(t.required=!0),o.readonly&&(t.readonly=!0),t},F=function(e,t,n){return t.name=n+e,t},E=function(e,t,n){var a=t||{hidden:!0};a.hidden||("object"==typeof a?(a.name=n,e.push(a)):e.push({name:n}))},k=function(e,t,n,a){if(n){for(var r=0,o=n.length;o>r;r++)if("text"===n[r].type){t.push({name:n[r].name});break}0===t.length&&0!==n.length&&t.push({name:n[0].name})}if(0===t.length){for(var i in a)if("_id"!==i&&a.hasOwnProperty(i)){t.push({name:i});break}if(0===t.length)throw new Error("Unable to generate a title for "+e)}},O=function(t,n){function a(t){var a=t;if("string"==typeof t&&"$"===t.slice(0,1)){var r=t.split(".");switch(r.length){case 1:a=e.getListData(n,t.slice(1));break;case 2:a=e.getListData(n,r[1]);break;default:throw new Error("Unsupported showIf format")}}return a}var r,o=a(t.lhs),i=a(t.rhs);switch(t.comp){case"eq":r=o===i;break;case"ne":r=o!==i;break;default:throw new Error("Unsupported comparator "+t.comp)}return r},q=function(t,n){function a(t){if("string"==typeof t&&"$"===t.slice(0,1)){var a=t.slice(1),o=e.dataDependencies[a]||[];o.push(n),e.dataDependencies[a]=o,r+=1}}var r=0,o=!0;return t&&(a(t.lhs),a(t.rhs),0!==r||O(t)||(o=!1)),o};e.getListData=function(t,n){for(var a=n.split("."),r=0;r<a.length;r++)void 0!==t&&(t=t[a[r]]);return t&&-1!==e.select2List.indexOf(a[r-1])&&(t=t.text),void 0===t&&(t=""),t},e.updateDataDependentDisplay=function(t,n,a){var r,o,i,s,l,c;for(var d in e.dataDependencies)if(e.dataDependencies.hasOwnProperty(d)){var u=d.split(".");if(1===u.length){if(a||!n||t[d]!==n[d])for(r=e.dataDependencies[d],o=0;o<r.length;o+=1){var f=r[o];for(i=0;i<e.formSchema.length;i+=1)e.formSchema[i].name===f&&(l=angular.element("#cg_"+e.formSchema[i].id),O(e.formSchema[i].showIf,t)?l.removeClass("ng-hide"):l.addClass("ng-hide"))}}else{if(2!==u.length)throw new Error("You can only go down one level of subdocument with showIf");if(void 0===c&&(c=!0),t[u[0]])for(s=0;s<t[u[0]].length;s++)if(a||!n||!n[u[0]]||!n[u[0]][s]||t[u[0]][s][u[1]]!==n[u[0]][s][u[1]])for(r=e.dataDependencies[d],o=0;o<r.length;o+=1){var m=r[o].split(".");if(2!==m.length)throw new Error("Conditional display must control dependent fields at same level ");for(i=0;i<e.formSchema.length;i+=1)if(e.formSchema[i].name===m[0])for(var p=e.formSchema[i].schema,h=0;h<p.length;h++)p[h].name===r[o]&&(l=angular.element("#f_"+m[0]+"List_"+s+" #cg_f_"+r[o].replace(".","_")),0===l.length?l=angular.element("#f_elements-"+s+"-"+m[1]):c=!1,l.length>0&&(O(e.formSchema[i].schema[h].showIf,t[u[0]][s])?l.show():l.hide()))}}}return c};var U=function(t,n,a,r,o,i){function s(t,n){var a=angular.copy(t),r=_.find(e.tabs,function(e){return e.title===a});if(!r){if(0===e.tabs.length&&e.formSchema.length>0){e.tabs.push({title:"Main",content:[]}),r=e.tabs[0];for(var o=0;o<e.formSchema.length;o++)r.content.push(e.formSchema[o])}r=e.tabs[e.tabs.push({title:a,containerType:"tab",content:[]})-1]}r.content.push(n)}for(var l in n)if("_id"!==l&&n.hasOwnProperty(l)){var c=n[l],d=c.options||{},u=d.form||{};if(!u.hidden)if(c.schema){if(i&&a){var f=[];U("Nested "+l,c.schema,f,null,l+".",!0);var m=F(l,u,o);m.schema=f,u.tab&&s(u.tab,m),void 0!==u.order?a.splice(u.order,0,m):a.push(m)}}else{if(a){var p=F(l,u,o);if(q(p.showIf,p.name)&&"options"!==l){var h=C(p,c,d);h.tab&&s(h.tab,h),void 0!==u.order?a.splice(u.order,0,h):a.push(h)}}r&&E(r,d.list,l)}}r&&0===r.length&&k(t,r,a,n)};e.processServerData=function(t){D=P(e.formSchema,t,0),e.phase="ready",e.cancel()},e.readRecord=function(){a.get("/api/"+e.modelName+"/"+e.id).success(function(t){e.buildSchema(),t.success===!1&&n.path("/404"),L=!1,e.phase="reading","function"==typeof e.dataEventFunctions.onAfterRead&&e.dataEventFunctions.onAfterRead(t),e.processServerData(t)}).error(function(){n.path("/404")})},e.indexOf=function(e,t){return _.indexOf(e,t)},e.scrollTheList=function(){e.buildSchema(),a.get("/api/"+e.modelName+h()).success(function(t){if(angular.isArray(t)){e.recordList=e.recordList.concat(t);for(var n in e.recordList)e.recordList[n].__unique_name=e.getListData(e.recordList[n],e.listSchema[0].name)}else e.showError(t,"Invalid query")}).error(function(){n.path("/404")})},e.buildSchema=function(){a.get("/api/schema/"+e.modelName+(e.formName?"/"+e.formName:""),{cache:!0}).success(function(t){if(U("Main "+e.modelName,t,e.formSchema,e.listSchema,"",!0),e.id||e.newRecord){var n=!0;e.$watch("record",function(t,a){t!==a&&(n=e.updateDataDependentDisplay(t,a,n))},!0),e.id?"function"==typeof e.dataEventFunctions.onBeforeRead&&e.dataEventFunctions.onBeforeRead(e.id,function(t){t&&e.showError(t)}):(D={},e.phase="ready",e.cancel())}else L=!0}).error(function(){n.path("/404")})},c.modelPage.test(n.path())?e.readRecord():c.newRecord.test(n.path())&&e.buildSchema(),e.setPristine=function(){e.dismissError(),e[e.topLevelFormName]&&e[e.topLevelFormName].$setPristine()},e.cancel=function(){for(var t in e.record)e.record.hasOwnProperty(t)&&delete e.record[t];$.extend(!0,e.record,D),e.setPristine()},e.$on("showErrorMessage",function(t,n){e.showError(n.body,n.title)});var I=function(t,n){if(-1!==[200,400].indexOf(n)){var a="";for(var o in t.errors)if(t.errors.hasOwnProperty(o)){switch(a+="<li><b>"+r("titleCase")(o)+": </b> ",t.errors[o].type){case"enum":a+="You need to select from the list of values";break;default:a+=t.errors[o].message}a+="</li>"}a=a.length>0?t.message+"<br /><ul>"+a+"</ul>":t.message||"Error!  Sorry - No further details available.",e.showError(a)}else e.showError(n+" "+JSON.stringify(t))};e.showError=function(t,n){e.alertTitle=n?n:"Error!",e.errorMessage=t},e.dismissError=function(){delete e.errorMessage},e.createNew=function(t,r){a.post("/api/"+e.modelName,t).success(function(t){t.success!==!1?("function"==typeof e.dataEventFunctions.onAfterCreate&&e.dataEventFunctions.onAfterCreate(t),r.redirect?l.location=r.redirect:d&&d.params&&d.params.model?d.go("model::edit",{id:t._id,model:e.modelName}):n.path(e.generateEditUrl(t))):e.showError(t)}).error(I)},e.updateDocument=function(t){e.phase="updating",a.post("/api/"+e.modelName+"/"+e.id,t).success(function(t){t.success!==!1?(e.setPristine(),m.reload()):e.showError(t)}).error(I)},e.save=function(t){t=t||{};var n=j(e.formSchema,angular.copy(e.record),0);e.id?"function"==typeof e.dataEventFunctions.onBeforeUpdate?e.dataEventFunctions.onBeforeUpdate(n,D,function(a){a?e.showError(a):e.updateDocument(n,t)}):e.updateDocument(n,t):"function"==typeof e.dataEventFunctions.onBeforeCreate?e.dataEventFunctions.onBeforeCreate(n,function(a){a?e.showError(a):e.createNew(n,t)}):e.createNew(n,t)},e.new=function(){n.search(""),c.newRecord.test(n.path())&&(e.record={}),n.path(e.generateNewUrl())},e.deleteRecord=function(t,r){a.delete("/api/"+t+"/"+r).success(function(){"function"==typeof e.dataEventFunctions.onAfterDelete&&e.dataEventFunctions.onAfterDelete(D);for(var t in e.recordList)e.recordList[t]._id===r&&e.recordList.splice(t,1);n.path(e.generateListUrl())})},e.$on("$stateChangeStart",function(t,n,a){if(!L&&!e.isCancelDisabled()){t.preventDefault();var r=s.open({template:'<div class="modal-header">   <h3>Record modified</h3></div><div class="modal-body">   <p>Would you like to save your changes?</p></div><div class="modal-footer">    <button class="btn btn-primary dlg-yes" ng-click="yes()">Yes</button>    <button class="btn btn-warning dlg-no" ng-click="no()">No</button>    <button class="btn dlg-cancel" ng-click="cancel()">Cancel</button></div>',controller:"SaveChangesModalCtrl",backdrop:"static"});r.result.then(function(t){t?(L=!0,e.save({stateChange:n,stateParams:a,allowChange:!0}),d.go(n,a)):(e.record={},L=!0,d.go(n,a))})}}),e.$on("$locationChangeStart",function(t,n){if(!L&&!e.isCancelDisabled()){t.preventDefault();var a=s.open({template:'<div class="modal-header">   <h3>Record modified</h3></div><div class="modal-body">   <p>Would you like to save your changes?</p></div><div class="modal-footer">    <button class="btn btn-primary dlg-yes" ng-click="yes()">Yes</button>    <button class="btn btn-warning dlg-no" ng-click="no()">No</button>    <button class="btn dlg-cancel" ng-click="cancel()">Cancel</button></div>',controller:"SaveChangesModalCtrl",backdrop:"static"});a.result.then(function(t){t?e.save({redirect:n,allowChange:!0}):(L=!0,l.location=n)})}}),e.delete=function(t){if(t=t||e.record._id){var n=s.open({template:'<div class="modal-header">   <h3>Delete Item</h3></div><div class="modal-body">   <p>Are you sure you want to delete this record?</p></div><div class="modal-footer">    <button class="btn btn-primary dlg-no" ng-click="cancel()">No</button>    <button class="btn btn-warning dlg-yes" ng-click="yes()">Yes</button></div>',controller:"SaveChangesModalCtrl",backdrop:"static"});n.result.then(function(n){n&&("function"==typeof e.dataEventFunctions.onBeforeDelete?e.dataEventFunctions.onBeforeDelete(D,function(n){n?e.showError(n):e.deleteRecord(e.modelName,t)}):e.deleteRecord(e.modelName,t))})}},e.isCancelDisabled=function(){return"function"==typeof e.disableFunctions.isCancelDisabled?e.disableFunctions.isCancelDisabled(e.record,D,e[e.topLevelFormName]):e[e.topLevelFormName]&&e[e.topLevelFormName].$pristine},e.isSaveDisabled=function(){return"function"==typeof e.disableFunctions.isSaveDisabled?e.disableFunctions.isSaveDisabled(e.record,D,e[e.topLevelFormName]):e[e.topLevelFormName]&&(e[e.topLevelFormName].$invalid||e[e.topLevelFormName].$pristine)},e.isDeleteDisabled=function(){return"function"==typeof e.disableFunctions.isDeleteDisabled?e.disableFunctions.isDeleteDisabled(e.record,D,e[e.topLevelFormName]):!e.id},e.isNewDisabled=function(){return"function"==typeof e.disableFunctions.isNewDisabled?e.disableFunctions.isNewDisabled(e.record,D,e[e.topLevelFormName]):!1},e.disabledText=function(t){var n="";return e.isSaveDisabled&&(n="This button is only enabled when the form is complete and valid.  Make sure all required inputs are filled in. "+t),n},e.skipCols=function(e){return e>0?"col-md-offset-2":""},e.setFormDirty=function(e){if(e){var t=angular.element(e.target).inheritedData("$formController");t.$setDirty()}else console.log("setFormDirty called without an event (fine in a unit test)")},e.add=function(t,n){var a,r=t.split(".");a=e.record;for(var o=0,i=r.length;i>o;o++)a[r[o]]||(a[r[o]]=o===i-1?[]:{}),a=a[r[o]];a.push({}),e.setFormDirty(n)},e.remove=function(t,n,a){for(var r=t.split("."),o=e.record,i=0,s=r.length;s>i;i++)o=o[r[i]];o.splice(n,1),e.setFormDirty(a)};var A=function(e){var t=!1;return"text"===e.type?t=!0:"select"!==e.type||e.ids||(t=!0),t},P=function(t,n,a){for(var r=0;r<t.length;r++){var o=t[r].name.slice(a);if(t[r].schema){if(n[o])for(var i=0;i<n[o].length;i++)n[o][i]=P(t[r].schema,n[o][i],a+1+o.length)}else{var s=e.getListData(n,o);if(t[r].array&&A(t[r])&&s)for(var l=0;l<s.length;l++)s[l]={x:s[l]};var c=e[x(t[r],"_ids")];c&&c.length>0&&n[o]?n[o]=y(t[r],n[o],e[x(t[r],"Options")],c):t[r].select2&&!t[r].select2.fngAjax&&n[o]&&e[t[r].select2.s2query].query({term:n[o],callback:function(e){e.results.length>0&&(n[o]=e.results[0])}})}}return n},j=function(t,n,a){for(var r=0;r<t.length;r++){var o=t[r].name.slice(a),i=e.getListData(n,o);if(t[r].schema){if(i)for(var s=0;s<i.length;s++)i[s]=j(t[r].schema,i[s],a+1+o.length)}else{if(t[r].array&&A(t[r])&&i)for(var l=0;l<i.length;l++)i[l]=i[l].x;var c=e[x(t[r],"_ids")];if(c&&c.length>0)g(o,n,function(n){return w(t[r],n,e[x(t[r],"Options")],c)});else if(t[r].select2){var d=e.getData(n,o,null);t[r].select2.fngAjax?d&&d.id&&e.setData(n,o,null,d.id):d?e.setData(n,o,null,d.text):e.setData(n,o,null,void 0)}}}return n},R=function(e,t,n,a){var r=t.indexOf(e);if(-1===r)throw new Error("convertIdToListValue: Invalid data - id "+e+" not found in "+t+" processing "+a);return n[r]},T=function(e,t,n,a){var r=_.isObject(e)?e.x||e.text:e;if(r&&r.match(/^[0-9a-f]{24}$/))return r;var o=t.indexOf(r);if(-1===o)throw new Error("convertListValueToId: Invalid data - value "+r+" not found in "+t+" processing "+a);return n[o]},M=function(t,n){var r=e[n.options]=[],o=e[n.ids]=[];a.get("/api/schema/"+t,{cache:!0}).success(function(e){var i=[];U("Lookup "+t,e,null,i,"",!1),a.get("/api/"+t,{cache:!0}).success(function(e){if(e){for(var t=0;t<e.length;t++){for(var a="",s=0;s<i.length;s++)a+=e[t][i[s].name]+" ";a=a.trim();var l=_.sortedIndex(r,a);r[l]===a&&(a=a+"    ("+e[t]._id+")",l=_.sortedIndex(r,a)),r.splice(l,0,a),o.splice(l,0,e[t]._id)}B(n)}})})},B=function(t){(!e.topLevelFormName||e[e.topLevelFormName].$pristine)&&(g(t.name,D,function(n){return y(t,n,e[x(t,"Options")],e[x(t,"_ids")])}),D[t.name]&&(e.record[t.name]=D[t.name]))};e.openSelect2=function(e){$("#"+$(e.currentTarget).data("select2-open")).select2("open")},e.toJSON=function(e){return JSON.stringify(e,null,2)},e.baseSchema=function(){return e.tabs.length?e.tabs:e.formSchema}}]).controller("SaveChangesModalCtrl",["$scope","$modalInstance",function(e,t){e.yes=function(){t.close(!0)},e.no=function(){t.close(!1)},e.cancel=function(){t.dismiss("cancel")}}]);
  "use strict";formsAngular.controller("ModelCtrl",["$scope","$http","$location","urlService",function(r,l,n,t){r.models=[],l.get("/api/models").success(function(l){r.models=l}).error(function(){n.path("/404")}),r.newUrl=function(r){return t.buildUrl(r+"/new")},r.listUrl=function(r){return t.buildUrl(r)}}]);
  "use strict";formsAngular.controller("NavCtrl",["$scope","$data","$location","$filter","$locationParse","$controller","urlService","cssFrameworkService","$http",function(e,t,n,o,a,r,i,s,c){function l(t,n){var o,a={};t+="Ctrl",a.$scope=e.scopes[n]=e.$new();try{r(t,a),o=e.routing.newRecord?"creating":e.routing.id?"editing":"listing",angular.isObject(a.$scope.contextMenu)&&angular.forEach(a.$scope.contextMenu,function(t){t[o]&&e.items.push(t)})}catch(i){/is not a function, got undefined/.test(i.message)||console.log("Unable to instantiate "+t+" - "+i.message)}}e.items=[],e.globalShortcuts=function(e){if(191===e.keyCode&&e.ctrlKey){var t=angular.element.find("input")[0];t&&"searchinput"===angular.element(t).attr("id")&&(angular.element(t).focus(),e.preventDefault())}},e.goTo=function(e){n.path(e)},e.css=function(e,t){var n;return n="function"==typeof s[e]?s[e](t):"error text-error"},e.$on("$locationChangeSuccess",function(){if(e.routing=a(n.$$path),e.items=[],e.routing.analyse)e.contextMenu="Report",e.items=[{broadcast:"exportToPDF",text:"PDF"},{broadcast:"exportToCSV",text:"CSV"}];else if(e.routing.modelName){angular.forEach(e.scopes,function(e){e.$destroy()}),e.scopes=[],t.record={},t.disableFunctions={},t.dataEventFunctions={},delete t.dropDownDisplay,delete t.modelNameDisplay;var r=o("titleCase")(e.routing.modelName,!0);l(r,0),e.routing.formName&&l(r+o("titleCase")(e.routing.formName,!0),1),e.contextMenu=t.dropDownDisplay||t.modelNameDisplay||o("titleCase")(e.routing.modelName,!1)}}),c.get("/model_names").success(function(t){e.modelNames=t}).error(function(){n.path("/404")}),e.doClick=function(t){if(e.items[t].broadcast)e.$broadcast(e.items[t].broadcast);else{var n=e.items[t].args||[],o=e.items[t].fn;switch(n.length){case 0:o();break;case 1:o(n[0]);break;case 2:o(n[0],n[1]);break;case 3:o(n[0],n[1],n[2]);break;case 4:o(n[0],n[1],n[2],n[3])}}},e.isHidden=function(t){return e.items[t].isHidden?e.items[t].isHidden():!1},e.buildUrl=function(e){return i.buildUrl(e)}}]);
  "use strict";formsAngular.directive("formButtons",["cssFrameworkService",function(r){return{restrict:"A",templateUrl:"template/form-button-"+r.framework()+".html"}}]);
  "use strict";formsAngular.directive("formInput",["$compile","$rootScope","utils","$filter","urlService","cssFrameworkService",function(e,a,n,i,t,l){return{restrict:"EA",link:function(r,s,o){function c(e,a,i){var t="getAddAll"+e+"Options";return n[t](r,i,a)||[]}var d=[1,2,4,6,8,10,12],m=["mini","small","medium","large","xlarge","xxlarge","block-level"],u=2,f=[],p=!1,b=function(e){return!e||"undefined"===e||-1===["vertical","inline"].indexOf(e)},v=function(e,a){function n(e){var n=e;if("string"==typeof e)if("$"===e.slice(0,1)){n=(a||"record")+".";var i=e.slice(1).split(".");if(i.length>1){var t=i.pop();n+=i.join(".")+"[$index]."+t}else n+=e.slice(1)}else n="'"+e+"'";return n}var i=["eq","ne","gt","gte","lt","lte"],t=["===","!==",">",">=","<","<="],l=i.indexOf(e.comp);if(-1===l)throw new Error("Invalid comparison in showWhen");return n(e.lhs)+t[l]+n(e.rhs)},h=function(e,a,n){var i="<input "+e+'type="'+n.type+'"';return"inline"!==a.formstyle||"bs2"!==l.framework()||n.size||(i+='class="input-small"'),i+=" />"},g=function(e,a,n,i,r){var s;if(!a)if(a=(r.model||"record")+".",r.subschema&&-1!==e.name.indexOf(".")){var o=e.name,f=o.lastIndexOf("."),p=o.slice(f+1);if(r.index){var v=a.length;a+=o.slice(0,f)+"."+r.index+"."+p,i="f_"+a.slice(v).replace(/\./g,"-")}else a+=o.slice(0,f),r.subkey?(a+="[$_arrayOffset_"+o.slice(0,f).replace(/\./g,"_")+"_"+r.subkeyno+"]."+p,i=o+"_subkey"):(a+="[$index]."+p,i=null,s=o.replace(/\./g,"-"))}else a+=e.name;var g,y=n||e.required?" required":"",k=e.readonly?" readonly":"",w=e.placeHolder,x="",$="",_="",A="";"bs3"===l.framework()?(x=-1===["horizontal","vertical","inline"].indexOf(r.formstyle)?" input-sm":"",$="col-xs-"+d[e.size?m.indexOf(e.size):u],A=" form-control"):_=e.size?" input-"+e.size:"","inline"===r.formstyle&&(w=w||e.label);var O='ng-model="'+a+'"'+(i?' id="'+i+'" name="'+i+'" ':' name="'+s+'" ');switch(O+=w?'placeholder="'+w+'" ':"",e.popup&&(O+='title="'+e.popup+'" '),O+=c("Field",null,r),e.type){case"select":O+=e.readonly?"disabled ":"",e.select2?(O+='class="fng-select2'+A+x+_+'"',e.select2.fngAjax?"bs2"===l.framework()?(g='<div class="input-append">',g+='<input ui-select2="'+e.select2.fngAjax+'" '+O+">",g+='<button class="btn" type="button" data-select2-open="'+i+'" ng-click="openSelect2($event)"><i class="icon-search"></i></button>',g+="</div>"):(g='<div class="input-group">',g+='<input ui-select2="'+e.select2.fngAjax+'" '+O+">",g+='<span class="input-group-addon'+x+'" data-select2-open="'+i+'" ',g+='    ng-click="openSelect2($event)"><i class="glyphicon glyphicon-search"></i></span>',g+="</div>"):e.select2&&(g='<input ui-select2="'+e.select2.s2query+'" '+(e.readonly?"disabled ":"")+O+">")):(g="<select "+O+'class="'+A.trim()+x+_+'">',n||(g+="<option></option>"),angular.isArray(e.options)?angular.forEach(e.options,function(e){g+="<option>"+e+"</option>"}):g+='<option ng-repeat="option in '+e.options+'">{{option}}</option>',g+="</select>");break;case"fileuploader":g='<ng-upload-form url="/file/upload" auto-upload = "true" size-limit="50000000000" name="'+e.name+'"></ng-upload-form>';break;case"link":g='<a ng-href="/'+t.buildUrl("")+e.ref+(e.form?"/"+e.form:"")+"/{{ "+a+'}}/edit">'+e.linkText+"</a>";break;case"radio":g="";var z="inline"!==r.formstyle&&!e.inlineRadio;if(angular.isArray(e.options))r.subschema&&(O=O.replace('name="','name="{{$index}}-')),angular.forEach(e.options,function(e){g+="<input "+O+'type="radio"',g+=' value="'+e+'">'+e,z&&(g+="<br />")});else{var L=z?"div":"span";r.subschema&&(O=O.replace("$index","$parent.$index").replace('name="','name="{{$parent.$index}}-')),g+="<"+L+' ng-repeat="option in '+e.options+'"><input '+O+' type="radio" value="{{option}}"> {{option}} </'+L+"> "}break;case"checkbox":g="bs3"===l.framework()?'<div class="checkbox"><input '+O+'type="checkbox"></div>':h(O,r,e);break;case"datetime":g='<div class="dropdown"><a class="dropdown-toggle my-toggle-select" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href=""><div class="input-append"><input type="text" class="input-large" data-ng-model="'+a+'"><span class="add-on"><i class="icon-calendar"></i></span></div></a><ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"><datetimepicker data-ng-model="'+a+'" data-datetimepicker-config="{ dropdownSelector: \'.my-toggle-select\' }"></datetimepicker></ul></div>';break;default:O+='class="'+A.trim()+x+_+'"'+(e.add?e.add:""),O+='ng-model="'+a+'"'+(i?' id="'+i+'" name="'+i+'"':"")+y+k+" ","textarea"===e.type?(e.rows&&(O+="auto"===e.rows?'msd-elastic="\n" class="ng-animate" ':'rows = "'+e.rows+'" '),"textAngular"===e.editor?(O+='text-angular ng-model="htmlVariable"',"bs3"===l.framework()&&($="col-xs-12"),g='<div style = "height : 450px" '+O+"></div>"):g="<textarea "+O+" />"):g=h(O,r,e)}return"bs3"===l.framework()&&b(r.formstyle)&&"checkbox"!==e.type&&(g='<div class="'+$+'">'+g+"</div>"),e.helpInline&&"checkbox"!==e.type&&(g+='<span class="help-inline">'+e.helpInline+"</span>"),e.help&&(g+='<span class="help-block '+$+'">'+e.help+"</span>"),g},y=function(e){var a;switch(e){case"horizontal":a="form-horizontal";break;case"vertical":a="";break;case"inline":a="form-inline";break;case"horizontalCompact":a="form-horizontal compact";break;default:a="form-horizontal compact"}return a},k=function(e){var a={before:"",after:""};if("function"==typeof e.containerType)a=e.containerType(e);else switch(e.containerType){case"tab":a.before='<tab heading="'+e.title+'">',a.after="</tab>";break;case"tabset":a.before="<tabset>",a.after="</tabset>";break;case"well":a.before='<div class="well">',e.title&&(a.before+="<h4>"+e.title+"</h4>"),a.after="</div>";break;case"well-large":a.before='<div class="well well-lg well-large">',a.after="</div>";break;case"well-small":a.before='<div class="well well-sm well-small">',a.after="</div>";break;case"fieldset":a.before="<fieldset>",e.title&&(a.before+="<legend>"+e.title+"</legend>"),a.after="</fieldset>";break;case void 0:break;case null:break;case"":break;default:if(a.before='<div class="'+e.containerType+'">',e.title){var n=e.titleTagOrClass||"h4";a.before+=n.match(/h[1-6]/)?"<"+n+">"+e.title+"</"+e.titleLook+">":'<p class="'+n+'">'+e.title+"</p>"}a.after="</div>"}return a},w=function(e,a,n){e.label+=":";var i="";return("bs3"===l.framework()||"inline"!==n.formstyle&&""!==e.label||a)&&(i="<label",b(n.formstyle)?(i+=' for="'+e.id+'"',"bs3"===l.framework()&&(i+=c("Label","col-sm-2",n))):"inline"===n.formstyle&&(i+=' for="'+e.id+'" class="sr-only"'),i+=c("Label","control-label",n),i+=">"+e.label+(a||"")+"</label>"),i},x=function(e,a){e.type=e.type||"text",e.id=e.id||"f_"+e.name.replace(/\./g,"_"),e.label=void 0!==e.label?null===e.label?"":e.label:i("titleCase")(e.name.split(".").slice(-1)[0]);var n="",t="",s="";"bs3"===l.framework()?(s="form-group","vertical"===a.formstyle&&"block-level"!==e.size&&(n+='<div class="row">',s+=" col-xs-"+d[e.size?m.indexOf(e.size):u],t+="</div>"),n+="<div"+c("Group",s,a),t+="</div>"):b(a.formstyle)?(n+="<div"+c("Group","control-group",a),t="</div>"):(n+="<span ",t="</span>");var p=!1;if(a.index)try{parseInt(a.index),p=!0}catch(h){}if(e.showWhen&&(n+="string"==typeof e.showWhen?'ng-show="'+e.showWhen+'"':'ng-show="'+v(e.showWhen,a.model)+'"'),n+=p?' id="cg_'+e.id.replace("_","-"+o.index+"-")+'">':' id="cg_'+e.id.replace(/\./g,"-")+'">',e.schema){var x=e.name.replace(/\./g,"_"),_="$_schema_"+x;if(r[_]=e.schema,e.schema)if(e.subkey){e.subkey.path=e.name,r[_+"_subkey"]=e.subkey;for(var A=angular.isArray(e.subkey)?e.subkey:[e.subkey],O=0;O<A.length;O++){var z=k(A[O]);n+=z.before,n+=$(e.schema,null,{subschema:!0,formStyle:a.formstyle,subkey:_+"_subkey",subkeyno:O}),n+=z.after}f.push(e)}else n+='<div class="schema-head">'+e.label+'</div><div ng-form class="'+("bs2"===l.framework()?"row-fluid ":"")+y(e.formStyle)+'" name="form_'+x+'{{$index}}" class="sub-doc well" id="'+e.id+'List_{{$index}}"  ng-repeat="subDoc in '+(a.model||"record")+"."+e.name+' track by $index">   <div class="'+("bs2"===l.framework()?"row-fluid":"row")+' sub-doc">      <div class="pull-left">'+$(e.schema,!1,{subschema:!0,formstyle:e.formStyle,model:a.model})+"      </div>",(!e.noRemove||e.customSubDoc)&&(n+='   <div class="pull-left sub-doc-btns">',e.customSubDoc&&(n+=e.customSubDoc),e.noRemove||(n+="bs2"===l.framework()?'      <button name="remove_'+e.id+'_btn" class="remove-btn btn btn-mini form-btn" ng-click="remove(\''+e.name+'\',$index,$event)">          <i class="icon-minus">':'      <button name="remove_'+e.id+'_btn" class="remove-btn btn btn-default btn-xs form-btn" ng-click="remove(\''+e.name+'\',$index,$event)">          <i class="glyphicon glyphicon-minus">',n+="          </i> Remove      </button>"),n+="  </div> "),n+="   </div></div>",(!e.noAdd||e.customFooter)&&(n+='<div class = "schema-foot">',e.customFooter&&(n+=e.customFooter),e.noAdd||(n+="bs2"===l.framework()?'    <button id="add_'+e.id+'_btn" class="add-btn btn btn-mini form-btn" ng-click="add(\''+e.name+'\',$event)">        <i class="icon-plus"></i> Add':'    <button id="add_'+e.id+'_btn" class="add-btn btn btn-default btn-xs form-btn" ng-click="add(\''+e.name+'\',$event)">        <i class="glyphicon glyphicon-plus"></i> Add',n+="    </button>"),n+="</div>")}else{var L=[];if(b(a.formstyle)&&L.push("bs2"===l.framework()?"controls":"col-sm-10"),e.array){if(L.push("fng-array"),"inline"===a.formstyle)throw"Cannot use arrays in an inline form";n+="bs2"===l.framework()?w(e,' <i id="add_'+e.id+'" ng-click="add(\''+e.name+'\',$event)" class="icon-plus-sign"></i>',a)+'<div class="'+L.join(" ")+'" id="'+e.id+'List" ng-repeat="arrayItem in '+(a.model||"record")+"."+e.name+'">'+g(e,"arrayItem.x",!0,e.id+"_{{$index}}",a)+"<i ng-click=\"remove('"+e.name+'\',$index,$event)" id="remove_'+e.id+'_{{$index}}" class="icon-minus-sign"></i></div>':w(e,' <i id="add_'+e.id+'" ng-click="add(\''+e.name+'\',$event)" class="glyphicon glyphicon-plus-sign"></i>',a)+'<div ng-class="skipCols($index)" class="'+L.join(" ")+'" id="'+e.id+'List" ng-repeat="arrayItem in '+(a.model||"record")+"."+e.name+'">'+g(e,"arrayItem.x",!0,e.id+"_{{$index}}",a)+"<i ng-click=\"remove('"+e.name+'\',$index,$event)" id="remove_'+e.id+'_{{$index}}" class="glyphicon glyphicon-minus-sign"></i></div>'}else n+=w(e,null,a),L.length>0&&(n+='<div class="'+L.join(" ")+'">'),n+=g(e,null,a.required,e.id,a),L.length>0&&(n+="</div>")}return n+=t},$=function(e,a,n){var i="";if(e)for(var t=0;t<e.length;t++){var l=e[t];0===t&&a&&!n.schema.match(/$_schema_/)&&(l.add=l.add||"",-1!==l.add.indexOf("ui-date")||n.noautofocus||l.containerType||(l.add=l.add+"autofocus "));var o=!0;if(l.directive){for(var c=l.directive,d="<"+c+' model="'+(n.model||"record")+'"',m=s[0],u=0;u<m.attributes.length;u++){var f=m.attributes[u];switch(f.nodeName){case"class":var b=f.nodeValue.replace("ng-scope","");b.length>0&&(d+=' class="'+b+'"');break;case"schema":var v=("bespoke_"+l.name).replace(/\./g,"_");r[v]=angular.copy(l),delete r[v].directive,d+=' schema="'+v+'"';break;default:d+=" "+f.nodeName+'="'+f.nodeValue+'"'}}d+="></"+c+">",i+=d,o=!1}else if(l.containerType){var h=k(l);switch(l.containerType){case"tab":p||(p="forced",i+="<tabset>"),i+=h.before,i+=$(l.content,null,n),i+=h.after;break;case"tabset":p=!0,i+=h.before,i+=$(l.content,null,n),i+=h.after;break;default:i+=h.before,i+=$(l.content,null,n),i+=h.after}o=!1}else if(n.subkey){var g=angular.isArray(r[n.subkey])?r[n.subkey][0].keyList:r[n.subkey].keyList;_.find(g,function(e,a){return r[n.subkey].path+"."+a===l.name})&&(o=!1)}o&&(i+=x(l,n))}else console.log("Empty array passed to processInstructions"),i="";return i},A=r.$watch(o.schema,function(n){if(n&&(n=angular.isArray(n)?n:[n],n.length>0)){A();var i="",t=r[o.model||"record"];if(!o.subschema&&!o.model||o.forceform){r.topLevelFormName=o.name||"myForm";var l="";for(var c in o)o.hasOwnProperty(c)&&"$"!==c[0]&&-1===["name","formstyle","schema","subschema","model"].indexOf(c)&&(l+=" "+o.$attr[c]+'="'+o[c]+'"');i='<form name="'+r.topLevelFormName+'" class="'+y(o.formstyle)+' novalidate"'+l+">"}else i="";if(t===r.topLevelFormName)throw new Error("Model and Name must be distinct - they are both "+t);if(i+=$(n,!0,o),"forced"===p&&(i+="</tabset>"),i+=o.subschema?"":"</form>",s.replaceWith(e(i)(r)),f.length>0)var d=r.$watch("phase",function(e){if("ready"===e){d();for(var a=0;a<f.length;a++)for(var n,i,l=f[a],s=angular.isArray(l.subkey)?l.subkey:[l.subkey],o=0;o<s.length;o++){var c=s[o].keyList,m=t[l.name]=t[l.name]||[];for(n=0;n<m.length;n++){i=!0;for(var u in c)if(c.hasOwnProperty(u)&&m[n][u]!==c[u]){i=!1;break}if(i)break}i||(n=t[l.name].push(c)-1),r["$_arrayOffset_"+l.name.replace(/\./g,"_")+"_"+o]=n}}});a.$broadcast("formInputDone"),r.updateDataDependentDisplay&&t&&Object.keys(t).length>0&&r.updateDataDependentDisplay(t,null,!0)}},!0)}}}]);
  "use strict";var COL_FIELD=/COL_FIELD/g;formsAngular.directive("ngTotalCell",["$compile","$domUtilityService",function(e,l){var t={scope:!1,compile:function(){return{pre:function(l,t){var c,a,n=l.col.cellTemplate.match(/{{COL_FIELD \|(.+)}}/);a=n?l.col.cellTemplate.replace("COL_FIELD |"+n[1],'getTotalVal("'+l.col.field+'","'+n[1]+'")'):l.col.cellTemplate.replace(COL_FIELD,'getTotalVal("'+l.col.field+'")'),l.col.enableCellEdit?(c=l.col.cellEditTemplate,c=c.replace(DISPLAY_CELL_TEMPLATE,a),c=c.replace(EDITABLE_CELL_TEMPLATE,l.col.editableCellTemplate.replace(COL_FIELD,"row.entity."+l.col.field))):c=a;var i=e(c)(l);l.enableCellSelection&&-1===i[0].className.indexOf("ngSelectionCell")&&(i[0].setAttribute("tabindex",0),i.addClass("ngCellElement")),t.append(i)},post:function(e,t){e.enableCellSelection&&e.domAccessProvider.selectionHandlers(e,t),e.$on("ngGridEventDigestCell",function(){l.digest(e)})}}}};return t}]);
  "use strict";formsAngular.controller("SearchCtrl",["$scope","$http","$location",function(e,s,t){var r="";e.handleKey=function(s){if(27===s.keyCode&&e.searchTarget.length>0)e.searchTarget="";else if(e.results.length>0)switch(s.keyCode){case 38:e.focus>0&&e.setFocus(e.focus-1),"function"==typeof s.preventDefault&&s.preventDefault();break;case 40:e.results.length>e.focus+1&&e.setFocus(e.focus+1),"function"==typeof s.preventDefault&&s.preventDefault();break;case 13:null!=e.focus&&e.selectResult(e.focus)}},e.setFocus=function(s){null!==e.focus&&delete e.results[e.focus].focussed,e.results[s].focussed=!0,e.focus=s},e.selectResult=function(s){var r=e.results[s];t.path("/"+r.resource+"/"+r.id+"/edit")},e.resultClass=function(s){var t="search-result";return e.results&&e.results[s].focussed&&(t+=" focus"),t};var o=function(){e.moreCount=0,e.errorClass="",e.results=[],e.focus=null};e.$watch("searchTarget",function(t){t&&t.length>0?(r=t,s.get("/api/search?q="+t).success(function(s){r===t&&(e.searchTarget.length>0?(e.results=s.results,e.moreCount=s.moreCount,s.results.length>0&&(e.errorClass="",e.setFocus(0)),e.errorClass=0===e.results.length?"error":""):o())}).error(function(e,s){console.log("Error in searchbox.js : "+e+" (status="+s+")")})):o()},!0),e.$on("$routeChangeStart",function(){e.searchTarget=""})}]).directive("globalSearch",["cssFrameworkService",function(e){return{restrict:"AE",templateUrl:"template/search-"+e.framework()+".html",controller:"SearchCtrl"}}]);
  "use strict";formsAngular.filter("titleCase",[function(){return function(e,r){var t=e.replace(/(_|\.)/g," ").replace(/[A-Z]/g," $&").trim().replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()});return t=r?t.replace(/\s/g,""):t.replace(/\s{2,}/g," ")}}]);
  "use strict";formsAngular.provider("cssFrameworkService",[function(){var r={framework:"bs3"};return{setOptions:function(e){angular.extend(r,e)},$get:function(){return{framework:function(){return r.framework},span:function(e){var s;switch(r.framework){case"bs2":s="span"+e;break;case"bs3":s="col-xs-"+e}return s},offset:function(e){var s;switch(r.framework){case"bs2":s="offset"+e;break;case"bs3":s="col-lg-offset-"+e}return s},rowFluid:function(){var e;switch(r.framework){case"bs2":e="row-fluid";break;case"bs3":e="row"}return e}}}}}]);
  "use strict";formsAngular.factory("$data",[function(){var t={record:{},disableFunctions:{},dataEventFunctions:{}};return t}]);
  "use strict";formsAngular.provider("formRoutes",["$routeProvider",function(e){return{setRoutes:function(t,l){for(var a=0;a<t.length;a++)e.when(t[a].route,t[a].options);e.when("/analyse/:model/:reportSchemaName",{templateUrl:"partials/base-analysis.html"}).when("/analyse/:model",{templateUrl:"partials/base-analysis.html"}).when("/:model/:id/edit",{templateUrl:"partials/base-edit.html"}).when("/:model/new",{templateUrl:"partials/base-edit.html"}).when("/:model",{templateUrl:"partials/base-list.html"}).when("/:model/:form/:id/edit",{templateUrl:"partials/base-edit.html"}).when("/:model/:form/new",{templateUrl:"partials/base-edit.html"}).when("/:model/:form",{templateUrl:"partials/base-list.html"}).otherwise({redirectTo:l})},$get:function(){return null}}}]);
  "use strict";formsAngular.factory("$locationParse",[function(){var e=null,n={};return function(r){if(r!==e){e=r;var a=r.split("/"),i=a.length;if(2===i&&"index"===a[1])n={index:!0};else if(n={newRecord:!1},"analyse"===a[1])n.analyse=!0,n.modelName=a[2];else{n.modelName=a[1];var l=a[i-1];"new"===l?(n.newRecord=!0,i--):"edit"===l&&(i-=2,n.id=a[i]),i>2&&(n.formName=a[2])}}return n}}]);
  "use strict";formsAngular.factory("$stateParse",[function(){var e={};return function(r){return r.current&&r.current.name&&(e={newRecord:!1},e.modelName=r.params.model,"model::list"===r.current.name?(e={index:!0},e.modelName=r.params.model):"model::edit"===r.current.name?e.id=r.params.id:"model::new"===r.current.name?e.newRecord=!0:"model::analyse"===r.current.name&&(e.analyse=!0)),e}}]);
  "use strict";formsAngular.provider("urlService",["$locationProvider",function(e){var r={hashPrefix:"",html5Mode:!1,baseHref:"",modelPage:/.*/,newRecord:/.*/};return{setOptions:function(o){angular.extend(r,o),e.html5Mode(r.html5Mode),""!==r.hashPrefix&&e.hashPrefix(r.hashPrefix)},$get:function(){return{buildUrl:function(e){var o=r.html5Mode?"":"#";return o+=r.baseHref,o+=r.hashPrefix,o[0]&&(o+="/"),o+e},modelPage:r.modelPage,newRecord:r.newRecord}}}}]);
  formsAngular.service("utils",function(){function t(t,n,i,e){function l(t){for(var n in t)n===i&&u.push(t[n]),"$parent"===n&&l(t[n])}var s,o,r,u=[],f=[];if(i="addAll"+i,"string"==typeof e)for(s=e.split(" "),o=0;o<s.length;o++)f.push(s[o]);if(l(t),void 0!==n[i])if("object"==typeof n[i]);else if("string"==typeof n[i])for(s=n[i].split(" "),o=0;o<s.length;o++)0===s[o].indexOf("class=")?f.push(s[o].substring(6,s[o].length)):u.push(s[o]);return e=f.length>0?' class="'+f.join(" ")+'" ':" ",r=u.length>0?u.join(" ")+" ":"",e+r}this.getAddAllGroupOptions=function(n,i,e){return t(n,i,"Group",e)},this.getAddAllFieldOptions=function(n,i,e){return t(n,i,"Field",e)},this.getAddAllLabelOptions=function(n,i,e){return t(n,i,"Label",e)}});
  "use strict";function ngGridCsvExportPlugin(n){var e=this;e.grid=null,e.scope=null,e.init=function(t,r){function a(){var n=angular.element("h1").parent(),t=angular.element("#csv-data-link");null!=t&&t.remove();var r='<button id="csv-data-link" class="btn"><a href="data:text/csv;charset=UTF-8,';r+=encodeURIComponent(e.prepareCSV()),r+='" download="Export.csv">CSV Export</button>',n.append(r)}e.grid=r,e.scope=t,n.inhibitButton||(setTimeout(a,0),t.catHashKeys=function(){var n="";for(var e in t.renderedRows)n+=t.renderedRows[e].$$hashKey;return n},t.$watch("catHashKeys()",a))},e.createCSV=function(){window.open("data:text/csv;charset=UTF-8,"+encodeURIComponent(e.prepareCSV()))},e.prepareCSV=function(){function n(n){return null==n?"":"number"==typeof n?""+n:"boolean"==typeof n?n?"TRUE":"FALSE":"string"==typeof n?n.replace(/"/g,'""'):JSON.stringify(n).replace(/"/g,'""')}function t(n){var e=n.substr(0,n.length-1);return e+"\n"}var r="";return angular.forEach(e.scope.columns,function(e){e.visible&&(void 0===e.width||e.width>0)&&(r+='"'+n(e.displayName)+'",')}),r=t(r),angular.forEach(e.grid.filteredRows,function(a){angular.forEach(e.scope.columns,function(e){e.visible&&(r+='"'+n(a.entity[e.field])+'",')}),r=t(r)}),r}}
  "use strict";function ngGridPdfExportPlugin(t){var e=this;e.grid=null,e.scope=null,e.services=null,e.options=t,e.init=function(n,o,i){if(e.grid=o,e.scope=n,e.services=i,!t.inhibitButton){var a=o.$root.find(".ngFooterPanel"),l=o.$root.find(".ngFooterPanel .pdf-data-link-span");null!=l&&l.remove();var r='<button class="pdf-data-link-span">PDF Export</button>';a.append(r),a.on("click",function(){e.createPDF()})}},e.createPDF=function(){var t=[],n=[],o={},i=e.scope.totalRowWidth(),a=15;angular.forEach(e.scope.columns,function(n){n.visible&&(void 0===n.width||n.width>0)&&(t.push({name:n.field,prompt:n.displayName,width:n.width*(185/i),align:n.colDef.align||"left"}),n.colDef.totalsRow&&(o[n.field]=e.scope.getTotalVal(n.field,n.filter).toString()))}),angular.forEach(e.grid.filteredRows,function(t){n.push(angular.copy(t.entity))});var l=new jsPDF("landscape","mm","a4");l.setFontStyle("bold"),l.setFontSize(24),l.text(e.scope.reportSchema.title,a,a),l.setFontStyle("normal"),l.setFontSize(12),l.cellInitialize(),l.table(a,24,n,{headers:t,footers:o,printHeaders:!0,autoSize:!1,margins:{left:a,top:a,bottom:a,width:l.internal.pageSize-a}}),l.output("dataurlnewwindow")}}
  !function(t){"use strict";var e,i,n,o,r=3,s=13,h={x:void 0,y:void 0,w:void 0,h:void 0,ln:void 0},a=1,l=function(t,e,i,n,o){h={x:t,y:e,w:i,h:n,ln:o}},d=function(){return h};t.setHeaderFunction=function(t){o=t},t.getTextDimensions=function(t){e=this.internal.getFont().fontName,i=this.table_font_size||this.internal.getFontSize(),n=this.internal.getFont().fontStyle;var o,r,s=19.049976/25.4;return r=document.createElement("font"),r.id="jsPDFCell",r.style.fontStyle=n,r.style.fontName=e,r.style.fontSize=i+"pt",r.innerText=t,document.body.appendChild(r),o={w:(r.offsetWidth+1)*s,h:(r.offsetHeight+1)*s},document.body.removeChild(r),o},t.cellAddPage=function(){this.addPage(),l(this.margins.left,this.margins.top,void 0,void 0),a+=1},t.cellInitialize=function(){h={x:void 0,y:void 0,w:void 0,h:void 0,ln:void 0},a=1},t.cell=function(t,e,i,n,o,h,a){var g=d();if(void 0!==g.ln&&(g.ln===h?(t=g.x+g.w,e=g.y):(g.y+g.h+n+s>=this.internal.pageSize.height-this.margins.bottom&&(this.cellAddPage(),this.printHeaders&&this.tableHeaderRow&&this.printHeaderRow(h,!0)),e=d().y+d().h)),void 0!==o[0])if(this.printingHeaderRow?this.rect(t,e,i,n,"FD"):this.rect(t,e,i,n),"right"===a){var f;if(o instanceof Array)for(var u=0;u<o.length;u++){var c=o[u];f=this.getStringUnitWidth(c)*this.internal.getFontSize()/2.8125,this.text(c,t+i-f-r,e+this.internal.getLineHeight()*(u+1))}else f=this.getStringUnitWidth(o)*this.internal.getFontSize()/2.8125,this.text(o,t+i-f-r,e+this.internal.getLineHeight())}else this.text(o,t+r,e+this.internal.getLineHeight());return l(t,e,i,n,h),this},t.getKeys="function"==typeof Object.keys?function(t){return t?Object.keys(t):[]}:function(t){var e,i=[];for(e in t)t.hasOwnProperty(e)&&i.push(e);return i},t.arrayMax=function(t,e){var i,n,o,r=t[0];for(i=0,n=t.length;n>i;i+=1)o=t[i],e?-1===e(r,o)&&(r=o):o>r&&(r=o);return r},t.table=function(e,i,n,o){if(!n)throw"No data for PDF table";var r,s,l,d,g,f,u,c,v,p,w=[],y=[],H={},m={},b=[],S=[],x=[],R=!1,z=!0,F=12,T=null,P=null,D={left:0,top:0,bottom:0,width:this.internal.pageSize.width};if(o&&(o.autoSize===!0&&(R=!0),o.printHeaders===!1&&(z=!1),o.fontSize&&(F=o.fontSize),o.margins&&(D=o.margins),o.headers&&(T=o.headers),o.footers&&(P=o.footers)),this.lnMod=0,h={x:void 0,y:void 0,w:void 0,h:void 0,ln:void 0},a=1,this.printHeaders=z,this.margins=D,this.setFontSize(F),this.table_font_size=F,void 0===T||null===T)w=this.getKeys(n[0]);else if(T[0]&&"string"!=typeof T[0]){var L=1.5;for(s=0,l=T.length;l>s;s+=1)r=T[s],w.push(r.name),y.push(r.prompt),m[r.name]=r.width*L,S[r.name]=r.align}else w=T;if(R)for(p=function(t){return t[r]},s=0,l=w.length;l>s;s+=1){for(r=w[s],H[r]=n.map(p),b.push(this.getTextDimensions(y[s]||r).w),f=H[r],u=0,d=f.length;d>u;u+=1)g=f[u],b.push(this.getTextDimensions(g).w);P&&b.push(this.getTextDimensions(P[s]).w),m[r]=t.arrayMax(b)}if(z){var _=this.calculateLineHeight(w,m,y.length?y:w);for(s=0,l=w.length;l>s;s+=1)r=w[s],x.push([e,i,m[r],_,String(y.length?y[s]:r),0,S[r]]);this.setTableHeaderRow(x),this.printHeaderRow(1,!1)}for(s=0,l=n.length;l>s;s+=1){var _;for(c=n[s],_=this.calculateLineHeight(w,m,c),u=0,v=w.length;v>u;u+=1)r=w[u],this.cell(e,i,m[r],_,c[r],s+2,S[r])}if(P){for(var j=0;j<w.length;j++)r=w[j],x[j][4]=P[r]||" ";this.printHeaderRow(s+2,!1)}return this.table_x=e,this.table_y=i,this},t.calculateLineHeight=function(t,e,i){for(var n,o=0,s=0;s<t.length;s++){n=t[s],i[n]=this.splitTextToSize(String(i[n]),e[n]-r);var h=this.internal.getLineHeight()*i[n].length+r;h>o&&(o=h)}return o},t.setTableHeaderRow=function(t){this.tableHeaderRow=t},t.printHeaderRow=function(t,e){if(!this.tableHeaderRow)throw"Property tableHeaderRow does not exist.";var i,n,r,s;if(this.printingHeaderRow=!0,void 0!==o){var h=o(this,a);l(h[0],h[1],h[2],h[3],-1)}this.setFontStyle("bold");var d=[];for(r=0,s=this.tableHeaderRow.length;s>r;r+=1)this.setFillColor(200,200,200),i=this.tableHeaderRow[r],e&&(i[1]=this.margins.top,d.push(i)),n=[].concat(i),n[5]=t,this.cell.apply(this,n);d.length>0&&this.setTableHeaderRow(d),this.setFontStyle("normal"),this.printingHeaderRow=!1}}(jsPDF.API);
  angular.module("formsAngular").run(["$templateCache",function(s){"use strict";s.put("template/form-button-bs2.html",'<div class="btn-group pull-right"><button id=saveButton class="btn btn-mini btn-primary form-btn" ng-click=save() ng-disabled=isSaveDisabled()><i class=icon-ok></i> Save</button> <button id=cancelButton class="btn btn-mini btn-warning form-btn" ng-click=cancel() ng-disabled=isCancelDisabled()><i class=icon-remove></i> Cancel</button></div><div class="btn-group pull-right"><button id=newButton class="btn btn-mini btn-success form-btn" ng-click=new() ng-disabled=isNewDisabled()><i class=icon-plus></i> New</button> <button id=deleteButton class="btn btn-mini btn-danger form-btn" ng-click=delete() ng-disabled=isDeleteDisabled()><i class=icon-minus></i> Delete</button></div>'),s.put("template/form-button-bs3.html",'<div class="btn-group pull-right"><button id=saveButton class="btn btn-primary form-btn btn-xs" ng-click=save() ng-disabled=isSaveDisabled()><i class="glyphicon glyphicon-ok"></i> Save</button> <button id=cancelButton class="btn btn-warning form-btn btn-xs" ng-click=cancel() ng-disabled=isCancelDisabled()><i class="glyphicon glyphicon-remove"></i> Cancel</button></div><div class="btn-group pull-right"><button id=newButton class="btn btn-success form-btn btn-xs" ng-click=new() ng-disabled=isNewDisabled()><i class="glyphicon glyphicon-plus"></i> New</button> <button id=deleteButton class="btn btn-danger form-btn btn-xs" ng-click=delete() ng-disabled=isDeleteDisabled()><i class="glyphicon glyphicon-minus"></i> Delete</button></div>'),s.put("template/search-bs2.html",'<form class="navbar-search pull-right"><div id=search-cg class=control-group ng-class=errorClass><input id=searchinput ng-model=searchTarget class=search-query placeholder="Ctrl+Slash to Search" ng-keyup=handleKey($event)></div></form><div class=results-container ng-show="results.length >= 1"><div class=search-results><div ng-repeat="result in results"><span ng-class=resultClass($index) ng-click=selectResult($index)>{{result.resourceText}} {{result.text}}</span></div><div ng-show="moreCount > 0">(plus more - continue typing to narrow down search...)</div></div></div>'),s.put("template/search-bs3.html",'<form class="pull-right navbar-form"><div id=search-cg class=form-group ng-class=errorClass><input id=searchinput ng-model=searchTarget class="search-query form-control" placeholder="Ctrl+Slash to Search" ng-keyup=handleKey($event)></div></form><div class=results-container ng-show="results.length >= 1"><div class=search-results><div ng-repeat="result in results"><span ng-class=resultClass($index) ng-click=selectResult($index)>{{result.resourceText}} {{result.text}}</span></div><div ng-show="moreCount > 0">(plus more - continue typing to narrow down search...)</div></div></div>')}]);