Last active
August 29, 2015 13:56
-
-
Save insin/9335123 to your computer and use it in GitHub Desktop.
Newforms: Custom Form Layout - - http://bl.ocks.org/insin/raw/9335123/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Concur 0.2.4 - https://github.com/insin/concur | |
* MIT Licensed | |
*/ | |
!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.Concur=t()}}(function(){return function t(n,r,e){function o(u,c){if(!r[u]){if(!n[u]){var f="function"==typeof require&&require;if(!c&&f)return f(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var a=r[u]={exports:{}};n[u][0].call(a.exports,function(t){var r=n[u][1][t];return o(r?r:t)},a,a.exports,t,n,r,e)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u<e.length;u++)o(e[u]);return o}({1:[function(t,n){"use strict";function r(t,n){i.Function(n)?u.extend(t,n.prototype):u.extend(t,n)}function e(t){var n=t.__mixin__;i.Array(n)||(n=[n]);for(var e={},o=0,c=n.length;c>o;o++)r(e,n[o]);return delete t.__mixin__,u.extend(e,t)}function o(t,n,r){var e;return e=n&&u.hasOwn(n,"constructor")?n.constructor:function(){t.apply(this,arguments)},t!==c&&(u.inherits(e,t),e.__super__=t.prototype),n&&u.extend(e.prototype,n),r&&u.extend(e,r),e}var i=t("isomorph/is"),u=t("isomorph/object"),c=n.exports=function(){};c.__mro__=[],c.extend=function(t,n){"undefined"!=typeof this.prototype.__meta__&&(t=t||{},n=n||{},this.prototype.__meta__(t,n)),t&&u.hasOwn(t,"__mixin__")&&(t=e(t)),n&&u.hasOwn(n,"__mixin__")&&(n=e(n));var r=o(this,t,n);return r.extend=this.extend,r.__mro__=[r].concat(this.__mro__),r}},{"isomorph/is":2,"isomorph/object":3}],2:[function(t,n){function r(t){return"[object Array]"==l.call(t)}function e(t){return"[object Boolean]"==l.call(t)}function o(t){return"[object Date]"==l.call(t)}function i(t){return"[object Error]"==l.call(t)}function u(t){return"[object Function]"==l.call(t)}function c(t){return"[object Number]"==l.call(t)}function f(t){return"[object Object]"==l.call(t)}function a(t){return"[object RegExp]"==l.call(t)}function p(t){return"[object String]"==l.call(t)}function s(t){for(var n in t)return!1;return!0}var l=Object.prototype.toString;n.exports={Array:r,Boolean:e,Date:o,Empty:s,Error:i,Function:u,NaN:isNaN,Number:c,Object:f,RegExp:a,String:p}},{}],3:[function(t,n){function r(t){for(var n,r=1,e=arguments.length;e>r;r++)if(n=arguments[r])for(var o in n)f(n,o)&&(t[o]=n[o]);return t}function e(t,n){var r=function(){};return r.prototype=n.prototype,t.prototype=new r,t.prototype.constructor=t,t}function o(t){var n=[];for(var r in t)f(t,r)&&n.push([r,t[r]]);return n}function i(t){for(var n,r={},e=0,o=t.length;o>e;e++)n=t[e],r[n[0]]=n[1];return r}function u(t){for(var n={},r=0,e=t.length;e>r;r++)n[""+t[r]]=!0;return n}function c(t,n,r){return f(t,n)?t[n]:r}var f=function(){var t=Object.prototype.hasOwnProperty;return function(n,r){return t.call(n,r)}}();n.exports={hasOwn:f,extend:r,inherits:e,items:o,fromItems:i,lookup:u,get:c}},{}]},{},[1])(1)}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { font-family: helvetica, arial, sans-serif; font-size: small; } | |
h2 { margin-top: 0; } | |
table { | |
border-spacing: 0; | |
border-color: #36f; | |
border-style: solid; | |
border-width: 3px 1px 1px; | |
} | |
tbody th { text-align: right; padding: 4px 6px; } | |
tbody th, td { vertical-align: top; } | |
tbody td { padding: 4px 6px; } | |
tbody th { | |
background-color: #F9F9FF; | |
border-bottom: 1px solid white; | |
border-right: 1px solid #CCDDFF; | |
font-weight: normal; | |
padding: 5px; | |
text-align: right; | |
vertical-align: top; | |
} | |
th.required { | |
background-color: #CCDDFF; | |
} | |
th.error { | |
background-color: red; | |
color: white; | |
font-weight: bold; | |
} | |
ul.errorlist { | |
list-style: none outside none; | |
margin: 0; | |
padding: 0; | |
} | |
ul.errorlist li { | |
color: red; | |
font-weight: bold; | |
margin-bottom: 5px; | |
} | |
tr.top-errors td { padding: 0; } | |
tr.top-errors li { | |
background-color: red; | |
color: white; | |
text-align: center; | |
font-size: larger; | |
padding: 4px 6px; | |
} | |
.inline-block { display: inline-block; vertical-align: top; } | |
.cleaned-data { margin-left: 1em; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
void function() { | |
'use strict'; | |
/** | |
* @interface | |
*/ | |
var FormLayout = Concur.extend({ | |
constructor: function FormLayout() { | |
} | |
}) | |
// TODO __meta__ which validates this on extension | |
FormLayout.prototype.render = function(form) { | |
throw new Error('Objects extending FormLayout must define a render() function') | |
} | |
/** | |
* @constructor | |
* @implements {FormLayout} | |
*/ | |
var GridLayout = FormLayout.extend({ | |
constructor: function GridLayout(kwargs) { | |
if (!(this instanceof GridLayout)) { return new GridLayout(kwargs) } | |
kwargs = isomorph.object.extend({ | |
layout: null, fillerCssClass: null, topErrorCssClass: null | |
}, kwargs) | |
if (!kwargs.layout) { | |
throw new Error('A layout must be specified for a GridLayout.') | |
} | |
this.layout = kwargs.layout | |
this.maxCol = Math.max.apply(Math, this.layout.map(function(row) { return row.length })) | |
this.fillerCssClass = kwargs.fillerCssClass | |
this.topErrorCssClass = kwargs.topErrorCssClass | |
} | |
}) | |
GridLayout.prototype.render = function(form) { | |
var renderedRows = [] | |
var nonFieldErrors = form.nonFieldErrors() | |
if (nonFieldErrors.isPopulated()) { | |
renderedRows.push(<tr className={this.topErrorCssClass}> | |
<td colSpan={2 * this.maxCol}>{nonFieldErrors.render()}</td> | |
</tr>) | |
} | |
for (var i = 0, l = this.layout.length, rowFields; i < l; i++) { | |
rowFields = this.layout[i] | |
var renderedCols = [] | |
for (var j = 0, m = rowFields.length; j < m; j++) { | |
var bf = form.boundField(rowFields[j]) | |
var errors = bf.errors() | |
var cssClasses = bf.cssClasses() | |
renderedCols.push( | |
<th className={cssClasses}>{bf.labelTag()}</th> | |
, <td key={bf.htmlName} className={cssClasses}> | |
{errors.isPopulated() && errors.render()} | |
{bf.render()} | |
</td> | |
) | |
} | |
// Fill up any remaining columns | |
if (rowFields.length < this.maxCol) { | |
renderedCols.push(<td colSpan={2 * (this.maxCol - rowFields.length)} | |
className={this.fillerCssClass}> | |
</td>) | |
} | |
renderedRows.push(<tr>{renderedCols}</tr>) | |
} | |
return renderedRows | |
} | |
// TODO __meta__ which validates presence of layout on extension | |
/** | |
* A Form which is configured with a Layout object which is responsible for | |
* rendering -- overrides the default render() function. | |
*/ | |
var LayoutForm = forms.Form.extend({ | |
constructor: function LayoutForm(kwargs) { | |
if (!(this.layout instanceof FormLayout)) { | |
throw new Error('A LayoutForm must have a layout property which is instanceof FormLayout') | |
} | |
LayoutForm.__super__.constructor.call(this, kwargs) | |
} | |
, render: function() { | |
return this.layout.render(this) | |
} | |
}) | |
var ReleaseForm = LayoutForm.extend({ | |
layout: GridLayout({ | |
layout: [ | |
[ 'name' ] | |
, [ 'theme' ] | |
, [ 'startDate' , 'releaseDate' ] | |
, [ 'state' , 'resources' ] | |
, [ 'project' ] | |
, [ 'estimate' ] | |
, [ 'notes' ] | |
] | |
, fillerCssClass: 'empty' | |
, topErrorCssClass: 'top-errors' | |
}) | |
, requiredCssClass: 'required' | |
, errorCssClass: 'error' | |
, name: forms.CharField({maxLength: 50}) | |
, theme: forms.CharField({required: false, widget: forms.Textarea}) | |
, startDate: forms.DateField() | |
, releaseDate: forms.DateField() | |
, state: forms.ChoiceField({choices: [ [1, 'Planning'] | |
, [2, 'Active'] | |
, [3, 'Accepted'] | |
]}) | |
, resources: forms.DecimalField({required: false, minValue: 0, decimalPlaces: 2}) | |
, project: forms.ChoiceField() | |
, estimate: forms.DecimalField({required: false, minValue: 0, decimalPlaces: 2}) | |
, notes: forms.CharField({required: false, widget: forms.Textarea}) | |
, constructor: function ReleaseForm(projects, kwargs) { | |
if (!(this instanceof ReleaseForm)) { return new ReleaseForm(projects, kwargs) } | |
ReleaseForm.__super__.constructor.call(this, kwargs) | |
this.fields.project.setChoices(projects.map(function(project) { | |
return [project.id, project.name] | |
})) | |
} | |
, clean: function() { | |
if (this.cleanedData.startDate && this.cleanedData.releaseDate && | |
this.cleanedData.startDate > this.cleanedData.releaseDate) { | |
this.addError('releaseDate', 'Cannot be prior to Start Date.') | |
} | |
if (JSON.stringify(this.cleanedData).toUpperCase().indexOf('CLOWN') != -1) { | |
throw forms.ValidationError('NO CLOWNS!') | |
} | |
} | |
}) | |
var projects = [ | |
{id: 1, name: 'Test Project 1'} | |
, {id: 2, name: 'Test Project 2'} | |
, {id: 3, name: 'Test Project 3'} | |
] | |
var CustomLayout = React.createClass({ | |
getInitialState: function() { | |
return {form: ReleaseForm(projects)} | |
} | |
, render: function() { | |
return <form ref="form" onSubmit={this.onSubmit}> | |
<div className="inline-block"> | |
<table> | |
<tbody> | |
{this.state.form.render()} | |
<tr> | |
<td colSpan="4"> | |
<input type="submit" value="Submit"/> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
</div> | |
<div className="inline-block cleaned-data"> | |
{this.state.form.cleanedData && <h2>form.cleanedData</h2>} | |
<pre>{this.state.form.cleanedData && JSON.stringify(this.state.form.cleanedData, null, ' ')}</pre> | |
</div> | |
</form> | |
} | |
, onSubmit: function(e) { | |
e.preventDefault() | |
this.state.form.setData(forms.formData(this.refs.form.getDOMNode())) | |
this.forceUpdate() | |
} | |
}) | |
React.renderComponent(<CustomLayout/>, document.getElementById('app')) | |
}() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Newforms: Custom Form Layout</title> | |
<script src="http://fb.me/react-0.9.0.js"></script> | |
<script src="http://fb.me/JSXTransformer-0.9.0.js"></script> | |
<script src="newforms-0.5.0-dev.min.js"></script> | |
<script src="isomorph-0.2.1.min.js"></script> | |
<script src="Concur-0.2.4.min.js"></script> | |
<link rel="stylesheet" href="customlayout.css"> | |
</head> | |
<body> | |
<h1><a href="https://github.com/insin/newforms">Newforms</a>: Custom Form Layout</h1> | |
<p>Implementing custom form layout using BoundFields and React.DOM.</p> | |
<p>(Please don't mention <small>clowns</small>)</p> | |
<div id="app"></div> | |
<script type="text/jsx" src="customlayout.js"></script> | |
<a href="https://gist.github.com/insin/9335123#file-customlayout-js"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* isomorph 0.2.1 - https://github.com/insin/isomorph | |
* MIT Licensed | |
*/ | |
!function(r){if("object"==typeof exports)module.exports=r();else if("function"==typeof define&&define.amd)define(r);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.isomorph=r()}}(function(){return function r(t,e,n){function o(u,a){if(!e[u]){if(!t[u]){var c="function"==typeof require&&require;if(!a&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=e[u]={exports:{}};t[u][0].call(s.exports,function(r){var e=t[u][1][r];return o(e?e:r)},s,s.exports,r,t,e,n)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(r,t){"use strict";function e(r){for(var t,e=0,i=r.length;i>e;e++)t=r[e],n.Array(t)&&(i+=t.length-1,o.apply(r,[e,1].concat(t)),e--);return r}var n=r("./is"),o=Array.prototype.splice;t.exports={flatten:e}},{"./is":6}],2:[function(r,t){"use strict";function e(){}function n(r){return"object"==typeof r?(e.prototype=r,new e):r}function o(r){if("object"!=typeof r)return r;var t=r.valueOf();if(r!=t)return new r.constructor(t);var e,o;if(r instanceof r.constructor&&r.constructor!==Object){e=n(r.constructor.prototype);for(o in r)r.hasOwnProperty(o)&&(e[o]=r[o])}else{e={};for(o in r)e[o]=r[o]}return e}function i(r){for(var t in r)this[t]=r[t]}function u(){this.copiedObjects=[];var r=this;this.recursiveDeepCopy=function(t){return r.deepCopy(t)},this.depth=0}function a(r,t){var e=new u;return t&&(e.maxDepth=t),e.deepCopy(r)}var c=r("./is"),s=[];i.prototype={constructor:i,canCopy:function(){return!1},create:function(){},populate:function(){}},u.prototype={constructor:u,maxDepth:256,cacheResult:function(r,t){this.copiedObjects.push([r,t])},getCachedResult:function(r){for(var t=this.copiedObjects,e=t.length,n=0;e>n;n++)if(t[n][0]===r)return t[n][1];return void 0},deepCopy:function(r){if(null===r)return null;if("object"!=typeof r)return r;var t=this.getCachedResult(r);if(t)return t;for(var e=0;e<s.length;e++){var n=s[e];if(n.canCopy(r))return this.applyDeepCopier(n,r)}throw new Error("no DeepCopier is able to copy "+r)},applyDeepCopier:function(r,t){var e=r.create(t);if(this.cacheResult(t,e),this.depth++,this.depth>this.maxDepth)throw new Error("Exceeded max recursion depth in deep copy.");return r.populate(this.recursiveDeepCopy,t,e),this.depth--,e}},a.DeepCopier=i,a.deepCopiers=s,a.register=function(r){r instanceof i||(r=new i(r)),s.unshift(r)},a.register({canCopy:function(){return!0},create:function(r){return r instanceof r.constructor?n(r.constructor.prototype):{}},populate:function(r,t,e){for(var n in t)t.hasOwnProperty(n)&&(e[n]=r(t[n]));return e}}),a.register({canCopy:function(r){return c.Array(r)},create:function(r){return new r.constructor},populate:function(r,t,e){for(var n=0;n<t.length;n++)e.push(r(t[n]));return e}}),a.register({canCopy:function(r){return c.Date(r)},create:function(r){return new Date(r)}}),a.register({canCopy:function(r){return c.RegExp(r)},create:function(r){return r}}),t.exports={DeepCopyAlgorithm:u,copy:o,clone:n,deepCopy:a}},{"./is":6}],3:[function(r,t){"use strict";function e(r){return n(r,u.call(arguments,1))}function n(r,t){var e=0;return r.replace(a,function(r){return"%%"==r?"%":t[e++]})}function o(r,t){return r.replace(c,function(r,e,n){return 2==e.length?r.slice(1):t[n]})}function i(r,t){t=Math.min(t||768,1024);for(var e=-1,n="bytes",o=r;o>t&&e<s.length;)o/=1024,e++;return e>-1&&(n=s.charAt(e)+"B"),o.toFixed(2).replace(f,"")+" "+n}var u=Array.prototype.slice,a=/%[%s]/g,c=/({{?)(\w+)}/g,s="kMGTPEZY",f=/\.00$|0$/;t.exports={format:e,formatArr:n,formatObj:o,fileSize:i}},{}],4:[function(r,t){"use strict";function e(r,t){var e=arguments.length>2?n.call(arguments,2):null,o=function(){var o=e?e.concat(n.call(arguments)):arguments;return r.apply(t,o)};return o.__func__=r,o.__context__=t,o}var n=Array.prototype.slice;t.exports={bind:e}},{}],5:[function(r,t){"use strict";t.exports={is:r("./is"),array:r("./array"),func:r("./func"),object:r("./object"),format:r("./format"),re:r("./re"),querystring:r("./querystring"),copy:r("./copy"),time:r("./time"),url:r("./url")}},{"./array":1,"./copy":2,"./format":3,"./func":4,"./is":6,"./object":7,"./querystring":8,"./re":9,"./time":10,"./url":11}],6:[function(r,t){"use strict";function e(r){return"[object Array]"==l.call(r)}function n(r){return"[object Boolean]"==l.call(r)}function o(r){return"[object Date]"==l.call(r)}function i(r){return"[object Error]"==l.call(r)}function u(r){return"[object Function]"==l.call(r)}function a(r){return"[object Number]"==l.call(r)}function c(r){return"[object Object]"==l.call(r)}function s(r){return"[object RegExp]"==l.call(r)}function f(r){return"[object String]"==l.call(r)}function p(r){for(var t in r)return!1;return!0}var l=Object.prototype.toString;t.exports={Array:e,Boolean:n,Date:o,Empty:p,Error:i,Function:u,NaN:isNaN,Number:a,Object:c,RegExp:s,String:f}},{}],7:[function(r,t){"use strict";function e(r){for(var t,e=1,n=arguments.length;n>e;e++)if(t=arguments[e])for(var o in t)f(t,o)&&(r[o]=t[o]);return r}function n(r,t){var e=function(){};return e.prototype=t.prototype,r.prototype=new e,r.prototype.constructor=r,r}function o(r){var t=[];for(var e in r)f(r,e)&&t.push([e,r[e]]);return t}function i(r){for(var t,e={},n=0,o=r.length;o>n;n++)t=r[n],e[t[0]]=t[1];return e}function u(r){for(var t={},e=0,n=r.length;n>e;e++)t[""+r[e]]=!0;return t}function a(r,t,e){return f(r,t)?r[t]:e}function c(r,t,e){if(null==r)throw new Error("popProp was given "+r);if(f(r,t)){var n=r[t];return delete r[t],n}if(2==arguments.length)throw new Error("popProp was given an object which didn't have an own '"+t+"' property, without a default value to return");return e}function s(r,t,e){if(null==r)throw new Error("setDefault was given "+r);return e=e||null,f(r,t)?r[t]:(r[t]=e,e)}var f=function(){var r=Object.prototype.hasOwnProperty;return function(t,e){return r.call(t,e)}}();t.exports={hasOwn:f,extend:e,inherits:n,items:o,fromItems:i,lookup:u,get:a,pop:c,setDefault:s}},{}],8:[function(r,t){"use strict";function e(r){var t={};if(r.length<2)return t;for(var e=r.substring(1).split("&"),n=0,i=e.length;i>n;n++){var u=e[n].split("="),a=u[0],c=decodeURIComponent(u[1]);t.hasOwnProperty(a)?o.Array(t[a])?t[a].push(c):t[a]=[t[a],c]:t[a]=c}return t}function n(r){var t=[];for(var e in r)if(o.Array(r[e]))for(var n=r[e],i=0,u=n.length;u>i;i++)t.push(e+"="+encodeURIComponent(n[i]));else t.push(e+"="+encodeURIComponent(r[e]));return t.join("&")}var o=r("./is");t.exports={parse:e,stringify:n}},{"./is":6}],9:[function(r,t){"use strict";function e(r,t,e){n.RegExp(r)||(r=new RegExp(r,e));for(var o=null,i=[];null!==(o=r.exec(t));){switch(o.length){case 1:i.push(o[0]);break;case 2:i.push(o[1]);break;default:i.push(o.slice(1))}if(!r.global)break}return i}var n=r("./is");t.exports={findAll:e}},{"./is":6}],10:[function(r,t){"use strict";function e(r){return 10>r?"0"+r:r}function n(r,t){for(var e=0,n=t.length;n>e;e++)if(r===t[e])return e;return-1}function o(r,t){this.format=r,this.locale=t;var e=o._cache[t.name+"|"+r];void 0!==e?(this.re=e[0],this.matchOrder=e[1]):this.compilePattern()}var i=r("./is"),u={b:function(r){return"("+r.b.join("|")+")"},B:function(r){return"("+r.B.join("|")+")"},p:function(r){return"("+r.AM+"|"+r.PM+")"},d:"(\\d\\d?)",H:"(\\d\\d?)",I:"(\\d\\d?)",m:"(\\d\\d?)",M:"(\\d\\d?)",S:"(\\d\\d?)",y:"(\\d\\d?)",Y:"(\\d{4})","%":"%"},a={a:function(r,t){return t.a[r.getDay()]},A:function(r,t){return t.A[r.getDay()]},b:function(r,t){return t.b[r.getMonth()]},B:function(r,t){return t.B[r.getMonth()]},d:function(r){return e(r.getDate(),2)},H:function(r){return e(r.getHours(),2)},M:function(r){return e(r.getMinutes(),2)},m:function(r){return e(r.getMonth()+1,2)},S:function(r){return e(r.getSeconds(),2)},w:function(r){return r.getDay()},Y:function(r){return r.getFullYear()},"%":function(){return"%"}},c=/[^%]%$/;o._cache={},o.prototype.compilePattern=function(){for(var r,t,e=this.format.split(/(?:\s|\t|\n)+/).join(" "),n=[],a=[],c=0,s=e.length;s>c;c++)if(r=e.charAt(c),"%"==r){if(c==s-1)throw new Error("strptime format ends with raw %");if(r=e.charAt(++c),t=u[r],void 0===t)throw new Error("strptime format contains an unknown directive: %"+r);n.push(i.Function(t)?t(this.locale):t),"%"!=r&&a.push(r)}else n.push(" "===r?" +":r);this.re=new RegExp("^"+n.join("")+"$"),this.matchOrder=a,o._cache[this.locale.name+"|"+this.format]=[this.re,a]},o.prototype.parse=function(r){var t=this.re.exec(r);if(null===t)throw new Error("Time data did not match format: data="+r+", format="+this.format);for(var e=[1900,1,1,0,0,0],o={},i=1,u=t.length;u>i;i++)o[this.matchOrder[i-1]]=t[i];if(o.hasOwnProperty("Y"))e[0]=parseInt(o.Y,10);else if(o.hasOwnProperty("y")){var a=parseInt(o.y,10);68>a?a=2e3+a:100>a&&(a=1900+a),e[0]=a}if(o.hasOwnProperty("m")){var c=parseInt(o.m,10);if(1>c||c>12)throw new Error("Month is out of range: "+c);e[1]=c}else o.hasOwnProperty("B")?e[1]=n(o.B,this.locale.B)+1:o.hasOwnProperty("b")&&(e[1]=n(o.b,this.locale.b)+1);if(o.hasOwnProperty("d")){var s=parseInt(o.d,10);if(1>s||s>31)throw new Error("Day is out of range: "+s);e[2]=s}var f;if(o.hasOwnProperty("H")){if(f=parseInt(o.H,10),f>23)throw new Error("Hour is out of range: "+f);e[3]=f}else if(o.hasOwnProperty("I")){if(f=parseInt(o.I,10),1>f||f>12)throw new Error("Hour is out of range: "+f);12==f&&(f=0),e[3]=f,o.hasOwnProperty("p")&&o.p==this.locale.PM&&(e[3]=e[3]+12)}if(o.hasOwnProperty("M")){var p=parseInt(o.M,10);if(p>59)throw new Error("Minute is out of range: "+p);e[4]=p}if(o.hasOwnProperty("S")){var l=parseInt(o.S,10);if(l>59)throw new Error("Second is out of range: "+l);e[5]=l}if(s=e[2],c=e[1],a=e[0],(4==c||6==c||9==c||11==c)&&s>30||2==c&&s>(a%4===0&&a%100!==0||a%400===0?29:28))throw new Error("Day is out of range: "+s);return e};var s={defaultLocale:"en",locales:{en:{name:"en",a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],AM:"AM",b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],PM:"PM"}}},f=s.getLocale=function(r){if(r){if(s.locales.hasOwnProperty(r))return s.locales[r];if(r.length>2){var t=r.substring(0,2);if(s.locales.hasOwnProperty(t))return s.locales[t]}}return s.locales[s.defaultLocale]},p=s.strptime=function(r,t,e){return new o(t,f(e)).parse(r)};s.strpdate=function(r,t,e){var n=p(r,t,e);return new Date(n[0],n[1]-1,n[2],n[3],n[4],n[5])},s.strftime=function(r,t,e){if(c.test(t))throw new Error("strftime format ends with raw %");return e=f(e),t.replace(/(%.)/g,function(t,n){var o=n.charAt(1);if("undefined"==typeof a[o])throw new Error("strftime format contains an unknown directive: "+n);return a[o](r,e)})},t.exports=s},{"./is":6}],11:[function(r,t){"use strict";function e(r){for(var t=e.options,n=t.parser[t.strictMode?"strict":"loose"].exec(r),o={},i=14;i--;)o[t.key[i]]=n[i]||"";return o[t.q.name]={},o[t.key[12]].replace(t.q.parser,function(r,e,n){e&&(o[t.q.name][e]=n)}),o}function n(r){var t="";r.protocol&&(t+=r.protocol+"://"),r.user&&(t+=r.user),r.password&&(t+=":"+r.password),(r.user||r.password)&&(t+="@"),r.host&&(t+=r.host),r.port&&(t+=":"+r.port),r.path&&(t+=r.path);var e=r.queryKey,n=[];for(var o in e)if(e.hasOwnProperty(o)){var i=encodeURIComponent(e[o]);o=encodeURIComponent(o),n.push(i?o+"="+i:o)}return n.length>0&&(t+="?"+n.join("&")),r.anchor&&(t+="#"+r.anchor),t}e.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},t.exports={parseUri:e,makeUri:n}},{}]},{},[5])(5)}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* newforms 0.5.0-dev - https://github.com/insin/newforms | |
* MIT Licensed | |
*/ | |
!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.forms=t()}}(function(){var t;return function e(t,r,i){function n(s,a){if(!r[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=r[s]={exports:{}};t[s][0].call(u.exports,function(e){var r=t[s][1][e];return n(r?r:e)},u,u.exports,e,t,r,i)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(t,e){"use strict";e.exports={browser:"undefined"==typeof process}},{}],2:[function(t,e){"use strict";var r=t("Concur"),i=t("isomorph/is"),n=t("isomorph/object"),o=t("isomorph/time"),s=t("isomorph/url"),a=t("validators"),l=t("./env"),u=t("./util"),c=t("./widgets"),h=a.ValidationError,d=c.Widget,p=a.ipv6.cleanIPv6Address,f=r.extend({widget:c.TextInput,hiddenWidget:c.HiddenInput,defaultValidators:[],defaultErrorMessages:{required:"This field is required."},emptyValues:a.EMPTY_VALUES.slice(),emptyValueArray:!0,constructor:function U(t){t=n.extend({required:!0,widget:null,label:null,initial:null,helpText:null,errorMessages:null,showHiddenInitial:!1,validators:[],cssClass:null},t),this.required=t.required,this.label=t.label,this.initial=t.initial,this.showHiddenInitial=t.showHiddenInitial,this.helpText=t.helpText||"",this.cssClass=t.cssClass;var e=t.widget||this.widget;e instanceof d||(e=new e),e.isRequired=this.required,n.extend(e.attrs,this.widgetAttrs(e)),this.widget=e,this.creationCounter=U.creationCounter++;for(var r=[{}],i=this.constructor.__mro__.length-1;i>=0;i--)r.push(n.get(this.constructor.__mro__[i].prototype,"defaultErrorMessages",null));r.push(t.errorMessages),this.errorMessages=n.extend.apply(n,r),this.validators=this.defaultValidators.concat(t.validators)}});f.creationCounter=0,f.prototype.prepareValue=function(t){return t},f.prototype.toJavaScript=function(t){return t},f.prototype.isEmptyValue=function(t){return-1!=this.emptyValues.indexOf(t)?!0:this.emptyValueArray===!0&&i.Array(t)&&0===t.length?!0:!1},f.prototype.validate=function(t){if(this.required&&this.isEmptyValue(t))throw h(this.errorMessages.required,{code:"required"})},f.prototype.runValidators=function(t){if(!this.isEmptyValue(t)){for(var e=[],r=0,i=this.validators.length;i>r;r++){var o=this.validators[r];try{o(t)}catch(s){if(!(s instanceof h))throw s;n.hasOwn(s,"code")&&n.hasOwn(this.errorMessages,s.code)&&(s.message=this.errorMessages[s.code]),e.push.apply(e,s.errorList)}}if(e.length>0)throw h(e)}},f.prototype.clean=function(t){return t=this.toJavaScript(t),this.validate(t),this.runValidators(t),t},f.prototype.boundData=function(t){return t},f.prototype.widgetAttrs=function(){return{}},f.prototype._hasChanged=function(t,e){var r=null===t?"":t;try{e=this.toJavaScript(e),"function"==typeof this._coerce&&(e=this._coerce(e))}catch(i){if(!(i instanceof h))throw i;return!0}var n=null===e?"":e;return""+r!=""+n};var m=f.extend({constructor:function B(t){return this instanceof f?(t=n.extend({maxLength:null,minLength:null},t),this.maxLength=t.maxLength,this.minLength=t.minLength,f.call(this,t),null!==this.minLength&&this.validators.push(a.MinLengthValidator(this.minLength)),void(null!==this.maxLength&&this.validators.push(a.MaxLengthValidator(this.maxLength)))):new B(t)}});m.prototype.toJavaScript=function(t){return this.isEmptyValue(t)?"":""+t},m.prototype.widgetAttrs=function(t){var e={};return null!==this.maxLength&&(t instanceof c.TextInput||t instanceof c.PasswordInput)&&(e.maxLength=""+this.maxLength),e};var v=f.extend({widget:c.NumberInput,defaultErrorMessages:{invalid:"Enter a whole number."},constructor:function H(t){return this instanceof f?(t=n.extend({maxValue:null,minValue:null},t),this.maxValue=t.maxValue,this.minValue=t.minValue,f.call(this,t),null!==this.minValue&&this.validators.push(a.MinValueValidator(this.minValue)),void(null!==this.maxValue&&this.validators.push(a.MaxValueValidator(this.maxValue)))):new H(t)}});v.prototype.toJavaScript=function(t){if(t=f.prototype.toJavaScript.call(this,t),this.isEmptyValue(t))return null;if(t=Number(t),isNaN(t)||-1!=t.toString().indexOf("."))throw h(this.errorMessages.invalid,{code:"invalid"});return t},v.prototype.widgetAttrs=function(t){var e=f.prototype.widgetAttrs.call(this,t);return t instanceof c.NumberInput&&(null!==this.minValue&&(e.min=this.minValue),null!==this.maxValue&&(e.max=this.maxValue)),e};var g=v.extend({defaultErrorMessages:{invalid:"Enter a number."},constructor:function J(t){return this instanceof f?void v.call(this,t):new J(t)}});g.FLOAT_REGEXP=/^[-+]?(?:\d+(?:\.\d*)?|(?:\d+)?\.\d+)$/,g.prototype.toJavaScript=function(t){if(t=f.prototype.toJavaScript.call(this,t),this.isEmptyValue(t))return null;if(t=u.strip(t),!g.FLOAT_REGEXP.test(t))throw h(this.errorMessages.invalid,{code:"invalid"});if(t=parseFloat(t),isNaN(t))throw h(this.errorMessages.invalid,{code:"invalid"});return t},g.prototype._hasChanged=function(t,e){var r=null===e?"":e,i=null===t?"":t;return i===r?!1:""===i||""===r?!0:parseFloat(""+i)!=parseFloat(""+r)},g.prototype.widgetAttrs=function(t){var e=v.prototype.widgetAttrs.call(this,t);return t instanceof c.NumberInput&&!n.hasOwn(t.attrs,"step")&&n.setDefault(e,"step","any"),e};var y=v.extend({defaultErrorMessages:{invalid:"Enter a number.",maxDigits:"Ensure that there are no more than {maxDigits} digits in total.",maxDecimalPlaces:"Ensure that there are no more than {maxDecimalPlaces} decimal places.",maxWholeDigits:"Ensure that there are no more than {maxWholeDigits} digits before the decimal point."},constructor:function W(t){return this instanceof f?(t=n.extend({maxDigits:null,decimalPlaces:null},t),this.maxDigits=t.maxDigits,this.decimalPlaces=t.decimalPlaces,void v.call(this,t)):new W(t)}});y.DECIMAL_REGEXP=/^[-+]?(?:\d+(?:\.\d*)?|(?:\d+)?\.\d+)$/,y.prototype.clean=function(t){if(f.prototype.validate.call(this,t),this.isEmptyValue(t))return null;if(t=u.strip(""+t),!y.DECIMAL_REGEXP.test(t))throw h(this.errorMessages.invalid,{code:"invalid"});var e=!1;("+"==t.charAt(0)||"-"==t.charAt(0))&&(e="-"==t.charAt(0),t=t.substr(1)),t=t.replace(/^0+/,""),t.indexOf(".")==t.length-1&&(t=t.substring(0,t.length-1));var r=t.split("."),i=r[0].length,n=2==r.length?r[1].length:0,o=i+n;if(null!==this.maxDigits&&o>this.maxDigits)throw h(this.errorMessages.maxDigits,{code:"maxDigits",params:{maxDigits:this.maxDigits}});if(null!==this.decimalPlaces&&n>this.decimalPlaces)throw h(this.errorMessages.maxDecimalPlaces,{code:"maxDecimalPlaces",params:{maxDecimalPlaces:this.decimalPlaces}});if(null!==this.maxDigits&&null!==this.decimalPlaces&&i>this.maxDigits-this.decimalPlaces)throw h(this.errorMessages.maxWholeDigits,{code:"maxWholeDigits",params:{maxWholeDigits:this.maxDigits-this.decimalPlaces}});return"."==t.charAt(0)&&(t="0"+t),e&&(t="-"+t),this.runValidators(parseFloat(t)),t},y.prototype.widgetAttrs=function(t){var e=v.prototype.widgetAttrs.call(this,t);if(t instanceof c.NumberInput&&!n.hasOwn(t.attrs,"step")){var r="any";null!==this.decimalPlaces&&(r=0===this.decimalPlaces?"1":this.decimalPlaces<7?"0."+"000001".slice(-this.decimalPlaces):"1e-"+this.decimalPlaces),n.setDefault(e,"step",r)}return e};var x=f.extend({constructor:function(t){t=n.extend({inputFormats:null},t),f.call(this,t),null!==t.inputFormats&&(this.inputFormats=t.inputFormats)}});x.prototype.toJavaScript=function(t){if(i.Date(t)||(t=u.strip(t)),i.String(t))for(var e=0,r=this.inputFormats.length;r>e;e++)try{return this.strpdate(t,this.inputFormats[e])}catch(n){continue}throw h(this.errorMessages.invalid,{code:"invalid"})},x.prototype.strpdate=function(t,e){return o.strpdate(t,e)},x.prototype._hasChanged=function(t,e){try{e=this.toJavaScript(e)}catch(r){if(!(r instanceof h))throw r;return!0}return t=this.toJavaScript(t),t&&e?t.getTime()!==e.getTime():t!==e};var w=x.extend({widget:c.DateInput,inputFormats:u.DEFAULT_DATE_INPUT_FORMATS,defaultErrorMessages:{invalid:"Enter a valid date."},constructor:function Y(t){return this instanceof f?void x.call(this,t):new Y(t)}});w.prototype.toJavaScript=function(t){return this.isEmptyValue(t)?null:t instanceof Date?new Date(t.getFullYear(),t.getMonth(),t.getDate()):x.prototype.toJavaScript.call(this,t)};var _=x.extend({widget:c.TimeInput,inputFormats:u.DEFAULT_TIME_INPUT_FORMATS,defaultErrorMessages:{invalid:"Enter a valid time."},constructor:function $(t){return this instanceof f?void x.call(this,t):new $(t)}});_.prototype.toJavaScript=function(t){return this.isEmptyValue(t)?null:t instanceof Date?new Date(1900,0,1,t.getHours(),t.getMinutes(),t.getSeconds()):x.prototype.toJavaScript.call(this,t)},_.prototype.strpdate=function(t,e){var r=o.strptime(t,e);return new Date(1900,0,1,r[3],r[4],r[5])};var b=x.extend({widget:c.DateTimeInput,inputFormats:u.DEFAULT_DATETIME_INPUT_FORMATS,defaultErrorMessages:{invalid:"Enter a valid date/time."},constructor:function Z(t){return this instanceof f?void x.call(this,t):new Z(t)}});b.prototype.toJavaScript=function(t){if(this.isEmptyValue(t))return null;if(t instanceof Date)return t;if(i.Array(t)){if(2!=t.length)throw h(this.errorMessages.invalid,{code:"invalid"});if(this.isEmptyValue(t[0])&&this.isEmptyValue(t[1]))return null;t=t.join(" ")}return x.prototype.toJavaScript.call(this,t)};var F=m.extend({constructor:function G(t,e){return this instanceof f?(m.call(this,e),i.String(t)&&(t=new RegExp(t)),this.regex=t,void this.validators.push(a.RegexValidator({regex:this.regex}))):new G(t,e)}}),E=m.extend({widget:c.EmailInput,defaultValidators:[a.validateEmail],constructor:function X(t){return this instanceof f?void m.call(this,t):new X(t)}});E.prototype.clean=function(t){return t=u.strip(this.toJavaScript(t)),m.prototype.clean.call(this,t)};var M=f.extend({widget:c.ClearableFileInput,defaultErrorMessages:{invalid:"No file was submitted. Check the encoding type on the form.",missing:"No file was submitted.",empty:"The submitted file is empty.",maxLength:"Ensure this filename has at most {max} characters (it has {length}).",contradicton:"Please either submit a file or check the clear checkbox, not both."},constructor:function z(t){return this instanceof f?(t=n.extend({maxLength:null,allowEmptyFile:!1},t),this.maxLength=t.maxLength,this.allowEmptyFile=t.allowEmptyFile,delete t.maxLength,void f.call(this,t)):new z(t)}});M.prototype.toJavaScript=function(t){if(this.isEmptyValue(t))return null;if(l.browser)return t;if("undefined"==typeof t.name||"undefined"==typeof t.size)throw h(this.errorMessages.invalid,{code:"invalid"});var e=t.name,r=t.size;if(null!==this.maxLength&&e.length>this.maxLength)throw h(this.errorMessages.maxLength,{code:"maxLength",params:{max:this.maxLength,length:e.length}});if(!e)throw h(this.errorMessages.invalid,{code:"invalid"});if(!this.allowEmptyFile&&!r)throw h(this.errorMessages.empty,{code:"empty"});return t},M.prototype.clean=function(t,e){if(t===c.FILE_INPUT_CONTRADICTION)throw h(this.errorMessages.contradiction,{code:"contradiction"});if(t===!1){if(!this.required)return!1;t=null}return!t&&e?e:f.prototype.clean.call(this,t)},M.prototype.boundData=function(t,e){return null===t||t===c.FILE_INPUT_CONTRADICTION?e:t},M.prototype._hasChanged=function(t,e){return null===e?!1:!0};var C=M.extend({defaultErrorMessages:{invalidImage:"Upload a valid image. The file you uploaded was either not an image or a corrupted image."},constructor:function K(t){return this instanceof f?void M.call(this,t):new K(t)}});C.prototype.toJavaScript=function(t,e){var r=M.prototype.toJavaScript.call(this,t,e);return null===r?null:r};var D=m.extend({widget:c.URLInput,defaultErrorMessages:{invalid:"Enter a valid URL."},defaultValidators:[a.URLValidator()],constructor:function Q(t){return this instanceof f?void m.call(this,t):new Q(t)}});D.prototype.toJavaScript=function(t){if(t){var e=s.parseUri(t);e.protocol||(e.protocol="http"),e.path||(e.path="/"),t=s.makeUri(e)}return m.prototype.toJavaScript.call(this,t)},D.prototype.clean=function(t){return t=u.strip(this.toJavaScript(t)),m.prototype.clean.call(this,t)};var O=f.extend({widget:c.CheckboxInput,constructor:function te(t){return this instanceof f?void f.call(this,t):new te(t)}});O.prototype.toJavaScript=function(t){if(t=!i.String(t)||"false"!=t.toLowerCase()&&"0"!=t?Boolean(t):!1,t=f.prototype.toJavaScript.call(this,t),!t&&this.required)throw h(this.errorMessages.required,{code:"required"});return t},O.prototype._hasChanged=function(t,e){return"false"===t&&(t=!1),Boolean(t)!=Boolean(e)};var I=O.extend({widget:c.NullBooleanSelect,constructor:function ee(t){return this instanceof f?void O.call(this,t):new ee(t)}});I.prototype.toJavaScript=function(t){return t===!0||"True"==t||"true"==t||"1"==t?!0:t===!1||"False"==t||"false"==t||"0"==t?!1:null},I.prototype.validate=function(){},I.prototype._hasChanged=function(t,e){return null!==t&&(t=Boolean(t)),null!==e&&(e=Boolean(e)),t!=e};var A=f.extend({widget:c.Select,defaultErrorMessages:{invalidChoice:"Select a valid choice. {value} is not one of the available choices."},constructor:function re(t){return this instanceof f?(t=n.extend({choices:[]},t),f.call(this,t),void this.setChoices(t.choices)):new re(t)}});A.prototype.choices=function(){return this._choices},A.prototype.setChoices=function(t){this._choices=this.widget.choices=t},A.prototype.toJavaScript=function(t){return this.isEmptyValue(t)?"":""+t},A.prototype.validate=function(t){if(f.prototype.validate.call(this,t),t&&!this.validValue(t))throw h(this.errorMessages.invalidChoice,{code:"invalidChoice",params:{value:t}})},A.prototype.validValue=function(t){for(var e=this.choices(),r=0,n=e.length;n>r;r++)if(i.Array(e[r][1])){for(var o=e[r][1],s=0,a=o.length;a>s;s++)if(t===""+o[s][0])return!0}else if(t===""+e[r][0])return!0;return!1};var T=A.extend({constructor:function ie(t){return this instanceof f?(t=n.extend({coerce:function(t){return t},emptyValue:""},t),this.coerce=n.pop(t,"coerce"),this.emptyValue=n.pop(t,"emptyValue"),void A.call(this,t)):new ie(t)}});T.prototype._coerce=function(t){if(t===this.emptyValue||this.isEmptyValue(t))return this.emptyValue;try{t=this.coerce(t)}catch(e){throw h(this.errorMessages.invalidChoice,{code:"invalidChoice",params:{value:t}})}return t},T.prototype.clean=function(t){return t=A.prototype.clean.call(this,t),this._coerce(t)};var V=A.extend({hiddenWidget:c.MultipleHiddenInput,widget:c.SelectMultiple,defaultErrorMessages:{invalidChoice:"Select a valid choice. {value} is not one of the available choices.",invalidList:"Enter a list of values."},constructor:function ne(t){return this instanceof f?void A.call(this,t):new ne(t)}});V.prototype.toJavaScript=function(t){if(!t)return[];if(!i.Array(t))throw h(this.errorMessages.invalidList,{code:"invalidList"});for(var e=[],r=0,n=t.length;n>r;r++)e.push(""+t[r]);return e},V.prototype.validate=function(t){if(this.required&&!t.length)throw h(this.errorMessages.required,{code:"required"});for(var e=0,r=t.length;r>e;e++)if(!this.validValue(t[e]))throw h(this.errorMessages.invalidChoice,{code:"invalidChoice",params:{value:t[e]}})},V.prototype._hasChanged=function(t,e){if(null===t&&(t=[]),null===e&&(e=[]),t.length!=e.length)return!0;for(var r=n.lookup(e),i=0,o=t.length;o>i;i++)if("undefined"==typeof r[""+t[i]])return!0;return!1};var P=V.extend({constructor:function oe(t){return this instanceof f?(t=n.extend({coerce:function(t){return t},emptyValue:[]},t),this.coerce=n.pop(t,"coerce"),this.emptyValue=n.pop(t,"emptyValue"),void V.call(this,t)):new oe(t)}});P.prototype._coerce=function(t){if(t===this.emptyValue||this.isEmptyValue(t)||i.Array(t)&&!t.length)return this.emptyValue;for(var e=[],r=0,n=t.length;n>r;r++)try{e.push(this.coerce(t[r]))}catch(o){throw h(this.errorMessages.invalidChoice,{code:"invalidChoice",params:{value:t[r]}})}return e},P.prototype.clean=function(t){return t=V.prototype.clean.call(this,t),this._coerce(t)},P.prototype.validate=function(t){if(t!==this.emptyValue||i.Array(t)&&t.length)V.prototype.validate.call(this,t);else if(this.required)throw h(this.errorMessages.required,{code:"required"})};var S=A.extend({constructor:function se(t,e){return this instanceof f?(e=n.extend({match:null,recursive:!1,required:!0,widget:null,label:null,initial:null,helpText:null},e),this.path=t,this.match=e.match,this.recursive=e.recursive,delete e.match,delete e.recursive,e.choices=[],A.call(this,e),this.setChoices(this.required?[]:[["","---------"]]),null!==this.match&&(this.matchRE=new RegExp(this.match)),void(this.widget.choices=this.choices())):new se(t,e)}}),j=f.extend({constructor:function ae(t){if(!(this instanceof f))return new ae(t);t=n.extend({fields:[]},t),f.call(this,t);for(var e=0,r=t.fields.length;r>e;e++)t.fields[e].required=!1;this.fields=t.fields}});j.prototype.clean=function(t){f.prototype.clean.call(this,t);for(var e=0,r=this.fields.length;r>e;e++)t=this.fields[e].clean(t);return t};var L=f.extend({defaultErrorMessages:{invalid:"Enter a list of values.",incomplete:"Enter a complete value."},constructor:function le(t){if(!(this instanceof f))return new le(t);t=n.extend({fields:[]},t),this.requireAllFields=n.pop(t,"requireAllFields",!0),f.call(this,t);for(var e=0,r=t.fields.length;r>e;e++){var i=t.fields[e];n.setDefault(i.errorMessages,"incomplete",this.errorMessages.incomplete),this.requireAllFields&&(i.required=!1)}this.fields=t.fields}});L.prototype.validate=function(){},L.prototype.clean=function(t){var e=[],r=[];if(t&&!i.Array(t))throw h(this.errorMessages.invalid,{code:"invalid"});var n=!0;if(i.Array(t))for(var o=0,s=t.length;s>o;o++)if(t[o]){n=!1;break}if(!t||n){if(this.required)throw h(this.errorMessages.required,{code:"required"});return this.compress([])}for(o=0,s=this.fields.length;s>o;o++){var a=this.fields[o],l=t[o];if(void 0===l&&(l=null),this.isEmptyValue(l))if(this.requireAllFields){if(this.required)throw h(this.errorMessages.required,{code:"required"})}else if(a.required){-1==r.indexOf(a.errorMessages.incomplete)&&r.push(a.errorMessages.incomplete);continue}try{e.push(a.clean(l))}catch(u){if(!(u instanceof h))throw u;r=r.concat(u.messages().filter(function(t){return-1==r.indexOf(t)}))}}if(0!==r.length)throw h(r);var c=this.compress(e);return this.validate(c),this.runValidators(c),c},L.prototype.compress=function(){throw new Error("Subclasses must implement this method.")},L.prototype._hasChanged=function(t,e){if(null===t){t=[];for(var r=0,n=e.length;n>r;r++)t.push("")}else i.Array(t)||(t=this.widget.decompress(t));for(r=0,n=this.fields.length;n>r;r++)if(this.fields[r]._hasChanged(t[r],e[r]))return!0;return!1};var N=L.extend({hiddenWidget:c.SplitHiddenDateTimeWidget,widget:c.SplitDateTimeWidget,defaultErrorMessages:{invalidDate:"Enter a valid date.",invalidTime:"Enter a valid time."},constructor:function ue(t){if(!(this instanceof f))return new ue(t);t=n.extend({inputDateFormats:null,inputTimeFormats:null},t);var e=n.extend({},this.defaultErrorMessages);"undefined"!=typeof t.errorMessages&&n.extend(e,t.errorMessages),t.fields=[w({inputFormats:t.inputDateFormats,errorMessages:{invalid:e.invalidDate}}),_({inputFormats:t.inputTimeFormats,errorMessages:{invalid:e.invalidTime}})],L.call(this,t)}});N.prototype.compress=function(t){if(i.Array(t)&&t.length>0){var e=t[0],r=t[1];if(this.isEmptyValue(e))throw h(this.errorMessages.invalidDate,{code:"invalidDate"});if(this.isEmptyValue(r))throw h(this.errorMessages.invalidTime,{code:"invalidTime"});return new Date(e.getFullYear(),e.getMonth(),e.getDate(),r.getHours(),r.getMinutes(),r.getSeconds())}return null};var R=m.extend({defaultValidators:[a.validateIPv4Address],constructor:function ce(t){return this instanceof f?void m.call(this,t):new ce(t)}}),k=m.extend({constructor:function he(t){return this instanceof f?(t=n.extend({protocol:"both",unpackIPv4:!1},t),this.unpackIPv4=t.unpackIPv4,this.defaultValidators=a.ipAddressValidators(t.protocol,t.unpackIPv4).validators,void m.call(this,t)):new he(t)}});k.prototype.toJavaScript=function(t){return t?t&&-1!=t.indexOf(":")?p(t,{unpackIPv4:this.unpackIPv4}):t:""};var q=m.extend({defaultValidators:[a.validateSlug],constructor:function de(t){return this instanceof f?void m.call(this,t):new de(t)}});q.prototype.clean=function(t){return t=u.strip(this.toJavaScript(t)),m.prototype.clean.call(this,t)},e.exports={Field:f,CharField:m,IntegerField:v,FloatField:g,DecimalField:y,BaseTemporalField:x,DateField:w,TimeField:_,DateTimeField:b,RegexField:F,EmailField:E,FileField:M,ImageField:C,URLField:D,BooleanField:O,NullBooleanField:I,ChoiceField:A,TypedChoiceField:T,MultipleChoiceField:V,TypedMultipleChoiceField:P,FilePathField:S,ComboField:j,MultiValueField:L,SplitDateTimeField:N,IPAddressField:R,GenericIPAddressField:k,SlugField:q}},{"./env":1,"./util":6,"./widgets":7,Concur:8,"isomorph/is":12,"isomorph/object":13,"isomorph/time":14,"isomorph/url":15,validators:18}],3:[function(t,e){"use strict";function r(t,e,r,i,n,o,s,a){var l={key:e};r&&(l.className=r);var u=[l];return s&&u.push(s),i&&u.push(i),u.push(" "),u.push(n),o&&(u.push(" "),u.push(o)),a&&u.push.apply(u,a),t.apply(null,u)}function i(t,e,r,i,n){var o={key:e};n&&(o.className=n);var s=[o];return r&&s.push(r),i&&s.push.apply(s,i),t.apply(null,s)}function n(t){var e=r.bind(null,t),n=i.bind(null,t);return function(){return this._htmlOutput(e,n)}}function o(t){var e=[];Object.keys(t).forEach(function(r){t[r]instanceof x&&(e.push([r,t[r]]),delete t[r])}),e.sort(function(t,e){return t[1].creationCounter-e[1].creationCounter}),t.declaredFields=u.fromItems(e);var r={};if(u.hasOwn(this,"declaredFields")&&u.extend(r,this.declaredFields),u.hasOwn(t,"__mixin__")){var i=t.__mixin__;a.Array(i)||(i=[i]);for(var n=i.length-1;n>=0;n--){var o=i[n];if(a.Function(o)&&u.hasOwn(o.prototype,"declaredFields")){u.extend(r,o.prototype.declaredFields),Object.keys(o.prototype).forEach(function(t){u.hasOwn(r,t)&&delete r[t]});var s=u.extend({},o.prototype);delete s.baseFields,delete s.declaredFields,i[n]=s}}t.__mixin__=i}u.extend(r,t.declaredFields),Object.keys(t).forEach(function(t){u.hasOwn(r,t)&&delete r[t]}),t.baseFields=r,t.declaredFields=r}var s=t("Concur"),a=t("isomorph/is"),l=t("isomorph/format").formatObj,u=t("isomorph/object"),c=t("isomorph/copy"),h=t("validators"),d=window.React,p=t("./util"),f=t("./fields"),m=t("./widgets"),v=p.ErrorList,g=p.ErrorObject,y=h.ValidationError,x=f.Field,w=f.FileField,_=m.Textarea,b=m.TextInput,F="__all__",E=s.extend({constructor:function D(t,e,r){return this instanceof D?(this.form=t,this.field=e,this.name=r,this.htmlName=t.addPrefix(r),this.htmlInitialName=t.addInitialPrefix(r),this.htmlInitialId=t.addInitialPrefix(this.autoId()),this.label=null!==this.field.label?this.field.label:p.prettyName(r),void(this.helpText=e.helpText||"")):new D(t,e,r)}});E.prototype.errors=function(){return this.form.errors(this.name)||new this.form.errorConstructor},E.prototype.isHidden=function(){return this.field.widget.isHidden},E.prototype.autoId=function(){var t=this.form.autoId;return t?(t=""+t,-1!=t.indexOf("{name}")?l(t,{name:this.htmlName}):this.htmlName):""},E.prototype.data=function(){return this.field.widget.valueFromData(this.form.data,this.form.files,this.htmlName)},E.prototype.idForLabel=function(){var t=this.field.widget,e=u.get(t.attrs,"id",this.autoId());return t.idForLabel(e)},E.prototype.render=function(t){return this.field.showHiddenInitial?d.DOM.div(null,this.asWidget(t),this.asHidden({onlyInitial:!0})):this.asWidget(t)},E.prototype.subWidgets=E.prototype.__iter__=function(){return this.field.widget.subWidgets(this.htmlName,this.value())},E.prototype.asWidget=function(t){t=u.extend({widget:null,attrs:null,onlyInitial:!1},t);var e=null!==t.widget?t.widget:this.field.widget,r=null!==t.attrs?t.attrs:{},i=this.autoId(),n=t.onlyInitial?this.htmlInitialName:this.htmlName;return i&&"undefined"==typeof r.id&&"undefined"==typeof e.attrs.id&&(r.id=t.onlyInitial?this.htmlInitialId:i),e.render(n,this.value(),{attrs:r})},E.prototype.asText=function(t){return t=u.extend({},t,{widget:b()}),this.asWidget(t)},E.prototype.asTextarea=function(t){return t=u.extend({},t,{widget:_()}),this.asWidget(t)},E.prototype.asHidden=function(t){return t=u.extend({},t,{widget:new this.field.hiddenWidget}),this.asWidget(t)},E.prototype.value=function(){var t;return this.form.isBound?t=this.field.boundData(this.data(),u.get(this.form.initial,this.name,this.field.initial)):(t=u.get(this.form.initial,this.name,this.field.initial),a.Function(t)&&(t=t())),this.field.prepareValue(t)},E.prototype._addLabelSuffix=function(t,e){return e&&-1==":?.!".indexOf(t.charAt(t.length-1))?t+e:t},E.prototype.labelTag=function(t){t=u.extend({contents:this.label,attrs:null,labelSuffix:this.form.labelSuffix},t);var e=this._addLabelSuffix(t.contents,t.labelSuffix),r=this.field.widget,i=u.get(r.attrs,"id",this.autoId());if(i){var n=u.extend(t.attrs||{},{htmlFor:r.idForLabel(i)});e=d.DOM.label(n,e)}return e},E.prototype.cssClasses=function(t){var e=t?[t]:[];return null!==this.field.cssClass&&e.push(this.field.cssClass),"undefined"!=typeof this.form.rowCssClass&&e.push(this.form.rowCssClass),this.errors().isPopulated()&&"undefined"!=typeof this.form.errorCssClass&&e.push(this.form.errorCssClass),this.field.required&&"undefined"!=typeof this.form.requiredCssClass&&e.push(this.form.requiredCssClass),e.join(" ")};var M=s.extend({constructor:function(t){t=u.extend({data:null,files:null,autoId:"id_{name}",prefix:null,initial:null,errorConstructor:v,labelSuffix:":",emptyPermitted:!1},t),this.isBound=null!==t.data||null!==t.files,this.data=t.data||{},this.files=t.files||{},this.autoId=t.autoId,this.prefix=t.prefix,this.initial=t.initial||{},this.errorConstructor=t.errorConstructor,this.labelSuffix=t.labelSuffix,this.emptyPermitted=t.emptyPermitted,this._errors=null,this._changedData=null,this.fields=c.deepCopy(this.baseFields)}});M.prototype.setData=function(t){return this._errors=null,this._changedData=null,this.data=t,this.isBound||(this.isBound=!0),this.isValid()},M.prototype.errors=function(t){return null===this._errors&&this.fullClean(),t?this._errors.get(t):this._errors},M.prototype.changedData=function(){if(null===this._changedData){this._changedData=[];var t;for(var e in this.fields)if(u.hasOwn(this.fields,e)){var r=this.fields[e],i=this.addPrefix(e),n=r.widget.valueFromData(this.data,this.files,i);if(r.showHiddenInitial){var o=this.addInitialPrefix(e),s=new r.hiddenWidget;try{t=s.valueFromData(this.data,this.files,o)}catch(l){if(!(l instanceof y))throw l;this._changedData.push(e);continue}}else t=u.get(this.initial,e,r.initial),a.Function(t)&&(t=t());r._hasChanged(t,n)&&this._changedData.push(e)}}return this._changedData},M.prototype.render=function(){return this.asTable()},M.prototype.boundFields=function(t){t=t||function(){return!0};var e=[];for(var r in this.fields)u.hasOwn(this.fields,r)&&t(this.fields[r],r)===!0&&e.push(E(this,this.fields[r],r));return e},M.prototype.boundFieldsObj=function(t){t=t||function(){return!0};var e={};for(var r in this.fields)u.hasOwn(this.fields,r)&&t(this.fields[r],r)===!0&&(e[r]=E(this,this.fields[r],r));return e},M.prototype.boundField=function(t){if(!u.hasOwn(this.fields,t))throw new Error("Form does not have a '"+t+"' field.");return E(this,this.fields[t],t)},M.prototype.isValid=function(){return this.isBound?!this.errors().isPopulated():!1},M.prototype.addPrefix=function(t){return null!==this.prefix?l("{prefix}-{fieldName}",{prefix:this.prefix,fieldName:t}):t},M.prototype.addInitialPrefix=function(t){return l("initial-{fieldName}",{fieldName:this.addPrefix(t)})},M.prototype._htmlOutput=function(t,e){for(var r,i,n=this.nonFieldErrors(),o=[],s=this.hiddenFields(),l=0,c=s.length;c>l;l++)r=s[l],i=r.errors(),i.isPopulated&&n.extend(i.messages().map(function(t){return"(Hidden field "+r.name+") "+t})),o.push(r.render());var h,p,f,m,v=[],g=this.visibleFields();for(l=0,c=g.length;c>l;l++)r=g[l],i=r.errors(),h=i.isPopulated()?i.render():null,p=r.label?r.labelTag():null,f=r.helpText,f&&(f=a.Object(f)&&u.hasOwn(f,"__html")?d.DOM.span({className:"helpText",dangerouslySetInnerHTML:f}):d.DOM.span({className:"helpText"},f)),m=l==c-1&&o.length>0?o:null,v.push(t(r.htmlName,r.cssClasses(),p,r.render(),f,h,m));return n.isPopulated()&&(m=o.length>0&&0===v.length?o:null,v.unshift(e(this.addPrefix(F),n.render(),m))),o.length>0&&0===v.length&&v.push(e(this.addPrefix("__hiddenFields__"),null,o,this.hiddenFieldRowCssClass)),v},M.prototype.asTable=function(){function t(t,e,r,i,n,o,s){var a=[];o&&a.push(o),a.push(i),n&&(a.push(d.DOM.br(null)),a.push(n)),s&&a.push.apply(a,s);var l={key:t};return e&&(l.className=e),d.DOM.tr(l,d.DOM.th(null,r),d.DOM.td(null,a))}function e(t,e,r,i){var n=[];e&&n.push(e),r&&n.push.apply(n,r);var o={key:t};return i&&(o.className=i),d.DOM.tr(o,d.DOM.td({colSpan:2},n))}return function(){return this._htmlOutput(t,e)}}(),M.prototype.asUl=n(d.DOM.li),M.prototype.asDiv=n(d.DOM.div),M.prototype.nonFieldErrors=function(){return this.errors(F)||new this.errorConstructor},M.prototype._rawValue=function(t){var e=this.fields[t],r=this.addPrefix(t);return e.widget.valueFromData(this.data,this.files,r)},M.prototype.addError=function(t,e){if(e instanceof y||(e=y(e)),u.hasOwn(e,"errorObj")){if(null!==t)throw new Error("The argument 'field' must be null when the 'error' argument contains errors for multiple fields.");e=e.errorObj}else{var r=e.errorList;e={},e[t||F]=r}for(var i=Object.keys(e),n=0,o=i.length;o>n;n++){if(t=i[n],r=e[t],!this._errors.hasField(t)){if(t!==F&&!u.hasOwn(this.fields,t)){var s=this.constructor.name?"'"+this.constructor.name+"'":"Form";throw new Error(s+" has no field named '"+t+"'")}this._errors.set(t,new this.errorConstructor)}this._errors.get(t).extend(r),u.hasOwn(this.cleanedData,t)&&delete this.cleanedData[t]}},M.prototype.fullClean=function(){this._errors=g(),this.isBound&&(this.cleanedData={},(!this.emptyPermitted||this.hasChanged())&&(this._cleanFields(),this._cleanForm(),this._postClean()))},M.prototype._cleanFields=function(){for(var t in this.fields)if(u.hasOwn(this.fields,t)){var e=this.fields[t],r=e.widget.valueFromData(this.data,this.files,this.addPrefix(t));try{if(e instanceof w){var i=u.get(this.initial,t,e.initial);r=e.clean(r,i)}else r=e.clean(r);this.cleanedData[t]=r;var n="clean"+t.charAt(0).toUpperCase()+t.substr(1);"undefined"!=typeof this[n]&&a.Function(this[n])?(r=this[n](),"undefined"!=typeof r&&(this.cleanedData[t]=r)):(n="clean_"+t,"undefined"!=typeof this[n]&&a.Function(this[n])&&(r=this[n](),"undefined"!=typeof r&&(this.cleanedData[t]=r)))}catch(o){if(!(o instanceof y))throw o;this.addError(t,o)}}},M.prototype._cleanForm=function(){var t;try{t=this.clean()}catch(e){if(!(e instanceof y))throw e;this.addError(null,e)}t&&(this.cleanedData=t)},M.prototype._postClean=function(){},M.prototype.clean=function(){return this.cleanedData},M.prototype.hasChanged=function(){return this.changedData().length>0},M.prototype.isMultipart=function(){for(var t in this.fields)if(u.hasOwn(this.fields,t)&&this.fields[t].widget.needsMultipartForm)return!0;return!1},M.prototype.hiddenFields=function(){return this.boundFields(function(t){return t.widget.isHidden})},M.prototype.visibleFields=function(){return this.boundFields(function(t){return!t.widget.isHidden})};var C=M.extend({__meta__:o,constructor:function(){M.apply(this,arguments)}});e.exports={NON_FIELD_ERRORS:F,BoundField:E,BaseForm:M,DeclarativeFieldsMeta:o,Form:C}},{"./fields":2,"./util":6,"./widgets":7,Concur:8,"isomorph/copy":10,"isomorph/format":11,"isomorph/is":12,"isomorph/object":13,validators:18}],4:[function(t,e){"use strict";function r(t,e){e=o.extend({formset:M,extra:1,canOrder:!1,canDelete:!1,maxNum:F,validateMax:!1,minNum:b,validateMin:!1},e);var r=o.pop(e,"formset"),i=o.pop(e,"extra"),n=o.pop(e,"canOrder"),s=o.pop(e,"canDelete"),a=o.pop(e,"maxNum"),l=o.pop(e,"validateMax"),u=o.pop(e,"minNum"),c=o.pop(e,"validateMin"),h=a+F;i+=u,e.constructor=function(e){this.form=t,this.extra=i,this.canOrder=n,this.canDelete=s,this.maxNum=a,this.validateMax=l,this.minNum=u,this.validateMin=c,this.absoluteMax=h,r.call(this,e) | |
};var d=r.extend(e);return d}function i(t){for(var e=!0,r=0,i=t.length;i>r;r++)t[r].isValid()||(e=!1);return e}var n=t("Concur"),o=t("isomorph/object"),s=t("validators"),a=t("./util"),l=t("./widgets"),u=t("./fields"),c=t("./forms"),h=a.ErrorList,d=s.ValidationError,p=u.IntegerField,f=u.BooleanField,m=l.HiddenInput,v="TOTAL_FORMS",g="INITIAL_FORMS",y="MIN_NUM_FORMS",x="MAX_NUM_FORMS",w="ORDER",_="DELETE",b=0,F=1e3,E=function(){var t={};return t[v]=p({widget:m}),t[g]=p({widget:m}),t[y]=p({required:!1,widget:m}),t[x]=p({required:!1,widget:m}),c.Form.extend(t)}(),M=n.extend({constructor:function(t){t=o.extend({data:null,files:null,autoId:"id_{name}",prefix:null,initial:null,errorConstructor:h,managementFormCssClass:null},t),this.isBound=null!==t.data||null!==t.files,this.prefix=t.prefix||this.getDefaultPrefix(),this.autoId=t.autoId,this.data=t.data||{},this.files=t.files||{},this.initial=t.initial,this.errorConstructor=t.errorConstructor,this.managementFormCssClass=t.managementFormCssClass,this._forms=null,this._errors=null,this._nonFormErrors=null}});M.prototype.managementForm=function(){var t;if(this.isBound){if(t=new E({data:this.data,autoId:this.autoId,prefix:this.prefix}),!t.isValid())throw d("ManagementForm data is missing or has been tampered with",{code:"missing_management_form"})}else{var e={};e[v]=this.totalFormCount(),e[g]=this.initialFormCount(),e[y]=this.minNum,e[x]=this.maxNum,t=new E({autoId:this.autoId,prefix:this.prefix,initial:e})}return null!==this.managementFormCssClass&&(t.hiddenFieldRowCssClass=this.managementFormCssClass),t},M.prototype.totalFormCount=function(){if(this.isBound)return Math.min(this.managementForm().cleanedData[v],this.absoluteMax);var t=this.initialFormCount(),e=this.initialFormCount()+this.extra;return null!==this.maxNum&&t>this.maxNum&&this.maxNum>=0&&(e=t),null!==this.maxNum&&e>this.maxNum&&this.maxNum>=0&&(e=this.maxNum),e},M.prototype.initialFormCount=function(){if(this.isBound)return this.managementForm().cleanedData[g];var t=null!==this.initial&&this.initial.length>0?this.initial.length:0;return t},M.prototype.forms=function(){if(null===this._forms){this._forms=[];for(var t=this.totalFormCount(),e=0;t>e;e++)this._forms.push(this._constructForm(e))}return this._forms},M.prototype._constructForm=function(t){var e={autoId:this.autoId,prefix:this.addPrefix(t),errorConstructor:this.errorConstructor};this.isBound&&(e.data=this.data,e.files=this.files),null!==this.initial&&this.initial.length>0&&"undefined"!=typeof this.initial[t]&&(e.initial=this.initial[t]),t>=this.initialFormCount()&&(e.emptyPermitted=!0);var r=new this.form(e);return this.addFields(r,t),r},M.prototype.initialForms=function(){return this.forms().slice(0,this.initialFormCount())},M.prototype.extraForms=function(){return this.forms().slice(this.initialFormCount())},M.prototype.emptyForm=function(){var t={autoId:this.autoId,prefix:this.addPrefix("__prefix__"),emptyPermitted:!0},e=new this.form(t);return this.addFields(e,null),e},M.prototype.cleanedData=function(){if(!this.isValid())throw new Error(this.constructor.name+" object has no attribute 'cleanedData'");return this.forms().map(function(t){return t.cleanedData})},M.prototype.deletedForms=function(){if(!this.isValid()||!this.canDelete)return[];var t=this.forms();if("undefined"==typeof this._deletedFormIndexes){this._deletedFormIndexes=[];for(var e=0,r=t.length;r>e;e++){var i=t[e];e>=this.initialFormCount()&&!i.hasChanged()||this._shouldDeleteForm(i)&&this._deletedFormIndexes.push(e)}}return this._deletedFormIndexes.map(function(e){return t[e]})},M.prototype.orderedForms=function(){if(!this.isValid()||!this.canOrder)throw new Error(this.constructor.name+" object has no attribute 'orderedForms'");var t=this.forms();if("undefined"==typeof this._ordering){this._ordering=[];for(var e=0,r=t.length;r>e;e++){var i=t[e];e>=this.initialFormCount()&&!i.hasChanged()||this.canDelete&&this._shouldDeleteForm(i)||this._ordering.push([e,i.cleanedData[w]])}this._ordering.sort(function(t,e){return null===t[1]&&null===e[1]?t[0]-e[0]:null===t[1]?1:null===e[1]?-1:t[1]-e[1]})}return this._ordering.map(function(e){return t[e[0]]})},M.prototype.getDefaultPrefix=function(){return"form"},M.prototype.nonFormErrors=function(){return null===this._nonFormErrors&&this.fullClean(),this._nonFormErrors},M.prototype.errors=function(){return null===this._errors&&this.fullClean(),this._errors},M.prototype.totalErrorCount=function(){return this.nonFormErrors().length()+this.errors().reduce(function(t,e){return t+e.length()},0)},M.prototype._shouldDeleteForm=function(t){return o.get(t.cleanedData,_,!1)},M.prototype.isValid=function(){if(!this.isBound)return!1;var t=!0;this.errors();for(var e=this.forms(),r=0,i=e.length;i>r;r++){var n=e[r];this.canDelete&&this._shouldDeleteForm(n)||n.isValid()||(t=!1)}return t&&!this.nonFormErrors().isPopulated()},M.prototype.fullClean=function(){if(this._errors=[],this._nonFormErrors=new this.errorConstructor,this.isBound){for(var t=this.forms(),e=0,r=t.length;r>e;e++){var i=t[e];this._errors.push(i.errors())}try{var n=this.totalFormCount(),o=this.deletedForms().length;if(this.validateMax&&n-o>this.maxNum||this.managementForm().cleanedData[v]>this.absoluteMax)throw d("Please submit "+this.maxNum+" or fewer forms.",{code:"tooManyForms"});if(this.validateMin&&n-o<this.minNum)throw d("Please submit "+this.minNum+" or more forms.",{code:"tooFewForms"});this.clean()}catch(s){if(!(s instanceof d))throw s;this._nonFormErrors=new this.errorConstructor(s.messages())}}},M.prototype.clean=function(){},M.prototype.hasChanged=function(){for(var t=this.forms(),e=0,r=t.length;r>e;e++)if(t[e].hasChanged())return!0;return!1},M.prototype.addFields=function(t,e){this.canOrder&&(t.fields[w]=p(null!=e&&e<this.initialFormCount()?{label:"Order",initial:e+1,required:!1}:{label:"Order",required:!1})),this.canDelete&&(t.fields[_]=f({label:"Delete",required:!1}))},M.prototype.addPrefix=function(t){return this.prefix+"-"+t},M.prototype.isMultipart=function(){return this.forms().length>0&&this.forms()[0].isMultipart()},M.prototype.render=function(){return this.asTable()},M.prototype.asTable=function(){var t=this.managementForm().asTable();return this.forms().forEach(function(e){t=t.concat(e.asTable())}),t},M.prototype.asDiv=function(){var t=this.managementForm().asDiv();return this.forms().forEach(function(e){t=t.concat(e.asDiv())}),t},M.prototype.asUl=function(){var t=this.managementForm().asUl();return this.forms().forEach(function(e){t=t.concat(e.asUl())}),t},e.exports={DEFAULT_MAX_NUM:F,BaseFormSet:M,formsetFactory:r,allValid:i}},{"./fields":2,"./forms":3,"./util":6,"./widgets":7,Concur:8,"isomorph/object":13,validators:18}],5:[function(t,e){"use strict";var r=t("isomorph/object"),i=t("validators"),n=t("./env"),o=t("./util"),s=t("./widgets"),a=t("./fields"),l=t("./forms"),u=t("./formsets");r.extend(e.exports,{env:n,ValidationError:i.ValidationError,ErrorObject:o.ErrorObject,ErrorList:o.ErrorList,formData:o.formData,util:{formatToArray:o.formatToArray,prettyName:o.prettyName},validators:i},s,a,l,u)},{"./env":1,"./fields":2,"./forms":3,"./formsets":4,"./util":6,"./widgets":7,"isomorph/object":13,validators:18}],6:[function(t,e){"use strict";function r(t){return s.Array(t)?t:(s.Function(t)&&(t=t()),null!=t&&s.Function(t.__iter__)&&(t=t.__iter__()),t||[])}function i(t,e,r){for(var i=t.split(/\{(\w+)\}/g),n=1,o=i.length;o>n;n+=2)i[n]=a.hasOwn(e,i[n])?e[i[n]]:"{"+i[n]+"}";return(!r||r&&r.strip!==!1)&&(i=i.filter(function(t){return""!==t})),i}function n(t){var e={};if(s.String(t)&&(t=document.getElementById(t)||document.forms[t]),!t)throw new Error("formData couldn't find a form with '"+t+"'");for(var r=0,i=t.elements.length;i>r;r++){var n=t.elements[r],o=n.type,l=null;if("hidden"==o||"password"==o||"text"==o||"email"==o||"url"==o||"number"==o||"file"==o||"textarea"==o||("checkbox"==o||"radio"==o)&&n.checked)l=n.value;else if("select-one"==o)n.options.length&&(l=n.options[n.selectedIndex].value);else if("select-multiple"==o){l=[];for(var u=0,c=n.options.length;c>u;u++)n.options[u].selected&&l.push(n.options[u].value);0===l.length&&(l=null)}null!==l&&(e[n.name]=a.hasOwn(e,n.name)?s.Array(e[n.name])?e[n.name].concat(l):[e[n.name],l]:l)}return e}var o=t("Concur"),s=t("isomorph/is"),a=t("isomorph/object"),l=t("validators"),u=window.React,c=l.ValidationError,h=["%Y-%m-%d","%m/%d/%Y","%m/%d/%y","%b %d %Y","%b %d, %Y","%d %b %Y","%d %b, %Y","%B %d %Y","%B %d, %Y","%d %B %Y","%d %B, %Y"],d=["%H:%M:%S","%H:%M"],p=["%Y-%m-%d %H:%M:%S","%Y-%m-%d %H:%M","%Y-%m-%d","%m/%d/%Y %H:%M:%S","%m/%d/%Y %H:%M","%m/%d/%Y","%m/%d/%y %H:%M:%S","%m/%d/%y %H:%M","%m/%d/%y"],f=function(){var t=/([A-Z]+)/g,e=/[ _]+/,r=/^[A-Z][A-Z0-9]+$/;return function(i){var n=i.replace(t," $1").split(e);""===n[0]&&n.splice(0,1);for(var o=0,s=n.length;s>o;o++)0===o?n[0]=n[0].charAt(0).toUpperCase()+n[0].substr(1):r.test(n[o])||(n[o]=n[o].charAt(0).toLowerCase()+n[o].substr(1));return n.join(" ")}}(),m=function(){var t=/(^\s+|\s+$)/g;return function(e){return(""+e).replace(t,"")}}(),v=o.extend({constructor:function y(t){return this instanceof y?void(this.errors=t||{}):new y(t)}});v.prototype.set=function(t,e){this.errors[t]=e},v.prototype.get=function(t){return this.errors[t]},v.prototype.hasField=function(t){return a.hasOwn(this.errors,t)},v.prototype.length=function(){return Object.keys(this.errors).length},v.prototype.isPopulated=function(){return this.length()>0},v.prototype.render=function(){return this.asUl()},v.prototype.asUl=function(){var t=Object.keys(this.errors).map(function(t){return u.DOM.li(null,t,this.errors[t].asUl())}.bind(this));return 0===t.length?"":u.DOM.ul({className:"errorlist"},t)},v.prototype.asText=v.prototype.toString=function(){return Object.keys(this.errors).map(function(t){var e=this.errors[t].messages();return["* "+t].concat(e.map(function(t){return" * "+t})).join("\n")}.bind(this)).join("\n")},v.prototype.asData=function(){var t={};return Object.keys(this.errors).map(function(e){t[e]=this.errors[e].asData()}.bind(this)),t},v.prototype.toJSON=function(){var t={};return Object.keys(this.errors).map(function(e){t[e]=this.errors[e].toJSON()}.bind(this)),t};var g=o.extend({constructor:function x(t){return this instanceof x?void(this.data=t||[]):new x(t)}});g.prototype.extend=function(t){this.data.push.apply(this.data,t)},g.prototype.length=function(){return this.data.length},g.prototype.isPopulated=function(){return this.length()>0},g.prototype.messages=function(){for(var t=[],e=0,r=this.data.length;r>e;e++){var i=this.data[e];i instanceof c&&(i=i.messages()[0]),t.push(i)}return t},g.prototype.render=function(){return this.asUl()},g.prototype.asUl=function(){return this.isPopulated()?u.DOM.ul({className:"errorlist"},this.messages().map(function(t){return u.DOM.li(null,t)})):""},g.prototype.asText=g.prototype.toString=function(){return this.messages().map(function(t){return"* "+t}).join("\n")},g.prototype.asData=function(){return this.data},g.prototype.toJSON=function(){return c(this.data).errorList.map(function(t){return{message:t.messages()[0],code:t.code||""}})},e.exports={DEFAULT_DATE_INPUT_FORMATS:h,DEFAULT_TIME_INPUT_FORMATS:d,DEFAULT_DATETIME_INPUT_FORMATS:p,ErrorObject:v,ErrorList:g,formData:n,iterate:r,formatToArray:i,prettyName:f,strip:m}},{Concur:8,"isomorph/is":12,"isomorph/object":13,validators:18}],7:[function(t,e){"use strict";var r=t("Concur"),i=t("isomorph/is"),n=t("isomorph/format").formatObj,o=t("isomorph/object"),s=t("isomorph/time"),a=window.React,l=t("./env"),u=t("./util"),c=r.extend({constructor:function W(t,e,r,i){return this instanceof W?(this.parentWidget=t,this.name=e,this.value=r,i=o.extend({attrs:null,choices:[]},i),this.attrs=i.attrs,void(this.choices=i.choices)):new W(t,e,r,i)}});c.prototype.render=function(){var t={attrs:this.attrs};return this.choices.length&&(t.choices=this.choices),this.parentWidget.render(this.name,this.value,t)};var h=r.extend({constructor:function(t){t=o.extend({attrs:null},t),this.attrs=o.extend({},t.attrs)},isHidden:!1,needsMultipartForm:!1,isRequired:!1});h.prototype.subWidgets=function(t,e,r){return[c(this,t,e,r)]},h.prototype.render=function(){throw new Error("Constructors extending must implement a render() method.")},h.prototype.buildAttrs=function(t,e){var r=o.extend({},this.attrs,e,t);return r.ref=r.id,r},h.prototype.valueFromData=function(t,e,r){return o.get(t,r,null)},h.prototype.idForLabel=function(t){return t};var d=h.extend({constructor:function Y(t){return this instanceof h?void h.call(this,t):new Y(t)},inputType:null});d.prototype._formatValue=function(t){return t},d.prototype.render=function(t,e,r){r=o.extend({attrs:null},r),null===e&&(e="");var i=this.buildAttrs(r.attrs,{type:this.inputType,name:t});return""!==e&&(i.defaultValue=""+this._formatValue(e)),a.DOM.input(i)};var p=d.extend({constructor:function $(t){return this instanceof h?(t=o.extend({attrs:null},t),null!=t.attrs&&(this.inputType=o.pop(t.attrs,"type",this.inputType)),void d.call(this,t)):new $(t)},inputType:"text"}),f=p.extend({constructor:function Z(t){return this instanceof h?void p.call(this,t):new Z(t)},inputType:"number"}),m=p.extend({constructor:function G(t){return this instanceof h?void p.call(this,t):new G(t)},inputType:"email"}),v=p.extend({constructor:function X(t){return this instanceof h?void p.call(this,t):new X(t)},inputType:"url"}),g=p.extend({constructor:function z(t){return this instanceof h?(t=o.extend({renderValue:!1},t),p.call(this,t),void(this.renderValue=t.renderValue)):new z(t)},inputType:"password"});g.prototype.render=function(t,e,r){return this.renderValue||(e=""),p.prototype.render.call(this,t,e,r)};var y=d.extend({constructor:function K(t){return this instanceof h?void d.call(this,t):new K(t)},inputType:"hidden",isHidden:!0}),x=y.extend({constructor:function Q(t){return this instanceof h?void y.call(this,t):new Q(t)}});x.prototype.render=function(t,e,r){r=o.extend({attrs:null},r),null===e&&(e=[]);for(var i=this.buildAttrs(r.attrs,{type:this.inputType,name:t}),s=o.get(i,"id",null),l=[],u=0,c=e.length;c>u;u++){var h=o.extend({},i,{value:e[u]});s&&(h.id=n("{id}_{i}",{id:s,i:u})),l.push(a.DOM.input(h))}return a.DOM.div(null,l)},x.prototype.valueFromData=function(t,e,r){return"undefined"!=typeof t[r]?[].concat(t[r]):null};var w=d.extend({constructor:function te(t){return this instanceof h?void d.call(this,t):new te(t)},inputType:"file",needsMultipartForm:!0});w.prototype.render=function(t,e,r){return d.prototype.render.call(this,t,null,r)},w.prototype.valueFromData=function(t,e,r){return o.get(l.browser?t:e,r,null)};var _={},b=w.extend({constructor:function ee(t){return this instanceof h?void w.call(this,t):new ee(t)},initialText:"Currently",inputText:"Change",clearCheckboxLabel:"Clear",templateWithInitial:function(t){return u.formatToArray("{initialText}: {initial} {clearTemplate}{br}{inputText}: {input}",o.extend(t,{br:a.DOM.br(null)}))},templateWithClear:function(t){return u.formatToArray("{checkbox} {label}",o.extend(t,{label:a.DOM.label({htmlFor:t.checkboxId},t.label)}))},urlMarkupTemplate:function(t,e){return a.DOM.a({href:t},e)}});b.prototype.clearCheckboxName=function(t){return t+"-clear"},b.prototype.clearCheckboxId=function(t){return t+"_id"},b.prototype.render=function(t,e,r){var i=w.prototype.render.call(this,t,e,r);if(e&&"undefined"!=typeof e.url){var n;if(!this.isRequired){var o=this.clearCheckboxName(t),s=this.clearCheckboxId(o);n=this.templateWithClear({checkbox:I().render(o,!1,{attrs:{id:s}}),checkboxId:s,label:this.clearCheckboxLabel})}var l=this.templateWithInitial({initialText:this.initialText,initial:this.urlMarkupTemplate(e.url,""+e),clearTemplate:n,inputText:this.inputText,input:i});return a.DOM.div(null,l)}return i},b.prototype.valueFromData=function(t,e,r){var i=w.prototype.valueFromData(t,e,r);return!this.isRequired&&I.prototype.valueFromData.call(this,t,e,this.clearCheckboxName(r))?i?_:!1:i};var F=h.extend({constructor:function re(t){return this instanceof h?(t=o.extend({attrs:null},t),t.attrs=o.extend({rows:"10",cols:"40"},t.attrs),void h.call(this,t)):new re(t)}});F.prototype.render=function(t,e,r){r=o.extend({attrs:null},r),null===e&&(e="");var i=this.buildAttrs(r.attrs,{name:t,defaultValue:e});return a.DOM.textarea(i)};var E=p.extend({constructor:function(t){t=o.extend({format:null},t),p.call(this,t),this.format=null!==t.format?t.format:this.defaultFormat}});E.prototype._formatValue=function(t){return i.Date(t)?s.strftime(t,this.format):t};var M=E.extend({constructor:function ie(t){return this instanceof ie?void E.call(this,t):new ie(t)},defaultFormat:u.DEFAULT_DATE_INPUT_FORMATS[0]}),C=E.extend({constructor:function ne(t){return this instanceof ne?void E.call(this,t):new ne(t)},defaultFormat:u.DEFAULT_DATETIME_INPUT_FORMATS[0]}),D=E.extend({constructor:function oe(t){return this instanceof oe?void E.call(this,t):new oe(t)},defaultFormat:u.DEFAULT_TIME_INPUT_FORMATS[0]}),O=function(t){return t!==!1&&null!==t&&""!==t},I=h.extend({constructor:function se(t){return this instanceof h?(t=o.extend({checkTest:O},t),h.call(this,t),void(this.checkTest=t.checkTest)):new se(t)}});I.prototype.render=function(t,e,r){r=o.extend({attrs:null},r);var i=this.checkTest(e),n=this.buildAttrs(r.attrs,{type:"checkbox",name:t});return""!==e&&e!==!0&&e!==!1&&null!==e&&void 0!==e&&(n.value=e),i&&(n.defaultChecked="checked"),a.DOM.input(n)},I.prototype.valueFromData=function(t,e,r){if("undefined"==typeof t[r])return!1;var n=t[r],s={"true":!0,"false":!1};return i.String(n)&&(n=o.get(s,n.toLowerCase(),n)),!!n};var A=h.extend({constructor:function ae(t){return this instanceof h?(t=o.extend({choices:[]},t),h.call(this,t),void(this.choices=t.choices||[])):new ae(t)},allowMultipleSelected:!1});A.prototype.render=function(t,e,r){r=o.extend({attrs:null,choices:[]},r),null===e&&(e="");var i=this.buildAttrs(r.attrs,{name:t}),n=this.renderOptions(r.choices,[e]);return a.DOM.select(i,n)},A.prototype.renderOptions=function(t,e){var r,n,o={},s=i.String(e);for(r=0,n=e.length;n>r;r++)o[""+(s?e.charAt(r):e[r])]=!0;var l=[],c=u.iterate(this.choices).concat(t||[]);for(r=0,n=c.length;n>r;r++)if(i.Array(c[r][1])){for(var h=[],d=c[r][1],p=0,f=d.length;f>p;p++)h.push(this.renderOption(o,d[p][0],d[p][1]));l.push(a.DOM.optgroup({label:c[r][0]},h))}else l.push(this.renderOption(o,c[r][0],c[r][1]));return l},A.prototype.renderOption=function(t,e,r){e=""+e;var i={value:e};return"undefined"!=typeof t[e]&&(i.selected="selected",this.allowMultipleSelected||delete t[e]),a.DOM.option(i,r)};var T=A.extend({constructor:function le(t){return this instanceof h?(t=t||{},t.choices=[["1","Unknown"],["2","Yes"],["3","No"]],void A.call(this,t)):new le(t)}});T.prototype.render=function(t,e,r){return e=e===!0||"2"==e?"2":e===!1||"3"==e?"3":"1",A.prototype.render.call(this,t,e,r)},T.prototype.valueFromData=function(t,e,r){var i=null;if("undefined"!=typeof t[r]){var n=t[r];n===!0||"True"==n||"true"==n||"2"==n?i=!0:(n===!1||"False"==n||"false"==n||"3"==n)&&(i=!1)}return i};var V=A.extend({constructor:function ue(t){return this instanceof h?void A.call(this,t):new ue(t)},allowMultipleSelected:!0});V.prototype.render=function(t,e,r){r=o.extend({attrs:null,choices:[]},r),null===e&&(e=[]),i.Array(e)||(e=[e]);var n=this.buildAttrs(r.attrs,{name:t,multiple:"multiple",defaultValue:e}),s=this.renderOptions(r.choices,e);return a.DOM.select(n,s)},V.prototype.valueFromData=function(t,e,r){return"undefined"!=typeof t[r]?[].concat(t[r]):null};var P=c.extend({constructor:function(t,e,r,i,n){this.name=t,this.value=e,this.attrs=r,this.choiceValue=""+i[0],this.choiceLabel=""+i[1],this.index=n,"undefined"!=typeof this.attrs.id&&(this.attrs.id+="_"+this.index)},inputType:null});P.prototype.render=function(){var t={};return this.idForLabel()&&(t.htmlFor=this.idForLabel()),a.DOM.label(t,this.tag()," ",this.choiceLabel)},P.prototype.isChecked=function(){return this.value===this.choiceValue},P.prototype.tag=function(){var t=o.extend({},this.attrs,{type:this.inputType,name:this.name,value:this.choiceValue});return this.isChecked()&&(t.defaultChecked="checked"),a.DOM.input(t)},P.prototype.idForLabel=function(){return o.get(this.attrs,"id","")};var S=P.extend({constructor:function ce(t,e,r,i,n){return this instanceof ce?(P.call(this,t,e,r,i,n),void(this.value=""+this.value)):new ce(t,e,r,i,n)},inputType:"radio"}),j=P.extend({constructor:function he(t,e,r,n,o){if(!(this instanceof he))return new he(t,e,r,n,o);i.Array(e)||(e=[e]),P.call(this,t,e,r,n,o);for(var s=0,a=this.value.length;a>s;s++)this.value[s]=""+this.value[s]},inputType:"checkbox"});j.prototype.isChecked=function(){return-1!==this.value.indexOf(this.choiceValue)};var L=r.extend({constructor:function de(t,e,r,i){return this instanceof de?(this.name=t,this.value=e,this.attrs=r,void(this.choices=i)):new de(t,e,r,i)},choiceInputConstructor:null});L.prototype.__iter__=function(){return this.choiceInputs()},L.prototype.choiceInputs=function(){for(var t=[],e=0,r=this.choices.length;r>e;e++)t.push(this.choiceInputConstructor(this.name,this.value,o.extend({},this.attrs),this.choices[e],e));return t},L.prototype.choiceInput=function(t){if(t>=this.choices.length)throw new Error("Index out of bounds: "+t);return this.choiceInputConstructor(this.name,this.value,o.extend({},this.attrs),this.choices[t],t)},L.prototype.render=function(){for(var t=o.get(this.attrs,"id",null),e=[],r=0,n=this.choices.length;n>r;r++){var s=this.choices[r],l=s[0],u=s[1];if(i.Array(u)){var c=o.extend({},this.attrs);t&&(c.id+="_"+r);var h=L(this.name,this.value,c,u);h.choiceInputConstructor=this.choiceInputConstructor,e.push(a.DOM.li(null,l,h.render()))}else{var d=this.choiceInputConstructor(this.name,this.value,o.extend({},this.attrs),s,r);e.push(a.DOM.li(null,d.render()))}}var p={};return t&&(p.id=t),a.DOM.ul(p,e)};var N=L.extend({constructor:function pe(t,e,r,i){return this instanceof pe?void L.apply(this,arguments):new pe(t,e,r,i)},choiceInputConstructor:S}),R=L.extend({constructor:function fe(t,e,r,i){return this instanceof fe?void L.apply(this,arguments):new fe(t,e,r,i)},choiceInputConstructor:j}),k=r.extend({constructor:function(t){t=o.extend({renderer:null},t),null!==t.renderer&&(this.renderer=t.renderer)},_emptyValue:null});k.prototype.subWidgets=function(t,e,r){return u.iterate(this.getRenderer(t,e,r))},k.prototype.getRenderer=function(t,e,r){r=o.extend({attrs:null,choices:[]},r),null===e&&(e=this._emptyValue);var i=this.buildAttrs(r.attrs),n=u.iterate(this.choices).concat(r.choices||[]);return new this.renderer(t,e,i,n)},k.prototype.render=function(t,e,r){return this.getRenderer(t,e,r).render()},k.prototype.idForLabel=function(t){return t&&(t+="_0"),t};var q=A.extend({__mixin__:k,constructor:function(t){return this instanceof q?(k.call(this,t),void A.call(this,t)):new q(t)},renderer:N,_emptyValue:""}),U=V.extend({__mixin__:k,constructor:function(t){return this instanceof U?(k.call(this,t),void V.call(this,t)):new U(t)},renderer:R,_emptyValue:[]}),B=h.extend({constructor:function me(t,e){if(!(this instanceof h))return new me(t,e);this.widgets=[];for(var r=!1,i=0,n=t.length;n>i;i++){var o=t[i]instanceof h?t[i]:new t[i];o.needsMultipartForm&&(r=!0),this.widgets.push(o)}this.needsMultipartForm=r,h.call(this,e)}});B.prototype.render=function(t,e,r){r=o.extend({attrs:null},r),i.Array(e)||(e=this.decompress(e));for(var n=this.buildAttrs(r.attrs),s="undefined"!=typeof n.id?n.id:null,a=[],l=0,u=this.widgets.length;u>l;l++){var c=this.widgets[l],h=null;"undefined"!=typeof e[l]&&(h=e[l]),s&&(n.id=s+"_"+l),a.push(c.render(t+"_"+l,h,{attrs:n}))}return this.formatOutput(a)},B.prototype.idForLabel=function(t){return t&&(t+="_0"),t},B.prototype.valueFromData=function(t,e,r){for(var i=[],n=0,o=this.widgets.length;o>n;n++)i[n]=this.widgets[n].valueFromData(t,e,r+"_"+n);return i},B.prototype.formatOutput=function(t){return a.DOM.div(null,t)},B.prototype.decompress=function(){throw new Error("MultiWidget subclasses must implement a decompress() method.")};var H=B.extend({constructor:function ve(t){if(!(this instanceof h))return new ve(t);t=o.extend({dateFormat:null,timeFormat:null},t);var e=[M({attrs:t.attrs,format:t.dateFormat}),D({attrs:t.attrs,format:t.timeFormat})];B.call(this,e,t.attrs)}});H.prototype.decompress=function(t){return t?[new Date(t.getFullYear(),t.getMonth(),t.getDate()),new Date(1900,0,1,t.getHours(),t.getMinutes(),t.getSeconds())]:[null,null]};var J=H.extend({constructor:function ge(t){if(!(this instanceof h))return new ge(t);H.call(this,t);for(var e=0,r=this.widgets.length;r>e;e++)this.widgets[e].inputType="hidden",this.widgets[e].isHidden=!0},isHidden:!0});e.exports={SubWidget:c,Widget:h,Input:d,TextInput:p,NumberInput:f,EmailInput:m,URLInput:v,PasswordInput:g,HiddenInput:y,MultipleHiddenInput:x,FileInput:w,FILE_INPUT_CONTRADICTION:_,ClearableFileInput:b,Textarea:F,DateInput:M,DateTimeInput:C,TimeInput:D,CheckboxInput:I,Select:A,NullBooleanSelect:T,SelectMultiple:V,ChoiceInput:P,RadioChoiceInput:S,CheckboxChoiceInput:j,ChoiceFieldRenderer:L,RendererMixin:k,RadioFieldRenderer:N,CheckboxFieldRenderer:R,RadioSelect:q,CheckboxSelectMultiple:U,MultiWidget:B,SplitDateTimeWidget:H,SplitHiddenDateTimeWidget:J}},{"./env":1,"./util":6,Concur:8,"isomorph/format":11,"isomorph/is":12,"isomorph/object":13,"isomorph/time":14}],8:[function(t,e){"use strict";function r(t,e){o.Function(e)?s.extend(t,e.prototype):s.extend(t,e)}function i(t){var e=t.__mixin__;o.Array(e)||(e=[e]);for(var i={},n=0,a=e.length;a>n;n++)r(i,e[n]);return delete t.__mixin__,s.extend(i,t)}function n(t,e,r){var i;return i=e&&s.hasOwn(e,"constructor")?e.constructor:function(){t.apply(this,arguments)},t!==a&&(s.inherits(i,t),i.__super__=t.prototype),e&&s.extend(i.prototype,e),r&&s.extend(i,r),i}var o=t("isomorph/is"),s=t("isomorph/object"),a=e.exports=function(){};a.__mro__=[],a.extend=function(t,e){"undefined"!=typeof this.prototype.__meta__&&(t=t||{},e=e||{},this.prototype.__meta__(t,e)),t&&s.hasOwn(t,"__mixin__")&&(t=i(t)),e&&s.hasOwn(e,"__mixin__")&&(e=i(e));var r=n(this,t,e);return r.extend=this.extend,r.__mro__=[r].concat(this.__mro__),r}},{"isomorph/is":12,"isomorph/object":13}],9:[function(e,r,i){!function(e){function n(t){throw RangeError(P[t])}function o(t,e){for(var r=t.length;r--;)t[r]=e(t[r]);return t}function s(t,e){return o(t.split(V),e).join(".")}function a(t){for(var e,r,i=[],n=0,o=t.length;o>n;)e=t.charCodeAt(n++),e>=55296&&56319>=e&&o>n?(r=t.charCodeAt(n++),56320==(64512&r)?i.push(((1023&e)<<10)+(1023&r)+65536):(i.push(e),n--)):i.push(e);return i}function l(t){return o(t,function(t){var e="";return t>65535&&(t-=65536,e+=L(t>>>10&1023|55296),t=56320|1023&t),e+=L(t)}).join("")}function u(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:b}function c(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function h(t,e,r){var i=0;for(t=r?j(t/C):t>>1,t+=j(t/e);t>S*E>>1;i+=b)t=j(t/S);return j(i+(S+1)*t/(t+M))}function d(t){var e,r,i,o,s,a,c,d,p,f,m=[],v=t.length,g=0,y=O,x=D;for(r=t.lastIndexOf(I),0>r&&(r=0),i=0;r>i;++i)t.charCodeAt(i)>=128&&n("not-basic"),m.push(t.charCodeAt(i));for(o=r>0?r+1:0;v>o;){for(s=g,a=1,c=b;o>=v&&n("invalid-input"),d=u(t.charCodeAt(o++)),(d>=b||d>j((_-g)/a))&&n("overflow"),g+=d*a,p=x>=c?F:c>=x+E?E:c-x,!(p>d);c+=b)f=b-p,a>j(_/f)&&n("overflow"),a*=f;e=m.length+1,x=h(g-s,e,0==s),j(g/e)>_-y&&n("overflow"),y+=j(g/e),g%=e,m.splice(g++,0,y)}return l(m)}function p(t){var e,r,i,o,s,l,u,d,p,f,m,v,g,y,x,w=[];for(t=a(t),v=t.length,e=O,r=0,s=D,l=0;v>l;++l)m=t[l],128>m&&w.push(L(m));for(i=o=w.length,o&&w.push(I);v>i;){for(u=_,l=0;v>l;++l)m=t[l],m>=e&&u>m&&(u=m);for(g=i+1,u-e>j((_-r)/g)&&n("overflow"),r+=(u-e)*g,e=u,l=0;v>l;++l)if(m=t[l],e>m&&++r>_&&n("overflow"),m==e){for(d=r,p=b;f=s>=p?F:p>=s+E?E:p-s,!(f>d);p+=b)x=d-f,y=b-f,w.push(L(c(f+x%y,0))),d=j(x/y);w.push(L(c(d,0))),s=h(r,g,i==o),r=0,++i}++r,++e}return w.join("")}function f(t){return s(t,function(t){return A.test(t)?d(t.slice(4).toLowerCase()):t})}function m(t){return s(t,function(t){return T.test(t)?"xn--"+p(t):t})}var v="object"==typeof i&&i,g="object"==typeof r&&r&&r.exports==v&&r,y="object"==typeof global&&global;(y.global===y||y.window===y)&&(e=y);var x,w,_=2147483647,b=36,F=1,E=26,M=38,C=700,D=72,O=128,I="-",A=/^xn--/,T=/[^ -~]/,V=/\x2E|\u3002|\uFF0E|\uFF61/g,P={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},S=b-F,j=Math.floor,L=String.fromCharCode;if(x={version:"1.2.4",ucs2:{decode:a,encode:l},decode:d,encode:p,toASCII:m,toUnicode:f},"function"==typeof t&&"object"==typeof t.amd&&t.amd)t("punycode",function(){return x});else if(v&&!v.nodeType)if(g)g.exports=x;else for(w in x)x.hasOwnProperty(w)&&(v[w]=x[w]);else e.punycode=x}(this)},{}],10:[function(t,e){"use strict";function r(){}function i(t){return"object"==typeof t?(r.prototype=t,new r):t}function n(t){if("object"!=typeof t)return t;var e=t.valueOf();if(t!=e)return new t.constructor(e);var r,n;if(t instanceof t.constructor&&t.constructor!==Object){r=i(t.constructor.prototype);for(n in t)t.hasOwnProperty(n)&&(r[n]=t[n])}else{r={};for(n in t)r[n]=t[n]}return r}function o(t){for(var e in t)this[e]=t[e]}function s(){this.copiedObjects=[];var t=this;this.recursiveDeepCopy=function(e){return t.deepCopy(e)},this.depth=0}function a(t,e){var r=new s;return e&&(r.maxDepth=e),r.deepCopy(t)}var l=t("./is"),u=[];o.prototype={constructor:o,canCopy:function(){return!1},create:function(){},populate:function(){}},s.prototype={constructor:s,maxDepth:256,cacheResult:function(t,e){this.copiedObjects.push([t,e])},getCachedResult:function(t){for(var e=this.copiedObjects,r=e.length,i=0;r>i;i++)if(e[i][0]===t)return e[i][1];return void 0},deepCopy:function(t){if(null===t)return null;if("object"!=typeof t)return t;var e=this.getCachedResult(t);if(e)return e;for(var r=0;r<u.length;r++){var i=u[r];if(i.canCopy(t))return this.applyDeepCopier(i,t)}throw new Error("no DeepCopier is able to copy "+t)},applyDeepCopier:function(t,e){var r=t.create(e);if(this.cacheResult(e,r),this.depth++,this.depth>this.maxDepth)throw new Error("Exceeded max recursion depth in deep copy.");return t.populate(this.recursiveDeepCopy,e,r),this.depth--,r}},a.DeepCopier=o,a.deepCopiers=u,a.register=function(t){t instanceof o||(t=new o(t)),u.unshift(t)},a.register({canCopy:function(){return!0},create:function(t){return t instanceof t.constructor?i(t.constructor.prototype):{}},populate:function(t,e,r){for(var i in e)e.hasOwnProperty(i)&&(r[i]=t(e[i]));return r}}),a.register({canCopy:function(t){return l.Array(t)},create:function(t){return new t.constructor},populate:function(t,e,r){for(var i=0;i<e.length;i++)r.push(t(e[i]));return r}}),a.register({canCopy:function(t){return l.Date(t)},create:function(t){return new Date(t)}}),a.register({canCopy:function(t){return l.RegExp(t)},create:function(t){return t}}),e.exports={DeepCopyAlgorithm:s,copy:n,clone:i,deepCopy:a}},{"./is":12}],11:[function(t,e){"use strict";function r(t){return i(t,s.call(arguments,1))}function i(t,e){var r=0;return t.replace(a,function(t){return"%%"==t?"%":e[r++]})}function n(t,e){return t.replace(l,function(t,r,i){return 2==r.length?t.slice(1):e[i]})}function o(t,e){e=Math.min(e||768,1024);for(var r=-1,i="bytes",n=t;n>e&&r<u.length;)n/=1024,r++;return r>-1&&(i=u.charAt(r)+"B"),n.toFixed(2).replace(c,"")+" "+i}var s=Array.prototype.slice,a=/%[%s]/g,l=/({{?)(\w+)}/g,u="kMGTPEZY",c=/\.00$|0$/;e.exports={format:r,formatArr:i,formatObj:n,fileSize:o}},{}],12:[function(t,e){"use strict";function r(t){return"[object Array]"==d.call(t)}function i(t){return"[object Boolean]"==d.call(t)}function n(t){return"[object Date]"==d.call(t)}function o(t){return"[object Error]"==d.call(t)}function s(t){return"[object Function]"==d.call(t)}function a(t){return"[object Number]"==d.call(t)}function l(t){return"[object Object]"==d.call(t)}function u(t){return"[object RegExp]"==d.call(t)}function c(t){return"[object String]"==d.call(t)}function h(t){for(var e in t)return!1;return!0}var d=Object.prototype.toString;e.exports={Array:r,Boolean:i,Date:n,Empty:h,Error:o,Function:s,NaN:isNaN,Number:a,Object:l,RegExp:u,String:c} | |
},{}],13:[function(t,e){"use strict";function r(t){for(var e,r=1,i=arguments.length;i>r;r++)if(e=arguments[r])for(var n in e)c(e,n)&&(t[n]=e[n]);return t}function i(t,e){var r=function(){};return r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t}function n(t){var e=[];for(var r in t)c(t,r)&&e.push([r,t[r]]);return e}function o(t){for(var e,r={},i=0,n=t.length;n>i;i++)e=t[i],r[e[0]]=e[1];return r}function s(t){for(var e={},r=0,i=t.length;i>r;r++)e[""+t[r]]=!0;return e}function a(t,e,r){return c(t,e)?t[e]:r}function l(t,e,r){if(null==t)throw new Error("popProp was given "+t);if(c(t,e)){var i=t[e];return delete t[e],i}if(2==arguments.length)throw new Error("popProp was given an object which didn't have an own '"+e+"' property, without a default value to return");return r}function u(t,e,r){if(null==t)throw new Error("setDefault was given "+t);return r=r||null,c(t,e)?t[e]:(t[e]=r,r)}var c=function(){var t=Object.prototype.hasOwnProperty;return function(e,r){return t.call(e,r)}}();e.exports={hasOwn:c,extend:r,inherits:i,items:n,fromItems:o,lookup:s,get:a,pop:l,setDefault:u}},{}],14:[function(t,e){"use strict";function r(t){return 10>t?"0"+t:t}function i(t,e){for(var r=0,i=e.length;i>r;r++)if(t===e[r])return r;return-1}function n(t,e){this.format=t,this.locale=e;var r=n._cache[e.name+"|"+t];void 0!==r?(this.re=r[0],this.matchOrder=r[1]):this.compilePattern()}var o=t("./is"),s={b:function(t){return"("+t.b.join("|")+")"},B:function(t){return"("+t.B.join("|")+")"},p:function(t){return"("+t.AM+"|"+t.PM+")"},d:"(\\d\\d?)",H:"(\\d\\d?)",I:"(\\d\\d?)",m:"(\\d\\d?)",M:"(\\d\\d?)",S:"(\\d\\d?)",y:"(\\d\\d?)",Y:"(\\d{4})","%":"%"},a={a:function(t,e){return e.a[t.getDay()]},A:function(t,e){return e.A[t.getDay()]},b:function(t,e){return e.b[t.getMonth()]},B:function(t,e){return e.B[t.getMonth()]},d:function(t){return r(t.getDate(),2)},H:function(t){return r(t.getHours(),2)},M:function(t){return r(t.getMinutes(),2)},m:function(t){return r(t.getMonth()+1,2)},S:function(t){return r(t.getSeconds(),2)},w:function(t){return t.getDay()},Y:function(t){return t.getFullYear()},"%":function(){return"%"}},l=/[^%]%$/;n._cache={},n.prototype.compilePattern=function(){for(var t,e,r=this.format.split(/(?:\s|\t|\n)+/).join(" "),i=[],a=[],l=0,u=r.length;u>l;l++)if(t=r.charAt(l),"%"==t){if(l==u-1)throw new Error("strptime format ends with raw %");if(t=r.charAt(++l),e=s[t],void 0===e)throw new Error("strptime format contains an unknown directive: %"+t);i.push(o.Function(e)?e(this.locale):e),"%"!=t&&a.push(t)}else i.push(" "===t?" +":t);this.re=new RegExp("^"+i.join("")+"$"),this.matchOrder=a,n._cache[this.locale.name+"|"+this.format]=[this.re,a]},n.prototype.parse=function(t){var e=this.re.exec(t);if(null===e)throw new Error("Time data did not match format: data="+t+", format="+this.format);for(var r=[1900,1,1,0,0,0],n={},o=1,s=e.length;s>o;o++)n[this.matchOrder[o-1]]=e[o];if(n.hasOwnProperty("Y"))r[0]=parseInt(n.Y,10);else if(n.hasOwnProperty("y")){var a=parseInt(n.y,10);68>a?a=2e3+a:100>a&&(a=1900+a),r[0]=a}if(n.hasOwnProperty("m")){var l=parseInt(n.m,10);if(1>l||l>12)throw new Error("Month is out of range: "+l);r[1]=l}else n.hasOwnProperty("B")?r[1]=i(n.B,this.locale.B)+1:n.hasOwnProperty("b")&&(r[1]=i(n.b,this.locale.b)+1);if(n.hasOwnProperty("d")){var u=parseInt(n.d,10);if(1>u||u>31)throw new Error("Day is out of range: "+u);r[2]=u}var c;if(n.hasOwnProperty("H")){if(c=parseInt(n.H,10),c>23)throw new Error("Hour is out of range: "+c);r[3]=c}else if(n.hasOwnProperty("I")){if(c=parseInt(n.I,10),1>c||c>12)throw new Error("Hour is out of range: "+c);12==c&&(c=0),r[3]=c,n.hasOwnProperty("p")&&n.p==this.locale.PM&&(r[3]=r[3]+12)}if(n.hasOwnProperty("M")){var h=parseInt(n.M,10);if(h>59)throw new Error("Minute is out of range: "+h);r[4]=h}if(n.hasOwnProperty("S")){var d=parseInt(n.S,10);if(d>59)throw new Error("Second is out of range: "+d);r[5]=d}if(u=r[2],l=r[1],a=r[0],(4==l||6==l||9==l||11==l)&&u>30||2==l&&u>(a%4===0&&a%100!==0||a%400===0?29:28))throw new Error("Day is out of range: "+u);return r};var u={defaultLocale:"en",locales:{en:{name:"en",a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],AM:"AM",b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],PM:"PM"}}},c=u.getLocale=function(t){if(t){if(u.locales.hasOwnProperty(t))return u.locales[t];if(t.length>2){var e=t.substring(0,2);if(u.locales.hasOwnProperty(e))return u.locales[e]}}return u.locales[u.defaultLocale]},h=u.strptime=function(t,e,r){return new n(e,c(r)).parse(t)};u.strpdate=function(t,e,r){var i=h(t,e,r);return new Date(i[0],i[1]-1,i[2],i[3],i[4],i[5])},u.strftime=function(t,e,r){if(l.test(e))throw new Error("strftime format ends with raw %");return r=c(r),e.replace(/(%.)/g,function(e,i){var n=i.charAt(1);if("undefined"==typeof a[n])throw new Error("strftime format contains an unknown directive: "+i);return a[n](t,r)})},e.exports=u},{"./is":12}],15:[function(t,e){"use strict";function r(t){for(var e=r.options,i=e.parser[e.strictMode?"strict":"loose"].exec(t),n={},o=14;o--;)n[e.key[o]]=i[o]||"";return n[e.q.name]={},n[e.key[12]].replace(e.q.parser,function(t,r,i){r&&(n[e.q.name][r]=i)}),n}function i(t){var e="";t.protocol&&(e+=t.protocol+"://"),t.user&&(e+=t.user),t.password&&(e+=":"+t.password),(t.user||t.password)&&(e+="@"),t.host&&(e+=t.host),t.port&&(e+=":"+t.port),t.path&&(e+=t.path);var r=t.queryKey,i=[];for(var n in r)if(r.hasOwnProperty(n)){var o=encodeURIComponent(r[n]);n=encodeURIComponent(n),i.push(o?n+"="+o:n)}return i.length>0&&(e+="?"+i.join("&")),t.anchor&&(e+="#"+t.anchor),e}r.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e.exports={parseUri:r,makeUri:i}},{}],16:[function(t,e){"use strict";var r=t("Concur"),i=t("isomorph/format").formatObj,n=t("isomorph/is"),o=t("isomorph/object"),s="__all__",a=r.extend({constructor:function l(t,e){if(!(this instanceof l))return new l(t,e);e=o.extend({code:null,params:null},e);var r=e.code,i=e.params;t instanceof l&&(o.hasOwn(t,"errorObj")?t=t.errorObj:o.hasOwn(t,"message")?t=t.errorList:(r=t.code,i=t.params,t=t.message)),n.Object(t)?(this.errorObj={},Object.keys(t).forEach(function(e){var r=t[e];r instanceof l||(r=l(r)),this.errorObj[e]=r.errorList}.bind(this))):n.Array(t)?(this.errorList=[],t.forEach(function(t){t instanceof l||(t=l(t)),this.errorList.push.apply(this.errorList,t.errorList)}.bind(this))):(this.message=t,this.code=r,this.params=i,this.errorList=[this])}});a.prototype.messageObj=function(){if(!o.hasOwn(this,"errorObj"))throw new Error("ValidationError has no errorObj");return this.__iter__()},a.prototype.messages=function(){if(o.hasOwn(this,"errorObj")){var t=[];return Object.keys(this.errorObj).forEach(function(e){var r=this.errorObj[e];t.push.apply(t,a(r).__iter__())}.bind(this)),t}return this.__iter__()},a.prototype.__iter__=function(){if(o.hasOwn(this,"errorObj")){var t={};return Object.keys(this.errorObj).forEach(function(e){var r=this.errorObj[e];t[e]=a(r).__iter__()}.bind(this)),t}return this.errorList.map(function(t){var e=t.message;return t.params&&(e=i(e,t.params)),e})},a.prototype.updateErrorObj=function(t){if(o.hasOwn(this,"errorObj"))t?Object.keys(this.errorObj).forEach(function(e){o.hasOwn(t,e)||(t[e]=[]);var r=t[e];r.push.apply(r,this.errorObj[e])}.bind(this)):t=this.errorObj;else{o.hasOwn(t,s)||(t[s]=[]);var e=t[s];e.push.apply(e,this.errorList)}return t},a.prototype.toString=function(){return"ValidationError("+JSON.stringify(this.__iter__())+")"},e.exports={ValidationError:a}},{Concur:8,"isomorph/format":11,"isomorph/is":12,"isomorph/object":13}],17:[function(t,e){"use strict";function r(t,e){e=c.extend({unpackIPv4:!1,errorMessage:"This is not a valid IPv6 address."},e);var r=-1,a=0,l=-1,u=0;if(!o(t))throw d(e.errorMessage,{code:"invalid"});if(t=s(t),t=i(t),e.unpackIPv4){var h=n(t);if(h)return h}for(var p=t.split(":"),f=0,m=p.length;m>f;f++)p[f]=p[f].replace(/^0+/,""),""===p[f]&&(p[f]="0"),"0"==p[f]?(u+=1,-1==l&&(l=f),u>a&&(a=u,r=l)):(u=0,l=-1);if(a>1){var v=r+a;v==p.length&&p.push(""),p.splice(r,a,""),0===r&&p.unshift("")}return p.join(":").toLowerCase()}function i(t){if(0!==t.toLowerCase().indexOf("0000:0000:0000:0000:0000:ffff:"))return t;var e=t.split(":");if(-1!=e[e.length-1].indexOf("."))return t;var r=[parseInt(e[6].substring(0,2),16),parseInt(e[6].substring(2,4),16),parseInt(e[7].substring(0,2),16),parseInt(e[7].substring(2,4),16)].join(".");return e.slice(0,6).join(":")+":"+r}function n(t){if(0!==t.toLowerCase().indexOf("0000:0000:0000:0000:0000:ffff:"))return null;var e=t.split(":");return e.pop()}function o(e){var r=t("./validators").validateIPv4Address;if(-1==e.indexOf(":"))return!1;if(u(e,"::")>1)return!1;if(-1!=e.indexOf(":::"))return!1;if(":"==e.charAt(0)&&":"!=e.charAt(1)||":"==e.charAt(e.length-1)&&":"!=e.charAt(e.length-2))return!1;if(u(e,":")>7)return!1;if(-1==e.indexOf("::")&&7!=u(e,":")&&3!=u(e,"."))return!1;e=s(e);for(var i,n=e.split(":"),o=0,a=n.length;a>o;o++)if(i=n[o],3==u(i,".")){if(e.split(":").pop()!=i)return!1;try{r(i)}catch(l){if(!(l instanceof d))throw l;return!1}}else{if(!p.test(i))return!1;var c=parseInt(i,16);if(isNaN(c)||0>c||c>65535)return!1}return!0}function s(t){if(!a(t))return t;var e=[],r=t.split("::"),i=-1!=t.split(":").pop().indexOf(".")?7:8;if(r.length>1){var n=r[0].split(":").length+r[1].split(":").length;e=r[0].split(":");for(var o=0,s=i-n;s>o;o++)e.push("0000");e=e.concat(r[1].split(":"))}else e=t.split(":");var u=[];for(o=0,s=e.length;s>o;o++)u.push(l(e[o],4)+e[o].toLowerCase());return u.join(":")}function a(t){if(1==u(t,"::"))return!0;for(var e=t.split(":"),r=0,i=e.length;i>r;r++)if(e[r].length<4)return!0;return!1}function l(t,e){return t.length>=e?"":new Array(e-t.length+1).join("0")}function u(t,e){return t.split(e).length-1}var c=t("isomorph/object"),h=t("./errors"),d=h.ValidationError,p=/^[0-9a-f]+$/;e.exports={cleanIPv6Address:r,isValidIPv6Address:o}},{"./errors":16,"./validators":18,"isomorph/object":13}],18:[function(t,e){"use strict";function r(t,e,r){var i=t.split(e);return r?[i.slice(0,-r).join(e)].concat(i.slice(-r)):i}function i(t){if(!f(t))throw p("Enter a valid IPv6 address.",{code:"invalid"})}function n(t){try{F(t)}catch(e){if(!(e instanceof p))throw e;try{i(t)}catch(e){if(!(e instanceof p))throw e;throw p("Enter a valid IPv4 or IPv6 address.",{code:"invalid"})}}}function o(t,e){if("both"!=t&&e)throw new Error('You can only use unpackIPv4 if protocol is set to "both"');if(t=t.toLowerCase(),"undefined"==typeof E[t])throw new Error('The protocol "'+t+'" is unknown');return E[t]}var s=t("Concur"),a=t("isomorph/is"),l=t("isomorph/object"),u=t("punycode"),c=t("isomorph/url"),h=t("./errors"),d=t("./ipv6"),p=h.ValidationError,f=d.isValidIPv6Address,m=[null,void 0,""],v=s.extend({constructor:function(t){return this instanceof v?(t=l.extend({regex:null,message:null,code:null,inverseMatch:null},t),t.regex&&(this.regex=t.regex),t.message&&(this.message=t.message),t.code&&(this.code=t.code),t.inverseMatch&&(this.inverseMatch=t.inverseMatch),a.String(this.regex)&&(this.regex=new RegExp(this.regex)),this.__call__.bind(this)):new v(t)},regex:"",message:"Enter a valid value.",code:"invalid",inverseMatch:!1,__call__:function(t){if(this.inverseMatch===this.regex.test(""+t))throw p(this.message,{code:this.code})}}),g=v.extend({regex:new RegExp("^(?:[a-z0-9\\.\\-]*)://(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|localhost|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\[?[A-F0-9]*:[A-F0-9:]+\\]?)(?::\\d+)?(?:/?|[/?]\\S+)$","i"),message:"Enter a valid URL.",schemes:["http","https","ftp","ftps"],constructor:function(t){return this instanceof g?(t=l.extend({schemes:null},t),v.call(this,t),null!==t.schemes&&(this.schemes=t.schemes),this.__call__.bind(this)):new g(t)},__call__:function(t){t=""+t;var e=t.split("://")[0].toLowerCase();if(-1===this.schemes.indexOf(e))throw p(this.message,{code:this.code});try{v.prototype.__call__.call(this,t)}catch(r){if(!(r instanceof p))throw r;var i=c.parseUri(t);try{i.host=u.toASCII(i.host)}catch(n){throw r}t=c.makeUri(i),v.prototype.__call__.call(this,t)}}}),y=s.extend({message:"Enter a valid email address.",code:"invalid",userRegex:new RegExp("(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*$|^\"([\\001-\\010\\013\\014\\016-\\037!#-\\[\\]-\\177]|\\\\[\\001-\\011\\013\\014\\016-\\177])*\"$)","i"),domainRegex:new RegExp("^(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,})$|^\\[(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\]$","i"),domainWhitelist:["localhost"],constructor:function(t){return this instanceof y?(t=l.extend({message:null,code:null,whitelist:null},t),null!==t.message&&(this.message=t.message),null!==t.code&&(this.code=t.code),null!==t.whitelist&&(this.domainWhitelist=t.whitelist),this.__call__.bind(this)):new y(t)},__call__:function(t){if(t=""+t,!t||-1==t.indexOf("@"))throw p(this.message,{code:this.code});var e=r(t,"@",1),i=e[0],n=e[1];if(!this.userRegex.test(i))throw p(this.message,{code:this.code});if(-1==this.domainWhitelist.indexOf(n)&&!this.domainRegex.test(n)){try{if(n=u.toASCII(n),this.domainRegex.test(n))return}catch(o){}throw p(this.message,{code:this.code})}}}),x=y(),w=/^[-a-zA-Z0-9_]+$/,_=v({regex:w,message:'Enter a valid "slug" consisting of letters, numbers, underscores or hyphens.',code:"invalid"}),b=/^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/,F=v({regex:b,message:"Enter a valid IPv4 address.",code:"invalid"}),E={both:{validators:[n],message:"Enter a valid IPv4 or IPv6 address."},ipv4:{validators:[F],message:"Enter a valid IPv4 address."},ipv6:{validators:[i],message:"Enter a valid IPv6 address."}},M=/^[\d,]+$/,C=v({regex:M,message:"Enter only digits separated by commas.",code:"invalid"}),D=s.extend({constructor:function(t){return this instanceof D?(this.limitValue=t,this.__call__.bind(this)):new D(t)},compare:function(t,e){return t!==e},clean:function(t){return t},message:"Ensure this value is {limitValue} (it is {showValue}).",code:"limitValue",__call__:function(t){var e=this.clean(t),r={limitValue:this.limitValue,showValue:e};if(this.compare(e,this.limitValue))throw p(this.message,{code:this.code,params:r})}}),O=D.extend({constructor:function(t){return this instanceof O?D.call(this,t):new O(t)},compare:function(t,e){return t>e},message:"Ensure this value is less than or equal to {limitValue}.",code:"maxValue"}),I=D.extend({constructor:function(t){return this instanceof I?D.call(this,t):new I(t)},compare:function(t,e){return e>t},message:"Ensure this value is greater than or equal to {limitValue}.",code:"minValue"}),A=D.extend({constructor:function(t){return this instanceof A?D.call(this,t):new A(t)},compare:function(t,e){return e>t},clean:function(t){return t.length},message:"Ensure this value has at least {limitValue} characters (it has {showValue}).",code:"minLength"}),T=D.extend({constructor:function(t){return this instanceof T?D.call(this,t):new T(t)},compare:function(t,e){return t>e},clean:function(t){return t.length},message:"Ensure this value has at most {limitValue} characters (it has {showValue}).",code:"maxLength"});e.exports={EMPTY_VALUES:m,RegexValidator:v,URLValidator:g,EmailValidator:y,validateEmail:x,validateSlug:_,validateIPv4Address:F,validateIPv6Address:i,validateIPv46Address:n,ipAddressValidators:o,validateCommaSeparatedIntegerList:C,BaseValidator:D,MaxValueValidator:O,MinValueValidator:I,MaxLengthValidator:T,MinLengthValidator:A,ValidationError:p,ipv6:d}},{"./errors":16,"./ipv6":17,Concur:8,"isomorph/is":12,"isomorph/object":13,"isomorph/url":15,punycode:9}]},{},[5])(5)}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment