(function(){"use strict";var t=['<div class="u8-padding">',"{{if bindings.length}}",'<table class="u8-table spaced alternate lined-header">',"<thead>","<tr>",'{{if !readonly}}<th class="actions"></th>{{/if}}','<th class="sourcepath">Source</th>','<th class="arrow"></th>','<th class="targetpath">Target <span class="u8-comment">(this ${itemKind})</span></th>',"</tr>","</thead>","<tbody>","{{each bindings}}",'<tr title="${explanation}" data-helpcontenttype="text/x-markdown">',"{{if !readonly}}",'<td class="actions"><button class="u8-imagebutton" data-command="remove" title="Remove Binding">{{image "u8-img-propertygrid-remove-s"}}</button></td>',"{{/if}}",'<td class="sourcepath">','{{if sourcePath}}<span class="path">${sourcePath}</span>{{/if}}',"{{if !sourcePath}}source path missing{{/if}}","</td>",'<td class="arrow">${arrow}</td>','<td class="targetpath">','{{if targetPath}}<span class="path">${targetPath}</span>{{/if}}',"{{if !targetPath}}target path missing{{/if}}","</td>","</tr>","{{/each}}","</tbody>","</table>","{{if !readonly}}",'<table class="u8-table spaced" style="width: 100%">',"<tr><td>",'<button class="u8-imagebutton" data-command="add" title="Add Binding">{{image "u8-img-propertygrid-add-s"}}</button>',"</td></tr>","</table>","{{/if}}","{{/if}}","{{if !bindings.length}}",'<p class="u8-comment" style="text-align:center;">',"There are no bindings yet.<br />"+"{{if !readonly}}",'Click <button class="u8-imagebutton" data-command="add" title="Add Binding">{{image "u8-img-propertygrid-add-s"}}</button> to add a binding.',"{{/if}}","</p>","{{/if}}","</div>"].join("");u8.Base.Widgets.BindingsEditor=function(t,e){this.Widget(t,$.extend({},u8.Base.Widgets.BindingsEditor.defaults,e));this._create()};u8.Base.Widgets.BindingsEditor.makeClass({name:"BindingsEditor",deriveFrom:u8.Base.Widgets.Widget,events:["ValueChange"]});u8.Base.Widgets.BindingsEditor.defaults={};$.extend(u8.Base.Widgets.BindingsEditor.prototype,{setValue:function(t){this.value=t;this.raise("ValueChange")},getValue:function(){return this.value},update:function(){if(this.itemKind=="Widget"&&this.value){var t=this.value;for(var e=0;e<t.length;e++){var i=t[e];if(!i.targetPath||!i.sourcePath){t.splice(e,1)}}}var a=this._createViewModel(this.value);this._createView(a)},activate:function(){this.update()},_create:function(){var t=this;var e=this.$(this.element).addClass("u8-bindingseditor "+(this.readonly?"readonly":"editable"));if(!this.readonly){e.on("click","button",function(e){var i=this.getAttribute("data-command");if(!i){return}e.stopPropagation();if(i=="add"){t._add()}else if(i=="remove"){t._remove($$(this).closest("tr").index())}}).on("click","tr",function(){t._showEditor($$(this).closest("tr").index(),this)})}this.update()},_add:function(){this.value.push({sourcePath:[],targetPath:[],isDynamic:false,sourceToTarget:true,targetToSource:true});this._onValueChange()},_remove:function(t){if(t<0||t>=this.value.length){return}this.value.removeAt(t);this._onValueChange()},_showEditor:function(t,e){if(t<0||t>=this.value.length){return}var i=this,a=this.value[t];u8.Base.Widgets.BindingInput.showPopup({binding:a,parent:this,alignTo:e},function(e){i.value[t]=e;i._onValueChange()})},_onValueChange:function(){this.update();this.raise("ValueChange")},_createViewModel:function(t){var a=(t||[]).map(function(t){return{sourcePath:i(t.sourcePath),arrow:e(t),targetPath:i(t.targetPath),explanation:u8.Base.Widgets.BindingInput.getExplanation(t)}});return{itemKind:this.itemKind||"Widget",bindings:a,readonly:!!this.readonly}},_createView:function(e){this.$(this.element).utml({template:t,data:e,itemOptions:{parent:this}})}});function e(t){return(t.targetToSource!==false?"<":" ")+(t.isInit?"-":t.isDynamic===false?"=":"==")+(t.sourceToTarget!==false?">":" ")}function i(t){return t?t.join("."):""}})();