var ref=function(a,b){for(var d=null;null==d||a.hasOwnProperty(d);)d="$"+(268435456+Math.floor(4026531839*Math.random())).toString(16)+"$";a[d]=b;return d},WrapperTable={},Wrapper=function(a){do a=268435456+Math.floor(4294967295*Math.random());while(WrapperTable[a]);return{}},FormBuilder=function(a){this.form_object=a;this.observer=new MutationObserver(FormBuilder.DOMUpdates)}; FormBuilder.prototype={form_object:this.form_object,defs_object:{},parent_element:null,built_form:null,root_element:null,ref_table:{$00000000$:null},ref_assoc:{NULL:"$00000000$"},observer:this.observer,scope:{}};FormBuilder.regex={reg_in_key:/^\/\^(.+)\$\/$/,reg_out_val:/\{(\$[1-9])\}/,pri_out_val:/\{([a-z_]+)\}/g,pri_in_key:/^\$([a-z_]+)$/,arr_out_set:/^\{([a-z_]+)\[\]\}$/,arr_out_val:/\{([a-z_]+)([\.:])([a-z_]+)\}/g,arr_in_key:/^\$([a-z_]+)$/,fun_out_val:/^\{([a-z_]+)\(\)\}$/,ref_pri:/^\$[a-f0-9]{8}\$$/}; FormBuilder.spread_attr="children next_nodes prev_nodes attributes node_link listeners repeat browse funcs".split(" ");FormBuilder.spec_attr=["_value","_selected"];FormBuilder.observe={attributes:{attributes:!0,attributeOldValue:!1,childList:!1,characterData:!1,subtree:!1,characterDataOldValue:!1},characterData:{attributes:!1,attributeOldValue:!1,childList:!1,characterData:!0,subtree:!1,characterDataOldValue:!0}};FormBuilder.debug_time=!1;FormBuilder.debug_time_details=!1; FormBuilder.debugStart=function(a,b){if(1!=b||!FormBuilder.debug_time)if(2!=b||!FormBuilder.debug_time_details)return{type:0};var d="["+parseInt(64424509439*Math.random()).toString(16)+"]";console.time(d);console.group(a);return{type:b,time_r:d,group:a}};FormBuilder.debug=function(a,b){if(1!=b||!FormBuilder.debug_time)if(2!=b||!FormBuilder.debug_time_details)return{type:0};console.debug(a)}; FormBuilder.debugStop=function(a){if(1!=a.type||!FormBuilder.debug_time)if(2!=a.type||!FormBuilder.debug_time_details)return null;console.timeEnd(a.time_r);console.groupEnd(a.group)};FormBuilder.prototype.add_definition=function(a){var b=FormBuilder.debugStart("FormBuilder.add_definition",1),d;for(d in a)this.defs_object[d]=a[d];FormBuilder.debugStop(b)}; FormBuilder.prototype.build=function(a){var b=FormBuilder.debugStart("FormBuilder.build",1);a=null==a?{}:a;for(var d in a)a[d]=ref(this.ref_table,a[d]),this.ref_assoc[d]=a[d],this.scope["$"+d]=this.ref_assoc[d],this.__defineGetter__("$"+d,function(a,b){return function(){return a.ref_table[a.scope["$"+b]]}}(this,d)),this.__defineSetter__("$"+d,function(a,b){return function(d){a.ref_table[a.scope["$"+b]]=d;a.attach()}}(this,d));this.built_form=JSON.parse(JSON.stringify(this.form_object));this.built_form= FormBuilder.replaceStatements(this.built_form,a,this.defs_object,this.ref_table,this.ref_assoc);FormBuilder.debugStop(b)};FormBuilder.prototype.update=function(a){var b=FormBuilder.debugStart("FormBuilder.update",1);a=null==a?{}:a;for(var d in a)this.ref_assoc.hasOwnProperty(d)&&(this.ref_table[this.ref_assoc[d]]=a[d]);FormBuilder.debugStop(b)}; FormBuilder.prototype.attach=function(a){var b=FormBuilder.debugStart("FormBuilder.attach",1);if(!(a instanceof Element)&&null===this.parent_element)return!1;this.parent_element=a instanceof Element?a:this.parent_element;this.built_form.hasOwnProperty("dom")&&(this.observer.disconnect(),FormBuilder.detachElements(this.parent_element,this.built_form.dom));FormBuilder.createElements(this.built_form,this.ref_table,this.ref_assoc);FormBuilder.attachElements(this.parent_element,this.built_form.dom);this.observer.observe(this.parent_element, FormBuilder.observe.attributes);FormBuilder.debugStop(b)}; FormBuilder.fetchNodeDefinition=function(a,b){var d=FormBuilder.debugStart("FormBuilder::fetchNodeDefinition",2);FormBuilder.debug('node = "'+a+'"',2);var e,f;r=FormBuilder.regex.reg_in_key;if("undefined"!=typeof b&&b.hasOwnProperty(a))return FormBuilder.debugStop(d),{def:b[a]};for(e in b)if(r.test(e)&&(f=new RegExp(e.slice(1,-1)),f.test(a))){matches={};for(f=1;ff;f++)matches["$"+f]=RegExp["$"+f];FormBuilder.debugStop(d);return{def:b[e],scope:matches}}FormBuilder.debugStop(d);return{}}; FormBuilder.replaceStatements=function(a,b,d,e,f){var g=FormBuilder.debugStart("FormBuilder::replaceStatements",2);a=a instanceof Object?a:{};b=b instanceof Object?JSON.parse(JSON.stringify(b)):{};var c,h;if(a.hasOwnProperty("scope")&&a.scope instanceof Object)for(c in a.scope)b[c]=a.scope[c];if(a.hasOwnProperty("node")&&"string"==typeof a.node&&(h=FormBuilder.fetchNodeDefinition(a.node,d),h.hasOwnProperty("def")&&(a.node_link=JSON.parse(JSON.stringify(h.def)),h.hasOwnProperty("scope"))))for(c in h.scope)b[c]= h.scope[c];a.hasOwnProperty("browse")&&(a.browse.hasOwnProperty("array")&&FormBuilder.regex.arr_out_set.test(a.browse.array)?a.browse.id=RegExp.$1:delete a.browse);for(c in a)"string"==typeof a[c]?(a[c]=[a[c]],h=FormBuilder.replaceStatementsFunction(a[c][0],b,e),!1!==h?a[c]=h:(h=FormBuilder.replaceStatementsArray(a[c][0],b,e),!1!==h?a[c]=h:(a[c]=FormBuilder.replaceStatementsRegex(a[c],b),a[c]=FormBuilder.replaceStatementsPrimary(a[c],b),a[c]=FormBuilder.replaceStatementsArrayValue(a[c],b,e,f)))): "number"===typeof a[c]&&(a[c]=[ref(e,a[c])]);for(c in a)FormBuilder.regex.pri_in_key.test(c)?b[c.substring(1)]=ref(e,a[c]):FormBuilder.regex.arr_in_key.test(c)&&(b[c.substring(2)]=ref(e,a[c]));b=JSON.parse(JSON.stringify(b));for(c in a)if(-1=d.lastIndex);)g=d.lastIndex,f.push(e);for(e=g=0;e",2);FormBuilder.debugStop(e);return a.dom=f}; FormBuilder.attachElements=function(a,b){var d=FormBuilder.debugStart("FormBuilder::attachElements",2),e,f;for(e in b){for(f in b[e].prev)b[e].prev[f]instanceof Element&&a.appendChild(b[e].prev[f]),b[e].prev[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].prev[f]]);for(f in b[e].node)b[e].node[f]instanceof Element&&a.appendChild(b[e].node[f]),b[e].node[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].node[f]]);for(f in b[e].next)b[e].next[f]instanceof Element&&a.appendChild(b[e].next[f]), b[e].next[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].next[f]])}FormBuilder.debugStop(d)}; FormBuilder.detachElements=function(a,b){var d,e;for(d in b){for(e in b[d].prev)b[d].prev[e]instanceof Element&&a.hasChildNodes(b[d].prev[e])&&a.removeChild(b[d].prev[e]),b[d].prev[e]instanceof Object&&FormBuilder.detachElements(a,[b[d].prev[e]]);for(e in b[d].node)b[d].node[e]instanceof Element&&a.hasChildNodes(b[d].node[e])&&a.removeChild(b[d].node[e]),b[d].node[e]instanceof Object&&FormBuilder.detachElements(a,[b[d].node[e]]);for(e in b[d].next)b[d].next[e]instanceof Element&&a.hasChildNodes(b[d].next[e])&& a.removeChild(b[d].next[e]),b[d].next[e]instanceof Object&&FormBuilder.detachElements(a,[b[d].next[e]])}};FormBuilder.applyCSS=function(a,b){for(var d in b)a.style[d]=b[d]};FormBuilder.fetchNodeType=function(a){if(a.hasOwnProperty("node_type"))return a.node_type;if(a.hasOwnProperty("node_link"))return FormBuilder.fetchNodeType(a.node_link)}; FormBuilder.DOMUpdates=function(a,b,d){var e,f,g,c=FormBuilder.regex.ref_pri;for(e in b)if(f=b[e].attributeName,a.hasOwnProperty("attributes")&&a.attributes.hasOwnProperty(f)&&(g=a.attributes[f]),g instanceof Array&&1==g.length&&c.test(g[0])||c.test(g))g=g[0]||g,g=FormBuilder.fetchRef(d,g),d[g]=b[e].target.getAttribute(f)};