(function(){var f="before_start before_end end_before end_after after_end after_start start_after start_before overlap overlap_end overlap_before overlap_after at_pointer after_pointer".split(" "),h={"no positive":"NO_POSITIVE","no negative":"NO_NEGATIVE","no zero":"NO_ZERO","no empty":"NO_EMPTY","no future":"NO_FUTURE","no past":"NO_PAST","no today":"NO_TODAY",strict:"STRICT",server:"SERVER"};zul.inp.SimpleConstraint=zk.$extends(zk.Object,{_finishParseCst:!0,$init:function(b,a,c){if("string"==typeof b)this._flags=
{},this._errmsg={},this._cstArr=[],this._cst=b,this._finishParseCst=!1,this._init(b);else{this._flags="number"==typeof b?this._cvtNum(b):b||{};this._regex="string"==typeof a?new RegExp(a,"g"):a;this._errmsg={};this._regex&&(this._errmsg.regex=c);for(flag in this._flags)this._errmsg[flag]=c;this._flags.SERVER&&(this.serverValidate=!0)}},_init:function(b){var a=0,c=0,e=b.length;a:for(;0<=c;a=c+1){for(;;++a){if(a>=e)return;var d=b.charAt(a);if("/"==d){for(c=++a;;++c){if(c>=e){c=-1;break}d=b.charAt(c);
if("/"==d)break;"\\"==d&&++c}this._regex=new RegExp(0<=c?b.substring(a,c):b.substring(a),"g");this._cstArr[this._cstArr.length]="regex";continue a}if(":"==d){var g=0,f=e;for(c=++a;;++c){if(c>=e){c=-1;break}d=b.charAt(c);if("{"==d)for(g=c+1,++c;;++c){if("}"==b.charAt(c)){f=c;break}}else if(","==d)break}this._errmsg[this._cstArr[this._cstArr.length-1]]=g?b.substring(g,f).trim():0<=c?b.substring(a,c).trim():b.substring(a).trim();continue a}if(!zUtl.isChar(d,{whitespace:1}))break}for(c=a;;++c){if(c>=
e){a=b.substring(a);c=-1;break}d=b.charAt(c);if(","==d||":"==d||";"==d||"/"==d)if(this._regex&&a==c)a++;else{a=b.substring(a,c);":"!=d&&"/"!=d||--c;break}}this.parseConstraint_(a.trim().toLowerCase())}},getFlags:function(){return this._flags},parseConstraint_:function(b){var a=this._flags,c=this._cstArr,e=h[b];b&&e?("server"==b&&(this.serverValidate=!0),a[e]=!0,c[c.length]=e):b&&f.$contains(b)?this._pos=b:!c.length&&zk.debugJS&&zk.error("Unknown constraint: "+b)},_cvtNum:function(b){var a={};b&1&&
(a.NO_POSITIVE=a.NO_FUTURE=!0);b&2&&(a.NO_NEGATIVE=a.NO_PAST=!0);b&4&&(a.NO_ZERO=a.NO_TODAY=!0);b&256&&(a.NO_EMPTY=!0);b&512&&(a.STRICT=!0);if(b&=61440)this._pos=f[(b>>12)-1];return a},validate:function(b,a){this._finishParseCst||(this._cst&&this._init(this._cst),this._finishParseCst=!0);var c=this._flags,e=this._errmsg;a&&a.$toNumber&&(a=a.$toNumber());switch(typeof a){case "string":if(c.NO_EMPTY&&(!a||!a.trim()))return e.NO_EMPTY||msgzul.EMPTY_NOT_ALLOWED;var d=this._regex;if(d&&(d=a.match(d),!d||
d.join("")!=a))return e.regex||msgzul.ILLEGAL_VALUE;if(c.STRICT&&a&&b.validateStrict&&(e=b.validateStrict(a)))return e;return;case "number":if(0<a){if(c.NO_POSITIVE)return e.NO_POSITIVE||this._msgNumDenied()}else if(0==a){if(c.NO_ZERO)return e.NO_ZERO||this._msgNumDenied()}else if(c.NO_NEGATIVE)return e.NO_NEGATIVE||this._msgNumDenied();return}if(a&&a.getFullYear)if(b=a.getTimeZone(),d=zUtl.today(null,b),a=Dates.newInstance([a.getFullYear(),a.getMonth(),a.getDate()],b),0>(d-a)/864E5){if(c.NO_FUTURE)return e.NO_FUTURE||
this._msgDateDenied()}else if(0==a-d){if(c.NO_TODAY)return e.NO_TODAY||this._msgDateDenied()}else{if(c.NO_PAST)return e.NO_PAST||this._msgDateDenied()}else if(!a&&c.NO_EMPTY)return e.NO_EMPTY||msgzul.EMPTY_NOT_ALLOWED},_msgNumDenied:function(){var b=this._flags,a=this._errmsg;return b.NO_POSITIVE?a.NO_POSITIVE||(b.NO_ZERO?b.NO_NEGATIVE?msgzul.NO_POSITIVE_NEGATIVE_ZERO:msgzul.NO_POSITIVE_ZERO:b.NO_NEGATIVE?msgzul.NO_POSITIVE_NEGATIVE:msgzul.NO_POSITIVE):b.NO_NEGATIVE?a.NO_NEGATIVE||(b.NO_ZERO?msgzul.NO_NEGATIVE_ZERO:
msgzul.NO_NEGATIVE):b.NO_ZERO?a.NO_ZERO||msgzul.NO_ZERO:a||msgzul.ILLEGAL_VALUE},_msgDateDenied:function(){var b=this._flags,a=this._errmsg;return b.NO_FUTURE?a.NO_FUTURE||(b.NO_TODAY?b.NO_PAST?NO_FUTURE_PAST_TODAY:msgzul.NO_FUTURE_TODAY:b.NO_PAST?msgzul.NO_FUTURE_PAST:msgzul.NO_FUTURE):b.NO_PAST?a.NO_PAST||(b.NO_TODAY?msgzul.NO_PAST_TODAY:msgzul.NO_PAST):b.NO_TODAY?a.NO_TODAY||msgzul.NO_TODAY:a||msgzul.ILLEGAL_VALUE},reparseConstraint:function(){this._finishParseCst=!1}})})();
