Skip to content

Instantly share code, notes, and snippets.

@insin
Last active August 29, 2015 13:56
Show Gist options
  • Save insin/9299833 to your computer and use it in GitHub Desktop.
Save insin/9299833 to your computer and use it in GitHub Desktop.
Newforms: All Default Fields - http://bl.ocks.org/insin/raw/9299833/
/**
* @jsx React.DOM
*/
var choices = [
[1, 'foo']
, [2, 'bar']
, [3, 'baz']
, [4, 'ter']
]
var choicesWithEmpty = [['', '----']].concat(choices)
var dateFormats = [
'%Y-%m-%d' // '2006-10-25'
, '%d/%m/%Y' // '25/10/2006'
, '%d/%m/%y' // '25/10/06'
]
var timeFormat = '%H:%M' // '14:30'
var dateTimeFormats = dateFormats.map(function(df) { return df + ' ' + timeFormat})
var AllFieldsForm = forms.Form.extend({
CharField: forms.CharField({minLength: 5, maxLength: 10, helpText: 'Any text between 5 and 10 characters long.'})
, CharFieldWithTextareaWidget: forms.CharField({label: 'Char field (textarea)', widget: forms.Textarea})
, IntegerField: forms.IntegerField({minValue: 42, maxValue: 420, helpText: 'Any whole number between 42 and 420'})
, FloatField: forms.FloatField({minValue: 4.2, maxValue: 42, helpText: 'Any number between 4.2 and 42'})
, DecimalField: forms.DecimalField({maxDigits: 5, decimalPlaces: 2, helpText: '3 digits allowed before the decimal point, 2 after it'})
, DateField: forms.DateField({inputFormats: dateFormats, helpText: {__html: '<em>yyyy-mm-dd</em> or <em>dd/mm/yyyy</em>'}})
, TimeField: forms.TimeField({inputFormats: [timeFormat], helpText: 'hh:mm, 24 hour'})
, DateTimeField: forms.DateTimeField({inputFormats: dateTimeFormats, helpText: 'e.g. 2014-03-01 20:08'})
, RegexField: forms.RegexField(/^I am Jack's /, {initial: "I am Jack's ", minLength: 20, helpText: 'Must begin with "I am Jack\'s " and be at least 20 characters long'})
, EmailField: forms.EmailField()
, FileField: forms.FileField({helpText: 'Required'})
, ImageField: forms.ImageField({required: false, helpText: 'Optional'})
, URLField: forms.URLField({label: 'URL field'})
, BooleanField: forms.BooleanField()
, NullBooleanField: forms.NullBooleanField()
, ChoiceField: forms.ChoiceField({choices: choicesWithEmpty})
, ChoiceFieldWithRadioWidget: forms.ChoiceField({label: 'Choice field (radios)', choices: choices, initial: 4, widget: forms.RadioSelect})
, TypedChoiceField: forms.TypedChoiceField({choices: choicesWithEmpty, coerce: Number})
, MultipleChoiceField: forms.MultipleChoiceField({choices: choices})
, MultipleChoiceFieldWithCheckboxWidget: forms.MultipleChoiceField({label: 'Multiple choice field (checkboxes)', choices: choices, initial: [1, 3], widget: forms.CheckboxSelectMultiple})
, TypedMultipleChoiceField: forms.TypedMultipleChoiceField({choices: choices, coerce: Number})
, ComboField: forms.ComboField({fields: [
forms.EmailField()
, forms.RegexField(/ferret/i, {errorMessages: {invalid: 'Where is ferret? ಠ_ಠ'}})
], helpText: 'An email address which contains the word "ferret"'})
, SplitDateTimeField: forms.SplitDateTimeField({label: 'Split date/time field (a MultiValueField)', inputDateFormats: dateFormats, inputTimeFormats: [timeFormat]})
, IPAddressField: forms.IPAddressField({label: 'IP address field', helpText: '(Deprecated)'})
, GenericIPAddressField: forms.GenericIPAddressField({label: 'Generic IP address field', helpText: 'An IPv4 or IPv6 address'})
, SlugField: forms.SlugField({helpText: 'Letters, numbers, underscores, and hyphens only'})
, render: function() {
return this.boundFields().map(function(bf) {
// Display cleaneddata, indicating its type
var cleanedData
if (this.cleanedData && bf.name in this.cleanedData) {
cleanedData = this.cleanedData[bf.name]
if (Array.isArray(cleanedData)) {
cleanedData = JSON.stringify(cleanedData)
}
else {
var isString = (Object.prototype.toString.call(cleanedData) == '[object String]')
cleanedData = ''+cleanedData
if (isString) {
cleanedData = '"' + cleanedData + '"'
}
}
}
var help
if (bf.helpText) {
help = (bf.helpText.__html
? <p dangerouslySetInnerHTML={bf.helpText}/>
: <p>{bf.helpText}</p>)
}
var errors = bf.errors().messages().map(function(message) {
return <div>{message}</div>
})
return <tr key={bf.htmlname}>
<th>{bf.labelTag()}</th>
<td>{bf.render()}{help}</td>
<td>{errors}</td>
<td className="cleaned-data">{cleanedData}</td>
</tr>
}.bind(this))
}
})
var AllFields = React.createClass({
getInitialState: function() {
return({form: new AllFieldsForm()})
}
, render: function() {
return <form encType='multipart/form-data' ref="form" onSubmit={this.onSubmit}>
<table>
<thead>
<tr>
<th>Label</th>
<th>Input</th>
<th>Errors</th>
<th>Cleaned Data</th>
</tr>
</thead>
<tbody>
{this.state.form.render()}
<tr>
<td></td>
<td colSpan="3">
<input type="submit" value="Submit"/>
</td>
</tr>
</tbody>
</table>
{this.state.form.cleanedData && <h2>form.cleanedData</h2>}
<pre>{this.state.form.cleanedData && JSON.stringify(this.state.form.cleanedData, null, ' ')}</pre>
</form>
}
, onSubmit: function(e) {
e.preventDefault()
this.state.form.setData(forms.formData(this.refs.form.getDOMNode()))
this.forceUpdate()
}
})
React.renderComponent(<AllFields/>, document.getElementById('app'))
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Newforms: All Default Fields</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>
<style>
body { font-family: helvetica, arial, sans-serif; font-size: small;}
thead th { text-align: left; padding: 4px 6px;}
tbody th { text-align: right; padding: 4px 6px; }
tbody th, td { vertical-align: top; }
tbody td { padding: 4px 6px; }
td.cleaned-data { white-space: pre; }
</style>
</head>
<body>
<h1><a href="https://github.com/insin/newforms">Newforms</a>: All Default Fields</h1>
<p>These are uncontrolled components, so get hitting that enter key!</p>
<div id="app"></div>
<script type="text/jsx" src="allfields.js"></script>
<a href="https://gist.github.com/insin/9299833"><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>
/**
* 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=[null];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.apply(null,a))}function e(t,e,r,i){var n=[{colSpan:2}];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.apply(null,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.apply(a.DOM,[null].concat(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