text: YUI().use(function(e){var t={groups:{wireit:{base:"wireit/src/",combine:!1,modules:{"arrow-wire":{requires:["wire-base"]},"bezier-wire":{requires:["wire-base"]},"bidirectional-arrow-wire":{requires:["arrow-wire"]},container:{requires:["widget-stdmod","widget-stack","widget-parent","widget-child","dd","resize","wires-delegate","widget-terminals","widget-icons"],skinnable:!0},"image-container":{requires:["container"],skinnable:!0},"inout-container":{requires:["container","terminal-input","terminal-output"],skinnable:!0},layer:{requires:["widget-parent","container","wires-delegate"],skinnable:!0},"straight-wire":{requires:["wire-base"]},terminal:{requires:["widget","widget-child","widget-position","widget-position-align","wire-base","wires-delegate","terminal-dragedit","terminal-scissors","terminal-ddgroups"],skinnable:!0},"terminal-ddgroups":{requires:["terminal-dragedit"]},"terminal-dragedit":{requires:["bezier-wire","dd-drop","dd-drag","dd-proxy"]},"terminal-input":{requires:["terminal"]},"terminal-output":{requires:["terminal"]},"terminal-scissors":{requires:["overlay"],skinnable:!0},"textarea-container":{requires:["container"]},"widget-icons":{requires:[],skinnable:!0},"widget-terminals":{requires:["terminal"]},"wire-base":{requires:["graphics"],skinnable:!0},"wireit-app":{requires:["app","handlebars","model","model-list","json","view","layer","bezier-wire","anim"]},"wires-delegate":{requires:["wire-base"]}}}}};typeof YUI_config=="undefined"&&(YUI_config={groups:{}}),e.mix(YUI_config.groups,t.groups)}),YUI.add("arrow-wire",function(e,t){"use strict";e.ArrowWire=function(t){e.ArrowWire.superclass.constructor.apply(this,arguments)},e.ArrowWire.NAME="arrowwire",e.extend(e.ArrowWire,e.WireBase,{_drawArrow:function(e,t){var n=7,r=Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)),i=20,s=r===0?0:1-i/r,o=[Math.abs(e[0]+s*(t[0]-e[0])),Math.abs(e[1]+s*(t[1]-e[1]))],u=e[0]-t[0],a=e[1]-t[1],f=e[0]*t[1]-e[1]*t[0],l,c,h,p,d,v,m,g,y,b,w,E,S;u!==0?(l=a/u,c=f/u):l=0,l===0?h=0:h=-1/l,p=o[1]-h*o[0],d=1+Math.pow(h,2),v=2*h*p-2*o[0]-2*o[1]*h,m=-2*o[1]*p+Math.pow(o[0],2)+Math.pow(o[1],2)-Math.pow(n,2)+Math.pow(p,2),g=Math.pow(v,2)-4*d*m;if(g<0)return;y=(-v+Math.sqrt(g))/(2*d),b=(-v-Math.sqrt(g))/(2*d),w=h*y+p,E=h*b+p,e[1]===t[1]&&(S=e[0]>t[0]?1:-1,y=t[0]+S*i,b=y,w-=n,E+=n),this.moveTo(t[0]+6,t[1]+6),this.lineTo(y+6,w+6),this.moveTo(t[0]+6,t[1]+6),this.lineTo(b+6,E+6)},_draw:function(){this.clear();var e=this.get("src").getXY(),t=this.get("tgt").getXY();this.moveTo(e[0]+6,e[1]+6),this.lineTo(t[0]+6,t[1]+6),this._drawArrow(e,t),this.end()}}),e.ArrowWire.ATTRS=e.merge(e.WireBase.ATTRS,{})},"@VERSION@",{requires:["wire-base"]}),YUI.add("bezier-wire",function(e,t){e.BezierWire=function(t){e.BezierWire.superclass.constructor.apply(this,arguments)},e.BezierWire.NAME="bezierwire",e.extend(e.BezierWire,e.WireBase,{_draw:function(){this.clear();var e=this.get("src").getXY(),t=this.get("tgt").getXY(),n=this.get("srcDir"),r=this.get("tgtDir"),i=this.get("bezierTangentNorm"),s=7;this.moveTo(e[0]+s,e[1]+s),this.curveTo(e[0]+s+n[0]*i,e[1]+s+n[1]*i,t[0]+s+r[0]*i,t[1]+s+r[1]*i,t[0]+s,t[1]+s),this.end()},SERIALIZABLE_ATTRS:function(){return["color","width","bezierTangentNorm"]}}),e.BezierWire.ATTRS=e.merge(e.WireBase.ATTRS,{bezierTangentNorm:{setter:function(e){return parseInt(e,10)},value:100}})},"@VERSION@",{requires:["wire-base"]}),YUI.add("bidirectional-arrow-wire",function(e,t){e.BidirectionalArrowWire=function(t){e.BidirectionalArrowWire.superclass.constructor.apply(this,arguments)},e.BidirectionalArrowWire.NAME="bidirectionalarrowwire",e.extend(e.BidirectionalArrowWire,e.ArrowWire,{_draw:function(){this.clear();var e=this.get("src").getXY(),t=this.get("tgt").getXY();this.moveTo(e[0]+6,e[1]+6),this.lineTo(t[0]+6,t[1]+6),this._drawArrow(e,t),this._drawArrow(t,e),this.end()}}),e.BidirectionalArrowWire.ATTRS=e.merge(e.ArrowWire.ATTRS,{})},"@VERSION@",{requires:["arrow-wire"]}),YUI.add("container",function(e,t){"use strict";e.Container=e.Base.create("container",e.Widget,[e.WidgetStdMod,e.WidgetStack,e.WidgetParent,e.WidgetChild,e.WiresDelegate,e.WidgetTerminals,e.WidgetIcons],{renderUI:function(){this._renderDrag(),this._renderResize()},bindUI:function(){this.resize&&this.resize.on("resize:resize",this._onResize,this),this.drag.on("drag:drag",function(){this.redrawAllWires()},this)},syncUI:function(){e.later(0,this,function(){this.alignTerminals()})},_renderDrag:function(){this.drag=new e.DD.Drag({node:this.get("boundingBox"),handles:[this._findStdModSection(e.WidgetStdMod.HEADER)]})},_renderResize:function(){if(!this.get("resizable"))return;this.resize=new e.Resize({node:this.get("contentBox"),handles:"br"})},_onResize:function(e){this._fillHeight(),this.alignTerminals();var t=this.get("boundingBox").get("region");this.set("width",e.details[0].info.offsetWidth),this.set("height",e.details[0].info.offsetHeight)},_onCloseClick:function(){this.destroy()},SERIALIZABLE_ATTRS:function(){var e=["x","y"];return this.get("resizable")&&(e.push("width"),e.push("height")),e},toJSON:function(){var t={},n=this;return e.Array.each(this.SERIALIZABLE_ATTRS(),function(e){t[e]=n.get(e)}),t},destructor:function(){this.drag.destroy(),this.resize&&this.resize.destroy()}},{ATTRS:{x:{lazyAdd:!1,getter:function(){return parseInt(this.get("boundingBox").getStyle("left"),10)},setter:function(e){this.get("boundingBox").setStyle("left",e)},validator:function(t){return e.Lang.isNumber(t)}},y:{lazyAdd:!1,getter:function(){return parseInt(this.get("boundingBox").getStyle("top"),10)},setter:function(e){this.get("boundingBox").setStyle("top",e)},validator:function(t){return e.Lang.isNumber(t)}},zIndex:{value:5},resizable:{value:!0},fillHeight:{value:!0},preventSelfWiring:{value:!0},icons:{value:[{title:"close",click:"_onCloseClick",className:"ui-silk ui-silk-cancel"}]}}})},"@VERSION@",{requires:["widget-stdmod","widget-stack","widget-parent","widget-child","dd","resize","wires-delegate","widget-terminals","widget-icons"],skinnable:!0}),YUI.add("image-container"
  ,function(e,t){e.ImageContainer=e.Base.create("image-container",e.Container,[],{renderUI:function(){this.image=e.Node.create('<img src="'+this.get("imageUrl")+'" width="'+this.get("width")+'"  height="'+this.get("height")+'"/>'),this.image.appendTo(this.get("contentBox")),e.ImageContainer.superclass.renderUI.apply(this),this.resize&&this.get("resizePreserveRatio")&&this.resize.plug(e.Plugin.ResizeConstrained,{preserveRatio:!0})},bindUI:function(){this.image.after("load",this.alignTerminals,this),this.resize&&this.resize.after("resize:resize",this._onResizeImage,this),this.drag.set("handles",[this.image]),e.ImageContainer.superclass.bindUI.apply(this)},_onResizeImage:function(e){var t=e.details[0].info;this.image.set("width",t.right-t.left),this.image.set("height",t.bottom-t.top)}},{ATTRS:{imageUrl:{value:"",setter:function(e){this.image&&this.image.set("src",e)}},resizePreserveRatio:{value:!0}}})},"@VERSION@",{requires:["container"],skinnable:!0}),YUI.add("inout-container",function(e,t){e.InOutContainer=e.Base.create("inout-container",e.Container,[],{renderUI:function(){e.InOutContainer.superclass.renderUI.call(this),this._renderInputsOutputs()},_renderInputsOutputs:function(){this.setStdModContent(e.WidgetStdMod.BODY,"<ul class='inputs'></ul><ul class='outputs'></ul>");var t=this.get("boundingBox"),n=t.one("ul.inputs"),r=t.one("ul.outputs"),i=this.get("inputs"),s=this.get("outputs"),o,u;for(o=0,u=i.length;o<u;o++)e.Node.create("<li>"+i[o].label+"</li>").appendTo(n),this.add({type:"TerminalInput",name:i[o].name,dir:[-0.3,0]});for(o=0,u=s.length;o<u;o++)e.Node.create("<li>"+s[o].label+"</li>").appendTo(r),this.add({type:"TerminalOutput",name:s[o].name,dir:[.3,0]});e.later(100,this,function(){var t,o;for(t=0;t<i.length;t++)this.item(t).align(n.all("li").item(t),[e.WidgetPositionAlign.TC,e.WidgetPositionAlign.LC]);for(t=0;t<s.length;t++)o=this.item(i.length+t),o.align(r.all("li").item(t),[e.WidgetPositionAlign.TL,e.WidgetPositionAlign.RC]),o.set("x",o.get("x")+11)})}},{ATTRS:{resizable:{value:!1},inputs:[],outputs:[]}})},"@VERSION@",{requires:["container","terminal-input","terminal-output"],skinnable:!0}),YUI.add("layer",function(e,t){e.Layer=e.Base.create("layer",e.Widget,[e.WidgetParent,e.WiresDelegate],{initializer:function(){this.graphic=new e.Graphic({render:this.get("contentBox")})},clear:function(){this.removeAll()}},{ATTRS:{defaultChildType:{value:"Container"}}})},"@VERSION@",{requires:["widget-parent","container","wires-delegate"],skinnable:!0}),YUI.add("straight-wire",function(e,t){e.StraightWire=function(t){e.StraightWire.superclass.constructor.apply(this,arguments)},e.StraightWire.NAME="straightwire",e.extend(e.StraightWire,e.WireBase,{_draw:function(){this.clear();var e=this.get("src").getXY(),t=this.get("tgt").getXY();this.moveTo(e[0]+6,e[1]+6),this.lineTo(t[0]+6,t[1]+6),this.end()}}),e.StraightWire.ATTRS=e.merge(e.WireBase.ATTRS,{})},"@VERSION@",{requires:["wire-base"]}),YUI.add("terminal",function(e,t){"use strict";e.Terminal=e.Base.create("terminal",e.Widget,[e.WidgetChild,e.WidgetPosition,e.WidgetPositionAlign,e.WiresDelegate,e.TerminalDragEdit,e.TerminalScissors,e.TerminalDDGroups],{syncUI:function(){this._syncOffset()},_syncOffset:function(){var e=this.get("offset");e&&(this._posNode.setStyle("left",e[0]),this._posNode.setStyle("top",e[1]),this.syncXY())},bindUI:function(){var e=this.get("boundingBox");e.on("mouseover",this._onMouseOver,this),e.on("mouseout",this._onMouseOut,this)},_onMouseOver:function(){e.later(300,this,this._showOverlay)},_showOverlay:function(){this.get("boundingBox").addClass(this.getClassName("show-overlay"))},_onMouseOut:function(){e.later(300,this,this._hideOverlay)},_hideOverlay:function(){var e=this.get("boundingBox");e&&e.removeClass(this.getClassName("show-overlay"))},_onAddWire:function(e){this.get("boundingBox").addClass(this.getClassName("connected"))},_onRemoveWire:function(e){this._wires.length===0&&this.get("boundingBox").removeClass(this.getClassName("connected"))},getXY:function(){var e=this.get("parent"),t=e.get("parent"),n=t.get("boundingBox").getXY(),r=this.get("contentBox").getXY();return[r[0]-n[0]+7.5,r[1]-n[1]+7.5]}},{ATTRS:{name:{value:null},dir:{value:[0,1]},alignNode:{value:null},offset:{value:null,validator:function(e){return this._validateXY(e)}}}})},"@VERSION@",{requires:["widget","widget-child","widget-position","widget-position-align","wire-base","wires-delegate","terminal-dragedit","terminal-scissors","terminal-ddgroups"],skinnable:!0}),YUI.add("terminal-ddgroups",function(e,t){e.TerminalDDGroups=function(t){e.after(this._renderUIgroups,this,"renderUI"),e.after(this._showOverlayDDGroups,this,"_showOverlay")},e.TerminalDDGroups.ATTRS={showGroups:{value:!0}},e.TerminalDDGroups.prototype={_renderUIgroups:function(){this.get("editable")&&this._renderTooltip()},_renderTooltip:function(){this.get("showGroups")&&(this._ddGroupsOverlay=new e.Overlay({render:this.get("boundingBox"),bodyContent:this.get("ddGroupsDrag").join(",")}),this._ddGroupsOverlay.get("contentBox").addClass(this.getClassName("dd-groups")))},_showOverlayDDGroups:function(){this._ddGroupsOverlay.align(this.get("contentBox"),[e.WidgetPositionAlign.TC,e.WidgetPositionAlign.BC])}}},"@VERSION@",{requires:["terminal-dragedit"]}),YUI.add("terminal-dragedit",function(e,t){e.TerminalDragEdit=function(t){e.after(this._renderUIdragedit,this,"renderUI"),e.after(this._bindUIdragedit,this,"bindUI");var n={color:{value:"rgb(173,216,230)"},weight:{value:4},opacity:{value:1},dashstyle:{value:"none"},fill:{value:"rgb(255,255,255)"},"editwire-class":{value:e.BezierWire}};this.addAttrs(n,t)},e.TerminalDragEdit.ATTRS={editable:{value:!0},graphic:{value:null},alwaysSrc:{value:!1},ddGroupsDrag:{value:["terminal"]},ddGroupsDrop:{value:["terminal"]}},e.TerminalDragEdit.prototype={_renderUIdragedit:function(){if(this.get("editable")){this.get("contentBox").addClass(this.getClassName("editable"));var t=(new e.DD.Drag({node:this.get("contentBox"),groups:this.get("ddGroupsDrag")})).plug(e
  .Plugin.DDProxy,{cloneNode:!0,moveOnEnd:!1});this.drag=t;var n=new e.DD.Drop({node:this.get("contentBox"),groups:this.get("ddGroupsDrop")});n.terminal=this,this.drop=n}},_bindUIdragedit:function(){var e=this.drag;e&&(e.on("drag:start",this._onDragEditStart,this),e.on("drag:drag",this._onDragEditDrag,this),e.on("drag:drophit",this._onDragEditDrophit,this),e.on("drag:dropmiss",this._onDragEditDropmiss,this),e.on("drag:enter",this._onDragEditEnter,this),e.on("drag:exit",this._onDragEditExit,this))},_onDragEditStart:function(e){this._editwireX=e.pageX,this._editwireY=e.pageY;var t=this.get("dir"),n=this;this.get("graphic")||this.set("graphic",this.get("root").graphic);var r=this.get("parent"),i=r.get("parent"),s=i.get("boundingBox").getXY();this.drag.wire=this.get("graphic").addShape({type:this.get("editwire-class"),stroke:{weight:this.get("weight"),color:this.get("color"),opacity:this.get("opacity"),dashstyle:this.get("dashstyle"),fill:this.get("fill")},src:{getXY:function(){return[e.pageX-s[0]+7.5,e.pageY-s[1]+7.5]}},tgt:{getXY:function(){return[n._magnetX||n._editwireX-s[0]+7.5,n._magnetY||n._editwireY-s[1]+7.5]}},srcDir:t,tgtDir:[-t[0],-t[1]]})},_onDragEditDrag:function(e){this._editwireX=e.pageX,this._editwireY=e.pageY,this.drag.wire._draw()},_onDragEditDrophit:function(e){this.isValidWireTerminal(e.drop.terminal)?(e.drop.terminal.alwaysSrc?(this.drag.wire.set("src",e.drop.terminal),this.drag.wire.set("tgt",this)):(this.drag.wire.set("src",this),this.drag.wire.set("tgt",e.drop.terminal)),this.drag.wire=null,this._magnetX=null,this._magnetY=null):this.drag.wire.destroy()},_onDragEditDropmiss:function(e){this.drag.wire.destroy(),this.drag.wire=null},_onDragEditEnter:function(e){var t=e.drop.terminal.getXY();this._magnetX=t[0],this._magnetY=t[1],this.drag.wire.set("tgtDir",e.drop.terminal.get("dir"))},_onDragEditExit:function(e){this._magnetX=null,this._magnetY=null},isValidWireTerminal:function(e){return this.get("parent")!==undefined&&this.get("parent").get("preventSelfWiring")&&e._parentNode._node==this._parentNode._node?!1:!0},destructor:function(){this.drag&&this.drag.destroy(),this.drop&&this.drop.destroy()}}},"@VERSION@",{requires:["bezier-wire","dd-drop","dd-drag","dd-proxy"]}),YUI.add("terminal-input",function(e,t){"use strict";e.TerminalInput=e.Base.create("terminal-input",e.Terminal,[],{getClassName:function(e){return"yui3-terminal-"+e}},{ATTRS:{dir:{value:[-0.3,0]},ddGroupsDrag:{value:["input"]},ddGroupsDrop:{value:["output"]}}})},"@VERSION@",{requires:["terminal"]}),YUI.add("terminal-output",function(e,t){"use strict";e.TerminalOutput=e.Base.create("terminal-output",e.Terminal,[],{getClassName:function(e){return"yui3-terminal-"+e}},{ATTRS:{dir:{value:[.3,0]},ddGroupsDrag:{value:["output"]},ddGroupsDrop:{value:["input"]}}})},"@VERSION@",{requires:["terminal"]}),YUI.add("terminal-scissors",function(e,t){e.TerminalScissors=function(t){e.after(this._renderUIScissors,this,"renderUI"),e.after(this._bindUIScissors,this,"bindUI")},e.TerminalScissors.ATTRS={dirNormed:{getter:function(){var e=this.get("dir"),t=e[0],n=e[1],r=Math.sqrt(t*t+n*n);return[e[0]/r,e[1]/r]}},scissorsDistance:{value:30}},e.TerminalScissors.prototype={_renderUIScissors:function(){this.get("editable")&&this._renderScissors()},_bindUIScissors:function(){this.get("editable")&&this._scissorsOverlay.get("boundingBox").on("click",this.destroyWires,this)},_renderScissors:function(){this._scissorsOverlay=new e.Overlay({}),this._scissorsOverlay.get("contentBox").addClass(this.getClassName("scissors"));var t=this.get("xy"),n=this.get("dirNormed"),r=this.get("scissorsDistance");this._scissorsOverlay.set("x",t[0]+n[0]*r-8),this._scissorsOverlay.set("y",t[1]+n[1]*r-8),this._scissorsOverlay.render(this.get("boundingBox"))}}},"@VERSION@",{requires:["overlay"],skinnable:!0}),YUI.add("textarea-container",function(e,t){e.TextareaContainer=e.Base.create("textarea-container",e.Container,[],{SERIALIZABLE_ATTRS:function(){return e.TextareaContainer.superclass.SERIALIZABLE_ATTRS.call(this).concat(["value"])},renderUI:function(){e.TextareaContainer.superclass.renderUI.call(this),this.setStdModContent(e.WidgetStdMod.BODY,"<textarea></textarea>"),this._bodyNode=this.getStdModNode(e.WidgetStdMod.BODY),this._textarea=this._bodyNode.one("textarea")},bindUI:function(){e.TextareaContainer.superclass.bindUI.call(this),this.resize&&this.resize.after("resize:resize",this._afterResizeTextarea,this)},_fillTextareaSize:function(){this.fillHeight(this._bodyNode);var e=this._bodyNode.get("region");this._textarea.setStyle("height",e.height),this._textarea.setStyle("width",e.width)},_afterResizeTextarea:function(e){this._fillTextareaSize()},syncUI:function(){e.TextareaContainer.superclass.syncUI.call(this),this.getStdModNode(e.WidgetStdMod.BODY).one("textarea").set(this.get("value")),e.later(0,this,function(){this._fillTextareaSize()})}},{ATTRS:{value:{getter:function(){return this.getStdModNode(e.WidgetStdMod.BODY).one("textarea").get("value")},setter:function(t){this.getStdModNode(e.WidgetStdMod.BODY).one("textarea").set("value",t)}}}})},"@VERSION@",{requires:["container"]}),YUI.add("widget-icons",function(e,t){e.WidgetIcons=function(t){e.after(this._renderUIicons,this,"renderUI")},e.WidgetIcons.ATTRS={icons:{value:[]}},e.WidgetIcons.prototype={_renderUIicons:function(){e.Array.each(this.get("icons"),e.bind(this._renderUIicon,this))},_renderUIicon:function(t){var n=e.Node.create('<span class="yui3-widget-icons-icon '+this.getClassName("icon")+" "+t.className+'" title="'+t.title+'"></span>');n.on("click",e.bind(this[t.click],this)),n.appendTo(this.get("contentBox"))}}},"@VERSION@",{requires:[],skinnable:!0}),YUI.add("wire-base",function(e,t){e.WireBase=function(t){e.WireBase.superclass.constructor.apply(this,arguments)},e.WireBase.NAME="wirebase",e.extend(e.WireBase,e.Path,{initializer:function(){e.WireBase.superclass.initializer.apply(this,arguments);var t=this.get("src"),n=this.get("tgt");t&&t.get&&this.set("srcDir",t.get("dir")),n&&n.get&&this.set("tgtDir"
  ,n.get("dir")),t&&e.Lang.isFunction(t.addWire)&&t.addWire(this),n&&e.Lang.isFunction(n.addWire)&&n.addWire(this)},bindUI:function(){e.ArrowWire.superclass.bindUI.call(this),this.on("srcChange",function(e){this.set("srcDir",e.newVal.get("dir"))},this),this.on("tgtChange",function(e){this.set("tgtDir",e.newVal.get("dir"))},this)},destroy:function(){e.WireBase.superclass.destroy.apply(this,arguments);var t=this.get("src"),n=this.get("tgt");t&&e.Lang.isFunction(t.removeWire)&&t.removeWire(this),n&&e.Lang.isFunction(n.removeWire)&&n.removeWire(this)},_draw:function(){},getOtherTerminal:function(e){return e===this.get("src")?this.get("tgt"):this.get("src")},toJSON:function(){return{}}}),e.WireBase.ATTRS=e.merge(e.Path.ATTRS,{src:{value:null,setter:function(t){return t&&e.Lang.isFunction(t.addWire)&&t.addWire(this),t}},tgt:{value:null,setter:function(t){return t&&e.Lang.isFunction(t.addWire)&&t.addWire(this),t}},srcDir:{validator:e.Lang.isArray,value:[1,0]},tgtDir:{validator:e.Lang.isArray,valueFn:function(){var e=this.get("srcDir");return[-e[0],-e[1]]}}})},"@VERSION@",{requires:["graphics"],skinnable:!0}),YUI.add("wireit-app",function(e,t){function n(t){function i(e){var t;if(t=r[e])delete r[e],u();return t}function s(){var e="",t=4;while(t--)e+=((1+Math.random())*65536|0).toString(16).substring(1);return e}function o(t){return t?r[t]:e.Object.values(r)}function u(){n&&n.setItem(t,e.JSON.stringify(r))}function a(t){var n=t.toJSON(),i=t.idAttribute;return e.Lang.isValue(n[i])||(n[i]=s()),r[n[i]]=n,u(),n}var n;t||e.error("No storage key specified."),e.config.win.localStorage&&(n=e.config.win.localStorage);var r=e.JSON.parse(n&&n.getItem(t)||"{}");return function(t,n,r){var s=e.Model&&this instanceof e.Model;switch(t){case"create":case"update":r(null,a(this));return;case"read":r(null,o(s&&this.get("id")));return;case"delete":r(null,i(s&&this.get("id")));return}}}e.WiringModel=e.Base.create("wiringModel",e.Model,[],{sync:n("wireit-app")},{ATTRS:{id:{value:null},name:{value:""},containers:{value:[]},description:{value:""},wires:{value:[]}}}),e.WiringModelList=e.Base.create("wiringModelList",e.ModelList,[],{sync:n("wireit-app"),model:e.WiringModel}),e.WiringListView=e.Base.create("wiringListView",e.View,[],{template:e.Handlebars.compile(e.one("#t-wiring-list").getContent()),render:function(){var e=this.template({wirings:this.get("modelList").toJSON()});return this.get("container").setContent(e),this}}),e.ContainerType=e.Base.create("containerModel",e.Model,[],{idAttribute:"name"},{ATTRS:{name:{value:null},description:{value:null},config:{value:null}}}),e.ContainerTypeList=e.Base.create("containerTypeList",e.ModelList,[],{model:e.ContainerType}),e.EditorView=e.Base.create("editorView",e.View,[],{template:e.Handlebars.compile(e.one("#t-editor").getContent()),events:{"#wiring-save-btn":{click:"saveWiring"}},render:function(){var t=this.template({containerTypes:this.get("containerTypes").toJSON()});this.get("container").setContent(t);var n=this;return this.get("container").all(".containerType-name").each(function(t){var r=(new e.DD.Drag({node:t,groups:["containerType"]})).plug(e.Plugin.DDProxy,{cloneNode:!0,moveOnEnd:!1});r._containerTypeName=t._node.attributes["app-container-name"].value,r.on("drag:drophit",function(e){var t=n.layer.get("boundingBox").getXY();n._addContainerFromName(e.drag._containerTypeName,{x:e.drag.lastXY[0]-t[0],y:e.drag.lastXY[1]-t[1]})},this)}),this._renderLayer(),this},_renderLayer:function(){this.layer=new e.Layer({height:500});var t=new e.DD.Drop({node:this.layer.get("contentBox"),groups:["containerType"]});this.layer.render(this.get("container").one("#layer-container"));var n=this.get("model");n&&this.setWiring(n)},saveWiring:function(t){var n={name:e.one("#wiring-name").get("value")||"Unnamed"};n.containers=[],e.Array.each(this.layer._items,function(e){n.containers.push({containerType:e.containerTypeName,config:e.toJSON()})}),n.wires=[];var r=this.layer;e.Array.each(this.layer._wires,function(e){var t=e.get("src"),i=e.get("tgt");n.wires.push({src:{container:r._items.indexOf(t.get("parent")),terminal:t.get("name")},tgt:{container:r._items.indexOf(i.get("parent")),terminal:i.get("name")},config:e.toJSON()})}),this.get("model")?this.get("model").setAttrs(n):this.set("model",new e.WiringModel(n)),this.get("model").save();var i=e.Node.create('<div class="alert-message bg-warning" style="width: 300px; z-index: 10001;"><p>Saved !</p></div>').appendTo(document.body),s=new e.Anim({node:i,duration:.5,easing:e.Easing.easeOut,from:{xy:[400,-50]},to:{xy:[400,2]}});s.on("end",function(){e.later(1e3,this,function(){(new e.Anim({node:i,duration:.5,easing:e.Easing.easeOut,to:{xy:[400,-50]}})).run()})}),s.run()},setWiring:function(t){var n=this,r=this.layer;e.Array.each(t.get("containers"),function(r){n._addContainerFromName(r.containerType,r.config),e.on("available",function(n){e.one("#wiring-name").set("value",t.get("name"))},"#wiring-name")}),e.Array.each(t.get("wires"),function(t){if(!t.src||!t.tgt)return;var n=r.item(t.src.container),i=n.getTerminal(t.src.terminal),s=r.item(t.tgt.container),o=s.getTerminal(t.tgt.terminal),u=r.graphic.addShape({type:e.BezierWire,stroke:{weight:4,color:"rgb(173,216,230)"},src:i,tgt:o})}),e.later(200,this,function(){r.redrawAllWires()})},_addContainerFromName:function(t,n){var r=this.get("containerTypes").getById(t),i=e.mix({},r.get("config"));i=e.mix(i,n),this.layer.add(i);var s=this.layer.item(this.layer.size()-1);s.containerTypeName=t}},{ATTRS:{containerTypes:{value:null}}}),e.WireItApp=new e.Base.create("contributorsApp",e.App,[],{views:{editorPage:{type:e.EditorView},wiringListPage:{type:e.WiringListView}},initializer:function(){this.on("navigate",this.indicateLoading),this.once("ready",function(e){this.hasRoute(this.getPath())?this.dispatch():this.showWiringListPage()})},indicateLoading:function(e){this.get("activeView").get("container").addClass("loading")},handleWiring:function(e,t,n){var r=e.params.wiring,i=this.get("modelList"),s=i.getById(r);this.
  set("wiring",s),n()},showEditorPage:function(){this.showView("editorPage",{containerTypes:this.get("containerTypes"),wirings:this.get("modelList"),model:this.get("wiring")})},blankEditorPage:function(){this.showView("editorPage",{containerTypes:this.get("containerTypes"),wirings:this.get("modelList"),model:null})},showWiringListPage:function(){var t=new e.WiringModelList;t.load(),this.set("modelList",t),this.showView("wiringListPage",{modelList:this.get("modelList")})}},{ATTRS:{containerTypes:{value:new e.ContainerTypeList},modelList:{value:new e.WiringModelList},wiring:{value:null},routes:{value:[{path:"/",callback:"showWiringListPage"},{path:"/wirings/:wiring/*",callback:"handleWiring"},{path:"/wirings/:wiring/edit",callback:"showEditorPage"},{path:"/wirings/new",callback:"blankEditorPage"}]}}})},"@VERSION@",{requires:["app","handlebars","model","model-list","json","view","layer","bezier-wire","anim"]}),YUI.add("wires-delegate",function(e,t){e.WiresDelegate=function(){this._wires=[],this.publish("addWire"),this.publish("removeWire"),this.on("*:addWire",this._onAddWire,this),this.on("*:removeWire",this._onRemoveWire,this)},e.WiresDelegate.ATTRS={},e.WiresDelegate.prototype={_wireFromEvent:function(e){var t=e;while(!!t._event)t=t.details[0];return t},_onAddWire:function(e){this.addWire(this._wireFromEvent(e))},_onRemoveWire:function(e){this.removeWire(this._wireFromEvent(e))},addWire:function(t){var n=e.Array.indexOf(this._wires,t);n===-1&&(this._wires.push(t),this.fire("addWire",t))},removeWire:function(t){var n=e.Array.indexOf(this._wires,t),r,i;n!==-1&&(r=this._wires,this._wires=[],i=this._wires,e.Array.each(r,function(e){e!==t&&i.push(e)}),this.fire("removeWire",t))},destroyWires:function(){this._wires&&e.Array.each(this._wires,function(e){e.destroy()})},getConnected:function(){var e=[],t,n;if(this._wires)for(t=0,n=this._wires.length;t<n;t++)e.push(this._wires[t].getOtherTerminal(this));return e},redrawAllWires:function(){this._wires&&e.Array.each(this._wires,function(e){e._draw()})},destructor:function(){this.destroyWires()}}},"@VERSION@",{requires:["wire-base"]}),YUI.add("wireit-all",function(e,t){},"@VERSION@");
  