/
svidget-0.2.0.min.js
4 lines (4 loc) · 78.7 KB
/
svidget-0.2.0.min.js
1
2
3
4
/* Svidget.js v0.2.0 on 2015-02-05, Copyright 2014 Joe Agster http://www.svidget.org MIT License */
(function(){var a={};a.emptyArray=[],a.root=window,a.version="0.1.1",a.declaredHandlerName="_declared",a.array=function(b){if(!b||!b.length)return null;try{return a.emptyArray.slice.call(b,0)}catch(c){for(var d=[],e=0;e<b.length;e++)d.push(b[e]);return d}},a.isArray=function(a){return null!=a&&(Array.isArray(a)||Array.prototype.isPrototypeOf(a)||a.length&&a.push)},a.isFunction=function(a){return"function"==typeof a},a.isString=function(a){return"string"==typeof a||a.length&&a.trim&&a.charAt},a.isColor=function(){return!1},a.convert=function(b,c,d,e){return a.Conversion.to(b,c,d,e)},a.extend=function(a,b,c){for(var d in b)(c||void 0===a.prototype[d])&&(a.prototype[d]=b[d])},a.wrap=function(a,b){if(null==a||"function"!=typeof a)return void 0;var c=function(){return a.apply(b,arguments)};return c},a.findFunction=function(b,c){if("function"==typeof b)return b;if(null==c&&(c=a.root),null!=b){var d=b+"",e=c[d];return null==e?null:"function"==typeof e?e:new Function("return "!=d.substr(0,7)?"return "+d:d)}return null},a.log=function(b){a.Settings.enableLogging&&console.log(b)},a.readOnlyProperty=function(a){return{enumerable:!0,configurable:!1,writable:!1,value:a}},a.fixedProperty=function(a){return{enumerable:!0,configurable:!1,writable:!0,value:a}},a.getPrivateAccessor=function(a){return function(b){return a[b]}},a.setPrivateAccessor=function(a){return function(b,c){return a.writable.contains(b)?(a[b]=c,!0):!1}},a.returnFalse=function(){return!1},a.returnTrue=function(){return!0},a.Settings={},a.Settings.showPrivates=!0,a.Settings.enableLogging=!1,Array.prototype.contains||(Array.prototype.contains=function(a){for(var b=this.length;b--;)if(this[b]===a)return!0;return!1}),Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),a.ObjectPrototype={setup:function(b){this.getPrivate=a.getPrivateAccessor(b),this.setPrivate=a.setPrivateAccessor(b),a.Settings.showPrivates&&(this.privates=b)},getset:function(a,b,c){var d=this.getPrivate(a);if(void 0===b)return d;if(c&&!c(b))return!1;var e=this.setPrivate(a,b);return e},select:function(a,b){return"number"==typeof b?(b=parseInt(b),a.wrap(a.getByIndex(b))):void 0!==b?a.wrap(a.getByName(b+"")):a},selectFirst:function(a,b){return"number"==typeof b?(b=parseInt(b),a.getByIndex(b)):void 0!==b?a.getByName(b+""):a.first()},wireCollectionAddRemoveHandlers:function(b,c,d){null!=b&&(b.onAdded(a.wrap(c,this)),b.onRemoved(a.wrap(d,this)))}},a.EventPrototype=function(b){this.eventTypes=new a.Collection(b)},a.EventPrototype.prototype={on:function(b,c,d,e){return e=e||(a.isFunction(d)?d:a.isFunction(c)?c:null),c=arguments.length>2?c:null,d=void 0!==d&&e!==d?d:null,this.addHandler(b,e,d,c)},off:function(b,c){var d=a.isFunction(c)?c:null,e=null!=d?null:c;return this.removeHandler(b,d,e)},trigger:function(b,c,d){if(null!=b){var e=this.triggerHandlers(b,c,d);a.log("trigger: "+b),e.isPropagationStopped()||this.bubble(b,e)}},triggerHandlers:function(b,c,d){var e=new a.Event(null,b,null,this.getTarget(),d,c);if(null==b||null==this.handlers||null==this.handlers[b])return e;var f=this.handlers[b];return f.each(function(a){return e.isImmediatePropagationStopped()?!1:void(null!=a&&null!=a.handler&&"function"==typeof a.handler&&(e.name=a.name,e.data=a.data,a.handler.call(null,e)))}),e},bubble:function(a,b){this.ensureBubbleParents(),b.name=null,b.data=null,this.bubbleParents[a]&&this.bubbleParents[a](a,b,this.getTarget())},addHandler:function(a,b,c,d){if(this.ensureHandlersByType(a),this.handlerExists(a,b,c))return!1;var e=this.toHandlerObject(b,c,d);return this.handlers[a].push(e),!0},removeHandler:function(a,b,c){if(this.ensureHandlers(),!this.handlers[a])return!1;var d=this;return this.handlers[a].removeWhere(function(a){return d.handlerMatch(a,b,c)})},handlerExists:function(a,b,c){var d=this,e=this.handlers[a].any(function(a){return d.handlerMatch(a,b,c)});return e},handlerMatch:function(a,b,c){return null!=c&&a.name===c?!0:b===a.handler?!0:!1},setBubbleParent:function(a,b){this.ensureBubbleParents(),this.bubbleParents[a]=b},registerBubbleCallback:function(b,c,d){if(c&&d)for(var e=0;e<b.length;e++)this.setBubbleParent(b[e],a.wrap(d,c))},toHandlerObject:function(a,b,c){var d={handler:a,name:b,data:c};return d},bubbleFuncs:function(){},ensureHandlers:function(){this.handlers||(this.handlers={})},ensureHandlersByType:function(b){this.ensureHandlers(),this.handlers[b]||(this.handlers[b]=new a.Collection)},ensureBubbleParents:function(){this.bubbleParents||(this.bubbleParents={})},getTarget:function(){return this}},a.ParamPrototype={name:function(){var a=this.getPrivate("name");return a},description:function(a){var b=this.getset("description",a);return void 0!==a&&b?(this.trigger&&this.trigger("change",{property:"description",value:a}),!0):b},type:function(a){var b=this.getset("type",a,this.validateType);return void 0!==a&&b?(this.trigger&&this.trigger("change",{property:"type",value:a}),!0):b},subtype:function(a){var b=this.getset("subtype",a,this.validateSubtype);return void 0!==a&&b?(this.trigger&&this.trigger("change",{property:"subtype",value:a}),!0):b},typedata:function(a){var b=this.getset("typedata",a);return void 0!==a&&b?(this.trigger("change",{property:"typedata",value:a}),!0):b},defvalue:function(a){var b=this.getset("defvalue",a,this.validateSubtype);return void 0!==a&&b?(this.trigger&&this.trigger("change",{property:"defvalue",value:a}),!0):b},validateType:function(b){return void 0!=a.ParamTypes[b]},validateSubtype:function(b){return void 0!=a.ParamSubTypes[b]}},a.Collection=function(b){this.__type="Svidget.Collection",this.source=b,b&&(a.isArray(b)||Array.prototype.isPrototypeOf(b))&&this.push.apply(this,b)},a.Collection.prototype=new Array,a.extend(a.Collection,{any:function(a){if(null==a)return this.length>0;for(var b=0;b<this.length;b++)if(a(this[b]))return!0;return!1},all:function(a){if(null==a)return!1;for(var b=0;b<this.length;b++)if(!a(this[b]))return!1;return!0},contains:function(a){return this.indexOf(a)>=0},each:function(a){for(var b=0;b<this.length;b++){var c=a(this[b]);if(c===!1)break}},first:function(a){if(0==this.length)return null;if(null==a)return this[0];for(var b=0;b<this.length;b++)if(a(this[b]))return this[b];return null},last:function(a){if(0==this.length)return null;if(null==a)return this[0];for(var b=this.length-1;b>=0;b--)if(a(this[b]))return this[b];return null},select:function(b){for(var c=[],d=0;d<this.length;d++)c.push(b(this[d]));return new a.Collection(c)},where:function(b){for(var c=[],d=0;d<this.length;d++)b(this[d])&&c.push(this[d]);return new a.Collection(c)},add:function(a){var b=this.indexOf(a);return b>=0?!1:(this.push(a),!0)},addRange:function(b){return a.isArray(b)?(this.push.apply(this,b),!0):!1},insert:function(a,b){return b=parseInt(b),!isNaN(b)&&(0>b||b>this.length)?!1:(this.splice(b,0,a),!0)},remove:function(a){var b=this.indexOf(a);return 0>b?!1:(this.splice(b,1),!0)},removeAll:function(a){for(var b=!1;this.remove(a);)b=!0;return b},removeWhere:function(a){for(var b=[],c=!1,d=0;d<this.length;d++)a(this[d])&&b.push(this[d]);for(var d=0;d<b.length;d++)c=this.remove(b)||c;return c},toArray:function(){for(var a=[],b=0;b<this.length;b++)a.push(this[b]);return a}}),a.ObjectCollection=function(b,c){a.Collection.apply(this,[b]),this.__type="Svidget.ObjectCollection";var d=new function(){this.writable=["addedFunc","removedFunc"],this.type=c,this.addedFunc=null,this.removedFunc=null};this.setup(d)};var b=new a.Collection;a.ObjectCollection.prototype=b,a.ObjectCollection.prototype.base_add=b.add,a.ObjectCollection.prototype.base_remove=b.remove,a.extend(a.ObjectCollection,{get:function(a){return"number"==typeof a?col.getByIndex(a):col.getByName(a)},getByIndex:function(a){return null==a||isNaN(a)?null:(a=parseInt(a),this[a])},getByName:function(a){return this.first(function(b){return b.name()==a})},type:function(){return this.getset("type")},add:function(){if(0==arguments.length)return null;var a,b,c;return arguments.length>=1&&(b=arguments[0]),a="string"==typeof b?this.create.apply(this,arguments):b,null==a?null:(c=this.addObject(a))?(this.triggerAdded(a),a):null},addObject:function(a){return null==a||!a instanceof this.type()?!1:void 0!==a.name&&null!=this.getByName(a.name())?!1:(this.push(a),a)},create:function(){return null},remove:function(a){var b=this.getByName(a);if(null==b)return!1;var c=this.base_remove(b);return c?(this.triggerRemoved(b),!0):!1},wrap:function(a){var b=[a];(null==a||!a instanceof this.type())&&(b=[]);var c=new this.constructor(b,this.parent);return c},onAdded:function(a){this.getset("addedFunc",a)},onRemoved:function(a){this.getset("removedFunc",a)},triggerAdded:function(a){var b=this.getset("addedFunc");b&&b(a)},triggerRemoved:function(a){var b=this.getset("removedFunc");b&&b(a)}},!0),a.extend(a.Collection,a.ObjectPrototype),a.Communicator=function(){this.__type="Svidget.Communicator",this.sameDomain=null,this._init()},a.Communicator.prototype={_init:function(){this.addMessageEvent()},addMessageEvent:function(){window.addEventListener("message",a.wrap(this.receiveXSM,this),!1)},receiveFromParent:function(a,b){svidget.receiveFromParent(a,b)},receiveFromWidget:function(a,b,c){svidget.receiveFromWidget(a,b,c)},receiveXSM:function(a){if(null!=a){var b=a.data;null!=b&&(void 0!==b.widget?this.receiveFromWidget(b.name,b.payload,b.widget):this.receiveFromParent(b.name,b.payload))}},signalParent:function(a,b,c){this.isParentSameDomain()?this.signalParentDirect(a,b,c):this.signalParentXSM(a,b,c)},signalParentDirect:function(a,b,c){if(null!=window.parent&&window!==window.parent&&null!=window.parent.svidget&&window.parent.svidget){var d=window.parent.svidget;setTimeout(function(){d.routeFromWidget(a,b,c)},0)}},signalParentXSM:function(a,b,c){if(null!=window.parent){var d=this.buildSignalParentMessage(a,b,c);window.parent.postMessage(d,"*")}},buildSignalParentMessage:function(a,b,c){return{name:a,payload:b,widget:c}},isParentSameDomain:function(){return null==this.sameParentDomain&&(this.sameParentDomain=this.checkParentSameDomain()),this.sameParentDomain},checkParentSameDomain:function(){try{{window.parent.document}return!0}catch(a){return!1}},signalWidget:function(b,c,d){a.log("communicator: signalWidget {name: "+c+"}"),b.isCrossDomain()?this.signalWidgetXSM(b,c,d):this.signalWidgetDirect(b,c,d)},signalWidgetDirect:function(a,b,c){if(null!=a){var d=a.root();null!=d&&setTimeout(function(){d.receiveFromParent(b,c)},0)}},signalWidgetXSM:function(b,c,d){if(null!=b&&null!=b.window()){var e=this.buildSignalWidgetMessage(c,d);setTimeout(function(){a.log("communicator: postMessage"),b.window().postMessage(e,"*")},0)}},buildSignalWidgetMessage:function(a,b){return{name:a,payload:b}}},a.Conversion={},a.Conversion.to=function(b,c,d,e){var f=a.ParamTypes[c]||a.ParamTypes.object,g=a.ParamSubTypes[d]||a.ParamSubTypes.none;switch(f){case a.ParamTypes.string:return a.Conversion.toString(b,g,e);case a.ParamTypes.number:return a.Conversion.toNumber(b,g==a.ParamSubTypes.integer);case a.ParamTypes.bool:return a.Conversion.toBool(b);case a.ParamTypes.array:return a.Conversion.toArray(b);default:return a.Conversion.toObject(b)}},a.Conversion.toString=function(b,c,d){return c==a.ParamSubTypes.choice?a.Conversion.toChoiceString(b,d):b+""},a.Conversion.toChoiceString=function(a,b){if(!b)return null;var c=b.split("|");return null==c||0==c.length?null:c.indexOf(a)>=0?a:c[0]},a.Conversion.toNumber=function(a,b){return a?a===!0?1:b?parseInt(a+""):+a:0},a.Conversion.toBool=function(a){var b=a+"";return"false"==b.toLowerCase()?!1:0===+a?!1:!!a},a.Conversion.toArray=function(b){if(null==b)return b;if(a.isArray(b))return b;if(a.Conversion.isArrayString(b)){var c=a.Conversion.parseArray(b);if(null!=c)return c}return[b]},a.Conversion.toObject=function(b){if(null==b)return b;if(a.Conversion.isJSONString(b)){b=a.Conversion.jsonifyString(b);try{return JSON.parse(b)}catch(c){}}return b},a.Conversion.isJSONString=function(b){return b?(b=b.trim(),b.length>0&&a.isString(b)&&"{"==b.charAt(0)&&"}"==b.charAt(b.length-1)):!1},a.Conversion.isArrayString=function(b){return b?(b=b.trim(),b.length>0&&a.isString(b)&&"["==b.charAt(0)&&"]"==b.charAt(b.length-1)):!1},a.Conversion.isQuotedString=function(b){return b?(b=b.trim(),b.length>0&&a.isString(b)&&("'"==b.charAt(0)&&"'"==b.charAt(b.length-1)||'"'==b.charAt(0)&&'"'==b.charAt(b.length-1))):!1},a.Conversion.parseArray=function(b){b=a.Conversion.jsonifyString(b);var c='{"d":'+b+"}";try{var d=JSON.parse(c);return d&&d.d?d.d:null}catch(e){return null}},a.Conversion.jsonifyString=function(a){if(null==a||a.indexOf("'")<0)return a;for(var b="'",c='"',d="\\",e="",f=!1,g=null,h=!1,i=0;i<a.length;i++){var j=a[i],k=j;j==b||j==c?h?(g==b&&j==b?e=e.substr(0,e.length-1):g==b&&j==c&&(k=d+d+c),h=!1):f&&j==g?(f=!1,g=null,k=c):f&&j==c?k=d+c:f||(g=j,f=!0,k=c):j==d&&(h=!0),e+=k}return e},a.DOM={get:function(a){return document.getElementById(a)},getByName:function(a,b){return this.getChildrenByName(document,a,b)},getByNameNS:function(b,c,d){var e=document.getElementsByTagNameNS(b,c);return d?new a.Collection(a.array(e)):e},getByNameSvidget:function(b,c){return this.getByNameNS(a.Namespaces.svidget,b,c)},getChildrenByName:function(b,c,d){var e=b.getElementsByTagName(c);return d?new a.Collection(a.array(e)):e},getElement:function(a){return"string"==typeof a?this.get(a):a},getItem:function(a){return this.wrap(this.get(a))},select:function(b){function c(b){if(null==b)return null;var c,d=/@([^=#\s]+)$/g,e=b,f=d.exec(b);f&&(c=f[1],e=e.replace(f[0],""));var g;try{g=document.querySelectorAll(e)}catch(h){return null}for(var i=[],j=0;j<g.length;j++){var k,l=g[j];if(c){var m=a.DOM.attr(l,c);null!=m&&(k=new a.DOMItem(m))}else k=new a.DOMItem(l);k&&i.push(k)}return new a.Collection(i)}if(!document.querySelectorAll)return null;if(null==b)return null;var d,e=/@[^=#\s]+/g,f=e.test(b),g=new a.Collection;if(f)for(var h=b.split(","),i=0;i<h.length;i++)d=c(h[i]),d&&g.addRange(d);else d=c(b),d&&g.addRange(d);var j=new a.DOMQuery(g,b);return j},selectElement:function(a){if("string"==typeof a){var b=this.select(a);return null==b||0==b.length?null:b.item(0).source()}return this.isElement(a)?a:null},wrap:function(b){return new a.DOMItem(b)},transportize:function(b){return{name:b.localName,namespace:b.namespaceURI,value:b.value,type:1==b.nodeType?a.NodeType.element:2==b.nodeType?a.NodeType.attribute:null}},root:function(){return document.documentElement},rootItem:function(){return this.wrap(this.root())},attr:function(a,b){return a.attributes[b]},attrValue:function(a,b){var c=this.attr(a,b);return c?c.value:null},clone:function(){},cloneDetached:function(){},isDOMNode:function(a){return a.namespaceURI&&a.localName&&a.nodeType&&a.value&&(1==a.nodeType||2==a.nodeType)},fromNodeType:function(a){return 1==a?"element":2==a?"attribute":3==a?"text":null},text:function(a,b){var c=this.select(a);return void 0===b?this.getText(c):void this.setText(c,b)},getText:function(a){return a.textContent?a.textContent:a.innerHTML?a.innerHTML:null},setText:function(a,b){a.textContent?a.textContent=b+"":a.innerHTML&&(a.innerHTML=b+"")},getDocument:function(a){try{var b=a.contentDocument;return null!=b&&"about:blank"==b.URL?null:b}catch(c){return void 0}},isElementDocumentReady:function(a){return null!==this.getDocument(a)},isElement:function(a){return a instanceof HTMLElement},attach:function(){},detach:function(){},disable:function(a){a.disabled=!0},enable:function(a){a.disabled=!1},show:function(a){a.style.display="initial",a.style.visibility="visible"},hide:function(a){a.style.display="none",a.style.visibility="hidden"},on:function(a,b,c,d){d=!!d;var e=!1;return a.addEventListener?(a.addEventListener(b,c,d),e=!0):a.attachEvent&&(a.attachEvent("on"+b,c),e=!0),e},off:function(a,b,c,d){d=!!d;var e=!1;return a.addEventListener?(a.removeEventListener(b,c,!1),e=!0):document.attachEvent&&(document.detachEvent("on"+b,c),e=!0),e}},a.DOMItem=function(b){function c(a){return null==a?!1:a.namespaceURI&&a.localName&&a.nodeType&&(a.value||a.textContent)&&(1==a.nodeType||2==a.nodeType)}function d(b){return b==a.NodeType.element?"element":b==a.NodeType.attribute?"attribute":null}function e(b){for(var c in a.Namespaces)if(b===a.Namespaces[c])return c}this.__type="Svidget.DOMItem",b=b||{};var f=new function(){this.writable=["value"],this.type=null,this.name=null,this.value=null,this.namespace=null,this.source=b,this.sourceDOM=c(b)};this.setup(f),f.sourceDOM?(f.typeCode=1==b.nodeType?a.NodeType.element:2==b.nodeType?a.NodeType.attribute:null,f.name=b.localName,f.namespace=b.namespaceURI):(f.typeCode=b.type,f.name=b.name,f.namespace=b.namespace),f.value=b.value||b.textContent,f.type=d(f.typeCode),f.namespaceType=e(f.namespace),this.cachedAttributes=null,this.cachedElements=null},a.DOMItem.prototype={typeCode:function(){return this.getset("type")},name:function(){return this.getset("name")},value:function(a){var b=this.source();if(void 0===a)return b.value||b.textContent;var c=a+"";b.value?b.value=c:b.textContent=c},namespace:function(){return this.getset("namespace")},namespaceType:function(){return this.getset("namespaceType")},hasElements:function(){if(this.isAttribute())return!1;var a=this.source();return this.isAttached()||a.children&&a.children.length?a.children.length>0:!1},hasAttributes:function(){if(this.isAttribute())return!1;var a=this.source();return this.isAttached()||a.attributes&&a.attributes.length?a.attributes.length>0:!1},isAttribute:function(){return this.type()==a.NodeType.attribute},elements:function(){if(null!=this.cachedElements&&a.isArray(this.cachedElements))return this.cachedElements;var b=this.isAttached();if(!(b||c.elements&&c.elements.length))return null;var c=this.source(),d=b?c.children:c.elements,e=new a.Collection(a.array(d));return e=e.select(function(b){return new a.DOMItem(b)}),this.cachedElements=e,this.cachedElements},attributes:function(){if(null!=this.cachedAttributes&&a.isArray(this.cachedAttributes))return this.cachedAttributes;var b=this.isAttached();if(!(b||c.attributes&&c.attributes.length))return null;var c=this.source(),d=c.attributes,e=new a.Collection(a.array(d));return e=e.select(function(b){return new a.DOMItem(b)}),this.cachedAttributes=e,this.cachedAttributes},source:function(){return this.getset("source")},isAttached:function(){return this.getset("sourceDOM")}},a.extend(a.DOMItem,a.ObjectPrototype),a.DOMQuery=function(b,c){this.__type="Svidget.DOMQuery";var d=new a.Collection(b),e=new function(){this.writable=[],this.items=d,this.selector=c};this.getPrivate=a.getPrivateAccessor(e),this.setPrivate=a.setPrivateAccessor(e),Object.defineProperty(this,"length",{enumerable:!0,configurable:!1,writable:!1,value:d.length||0})},a.DOMQuery.prototype={items:function(){return this.getset("items")},item:function(a){var b=this.items();return null==b?null:b[a]},hasItems:function(){return this.length>0},selector:function(){return this.getset("selector")},setValue:function(a){this.items().each(function(b){b.value(a)})},toString:function(){return'[Svidget.DOMQuery { selector: "'+this.selector()+'", items: '+this.items().length+"}]"}},a.extend(a.DOMQuery,a.ObjectPrototype),a.DocType={html:0,svg:1},a.DocReadyState={loading:0,interactive:1,complete:2},a.ElementReadyState={uninitialized:0,loading:1,loaded:2,interactive:3,complete:4},a.ParamTypes={object:0,string:1,number:2,bool:3,array:4},a.ParamSubTypes={none:0,color:1,integer:2,regex:3,choice:4},a.NodeType={element:0,attribute:1},a.Namespaces={html:"http://www.w3.org/1999/xhtml",svidget:"http://www.svidget.org/svidget",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"},a.Event=function(b,c,d,e,f,g){Object.defineProperty(this,"currentTarget",a.readOnlyProperty(e)),Object.defineProperty(this,"data",a.fixedProperty(d)),Object.defineProperty(this,"name",a.fixedProperty(b)),Object.defineProperty(this,"timeStamp",a.readOnlyProperty(+new Date)),Object.defineProperty(this,"target",a.readOnlyProperty(null==f?e:f)),Object.defineProperty(this,"type",a.readOnlyProperty(c)),Object.defineProperty(this,"value",a.readOnlyProperty(g))},a.Event.prototype={isPropagationStopped:a.returnFalse,isImmediatePropagationStopped:a.returnFalse,stopPropagation:function(){this.isPropagationStopped=a.returnTrue},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=returnTrue,this.stopPropagation()}},a.EventContainer=function(b,c){this.__type="Svidget.EventContainer",a.EventPrototype.apply(this,[b]),this.target=c},a.EventContainer.prototype=new a.EventPrototype,a.extend(a.EventContainer,{getTarget:function(){return this.target}},!0),a.Root=function(b){this.__type="Svidget.Root";var c=this,d=new function(){this.writable=["current","widgets","connected","loaded"],this.comm=new a.Communicator,this.eventContainer=new a.EventContainer(["loaded"],c),this.loaded=!1,this.current=null,this.connected=!1,this.widgets=null};this.setup(d),this.isBrowser=!0,this.root=b||window,this.docType=null,this.setCurrent=function(a){d.current=a},this._init()},a.Root.prototype={_init:function(){this._initEvents(),this._initPrototypes(),this.initInternal(),this._initReady()},_initEvents:function(){},_initPrototypes:function(){this.isWidget()?a.extend(a.Root,a.Root.WidgetPrototype,!0):a.extend(a.Root,a.Root.PagePrototype,!0)},_initReady:function(){this.isDomReady()?this._ready():this.addReadyEvents()},initInternal:function(){},_ready:function(){this.isReady=!0,this.isWidget()?this.readyWidget():this.readyPage()},getDocType:function(){var b=document.documentElement.localName,c=document.documentElement.namespaceURI;return"svg"==b&&c==a.Namespaces.svg?a.DocType.svg:a.DocType.html},isWidget:function(){return this.docType=this.getDocType(),this.docType==a.DocType.svg},isDomReady:function(){var b=document.readyState;return null!=b&&a.DocReadyState[b]?a.DocReadyState[b]>=a.DocReadyState.interactive:!1},addReadyEvents:function(){var b=a.wrap(this.readyHandler,this);a.DOM.on(document,"DOMContentLoaded",b),a.DOM.on(document,"readystatechange",b),a.DOM.on(window,"load",b)},readyHandler:function(){this.ensureReady()},ensureReady:function(){this.isReady||this._ready(),this.isReady=!0},markLoaded:function(){this.getset("loaded")!==!0&&(this.getset("loaded",!0),this.triggerLoaded())},eventContainer:function(){return this.getset("eventContainer")},on:function(a,b,c,d){this.eventContainer().on(a,b,c,d)},off:function(a,b){this.eventContainer().off(a,b)},trigger:function(a,b){this.eventContainer().trigger(a,b)},loaded:function(a,b,c){this.onload(a,b,c)},onload:function(a,b,c){this.on("load",a,b,c)},offload:function(a){this.off("load",a)},offdeclaredload:function(){this.off("load",a.declaredHandlerName)},widgetloaded:function(a,b,c){this.widgetloaded(a,b,c)},onwidgetload:function(a,b,c){this.on("widgetload",a,b,c)},offwidgetload:function(a){this.off("widgetload",a)},offdeclaredwidgetload:function(){this.off("widgetload",a.declaredHandlerName)},triggerLoaded:function(){this.trigger("load")},triggerWidgetLoaded:function(a){this.trigger("widgetload",a)},comm:function(){return this.getset("comm")},routeFromParent:function(b,c){a.log("root: routeFromParent {name: "+b+"}"),this.comm().receiveFromParent(b,c)},routeFromWidget:function(b,c,d){a.log("root: routeFromWidget {name: "+b+"}"),this.comm().receiveFromWidget(b,c,d)},receiveFromParent:function(){},receiveFromWidget:function(){},current:function(){return null},connected:function(a){var b=this.getset("connected",a);return void 0!==a&&b?!0:b}},a.extend(a.Root,a.ObjectPrototype),a.Util={},a.Util.queryString=function(b,c){for(var d,e=/\+/g,f=/([^&=]+)=?([^&]*)/g,g=function(a){return decodeURIComponent(a.replace(e," "))},h=window.location.search.substring(1),i={};d=f.exec(h);){var j=g(d[1]),k=g(d[2]);b?void 0!==i[j]?a.isArray(i[j])?i[j].push(k):i[j]=[i[j],k]:i[j]=k:(c||void 0===i[j])&&(i[j]=k)}return i},a.Action=function(b,c,d){this.__type="Svidget.Action",c=c||{},d=d instanceof a.Widget?d:null;var e=this,f=new function(){this.writable=["binding","enabled","external","description"],this.params=new a.ActionParamCollection([],e),this.name=b,this.description=c.description,this.enabled=c.enabled!==!1,this.binding=c.binding||null,this.external=c.external!==!1,this.widget=d,this.bindingFunc=null};this.setup(f),f.bindingFunc=a.findFunction(f.binding),this.registerBubbleCallback(a.Action.eventTypes,d,d.actionBubble),this.wireCollectionAddRemoveHandlers(f.params,e.paramAdded,e.paramRemoved)},a.Action.prototype={name:function(){var a=this.getPrivate("name");return a},attached:function(){this.getset("widget");return null!=this.widget&&this.widget instanceof a.Widget},enabled:function(a){var b=this.getset("enabled",a);return void 0!==a&&b?(this.trigger("change",{property:"enabled",value:a}),!0):b},description:function(a){var b=this.getset("description",a);return void 0!==a&&b?(this.trigger("change",{property:"description",value:a}),!0):b},external:function(a){var b=this.getset("external",a);return void 0!==a&&b?(this.trigger("change",{property:"external",value:a}),!0):b},binding:function(b){if(void 0!==b){"function"!=typeof b&&(b+="");var c=a.findFunction(b);this.getset("bindingFunc",c)}var d=this.getset("binding",b);return void 0!==b&&d?(this.trigger("change",{property:"binding",value:val}),!0):d},bindingFunc:function(){var b=this.getset("binding"),c=a.findFunction(b);return c},invoke:function(){if(!this.enabled())return!1;var b=this.invocableBindingFunc();if(!b)return!1;var c=this.buildArgumentArray(a.array(arguments)),d=b.apply(null,c);return this.trigger("invoke",{returnValue:d}),!0},invokeApply:function(a){this.invoke.apply(this,a)},invocableBindingFunc:function(){var a=this.bindingFunc();return null==a||"function"!=typeof a?null:a},buildArgumentArray:function(a){var b=[];a=null==a?[]:a;for(var c=this.params(),d=0;d<c.length;d++){var e=c[d],f=void 0;d<a.length&&(f=a[d]),void 0===f&&(f=e.defvalue()),b.push(f)}return b},toArgumentObject:function(a){for(var b={},c=this.params(),d=0;d<c.length;d++){var e=c[d],f=void 0;d<a.length&&(f=a[d]),void 0===f&&(f=e.defvalue()),b[e.name()]=f}return b},params:function(a){var b=this.getset("params");return this.select(b,a)},param:function(a){var b=this.getset("params"),c=this.selectFirst(b,a);return c},addParam:function(a,b){return this.params().add(a,b,this)},removeParam:function(a){return this.params().remove(a)},paramBubble:function(a,b,c){"change"==a&&this.paramChanged(c,b.value)},paramChanged:function(b,c){a.log("action: param changed: "+b.name()),this.trigger("paramchange",c,b)},paramAdded:function(b){a.log("action: param added: "+b.name()),this.trigger("paramadd",b)},paramRemoved:function(b){a.log("action: param removed: "+b.name()),this.trigger("paramremove",b.name())},onchange:function(a,b,c){return this.on("change",a,b,c)},ondeclaredchange:function(b){return this.onchange(null,a.declaredHandlerName,b)},offchange:function(a){this.off("change",a)},offdeclaredchange:function(){return this.offchange(a.declaredHandlerName)},oninvoke:function(a,b,c){return this.on("invoke",a,b,c)},ondeclaredinvoke:function(b){return this.oninvoke(null,a.declaredHandlerName,b)},offinvoke:function(a){return this.off("invoke",a)},offdeclaredinvoke:function(){return this.offinvoke(a.declaredHandlerName)},onparamadd:function(a,b,c){return this.on("paramadd",a,b,c)},ondeclaredparamadd:function(b){return this.onparamadd(null,a.declaredHandlerName,b)},offparamadd:function(a){return this.off("paramadd",a)},offdeclaredparamadd:function(){return this.offparamadd(a.declaredHandlerName)},onparamremove:function(a,b,c){return this.on("paramremove",a,b,c)},ondeclaredparamremove:function(b){return this.onparamremove(null,a.declaredHandlerName,b)},offparamremove:function(a){return this.off("paramremove",a)},offdeclaredparamremove:function(){return this.offparamremove(a.declaredHandlerName)},onparamchange:function(a,b,c){return this.on("paramchange",a,b,c)},ondeclaredparamchange:function(b){return this.onparamchange(null,a.declaredHandlerName,b)},offparamchange:function(a){return this.off("paramchange",a)},offdeclaredparamchange:function(){return this.offparamchange(a.declaredHandlerName)},toTransport:function(){var a={name:this.name(),description:this.description(),external:this.external(),enabled:this.enabled(),params:this.toParamsTransport()};return a},toParamsTransport:function(){var a=this.params(),b=a.select(function(a){return a.toTransport()}).toArray();return b},toString:function(){return'[Svidget.Action { name: "'+this.name()+'" }]'}},a.Action.eventTypes=["invoke","change","paramchange","paramadd","paramremove"],a.Action.optionProperties=["external","binding","enabled","description"],a.Action.allProxyProperties=["name","external","enabled","description"],a.Action.writableProxyProperties=[],a.extend(a.Action,a.ObjectPrototype),a.extend(a.Action,new a.EventPrototype(a.Action.eventTypes)),a.ActionCollection=function(b,c){a.ObjectCollection.apply(this,[b,a.Action]),this.__type="Svidget.ActionCollection";this.parent=c},a.ActionCollection.prototype=new a.ObjectCollection,a.extend(a.ActionCollection,{create:function(b,c,d){if(null==b)return null;if(null!=this.getByName(b))return null;var e=new a.Action(b,c,d);return e}},!0),a.ActionParam=function(b,c,d){this.__type="Svidget.ActionParam",c=c||{},d=d instanceof a.Action?d:null;var e=new function(){this.writable=["type","subtype","description","defvalue"],this.name=b,this.description=c.description,this.type=c.type||"string",this.subtype=c.subtype||null,this.defvalue=c.defvalue,this.parent=d};this.setup(e),this.registerBubbleCallback(a.ActionParam.eventTypes,d,d.paramBubble)},a.ActionParam.prototype={toTransport:function(){var a={name:this.name(),type:this.type(),subtype:this.subtype(),description:this.description()};return a},onchange:function(a,b,c){return this.on("change",a,b,c)},ondeclaredchange:function(b){return this.onchange(null,a.declaredHandlerName,b)},offchange:function(a){this.off("change",a)},offdeclaredchange:function(){return this.offchange(a.declaredHandlerName)},toString:function(){return'[Svidget.ActionParam { name: "'+this.name+'" }]'}},a.ActionParam.eventTypes=["change"],a.ActionParam.optionProperties=["type","subtype","description","defvalue"],a.ActionParam.allProxyProperties=["name","type","subtype","description","defvalue"],a.ActionParam.writableProxyProperties=[],a.extend(a.ActionParam,a.ObjectPrototype),a.extend(a.ActionParam,a.ParamPrototype),a.extend(a.ActionParam,new a.EventPrototype(a.ActionParam.eventTypes)),a.ActionParamCollection=function(b,c){a.ObjectCollection.apply(this,[b,a.ActionParam]),this.__type="Svidget.ActionParamCollection";this.parent=c},a.ActionParamCollection.prototype=new a.ObjectCollection,a.extend(a.ActionParamCollection,{create:function(b,c,d){if(null==b)return null;if(null!=this.getByName(b))return null;var e=new a.ActionParam(b,c,d);return e}},!0),a.EventDesc=function(b,c,d){this.__type="Svidget.EventDesc",c=c||{},d=d instanceof a.Widget?d:null;var e=this,f=new function(){this.writable=["description","enabled","external"],this.name=b,this.description=c.description,this.external=c.external!==!1,this.enabled=c.enabled!==!1,this.eventName="trigger",this.eventContainer=new a.EventContainer([this.eventName],e)};this.setup(f),f.eventContainer.registerBubbleCallback(a.EventDesc.eventTypes,d,d.eventBubble)},a.EventDesc.prototype={name:function(){var a=this.getPrivate("name");return a},attached:function(){this.getset("widget");return null!=this.widget&&this.widget instanceof a.Widget},enabled:function(a){var b=this.getset("enabled",a);return void 0!==a&&b?(this.trigger("change",{property:"enabled",value:a}),!0):b},description:function(a){var b=this.getset("description",a);return void 0!==a&&b?(this.trigger("change",{property:"description",value:a}),!0):b},external:function(a){var b=this.getset("external",a);return void 0!==a&&b?(this.trigger("change",{property:"public",value:a}),!0):b},eventName:function(){return this.getPrivate("eventName")},eventContainer:function(){return this.getset("eventContainer")},on:function(b,c,d,e){a.isFunction(b)&&(e=b,b=this.eventName()),this.eventContainer().on(b,c,d,e)
},ontrigger:function(a,b,c){this.eventContainer().on(this.eventName(),a,b,c)},ondeclaredtrigger:function(b){return this.ontrigger(null,a.declaredHandlerName,b)},off:function(b,c){a.isFunction(b)&&(c=b,b=this.eventName()),this.eventContainer().off(b,c)},offtrigger:function(a){this.eventContainer().off(this.eventName(),a)},offdeclaredtrigger:function(){return this.offtrigger(a.declaredHandlerName)},onchange:function(a,b,c){return this.on("change",a,b,c)},ondeclaredchange:function(b){return this.onchange(null,a.declaredHandlerName,b)},offchange:function(a){this.off("change",a)},offdeclaredchange:function(){return this.offchange(a.declaredHandlerName)},trigger:function(a,b){this.enabled()&&(void 0===b&&(b=a,a=this.eventName()),this.eventContainer().trigger(a,b))},triggerEvent:function(a){this.trigger(this.eventName(),a)},toTransport:function(){var a={name:this.name(),description:this.description(),external:this.external(),enabled:this.enabled()};return a},toString:function(){return'[Svidget.EventDesc { name: "'+this.name+'" }]'}},a.EventDesc.eventTypes=["trigger","change"],a.EventDesc.optionProperties=["external","enabled","description"],a.EventDesc.allProxyProperties=["name","external","enabled","description","eventContainer"],a.EventDesc.writableProxyProperties=[],a.extend(a.EventDesc,a.ObjectPrototype),a.EventDescCollection=function(b,c){a.ObjectCollection.apply(this,[b,a.EventDesc]),this.__type="Svidget.EventDescCollection";this.parent=c},a.EventDescCollection.prototype=new a.ObjectCollection,a.extend(a.EventDescCollection,{create:function(b,c,d){if(null==b)return null;if(null!=this.getByName(b))return null;var e=new a.EventDesc(b,c,d);return e}},!0),a.Param=function(b,c,d,e){this.__type="Svidget.Param",d=d||{},e=e instanceof a.Widget?e:null;var f=new function(){this.writable=["binding","enabled","type","subtype","value","description","defvalue","typedata","coerce"],this.name=b,this.shortname=d.shortname,this.description=d.description,this.enabled=d.enabled!==!1,this.type=d.type||"string",this.subtype=d.subtype||null,this.typedata=d.typedata||null,this.value=c,this.defvalue=d.defvalue,this.sanitizer=d.sanitizer||null,this.coerce=!!d.coerce,this.widget=e,this.binding=d.binding||null,this.bindingQuery=null};this.setup(f),f.bindingQuery=a.DOM.select(f.binding),f.sanitizerFunc=a.findFunction(f.sanitizer),this.valuePopulated=!1,this.registerBubbleCallback(a.Param.eventTypes,e,e.paramBubble)},a.Param.prototype={shortname:function(){var a=this.getPrivate("shortname");return a},attached:function(){this.getset("widget");return null!=this.widget&&this.widget instanceof a.Widget},enabled:function(a){var b=this.getset("enabled",a);return void 0!==a&&b?(this.trigger("change",{property:"enabled",value:a}),!0):b},value:function(a){var b=this.getset("value",a,this.validateValue);if(void 0===a||!b)return b;if(!this.enabled())return!1;var c=a;return this.getset("coerce")===!0&&(c=this.coerceValue(c)),c=this.applySanitizer(c),this.setPrivate("value",c),this.applyBinding(c),this.trigger("valuechange",{value:c}),this.trigger("set",{value:c}),!0},coerce:function(a){var b=this.getset("coerce",a);return void 0!==a&&b?(this.trigger("change",{property:"coerce",value:a}),!0):b},binding:function(b){b=void 0!==b?b+"":void 0;var c=this.getset("binding",b);return void 0!==b&&c?(this.getset("bindingQuery",a.DOM.select(b)),this.trigger("change",{property:"binding",value:b}),!0):c},bindingQuery:function(){return this.getset("bindingQuery")},sanitizer:function(b){if(void 0!==b){"function"!=typeof b&&(b+="");var c=a.findFunction(b);this.getset("sanitizerFunc",c)}var d=this.getset("sanitizer",b);return void 0!==bind&&d?(this.trigger("change",{property:"sanitizer",value:val}),!0):d},sanitizerFunc:function(){var b=this.getset("sanitizer"),c=a.findFunction(b);return c},applySanitizer:function(a){var b=this.sanitizerFunc();if(!b)return a;var c=b.call(null,this,a);return void 0===c?a:c},validateValue:function(){return!0},coerceValue:function(b){return a.convert(b,this.type(),this.subtype(),this.typedata())},applyBinding:function(a){var b=this.bindingQuery();null!=b&&b.setValue(a)},onchange:function(a,b,c){return this.on("change",a,b,c)},ondeclaredchange:function(b){return this.onchange(null,a.declaredHandlerName,b)},offchange:function(a){this.off("change",a)},offdeclaredchange:function(){return this.offchange(a.declaredHandlerName)},onset:function(a,b,c){return this.on("set",a,b,c)},ondeclaredset:function(b){return this.onset(null,a.declaredHandlerName,b)},offset:function(a){return this.off("set",a)},offdeclaredset:function(){return this.offset(a.declaredHandlerName)},toTransport:function(){var a={name:this.name(),shortname:this.shortname(),enabled:this.enabled(),type:this.type(),subtype:this.subtype(),value:this.value()};return a},toString:function(){return'[Svidget.Param { name: "'+this.name+'" }]'}},a.Param.eventTypes=["valuechange","change"],a.Param.optionProperties=["type","subtype","binding","sanitizer","enabled","shortname","defvalue","typedata","coerce"],a.Param.allProxyProperties=["name","value","type","subtype","enabled","shortname","defvalue","typedata","coerce"],a.Param.writableProxyProperties=["value"],a.extend(a.Param,a.ObjectPrototype),a.extend(a.Param,a.ParamPrototype),a.extend(a.Param,new a.EventPrototype(a.Param.eventTypes)),a.ParamCollection=function(b,c){a.ObjectCollection.apply(this,[b,a.Param]),this.__type="Svidget.ParamCollection";this.parent=c},a.ParamCollection.prototype=new a.ObjectCollection,a.extend(a.ParamCollection,{create:function(b,c,d,e){if(null==b)return null;if(null!=this.getByName(b))return null;var f=new a.Param(b,c,d,e);return f}},!0),a.Widget=function(){this.__type="Svidget.Widget";var b=this,c=new function(){this.writable=["id","enabled","started","connected","populatedFromPage"],this.params=new a.ParamCollection([],b),this.actions=new a.ActionCollection([],b),this.events=new a.EventDescCollection([],b),this.enabled=!0,this.connected=!1,this.started=!1,this.populatedFromPage=!1,this.id=null,this.page=null,this.parentElement=null};this.setup(c),this.wireCollectionAddRemoveHandlers(c.params,b.paramAdded,b.paramRemoved),this.wireCollectionAddRemoveHandlers(c.actions,b.actionAdded,b.actionRemoved),this.wireCollectionAddRemoveHandlers(c.events,b.eventAdded,b.eventRemoved),this._init()},a.Widget.prototype={_init:function(){},start:function(){this.getset("started",!0)},connect:function(a){this.connected()||(this.getset("id",a),this.getset("connected",!0))},setPopulatedFromPage:function(){this.getset("populatedFromPage",!0),this.trigger("pagepopulate",this)},updateParentElement:function(){},params:function(a){var b=this.getset("params");return this.select(b,a)},param:function(a){var b=this.getset("params"),c=this.selectFirst(b,a);return c},addParam:function(a,b,c){return this.params().add(a,b,c,this)},removeParam:function(a){return this.params().remove(a)},paramAdded:function(b){a.log("widget: param added: "+b.name()),this.trigger("paramadd",b),svidget.signalParamAdded(b)},paramRemoved:function(b){a.log("widget: param removed: "+b.name()),this.trigger("paramremove",b.name()),svidget.signalParamRemoved(b.name())},paramBubble:function(a,b,c){"change"==a&&this.paramChanged(c,b.value),("valuechange"==a||"set"==a)&&this.paramSet(c,b.value)},paramChanged:function(a,b){this.trigger("paramchange",b,a),svidget.signalParamChanged(a,b)},paramSet:function(a,b){this.trigger("paramset",b,a),this.trigger("paramvaluechange",b,a),svidget.signalParamSet(a,b)},actions:function(a){var b=this.getset("actions");return this.select(b,a)},action:function(a){var b=this.getset("actions"),c=this.selectFirst(b,a);return c},addAction:function(b,c){var d=this.actions().add(b,c,this);if(null==d)return d;if(null==c||null==c.params||!a.isArray(c.params))return d;for(var e=0;e<c.params.length;e++){var f=c.params[e];null!=f&&null!=f.name&&d.addParam(f.name,f)}},removeAction:function(a){return this.actions().remove(a)},actionAdded:function(b){a.log("widget: action added: "+b.name()),this.trigger("actionadd",b),svidget.signalActionAdded(b)},actionRemoved:function(b){a.log("widget: action removed: "+b.name()),this.trigger("actionremove",b.name()),svidget.signalActionRemoved(b.name())},actionBubble:function(a,b,c){"invoke"==a&&this.actionInvoked(c,b.value),"change"==a&&this.actionChanged(c,b.value),"paramchange"==a&&this.actionParamChanged(c,b.target,b.value),"paramadd"==a&&this.actionParamAdded(c,b.value),"paramremove"==a&&this.actionParamRemoved(c,b.value)},actionInvoked:function(a,b){this.trigger("actioninvoke",b,a),svidget.signalActionInvoked(a,b)},actionChanged:function(a,b){this.trigger("actionchange",b,a),svidget.signalActionChanged(a,b)},actionParamChanged:function(a,b,c){this.trigger("actionparamchange",c,b),svidget.signalActionParamChanged(b,a,c)},actionParamAdded:function(a,b){this.trigger("actionparamadd",b,a),svidget.signalActionParamAdded(b,a.name())},actionParamRemoved:function(a,b){this.trigger("actionparamremove",b,a),svidget.signalActionParamRemoved(b,a.name())},events:function(a){var b=this.getset("events");return this.select(b,a)},event:function(a){var b=this.getset("events"),c=this.selectFirst(b,a);return c},addEvent:function(a,b){return this.events().add(a,b,this)},removeEvent:function(a){return this.events().remove(a)},eventAdded:function(b){a.log("widget: event added: "+b.name()),this.trigger("eventadd",b),svidget.signalEventAdded(b)},eventRemoved:function(b){a.log("widget: event removed: "+b.name()),this.trigger("eventremove",b.name()),svidget.signalEventRemoved(b.name())},eventBubble:function(a,b,c){"trigger"==a&&this.eventTrigger(c,b),"change"==a&&this.eventChanged(c,b.value)},eventTrigger:function(b,c){a.log("widget: event trigger: "+b.name()),this.trigger("eventtrigger",c.value,b),svidget.signalEventTriggered(c.target,c.value)},eventChanged:function(a,b){this.trigger("eventchange",b,a),svidget.signalEventChanged(a,b)},id:function(){return this.getset("id")},enabled:function(a){var b=this.getset("enabled",a);return void 0!==a&&b?(this.trigger&&this.trigger("change",{property:"enabled",value:a}),!0):b},connected:function(){return this.getset("connected")},started:function(){var a=this.getset("started");return a},populatedFromPage:function(){return this.getset("populatedFromPage")},toTransport:function(){var a={id:this.id(),enabled:this.enabled(),params:this.toParamsTransport(),actions:this.toActionsTransport(),events:this.toEventsTransport()};return a},toParamsTransport:function(){var a=this.params(),b=a.select(function(a){return a.toTransport()}).toArray();return b},toActionsTransport:function(){var a=this.actions(),b=a.select(function(a){return a.toTransport()}).toArray();return b},toEventsTransport:function(){var a=this.events(),b=a.select(function(a){return a.toTransport()}).toArray();return b},onparamadd:function(a,b,c){return this.on("paramadd",a,b,c)},ondeclaredparamadd:function(b){return this.onparamadd(null,a.declaredHandlerName,b)},offparamadd:function(a){return this.off("paramadd",a)},offdeclaredparamadd:function(){return this.offparamadd(a.declaredHandlerName)},onparamremove:function(a,b,c){return this.on("paramremove",a,b,c)},ondeclaredparamremove:function(b){return this.onparamremove(null,a.declaredHandlerName,b)},offparamremove:function(a){return this.off("paramremove",a)},offdeclaredparamremove:function(){return this.offparamremove(a.declaredHandlerName)},onparamchange:function(a,b,c){return this.on("paramchange",a,b,c)},offparamchange:function(a){return this.off("paramchange",a)},onparamset:function(a,b,c){return this.on("paramset",a,b,c)},offparamset:function(a){return this.off("paramset",a)},onactionadd:function(a,b,c){return this.on("actionadd",a,b,c)},ondeclaredactionadd:function(b){return this.onactionadd(null,a.declaredHandlerName,b)},offactionadd:function(a){return this.off("actionadd",a)},offdeclaredactionadd:function(){return this.offactionadd(a.declaredHandlerName)},onactionremove:function(a,b,c){return this.on("actionremove",a,b,c)},ondeclaredactionremove:function(b){return this.onactionremove(null,a.declaredHandlerName,b)},offactionremove:function(a){return this.off("actionremove",a)},offdeclaredactionremove:function(){return this.offactionremove(a.declaredHandlerName)},onactionchange:function(a,b,c){return this.on("actionchange",a,b,c)},offactionchange:function(a){return this.off("actionchange",a)},onactioninvoke:function(a,b,c){return this.on("actioninvoke",a,b,c)},offactioninvoke:function(a){return this.off("actioninvoke",a)},oneventadd:function(a,b,c){return this.on("eventadd",a,b,c)},ondeclaredeventadd:function(b){return this.oneventadd(null,a.declaredHandlerName,b)},offeventadd:function(a){return this.off("eventadd",a)},offdeclaredeventadd:function(){return this.offeventadd(a.declaredHandlerName)},oneventremove:function(a,b,c){return this.on("eventremove",a,b,c)},ondeclaredeventremove:function(b){return this.oneventremove(null,a.declaredHandlerName,b)},offeventremove:function(a){return this.off("eventremove",a)},offdeclaredeventremove:function(){return this.offeventremove(a.declaredHandlerName)},oneventchange:function(a,b,c){return this.on("eventchange",a,b,c)},offeventchange:function(a){return this.off("eventchange",a)},oneventtrigger:function(a,b,c){return this.on("eventtrigger",a,b,c)},offeventtrigger:function(a){return this.off("eventtrigger",a)},onpagepopulate:function(a,b,c){return this.on("pagepopulate",a,b,c)},offpagepopulate:function(a){return this.off("pagepopulate",a)},toString:function(){return'[Svidget.Widget { id: "'+this.id()+'" }]'}},a.Widget.eventTypes=["change","pagepopulate","paramvaluechange","paramchange","paramadd","paramremove","actioninvoke","actionchange","actionadd","actionremove","eventtrigger","eventadd","eventremove"],a.extend(a.Widget,a.ObjectPrototype),a.extend(a.Widget,new a.EventPrototype(a.Widget.eventTypes)),a.Proxy=function(b,c,d,e,f){function g(a){return function(b){return this.getsetProp(a,b)}}this.__type="Svidget.Proxy";var h=this;c=c||{};var i=new a.Collection(a.isArray(d)?d:null),j=new a.Collection(a.isArray(e)?e:null);j=j.where(function(a){return i.contains(a)});var k={writable:j.toArray(),propertyChangeFuncs:new a.Collection,eventContainer:new a.EventContainer(f,h),parent:b,connected:null==c.connected?!0:!!c.connected};this.setup(k);for(var l in c)void 0===k[l]&&(k[l]=c[l]);for(var m=0;m<i.length;m++){var n=i[m]+"";n.length>0&&(this[n]=g(n))}},a.Proxy.prototype={parent:function(){var a=this.getPrivate("parent");return a},propertyChangeFuncs:function(){return this.getPrivate("propertyChangeFuncs")},connected:function(){return this.getPrivate("connected")},getsetProp:function(a,b){var c=this.getset(a,b);return void 0!==b&&c?(this.handlePropertyChange(a,b),!0):c},handlePropertyChange:function(){},triggerPropertyChange:function(a,b){var c=this.propertyChangeFuncs(),d=this;c.each(function(c){c(d,a,b)})},notifyPropertyChange:function(a,b){null!=a&&(this.getset(a,b),this.triggerFromWidget("change",{property:a,value:b},this))},refreshProperties:function(a){for(var b in a){var c=this.getPrivate(b);null!=c&&this.setPrivate(b,a[b])}},connect:function(){this.setPrivate("connected",!0)},onPropertyChange:function(a){var b=this.propertyChangeFuncs();return b.add(a),!0},offPropertyChange:function(a){var b=this.propertyChangeFuncs();return b.remove(a)},eventContainer:function(){return this.getPrivate("eventContainer")},on:function(a,b,c,d){this.eventContainer().on(a,b,c,d)},off:function(a,b){this.eventContainer().off(a,b)},triggerFromWidget:function(a,b,c){this.eventContainer().trigger(a,b,c)},registerBubbleCallback:function(a,b,c){this.eventContainer().registerBubbleCallback(a,b,c)}},a.extend(a.Proxy,a.ObjectPrototype),a.ActionProxy=function(b,c,d){var e=this,f={name:b,params:new a.ActionParamProxyCollection([],e)};c=c||{};for(var g in c)void 0===f[g]&&(f[g]=c[g]);d&&(d=d instanceof a.WidgetReference?d:null),a.Proxy.apply(this,[d,f,a.Action.allProxyProperties,a.Action.writableProxyProperties]),this.__type="Svidget.ActionProxy",this.registerBubbleCallback(a.Action.eventTypes,d,d.actionProxyBubble),this.wireCollectionAddRemoveHandlers(f.params,e.paramAdded,e.paramRemoved)},a.ActionProxy.prototype=new a.Proxy,a.extend(a.ActionProxy,{invoke:function(){if(!this.canInvoke())return!1;var b=a.array(arguments);return svidget.signalActionInvoke(this.parent(),this,b),!0},canInvoke:function(){return this.getset("external")},invokeFromWidget:function(a){this.triggerFromWidget("invoke",{returnValue:a},this)},params:function(a){var b=this.getset("params");return this.select(b,a)},param:function(a){var b=this.getset("params"),c=this.selectFirst(b,a);return c},addParam:function(a,b){return this.params().add(a,b,this)},removeParam:function(a){return this.params().remove(a)},paramProxyBubble:function(a,b,c){"change"==a&&this.paramChanged(c,b.value)},paramChanged:function(a,b){this.triggerFromWidget("paramchange",b,a)},paramAdded:function(a){this.triggerFromWidget("paramadd",a)},paramRemoved:function(a){this.triggerFromWidget("paramremove",a.name())},onchange:function(a,b,c){return this.on("change",a,b,c)},offchange:function(a){this.off("change",a)},oninvoke:function(a,b,c){return this.on("invoke",a,b,c)},offinvoke:function(a){return this.off("invoke",a)},toString:function(){return'[Svidget.ActionProxy { name: "'+this.name+'" }]'}},!0),a.ActionProxyCollection=function(b,c){a.ObjectCollection.apply(this,[b,a.ActionProxy]),this.__type="Svidget.ActionProxyCollection";this.parent=c},a.ActionProxyCollection.prototype=new a.ObjectCollection,a.extend(a.ActionProxyCollection,{create:function(b,c,d){if(null==b)return null;if(null!=this.getByName(b))return null;var e=new a.ActionProxy(b,c,d);return e}},!0),a.ActionParamProxy=function(b,c,d){var e={name:b};c=c||{};for(var f in c)void 0===e[f]&&(e[f]=c[f]);d&&(d=d instanceof a.ActionProxy?d:null),a.Proxy.apply(this,[d,e,a.ActionParam.allProxyProperties,a.ActionParam.writableProxyProperties]),this.__type="Svidget.ActionParamProxy",this.registerBubbleCallback(a.ActionParam.eventTypes,d,d.paramProxyBubble)},a.ActionParamProxy.prototype=new a.Proxy,a.extend(a.ActionParamProxy,{toString:function(){return'[Svidget.ActionParamProxy { name: "'+this.name+'" }]'}},!0),a.ActionParamProxyCollection=function(b,c){a.ObjectCollection.apply(this,[b,a.ActionParamProxy]),this.__type="Svidget.ActionParamProxyCollection";this.parent=c},a.ActionParamProxyCollection.prototype=new a.ObjectCollection,a.extend(a.ActionParamProxyCollection,{create:function(b,c,d){if(null==b)return null;if(null!=this.getByName(b))return null;var e=new a.ActionParamProxy(b,c,d);return e}},!0),a.EventDescProxy=function(b,c,d){var e="trigger",f={name:b,eventName:e};c=c||{};for(var g in c)void 0===f[g]&&(f[g]=c[g]);d&&(d=d instanceof a.WidgetReference?d:null),a.Proxy.apply(this,[d,f,a.EventDesc.allProxyProperties,a.EventDesc.writableProxyProperties]),this.__type="Svidget.EventDescProxy",this.registerBubbleCallback(a.EventDesc.eventTypes,d,d.eventProxyBubble)},a.EventDescProxy.prototype=new a.Proxy,a.extend(a.EventDescProxy,{triggerEventName:function(){return this.getPrivate("eventName")},on:function(b,c,d,e){a.isFunction(b)&&(e=b,b=this.triggerEventName()),this.eventContainer().on(b,c,d,e)},ontrigger:function(a,b,c){this.eventContainer().on(this.eventName(),a,b,c)},off:function(b,c){a.isFunction(b)&&(c=b,b=this.triggerEventName()),this.eventContainer().off(b,c)},offtrigger:function(a){this.eventContainer().off(this.eventName(),a)},onchange:function(a,b,c){return this.on("change",a,b,c)},offchange:function(a){this.off("change",a)},trigger:function(a){return this.canTrigger()?(svidget.signalEventTrigger(this.parent(),this,a),!0):!1},canTrigger:function(){return this.getset("external")},triggerEventFromWidget:function(a){this.eventContainer().trigger(this.triggerEventName(),a)},toString:function(){return'[Svidget.EventDescProxy { name: "'+this.name+'" }]'}},!0),a.EventDescProxyCollection=function(b,c){a.ObjectCollection.apply(this,[b,a.EventDescProxy]),this.__type="Svidget.EventDescProxyCollection";this.parent=c},a.EventDescProxyCollection.prototype=new a.ObjectCollection,a.extend(a.EventDescProxyCollection,{create:function(b,c,d){if(null==b)return null;if(null!=this.getByName(b))return null;var e=new a.EventDescProxy(b,c,d);return e}},!0),a.ParamProxy=function(b,c,d,e){var f={name:b,value:c};d=d||{};for(var g in d)f[g]=d[g];e&&(e=e instanceof a.WidgetReference?e:null),a.Proxy.apply(this,[e,f,a.Param.allProxyProperties,a.Param.writableProxyProperties]),this.__type="Svidget.ParamProxy",this.registerBubbleCallback(a.Param.eventTypes,e,e.paramProxyBubble)},a.ParamProxy.prototype=new a.Proxy,a.extend(a.ParamProxy,{handlePropertyChange:function(a,b){"value"==a&&svidget.signalPropertyChange(this.parent(),this,"param",a,b)},notifyValueChange:function(a){this.getset("value",a),this.triggerFromWidget("valuechange",{value:a},this),this.triggerFromWidget("set",{value:a},this)},onchange:function(a,b,c){return this.on("change",a,b,c)},offchange:function(a){this.off("change",a)},onset:function(a,b,c){return this.on("set",a,b,c)},offset:function(a){return this.off("set",a)},toString:function(){return'[Svidget.ParamProxy { name: "'+this.name+'" }]'}},!0),a.ParamProxyCollection=function(b,c){a.ObjectCollection.apply(this,[b,a.ParamProxy]),this.__type="Svidget.ParamProxyCollection";this.parent=c},a.ParamProxyCollection.prototype=new a.ObjectCollection,a.extend(a.ParamProxyCollection,{create:function(b,c,d,e){if(null==b)return null;if(null!=this.getByName(b))return null;var f=new a.ParamProxy(b,c,d,e);return f}},!0),a.WidgetReference=function(b,c,d,e,f,g){function h(a){if(null!=a)for(var b in a)this.addParamProxy(b,a[b],{connected:!1})}this.__type="Svidget.WidgetReference";var i=this,j=new function(){this.writable=["enabled","started","populated"],this.params=new a.ParamProxyCollection([],i),this.actions=new a.ActionProxyCollection([],i),this.events=new a.EventDescProxyCollection([],i),this.eventContainer=new a.EventContainer(a.Widget.eventTypes,i),this.paramValues=c,this.enabled=!0,this.started=!1,this.populated=!1,this.connected=!!f,this.crossdomain=!!g,this.state="declared",this.id=b,this.element=e,this.declaringElement=d,this.url=d.getAttribute("data")};this.setup(j),this.setElement=function(b){return null!=j.element?!1:a.DOM.isElement(b)?(j.element=b,void(this.setElement=null)):!1},h.call(i,c),d.widgetReference=this,this.wireCollectionAddRemoveHandlers(j.params,i.paramProxyAdded,i.paramProxyRemoved),this.wireCollectionAddRemoveHandlers(j.actions,i.actionProxyAdded,i.actionProxyRemoved),this.wireCollectionAddRemoveHandlers(j.events,i.eventProxyAdded,i.eventProxyRemoved)},a.WidgetReference.prototype={id:function(){var a=this.getset("id");return a},name:function(){return this.id()},enabled:function(){var a=this.getset("enabled");return a},url:function(){var a=this.getset("url");return a},element:function(){var a=this.getset("element");return a},declaringElement:function(){var a=this.getset("declaringElement");return a},root:function(){if(this.isCrossDomain())return null;var a=this.document(),b=a.parentWindow||a.defaultView;return b.svidget},window:function(){var a=this.element();return null==a?null:a.contentWindow},document:function(){var b=this.element();return a.DOM.getDocument(b)},connected:function(a){var b=this.getset("connected",a);return void 0!==a&&b?!0:b},crossdomain:function(a){var b=this.getset("crossdomain",a);return void 0!==a&&b?!0:b},params:function(a){var b=this.getset("params");return this.select(b,a)},param:function(a){var b=this.getset("params"),c=this.selectFirst(b,a);return c},actions:function(a){var b=this.getset("actions");return this.select(b,a)},action:function(a){var b=this.getset("actions"),c=this.selectFirst(b,a);return c},events:function(a){var b=this.getset("events");return this.select(b,a)},event:function(a){var b=this.getset("events"),c=this.selectFirst(b,a);return c},paramValues:function(){var a=this.getset("paramValues");return a},addParamProxy:function(a,b,c){return this.params().add(a,b,c,this)},removeParamProxy:function(a){return this.params().remove(a)},refreshParamProxy:function(a,b,c){var d=this.param(a);return null==d?this.params().add(a,b,c,this):(d.refreshProperties(c),d)},paramProxyAdded:function(b){a.log("page: param proxy added: "+b.name()),this.triggerFromWidget("paramadd",b)},paramProxyRemoved:function(b){a.log("page: param proxy removed: "+b.name()),this.triggerFromWidget("paramremove",b.name())},paramProxyBubble:function(b,c,d){a.log("page: param proxy bubble: "+d.name()),"change"==b&&this.paramProxyChanged(d,c.value),"valuechange"==b&&this.paramProxyValueChanged(d,c.value)},paramProxyChanged:function(b,c){a.log("page: param proxy change: "+b.name()),this.triggerFromWidget("paramchange",c,b)},paramProxyValueChanged:function(b,c){a.log("page: param proxy value change: "+b.name()),this.triggerFromWidget("paramvaluechange",c,b)},addActionProxy:function(a,b){return this.actions().add(a,b,this)},removeActionProxy:function(a){return this.actions().remove(a)},actionProxyAdded:function(b){a.log("page: action proxy added: "+b.name()),this.triggerFromWidget("actionadd",b)},actionProxyRemoved:function(b){a.log("page: action proxy removed: "+b.name()),this.triggerFromWidget("actionremove",b.name())},actionProxyBubble:function(b,c,d){a.log("page: action proxy bubble: "+d.name()),"invoke"==b&&this.actionProxyInvoked(d,c.value),"change"==b&&this.actionProxyChanged(d,c.value),"paramchange"==b&&this.actionParamProxyChanged(d,c.target,c.value),"paramadd"==b&&this.actionParamProxyAdded(d,c.value),"paramremove"==b&&this.actionParamProxyRemoved(d,c.value)},actionProxyInvoked:function(a,b){this.triggerFromWidget("actioninvoke",b,a)},actionProxyChanged:function(a,b){this.triggerFromWidget("actionchange",b,a)},actionParamProxyAdded:function(a,b){this.triggerFromWidget("actionparamadd",b,a)},actionParamProxyRemoved:function(a,b){this.triggerFromWidget("actionparamremove",b,a)},actionParamProxyChanged:function(a,b,c){this.triggerFromWidget("actionparamchange",c,b)},addEventProxy:function(a,b){return this.events().add(a,b,this)},removeEventProxy:function(a){return this.events().remove(a)},eventProxyAdded:function(b){a.log("page: event proxy added: "+b.name()),this.triggerFromWidget("eventadd",b)},eventProxyRemoved:function(b){a.log("page: event proxy removed: "+b.name()),this.triggerFromWidget("eventremove",b.name())},eventProxyBubble:function(b,c,d){a.log("page: event proxy bubble: "+d.name()),"trigger"==b&&this.eventProxyTriggered(d,c),"change"==b&&this.eventProxyChanged(d,c.value)},eventProxyTriggered:function(b,c){a.log("page: event proxy trigger: "+b.name()),this.triggerFromWidget("eventtrigger",c.value,b)},eventProxyChanged:function(b,c){a.log("page: event proxy change: "+b.name()),this.triggerFromWidget("eventchange",c,b)},eventContainer:function(){return this.getPrivate("eventContainer")},on:function(a,b,c,d){this.eventContainer().on(a,b,c,d)},off:function(a,b){this.eventContainer().off(a,b)},triggerFromWidget:function(a,b,c){this.eventContainer().trigger(a,b,c)},hasElement:function(){return null!=this.element()},isAttached:function(){var a=this.element();return null!=a&&null!=a.parentNode},isCrossDomain:function(){return this.element()!==this.declaringElement()},started:function(){var a=this.getset("started");return a},populated:function(){var a=this.getset("populated");return a},start:function(){this.getset("started",!0)},populate:function(a){this.populated()||(this.enabled(a.enabled),this._populateParams(a.params),this._populateActions(a.actions),this._populateEvents(a.events),this.getset("populated",!0))},_populateParams:function(b){if(b&&a.isArray(b))for(var c=0;c<b.length;c++){var d=b[c],e=this.refreshParamProxy(d.name,d.value,d);e.connect()}},_populateActions:function(b){if(b&&a.isArray(b))for(var c=0;c<b.length;c++){var d=b[c],e=this.addActionProxy(d.name,d);this._populateActionParams(d.params,e)}},_populateActionParams:function(b,c){if(b&&a.isArray(b))for(var d=0;d<b.length;d++){var e=b[d];c.addParam(e.name,e)}},_populateEvents:function(b){if(b&&a.isArray(b))for(var c=0;c<b.length;c++){var d=b[c];this.addEventProxy(d.name,d)}}},a.extend(a.WidgetReference,a.ObjectPrototype),a.Root.PagePrototype={initInternal:function(){this.idSeed=1,window._svidget="page",this.connected(!0),Object.defineProperty(this,"$",a.readOnlyProperty(null))},readyPage:function(){a.log("page: readyPage"),this.loadPageWidgets()},loadPageWidgets:function(){var a=this,b=this.findAllWidgetElements();b.each(function(b){a.loadPageWidget(b)})},loadPageWidget:function(a,b){var c=this.createWidgetReference(a,b);return this.addWidget(c),this.readyWidgetReference(c,a),c},createWidgetReference:function(b,c){var d;d=void 0===c?this.parseParamElements(b):c;var e="false"!=b.getAttribute("data-connected"),f="true"==b.getAttribute("data-crossdomain"),g=this.getWidgetIDForElement(b),h=this.resolveCoreWidgetElement(b,null,f),i=new a.WidgetReference(g,d,b,h,e,f);return i},readyWidgetReference:function(a,b){var c=a.element()||b;this.addWidgetLoadEvents(c,a)},addWidgetLoadEvents:function(b,c){a.log("page: addWidgetLoadEvents: id = "+b.id+", tag = "+b.tagName);var d=a.wrap(this.finishPageWidget,this),e=function(){d(c)};c._waitingForDOM=!0,a.DOM.on(b,"load",e)},finishPageWidget:function(b){a.log("page: finishPageWidget: id = "+b.id()),b._waitingForDOM=!1;var c=this.ensureCoreElementResolved(b);null!=c&&c!=b.declaringElement()?this.readyWidgetReference(b,b.element()):this.ensureWidgetStarted(b)},ensureCoreElementResolved:function(b){if(b.hasElement())return null;var c=this.resolveCoreWidgetElement(b.declaringElement(),b,b.crossdomain());return null!=c?(a.log("page: CoreElementCreated: "+c.tagName+" id:"+b.id()),b.setElement(c),c):null},ensureWidgetStarted:function(b){b.hasElement()&&!b.started()&&a.DOM.isElementDocumentReady(b.element())&&this.signalStart(b,b.paramValues())},resolveCoreWidgetElement:function(b,c,d){var e=a.DOM.getDocument(b);if(null===e&&!d)return null;var f=null,g=b;return(void 0===e||d)&&(f=this.buildIFrameElement(b),b.parentNode.insertBefore(f,b),this.disableAndHide(b),g=f),g},waitForWidgets:function(){setTimeout(a.wrap(this.checkUnfinishedWidgetReferences,this),50)},checkUnfinishedWidgetReferences:function(){if(!this.allWidgetsStarted){a.log("page: checkUnfinishedWidgetReferences");var b=this,c=0;this.widgets().where(function(a){return b.needsFinishing(a)}).each(function(a){c++,b.finishPageWidget(a)}),this.waitForWidgets()}},needsFinishing:function(b){return b._waitingForDOM?!1:b.hasElement()&&b.started()||!a.DOM.isElementDocumentReady(b.declaringElement())?b.hasElement()&&b.isCrossDomain()&&!b.started()&&a.DOM.isElementDocumentReady(b.element())?!0:!1:!0},areAllWidgetsStarted:function(){return this.widgets().all(function(a){return a.started()})},disableAndHide:function(b){b.data="",a.DOM.disable(b),a.DOM.hide(b)},getWidgetIDForElement:function(a){var b=a.id;return null!=b&&document.getElementById(b)==a?b:this.newWidgetID()},newWidgetID:function(){var a="_svidget_";void 0===this.idCounter&&(this.idCounter=1);for(var b,c=this.idCounter;;){var b=a+c;if(c++,null==document.getElementById(b))break}return this.idCounter=c,b},buildIFrameElement:function(b){var c=document.createElement("iframe"),d=a.DOM.wrap(b);return d.attributes().each(function(a){"data"==a.name()?c.setAttribute("src",a.value()):"id"==a.name()?c.setAttribute("id",a.value()+"_frame"):c.setAttribute(a.name(),a.value())}),c},buildObjectElement:function(a,b){var c=document.createElement("object");c.setAttribute("role","svidget"),c.setAttribute("data",a.url),a.id&&c.setAttribute("id",a.id),a.width&&c.setAttribute("width",a.width),a.height&&c.setAttribute("height",a.height),a.standalone&&c.setAttribute("data-standalone",a.standalone),a.crossdomain&&c.setAttribute("data-crossdomain",a.crossdomain);for(var d in b){var e=document.createElement("param");e.setAttribute("name",d)}return c},createObjectElement:function(a,b,c){var d=this.buildObjectElement(b,c);return a.appendChild(d),d},populateWidgetReference:function(b,c){a.log("page: populateWidgetReference"),b.populated()||b.populate(c)
},findAllWidgetElements:function(){var b=a.DOM.getByName("object",!0),c=b.where(function(b){return"svidget"==a.DOM.attrValue(b,"role")});return c},parseParamElements:function(b){for(var c=a.DOM.getChildrenByName(b,"param",!0),d={},e=0;e<c.length;e++){var f=c[e].getAttribute("name");null!=f&&f.length>0&&(d[f]=c[e].getAttribute("value"))}return d},getWidget:function(a){if(null==a)return null;var b=this.widgets();return b.first(function(b){return b.id()===a})},addWidget:function(a){return this.widgets().contains(a)?!1:(this.widgets().add(a),!0)},load:function(b,c,d,e){var f=a.DOM.selectElement(b);if(null==f)return null;var g=null;if("string"==typeof c)g={url:c};else{if(null==c)return null;g=c}if(null!=g.url){this.allWidgetsStarted=!1;var h=this.createObjectElement(f,g,d),i=this.loadPageWidget(h,d);return e&&"function"==typeof e&&e(i),i}},widgets:function(a){var b=this.getWidgets();return this.select(b,a)},widget:function(a){var b=this.getWidgets(),c=this.selectFirst(b,a);return c},getWidgets:function(){var b=this.getset("widgets");return null==b&&(b=new a.ObjectCollection(null,a.WidgetReference),this.getset("widgets",b)),b},triggerWidgetEvent:function(a,b,c){var d=a.event(b);null!=d&&d.triggerFromWidget(c)},receiveFromWidget:function(b,c,d){a.log("page: receiveFromWidget {name: "+b+", widgetID: "+d+"}");var e=this.getWidget(d);switch(b){case"paramadded":this.handleReceiveWidgetParamAdded(e,c);break;case"paramremoved":this.handleReceiveWidgetParamRemoved(e,c);break;case"paramchanged":this.handleReceiveWidgetParamChanged(e,c);break;case"paramvaluechanged":this.handleReceiveWidgetParamValueChanged(e,c);break;case"actionadded":this.handleReceiveWidgetActionAdded(e,c);break;case"actionremoved":this.handleReceiveWidgetActionRemoved(e,c);break;case"actionchanged":this.handleReceiveWidgetActionChanged(e,c);break;case"actioninvoked":this.handleReceiveWidgetActionInvoked(e,c);break;case"actionparamadded":this.handleReceiveWidgetActionParamAdded(e,c);break;case"actionparamremoved":this.handleReceiveWidgetActionParamRemoved(e,c);break;case"actionparamchanged":this.handleReceiveWidgetActionParamChanged(e,c);break;case"eventadded":this.handleReceiveWidgetEventAdded(e,c);break;case"eventremoved":this.handleReceiveWidgetEventRemoved(e,c);break;case"eventchanged":this.handleReceiveWidgetEventChanged(e,c);break;case"eventtriggered":this.handleReceiveWidgetEventTriggered(e,c);break;case"startack":this.handleReceiveWidgetStartAck(e,c)}},signalStart:function(b,c){a.log("page: signalStart {id: "+b.id()+", url: "+b.url()+", tag: "+b.element().tagName+"}");var d={id:b.id(),params:c,connected:b.connected()};this.comm().signalWidget(b,"start",d)},signalPropertyChange:function(b,c,d,e,f){if(b.started()&&b.connected()){a.log("page: signalPropertyChange {id: "+b.id()+", type: "+d+"}");var g={type:d,name:c.name(),propertyName:e,value:f};this.comm().signalWidget(b,"propertychange",g)}},signalActionInvoke:function(b,c,d){if(b.started()&&b.connected()){a.log("page: signalActionInvoke {id: "+b.id()+", url: "+b.url()+"}");var e={action:c.name(),args:d};this.comm().signalWidget(b,"actioninvoke",e)}},signalEventTrigger:function(b,c,d){if(b.started()&&b.connected()){a.log("page: signalEventTrigger {id: "+b.id()+"}");var e={event:c.name(),data:d};this.comm().signalWidget(b,"eventtrigger",e)}},handleReceiveWidgetInitialized:function(){a.log("page: handleReceiveWidgetInitialized")},handleReceiveWidgetLoaded:function(a,b){return null==a?void this.checkUnfinishedWidgetReferences():void this.populateWidgetReference(a,b)},handleReceiveWidgetStartAck:function(b,c){a.log("page: handleReceiveWidgetStartAck {widget: "+b.id()+"}"),b.started()||(b.start(),this.populateWidgetReference(b,c),this.triggerWidgetLoaded(b.id()),this.areAllWidgetsStarted()&&(this.allWidgetsStarted=!0,this.markLoaded()))},handleReceiveWidgetParamAdded:function(b,c){a.log("page: handleReceiveWidgetParamAdded {param: "+c.name+"}"),b.addParamProxy(c.name,c)},handleReceiveWidgetParamRemoved:function(b,c){a.log("page: handleReceiveWidgetParamRemoved {param: "+c+"}"),b.removeParamProxy(c)},handleReceiveWidgetParamChanged:function(b,c){a.log("page: handleReceiveWidgetParamChanged {param: "+c.name+"}");var d=b.param(c.name);null!=d&&d.notifyPropertyChange(c.property,c.value)},handleReceiveWidgetParamSet:function(b,c){a.log("page: handleReceiveWidgetParamSet {param: "+c.name+"}");var d=b.param(c.name);null!=d&&d.notifyValueChange("value",c.value)},handleReceiveWidgetActionAdded:function(b,c){a.log("page: handleReceiveWidgetActionAdded {action: "+c.name+"}"),b.addActionProxy(c.name,c)},handleReceiveWidgetActionRemoved:function(b,c){a.log("page: handleReceiveWidgetActionRemoved {action: "+c+"}"),b.removeActionProxy(c)},handleReceiveWidgetActionChanged:function(b,c){a.log("page: handleReceiveWidgetActionChanged {action: "+c.name+"}");var d=b.action(c.name);null!=d&&d.notifyPropertyChange(c.property,c.value)},handleReceiveWidgetActionInvoked:function(b,c){a.log("page: handleReceiveWidgetActionInvoked {action: "+c.name+"}");var d=b.action(c.name);null!=d&&d.invokeFromWidget(c.returnValue)},handleReceiveWidgetActionParamAdded:function(b,c){a.log("page: handleReceiveWidgetActionParamAdded {actionparam: "+c.name+"}");var d=b.action(c.actionName);null!=d&&d.addParam(c.name,c)},handleReceiveWidgetActionParamRemoved:function(b,c){a.log("page: handleReceiveWidgetActionParamRemoved {actionparam: "+c+"}");var d=b.action(c.actionName);null!=d&&d.removeParam(c.name)},handleReceiveWidgetActionParamChanged:function(b,c){a.log("page: handleReceiveWidgetActionParamChanged {actionparam: "+c.name+"}");var d=b.action(c.actionName);if(null!=d){var e=d.param(c.name);null!=e&&e.notifyPropertyChange(c.property,c.value)}},handleReceiveWidgetEventAdded:function(b,c){a.log("page: handleReceiveWidgetEventAdded {event: "+c.name+"}"),b.addEventProxy(c.name,c)},handleReceiveWidgetEventRemoved:function(b,c){a.log("page: handleReceiveWidgetEventRemoved {event: "+c+"}"),b.removeEventProxy(c)},handleReceiveWidgetEventChanged:function(b,c){a.log("page: handleReceiveWidgetEventChanged {event: "+c.name+"}");var d=b.event(c.name);null!=d&&d.notifyPropertyChange(c.property,c.value)},handleReceiveWidgetEventTriggered:function(b,c){a.log("page: handleReceiveWidgetEventTriggered {event: "+c.name+"}");var d=b.event(c.name);null!=d&&d.triggerEventFromWidget(c.value)}},a.Root.WidgetPrototype={initInternal:function(){this.loadCurrent(),window._svidget="widget"},readyWidget:function(){a.log("widget: readyWidget"),this.startWidget()},loadCurrent:function(){var b=new a.Widget;this.setCurrent(b),this.setCurrent=null,Object.defineProperty(this,"$",a.readOnlyProperty(b))},startWidget:function(){var a=this.current();this.populateObjects(),this.connected()?this.startWidgetConnected(a):this.startWidgetStandalone(a)},startWidgetStandalone:function(a){var b=this.getParamValuesFromQueryString();this.setParamValues(a,b,!0),a.start()},startWidgetConnected:function(a){null!=this.paramValues&&(this.setParamValues(this.paramValues),this.paramValues=null,a.setPopulatedFromPage()),a.start()},populateObjects:function(){var a=this.getParamsElement();this.populateParams(a);var b=this.getActionsElement();this.populateActions(b);var c=this.getEventsElement();this.populateEvents(c)},getParamsElement:function(){return this.getSvidgetElement("params")},getActionsElement:function(){return this.getSvidgetElement("actions")},getEventsElement:function(){return this.getSvidgetElement("events")},getSvidgetElement:function(b){var c=a.DOM.getByNameSvidget(b,!0);return 0==c.length?null:c[0]},populateParams:function(b){if(null!=b){var c=this,d=this.current();this.populateElementObjects(b,function(a,b){var d=c.buildParam(a,b);null!=d&&b.addParam(d)}),this.wireDeclaredHandler(d,d.ondeclaredparamadd,a.DOM.attrValue(b,"onadd")),this.wireDeclaredHandler(d,d.ondeclaredparamremove,a.DOM.attrValue(b,"onremove"))}},buildParam:function(b,c){if(!this.isValidSvidgetElement(b,"param"))return null;var d=a.DOM.attrValue(b,"name");if(null==d)return null;var e=a.DOM.attrValue(b,"value"),f=this.buildOptions(b,a.Param.optionProperties),g=new a.Param(d,e,f,c);return this.wireDeclaredChangeHandler(g,a.DOM.attrValue(b,"onchange")),this.wireDeclaredSetHandler(g,a.DOM.attrValue(b,"onset")),g},populateActions:function(b){if(null!=b){var c=this,d=this.current();this.populateElementObjects(b,function(a,b){var d=c.buildAction(a,b);null!=d&&(b.addAction(d),c.populateActionParams(a,d))}),this.wireDeclaredHandler(d,d.ondeclaredactionadd,a.DOM.attrValue(b,"onadd")),this.wireDeclaredHandler(d,d.ondeclaredactionremove,a.DOM.attrValue(b,"onremove"))}},populateActionParams:function(a,b){if(null!=a){var c=this;this.populateElementObjects(a,function(a){var d=c.buildActionParam(a,b);null!=d&&b.addParam(d)})}},buildAction:function(b,c){if(!this.isValidSvidgetElement(b,"action"))return null;var d=a.DOM.attrValue(b,"name");if(null==d)return null;var e=this.buildOptions(b,a.Action.optionProperties),f=new a.Action(d,e,c);return this.wireDeclaredChangeHandler(f,a.DOM.attrValue(b,"onchange")),this.wireDeclaredInvokeHandler(f,a.DOM.attrValue(b,"oninvoke")),this.wireDeclaredParamAddHandler(f,a.DOM.attrValue(b,"onparamadd")),this.wireDeclaredParamRemoveHandler(f,a.DOM.attrValue(b,"onparamremove")),this.wireDeclaredParamChangeHandler(f,a.DOM.attrValue(b,"onparamchange")),f},buildActionParam:function(b,c){if(!this.isValidSvidgetElement(b,"actionparam"))return null;var d=a.DOM.attrValue(b,"name");if(null==d)return null;var e=this.buildOptions(b,a.ActionParam.optionProperties),f=new a.ActionParam(d,e,c);return this.wireDeclaredChangeHandler(f,a.DOM.attrValue(b,"onchange")),f},populateEvents:function(b){if(null!=b){var c=this,d=this.current();this.populateElementObjects(b,function(a,b){var d=c.buildEvent(a,b);null!=d&&b.addEvent(d)}),this.wireDeclaredHandler(d,d.ondeclaredeventadd,a.DOM.attrValue(b,"onadd")),this.wireDeclaredHandler(d,d.ondeclaredeventremove,a.DOM.attrValue(b,"onremove"))}},buildEvent:function(b,c){if(!this.isValidSvidgetElement(b,"event"))return null;var d=a.DOM.attrValue(b,"name");if(null==d)return null;var e=this.buildOptions(b,a.EventDesc.optionProperties),f=new a.EventDesc(d,e,c);return this.wireDeclaredChangeHandler(f,a.DOM.attrValue(b,"onchange")),this.wireDeclaredTriggerHandler(f,a.DOM.attrValue(b,"ontrigger")),f},populateElementObjects:function(a,b){if(null!=a&&null!=a.childNodes)for(var c=this.current(),d=a.firstElementChild;null!=d;)b&&b(d,c),d=d.nextElementSibling},buildOptions:function(b,c){var d={};if(null==c||!a.isArray(c))return d;for(var e=0;e<c.length;e++){var f=c[e],g=a.DOM.attrValue(b,f);null!=g&&(d[f]=g)}return d},wireDeclaredChangeHandler:function(a,b){this.wireDeclaredHandler(a,a.ondeclaredchange,b)},wireDeclaredSetHandler:function(a,b){this.wireDeclaredHandler(a,a.ondeclaredset,b)},wireDeclaredInvokeHandler:function(a,b){this.wireDeclaredHandler(a,a.ondeclaredinvoke,b)},wireDeclaredTriggerHandler:function(a,b){this.wireDeclaredHandler(a,a.ondeclaredtrigger,b)},wireDeclaredParamAddHandler:function(a,b){this.wireDeclaredHandler(a,a.ondeclaredparamadd,b)},wireDeclaredParamRemoveHandler:function(a,b){this.wireDeclaredHandler(a,a.ondeclaredparamremove,b)},wireDeclaredParamChangeHandler:function(a,b){this.wireDeclaredHandler(a,a.ondeclaredparamchange,b)},wireDeclaredHandler:function(b,c,d){if(null!=c){var e=a.findFunction(d);null!=e&&a.isFunction(e)&&c.call(b,e)}},connectWidget:function(b,c,d){var e=this.current();e.connected()||(d?(a.log("widget: connect {id: "+b+"}"),e.connect(b),this.getset("connected",!0)):a.log("widget: standalone {id: "+b+"}"),this.paramValues=c||{})},startWidgetWithPageParams:function(){var a=this.current();a.started()&&(this.setParamValues(a,this.paramValues),a.setPopulatedFromPage())},getParamValuesFromQueryString:function(){var b=a.Util.queryString();return b},setParamValues:function(a,b,c){var d=a.params();null!=d&&d.each(function(a){var d=c?a.shortname()||a.name():a.name(),e=b[d];void 0===e&&(e=a.defvalue()),void 0!==d&&a.value(e)})},isValidSvidgetElement:function(b,c){return null!=b&&b.localName==c&&b.namespaceURI==a.Namespaces.svidget},current:function(){return this.getset("current")},connected:function(){return this.getset("connected")},receiveFromParent:function(b,c){a.log("widget: receiveFromParent {name: "+b+"}"),"start"==b?this.handleReceiveParentStart(c):"actioninvoke"==b?this.handleReceiveParentActionInvoke(c):"eventtrigger"==b?this.handleReceiveParentEventTrigger(c):"propertychange"==b&&this.handleReceiveParentPropertyChange(c)},signalStartAck:function(){a.log("widget: signalStartAck {id: "+this.current().id()+"}");var b=this.current().toTransport();this.comm().signalParent("startack",b,this.current().id())},signalParamAdded:function(b){if(this.connected()){a.log("widget: signalParamAdded {id: "+this.current().id()+"}");var c=b.toTransport();this.comm().signalParent("paramadded",c,this.current().id())}},signalParamRemoved:function(b){this.connected()&&(a.log("widget: signalParamRemoved {id: "+this.current().id()+"}"),this.comm().signalParent("paramremoved",b,this.current().id()))},signalParamChanged:function(b,c){this.connected()&&(a.log("widget: signalParamChanged {id: "+this.current().id()+"}"),c.name=b.name(),this.comm().signalParent("paramchanged",c,this.current().id()))},signalParamSet:function(b,c){this.connected()&&(a.log("widget: signalParamSet {id: "+this.current().id()+"}"),c.name=b.name(),this.comm().signalParent("paramset",c,this.current().id()))},signalActionAdded:function(b){if(this.connected()){a.log("widget: signalActionAdded {id: "+this.current().id()+"}");var c=b.toTransport();this.comm().signalParent("actionadded",c,this.current().id())}},signalActionRemoved:function(b){this.connected()&&(a.log("widget: signalActionRemoved {id: "+this.current().id()+"}"),this.comm().signalParent("actionremoved",b,this.current().id()))},signalActionChanged:function(b,c){this.connected()&&(a.log("widget: signalActionChanged {id: "+this.current().id()+"}"),c.name=b.name(),this.comm().signalParent("actionchanged",c,this.current().id()))},signalActionInvoked:function(b,c){this.connected()&&(a.log("widget: signalActionInvoked {id: "+this.current().id()+"}"),c.name=b.name(),this.comm().signalParent("actioninvoked",c,this.current().id()))},signalActionParamAdded:function(b,c){if(this.connected()){a.log("widget: signalActionParamAdded {id: "+this.current().id()+"}");var d=b.toTransport();d.actionName=c,this.comm().signalParent("actionparamadded",d,this.current().id())}},signalActionParamRemoved:function(b,c){if(this.connected()){a.log("widget: signalActionParamRemoved {id: "+this.current().id()+"}");var d={name:b,actionName:c};this.comm().signalParent("actionparamremoved",d,this.current().id())}},signalActionParamChanged:function(b,c,d){this.connected()&&(a.log("widget: signalActionParamChanged {id: "+this.current().id()+"}"),d.name=b.name(),d.actionName=c.name(),this.comm().signalParent("actionparamchanged",d,this.current().id()))},signalEventAdded:function(b){if(this.connected()){a.log("widget: signalEventAdded {id: "+this.current().id()+"}");var c=b.toTransport();this.comm().signalParent("eventadded",c,this.current().id())}},signalEventRemoved:function(b){this.connected()&&(a.log("widget: signalEventRemoved {id: "+this.current().id()+"}"),this.comm().signalParent("eventremoved",b,this.current().id()))},signalEventChanged:function(b,c){this.connected()&&(a.log("widget: signalEventChanged {id: "+this.current().id()+"}"),c.name=b.name(),this.comm().signalParent("eventchanged",c,this.current().id()))},signalEventTriggered:function(b,c){if(this.connected()){a.log("widget: signalEventTriggered {id: "+this.current().id()+"}");var d={name:b.name(),value:c};this.comm().signalParent("eventtriggered",d,this.current().id())}},handleReceiveParentStart:function(a){a=a||{};var b=a.connected!==!1;this.connectWidget(a.id,a.params,b),b&&this.signalStartAck(),this.startWidgetWithPageParams()},handleReceiveParentPropertyChange:function(a){a=a||{};a.type;if("param"==a.type&&"value"==a.propertyName&&null!=a.name){var b=this.current().param(a.name);null!=b&&b.value(a.value)}},handleReceiveParentActionInvoke:function(a){a=a||{};var b=a.action,c=this.current().action(b);null!=c&&c.external()&&c.invokeApply(a.args)},handleReceiveParentEventTrigger:function(a){a=a||{};var b=a.event,c=this.current().event(b);null!=c&&c.external()&&c.trigger(a.data)}},this.svidget=new a.Root(this)}).call(this);